终端一体化运控平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

DosingLogicControl.cs 244 KiB

2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382
  1. using BPASmartClient.AGV;
  2. using BPASmartClient.AGV.Enums;
  3. using BPASmartClient.AGV.Feedback;
  4. using BPASmartClient.CustomResource.Pages.Model;
  5. using BPASmartClient.Helper;
  6. using BPASmartClient.HubHelper;
  7. using FryPot_DosingSystem.Model;
  8. using FryPot_DosingSystem.ViewModel;
  9. using Newtonsoft.Json;
  10. using System;
  11. using System.Collections.Concurrent;
  12. using System.Collections.Generic;
  13. using System.Collections.ObjectModel;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Threading;
  17. using System.Threading.Tasks;
  18. using System.Windows.Media;
  19. using System.Windows;
  20. using FryPot_DosingSystem.AGV;
  21. using FryPot_DosingSystem.FryPotStatus;
  22. using System.IO;
  23. using System.Runtime.Serialization.Formatters.Binary;
  24. using System.Diagnostics;
  25. namespace FryPot_DosingSystem.Control
  26. {
  27. internal class DosingLogicControl
  28. {
  29. public static DosingLogicControl _instance;
  30. public static DosingLogicControl GetInstance => _instance ??= new DosingLogicControl();
  31. /// <summary>
  32. /// 滚筒线PLC数据
  33. /// </summary>
  34. public ConcurrentDictionary<string, object> PlcReadData = new ConcurrentDictionary<string, object>();
  35. public ConcurrentDictionary<string, object> FryOneData = new ConcurrentDictionary<string, object>();
  36. public ConcurrentDictionary<string, object> FryTwoData = new ConcurrentDictionary<string, object>();
  37. public ConcurrentDictionary<string, object> FryThreeData = new ConcurrentDictionary<string, object>();
  38. public ConcurrentDictionary<string, object> FryFourData = new ConcurrentDictionary<string, object>();
  39. public ConcurrentDictionary<string, object> FryFiveData = new ConcurrentDictionary<string, object>();
  40. /// <summary>
  41. /// 线体1配方队列
  42. /// </summary>
  43. public ConcurrentQueue<NewRecipeModel> RecipeQuene = new ConcurrentQueue<NewRecipeModel>();
  44. /// <summary>
  45. /// 线体2配方队列
  46. /// </summary>
  47. public ConcurrentQueue<NewRecipeModel> LTwoRecipeQuene = new ConcurrentQueue<NewRecipeModel>();
  48. /// <summary>
  49. /// 线体3配方队列
  50. /// </summary>
  51. public ConcurrentQueue<NewRecipeModel> LThreeRecipeQuene = new ConcurrentQueue<NewRecipeModel>();
  52. /// <summary>
  53. /// 线体1进料原料队列
  54. /// </summary>
  55. public ConcurrentQueue<MaterialInfo> InputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  56. /// <summary>
  57. /// 线体2进料原料队列
  58. /// </summary>
  59. public ConcurrentQueue<MaterialInfo> LTwoInputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  60. /// <summary>
  61. /// 线体3进料原料队列
  62. /// </summary>
  63. public ConcurrentQueue<MaterialInfo> LThreeInputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  64. /// <summary>
  65. /// 线体1出料原料队列
  66. /// </summary>
  67. public ConcurrentQueue<MaterialInfo> OutputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  68. /// <summary>
  69. /// 线体2出料原料队列
  70. /// </summary>
  71. public ConcurrentQueue<MaterialInfo> LTwoOutputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  72. /// <summary>
  73. /// 线体3出料原料队列
  74. /// </summary>
  75. public ConcurrentQueue<MaterialInfo> LThreeOutputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  76. /// <summary>
  77. /// 全局变量对象声明
  78. /// </summary>
  79. GlobalVariable globalVar;
  80. /// <summary>
  81. /// 线体状态对象声明
  82. /// </summary>
  83. HardWareStatusViewModel hardWareStatusModel;
  84. ///// <summary>
  85. ///// 炒锅1状态
  86. ///// </summary>
  87. //PotOneStatus fryOne;
  88. ///// <summary>
  89. ///// 炒锅2状态
  90. ///// </summary>
  91. //PotTwoStatus fryTwo;
  92. ///// <summary>
  93. ///// 炒锅3状态
  94. ///// </summary>
  95. //PotThreeStatus fryThree;
  96. ///// <summary>
  97. ///// 炒锅4状态
  98. ///// </summary>
  99. //PotFourStatus fryFour;
  100. ///// <summary>
  101. ///// 炒锅5状态
  102. ///// </summary>
  103. //PotFiveStatus fryFive;
  104. /// <summary>
  105. /// 报警信息对象声明
  106. /// </summary>
  107. #region 上位机内部变量
  108. int FryPotAlarm = 0;//炒锅1滚筒故障信号 1:无故障 -1:故障
  109. int FryPotTwoAlarm = 0;//炒锅2滚筒故障信号 1:无故障 -1:故障
  110. int FryPotThreeAlarm = 0;//炒锅3滚筒故障信号 1:无故障 -1:故障
  111. int FryPotFourAlarm = 0;//炒锅4滚筒故障信号 1:无故障 -1:故障
  112. int FryPotFiveAlarm = 0;//炒锅5滚筒故障信号 1:无故障 -1:故障
  113. int ReicpeNum = 0;//记录接收到的配方数
  114. bool ErrorRecipe;//线体1错误配方标识
  115. bool LTwoErrorRecipe;//线体2错误配方标识
  116. bool LThreeErrorRecipe;//线体3错误配方标识
  117. string fryOneRecipe = string.Empty;
  118. string fryTwoRecipe = string.Empty;
  119. string fryThreeRecipe = string.Empty;
  120. string fryFourRecipe = string.Empty;
  121. string fryFiveRecipe = string.Empty;
  122. #endregion
  123. #region agv临时变量
  124. //bool agvArriveUpLoad = false;//agv是否到达线体1上料位置
  125. //bool agvArriveLTwoUpLoad = false;//agv是否到达线体2上料位置
  126. //bool agvArriveLThreeUpLoad = false;//agv是否到达线体3上料位置
  127. //bool agvArriveUnLoad = false;//线体1 agv是否到达炒锅送料位置
  128. //bool LTwoagvArriveUnLoad = false;//线体2 agv是否到达炒锅送料位置
  129. //bool LThreeagvArriveUnLoad = false;//线体3 agv是否到达炒锅送料位置
  130. //bool agvFryPotEmptyRollerArrive = false;// 线体1的agv是否拿到炒锅空桶
  131. //bool LTwoagvFryPotEmptyRollerArrive = false; //线体2的agv是否拿到炒锅空桶
  132. //bool LThreeagvFryPotEmptyRollerArrive = false;//线体3的agv是否拿到炒锅空桶
  133. string LOnerobotJobId = string.Empty;//线体1当前上游系统任务号,全局唯一 从线体1到炒锅路径
  134. string LTworobotJobId = string.Empty;//线体2当前上游系统任务号,全局唯一 从线体2到炒锅路径
  135. string LThreerobotJobId = string.Empty;//线体3当前上游系统任务号,全局唯一 从线体3到炒锅路径
  136. string LFourrobotJobId = string.Empty;//线体4当前上游系统任务号,全局唯一 从炒锅1、4到线体4路径
  137. string LFiverobotJobId = string.Empty; //从炒锅2、5到线体4路径
  138. string LSixrobotJobId = string.Empty; //从炒锅3到线体4路径
  139. List<string> LSevenrobotJobId = new List<string>(); //从线体1到清洗台路径
  140. List<string> LEightrobotJobId = new List<string>();//从线体2到清洗台路径
  141. List<string> LNinerobotJobId = new List<string>(); //从线体3到清洗台路径
  142. List<string> LTenrobotJobId = new List<string>(); //从清洗台到线体4路径
  143. Dictionary<string, int> agvCode = new Dictionary<string, int>() { { "1", 1 }, { "2", 2 }, { "3", 3 }, { "4", 4 } };//agv小车的编号对AGV动画小车编号
  144. public int CleanNum = 0;//当前清洗台桶数
  145. #endregion
  146. /// <summary>
  147. /// 调试命令注册
  148. /// </summary>
  149. public void CommandRegist()
  150. {
  151. #region 线体空桶清洗及回收调试
  152. ActionManage.GetInstance.Register(new Action(() =>
  153. {
  154. globalVar.agvArriveLineOneLoadEmptyRoller = true;
  155. }), "AgvArriveLineOneEmptyRollerLoc");
  156. ActionManage.GetInstance.Register(new Action(() =>
  157. {
  158. globalVar.agvArriveLineTwoLoadEmptyRoller = true;
  159. }), "AgvArriveLineTwoEmptyRollerLoc");
  160. ActionManage.GetInstance.Register(new Action(() =>
  161. {
  162. globalVar.agvArriveLineThreeLoadEmptyRoller = true;
  163. }), "AgvArriveLineThreeEmptyRollerLoc");
  164. ActionManage.GetInstance.Register(new Action(() =>
  165. {
  166. globalVar.CleanComplete = 1;
  167. }), "CleanPlateCallAgv");
  168. ActionManage.GetInstance.Register(new Action(() =>
  169. {
  170. globalVar.rollerLineOne.agvArriveCleanUnLoad = true;//清洗台空桶下料就位
  171. globalVar.rollerLineTwo.agvArriveCleanUnLoad = true;
  172. globalVar.rollerLineThree.agvArriveCleanUnLoad = true;
  173. }), "AgvArriveCleanPlateLoc");
  174. ActionManage.GetInstance.Register(new Action(() =>
  175. {
  176. globalVar.agvArriveCleanLoad = true;//清洗台空桶上料就位
  177. }), "AgvArriveCleanPlateLocLoad");
  178. ActionManage.GetInstance.Register(new Action(() =>
  179. {
  180. globalVar.agvArriveLineFour = true;
  181. globalVar.rollerLineOne.agvArriveLineFour = true;
  182. globalVar.rollerLineTwo.agvArriveLineFour = true;
  183. globalVar.rollerLineThree.agvArriveLineFour = true;
  184. }), "AgvArriveLineFourLoc");
  185. ActionManage.GetInstance.Register(new Action(() =>
  186. {
  187. LineOneEmptyRollerCleanTaskRestart();
  188. }), "EmptyRollerCleanTaskRestart");
  189. ActionManage.GetInstance.Register(new Action(() =>
  190. {
  191. LineTwoEmptyRollerCleanTaskRestart();
  192. }), "LineTwoEmptyRollerCleanTaskRestart");
  193. ActionManage.GetInstance.Register(new Action(() =>
  194. {
  195. LineThreeEmptyRollerCleanTaskRestart();
  196. }), "LineThreeEmptyRollerCleanTaskRestart");
  197. #endregion
  198. //接口调试
  199. ActionManage.GetInstance.Register(new Action(() =>
  200. {
  201. string id = Guid.NewGuid().ToString();
  202. string errorCode = AGVHelper._Instance.AgvToLineOneLoadRoller(id);
  203. if (errorCode == "SUCCESS")
  204. {
  205. MessageLog.GetInstance.ShowRunLog($"AGV任务下发成功");
  206. }
  207. else if (errorCode == "Analysis Error")
  208. {
  209. MessageLog.GetInstance.ShowRunLog($"提示:AGV 调用API失败,请检查请求报文");
  210. }
  211. else
  212. {
  213. MessageLog.GetInstance.ShowRunLog($"提示:AGV任务下发失败,错误码:{errorCode}");
  214. }
  215. }), "AgvDebug");
  216. ActionManage.GetInstance.Register(() =>
  217. {
  218. MessageLog.GetInstance.ShowRunLog("清洗台卸桶完成");
  219. }, "AgvArriveCleanPlateLocCom");
  220. ActionManage.GetInstance.Register(() =>
  221. {
  222. MessageLog.GetInstance.ShowRunLog("清洗台空桶在【4】号线卸桶完成");
  223. MessageLog.GetInstance.ShowRunLog("【1】号线炒锅空桶在【4】号线卸桶完成");
  224. MessageLog.GetInstance.ShowRunLog("【2】号线炒锅空桶在【4】号线卸桶完成");
  225. MessageLog.GetInstance.ShowRunLog("【3】号线炒锅空桶在【4】号线卸桶完成");
  226. }, "AgvArriveLineFourLocCom");
  227. ActionManage.GetInstance.Register(() =>
  228. {
  229. MessageLog.GetInstance.ShowRunLog("清洗台空桶装载完成");
  230. }, "AgvArriveCleanPlateLocLoadCom");
  231. ActionManage.GetInstance.Register(() =>
  232. {
  233. globalVar.rollerLineOne.RecipeCompleteSingle = 1;
  234. }, "LineOneRecipeComSignal");
  235. ActionManage.GetInstance.Register(() =>
  236. {
  237. globalVar.rollerLineTwo.RecipeCompleteSingle = 1;
  238. }, "LineTwoRecipeComSignal");
  239. ActionManage.GetInstance.Register(() =>
  240. {
  241. globalVar.rollerLineThree.RecipeCompleteSingle = 1;
  242. }, "LineThreeRecipeComSignal");
  243. ActionManage.GetInstance.Register(new Action(() =>
  244. {
  245. globalVar.agvArriveLineOneLoadCom = true;
  246. }), "AgvLineOneLoadEmptyCom");
  247. ActionManage.GetInstance.Register(new Action(() =>
  248. {
  249. globalVar.agvArriveLineTwoLoadCom = true;
  250. }), "AgvLineTwoLoadEmptyCom");
  251. ActionManage.GetInstance.Register(new Action(() =>
  252. {
  253. globalVar.agvArriveLineThreeLoadCom = true;
  254. }), "AgvLineThreeLoadEmptyCom");
  255. ActionManage.GetInstance.Register(new Action(() =>
  256. {
  257. globalVar.rollerLineOne.CanRun = true;
  258. }), "AGVLineOneLoadCom");
  259. ActionManage.GetInstance.Register(new Action(() =>
  260. {
  261. globalVar.rollerLineTwo.CanRun = true;
  262. }), "AGVLineTwoLoadCom");
  263. ActionManage.GetInstance.Register(new Action(() =>
  264. {
  265. globalVar.rollerLineThree.CanRun = true;
  266. }), "AGVLineThreeLoadCom");
  267. ActionManage.GetInstance.Register(new Action(() =>
  268. {
  269. globalVar.rollerLineOne.OutMaterialingSingle = 1;
  270. }), "RollerLineRunning");
  271. ActionManage.GetInstance.Register(new Action<object>((obj) =>
  272. {
  273. globalVar.rollerLineOne.StationEight = (ushort)obj;
  274. }), "EightWorkLoc");
  275. ActionManage.GetInstance.Register(new Action(() =>
  276. {
  277. globalVar.fryPotOne.InputMaterialArrivedSingle = 1;
  278. globalVar.fryPotFour.InputMaterialArrivedSingle = 1;
  279. }), "FryPotInputArrive");
  280. ActionManage.GetInstance.Register(new Action(() =>
  281. {
  282. globalVar.fryPotOne.EmptyBarrelArrivedSingle = 1;
  283. globalVar.fryPotFour.EmptyBarrelArrivedSingle = 1;
  284. }), "FryPotEmptyRollerArrive");
  285. ActionManage.GetInstance.Register(new Action(() =>
  286. {
  287. globalVar.agvArriveUpLoad = true;
  288. }), "AGVLOneArrive");
  289. ActionManage.GetInstance.Register(new Action(() =>
  290. {
  291. globalVar.agvArriveUnLoad = true;
  292. }), "AGVFryPotDownArrive");
  293. ActionManage.GetInstance.Register(new Action(() =>
  294. {
  295. globalVar.agvArriveUpLoad = true;
  296. }), "AGVFryPotUpArrive");
  297. ActionManage.GetInstance.Register(new Action(() =>
  298. {
  299. globalVar.agvFryPotEmptyRollerArrive = true;
  300. }), "AGVFryPotGetEmptyRoller");
  301. //滚筒线2
  302. ActionManage.GetInstance.Register(new Action(() =>
  303. {
  304. globalVar.rollerLineTwo.OutMaterialingSingle = 1;
  305. }), "RollerLineTwoRunning");
  306. ActionManage.GetInstance.Register(new Action<object>((obj) =>
  307. {
  308. globalVar.rollerLineTwo.StationEight = (ushort)obj;
  309. }), "TwoEightWorkLoc");
  310. ActionManage.GetInstance.Register(new Action(() =>
  311. {
  312. globalVar.fryPotTwo.InputMaterialArrivedSingle = 1;
  313. globalVar.fryPotFive.InputMaterialArrivedSingle = 1;
  314. }), "FryPotTwoInputArrive");
  315. ActionManage.GetInstance.Register(new Action(() =>
  316. {
  317. globalVar.fryPotTwo.EmptyBarrelArrivedSingle = 1;
  318. globalVar.fryPotFive.EmptyBarrelArrivedSingle = 1;
  319. }), "FryPotTwoEmptyRollerArrive");
  320. ActionManage.GetInstance.Register(new Action(() =>
  321. {
  322. globalVar.agvArriveLTwoUpLoad = true;
  323. }), "AGVLTwoArrive");
  324. ActionManage.GetInstance.Register(new Action(() =>
  325. {
  326. globalVar.LTwoagvArriveUnLoad = true;
  327. }), "AGVFryPotTwoDownArrive");
  328. ActionManage.GetInstance.Register(new Action(() =>
  329. {
  330. globalVar.agvArriveLTwoUpLoad = true;
  331. }), "AGVFryPotTwoUpArrive");
  332. ActionManage.GetInstance.Register(new Action(() =>
  333. {
  334. globalVar.LTwoagvFryPotEmptyRollerArrive = true;
  335. }), "AGVFryPotTwoGetEmptyRoller");
  336. //滚筒线3
  337. ActionManage.GetInstance.Register(new Action(() =>
  338. {
  339. globalVar.rollerLineThree.OutMaterialingSingle = 1;
  340. }), "RollerLineThreeRunning");
  341. ActionManage.GetInstance.Register(new Action<object>((obj) =>
  342. {
  343. globalVar.rollerLineThree.StationEight = (ushort)obj;
  344. }), "ThreeEightWorkLoc");
  345. ActionManage.GetInstance.Register(new Action(() =>
  346. {
  347. globalVar.fryPotThree.InputMaterialArrivedSingle = 1;
  348. }), "FryPotThreeInputArrive");
  349. ActionManage.GetInstance.Register(new Action(() =>
  350. {
  351. globalVar.fryPotThree.EmptyBarrelArrivedSingle = 1;
  352. }), "FryPotThreeEmptyRollerArrive");
  353. ActionManage.GetInstance.Register(new Action(() =>
  354. {
  355. globalVar.agvArriveLThreeUpLoad = true;
  356. }), "AGVLThreeArrive");
  357. ActionManage.GetInstance.Register(new Action(() =>
  358. {
  359. globalVar.LThreeagvArriveUnLoad = true;
  360. }), "AGVFryPotThreeDownArrive");
  361. ActionManage.GetInstance.Register(new Action(() =>
  362. {
  363. globalVar.agvArriveLThreeUpLoad = true;
  364. }), "AGVFryPotThreeUpArrive");
  365. ActionManage.GetInstance.Register(new Action(() =>
  366. {
  367. globalVar.LThreeagvFryPotEmptyRollerArrive = true;
  368. }), "AGVFryPotThreeGetEmptyRoller");
  369. }
  370. public DosingLogicControl()
  371. {
  372. globalVar = new GlobalVariable();
  373. //fryOne = new PotOneStatus();
  374. //fryTwo = new PotTwoStatus();
  375. //fryThree = new PotThreeStatus();
  376. //fryFour = new PotFourStatus();
  377. //fryFive = new PotFiveStatus();
  378. hardWareStatusModel = HardWareStatusViewModel.GetInstance;
  379. DateTimeJudge();
  380. FileRegClean();
  381. ActionManage.GetInstance.Register(new Action<object[]>(RecipeDataParse), "RecipeSetDown");
  382. //ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); LTwoInputMaterialQuene.Clear(); LTwoOutputMaterialQuene.Clear(); LThreeInputMaterialQuene.Clear(); LThreeOutputMaterialQuene.Clear(); }), "ClearRecipes");
  383. ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); }), "ClearOneRecipes");
  384. ActionManage.GetInstance.Register(new Action(() => { LTwoRecipeQuene.Clear(); LTwoInputMaterialQuene.Clear(); LTwoOutputMaterialQuene.Clear(); }), "ClearTwoRecipes");
  385. ActionManage.GetInstance.Register(new Action(() => { LThreeRecipeQuene.Clear(); LThreeInputMaterialQuene.Clear(); LThreeOutputMaterialQuene.Clear(); }), "ClearThreeRecipes");
  386. ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 1; }), "StartPlcInite");
  387. ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 0; }), "EndPlcInite");
  388. ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineOneTask = true; LineOneTaskRestart(); }), "LineOneTaskExit");
  389. ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineTwoTask = true; LineTwoTaskRestart(); }), "LineTwoTaskExit");
  390. ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineThreeTask = true; LineThreeTaskRestart(); }), "LineThreeTaskExit");
  391. HubHelper.GetInstance.Report = new Action<object>(AgvTaskUpReportDataAnalysis);
  392. HubHelper.GetInstance.Upstreamrequest = new Action<object>(AgvFeedBackUpReportDataAnalysis);
  393. // ResetProgram();
  394. ReadPlcData();
  395. SaveFryPotData();
  396. MainTask();
  397. CommandRegist();
  398. }
  399. /// <summary>
  400. /// 文件数据定期清理
  401. /// </summary>
  402. /// <exception cref="NotImplementedException"></exception>
  403. private void FileRegClean()
  404. {
  405. int days = 5; //清除期限
  406. string[] filesOne = Directory.GetDirectories("AccessFile//DB//炒锅1状态数据");
  407. if (filesOne.Count() > 0)
  408. {
  409. foreach (var item in filesOne)
  410. {
  411. FileInfo info = new FileInfo(item);
  412. DateTime createTime = info.CreationTime;
  413. DateTime timeNow = DateTime.Now;
  414. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  415. {
  416. Directory.Delete(item, true);
  417. }
  418. }
  419. }
  420. string[] filesTwo = Directory.GetDirectories("AccessFile//DB//炒锅2状态数据");
  421. if (filesTwo.Count() > 0)
  422. {
  423. foreach (var item in filesTwo)
  424. {
  425. FileInfo info = new FileInfo(item);
  426. DateTime createTime = info.CreationTime;
  427. DateTime timeNow = DateTime.Now;
  428. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  429. {
  430. Directory.Delete(item, true);
  431. }
  432. }
  433. }
  434. string[] filesThree = Directory.GetDirectories("AccessFile//DB//炒锅3状态数据");
  435. if (filesThree.Count() > 0)
  436. {
  437. foreach (var item in filesThree)
  438. {
  439. FileInfo info = new FileInfo(item);
  440. DateTime createTime = info.CreationTime;
  441. DateTime timeNow = DateTime.Now;
  442. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  443. {
  444. Directory.Delete(item, true);
  445. }
  446. }
  447. }
  448. string[] filesFour = Directory.GetDirectories("AccessFile//DB//炒锅4状态数据");
  449. if (filesFour.Count() > 0)
  450. {
  451. foreach (var item in filesFour)
  452. {
  453. FileInfo info = new FileInfo(item);
  454. DateTime createTime = info.CreationTime;
  455. DateTime timeNow = DateTime.Now;
  456. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  457. {
  458. Directory.Delete(item, true);
  459. }
  460. }
  461. }
  462. string[] filesFive = Directory.GetDirectories("AccessFile//DB//炒锅5状态数据");
  463. if (filesFive.Count() > 0)
  464. {
  465. foreach (var item in filesFive)
  466. {
  467. FileInfo info = new FileInfo(item);
  468. DateTime createTime = info.CreationTime;
  469. DateTime timeNow = DateTime.Now;
  470. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  471. {
  472. Directory.Delete(item, true);
  473. }
  474. }
  475. }
  476. }
  477. /// <summary>
  478. /// 时间差计算
  479. /// </summary>
  480. /// <param name="t">当前时间</param>
  481. /// <param name="t2">创建时间</param>
  482. /// <returns></returns>
  483. private int TimeDiff(DateTime t, DateTime t2)
  484. {
  485. long lReturn = -1;
  486. System.TimeSpan NowValue = new TimeSpan(t.Ticks);
  487. System.TimeSpan TimeValue = new TimeSpan(t2.Ticks);
  488. System.TimeSpan DateDiff = TimeSpan.Zero;
  489. try
  490. {
  491. //计算时间差
  492. //DateDiff = TimeValue.Subtract(NowValue).Duration();
  493. DateDiff = NowValue.Subtract(TimeValue);
  494. int h = DateDiff.Hours;
  495. int m = DateDiff.Minutes;
  496. return DateDiff.Days;
  497. }
  498. catch
  499. {
  500. return -1;
  501. }
  502. }
  503. /// <summary>
  504. /// 炒锅数据实时保存
  505. /// </summary>
  506. /// <exception cref="NotImplementedException"></exception>
  507. private void SaveFryPotData()
  508. {
  509. Task.Run(new Action(() =>
  510. {
  511. while (true)
  512. {
  513. FryPotDataSaveToBinaryFile(); Thread.Sleep(1000);
  514. }
  515. }));
  516. }
  517. /// <summary>
  518. /// 时间判断,数据处理
  519. /// </summary>
  520. private void DateTimeJudge()
  521. {
  522. #region sqlite数据库保存
  523. //if (Sqlite<PotOneStatus>.GetInstance.GetData().Count > 0)
  524. //{
  525. // string time1 = Sqlite<PotOneStatus>.GetInstance.GetData().Last().Time;
  526. // if (time1.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  527. // {
  528. // FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy = Sqlite<PotOneStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  529. // FryPotMonitorManage.GetInstance.fryOne.TotalProduct = Sqlite<PotOneStatus>.GetInstance.GetData().Last().TotalProduct;
  530. // }
  531. //}
  532. //if (Sqlite<PotTwoStatus>.GetInstance.GetData().Count > 0)
  533. //{
  534. // string time2 = Sqlite<PotTwoStatus>.GetInstance.GetData().Last().Time;
  535. // if (time2.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  536. // {
  537. // FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy = Sqlite<PotTwoStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  538. // FryPotMonitorManage.GetInstance.fryTwo.TotalProduct = Sqlite<PotTwoStatus>.GetInstance.GetData().Last().TotalProduct;
  539. // }
  540. //}
  541. //if (Sqlite<PotThreeStatus>.GetInstance.GetData().Count > 0)
  542. //{
  543. // string time3 = Sqlite<PotThreeStatus>.GetInstance.GetData().Last().Time;
  544. // if (time3.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  545. // {
  546. // FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy = Sqlite<PotThreeStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  547. // FryPotMonitorManage.GetInstance.fryThree.TotalProduct = Sqlite<PotThreeStatus>.GetInstance.GetData().Last().TotalProduct;
  548. // }
  549. //}
  550. //if (Sqlite<PotFourStatus>.GetInstance.GetData().Count > 0)
  551. //{
  552. // string time4 = Sqlite<PotFourStatus>.GetInstance.GetData().Last().Time;
  553. // if (time4.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  554. // {
  555. // FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy = Sqlite<PotFourStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  556. // FryPotMonitorManage.GetInstance.fryFour.TotalProduct = Sqlite<PotFourStatus>.GetInstance.GetData().Last().TotalProduct;
  557. // }
  558. //}
  559. //if (Sqlite<PotFiveStatus>.GetInstance.GetData().Count > 0)
  560. //{
  561. // string time5 = Sqlite<PotFiveStatus>.GetInstance.GetData().Last().Time;
  562. // if (time5.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  563. // {
  564. // FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy = Sqlite<PotFiveStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  565. // FryPotMonitorManage.GetInstance.fryFive.TotalProduct = Sqlite<PotFiveStatus>.GetInstance.GetData().Last().TotalProduct;
  566. // }
  567. //}
  568. #endregion
  569. string p1 = "AccessFile//" + "Statistic//" + "FryOne.txt";
  570. string p2 = "AccessFile//" + "Statistic//" + "FryTwo.txt";
  571. string p3 = "AccessFile//" + "Statistic//" + "FryThree.txt";
  572. string p4 = "AccessFile//" + "Statistic//" + "FryFour.txt";
  573. string p5 = "AccessFile//" + "Statistic//" + "FryFive.txt";
  574. if (!Directory.Exists("AccessFile//" + "Statistic"))
  575. Directory.CreateDirectory("AccessFile//" + "Statistic");
  576. if (File.Exists(p1))
  577. {
  578. using (StreamReader sReader = new StreamReader(p1, Encoding.UTF8))
  579. {
  580. string time = sReader.ReadLine();
  581. string statistic = sReader.ReadLine();
  582. if (DateTime.Now.ToShortDateString() == time)
  583. {
  584. FryPotMonitorManage.GetInstance.fryOne.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  585. FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  586. }
  587. }
  588. }
  589. if (File.Exists(p2))
  590. {
  591. using (StreamReader sReader = new StreamReader(p2, Encoding.UTF8))
  592. {
  593. string time = sReader.ReadLine();
  594. string statistic = sReader.ReadLine();
  595. if (DateTime.Now.ToShortDateString() == time)
  596. {
  597. FryPotMonitorManage.GetInstance.fryTwo.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  598. FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  599. }
  600. }
  601. }
  602. if (File.Exists(p3))
  603. {
  604. using (StreamReader sReader = new StreamReader(p3, Encoding.UTF8))
  605. {
  606. string time = sReader.ReadLine();
  607. string statistic = sReader.ReadLine();
  608. if (DateTime.Now.ToShortDateString() == time)
  609. {
  610. FryPotMonitorManage.GetInstance.fryThree.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  611. FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  612. }
  613. }
  614. }
  615. if (File.Exists(p4))
  616. {
  617. using (StreamReader sReader = new StreamReader(p4, Encoding.UTF8))
  618. {
  619. string time = sReader.ReadLine();
  620. string statistic = sReader.ReadLine();
  621. if (DateTime.Now.ToShortDateString() == time)
  622. {
  623. FryPotMonitorManage.GetInstance.fryFour.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  624. FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  625. }
  626. }
  627. }
  628. if (File.Exists(p5))
  629. {
  630. using (StreamReader sReader = new StreamReader(p5, Encoding.UTF8))
  631. {
  632. string time = sReader.ReadLine();
  633. string statistic = sReader.ReadLine();
  634. if (DateTime.Now.ToShortDateString() == time)
  635. {
  636. FryPotMonitorManage.GetInstance.fryFive.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  637. FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  638. }
  639. }
  640. }
  641. }
  642. /// <summary>
  643. /// AGV上下料上报数据解析
  644. /// </summary>
  645. /// <param name="obj"></param>
  646. private void AgvFeedBackUpReportDataAnalysis(object obj)
  647. {
  648. //if (obj != null && obj is byte[] datas)
  649. //{
  650. //string strData = Encoding.UTF8.GetString(datas);
  651. Upstreamrequest objData = JsonConvert.DeserializeObject<Upstreamrequest>(obj.ToString());
  652. if (objData != null)
  653. {
  654. #region 线体到炒锅请求上下料
  655. //线体1请求上下料
  656. if (objData.robotJobId == LOnerobotJobId && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料
  657. {
  658. globalVar.agvArriveUpLoad = true;//AGV到达上料位置
  659. }
  660. if (objData.robotJobId == LOnerobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  661. {
  662. globalVar.agvArriveUnLoad = true;//AGV到达下料位置
  663. }
  664. //线体2请求上下料
  665. if (objData.robotJobId == LTworobotJobId && objData.command == "LOAD")
  666. {
  667. globalVar.agvArriveLTwoUpLoad = true;//AGV到达上料位置
  668. }
  669. if (objData.robotJobId == LTworobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  670. {
  671. globalVar.LTwoagvArriveUnLoad = true;//AGV到达下料位置
  672. }
  673. //线体3请求上下料
  674. if (objData.robotJobId == LThreerobotJobId && objData.command == "LOAD")
  675. {
  676. globalVar.agvArriveLThreeUpLoad = true;//AGV到达上料位置
  677. }
  678. if (objData.robotJobId == LThreerobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  679. {
  680. globalVar.LThreeagvArriveUnLoad = true;//AGV到达下料位置
  681. }
  682. #endregion
  683. #region 炒锅到线体4请求上下料
  684. if (objData.robotJobId == LFourrobotJobId && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料
  685. {
  686. globalVar.agvArriveUpLoad = true;//AGV到达上料位置
  687. }
  688. if (objData.robotJobId == LFourrobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  689. {
  690. globalVar.rollerLineOne.agvArriveLineFour = true;//AGV到达下料位置
  691. // AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
  692. }
  693. if (objData.robotJobId == LFiverobotJobId && objData.command == "LOAD")
  694. {
  695. globalVar.agvArriveLTwoUpLoad = true;//AGV到达上料位置
  696. }
  697. if (objData.robotJobId == LFiverobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  698. {
  699. globalVar.rollerLineTwo.agvArriveLineFour = true;//AGV到达下料位置
  700. }
  701. if (objData.robotJobId == LSixrobotJobId && objData.command == "LOAD")
  702. {
  703. globalVar.agvArriveLThreeUpLoad = true;//AGV到达上料位置
  704. }
  705. if (objData.robotJobId == LSixrobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  706. {
  707. globalVar.rollerLineThree.agvArriveLineFour = true;//AGV到达下料位置
  708. }
  709. #endregion
  710. #region 线体123到清洗台请求上下料
  711. if (LSevenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料
  712. {
  713. globalVar.agvArriveLineOneLoadEmptyRoller = true;//AGV到达上料位置
  714. }
  715. if (LSevenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  716. {
  717. globalVar.rollerLineOne.agvArriveCleanUnLoad = true;//AGV到达下料位置
  718. }
  719. if (LEightrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "LOAD")
  720. {
  721. globalVar.agvArriveLineTwoLoadEmptyRoller = true;//AGV到达上料位置
  722. }
  723. if (LEightrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  724. {
  725. globalVar.rollerLineTwo.agvArriveCleanUnLoad = true;//AGV到达下料位置
  726. }
  727. if (LNinerobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "LOAD")
  728. {
  729. globalVar.agvArriveLineThreeLoadEmptyRoller = true;//AGV到达上料位置
  730. }
  731. if (LNinerobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  732. {
  733. globalVar.rollerLineThree.agvArriveCleanUnLoad = true;//AGV到达下料位置
  734. }
  735. #endregion
  736. #region 清洗台到线体4请求上下料
  737. if (LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "LOAD")
  738. {
  739. globalVar.agvArriveCleanLoad = true;//agv到达清洗台上料位置
  740. }
  741. if (LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "UNLOAD")
  742. {
  743. globalVar.agvArriveLineFour = true;//agv到达线体4下料位置
  744. }
  745. #endregion
  746. }
  747. }
  748. /// <summary>
  749. /// AGV搬运任务上报数据解析
  750. /// </summary>
  751. /// <param name="obj"></param>
  752. private void AgvTaskUpReportDataAnalysis(object obj)
  753. {
  754. //if (obj != null && obj is byte[] datas)
  755. //{
  756. // string strData = Encoding.UTF8.GetString(datas);
  757. AGVToUpSystem objData = JsonConvert.DeserializeObject<AGVToUpSystem>(obj.ToString());
  758. if (objData != null)
  759. {
  760. #region 线体上下料任务信息回报
  761. //线体1任务上报
  762. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体上料
  763. {
  764. }
  765. //线体2任务上报
  766. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体上料
  767. {
  768. //日志
  769. }
  770. //线体3任务上报
  771. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体上料
  772. {
  773. //日志
  774. }
  775. //线体1任务上报
  776. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体上料
  777. {
  778. globalVar.agvLineOneLoadCom = true;
  779. AgvViewModel.GetInstance().Set滚筒线上数量(1, (--globalVar.LOneMaterialNum).ToString());
  780. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.Yes);
  781. if (globalVar.LOneFryPotSerial == 1)
  782. {
  783. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.yc_1_1);
  784. }
  785. else if (globalVar.LOneFryPotSerial == 4)
  786. {
  787. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.yc_1_4);
  788. }
  789. }
  790. //线体2任务上报
  791. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体上料
  792. {
  793. globalVar.agvLineTwoLoadCom = true;
  794. AgvViewModel.GetInstance().Set滚筒线上数量(2, (--globalVar.LTwoMaterialNum).ToString());
  795. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.Yes);
  796. if (globalVar.LTwoFryPotSerial == 2)
  797. {
  798. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.yc_2_2);
  799. }
  800. else if (globalVar.LTwoFryPotSerial == 5)
  801. {
  802. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.yc_2_5);
  803. }
  804. }
  805. //线体3任务上报
  806. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体上料
  807. {
  808. globalVar.agvLineThreeLoadCom = true;
  809. AgvViewModel.GetInstance().Set滚筒线上数量(3, (--globalVar.LThreeMaterialNum).ToString());
  810. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.Yes);
  811. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.yc_3_3);
  812. }
  813. //线体1任务上报
  814. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LOnerobotJobId && objData.jobData.targetPointCode == "" && objData.jobData.targetPointCode == "")//指定下料点正在下料,指线体到炒锅下料
  815. {
  816. }
  817. //线体2任务上报
  818. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LTworobotJobId && objData.jobData.targetPointCode == "" && objData.jobData.targetPointCode == "")//指定下料点正在下料,指线体到炒锅下料
  819. {
  820. }
  821. //线体3任务上报
  822. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LThreerobotJobId && objData.jobData.targetPointCode == "" && objData.jobData.targetPointCode == "")//指定下料点正在下料,指线体到炒锅下料
  823. {
  824. }
  825. //线体1任务上报
  826. if (objData.state == "DONE" && objData.robotJobId == LOnerobotJobId && objData.jobData.targetPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指线体到炒锅下料
  827. {
  828. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  829. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hj);
  830. AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
  831. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  832. }
  833. //线体2任务上报
  834. if (objData.state == "DONE" && objData.robotJobId == LTworobotJobId && objData.jobData.targetPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指线体到炒锅下料
  835. {
  836. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  837. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hj);
  838. AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
  839. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  840. }
  841. //线体3任务上报
  842. if (objData.state == "DONE" && objData.robotJobId == LThreerobotJobId && objData.jobData.targetPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指线体到炒锅下料
  843. {
  844. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  845. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hj);
  846. AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
  847. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  848. }
  849. #endregion
  850. #region 炒锅空桶上下料任务信息回报
  851. //线体1任务上报
  852. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LFourrobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指炒锅空桶上料
  853. {
  854. //日志
  855. }
  856. //线体2任务上报
  857. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LFiverobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指炒锅空桶上料
  858. {
  859. //日志
  860. }
  861. //线体3任务上报
  862. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LSixrobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指炒锅空桶上料
  863. {
  864. //日志
  865. }
  866. //线体1任务上报
  867. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LFourrobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指炒锅空桶上料
  868. {
  869. globalVar.agvFryPotEmptyRollerArrive = true;
  870. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
  871. if (globalVar.LOneFryPotSerial == 1)
  872. {
  873. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hs_1);
  874. }
  875. else if (globalVar.LOneFryPotSerial == 4)
  876. {
  877. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hs_4);
  878. }
  879. }
  880. //线体2任务上报
  881. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LFiverobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指炒锅空桶上料
  882. {
  883. globalVar.LTwoagvFryPotEmptyRollerArrive = true;
  884. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
  885. if (globalVar.LTwoFryPotSerial == 2)
  886. {
  887. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hs_2);
  888. }
  889. else if (globalVar.LTwoFryPotSerial == 5)
  890. {
  891. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hs_5);
  892. }
  893. }
  894. //线体3任务上报
  895. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LSixrobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指炒锅空桶上料
  896. {
  897. globalVar.LThreeagvFryPotEmptyRollerArrive = true;
  898. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
  899. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hs_3);
  900. }
  901. //线体1任务上报
  902. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LFourrobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指炒锅空桶下料
  903. {
  904. AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
  905. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  906. }
  907. //线体2任务上报
  908. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LFiverobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指炒锅空桶下料
  909. {
  910. AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
  911. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  912. }
  913. //线体3任务上报
  914. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LSixrobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指炒锅空桶下料
  915. {
  916. AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
  917. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  918. }
  919. //线体1任务上报
  920. if (objData.state == "DONE" && objData.robotJobId == LFourrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指炒锅空桶下料
  921. {
  922. MessageLog.GetInstance.ShowRunLog("1号线炒锅空桶在4号线卸桶完成");
  923. if (globalVar.LFourRollerNum >= 8)
  924. {
  925. AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
  926. }
  927. else
  928. {
  929. AgvViewModel.GetInstance().Set滚筒线上数量(4, (++globalVar.LFourRollerNum).ToString());
  930. }
  931. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], AgvViewModel.GetInstance().GetCommandValue("hj"));
  932. AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
  933. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  934. }
  935. //线体2任务上报
  936. if (objData.state == "DONE" && objData.robotJobId == LFiverobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指炒锅空桶下料
  937. {
  938. MessageLog.GetInstance.ShowRunLog("2号线炒锅空桶在4号线卸桶完成");
  939. if (globalVar.LFourRollerNum >= 8)
  940. {
  941. AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
  942. }
  943. else
  944. {
  945. AgvViewModel.GetInstance().Set滚筒线上数量(4, (++globalVar.LFourRollerNum).ToString());
  946. }
  947. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], AgvViewModel.GetInstance().GetCommandValue("hj"));
  948. AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
  949. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  950. }
  951. //线体3任务上报
  952. if (objData.state == "DONE" && objData.robotJobId == LSixrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指炒锅空桶下料
  953. {
  954. MessageLog.GetInstance.ShowRunLog("3号线炒锅空桶在4号线卸桶完成");
  955. if (globalVar.LFourRollerNum >= 8)
  956. {
  957. AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
  958. }
  959. else
  960. {
  961. AgvViewModel.GetInstance().Set滚筒线上数量(4, (++globalVar.LFourRollerNum).ToString());
  962. }
  963. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], AgvViewModel.GetInstance().GetCommandValue("hj"));
  964. AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
  965. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  966. }
  967. #endregion
  968. #region 线体123空桶到清戏台
  969. //线体1任务上报
  970. if (objData.state == "ROLLER_LOAD_FINISH" && LSevenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体1空桶上料
  971. {
  972. globalVar.agvArriveLineOneLoadCom = true;
  973. AgvViewModel.GetInstance().Set滚筒线上数量(1, (--globalVar.LOneMaterialNum).ToString());
  974. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
  975. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.tqx_1);
  976. //到清洗处
  977. }
  978. //线体2任务上报
  979. if (objData.state == "ROLLER_LOAD_FINISH" && LEightrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体2空桶上料
  980. {
  981. globalVar.agvArriveLineTwoLoadCom = true;
  982. AgvViewModel.GetInstance().Set滚筒线上数量(2, (--globalVar.LTwoMaterialNum).ToString());
  983. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
  984. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.tqx_2);
  985. //到清洗处
  986. }
  987. //线体3任务上报
  988. if (objData.state == "ROLLER_LOAD_FINISH" && LNinerobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体3空桶上料
  989. {
  990. globalVar.agvArriveLineThreeLoadCom = true;
  991. AgvViewModel.GetInstance().Set滚筒线上数量(3, (--globalVar.LThreeMaterialNum).ToString());
  992. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
  993. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.tqx_3);
  994. //到清洗处
  995. }
  996. if (objData.state == "DONE" && LSevenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指从线体1到清戏台空桶下料
  997. {
  998. LSevenrobotJobId.Remove(objData.robotJobId);
  999. MessageLog.GetInstance.ShowRunLog("线体【1】空桶在清洗台卸桶完成");
  1000. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  1001. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.qxt_hj);
  1002. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  1003. AgvViewModel.GetInstance().SetCleanRollerNum(++CleanNum);
  1004. }
  1005. if (objData.state == "DONE" && LEightrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指从线体2到清戏台空桶下料
  1006. {
  1007. LEightrobotJobId.Remove(objData.robotJobId);
  1008. MessageLog.GetInstance.ShowRunLog("线体【2】空桶在清洗台卸桶完成");
  1009. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  1010. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.qxt_hj);
  1011. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  1012. AgvViewModel.GetInstance().SetCleanRollerNum(++CleanNum);
  1013. }
  1014. if (objData.state == "DONE" && LNinerobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指从线体3到清戏台空桶下料
  1015. {
  1016. LNinerobotJobId.Remove(objData.robotJobId);
  1017. MessageLog.GetInstance.ShowRunLog("线体【3】空桶在清洗台卸桶完成");
  1018. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  1019. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.qxt_hj);
  1020. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  1021. AgvViewModel.GetInstance().SetCleanRollerNum(++CleanNum);
  1022. }
  1023. #endregion
  1024. #region 清洗台到线体4
  1025. if (objData.state == "ROLLER_LOAD_FINISH" && LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料位置上料完成,指清戏台空桶到上料
  1026. {
  1027. MessageLog.GetInstance.ShowRunLog("清洗台空桶装载完成");
  1028. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
  1029. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hs_4);//去四号空桶线
  1030. AgvViewModel.GetInstance().SetCleanRollerNum(--CleanNum);
  1031. }
  1032. if (objData.state == "ROLLER_UNLOAD_DOING" && LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.targetPointCode == "")//指定下料点正在下料,指清洗台空桶到线体4下料
  1033. {
  1034. AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
  1035. }
  1036. if (objData.state == "DONE" && LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指清戏台空桶到线体4下料
  1037. {
  1038. LTenrobotJobId.Remove(objData.robotJobId);
  1039. MessageLog.GetInstance.ShowRunLog("【4】号线空桶回桶完成");
  1040. if (globalVar.LFourRollerNum >= 8)
  1041. {
  1042. AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
  1043. }
  1044. else
  1045. {
  1046. AgvViewModel.GetInstance().Set滚筒线上数量(4, (++globalVar.LFourRollerNum).ToString());
  1047. }
  1048. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  1049. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], AgvViewModel.GetInstance().GetCommandValue("hj"));
  1050. AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
  1051. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  1052. }
  1053. #endregion
  1054. }
  1055. }
  1056. /// <summary>
  1057. /// 主任务重启
  1058. /// </summary>
  1059. private void ResetProgram()
  1060. {
  1061. ThreadManage.GetInstance().StartLong(new Action(() =>
  1062. {
  1063. if (RTrig.GetInstance("ResetProgram").Start(globalVar.PlcInite == 1))//判断是否初始化 一初始化就重启主任务
  1064. {
  1065. MessageLog.GetInstance.ShowUserLog("主任务正在重启");
  1066. ThreadManage.GetInstance().StopTask("MainViewReadPlcData", new Action(() =>
  1067. {
  1068. //ActionManage.GetInstance.CancelRegister("RecipeSetDown");
  1069. //ActionManage.GetInstance.Register(new Action<object>(RecipeDataParse), "RecipeSetDown");
  1070. // ActionManage.GetInstance.Send("ClearRecipes");
  1071. ThreadManage.GetInstance().StopTask("滚筒线1任务线程", new Action(() =>
  1072. {
  1073. ThreadManage.GetInstance().StopTask("滚筒线2任务线程", new Action(() =>
  1074. {
  1075. ThreadManage.GetInstance().StopTask("滚筒线3任务线程", new Action(() =>
  1076. {
  1077. globalVar = null;
  1078. globalVar = new GlobalVariable();
  1079. ReicpeNum = 0;
  1080. ReadPlcData();
  1081. MainTask();
  1082. MessageLog.GetInstance.ShowUserLog("主任务重启完成");
  1083. }));
  1084. }));
  1085. }));
  1086. }));
  1087. }
  1088. Thread.Sleep(10);
  1089. }), "ResetProgram");
  1090. }
  1091. public void LineOneTaskRestart()
  1092. {
  1093. ThreadManage.GetInstance().StopTask("滚筒线1任务线程", new Action(() =>
  1094. {
  1095. ActionManage.GetInstance.Send("ClearOneRecipes");
  1096. globalVar.rollerLineOne = null;
  1097. globalVar.rollerLineOne = new RollerLineOne();
  1098. globalVar.fryPotOne = null;
  1099. globalVar.fryPotOne = new FryPotOne();
  1100. globalVar.fryPotFour = null;
  1101. globalVar.fryPotFour = new FryPotFour();
  1102. globalVar.ExitLineOneTask = false;
  1103. globalVar.AllowAgvToLineLoadRoller = true;
  1104. globalVar.InOrOutputLock = false;
  1105. globalVar.LOneCurrentRecipeName = string.Empty;
  1106. globalVar.LoadRoller = false;
  1107. globalVar.AgvToFryPot = false;
  1108. globalVar.PotOneInputMaterialArrive = false;
  1109. globalVar.PotOneOutputRollerArrive = false;
  1110. globalVar.AgvArrivePot = false;
  1111. globalVar.LOneMaterialNum = 0;
  1112. globalVar.LOneFryPotSerial = 1;
  1113. globalVar.LOneCurrentCookingStep = 0;
  1114. globalVar.agvArriveUpLoad = false;
  1115. globalVar.agvArriveUnLoad = false;
  1116. globalVar.agvFryPotEmptyRollerArrive = false;
  1117. globalVar.agvLineOneLoadCom = false;
  1118. ThreadManage.GetInstance().StartLong(new Action(() => { LineOneProcessExecute(); Thread.Sleep(10); }), "滚筒线1任务线程");
  1119. MessageLog.GetInstance.ShowUserLog("滚筒线【1】任务重启成功");
  1120. }));
  1121. }
  1122. public void LineTwoTaskRestart()
  1123. {
  1124. ThreadManage.GetInstance().StopTask("滚筒线2任务线程", new Action(() =>
  1125. {
  1126. ActionManage.GetInstance.Send("ClearTwoRecipes");
  1127. globalVar.rollerLineTwo = null;
  1128. globalVar.rollerLineTwo = new RollerLineTwo();
  1129. globalVar.fryPotTwo = null;
  1130. globalVar.fryPotTwo = new FryPotTwo();
  1131. globalVar.fryPotFive = null;
  1132. globalVar.fryPotFive = new FryPotFive();
  1133. globalVar.ExitLineTwoTask = false;
  1134. globalVar.AllowAgvToLineTwoLoadRoller = true;
  1135. globalVar.LTwoInOrOutputLock = false;
  1136. globalVar.LTwoCurrentRecipeName = string.Empty;
  1137. globalVar.LTwoLoadRoller = false;
  1138. globalVar.LTwoAgvToFryPot = false;
  1139. globalVar.LTwoPotInputMaterialArrive = false;
  1140. globalVar.LTwoPotOutputRollerArrive = false;
  1141. globalVar.LTwoAgvArrivePot = false;
  1142. globalVar.LTwoMaterialNum = 0;
  1143. globalVar.LTwoFryPotSerial = 2;
  1144. globalVar.LTwoCurrentCookingStep = 0;
  1145. globalVar.agvArriveLTwoUpLoad = false;
  1146. globalVar.LTwoagvArriveUnLoad = false;
  1147. globalVar.LTwoagvFryPotEmptyRollerArrive = false;
  1148. globalVar.agvLineTwoLoadCom = false;
  1149. ThreadManage.GetInstance().StartLong(new Action(() => { LineTwoProcessExecute(); Thread.Sleep(10); }), "滚筒线2任务线程");
  1150. MessageLog.GetInstance.ShowUserLog("滚筒线【2】任务重启成功");
  1151. }));
  1152. }
  1153. public void LineThreeTaskRestart()
  1154. {
  1155. ThreadManage.GetInstance().StopTask("滚筒线3任务线程", new Action(() =>
  1156. {
  1157. ActionManage.GetInstance.Send("ClearThreeRecipes");
  1158. globalVar.rollerLineThree = null;
  1159. globalVar.rollerLineThree = new RollerLineThree();
  1160. globalVar.fryPotThree = null;
  1161. globalVar.fryPotThree = new FryPotThree();
  1162. globalVar.ExitLineThreeTask = false;
  1163. globalVar.AllowAgvToLineThreeLoadRoller = true;
  1164. globalVar.LThreeInOrOutputLock = false;
  1165. globalVar.LThreeCurrentRecipeName = string.Empty;
  1166. globalVar.LThreeLoadRoller = false;
  1167. globalVar.LThreeAgvToFryPot = false;
  1168. globalVar.LThreePotInputMaterialArrive = false;
  1169. globalVar.LThreePotOutputRollerArrive = false;
  1170. globalVar.LThreeAgvArrivePot = false;
  1171. globalVar.LThreeMaterialNum = 0;
  1172. globalVar.LThreeFryPotSerial = 3;
  1173. globalVar.LThreeCurrentCookingStep = 0;
  1174. globalVar.agvArriveLThreeUpLoad = false;
  1175. globalVar.LThreeagvArriveUnLoad = false;
  1176. globalVar.LThreeagvFryPotEmptyRollerArrive = false;
  1177. globalVar.agvLineThreeLoadCom = false;
  1178. ThreadManage.GetInstance().StartLong(new Action(() => { LineThreeProcessExecute(); Thread.Sleep(10); }), "滚筒线3任务线程");
  1179. MessageLog.GetInstance.ShowUserLog("滚筒线【3】任务重启成功");
  1180. }));
  1181. }
  1182. public void LineOneEmptyRollerCleanTaskRestart()
  1183. {
  1184. ThreadManage.GetInstance().StopTask("滚筒线1空桶清洗任务线程", new Action(() =>
  1185. {
  1186. globalVar.rollerLineOne.StationEight = 0;
  1187. globalVar.rollerLineOne.EmptyRollerNums.Clear();
  1188. globalVar.rollerLineOne.EmptyRollerNums.Add(108);
  1189. globalVar.rollerLineOne.IsEpmtyBefore = false;
  1190. // globalVar.rollerLineOne.CanRun = true;
  1191. globalVar.agvArriveLineFour = false;
  1192. globalVar.agvArriveCleanLoad = false;
  1193. globalVar.rollerLineOne.agvArriveCleanUnLoad = false;
  1194. globalVar.agvArriveLineOneLoadEmptyRoller = false;
  1195. globalVar.agvArriveLineOneLoadCom = false;
  1196. ThreadManage.GetInstance().StartLong(new Action(() => { LineOneToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线1空桶清洗任务线程");
  1197. MessageLog.GetInstance.ShowUserLog("滚筒线1空桶清洗任务重启成功");
  1198. }));
  1199. }
  1200. public void LineTwoEmptyRollerCleanTaskRestart()
  1201. {
  1202. ThreadManage.GetInstance().StopTask("滚筒线2空桶清洗任务线程", new Action(() =>
  1203. {
  1204. globalVar.rollerLineTwo.StationEight = 0;
  1205. globalVar.rollerLineTwo.EmptyRollerNums.Clear();
  1206. globalVar.rollerLineTwo.EmptyRollerNums.Add(208);
  1207. globalVar.rollerLineTwo.IsEpmtyBefore = false;
  1208. //globalVar.rollerLineTwo.CanRun = true;
  1209. globalVar.agvArriveLineFour = false;
  1210. globalVar.agvArriveCleanLoad = false;
  1211. globalVar.rollerLineTwo.agvArriveCleanUnLoad = false;
  1212. globalVar.agvArriveLineTwoLoadEmptyRoller = false;
  1213. globalVar.agvArriveLineTwoLoadCom = false;
  1214. ThreadManage.GetInstance().StartLong(new Action(() => { LineOneToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线2空桶清洗任务线程");
  1215. MessageLog.GetInstance.ShowUserLog("滚筒线2空桶清洗任务重启成功");
  1216. }));
  1217. }
  1218. public void LineThreeEmptyRollerCleanTaskRestart()
  1219. {
  1220. ThreadManage.GetInstance().StopTask("滚筒线3空桶清洗任务线程", new Action(() =>
  1221. {
  1222. globalVar.rollerLineThree.StationEight = 0;
  1223. globalVar.rollerLineThree.EmptyRollerNums.Clear();
  1224. globalVar.rollerLineThree.EmptyRollerNums.Add(308);
  1225. globalVar.rollerLineThree.IsEpmtyBefore = false;
  1226. //globalVar.rollerLineThree.CanRun = true;
  1227. globalVar.agvArriveLineFour = false;
  1228. globalVar.agvArriveCleanLoad = false;
  1229. globalVar.rollerLineThree.agvArriveCleanUnLoad = false;
  1230. globalVar.agvArriveLineThreeLoadEmptyRoller = false;
  1231. globalVar.agvArriveLineThreeLoadCom = false;
  1232. ThreadManage.GetInstance().StartLong(new Action(() => { LineOneToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线3空桶清洗任务线程");
  1233. MessageLog.GetInstance.ShowUserLog("滚筒线3空桶清洗任务重启成功");
  1234. }));
  1235. }
  1236. /// <summary>
  1237. /// 实时获取plc数据
  1238. /// </summary>
  1239. public void ReadPlcData()
  1240. {
  1241. ThreadManage.GetInstance().StartLong(new Action(() =>
  1242. {
  1243. GetAddressData("D2001", new Action<ushort[]>((data) =>
  1244. {
  1245. globalVar.rollerLineOne.StationOne = data[0];
  1246. globalVar.rollerLineOne.StationTwo = data[1];
  1247. globalVar.rollerLineOne.StationThree = data[2];
  1248. globalVar.rollerLineOne.StationFour = data[3];
  1249. globalVar.rollerLineOne.StationFive = data[4];
  1250. globalVar.rollerLineOne.StationSix = data[5];
  1251. globalVar.rollerLineOne.StationSeven = data[6];
  1252. globalVar.rollerLineOne.StationEight = data[7];
  1253. }));
  1254. GetAddressData("D2011", new Action<ushort[]>((data) =>
  1255. {
  1256. globalVar.rollerLineTwo.StationOne = data[0];
  1257. globalVar.rollerLineTwo.StationTwo = data[1];
  1258. globalVar.rollerLineTwo.StationThree = data[2];
  1259. globalVar.rollerLineTwo.StationFour = data[3];
  1260. globalVar.rollerLineTwo.StationFive = data[4];
  1261. globalVar.rollerLineTwo.StationSix = data[5];
  1262. globalVar.rollerLineTwo.StationSeven = data[6];
  1263. globalVar.rollerLineTwo.StationEight = data[7];
  1264. }));
  1265. GetAddressData("D2021", new Action<ushort[]>((data) =>
  1266. {
  1267. globalVar.rollerLineThree.StationOne = data[0];
  1268. globalVar.rollerLineThree.StationTwo = data[1];
  1269. globalVar.rollerLineThree.StationThree = data[2];
  1270. globalVar.rollerLineThree.StationFour = data[3];
  1271. globalVar.rollerLineThree.StationFive = data[4];
  1272. globalVar.rollerLineThree.StationSix = data[5];
  1273. globalVar.rollerLineThree.StationSeven = data[6];
  1274. globalVar.rollerLineThree.StationEight = data[7];
  1275. }));
  1276. GetAddressData("D2031", new Action<ushort[]>((data) =>
  1277. {
  1278. globalVar.rollerLineOne.OutMaterialingSingle = data[3];
  1279. globalVar.rollerLineTwo.OutMaterialingSingle = data[4];
  1280. globalVar.rollerLineThree.OutMaterialingSingle = data[5];
  1281. AlarmHelper<AlarmInfo>.Alarm.LineOneRollerRunning = data[3];
  1282. AlarmHelper<AlarmInfo>.Alarm.LineTwoRollerRunning = data[4];
  1283. AlarmHelper<AlarmInfo>.Alarm.LineThreeRollerRunning = data[5];
  1284. AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble = data[6];
  1285. AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble = data[7];
  1286. AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble = data[8];
  1287. }));
  1288. GetAddressData("D2040", new Action<ushort[]>((data) =>
  1289. {
  1290. globalVar.fryPotOne.InputMaterialRollerRunningSingle = data[0];
  1291. globalVar.fryPotTwo.InputMaterialRollerRunningSingle = data[1];
  1292. globalVar.fryPotThree.InputMaterialRollerRunningSingle = data[2];
  1293. globalVar.fryPotFour.InputMaterialRollerRunningSingle = data[3];
  1294. globalVar.fryPotFive.InputMaterialRollerRunningSingle = data[4];
  1295. AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerRunning = data[0];
  1296. AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerRunning = data[1];
  1297. AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerRunning = data[2];
  1298. AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerRunning = data[3];
  1299. AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerRunning = data[4];
  1300. }));
  1301. GetAddressData("D2045", new Action<ushort[]>((data) =>
  1302. {
  1303. globalVar.fryPotOne.InputMaterialArrivedSingle = data[0];
  1304. globalVar.fryPotTwo.InputMaterialArrivedSingle = data[1];
  1305. globalVar.fryPotThree.InputMaterialArrivedSingle = data[2];
  1306. globalVar.fryPotFour.InputMaterialArrivedSingle = data[3];
  1307. globalVar.fryPotFive.InputMaterialArrivedSingle = data[4];
  1308. }));
  1309. GetAddressData("D2050", new Action<ushort[]>((data) =>
  1310. {
  1311. globalVar.fryPotOne.EmptyBarrelArrivedSingle = data[0];
  1312. globalVar.fryPotTwo.EmptyBarrelArrivedSingle = data[1];
  1313. globalVar.fryPotThree.EmptyBarrelArrivedSingle = data[2];
  1314. globalVar.fryPotFour.EmptyBarrelArrivedSingle = data[3];
  1315. globalVar.fryPotFive.EmptyBarrelArrivedSingle = data[4];
  1316. }));
  1317. GetAddressData("D2065", new Action<ushort[]>((data) =>
  1318. {
  1319. globalVar.fryPotOne.EmptyBarrelRollerRunningSingle = data[0];
  1320. globalVar.fryPotTwo.EmptyBarrelRollerRunningSingle = data[1];
  1321. globalVar.fryPotThree.EmptyBarrelRollerRunningSingle = data[2];
  1322. globalVar.fryPotFour.EmptyBarrelRollerRunningSingle = data[3];
  1323. globalVar.fryPotFive.EmptyBarrelRollerRunningSingle = data[4];
  1324. AlarmHelper<AlarmInfo>.Alarm.FryPotOneEmptyRollerRunning = data[0];
  1325. AlarmHelper<AlarmInfo>.Alarm.FryPotTwoEmptyRollerRunning = data[1];
  1326. AlarmHelper<AlarmInfo>.Alarm.FryPotThreeEmptyRollerRunning = data[2];
  1327. AlarmHelper<AlarmInfo>.Alarm.FryPotFourEmptyRollerRunning = data[3];
  1328. AlarmHelper<AlarmInfo>.Alarm.FryPotFiveEmptyRollerRunning = data[4];
  1329. }));
  1330. GetAddressData("D2070", new Action<ushort[]>((data) =>
  1331. {
  1332. //globalVar.fryPotOne.RollerTroubleSingle = data[0];
  1333. //globalVar.fryPotTwo.RollerTroubleSingle = data[1];
  1334. //globalVar.fryPotThree.RollerTroubleSingle = data[2];
  1335. //globalVar.fryPotFour.RollerTroubleSingle = data[3];
  1336. //globalVar.fryPotFive.RollerTroubleSingle = data[4];
  1337. AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerTrouble = data[0];
  1338. AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble = data[1];
  1339. AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble = data[2];
  1340. AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble = data[3];
  1341. AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble = data[4];
  1342. }));
  1343. GetAddressData("D2078", new Action<ushort[]>(data =>
  1344. {
  1345. globalVar.rollerLineOne.RecipeCompleteSingle = data[0];
  1346. globalVar.rollerLineTwo.RecipeCompleteSingle = data[1];
  1347. globalVar.rollerLineThree.RecipeCompleteSingle = data[2];
  1348. }));
  1349. GetAddressData("D2075", new Action<ushort[]>(data =>
  1350. {
  1351. AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning = data[0];
  1352. globalVar.CleadBarrelEnterSingle = data[0];
  1353. }));
  1354. GetAddressData("2076", new Action<ushort[]>(data =>
  1355. {
  1356. globalVar.CleanComplete = data[0];//洗桶出桶agv呼叫信号
  1357. }));
  1358. GetAddressData("D2077", new Action<ushort[]>(data =>
  1359. {
  1360. AlarmHelper<AlarmInfo>.Alarm.CleanOutputRollerRunning = data[0];
  1361. globalVar.CleadBarrelExitSingle = data[0];
  1362. }));
  1363. //炒锅1状态数据
  1364. GetFryOneData("D2001", new Action<ushort[]>(data =>
  1365. {
  1366. }));
  1367. //炒锅2状态数据
  1368. GetFryTwoData("D2001", new Action<ushort[]>(data =>
  1369. {
  1370. }));
  1371. //炒锅3状态数据
  1372. GetFryThreeData("D2001", new Action<ushort[]>(data =>
  1373. {
  1374. }));
  1375. //炒锅4状态数据
  1376. GetFryFourData("D2001", new Action<ushort[]>(data =>
  1377. {
  1378. }));
  1379. //炒锅5状态数据
  1380. GetFryFiveData("D2001", new Action<ushort[]>(data =>
  1381. {
  1382. }));
  1383. //线体上放空桶
  1384. if (globalVar.rollerLineOne.EmptyRollerConfirmSingle == 1 && globalVar.rollerLineOne.EmptyRollerNum != 0)
  1385. {
  1386. globalVar.rollerLineOne.EmptyRollerNums.Add(globalVar.rollerLineOne.EmptyRollerNum);
  1387. ++globalVar.LOneMaterialNum;
  1388. //是否手动复位PLC
  1389. }
  1390. if (globalVar.rollerLineTwo.EmptyRollerConfirmSingle == 1 && globalVar.rollerLineTwo.EmptyRollerNum != 0)
  1391. {
  1392. globalVar.rollerLineTwo.EmptyRollerNums.Add(globalVar.rollerLineTwo.EmptyRollerNum);
  1393. ++globalVar.LTwoMaterialNum;
  1394. //是否手动复位PLC
  1395. }
  1396. if (globalVar.rollerLineThree.EmptyRollerConfirmSingle == 1 && globalVar.rollerLineThree.EmptyRollerNum != 0)
  1397. {
  1398. globalVar.rollerLineThree.EmptyRollerNums.Add(globalVar.rollerLineThree.EmptyRollerNum);
  1399. ++globalVar.LThreeMaterialNum;
  1400. //是否手动复位PLC
  1401. }
  1402. //炒锅状态数据
  1403. if (globalVar.fryPotOne.OilConfirm == 1)
  1404. {
  1405. FryPotMonitorManage.GetInstance.fryOne.OilCapacity = globalVar.fryPotOne.OilCapacity;
  1406. FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy += globalVar.fryPotOne.OilCapacity;
  1407. }
  1408. if (globalVar.fryPotTwo.OilConfirm == 1)
  1409. {
  1410. FryPotMonitorManage.GetInstance.fryTwo.OilCapacity = globalVar.fryPotTwo.OilCapacity;
  1411. FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy += globalVar.fryPotTwo.OilCapacity;
  1412. }
  1413. if (globalVar.fryPotThree.OilConfirm == 1)
  1414. {
  1415. FryPotMonitorManage.GetInstance.fryThree.OilCapacity = globalVar.fryPotThree.OilCapacity;
  1416. FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy += globalVar.fryPotThree.OilCapacity;
  1417. }
  1418. if (globalVar.fryPotFour.OilConfirm == 1)
  1419. {
  1420. FryPotMonitorManage.GetInstance.fryFour.OilCapacity = globalVar.fryPotFour.OilCapacity;
  1421. FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy += globalVar.fryPotFour.OilCapacity;
  1422. }
  1423. if (globalVar.fryPotFive.OilConfirm == 1)
  1424. {
  1425. FryPotMonitorManage.GetInstance.fryFive.OilCapacity = globalVar.fryPotFive.OilCapacity;
  1426. FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy += globalVar.fryPotFive.OilCapacity;
  1427. }
  1428. //炒锅状态实时显示
  1429. FryPotStatusDisplay();
  1430. RollerLineStatusDisplay();
  1431. Thread.Sleep(10);
  1432. }), "MainViewReadPlcData");
  1433. }
  1434. private void FryPotStatusDisplay()
  1435. {
  1436. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.Temperature.ToString();
  1437. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOnePower").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.HotPower.ToString();
  1438. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.Speed.ToString();
  1439. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight.ToString();
  1440. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneOil").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.OilCapacity.ToString();
  1441. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy.ToString();
  1442. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.TotalProduct.ToString();
  1443. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.Temperature.ToString();
  1444. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoPower").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.HotPower.ToString();
  1445. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.Speed.ToString();
  1446. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight.ToString();
  1447. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoOil").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity.ToString();
  1448. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy.ToString();
  1449. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct.ToString();
  1450. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.Temperature.ToString();
  1451. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreePower").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.HotPower.ToString();
  1452. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.Speed.ToString();
  1453. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight.ToString();
  1454. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeOil").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.OilCapacity.ToString();
  1455. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy.ToString();
  1456. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.TotalProduct.ToString();
  1457. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.Temperature.ToString();
  1458. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourPower").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.HotPower.ToString();
  1459. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.Speed.ToString();
  1460. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight.ToString();
  1461. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourOil").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.OilCapacity.ToString();
  1462. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy.ToString();
  1463. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.TotalProduct.ToString();
  1464. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.Temperature.ToString();
  1465. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFivePower").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.HotPower.ToString();
  1466. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.Speed.ToString();
  1467. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight.ToString();
  1468. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveOil").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.OilCapacity.ToString();
  1469. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy.ToString();
  1470. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.TotalProduct.ToString();
  1471. //FryPotMonitorManage.GetInstance.fryFive.Temperature = 10;
  1472. //FryPotMonitorManage.GetInstance.fryFive.HotPower = "9";
  1473. //FryPotMonitorManage.GetInstance.fryFive.Speed = 8;
  1474. //FryPotMonitorManage.GetInstance.fryFive.FryPotWeight=7;
  1475. //FryPotMonitorManage.GetInstance.fryFive.OilCapacity = 6;
  1476. //FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy = 5;
  1477. //FryPotMonitorManage.GetInstance.fryFive.TotalProduct = 4;
  1478. }
  1479. /// <summary>
  1480. /// 炒锅状态数据保存到二进制文件
  1481. /// </summary>
  1482. public void FryPotDataSaveToBinaryFile()
  1483. {
  1484. #region 炒锅1状态数据保存
  1485. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅1状态数据"))
  1486. {
  1487. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据");
  1488. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString()))
  1489. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString());
  1490. if (globalVar.LOneFryPotSerial == 1 && fryOneRecipe != string.Empty)
  1491. {
  1492. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryOneRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1493. {
  1494. writeStream.Position = writeStream.Length;
  1495. PotOneStatus p1 = new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, RecipeName = fryOneRecipe, Time = DateTime.Now.ToShortDateString() };
  1496. BinaryFormatter bf = new BinaryFormatter();
  1497. bf.Serialize(writeStream, p1);
  1498. }
  1499. }
  1500. }
  1501. else
  1502. {
  1503. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString()))
  1504. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString());
  1505. if (globalVar.LOneFryPotSerial == 1 && fryOneRecipe != string.Empty)
  1506. {
  1507. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryOneRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1508. {
  1509. writeStream.Position = writeStream.Length;
  1510. PotOneStatus p1 = new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, RecipeName = fryOneRecipe, Time = DateTime.Now.ToShortDateString() };
  1511. BinaryFormatter bf = new BinaryFormatter();
  1512. bf.Serialize(writeStream, p1);
  1513. }
  1514. }
  1515. }
  1516. #endregion
  1517. #region 炒锅2状态数据保存
  1518. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据"))
  1519. {
  1520. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据");
  1521. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString()))
  1522. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString());
  1523. if (globalVar.LTwoFryPotSerial == 2 && fryTwoRecipe != string.Empty)
  1524. {
  1525. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryTwoRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1526. {
  1527. writeStream.Position = writeStream.Length;
  1528. PotTwoStatus p1 = new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryTwo.HotPower, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, RecipeName = fryTwoRecipe, Time = DateTime.Now.ToShortDateString() };
  1529. BinaryFormatter bf = new BinaryFormatter();
  1530. bf.Serialize(writeStream, p1);
  1531. }
  1532. }
  1533. }
  1534. else
  1535. {
  1536. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString()))
  1537. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString());
  1538. if (globalVar.LTwoFryPotSerial == 2 && fryTwoRecipe != string.Empty)
  1539. {
  1540. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryTwoRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1541. {
  1542. writeStream.Position = writeStream.Length;
  1543. PotTwoStatus p1 = new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryTwo.HotPower, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, RecipeName = fryTwoRecipe, Time = DateTime.Now.ToShortDateString() };
  1544. BinaryFormatter bf = new BinaryFormatter();
  1545. bf.Serialize(writeStream, p1);
  1546. }
  1547. }
  1548. }
  1549. #endregion
  1550. #region 炒锅3状态数据保存
  1551. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据"))
  1552. {
  1553. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据");
  1554. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString()))
  1555. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString());
  1556. if (globalVar.LThreeFryPotSerial == 3 && fryThreeRecipe != string.Empty)
  1557. {
  1558. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryThreeRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1559. {
  1560. writeStream.Position = writeStream.Length;
  1561. PotThreeStatus p1 = new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, RecipeName = fryThreeRecipe, Time = DateTime.Now.ToShortDateString() };
  1562. BinaryFormatter bf = new BinaryFormatter();
  1563. bf.Serialize(writeStream, p1);
  1564. }
  1565. }
  1566. }
  1567. else
  1568. {
  1569. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString()))
  1570. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString());
  1571. if (globalVar.LThreeFryPotSerial == 3 && fryThreeRecipe != string.Empty)
  1572. {
  1573. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryThreeRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1574. {
  1575. writeStream.Position = writeStream.Length;
  1576. PotThreeStatus p1 = new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, RecipeName = fryThreeRecipe, Time = DateTime.Now.ToShortDateString() };
  1577. BinaryFormatter bf = new BinaryFormatter();
  1578. bf.Serialize(writeStream, p1);
  1579. }
  1580. }
  1581. }
  1582. #endregion
  1583. #region 炒锅4状态数据保存
  1584. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据"))
  1585. {
  1586. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据");
  1587. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString()))
  1588. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString());
  1589. if (globalVar.LOneFryPotSerial == 4 && fryFourRecipe != string.Empty)
  1590. {
  1591. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryFourRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1592. {
  1593. writeStream.Position = writeStream.Length;
  1594. PotFourStatus p1 = new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, RecipeName = fryFourRecipe, Time = DateTime.Now.ToShortDateString() };
  1595. BinaryFormatter bf = new BinaryFormatter();
  1596. bf.Serialize(writeStream, p1);
  1597. }
  1598. }
  1599. }
  1600. else
  1601. {
  1602. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString()))
  1603. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString());
  1604. if (globalVar.LOneFryPotSerial == 4 && fryFourRecipe != string.Empty)
  1605. {
  1606. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryFourRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1607. {
  1608. writeStream.Position = writeStream.Length;
  1609. PotFourStatus p1 = new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, RecipeName = fryFourRecipe, Time = DateTime.Now.ToShortDateString() };
  1610. BinaryFormatter bf = new BinaryFormatter();
  1611. bf.Serialize(writeStream, p1);
  1612. }
  1613. }
  1614. }
  1615. #endregion
  1616. #region 炒锅5状态数据保存
  1617. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据"))
  1618. {
  1619. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据");
  1620. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString()))
  1621. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString());
  1622. if (globalVar.LTwoFryPotSerial == 5 && fryFiveRecipe != string.Empty)
  1623. {
  1624. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryFiveRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1625. {
  1626. writeStream.Position = writeStream.Length;
  1627. PotFiveStatus p1 = new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, RecipeName = fryFiveRecipe, Time = DateTime.Now.ToShortDateString() };
  1628. BinaryFormatter bf = new BinaryFormatter();
  1629. bf.Serialize(writeStream, p1);
  1630. }
  1631. }
  1632. }
  1633. else
  1634. {
  1635. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString()))
  1636. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString());
  1637. if (globalVar.LTwoFryPotSerial == 5 && fryFiveRecipe != string.Empty)
  1638. {
  1639. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryFiveRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1640. {
  1641. writeStream.Position = writeStream.Length;
  1642. PotFiveStatus p1 = new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, RecipeName = fryFiveRecipe, Time = DateTime.Now.ToShortDateString() };
  1643. BinaryFormatter bf = new BinaryFormatter();
  1644. bf.Serialize(writeStream, p1);
  1645. }
  1646. }
  1647. }
  1648. #endregion
  1649. }
  1650. /// <summary>
  1651. /// 滚筒线运行状态显示
  1652. /// </summary>
  1653. private void RollerLineStatusDisplay()
  1654. {
  1655. hardWareStatusModel.RollerOneModel.LocOneRollerSerial = globalVar.rollerLineOne.StationOne;
  1656. hardWareStatusModel.RollerOneModel.LocTwoRollerSerial = globalVar.rollerLineOne.StationTwo;
  1657. hardWareStatusModel.RollerOneModel.LocThreeRollerSerial = globalVar.rollerLineOne.StationThree;
  1658. hardWareStatusModel.RollerOneModel.LocFourRollerSerial = globalVar.rollerLineOne.StationFour;
  1659. hardWareStatusModel.RollerOneModel.LocFiveRollerSerial = globalVar.rollerLineOne.StationFive;
  1660. hardWareStatusModel.RollerOneModel.LocSixRollerSerial = globalVar.rollerLineOne.StationSix;
  1661. hardWareStatusModel.RollerOneModel.LocSevenRollerSerial = globalVar.rollerLineOne.StationSeven;
  1662. hardWareStatusModel.RollerOneModel.LocEightRollerSerial = globalVar.rollerLineOne.StationEight;
  1663. if (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 0)
  1664. {
  1665. hardWareStatusModel.RollerOneModel.RollerAlarmState = Color.FromRgb(130, 232, 139);//无故障
  1666. }
  1667. else
  1668. {
  1669. hardWareStatusModel.RollerOneModel.RollerAlarmState = Color.FromRgb(255, 51, 153);//有故障
  1670. }
  1671. if (globalVar.rollerLineOne.OutMaterialingSingle == 1)//运行中
  1672. {
  1673. hardWareStatusModel.RollerOneModel.RollerRunState = Color.FromRgb(130, 232, 139);//运行中
  1674. }
  1675. else
  1676. {
  1677. hardWareStatusModel.RollerOneModel.RollerRunState = Color.FromRgb(84, 84, 84);//未运行
  1678. }
  1679. hardWareStatusModel.RollerTwoModel.LocOneRollerSerial = globalVar.rollerLineTwo.StationOne;
  1680. hardWareStatusModel.RollerTwoModel.LocTwoRollerSerial = globalVar.rollerLineTwo.StationTwo;
  1681. hardWareStatusModel.RollerTwoModel.LocThreeRollerSerial = globalVar.rollerLineTwo.StationThree;
  1682. hardWareStatusModel.RollerTwoModel.LocFourRollerSerial = globalVar.rollerLineTwo.StationFour;
  1683. hardWareStatusModel.RollerTwoModel.LocFiveRollerSerial = globalVar.rollerLineTwo.StationFive;
  1684. hardWareStatusModel.RollerTwoModel.LocSixRollerSerial = globalVar.rollerLineTwo.StationSix;
  1685. hardWareStatusModel.RollerTwoModel.LocSevenRollerSerial = globalVar.rollerLineTwo.StationSeven;
  1686. hardWareStatusModel.RollerTwoModel.LocEightRollerSerial = globalVar.rollerLineTwo.StationEight;
  1687. if (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 0)
  1688. {
  1689. hardWareStatusModel.RollerTwoModel.RollerAlarmState = Color.FromRgb(130, 232, 139);//无故障
  1690. }
  1691. else
  1692. {
  1693. hardWareStatusModel.RollerTwoModel.RollerAlarmState = Color.FromRgb(255, 51, 153);//有故障
  1694. }
  1695. if (globalVar.rollerLineTwo.OutMaterialingSingle == 1)//运行中
  1696. {
  1697. hardWareStatusModel.RollerTwoModel.RollerRunState = Color.FromRgb(130, 232, 139);//运行中
  1698. }
  1699. else
  1700. {
  1701. hardWareStatusModel.RollerTwoModel.RollerRunState = Color.FromRgb(84, 84, 84);//未运行
  1702. }
  1703. hardWareStatusModel.RollerThreeModel.LocOneRollerSerial = globalVar.rollerLineThree.StationOne;
  1704. hardWareStatusModel.RollerThreeModel.LocTwoRollerSerial = globalVar.rollerLineThree.StationTwo;
  1705. hardWareStatusModel.RollerThreeModel.LocThreeRollerSerial = globalVar.rollerLineThree.StationThree;
  1706. hardWareStatusModel.RollerThreeModel.LocFourRollerSerial = globalVar.rollerLineThree.StationFour;
  1707. hardWareStatusModel.RollerThreeModel.LocFiveRollerSerial = globalVar.rollerLineThree.StationFive;
  1708. hardWareStatusModel.RollerThreeModel.LocSixRollerSerial = globalVar.rollerLineThree.StationSix;
  1709. hardWareStatusModel.RollerThreeModel.LocSevenRollerSerial = globalVar.rollerLineThree.StationSeven;
  1710. hardWareStatusModel.RollerThreeModel.LocEightRollerSerial = globalVar.rollerLineThree.StationEight;
  1711. if (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 0)
  1712. {
  1713. hardWareStatusModel.RollerThreeModel.RollerAlarmState = Color.FromRgb(130, 232, 139);//无故障
  1714. }
  1715. else
  1716. {
  1717. hardWareStatusModel.RollerThreeModel.RollerAlarmState = Color.FromRgb(255, 51, 153);//有故障
  1718. }
  1719. if (globalVar.rollerLineThree.OutMaterialingSingle == 1)//运行中
  1720. {
  1721. hardWareStatusModel.RollerThreeModel.RollerRunState = Color.FromRgb(130, 232, 139);//运行中
  1722. }
  1723. else
  1724. {
  1725. hardWareStatusModel.RollerThreeModel.RollerRunState = Color.FromRgb(84, 84, 84);//未运行
  1726. }
  1727. //滚筒线4
  1728. }
  1729. /// <summary>
  1730. /// 返回滚筒线PLC指定地址指定长度的数据
  1731. /// </summary>
  1732. /// <param name="address"></param>
  1733. /// <returns></returns>
  1734. public void GetAddressData(string address, Action<ushort[]> action)
  1735. {
  1736. PlcReadData = DeviceOperate.GetInstance.GetAllData();
  1737. if (PlcReadData.ContainsKey(address))
  1738. {
  1739. action((ushort[])(PlcReadData[address]));
  1740. }
  1741. }
  1742. public void GetFryOneData(string address, Action<ushort[]> action)
  1743. {
  1744. FryOneData = DeviceOperate.GetInstance.GetFryOneData();
  1745. if (FryOneData.ContainsKey(address))
  1746. {
  1747. action((ushort[])(FryOneData[address]));
  1748. }
  1749. }
  1750. public void GetFryTwoData(string address, Action<ushort[]> action)
  1751. {
  1752. FryTwoData = DeviceOperate.GetInstance.GetFryTwoData();
  1753. if (FryTwoData.ContainsKey(address))
  1754. {
  1755. action((ushort[])(FryTwoData[address]));
  1756. }
  1757. }
  1758. public void GetFryThreeData(string address, Action<ushort[]> action)
  1759. {
  1760. FryThreeData = DeviceOperate.GetInstance.GetFryThreeData();
  1761. if (FryThreeData.ContainsKey(address))
  1762. {
  1763. action((ushort[])(FryThreeData[address]));
  1764. }
  1765. }
  1766. public void GetFryFourData(string address, Action<ushort[]> action)
  1767. {
  1768. FryFourData = DeviceOperate.GetInstance.GetFryFourData();
  1769. if (FryFourData.ContainsKey(address))
  1770. {
  1771. action((ushort[])(FryFourData[address]));
  1772. }
  1773. }
  1774. public void GetFryFiveData(string address, Action<ushort[]> action)
  1775. {
  1776. FryFiveData = DeviceOperate.GetInstance.GetFryFiveData();
  1777. if (FryFiveData.ContainsKey(address))
  1778. {
  1779. action((ushort[])(FryFiveData[address]));
  1780. }
  1781. }
  1782. /// <summary>
  1783. /// 写Plc数据
  1784. /// </summary>
  1785. /// <param name="address"></param>
  1786. /// <param name="Value"></param>
  1787. public void WritePlcData(string address, ushort Value)
  1788. {
  1789. DeviceOperate.GetInstance.WritePlcData(address, Value);
  1790. }
  1791. /// <summary>
  1792. /// 初始化任务
  1793. /// </summary>
  1794. //public void IniteTask()
  1795. //{
  1796. // ThreadManage.GetInstance().StartLong(new Action(() =>
  1797. // {
  1798. // MainTask();
  1799. // }), "MainTask");
  1800. //}
  1801. /// <summary>
  1802. /// 配方数据接收
  1803. /// </summary>
  1804. public void RecipeDataParse(object obj)
  1805. {
  1806. Task.Run(new Action(() =>
  1807. {
  1808. if (obj != null && obj is NewRecipeModel[] recipes)
  1809. {
  1810. ReicpeNum = ReicpeNum + recipes.Length;
  1811. MessageLog.GetInstance.ShowUserLog($"新接收到{recipes.Length}个配方,总共{ReicpeNum}个配方");
  1812. for (int i = 0; i < recipes.Length; i++)
  1813. {
  1814. int? res = recipes[i].materialCollection.ElementAt(0).MaterialLoc / 100;
  1815. if (res != null)
  1816. {
  1817. switch (res)
  1818. {
  1819. case 1:
  1820. case 4: RecipeQuene.Enqueue(recipes[i]); break;
  1821. case 3: LThreeRecipeQuene.Enqueue(recipes[i]); break;
  1822. case 2:
  1823. case 5: LTwoRecipeQuene.Enqueue(recipes[i]); break;
  1824. }
  1825. }
  1826. }
  1827. }
  1828. }));
  1829. }
  1830. /// <summary>
  1831. /// 开启主任务
  1832. /// </summary>
  1833. public void MainTask()
  1834. {
  1835. ////RecipeDataToPlc();
  1836. //LOneRecipeDataToPlc();
  1837. //LTwoRecipeDataToPlc();
  1838. //LThreeRecipeDataToPlc();
  1839. ////AgvLoadRoller();
  1840. //LOneLoadRoller();
  1841. //LTwoAgvLoadRoller();
  1842. //LThreeAgvLoadRoller();
  1843. //// FryPotInputMaterial();
  1844. //LOneFryPotInputMaterial();
  1845. //LTwoFryPotInputMaterial();
  1846. //LThreeFryPotInputMaterial();
  1847. ////FryPotOutputMaterial();
  1848. //LOneFryPotOutputMaterial();
  1849. //LTwoFryPotOutputMaterial();
  1850. //LThreeFryPotOutputMaterial();
  1851. ThreadManage.GetInstance().StartLong(new Action(() => { LineOneProcessExecute(); Thread.Sleep(10); }), "滚筒线1任务线程");
  1852. ThreadManage.GetInstance().StartLong(new Action(() => { LineTwoProcessExecute(); Thread.Sleep(10); }), "滚筒线2任务线程");
  1853. ThreadManage.GetInstance().StartLong(new Action(() => { LineThreeProcessExecute(); Thread.Sleep(10); }), "滚筒线3任务线程");
  1854. ThreadManage.GetInstance().StartLong(new Action(() => { LineOneToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线1空桶清洗任务线程");
  1855. ThreadManage.GetInstance().StartLong(new Action(() => { LineTwoToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线2空桶清洗任务线程");
  1856. ThreadManage.GetInstance().StartLong(new Action(() => { LineThreeToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线3空桶清洗任务线程");
  1857. ThreadManage.GetInstance().StartLong(new Action(() => { ToLineFourFromCleanPlate(); Thread.Sleep(10); }), "清洗台空桶回桶任务线程");
  1858. ThreadManage.GetInstance().StartLong(new Action(() => { EmptyRollerToLinFourFromPot(); Thread.Sleep(10); }), "炒锅空桶回桶任务线程");
  1859. }
  1860. /// <summary>
  1861. /// 线体1的执行流程
  1862. /// </summary>
  1863. public void LineOneProcessExecute()
  1864. {
  1865. //if (!globalVar.LOneTaskLock)
  1866. //{
  1867. // globalVar.LOneTaskLock = true;
  1868. LOneRecipeDataToPlc();
  1869. LOneLoadRoller();
  1870. LOneFryPotInputMaterial();
  1871. LOneFallMaterial();
  1872. LOneFryPotOutputMaterial();
  1873. LOneEmptyOperate();
  1874. // globalVar.LOneTaskLock = false;
  1875. //}
  1876. }
  1877. /// <summary>
  1878. /// 线体2的执行流程
  1879. /// </summary>
  1880. public void LineTwoProcessExecute()
  1881. {
  1882. //if (!globalVar.LTwoTaskLock)
  1883. //{
  1884. // globalVar.LTwoTaskLock = true;
  1885. LTwoRecipeDataToPlc();
  1886. LTwoAgvLoadRoller();
  1887. LTwoFryPotInputMaterial();
  1888. LTwoFallMaterial();
  1889. LTwoFryPotOutputMaterial();
  1890. LTwoEmptyOperate();
  1891. // globalVar.LTwoTaskLock = false;
  1892. //}
  1893. }
  1894. /// <summary>
  1895. /// 线体3的执行流程
  1896. /// </summary>
  1897. public void LineThreeProcessExecute()
  1898. {
  1899. //if (!globalVar.LThreeTaskLock)
  1900. //{
  1901. // globalVar.LThreeTaskLock = true;
  1902. LThreeRecipeDataToPlc();
  1903. LThreeAgvLoadRoller();
  1904. LThreeFryPotInputMaterial();
  1905. LThreeFallMaterial();
  1906. LThreeFryPotOutputMaterial();
  1907. LThreeEmptyOperate();
  1908. // globalVar.LThreeTaskLock = false;
  1909. //}
  1910. }
  1911. private void LineOneToCleanProcessExecute()
  1912. {
  1913. //线体1到清洗台
  1914. AgvFromLineOneToCleanPlate();
  1915. AgvArriveCleanPlateFromLineOne();
  1916. }
  1917. public void LineTwoToCleanProcessExecute()
  1918. {
  1919. //线体1到清洗台
  1920. AgvFromLineTwoToCleanPlate();
  1921. AgvArriveCleanPlateFromLineTwo();
  1922. }
  1923. public void LineThreeToCleanProcessExecute()
  1924. {
  1925. //线体1到清洗台
  1926. AgvFromLineThreeToCleanPlate();
  1927. AgvArriveCleanPlateFromLineThree();
  1928. }
  1929. private void ToLineFourFromCleanPlate()
  1930. {
  1931. //空桶到线体4
  1932. CallAgvToLineFour();
  1933. CleanPlateUpLoad();
  1934. EmptyRollerToLinFourFromClean();
  1935. }
  1936. private void CleanPlateUpLoad()
  1937. {
  1938. if (globalVar.agvArriveCleanLoad)
  1939. {
  1940. globalVar.agvArriveCleanLoad = false;
  1941. WritePlcData("D1066", 1);//AGV空桶出桶就位信号下发PlC
  1942. MessageLog.GetInstance.ShowRunLog("AGV到达清洗台空桶上料位置");
  1943. // MessageLog.GetInstance.ShowRunLog("清洗台空桶装载完成");
  1944. if (globalVar.CleadBarrelExitSingle == 0)
  1945. {
  1946. MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶上料信号已发送,出桶滚筒未运行!!");
  1947. }
  1948. }
  1949. }
  1950. /// <summary>
  1951. /// 线体1到清洗台
  1952. /// </summary>
  1953. private void AgvFromLineOneToCleanPlate()
  1954. {
  1955. if (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 0)//输送线无故障
  1956. {
  1957. //线体1到清洗台
  1958. if (!globalVar.rollerLineOne.IsEpmtyBefore && globalVar.rollerLineOne.CanRun)
  1959. {
  1960. var res = InputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineOne.StationEight);
  1961. if ((globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0) && InputMaterialQuene.Count > 0 && globalVar.rollerLineOne.StationEight != InputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0)))//工位8上面有桶且不是配方上的原料桶且工位8的桶号和plc上报的桶号一致,即空桶
  1962. {
  1963. //下发AGV去空桶线洗桶任务
  1964. e: string id = Guid.NewGuid().ToString("N");
  1965. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  1966. goto e;
  1967. string info = AGVHelper.GetInstance.AgvLeaveLOneToClean(id);//1号线到洗桶处
  1968. LSevenrobotJobId.Add(id);
  1969. Thread.Sleep(500);
  1970. LineToCleanCarryTaskErrorCodeAnalysis(info, 1);
  1971. globalVar.rollerLineOne.IsEpmtyBefore = true;
  1972. //globalVar.rollerLineOne.CanRun = false;
  1973. AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  1974. }
  1975. }
  1976. else
  1977. {
  1978. AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  1979. }
  1980. }
  1981. }
  1982. /// <summary>
  1983. /// 线体2到清洗台
  1984. /// </summary>
  1985. private void AgvFromLineTwoToCleanPlate()
  1986. {
  1987. // 线体2到清洗台
  1988. if (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 0)//输送线无故障
  1989. {
  1990. if (!globalVar.rollerLineTwo.IsEpmtyBefore && globalVar.rollerLineTwo.CanRun)
  1991. {
  1992. var res = LTwoInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineTwo.StationEight);
  1993. if ((globalVar.rollerLineTwo.StationEight != 0 && globalVar.rollerLineTwo.EmptyRollerNums.Count > 0 && globalVar.rollerLineTwo.StationEight == globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0) && LTwoInputMaterialQuene.Count > 0 && globalVar.rollerLineTwo.StationEight != LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineTwo.StationEight != 0 && globalVar.rollerLineTwo.EmptyRollerNums.Count > 0 && globalVar.rollerLineTwo.StationEight == globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0)))//工位8上面有桶且不是配方上的原料桶,即空桶
  1994. {
  1995. //下发AGV去空桶线洗桶任务
  1996. e: string id = Guid.NewGuid().ToString("N");
  1997. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  1998. goto e;
  1999. string info = AGVHelper.GetInstance.AgvLeaveLTwoToClean(id);//2号线到洗桶处
  2000. LEightrobotJobId.Add(id);
  2001. Thread.Sleep(500);
  2002. LineToCleanCarryTaskErrorCodeAnalysis(info, 2);
  2003. globalVar.rollerLineTwo.IsEpmtyBefore = true;
  2004. // globalVar.rollerLineTwo.CanRun = false;
  2005. AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体2到清洗处
  2006. }
  2007. }
  2008. else
  2009. {
  2010. AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  2011. }
  2012. }
  2013. }
  2014. /// <summary>
  2015. /// 线体3到清洗台
  2016. /// </summary>
  2017. private void AgvFromLineThreeToCleanPlate()
  2018. {
  2019. //线体3到清洗台
  2020. if (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 0)//输送线无故障
  2021. {
  2022. if (!globalVar.rollerLineThree.IsEpmtyBefore && globalVar.rollerLineThree.CanRun)
  2023. {
  2024. var res = LThreeInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineThree.StationEight);
  2025. if ((globalVar.rollerLineThree.StationEight != 0 && globalVar.rollerLineThree.EmptyRollerNums.Count > 0 && globalVar.rollerLineThree.StationEight == globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0) && LThreeInputMaterialQuene.Count > 0 && globalVar.rollerLineThree.StationEight != LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineThree.StationEight != 0 && globalVar.rollerLineThree.EmptyRollerNums.Count > 0 && globalVar.rollerLineThree.StationEight == globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0)))//工位8上面有桶且不是配方上的原料桶,即空桶
  2026. {
  2027. //下发AGV去空桶线洗桶任务
  2028. e: string id = Guid.NewGuid().ToString("N");
  2029. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  2030. goto e;
  2031. string info = AGVHelper.GetInstance.AgvLeaveLThreeToClean(id);//3号线到洗桶处
  2032. LNinerobotJobId.Add(id);
  2033. Thread.Sleep(500);
  2034. LineToCleanCarryTaskErrorCodeAnalysis(info, 3);
  2035. globalVar.rollerLineThree.IsEpmtyBefore = true;
  2036. //globalVar.rollerLineThree.CanRun = false;
  2037. AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处
  2038. }
  2039. }
  2040. else
  2041. {
  2042. AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处
  2043. }
  2044. }
  2045. }
  2046. /// <summary>
  2047. /// AGV从线体1到达清洗台下料位置
  2048. /// </summary>
  2049. private void AgvArriveCleanPlateFromLineOne()
  2050. {
  2051. if (globalVar.rollerLineOne.agvArriveCleanUnLoad)
  2052. {
  2053. globalVar.rollerLineOne.agvArriveCleanUnLoad = false;
  2054. MessageLog.GetInstance.ShowRunLog("空桶从线体1到达清洗位置,准备卸桶");
  2055. //plc交互
  2056. WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC
  2057. if (globalVar.CleadBarrelEnterSingle == 0)
  2058. {
  2059. MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶下料就位信号已发送,进桶滚筒未运行!!");
  2060. }
  2061. }
  2062. }
  2063. /// <summary>
  2064. /// AGV从线体2到达清洗台下料位置
  2065. /// </summary>
  2066. private void AgvArriveCleanPlateFromLineTwo()
  2067. {
  2068. if (globalVar.rollerLineTwo.agvArriveCleanUnLoad)
  2069. {
  2070. globalVar.rollerLineTwo.agvArriveCleanUnLoad = false;
  2071. MessageLog.GetInstance.ShowRunLog("空桶从线体2到达清洗位置,准备卸桶");
  2072. //plc交互
  2073. WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC
  2074. if (globalVar.CleadBarrelEnterSingle == 0)
  2075. {
  2076. MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶下料就位信号已发送,进桶滚筒未运行!!");
  2077. }
  2078. }
  2079. }
  2080. /// <summary>
  2081. /// AGV从线体3到达清洗台下料位置
  2082. /// </summary>
  2083. private void AgvArriveCleanPlateFromLineThree()
  2084. {
  2085. if (globalVar.rollerLineThree.agvArriveCleanUnLoad)
  2086. {
  2087. globalVar.rollerLineThree.agvArriveCleanUnLoad = false;
  2088. MessageLog.GetInstance.ShowRunLog("空桶从线体3到达清洗位置,准备卸桶");
  2089. //plc交互
  2090. WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC
  2091. if (globalVar.CleadBarrelEnterSingle == 0)
  2092. {
  2093. MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶下料就位信号已发送,进桶滚筒未运行!!");
  2094. }
  2095. }
  2096. }
  2097. /// <summary>
  2098. /// 呼叫Agv从清洗台运洗好的空桶到四号线体
  2099. /// </summary>
  2100. public void CallAgvToLineFour()
  2101. {
  2102. if (globalVar.CleanComplete == 1)
  2103. {
  2104. //是否需要手动给PLC置位??
  2105. globalVar.CleanComplete = 0;
  2106. e: string id = Guid.NewGuid().ToString("N");
  2107. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  2108. goto e;
  2109. string info = AGVHelper.GetInstance.AgvFromCleanToLineFourUnLoadRoller(id);
  2110. LTenrobotJobId.Add(id);
  2111. Thread.Sleep(500);
  2112. MessageLog.GetInstance.ShowRunLog("清洗台呼叫AGV取桶");
  2113. CleanToLineCarryTaskErrorCodeAnalysis(info, 4);
  2114. }
  2115. }
  2116. /// <summary>
  2117. /// 3号滚筒线数据下发 2022/7/4 新增
  2118. /// </summary>
  2119. /// <exception cref="NotImplementedException"></exception>
  2120. private void LThreeRecipeDataToPlc()
  2121. {
  2122. if (LThreeOutputMaterialQuene.Count == 0 && LThreeInputMaterialQuene.Count == 0 && !LThreeErrorRecipe && globalVar.rollerLineThree.RecipeCompleteSingle == 1)
  2123. {
  2124. globalVar.rollerLineThree.RecipeComMidSingle = 1;
  2125. if (globalVar.LThreeCurrentRecipeName != string.Empty)
  2126. {
  2127. MessageLog.GetInstance.ShowUserLog($"【3】号滚筒线【{globalVar.LThreeCurrentRecipeName}】 配方制作完成");
  2128. if (globalVar.LThreeFryPotSerial == 3)
  2129. {
  2130. FryPotMonitorManage.GetInstance.fryThree.TotalProduct++;
  2131. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryThree.txt", false, Encoding.UTF8))
  2132. {
  2133. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  2134. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryThree.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy);//炒锅1产量以及总油量记录
  2135. }
  2136. //Sqlite<PotThreeStatus>.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  2137. //Sqlite<PotThreeStatus>.GetInstance.Save();//保存数据
  2138. }
  2139. globalVar.LThreeCurrentRecipeName = string.Empty;
  2140. Task.Run(() => { Thread.Sleep(1500); fryThreeRecipe = string.Empty; });
  2141. }
  2142. }
  2143. if (LThreeRecipeQuene.Count > 0 && LThreeOutputMaterialQuene.Count == 0 && LThreeInputMaterialQuene.Count == 0 && globalVar.rollerLineThree.RecipeComMidSingle == 1)//后续添加其它限制条件
  2144. {
  2145. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.goodsName = string.Empty; }));
  2146. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows = new ObservableCollection<WorkflowModel>(); }));
  2147. AgvViewModel.GetInstance().Set启动或停止炒锅(3, IsRun.Stop);
  2148. //if (globalVar.LThreeCurrentRecipeName != string.Empty)
  2149. // MessageLog.GetInstance.ShowUserLog($"【3】号滚筒线【{globalVar.LThreeCurrentRecipeName}】 配方制作完成");
  2150. if (LThreeRecipeQuene.TryDequeue(out NewRecipeModel result))
  2151. {
  2152. LThreeErrorRecipe = false;
  2153. int headNum = result.materialCollection[0].MaterialLoc / 100;
  2154. globalVar.LThreeMaterialNum = result.materialCollection.Count;
  2155. globalVar.LThreeFryPotSerial = headNum;
  2156. globalVar.LThreeCurrentRecipeName = result.RecipeName;
  2157. AgvViewModel.GetInstance().Set滚筒线上数量(3, globalVar.LThreeMaterialNum.ToString());
  2158. MessageLog.GetInstance.ShowUserLog($"【3】号滚筒线开始制作【{result.RecipeName}】 配方");
  2159. for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
  2160. {
  2161. if (result.materialCollection[i].MaterialLoc % 100 == i + 1 && result.materialCollection[i].MaterialLoc / 100 == headNum && headNum == 3)
  2162. {
  2163. fryThreeRecipe = result.RecipeName;//炒锅状态开始记录
  2164. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.goodsName = result.RecipeName; }));
  2165. //将配方中原料加入新的队列
  2166. LThreeInputMaterialQuene.Enqueue(new MaterialInfo()
  2167. {
  2168. materialType = result.materialCollection[i],
  2169. materialId = result.RecipeId
  2170. });
  2171. RollerThreeDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight);//3号滚筒线桶号以及重量数据下发
  2172. }
  2173. else
  2174. {
  2175. MessageLog.GetInstance.ShowRunLog($"【3】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  2176. MessageLog.GetInstance.ShowUserLog($"【3】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  2177. LThreeInputMaterialQuene.Clear();
  2178. LThreeErrorRecipe = true;
  2179. return;
  2180. }
  2181. }
  2182. DeviceOperate.GetInstance.WritePlcData("D1043", (ushort)result.materialCollection.Count);//发送3号滚筒线工序数据
  2183. globalVar.rollerLineThree.RecipeComMidSingle = 0;
  2184. }
  2185. }
  2186. }
  2187. /// <summary>
  2188. /// 2号滚筒线数据下发 2022/7/4 新增
  2189. /// </summary>
  2190. /// <exception cref="NotImplementedException"></exception>
  2191. private void LTwoRecipeDataToPlc()
  2192. {
  2193. if (LTwoOutputMaterialQuene.Count == 0 && LTwoInputMaterialQuene.Count == 0 && !LTwoErrorRecipe && globalVar.rollerLineTwo.RecipeCompleteSingle == 1)
  2194. {
  2195. globalVar.rollerLineTwo.RecipeComMidSingle = 1;
  2196. if (globalVar.LTwoCurrentRecipeName != string.Empty)
  2197. {
  2198. MessageLog.GetInstance.ShowUserLog($"【2】号滚筒线【{globalVar.LTwoCurrentRecipeName}】 配方制作完成");
  2199. if (globalVar.LTwoFryPotSerial == 2)
  2200. {
  2201. FryPotMonitorManage.GetInstance.fryTwo.TotalProduct++;
  2202. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryTwo.txt", false, Encoding.UTF8))
  2203. {
  2204. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  2205. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryTwo.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy);//炒锅1产量以及总油量记录
  2206. }
  2207. //Sqlite<PotTwoStatus>.GetInstance.Base.Add(new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryTwo.HotPower, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  2208. //Sqlite<PotTwoStatus>.GetInstance.Save();//保存数据
  2209. }
  2210. if (globalVar.LTwoFryPotSerial == 5)
  2211. {
  2212. FryPotMonitorManage.GetInstance.fryFive.TotalProduct++;
  2213. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryFive.txt", false, Encoding.UTF8))
  2214. {
  2215. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  2216. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryFive.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy);//炒锅1产量以及总油量记录
  2217. }
  2218. //Sqlite<PotFiveStatus>.GetInstance.Base.Add(new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  2219. //Sqlite<PotFiveStatus>.GetInstance.Save();//保存数据
  2220. }
  2221. globalVar.LTwoCurrentRecipeName = string.Empty;
  2222. Task.Run(() => { Thread.Sleep(1500); fryTwoRecipe = string.Empty; fryFiveRecipe = string.Empty; });
  2223. }
  2224. }
  2225. if (LTwoRecipeQuene.Count > 0 && LTwoOutputMaterialQuene.Count == 0 && LTwoInputMaterialQuene.Count == 0 && globalVar.rollerLineTwo.RecipeComMidSingle == 1)//后续添加其它限制条件
  2226. {
  2227. if (globalVar.LTwoFryPotSerial == 2)
  2228. {
  2229. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.goodsName = string.Empty; }));
  2230. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.workflows = new ObservableCollection<WorkflowModel>(); }));
  2231. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Stop);
  2232. }
  2233. if (globalVar.LTwoFryPotSerial == 5)
  2234. {
  2235. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.goodsName = string.Empty; }));
  2236. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.workflows = new ObservableCollection<WorkflowModel>(); }));
  2237. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Stop);
  2238. }
  2239. //if (globalVar.LTwoCurrentRecipeName != string.Empty)
  2240. // MessageLog.GetInstance.ShowUserLog($"【2】号滚筒线【{globalVar.LTwoCurrentRecipeName}】 配方制作完成");
  2241. if (LTwoRecipeQuene.TryDequeue(out NewRecipeModel result))
  2242. {
  2243. LTwoErrorRecipe = false;
  2244. int headNum = result.materialCollection[0].MaterialLoc / 100;
  2245. globalVar.LTwoMaterialNum = result.materialCollection.Count;
  2246. globalVar.LTwoFryPotSerial = headNum;
  2247. globalVar.LTwoCurrentRecipeName = result.RecipeName;
  2248. AgvViewModel.GetInstance().Set滚筒线上数量(2, globalVar.LTwoMaterialNum.ToString());
  2249. MessageLog.GetInstance.ShowUserLog($"【2】号滚筒线开始制作【{result.RecipeName}】 配方");
  2250. for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
  2251. {
  2252. if (result.materialCollection[i].MaterialLoc % 100 == i + 1 && result.materialCollection[i].MaterialLoc / 100 == headNum && (headNum == 2 || headNum == 5))
  2253. {
  2254. if (headNum == 2)//炒锅2
  2255. {
  2256. fryTwoRecipe = result.RecipeName;//炒锅状态开始记录
  2257. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.goodsName = result.RecipeName; }));
  2258. }
  2259. else//炒锅5
  2260. {
  2261. fryFiveRecipe = result.RecipeName;//炒锅状态开始记录
  2262. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.goodsName = result.RecipeName; }));
  2263. }
  2264. //将配方中原料加入新的队列
  2265. LTwoInputMaterialQuene.Enqueue(new MaterialInfo()
  2266. {
  2267. materialType = result.materialCollection[i],
  2268. materialId = result.RecipeId
  2269. });
  2270. RollerTwoDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight);//2号滚筒线桶号以及重量数据下发
  2271. }
  2272. else
  2273. {
  2274. MessageLog.GetInstance.ShowRunLog($"【2】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  2275. MessageLog.GetInstance.ShowUserLog($"【2】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  2276. LTwoInputMaterialQuene.Clear();
  2277. LTwoErrorRecipe = true;
  2278. return;
  2279. }
  2280. }
  2281. DeviceOperate.GetInstance.WritePlcData("D1026", (ushort)result.materialCollection.Count);//发送2号滚筒线工序数据
  2282. globalVar.rollerLineTwo.RecipeComMidSingle = 0;
  2283. }
  2284. }
  2285. }
  2286. /// <summary>
  2287. /// 1号滚筒线数据下发 2022/7/4 新增
  2288. /// </summary>
  2289. private void LOneRecipeDataToPlc()
  2290. {
  2291. if (OutputMaterialQuene.Count == 0 && InputMaterialQuene.Count == 0 && !ErrorRecipe && globalVar.rollerLineOne.RecipeCompleteSingle == 1)
  2292. {
  2293. globalVar.rollerLineOne.RecipeComMidSingle = 1;
  2294. if (globalVar.LOneCurrentRecipeName != string.Empty)
  2295. {
  2296. MessageLog.GetInstance.ShowUserLog($"【1】号滚筒线【{globalVar.LOneCurrentRecipeName}】 配方制作完成");
  2297. if (globalVar.LOneFryPotSerial == 1)
  2298. {
  2299. FryPotMonitorManage.GetInstance.fryOne.TotalProduct++;
  2300. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryOne.txt", false, Encoding.UTF8))
  2301. {
  2302. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  2303. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryOne.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy);//炒锅1产量以及总油量记录
  2304. }
  2305. //Sqlite<PotOneStatus>.GetInstance.Base.Add(new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  2306. //Sqlite<PotOneStatus>.GetInstance.Save();//保存数据
  2307. }
  2308. if (globalVar.LOneFryPotSerial == 4)
  2309. {
  2310. FryPotMonitorManage.GetInstance.fryFour.TotalProduct++;
  2311. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryFour.txt", false, Encoding.UTF8))
  2312. {
  2313. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  2314. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryFour.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy);//炒锅1产量以及总油量记录
  2315. }
  2316. //Sqlite<PotFourStatus>.GetInstance.Base.Add(new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  2317. //Sqlite<PotFourStatus>.GetInstance.Save();//保存数据
  2318. }
  2319. globalVar.LOneCurrentRecipeName = string.Empty;
  2320. Task.Run(() => { Thread.Sleep(1500); fryOneRecipe = string.Empty; fryFourRecipe = string.Empty; });
  2321. }
  2322. }
  2323. if (RecipeQuene.Count > 0 && OutputMaterialQuene.Count == 0 && InputMaterialQuene.Count == 0 && globalVar.rollerLineOne.RecipeComMidSingle == 1)//后续添加其它限制条件
  2324. {
  2325. if (globalVar.LOneFryPotSerial == 1)
  2326. {
  2327. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.goodsName = string.Empty; }));
  2328. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.workflows = new ObservableCollection<WorkflowModel>(); }));
  2329. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Stop);
  2330. }
  2331. if (globalVar.LOneFryPotSerial == 4)
  2332. {
  2333. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.goodsName = string.Empty; }));
  2334. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.workflows = new ObservableCollection<WorkflowModel>(); }));
  2335. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Stop);
  2336. }
  2337. if (RecipeQuene.TryDequeue(out NewRecipeModel result))
  2338. {
  2339. ErrorRecipe = false;
  2340. int headNum = result.materialCollection[0].MaterialLoc / 100;
  2341. globalVar.LOneMaterialNum = result.materialCollection.Count;
  2342. globalVar.LOneFryPotSerial = headNum;
  2343. globalVar.LOneCurrentRecipeName = result.RecipeName;
  2344. AgvViewModel.GetInstance().Set滚筒线上数量(1, globalVar.LOneMaterialNum.ToString());
  2345. MessageLog.GetInstance.ShowUserLog($"【1】号滚筒线开始制作【{result.RecipeName}】 配方");
  2346. for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
  2347. {
  2348. if (result.materialCollection.Count <= 8 && result.materialCollection[i].MaterialLoc % 100 == i + 1 && result.materialCollection[i].MaterialLoc / 100 == headNum && (headNum == 1 || headNum == 4))
  2349. {
  2350. if (headNum == 1)//炒锅1
  2351. {
  2352. fryOneRecipe = result.RecipeName;//炒锅状态开始记录
  2353. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.goodsName = result.RecipeName; }));
  2354. }
  2355. else//炒锅4
  2356. {
  2357. fryFourRecipe = result.RecipeName;//炒锅状态开始记录
  2358. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.goodsName = result.RecipeName; }));
  2359. }
  2360. //将配方中原料加入新的队列
  2361. InputMaterialQuene.Enqueue(new MaterialInfo()
  2362. {
  2363. materialType = result.materialCollection[i],
  2364. materialId = result.RecipeId
  2365. });
  2366. RollerOneDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight);//1号滚筒线桶号以及重量数据下发
  2367. }
  2368. else
  2369. {
  2370. MessageLog.GetInstance.ShowRunLog($"【1】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  2371. MessageLog.GetInstance.ShowUserLog($"【1】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  2372. InputMaterialQuene.Clear();
  2373. ErrorRecipe = true;
  2374. return;
  2375. }
  2376. }
  2377. DeviceOperate.GetInstance.WritePlcData("D1009", (ushort)result.materialCollection.Count);//发送1号滚筒线工序数据
  2378. globalVar.rollerLineOne.RecipeComMidSingle = 0;//配方完成的中转信号置0
  2379. }
  2380. }
  2381. }
  2382. /// <summary>
  2383. /// 数据下发PLC
  2384. /// </summary>
  2385. //public void RecipeDataToPlc()
  2386. //{
  2387. // if (RecipeQuene.Count > 0 && OutputMaterialQuene.Count == 0 && InputMaterialQuene.Count == 0)//后续添加其它限制条件
  2388. // {
  2389. // //NewRecipeModel newRecipe = new NewRecipeModel();
  2390. // //MaterialType material = new MaterialType();
  2391. // if (RecipeQuene.TryDequeue(out NewRecipeModel result))
  2392. // {
  2393. // //newRecipe = result;
  2394. // MessageLog.GetInstance.ShowRunLog($"开始制作【{result.RecipeName}】 配方");
  2395. // //for (int k = 0; k < newRecipe.materialCollection.Count - 1; k++)
  2396. // //{
  2397. // // for (int j = 0; j < newRecipe.materialCollection.Count - 1 - k; j++)
  2398. // // {
  2399. // // if (newRecipe.materialCollection[j].MaterialLoc > newRecipe.materialCollection[j + 1].MaterialLoc)
  2400. // // {
  2401. // // material = newRecipe.materialCollection[j];
  2402. // // // newRecipe.materialCollection[j] = null;
  2403. // // newRecipe.materialCollection[j] = newRecipe.materialCollection[j + 1];
  2404. // // // newRecipe.materialCollection[j + 1] = null;
  2405. // // newRecipe.materialCollection[j + 1] = material;
  2406. // // }
  2407. // // }
  2408. // //}
  2409. // for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
  2410. // {
  2411. // //将配方中原料加入新的队列
  2412. // InputMaterialQuene.Enqueue(new MaterialInfo()
  2413. // {
  2414. // materialType = result.materialCollection[i],
  2415. // materialId = result.RecipeId
  2416. // });
  2417. // ushort n = result.materialCollection[i].MaterialLoc;
  2418. // switch (n / 100)
  2419. // {
  2420. // case 1:
  2421. // case 4: RollerOneDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//1号滚筒线桶号以及重量数据下发
  2422. // case 2:
  2423. // case 5: RollerTwoDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//2号滚筒线桶号以及重量数据下发
  2424. // case 3: RollerThreeDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//3号滚筒线桶号以及重量数据下发
  2425. // }
  2426. // }
  2427. // switch (result.materialCollection[0].MaterialLoc / 100)
  2428. // {
  2429. // case 1:
  2430. // DeviceOperate.GetInstance.WritePlcData("D1009", (ushort)result.materialCollection.Count); break;//发送1号滚筒线工序数据
  2431. // case 2:
  2432. // DeviceOperate.GetInstance.WritePlcData("D1026", (ushort)result.materialCollection.Count); break;//发送2号滚筒线工序数据
  2433. // case 3:
  2434. // DeviceOperate.GetInstance.WritePlcData("D1043", (ushort)result.materialCollection.Count); break;//发送3号滚筒线工序数据
  2435. // }
  2436. // }
  2437. // }
  2438. //}
  2439. /// <summary>
  2440. /// AGV到配方线体1装桶以及出料到炒锅
  2441. /// </summary>
  2442. //public void AgvLoadRoller()
  2443. //{
  2444. // //lineAlarm = 0;
  2445. // if (InputMaterialQuene.Count > 0)
  2446. // {
  2447. // switch (InputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  2448. // {
  2449. // case 1:
  2450. // case 4: AgvToLineOneLoadRoller(); AgvFromLineOneToFryPot(); break;//AGV到1号线体装桶
  2451. // case 2:
  2452. // case 5: AgvToLineTwoLoadRoller(); AgvFromLineTwoToFryPot(); break;//AGV到2号线体装桶
  2453. // case 3: AgvToLineThreeLoadRoller(); AgvFromLineThreeToFryPot(); break;//AGV到3号线体装桶
  2454. // }
  2455. // }
  2456. //}
  2457. /// <summary>
  2458. /// AGV到配方线体1装桶以及出料到炒锅
  2459. /// </summary>
  2460. public void LOneLoadRoller()
  2461. {
  2462. if (InputMaterialQuene.Count > 0)
  2463. {
  2464. AgvToLineOneLoadRoller();
  2465. AgvFromLineOneToFryPot();//AGV到1号线体装桶
  2466. AgvLineOneLoadRollerCom();
  2467. }
  2468. }
  2469. /// <summary>
  2470. /// 判断agv在1号线体是否上料完成,作为线体空桶能否开始运输的条件
  2471. /// </summary>
  2472. /// <exception cref="NotImplementedException"></exception>
  2473. private void AgvLineOneLoadRollerCom()
  2474. {
  2475. if (globalVar.agvLineOneLoadCom)
  2476. {
  2477. globalVar.rollerLineOne.CanRun = true;
  2478. globalVar.agvLineOneLoadCom = false;
  2479. MessageLog.GetInstance.ShowRunLog("AGV在【1】号滚筒线装桶完成");
  2480. }
  2481. }
  2482. /// <summary>
  2483. /// AGV到配方线体2装桶以及出料到炒锅
  2484. /// </summary>
  2485. public void LTwoAgvLoadRoller()
  2486. {
  2487. if (LTwoInputMaterialQuene.Count > 0)
  2488. {
  2489. AgvToLineTwoLoadRoller();
  2490. AgvFromLineTwoToFryPot();//AGV到2号线体装桶
  2491. AgvLineTwoLoadRollerCom();
  2492. }
  2493. }
  2494. /// <summary>
  2495. /// 判断agv在1号线体是否上料完成,作为线体空桶能否开始运输的条件
  2496. /// </summary>
  2497. private void AgvLineTwoLoadRollerCom()
  2498. {
  2499. if (globalVar.agvLineTwoLoadCom)
  2500. {
  2501. globalVar.rollerLineTwo.CanRun = true;
  2502. globalVar.agvLineTwoLoadCom = false;
  2503. MessageLog.GetInstance.ShowRunLog("AGV在【2】号滚筒线装桶完成");
  2504. }
  2505. }
  2506. /// <summary>
  2507. /// AGV到配方线体3装桶以及出料到炒锅
  2508. /// </summary>
  2509. public void LThreeAgvLoadRoller()
  2510. {
  2511. if (LThreeInputMaterialQuene.Count > 0)
  2512. {
  2513. AgvToLineThreeLoadRoller();
  2514. AgvFromLineThreeToFryPot();//AGV到2号线体装桶
  2515. AgvLineThreeLoadRollerCom();
  2516. }
  2517. }
  2518. /// <summary>
  2519. /// 判断agv在1号线体是否上料完成,作为线体空桶能否开始运输的条件
  2520. /// </summary>
  2521. private void AgvLineThreeLoadRollerCom()
  2522. {
  2523. if (globalVar.agvLineThreeLoadCom)
  2524. {
  2525. globalVar.rollerLineThree.CanRun = true;
  2526. globalVar.agvLineThreeLoadCom = false;
  2527. MessageLog.GetInstance.ShowRunLog("AGV在【3】号滚筒线装桶完成");
  2528. }
  2529. }
  2530. /// <summary>
  2531. /// AGV从炒锅送料位置到倒料过程处理
  2532. /// </summary>
  2533. //public void FryPotInputMaterial()
  2534. //{
  2535. // if (OutputMaterialQuene.Count > 0 && !globalVar.InOrOutputLock)
  2536. // {
  2537. // while (!agvArriveUnLoad)//等待agv到达炒锅位置
  2538. // {
  2539. // Thread.Sleep(5);
  2540. // if (globalVar.ExitMainTask)
  2541. // return;
  2542. // }
  2543. // AgvArriveFryPotSingleSetDown();
  2544. // FryPotRollerTroubleCheck();
  2545. // if (FryPotAlarm == 1)//炒锅滚筒无故障
  2546. // {
  2547. // //炒锅滚筒进料运行到位处理
  2548. // FryPotInputMaterialRollerOperate();
  2549. // globalVar.InOrOutputLock = true;
  2550. // }
  2551. // }
  2552. //}
  2553. /// <summary>
  2554. /// 线体1的AGV从炒锅送料位置到倒料过程处理
  2555. /// </summary>
  2556. public void LOneFryPotInputMaterial()
  2557. {
  2558. if (OutputMaterialQuene.Count > 0 && globalVar.agvArriveUnLoad && globalVar.AgvToFryPot && !globalVar.PotOneInputMaterialArrive)
  2559. {
  2560. //if (globalVar.LOneFryPotSerial == 1)
  2561. //{
  2562. // AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.yc_1_1);
  2563. //}
  2564. //else if (globalVar.LOneFryPotSerial == 4)
  2565. //{
  2566. // AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.yc_1_4);
  2567. //}
  2568. MessageLog.GetInstance.ShowRunLog($"AGV到达【{globalVar.LOneFryPotSerial}】号炒锅下料位置");
  2569. AgvArriveFryPotOneOrFourSingleSetDown();
  2570. globalVar.agvArriveUnLoad = false;
  2571. globalVar.PotOneInputMaterialArrive = true;
  2572. FryPotOneRollerTroubleCheck();
  2573. }
  2574. }
  2575. public void LOneFallMaterial()
  2576. {
  2577. if (!globalVar.InOrOutputLock && (globalVar.fryPotOne.InputMaterialArrivedSingle == 1 || globalVar.fryPotFour.InputMaterialArrivedSingle == 1) && globalVar.PotOneInputMaterialArrive && OutputMaterialQuene.Count > 0 && !globalVar.PotOneOutputRollerArrive)
  2578. {
  2579. //if (globalVar.LOneFryPotSerial == 1)
  2580. //{
  2581. // Sqlite<PotOneStatus>.GetInstance.Base.Add(new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  2582. // Sqlite<PotOneStatus>.GetInstance.Save();//保存数据
  2583. //}
  2584. //else
  2585. //{
  2586. // Sqlite<PotFourStatus>.GetInstance.Base.Add(new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  2587. // Sqlite<PotFourStatus>.GetInstance.Save();//保存数据
  2588. //}
  2589. //FryPotOneRollerTroubleCheck();
  2590. if (FryPotAlarm == 1 || FryPotFourAlarm == 1)//炒锅滚筒无故障
  2591. {
  2592. if (globalVar.LOneFryPotSerial == 1)
  2593. {
  2594. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.workflows.Add(new WorkflowModel { id = globalVar.LOneCurrentCookingStep, Name = OutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); }));
  2595. }
  2596. else
  2597. {
  2598. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.workflows.Add(new WorkflowModel { id = globalVar.LOneCurrentCookingStep, Name = OutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); }));
  2599. }
  2600. //炒锅滚筒进料运行到位处理
  2601. FryPotOneOrFourInputMaterialRollerOperate();
  2602. AgvFromFryPotOneOrFourToClean();//上游下发搬运任务给AGV
  2603. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Start);
  2604. globalVar.InOrOutputLock = true;
  2605. globalVar.PotOneOutputRollerArrive = true;
  2606. }
  2607. }
  2608. }
  2609. /// <summary>
  2610. /// 线体2的AGV从炒锅送料位置到倒料过程处理
  2611. /// </summary>
  2612. public void LTwoFryPotInputMaterial()
  2613. {
  2614. if (LTwoOutputMaterialQuene.Count > 0 && globalVar.LTwoagvArriveUnLoad && globalVar.LTwoAgvToFryPot && !globalVar.LTwoPotInputMaterialArrive)
  2615. {
  2616. //if (globalVar.LTwoFryPotSerial == 2)
  2617. //{
  2618. // AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.yc_2_2);
  2619. //}
  2620. //else if (globalVar.LTwoFryPotSerial == 5)
  2621. //{
  2622. // AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.yc_2_5);
  2623. //}
  2624. MessageLog.GetInstance.ShowRunLog($"AGV到达【{globalVar.LTwoFryPotSerial}】号炒锅下料位置");
  2625. AgvArriveFryPotTwoOrFiveSingleSetDown();
  2626. globalVar.LTwoagvArriveUnLoad = false;
  2627. globalVar.LTwoPotInputMaterialArrive = true;
  2628. }
  2629. }
  2630. public void LTwoFallMaterial()
  2631. {
  2632. if (!globalVar.LTwoInOrOutputLock && (globalVar.fryPotTwo.InputMaterialArrivedSingle == 1 || globalVar.fryPotFive.InputMaterialArrivedSingle == 1) && globalVar.LTwoPotInputMaterialArrive && LTwoOutputMaterialQuene.Count > 0 && !globalVar.LTwoPotOutputRollerArrive)
  2633. {
  2634. //if (globalVar.LTwoFryPotSerial == 2)
  2635. //{
  2636. // Sqlite<PotTwoStatus>.GetInstance.Base.Add(new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryTwo.HotPower, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  2637. // Sqlite<PotTwoStatus>.GetInstance.Save();//保存数据
  2638. //}
  2639. //else
  2640. //{
  2641. // Sqlite<PotFiveStatus>.GetInstance.Base.Add(new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  2642. // Sqlite<PotFiveStatus>.GetInstance.Save();//保存数据
  2643. //}
  2644. FryPotTwoRollerTroubleCheck();
  2645. if (FryPotTwoAlarm == 1 || FryPotFiveAlarm == 1)//炒锅滚筒无故障
  2646. {
  2647. if (globalVar.LTwoFryPotSerial == 2)
  2648. {
  2649. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.workflows.Add(new WorkflowModel { id = globalVar.LTwoCurrentCookingStep, Name = LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); }));
  2650. }
  2651. else
  2652. {
  2653. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.workflows.Add(new WorkflowModel { id = globalVar.LTwoCurrentCookingStep, Name = LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); }));
  2654. }
  2655. //炒锅滚筒进料运行到位处理
  2656. FryPotTwoOrFiveInputMaterialRollerOperate();
  2657. AgvFromFryPotTwoOrFiveToClean();//上游下发搬运任务给AGV
  2658. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Start);
  2659. globalVar.LTwoInOrOutputLock = true;
  2660. globalVar.LTwoPotOutputRollerArrive = true;
  2661. }
  2662. }
  2663. }
  2664. /// <summary>
  2665. /// 线体3的AGV从炒锅送料位置到倒料过程处理
  2666. /// </summary>
  2667. public void LThreeFryPotInputMaterial()
  2668. {
  2669. if (LThreeOutputMaterialQuene.Count > 0 && globalVar.LThreeagvArriveUnLoad && globalVar.LThreeAgvToFryPot && !globalVar.LThreePotInputMaterialArrive)
  2670. {
  2671. // AgvViewModel.GetInstance().Set小车运动(3, CartMotionTrajectory.yc_3_3);
  2672. MessageLog.GetInstance.ShowRunLog("AGV到达【3】号炒锅下料位置");
  2673. AgvArriveFryPotThreeSingleSetDown();
  2674. globalVar.LThreeagvArriveUnLoad = false;
  2675. globalVar.LThreePotInputMaterialArrive = true;
  2676. }
  2677. }
  2678. public void LThreeFallMaterial()
  2679. {
  2680. if (!globalVar.LThreeInOrOutputLock && globalVar.fryPotThree.InputMaterialArrivedSingle == 1 && globalVar.LThreePotInputMaterialArrive && LThreeOutputMaterialQuene.Count > 0 && !globalVar.LThreePotOutputRollerArrive)
  2681. {
  2682. //Sqlite<PotThreeStatus>.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  2683. //Sqlite<PotThreeStatus>.GetInstance.Save();//保存数据
  2684. FryPotThreeRollerTroubleCheck();
  2685. if (FryPotThreeAlarm == 1)//炒锅滚筒无故障
  2686. {
  2687. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows.Add(new WorkflowModel { id = globalVar.LThreeCurrentCookingStep, Name = LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); }));
  2688. //炒锅滚筒进料运行到位处理
  2689. FryPotThreeInputMaterialRollerOperate();
  2690. AgvFromFryPotThreeToClean();//上游下发搬运任务给AGV
  2691. AgvViewModel.GetInstance().Set启动或停止炒锅(3, IsRun.Start);
  2692. globalVar.LThreeInOrOutputLock = true;
  2693. globalVar.LThreePotOutputRollerArrive = true;
  2694. }
  2695. }
  2696. }
  2697. /// <summary>
  2698. /// 炒锅出桶
  2699. /// </summary>
  2700. //public void FryPotOutputMaterial()
  2701. //{
  2702. // if (OutputMaterialQuene.Count > 0 && globalVar.InOrOutputLock)
  2703. // {
  2704. // AgvFromFryPotToClean();//上游下发搬运任务给AGV
  2705. // while (!agvArriveUpLoad)//等待agv到达炒锅位置
  2706. // {
  2707. // Thread.Sleep(5);
  2708. // if (globalVar.ExitMainTask)
  2709. // return;
  2710. // }
  2711. // agvArriveUpLoad = false;
  2712. // AgvArriveFryPotOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号
  2713. // FryPotRollerTroubleCheck();
  2714. // if (FryPotAlarm == 1)//无故障
  2715. // {
  2716. // FryPotOutEmpetyRollerOperate();
  2717. // if (OutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
  2718. // {
  2719. // while (!agvFryPotEmptyRollerArrive)//等待AGV拿到出桶空桶
  2720. // {
  2721. // Thread.Sleep(5);
  2722. // if (globalVar.ExitMainTask)
  2723. // return;
  2724. // }
  2725. // //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
  2726. // globalVar.AllowAgvToLineLoadRoller = true;
  2727. // globalVar.InOrOutputLock = false;
  2728. // }
  2729. // }
  2730. // }
  2731. //}
  2732. /// <summary>
  2733. /// 线体1对应炒锅出桶
  2734. /// </summary>
  2735. public void LOneFryPotOutputMaterial()
  2736. {
  2737. if (OutputMaterialQuene.Count > 0 && globalVar.InOrOutputLock && globalVar.agvArriveUpLoad && globalVar.PotOneOutputRollerArrive && !globalVar.AgvArrivePot)
  2738. {
  2739. MessageLog.GetInstance.ShowRunLog($"AGV到达【{globalVar.LOneFryPotSerial}】号炒锅空桶上料位置");
  2740. AgvArriveFryPotOneOrFourOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号
  2741. globalVar.agvArriveUpLoad = false;
  2742. globalVar.AgvArrivePot = true;
  2743. FryPotOneRollerTroubleCheck();
  2744. }
  2745. }
  2746. public void LOneEmptyOperate()
  2747. {
  2748. if ((globalVar.fryPotOne.EmptyBarrelArrivedSingle == 1 || globalVar.fryPotFour.EmptyBarrelArrivedSingle == 1) && OutputMaterialQuene.Count > 0 && globalVar.AgvArrivePot)
  2749. {
  2750. // FryPotOneRollerTroubleCheck();
  2751. if (FryPotAlarm == 1 || FryPotFourAlarm == 1)//无故障
  2752. {
  2753. if (globalVar.agvFryPotEmptyRollerArrive)
  2754. {
  2755. FryPotOneOrFourOutEmpetyRollerOperate();
  2756. if (OutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
  2757. {
  2758. //AgvViewModel.GetInstance().Set小车是否承载物品(1, IsBool.OnllYes);
  2759. //if (globalVar.LOneFryPotSerial == 1)
  2760. //{
  2761. // AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.hs_1);
  2762. //}
  2763. //else if (globalVar.LOneFryPotSerial == 4)
  2764. //{
  2765. // AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.hs_4);
  2766. //}
  2767. globalVar.agvFryPotEmptyRollerArrive = false;
  2768. globalVar.InOrOutputLock = false;
  2769. MessageLog.GetInstance.ShowRunLog($"AGV在【{globalVar.LOneFryPotSerial}】号炒锅将空桶回收到4号滚筒线");
  2770. //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
  2771. globalVar.AllowAgvToLineLoadRoller = true;
  2772. globalVar.LoadRoller = false;
  2773. globalVar.AgvToFryPot = false;
  2774. globalVar.PotOneInputMaterialArrive = false;
  2775. globalVar.PotOneOutputRollerArrive = false;
  2776. globalVar.AgvArrivePot = false;
  2777. }
  2778. }
  2779. }
  2780. }
  2781. }
  2782. /// <summary>
  2783. /// 线体2对应炒锅出桶
  2784. /// </summary>
  2785. public void LTwoFryPotOutputMaterial()
  2786. {
  2787. if (LTwoOutputMaterialQuene.Count > 0 && globalVar.LTwoInOrOutputLock && globalVar.agvArriveLTwoUpLoad && globalVar.LTwoPotOutputRollerArrive && !globalVar.LTwoAgvArrivePot)
  2788. {
  2789. MessageLog.GetInstance.ShowRunLog($"AGV到达【{globalVar.LTwoFryPotSerial}】号炒锅空桶上料位置");
  2790. AgvArriveFryPotTwoOrFiveOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号
  2791. globalVar.agvArriveLTwoUpLoad = false;
  2792. globalVar.LTwoAgvArrivePot = true;
  2793. }
  2794. }
  2795. public void LTwoEmptyOperate()
  2796. {
  2797. if ((globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 1 || globalVar.fryPotFive.EmptyBarrelArrivedSingle == 1) && LTwoOutputMaterialQuene.Count > 0 && globalVar.LTwoAgvArrivePot)
  2798. {
  2799. FryPotTwoRollerTroubleCheck();
  2800. if (FryPotTwoAlarm == 1 || FryPotFiveAlarm == 1)//无故障
  2801. {
  2802. if (globalVar.LTwoagvFryPotEmptyRollerArrive)
  2803. {
  2804. FryPotTwoOrFiveOutEmpetyRollerOperate();
  2805. if (LTwoOutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
  2806. {
  2807. //AgvViewModel.GetInstance().Set小车是否承载物品(2, IsBool.OnllYes);
  2808. //if (globalVar.LTwoFryPotSerial == 2)
  2809. //{
  2810. // AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.hs_2);
  2811. //}
  2812. //else if (globalVar.LTwoFryPotSerial == 5)
  2813. //{
  2814. // AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.hs_5);
  2815. //}
  2816. globalVar.LTwoagvFryPotEmptyRollerArrive = false;
  2817. globalVar.LTwoInOrOutputLock = false;
  2818. MessageLog.GetInstance.ShowRunLog($"AGV在【{globalVar.LTwoFryPotSerial}】号炒锅将空桶回收到4号滚筒线");
  2819. //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
  2820. globalVar.AllowAgvToLineTwoLoadRoller = true;
  2821. globalVar.LTwoLoadRoller = false;
  2822. globalVar.LTwoAgvToFryPot = false;
  2823. globalVar.LTwoPotInputMaterialArrive = false;
  2824. globalVar.LTwoPotOutputRollerArrive = false;
  2825. globalVar.LTwoAgvArrivePot = false;
  2826. }
  2827. }
  2828. }
  2829. }
  2830. }
  2831. /// <summary>
  2832. /// 线体3对应炒锅出桶
  2833. /// </summary>
  2834. public void LThreeFryPotOutputMaterial()
  2835. {
  2836. if (LThreeOutputMaterialQuene.Count > 0 && globalVar.LThreeInOrOutputLock && globalVar.agvArriveLThreeUpLoad && globalVar.LThreePotOutputRollerArrive && !globalVar.LThreeAgvArrivePot)
  2837. {
  2838. MessageLog.GetInstance.ShowRunLog($"AGV到达【{globalVar.LThreeFryPotSerial}】号炒锅空桶上料位置");
  2839. AgvArriveFryPotThreeOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号
  2840. globalVar.agvArriveLThreeUpLoad = false;
  2841. globalVar.LThreeAgvArrivePot = true;
  2842. }
  2843. }
  2844. public void LThreeEmptyOperate()
  2845. {
  2846. if (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 1 && LThreeOutputMaterialQuene.Count > 0 && globalVar.LThreeAgvArrivePot)
  2847. {
  2848. FryPotThreeRollerTroubleCheck();
  2849. if (FryPotThreeAlarm == 1)//无故障
  2850. {
  2851. if (globalVar.LThreeagvFryPotEmptyRollerArrive)
  2852. {
  2853. FryPotThreeOutEmpetyRollerOperate();
  2854. if (LThreeOutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
  2855. {
  2856. //AgvViewModel.GetInstance().Set小车是否承载物品(3, IsBool.OnllYes);
  2857. //AgvViewModel.GetInstance().Set小车运动(3, CartMotionTrajectory.hs_3);
  2858. globalVar.LThreeagvFryPotEmptyRollerArrive = false;
  2859. globalVar.LThreeInOrOutputLock = false;
  2860. MessageLog.GetInstance.ShowRunLog($"AGV在【{globalVar.LThreeFryPotSerial}】号炒锅将空桶回收到4号滚筒线");
  2861. //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
  2862. globalVar.AllowAgvToLineThreeLoadRoller = true;
  2863. globalVar.LThreeLoadRoller = false;
  2864. globalVar.LThreeAgvToFryPot = false;
  2865. globalVar.LThreePotInputMaterialArrive = false;
  2866. globalVar.LThreePotOutputRollerArrive = false;
  2867. globalVar.LThreeAgvArrivePot = false;
  2868. }
  2869. }
  2870. }
  2871. }
  2872. }
  2873. /// <summary>
  2874. /// 清洗台到4号线体下料
  2875. /// </summary>
  2876. public void EmptyRollerToLinFourFromClean()
  2877. {
  2878. if (globalVar.agvArriveLineFour)//agv到达线体4下料位置
  2879. {
  2880. globalVar.agvArriveLineFour = false;
  2881. //线体四信号交互
  2882. WritePlcData("D1067", 1);//AGV空桶回桶就位信号下发PLC
  2883. MessageLog.GetInstance.ShowRunLog("AGV从清洗台到达【4】号回收线体,准备卸桶");
  2884. // MessageLog.GetInstance.ShowRunLog("卸桶完成");
  2885. }
  2886. }
  2887. public void EmptyRollerToLinFourFromPot()
  2888. {
  2889. if (globalVar.rollerLineOne.agvArriveLineFour)//agv到达线体4下料位置
  2890. {
  2891. globalVar.rollerLineOne.agvArriveLineFour = false;
  2892. //线体四信号交互
  2893. WritePlcData("D1067", 1);//AGV空桶回桶就位信号下发PLC
  2894. MessageLog.GetInstance.ShowRunLog("AGV从1号线体对应炒锅到达【4】号回收线体,准备卸桶");
  2895. // MessageLog.GetInstance.ShowRunLog("卸桶完成");
  2896. }
  2897. if (globalVar.rollerLineTwo.agvArriveLineFour)//agv到达线体4下料位置
  2898. {
  2899. globalVar.rollerLineTwo.agvArriveLineFour = false;
  2900. //线体四信号交互
  2901. WritePlcData("D1067", 1);//AGV空桶回桶就位信号下发PLC
  2902. MessageLog.GetInstance.ShowRunLog("AGV从2号线体对应炒锅到达【4】号回收线体,准备卸桶");
  2903. // MessageLog.GetInstance.ShowRunLog("卸桶完成");
  2904. }
  2905. if (globalVar.rollerLineThree.agvArriveLineFour)//agv到达线体4下料位置
  2906. {
  2907. globalVar.rollerLineThree.agvArriveLineFour = false;
  2908. //线体四信号交互
  2909. WritePlcData("D1067", 1);//AGV空桶回桶就位信号下发PLC
  2910. MessageLog.GetInstance.ShowRunLog("AGV从3号炒锅到达【4】号回收线体,准备卸桶");
  2911. // MessageLog.GetInstance.ShowRunLog("卸桶完成");
  2912. }
  2913. }
  2914. ///// <summary>
  2915. ///// 线体1对应炒锅到4号线体下料
  2916. ///// </summary>
  2917. //public void EmptyRollerToLinFourFromLineOne()
  2918. //{
  2919. // if (globalVar.rollerLineOne.agvArriveLineFour)//agv到达线体4下料位置
  2920. // {
  2921. // globalVar.rollerLineOne.agvArriveLineFour = false;
  2922. // //线体四信号交互
  2923. // WritePlcData("D1067", 1);//AGV空桶回桶就位信号下发PLC
  2924. // MessageLog.GetInstance.ShowRunLog("AGV从1号线体对应炒锅到达【4】号回收线体,准备卸桶");
  2925. // // MessageLog.GetInstance.ShowRunLog("卸桶完成");
  2926. // }
  2927. //}
  2928. ///// <summary>
  2929. /////线体2对应炒锅到4号线体下料
  2930. ///// </summary>
  2931. //public void EmptyRollerToLinFourFromLineTwo()
  2932. //{
  2933. // if (globalVar.rollerLineTwo.agvArriveLineFour)//agv到达线体4下料位置
  2934. // {
  2935. // globalVar.rollerLineTwo.agvArriveLineFour = false;
  2936. // //线体四信号交互
  2937. // WritePlcData("D1067", 1);//AGV空桶回桶就位信号下发PLC
  2938. // MessageLog.GetInstance.ShowRunLog("AGV从2号线体对应炒锅到达【4】号回收线体,准备卸桶");
  2939. // // MessageLog.GetInstance.ShowRunLog("卸桶完成");
  2940. // }
  2941. //}
  2942. ///// <summary>
  2943. ///// 线体3对应炒锅到4号线体下料
  2944. ///// </summary>
  2945. //public void EmptyRollerToLinFourFromLineThree()
  2946. //{
  2947. // if (globalVar.rollerLineThree.agvArriveLineFour)//agv到达线体4下料位置
  2948. // {
  2949. // globalVar.rollerLineThree.agvArriveLineFour = false;
  2950. // //线体四信号交互
  2951. // WritePlcData("D1067", 1);//AGV空桶回桶就位信号下发PLC
  2952. // MessageLog.GetInstance.ShowRunLog("AGV从3号炒锅到达【4】号回收线体,准备卸桶");
  2953. // // MessageLog.GetInstance.ShowRunLog("卸桶完成");
  2954. // }
  2955. //}
  2956. /// <summary>
  2957. /// 炒锅1,4滚筒进料运行到位处理
  2958. /// </summary>
  2959. public void FryPotOneOrFourInputMaterialRollerOperate()
  2960. {
  2961. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  2962. {
  2963. case 1:
  2964. //while (globalVar.fryPotOne.InputMaterialArrivedSingle == 0)
  2965. //{
  2966. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2967. // return;
  2968. //}
  2969. MessageLog.GetInstance.ShowRunLog($"炒锅【1】:【{OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料"); break;
  2970. case 4:
  2971. //while (globalVar.fryPotFour.InputMaterialArrivedSingle == 0)
  2972. //{
  2973. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2974. // return;
  2975. //}
  2976. MessageLog.GetInstance.ShowRunLog($"炒锅【4】:【{OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料"); break;
  2977. }
  2978. }
  2979. /// <summary>
  2980. /// 炒锅2,5滚筒进料运行到位处理
  2981. /// </summary>
  2982. public void FryPotTwoOrFiveInputMaterialRollerOperate()
  2983. {
  2984. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  2985. {
  2986. case 2:
  2987. //while (globalVar.fryPotTwo.InputMaterialArrivedSingle == 0)
  2988. //{
  2989. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2990. // return;
  2991. //}
  2992. MessageLog.GetInstance.ShowRunLog($"炒锅【2】:【{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料"); break;
  2993. case 5:
  2994. //while (globalVar.fryPotFive.InputMaterialArrivedSingle == 0)
  2995. //{
  2996. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2997. // return;
  2998. //}
  2999. MessageLog.GetInstance.ShowRunLog($"炒锅【5】:【{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料"); break;
  3000. }
  3001. }
  3002. public void FryPotThreeInputMaterialRollerOperate()
  3003. {
  3004. //while (globalVar.fryPotThree.InputMaterialArrivedSingle == 0)
  3005. //{
  3006. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3007. // return;
  3008. //}
  3009. MessageLog.GetInstance.ShowRunLog($"炒锅【3】:【{LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料");
  3010. }
  3011. /// <summary>
  3012. /// 炒锅滚筒空桶出桶处理
  3013. /// </summary>
  3014. //public void FryPotOutEmpetyRollerOperate(ConcurrentQueue<MaterialInfo> queue)
  3015. //{
  3016. // switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  3017. // {
  3018. // case 1:
  3019. // while (globalVar.fryPotOne.EmptyBarrelArrivedSingle == 0)
  3020. // {
  3021. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3022. // return;
  3023. // }
  3024. // MessageLog.GetInstance.ShowRunLog($"炒锅【1】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  3025. // case 2:
  3026. // while (globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 0)
  3027. // {
  3028. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3029. // return;
  3030. // }
  3031. // MessageLog.GetInstance.ShowRunLog($"炒锅【2】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  3032. // case 3:
  3033. // while (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 0)
  3034. // {
  3035. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3036. // return;
  3037. // }
  3038. // MessageLog.GetInstance.ShowRunLog($"炒锅【3】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  3039. // case 4:
  3040. // while (globalVar.fryPotFour.EmptyBarrelArrivedSingle == 0)
  3041. // {
  3042. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3043. // return;
  3044. // }
  3045. // MessageLog.GetInstance.ShowRunLog($"炒锅【4】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  3046. // case 5:
  3047. // while (globalVar.fryPotFive.EmptyBarrelArrivedSingle == 0)
  3048. // {
  3049. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3050. // return;
  3051. // }
  3052. // MessageLog.GetInstance.ShowRunLog($"炒锅【5】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  3053. // }
  3054. //}
  3055. /// <summary>
  3056. /// 炒锅1,4滚筒空桶出桶处理
  3057. /// </summary>
  3058. public void FryPotOneOrFourOutEmpetyRollerOperate()
  3059. {
  3060. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  3061. {
  3062. case 1:
  3063. //while (globalVar.fryPotOne.EmptyBarrelArrivedSingle == 0)
  3064. //{
  3065. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3066. // return;
  3067. //}
  3068. MessageLog.GetInstance.ShowRunLog($"炒锅【1】原料:【{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}】空桶上料完成"); break;
  3069. case 4:
  3070. //while (globalVar.fryPotFour.EmptyBarrelArrivedSingle == 0)
  3071. //{
  3072. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3073. // return;
  3074. //}
  3075. MessageLog.GetInstance.ShowRunLog($"炒锅【4】原料:【{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}】空桶上料完成"); break;
  3076. }
  3077. }
  3078. /// <summary>
  3079. /// 炒锅2,5滚筒空桶出桶处理
  3080. /// </summary>
  3081. public void FryPotTwoOrFiveOutEmpetyRollerOperate()
  3082. {
  3083. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  3084. {
  3085. case 2:
  3086. //while (globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 0)
  3087. //{
  3088. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3089. // return;
  3090. //}
  3091. MessageLog.GetInstance.ShowRunLog($"炒锅【2】原料:【{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialName}】空桶上料完成"); break;
  3092. case 5:
  3093. //while (globalVar.fryPotFive.EmptyBarrelArrivedSingle == 0)
  3094. //{
  3095. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3096. // return;
  3097. //}
  3098. MessageLog.GetInstance.ShowRunLog($"炒锅【5】原料:【{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialName}】空桶上料完成"); break;
  3099. }
  3100. }
  3101. /// <summary>
  3102. /// 炒锅3滚筒空桶出桶处理
  3103. /// </summary>
  3104. public void FryPotThreeOutEmpetyRollerOperate()
  3105. {
  3106. //while (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 0)
  3107. //{
  3108. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3109. // return;
  3110. //}
  3111. MessageLog.GetInstance.ShowRunLog($"炒锅【3】原料:【{LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialName}】空桶上料完成");
  3112. }
  3113. /// <summary>
  3114. /// 发送agv送料就位信号至PLC(线体到炒锅)
  3115. /// </summary>
  3116. public void AgvArriveFryPotSingleSetDown(ConcurrentQueue<MaterialInfo> queue)
  3117. {
  3118. switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  3119. {
  3120. case 1: DeviceOperate.GetInstance.WritePlcData("D1055", 1); break;//agv到炒锅1送料就位信号
  3121. case 2: DeviceOperate.GetInstance.WritePlcData("D1056", 1); break;//agv到炒锅2送料就位信号
  3122. case 3: DeviceOperate.GetInstance.WritePlcData("D1057", 1); break;//agv到炒锅3送料就位信号
  3123. case 4: DeviceOperate.GetInstance.WritePlcData("D1058", 1); break;//agv到炒锅4送料就位信号
  3124. case 5: DeviceOperate.GetInstance.WritePlcData("D1059", 1); break;//agv到炒锅5送料就位信号
  3125. }
  3126. }
  3127. /// <summary>
  3128. /// 发送agv送料就位信号至PLC(线体1到炒锅)
  3129. /// </summary>
  3130. public void AgvArriveFryPotOneOrFourSingleSetDown()
  3131. {
  3132. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  3133. {
  3134. case 1: DeviceOperate.GetInstance.WritePlcData("D1055", 1); break;//agv到炒锅1送料就位信号
  3135. case 4: DeviceOperate.GetInstance.WritePlcData("D1058", 1); break;//agv到炒锅4送料就位信号
  3136. }
  3137. }
  3138. /// <summary>
  3139. /// 发送agv送料就位信号至PLC(线体2到炒锅)
  3140. /// </summary>
  3141. public void AgvArriveFryPotTwoOrFiveSingleSetDown()
  3142. {
  3143. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  3144. {
  3145. case 2: DeviceOperate.GetInstance.WritePlcData("D1056", 1); break;//agv到炒锅2送料就位信号
  3146. case 5: DeviceOperate.GetInstance.WritePlcData("D1059", 1); break;//agv到炒锅5送料就位信号
  3147. }
  3148. }
  3149. /// <summary>
  3150. /// 发送agv送料就位信号至PLC(线体3到炒锅)
  3151. /// </summary>
  3152. public void AgvArriveFryPotThreeSingleSetDown()
  3153. {
  3154. DeviceOperate.GetInstance.WritePlcData("D1057", 1); //agv到炒锅3送料就位信号
  3155. }
  3156. /// <summary>
  3157. /// 发送agv回桶就位信号至PLC
  3158. /// </summary>
  3159. public void AgvArriveFryPotOutEmptyRollerSingleSetDown(ConcurrentQueue<MaterialInfo> queue)
  3160. {
  3161. switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  3162. {
  3163. case 1: DeviceOperate.GetInstance.WritePlcData("D1060", 1); break;//agv到炒锅1送料就位信号
  3164. case 2: DeviceOperate.GetInstance.WritePlcData("D1061", 1); break;//agv到炒锅2送料就位信号
  3165. case 3: DeviceOperate.GetInstance.WritePlcData("D1062", 1); break;//agv到炒锅3送料就位信号
  3166. case 4: DeviceOperate.GetInstance.WritePlcData("D1063", 1); break;//agv到炒锅4送料就位信号
  3167. case 5: DeviceOperate.GetInstance.WritePlcData("D1064", 1); break;//agv到炒锅5送料就位信号
  3168. }
  3169. }
  3170. public void AgvArriveFryPotOneOrFourOutEmptyRollerSingleSetDown()
  3171. {
  3172. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  3173. {
  3174. case 1: DeviceOperate.GetInstance.WritePlcData("D1060", 1); break;//agv到炒锅1送料就位信号
  3175. case 4: DeviceOperate.GetInstance.WritePlcData("D1063", 1); break;//agv到炒锅4送料就位信号
  3176. }
  3177. }
  3178. public void AgvArriveFryPotTwoOrFiveOutEmptyRollerSingleSetDown()
  3179. {
  3180. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  3181. {
  3182. case 2: DeviceOperate.GetInstance.WritePlcData("D1061", 1); break;//agv到炒锅2送料就位信号
  3183. case 5: DeviceOperate.GetInstance.WritePlcData("D1064", 1); break;//agv到炒锅5送料就位信号
  3184. }
  3185. }
  3186. public void AgvArriveFryPotThreeOutEmptyRollerSingleSetDown()
  3187. {
  3188. DeviceOperate.GetInstance.WritePlcData("D1062", 1);//agv到炒锅3送料就位信号
  3189. }
  3190. ///// <summary>
  3191. ///// AGV离开炒锅运送空桶任务
  3192. ///// </summary>
  3193. //public void AgvFromFryPotToClean(ConcurrentQueue<MaterialInfo> queue)
  3194. //{
  3195. // switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  3196. // {
  3197. // case 1:
  3198. // erp: string id = Guid.NewGuid().ToString("N");//上游唯一ID
  3199. // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId)
  3200. // {
  3201. // goto erp;
  3202. // }
  3203. // string info = AGVHelper.GetInstance.AgvLeaveFryPotOne(id);
  3204. // LOnerobotJobId = id;
  3205. // FryCarryTaskErrorCodeAnalysis(info, 1); break;
  3206. // case 2:
  3207. // erp1: string id1 = Guid.NewGuid().ToString("N");//上游唯一ID
  3208. // if (id1 == LTworobotJobId)
  3209. // {
  3210. // goto erp1;
  3211. // }
  3212. // string info1 = AGVHelper.GetInstance.AgvLeaveFryPotTwo(id1);
  3213. // LTworobotJobId = id1;
  3214. // FryCarryTaskErrorCodeAnalysis(info1, 2); break;
  3215. // case 3:
  3216. // erp2: string id2 = Guid.NewGuid().ToString("N");//上游唯一ID
  3217. // if (id2 == LThreerobotJobId)
  3218. // {
  3219. // goto erp2;
  3220. // }
  3221. // string info2 = AGVHelper.GetInstance.AgvLeaveFryPotThree(id2);
  3222. // LThreerobotJobId = id2;
  3223. // FryCarryTaskErrorCodeAnalysis(info2, 3); break;
  3224. // case 4:
  3225. // erp3: string id3 = Guid.NewGuid().ToString("N");//上游唯一ID
  3226. // if (id3 == LOnerobotJobId)
  3227. // {
  3228. // goto erp3;
  3229. // }
  3230. // string info3 = AGVHelper.GetInstance.AgvLeaveFryPotFour(id3);
  3231. // LOnerobotJobId = id3;
  3232. // FryCarryTaskErrorCodeAnalysis(info3, 4); break;
  3233. // case 5:
  3234. // erp4: string id4 = Guid.NewGuid().ToString("N");//上游唯一ID
  3235. // if (id4 == LTworobotJobId)
  3236. // {
  3237. // goto erp4;
  3238. // }
  3239. // string info4 = AGVHelper.GetInstance.AgvLeaveFryPotFive(id4);
  3240. // LTworobotJobId = id4;
  3241. // FryCarryTaskErrorCodeAnalysis(info4, 5); break;
  3242. // }
  3243. //}
  3244. /// <summary>
  3245. /// AGV离开炒锅1,4运送空桶任务
  3246. /// </summary>
  3247. public void AgvFromFryPotOneOrFourToClean()
  3248. {
  3249. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  3250. {
  3251. case 1:
  3252. erp: string id = Guid.NewGuid().ToString("N");//上游唯一ID
  3253. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  3254. {
  3255. goto erp;
  3256. }
  3257. MessageLog.GetInstance.ShowRunLog("AGV执行【1】号炒锅空桶回收任务");
  3258. string info = AGVHelper.GetInstance.AgvLeaveFryPotOne(id);
  3259. LFourrobotJobId = id;
  3260. FryCarryTaskErrorCodeAnalysis(info, 1); break;
  3261. case 4:
  3262. erp3: string id3 = Guid.NewGuid().ToString("N");//上游唯一ID
  3263. if (id3 == LOnerobotJobId || id3 == LTworobotJobId || id3 == LThreerobotJobId || id3 == LFourrobotJobId || id3 == LFiverobotJobId || id3 == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id3) != null || LEightrobotJobId.FirstOrDefault(p => p == id3) != null || LNinerobotJobId.FirstOrDefault(p => p == id3) != null || LTenrobotJobId.FirstOrDefault(p => p == id3) != null)
  3264. {
  3265. goto erp3;
  3266. }
  3267. MessageLog.GetInstance.ShowRunLog("AGV执行【4】号炒锅空桶回收任务");
  3268. string info3 = AGVHelper.GetInstance.AgvLeaveFryPotFour(id3);
  3269. LFourrobotJobId = id3;
  3270. FryCarryTaskErrorCodeAnalysis(info3, 4); break;
  3271. }
  3272. }
  3273. /// <summary>
  3274. /// AGV离开炒锅2,5运送空桶任务
  3275. /// </summary>
  3276. public void AgvFromFryPotTwoOrFiveToClean()
  3277. {
  3278. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  3279. {
  3280. case 2:
  3281. erp1: string id1 = Guid.NewGuid().ToString("N");//上游唯一ID
  3282. if (id1 == LOnerobotJobId || id1 == LTworobotJobId || id1 == LThreerobotJobId || id1 == LFourrobotJobId || id1 == LFiverobotJobId || id1 == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id1) != null || LEightrobotJobId.FirstOrDefault(p => p == id1) != null || LNinerobotJobId.FirstOrDefault(p => p == id1) != null || LTenrobotJobId.FirstOrDefault(p => p == id1) != null)
  3283. {
  3284. goto erp1;
  3285. }
  3286. MessageLog.GetInstance.ShowRunLog("AGV执行【2】号炒锅空桶回收任务");
  3287. string info1 = AGVHelper.GetInstance.AgvLeaveFryPotTwo(id1);
  3288. LFiverobotJobId = id1;
  3289. FryCarryTaskErrorCodeAnalysis(info1, 2); break;
  3290. case 5:
  3291. erp4: string id4 = Guid.NewGuid().ToString("N");//上游唯一ID
  3292. if (id4 == LOnerobotJobId || id4 == LTworobotJobId || id4 == LThreerobotJobId || id4 == LFourrobotJobId || id4 == LFiverobotJobId || id4 == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id4) != null || LEightrobotJobId.FirstOrDefault(p => p == id4) != null || LNinerobotJobId.FirstOrDefault(p => p == id4) != null || LTenrobotJobId.FirstOrDefault(p => p == id4) != null)
  3293. {
  3294. goto erp4;
  3295. }
  3296. MessageLog.GetInstance.ShowRunLog("AGV执行【5】号炒锅空桶回收任务");
  3297. string info4 = AGVHelper.GetInstance.AgvLeaveFryPotFive(id4);
  3298. LFiverobotJobId = id4;
  3299. FryCarryTaskErrorCodeAnalysis(info4, 5); break;
  3300. }
  3301. }
  3302. /// <summary>
  3303. /// AGV离开炒锅3运送空桶任务
  3304. /// </summary>
  3305. public void AgvFromFryPotThreeToClean()
  3306. {
  3307. erp2: string id2 = Guid.NewGuid().ToString("N");//上游唯一ID
  3308. if (id2 == LOnerobotJobId || id2 == LTworobotJobId || id2 == LThreerobotJobId || id2 == LFourrobotJobId || id2 == LFiverobotJobId || id2 == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id2) != null || LEightrobotJobId.FirstOrDefault(p => p == id2) != null || LNinerobotJobId.FirstOrDefault(p => p == id2) != null || LTenrobotJobId.FirstOrDefault(p => p == id2) != null)
  3309. {
  3310. goto erp2;
  3311. }
  3312. MessageLog.GetInstance.ShowRunLog("AGV执行【3】号炒锅空桶回收任务");
  3313. string info2 = AGVHelper.GetInstance.AgvLeaveFryPotThree(id2);
  3314. LSixrobotJobId = id2;
  3315. FryCarryTaskErrorCodeAnalysis(info2, 3);
  3316. }
  3317. /// <summary>
  3318. /// 处理agv从线体1到送料到炒锅的条件
  3319. /// </summary>
  3320. /// <param name="lineAlarm"></param>
  3321. public void AgvFromLineOneToFryPot()
  3322. {
  3323. erp: if (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 0)
  3324. {
  3325. if (globalVar.agvArriveUpLoad && globalVar.LoadRoller && globalVar.rollerLineOne.StationEight == InputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.AgvToFryPot)//无故障
  3326. {
  3327. MessageLog.GetInstance.ShowRunLog("AGV到达【1】号滚筒线装桶位置");
  3328. AgvArriveLineSingelSetDown(InputMaterialQuene);
  3329. if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
  3330. {
  3331. MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶");
  3332. globalVar.LOneCurrentCookingStep++;
  3333. OutputMaterialQuene.Enqueue(materialInfo);
  3334. globalVar.agvArriveUpLoad = false;
  3335. globalVar.AgvToFryPot = true;
  3336. //原料到位,agv到位,agv自行运料到炒锅
  3337. }
  3338. }
  3339. }
  3340. else//有故障
  3341. {
  3342. while (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 1)
  3343. {
  3344. Thread.Sleep(5);
  3345. if (globalVar.ExitLineOneTask)
  3346. return;
  3347. }
  3348. MessageLog.GetInstance.ShowRunLog("线体【1】滚筒故障解除,继续运行");
  3349. //lineAlarm = 1;
  3350. goto erp;
  3351. }
  3352. }
  3353. /// <summary>
  3354. /// Agv从1号线体运空桶到清洗处
  3355. /// </summary>
  3356. public void AgvFromLineOneToClean(ushort emptyRollerNum)
  3357. {
  3358. erp: if (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 0)//无故障
  3359. {
  3360. if (globalVar.agvArriveLineOneLoadEmptyRoller)//agv到达上料位置
  3361. {
  3362. MessageLog.GetInstance.ShowRunLog("AGV到达【1】号滚筒线装桶位置");
  3363. DeviceOperate.GetInstance.WritePlcData("D1052", 1);//agv到达线体1上料位置信号下发plc
  3364. MessageLog.GetInstance.ShowRunLog($"AGV正在装载【{emptyRollerNum}】号空料桶");
  3365. globalVar.agvArriveLineOneLoadEmptyRoller = false;
  3366. //原料到位,agv到位,agv自行运料到清洗处
  3367. }
  3368. if (globalVar.agvArriveLineOneLoadCom)//上料完成
  3369. {
  3370. globalVar.rollerLineOne.EmptyRollerNums.RemoveAt(0);
  3371. globalVar.agvArriveLineOneLoadCom = false;
  3372. globalVar.rollerLineOne.IsEpmtyBefore = false;
  3373. MessageLog.GetInstance.ShowRunLog($"AGV在【1】号线体完成【{emptyRollerNum}】号空料桶装载");
  3374. }
  3375. }
  3376. else//有故障
  3377. {
  3378. while (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 1)
  3379. {
  3380. Thread.Sleep(5);
  3381. if (globalVar.ExitLineOneTask)
  3382. return;
  3383. }
  3384. MessageLog.GetInstance.ShowRunLog("线体【1】滚筒故障解除,继续运行");
  3385. //lineAlarm = 1;
  3386. goto erp;
  3387. }
  3388. }
  3389. /// <summary>
  3390. /// 处理agv从线体2到送料到炒锅的条件
  3391. /// </summary>
  3392. /// <param name="lineAlarm"></param>
  3393. public void AgvFromLineTwoToFryPot()
  3394. {
  3395. erp: if (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 0)//无故障
  3396. {
  3397. if (globalVar.agvArriveLTwoUpLoad && globalVar.LTwoLoadRoller && globalVar.rollerLineTwo.StationEight == LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.LTwoAgvToFryPot)//无故障
  3398. {
  3399. MessageLog.GetInstance.ShowRunLog("AGV到达【2】号滚筒线装桶位置");
  3400. AgvArriveLineSingelSetDown(LTwoInputMaterialQuene);
  3401. if (LTwoInputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
  3402. {
  3403. MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶");
  3404. globalVar.LTwoCurrentCookingStep++;
  3405. LTwoOutputMaterialQuene.Enqueue(materialInfo);
  3406. globalVar.agvArriveLTwoUpLoad = false;
  3407. globalVar.LTwoAgvToFryPot = true;
  3408. //原料到位,agv到位,agv自行运料到炒锅
  3409. }
  3410. }
  3411. }
  3412. else//有故障
  3413. {
  3414. while (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 1)
  3415. {
  3416. Thread.Sleep(5);
  3417. if (globalVar.ExitLineTwoTask)
  3418. return;
  3419. }
  3420. MessageLog.GetInstance.ShowRunLog("线体【2】滚筒故障解除,继续运行");
  3421. // lineAlarm = 1;
  3422. goto erp;
  3423. }
  3424. }
  3425. /// <summary>
  3426. /// Agv从2号线体运空桶到清洗处
  3427. /// </summary>
  3428. public void AgvFromLineTwoToClean(ushort emptyRollerNum)
  3429. {
  3430. erp: if (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 0)//无故障
  3431. {
  3432. if (globalVar.agvArriveLineTwoLoadEmptyRoller)//agv到达上料位置
  3433. {
  3434. MessageLog.GetInstance.ShowRunLog("AGV到达【2】号滚筒线装桶位置");
  3435. DeviceOperate.GetInstance.WritePlcData("D1053", 1);//agv到达线体2上料位置信号下发plc
  3436. MessageLog.GetInstance.ShowRunLog($"AGV正在装载【{emptyRollerNum}】号空料桶");
  3437. globalVar.agvArriveLineTwoLoadEmptyRoller = false;
  3438. //原料到位,agv到位,agv自行运料到清洗处
  3439. }
  3440. if (globalVar.agvArriveLineTwoLoadCom)//上料完成
  3441. {
  3442. globalVar.rollerLineTwo.EmptyRollerNums.RemoveAt(0);
  3443. globalVar.agvArriveLineTwoLoadCom = false;
  3444. globalVar.rollerLineTwo.IsEpmtyBefore = false;
  3445. MessageLog.GetInstance.ShowRunLog($"AGV在【2】号线体完成【{emptyRollerNum}】号空料桶装载");
  3446. }
  3447. }
  3448. else//有故障
  3449. {
  3450. while (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 1)
  3451. {
  3452. Thread.Sleep(5);
  3453. if (globalVar.ExitLineOneTask)
  3454. return;
  3455. }
  3456. MessageLog.GetInstance.ShowRunLog("线体【2】滚筒故障解除,继续运行");
  3457. //lineAlarm = 1;
  3458. goto erp;
  3459. }
  3460. }
  3461. /// <summary>
  3462. /// 处理agv从线体3到送料到炒锅的条件
  3463. /// </summary>
  3464. /// <param name="lineAlarm"></param>
  3465. public void AgvFromLineThreeToFryPot()
  3466. {
  3467. erp: if (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 0)//无故障
  3468. {
  3469. if (globalVar.agvArriveLThreeUpLoad && globalVar.LThreeLoadRoller && globalVar.rollerLineThree.StationEight == LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.LThreeAgvToFryPot)//无故障
  3470. {
  3471. MessageLog.GetInstance.ShowRunLog("AGV到达【3】号滚筒线装桶位置");
  3472. AgvArriveLineSingelSetDown(LThreeInputMaterialQuene);
  3473. if (LThreeInputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
  3474. {
  3475. MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶");
  3476. globalVar.LThreeCurrentCookingStep++;
  3477. LThreeOutputMaterialQuene.Enqueue(materialInfo);
  3478. globalVar.agvArriveLThreeUpLoad = false;
  3479. globalVar.LThreeAgvToFryPot = true;
  3480. //原料到位,agv到位,agv自行运料到炒锅
  3481. }
  3482. }
  3483. }
  3484. else //有故障
  3485. {
  3486. while (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 1)
  3487. {
  3488. Thread.Sleep(5);
  3489. if (globalVar.ExitLineThreeTask)
  3490. return;
  3491. }
  3492. MessageLog.GetInstance.ShowRunLog("线体【3】滚筒故障解除,继续运行");
  3493. // lineAlarm = 1;
  3494. goto erp;
  3495. }
  3496. }
  3497. /// <summary>
  3498. /// Agv从3号线体运空桶到清洗处
  3499. /// </summary>
  3500. public void AgvFromLineThreeToClean(ushort emptyRollerNum)
  3501. {
  3502. erp: if (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 0)//无故障
  3503. {
  3504. if (globalVar.agvArriveLineThreeLoadEmptyRoller)//agv到达上料位置
  3505. {
  3506. MessageLog.GetInstance.ShowRunLog("AGV到达【3】号滚筒线装桶位置");
  3507. DeviceOperate.GetInstance.WritePlcData("D1054", 1);//agv到达线体3上料位置信号下发plc
  3508. MessageLog.GetInstance.ShowRunLog($"AGV正在装载【{emptyRollerNum}】号空料桶");
  3509. globalVar.agvArriveLineThreeLoadEmptyRoller = false;
  3510. // globalVar.rollerLineThree.IsEpmtyBefore = false;
  3511. //原料到位,agv到位,agv自行运料到清洗处
  3512. }
  3513. if (globalVar.agvArriveLineThreeLoadCom)//上料完成
  3514. {
  3515. globalVar.rollerLineThree.EmptyRollerNums.RemoveAt(0);
  3516. globalVar.agvArriveLineThreeLoadCom = false;
  3517. globalVar.rollerLineThree.IsEpmtyBefore = false;
  3518. MessageLog.GetInstance.ShowRunLog($"AGV在【3】号线体完成【{emptyRollerNum}】号空料桶装载");
  3519. }
  3520. }
  3521. else//有故障
  3522. {
  3523. while (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 1)
  3524. {
  3525. Thread.Sleep(5);
  3526. if (globalVar.ExitLineOneTask)
  3527. return;
  3528. }
  3529. MessageLog.GetInstance.ShowRunLog("线体【3】滚筒故障解除,继续运行");
  3530. //lineAlarm = 1;
  3531. goto erp;
  3532. }
  3533. }
  3534. /// <summary>
  3535. /// 线体到炒锅搬运任务错误码分析
  3536. /// </summary>
  3537. /// <param name="errorCode"></param>
  3538. /// <param name="num"></param>
  3539. public void LineCarryTaskErrorCodeAnalysis(string errorCode, int num)
  3540. {
  3541. if (errorCode == "SUCCESS")
  3542. {
  3543. MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线装桶");
  3544. globalVar.AllowAgvToLineLoadRoller = false;
  3545. }
  3546. else if (errorCode == "Analysis Error")
  3547. {
  3548. MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文");
  3549. }
  3550. else
  3551. {
  3552. MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}");
  3553. }
  3554. }
  3555. /// <summary>
  3556. /// 线体到清洗台搬运任务错误码分析
  3557. /// </summary>
  3558. /// <param name="errorCode"></param>
  3559. /// <param name="num"></param>
  3560. public void LineToCleanCarryTaskErrorCodeAnalysis(string errorCode, int num)
  3561. {
  3562. if (errorCode == "SUCCESS")
  3563. {
  3564. MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线装桶");
  3565. }
  3566. else if (errorCode == "Analysis Error")
  3567. {
  3568. MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文");
  3569. }
  3570. else
  3571. {
  3572. MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}");
  3573. }
  3574. }
  3575. /// <summary>
  3576. /// 清洗台到线体搬运任务错误码分析
  3577. /// </summary>
  3578. /// <param name="errorCode"></param>
  3579. /// <param name="num"></param>
  3580. public void CleanToLineCarryTaskErrorCodeAnalysis(string errorCode, int num)
  3581. {
  3582. if (errorCode == "SUCCESS")
  3583. {
  3584. MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线卸桶");
  3585. }
  3586. else if (errorCode == "Analysis Error")
  3587. {
  3588. MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文");
  3589. }
  3590. else
  3591. {
  3592. MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}");
  3593. }
  3594. }
  3595. /// <summary>
  3596. /// 炒锅搬运任务错误码分析
  3597. /// </summary>
  3598. /// <param name="errorCode"></param>
  3599. /// <param name="num"></param>
  3600. public void FryCarryTaskErrorCodeAnalysis(string errorCode, int num)
  3601. {
  3602. if (errorCode == "SUCCESS")
  3603. {
  3604. MessageLog.GetInstance.ShowRunLog($"AGV离开{num}号炒锅");
  3605. }
  3606. else if (errorCode == "Analysis Error")
  3607. {
  3608. MessageLog.GetInstance.ShowRunLog($"提示:AGV离开{num}号炒锅接口调用失败,请检查");
  3609. }
  3610. else
  3611. {
  3612. MessageLog.GetInstance.ShowRunLog($"提示:AGV离开{num}号炒锅失败,错误码:{errorCode}");
  3613. }
  3614. }
  3615. public void AgvToLineOneLoadRoller()
  3616. {
  3617. if (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 0)//输送线无故障
  3618. {
  3619. if (InputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineLoadRoller && globalVar.rollerLineOne.OutMaterialingSingle == 1 && !globalVar.LoadRoller)
  3620. {
  3621. if (globalVar.rollerLineOne.StationEight == InputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.rollerLineOne.IsEpmtyBefore)//工位8上面是配方料桶
  3622. {
  3623. globalVar.rollerLineOne.CanRun = false;
  3624. e: string id = Guid.NewGuid().ToString("N");
  3625. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  3626. goto e;
  3627. string info = AGVHelper.GetInstance.AgvToLineOneLoadRoller(id);
  3628. LOnerobotJobId = id;
  3629. Thread.Sleep(500);
  3630. LineCarryTaskErrorCodeAnalysis(info, 1);
  3631. globalVar.LoadRoller = true;
  3632. }
  3633. //else if (globalVar.rollerLineOne.StationEight != InputMaterialQuene.ElementAt(0).materialType.MaterialLoc)
  3634. //{
  3635. // globalVar.rollerLineOne.CanRun = true;
  3636. //}
  3637. //else // 工位8上面不是配方料桶或没有桶时
  3638. //{
  3639. // if (!globalVar.rollerLineOne.IsEpmtyBefore)
  3640. // {
  3641. // var res = InputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineOne.StationEight);
  3642. // if (res == null && globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶且工位8的桶号和plc上报的桶号一致,即空桶
  3643. // {
  3644. // //下发AGV去空桶线洗桶任务
  3645. // e: string id = Guid.NewGuid().ToString("N");
  3646. // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  3647. // goto e;
  3648. // string info = AGVHelper.GetInstance.AgvLeaveLOneToClean(id);//1号线到洗桶处
  3649. // LFourrobotJobId = id;
  3650. // Thread.Sleep(500);
  3651. // LineToCleanCarryTaskErrorCodeAnalysis(info, 1);
  3652. // globalVar.rollerLineOne.IsEpmtyBefore = true;
  3653. // AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  3654. // }
  3655. // }
  3656. // else
  3657. // {
  3658. // AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  3659. // }
  3660. //}
  3661. }
  3662. }
  3663. //else
  3664. //{
  3665. // MessageLog.GetInstance.ShowRunLog("警告:滚筒输送线体【1】故障!!!");
  3666. // // lineAlarm = -1;
  3667. //}
  3668. //// lineAlarm = 1;
  3669. }
  3670. public void AgvToLineTwoLoadRoller()
  3671. {
  3672. if (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 0)//输送线无故障
  3673. {
  3674. if (LTwoInputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineTwoLoadRoller && globalVar.rollerLineTwo.OutMaterialingSingle == 1 && !globalVar.LTwoLoadRoller)
  3675. {
  3676. if (globalVar.rollerLineTwo.StationEight == LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.rollerLineTwo.IsEpmtyBefore)//工位8上面是配方料桶
  3677. {
  3678. globalVar.rollerLineTwo.CanRun = false;
  3679. e: string id = Guid.NewGuid().ToString("N");
  3680. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  3681. goto e;
  3682. string info = AGVHelper.GetInstance.AgvToLineTwoLoadRoller(id);
  3683. LTworobotJobId = id;
  3684. Thread.Sleep(500);
  3685. LineCarryTaskErrorCodeAnalysis(info, 2);
  3686. globalVar.LTwoLoadRoller = true;
  3687. }
  3688. //else if (globalVar.rollerLineTwo.StationEight != LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc)
  3689. //{
  3690. // globalVar.rollerLineTwo.CanRun = true;
  3691. //}
  3692. }
  3693. //else// 工位8上面不是配方料桶或没有桶时
  3694. //{
  3695. // if (!globalVar.rollerLineTwo.IsEpmtyBefore)
  3696. // {
  3697. // var res = LTwoInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineTwo.StationEight);
  3698. // if (res == null && globalVar.rollerLineTwo.StationEight != 0 && globalVar.rollerLineTwo.StationEight == globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶,即空桶
  3699. // {
  3700. // //下发AGV去空桶线洗桶任务
  3701. // e: string id = Guid.NewGuid().ToString("N");
  3702. // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  3703. // goto e;
  3704. // string info = AGVHelper.GetInstance.AgvLeaveLTwoToClean(id);//2号线到洗桶处
  3705. // LFiverobotJobId = id;
  3706. // Thread.Sleep(500);
  3707. // LineToCleanCarryTaskErrorCodeAnalysis(info, 2);
  3708. // globalVar.rollerLineTwo.IsEpmtyBefore = true;
  3709. // AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体2到清洗处
  3710. // }
  3711. // }
  3712. // else
  3713. // {
  3714. // AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  3715. // }
  3716. //}
  3717. }
  3718. }
  3719. public void AgvToLineThreeLoadRoller()
  3720. {
  3721. if (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 0)//输送线无故障
  3722. {
  3723. if (LThreeInputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineThreeLoadRoller && globalVar.rollerLineThree.OutMaterialingSingle == 1 && !globalVar.LThreeLoadRoller)
  3724. {
  3725. if (globalVar.rollerLineThree.StationEight == LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.rollerLineThree.IsEpmtyBefore)//工位8上面是配方料桶
  3726. {
  3727. globalVar.rollerLineThree.CanRun = false;
  3728. e: string id = Guid.NewGuid().ToString("N");
  3729. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  3730. goto e;
  3731. string info = AGVHelper.GetInstance.AgvToLineThreeLoadRoller(id);
  3732. LThreerobotJobId = id;
  3733. Thread.Sleep(500);
  3734. LineCarryTaskErrorCodeAnalysis(info, 3);
  3735. globalVar.LThreeLoadRoller = true;
  3736. }
  3737. //else if (globalVar.rollerLineThree.StationEight != LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc)
  3738. //{
  3739. // globalVar.rollerLineThree.CanRun = true;
  3740. //}
  3741. //else // 工位8上面不是配方料桶或没有桶时
  3742. //{
  3743. // if (!globalVar.rollerLineThree.IsEpmtyBefore)
  3744. // {
  3745. // var res = LThreeInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineThree.StationEight);
  3746. // if (res == null && globalVar.rollerLineThree.StationEight != 0 && globalVar.rollerLineThree.StationEight == globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶,即空桶
  3747. // {
  3748. // //下发AGV去空桶线洗桶任务
  3749. // e: string id = Guid.NewGuid().ToString("N");
  3750. // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  3751. // goto e;
  3752. // string info = AGVHelper.GetInstance.AgvLeaveLThreeToClean(id);//3号线到洗桶处
  3753. // LSixrobotJobId = id;
  3754. // Thread.Sleep(500);
  3755. // LineToCleanCarryTaskErrorCodeAnalysis(info, 3);
  3756. // globalVar.rollerLineThree.IsEpmtyBefore = true;
  3757. // AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处
  3758. // }
  3759. // }
  3760. // else
  3761. // {
  3762. // AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处
  3763. // }
  3764. //}
  3765. }
  3766. }
  3767. //if (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 0)//输送线无故障
  3768. //{
  3769. // if (LThreeInputMaterialQuene.Count > 0)
  3770. // {
  3771. // while (!globalVar.AllowAgvToLineThreeLoadRoller || globalVar.rollerLineThree.OutMaterialingSingle == 0) //后续考虑是否用while
  3772. // {
  3773. // Thread.Sleep(5);
  3774. // if (globalVar.ExitMainTask)
  3775. // return;
  3776. // }
  3777. // g: string id = Guid.NewGuid().ToString();
  3778. // if (id == LThreerobotJobId)
  3779. // goto g;
  3780. // string info = AGVHelper.GetInstance.AgvToLineThreeLoadRoller(id);
  3781. // // MessageLog.GetInstance.ShowRunLog("AGV去【3】号滚筒线装桶");
  3782. // LThreerobotJobId = id;
  3783. // Thread.Sleep(500);
  3784. // LineCarryTaskErrorCodeAnalysis(info, 3);
  3785. // }
  3786. //}
  3787. //else
  3788. //{
  3789. // MessageLog.GetInstance.ShowRunLog("警告:滚筒输送线体【3】故障!!!");
  3790. // // lineAlarm = -1;
  3791. //}
  3792. }
  3793. /// <summary>
  3794. /// 1号线体数据下发
  3795. /// </summary>
  3796. /// <param name="count"></param>
  3797. /// <param name="materialLoc"></param>
  3798. /// <param name="materialWeight"></param>
  3799. public void RollerOneDataWrite(int count, ushort materialLoc, ushort materialWeight)
  3800. {
  3801. switch (count)
  3802. {
  3803. case 0:
  3804. DeviceOperate.GetInstance.WritePlcData("D1001", materialLoc);//桶1位置
  3805. DeviceOperate.GetInstance.WritePlcData("D1010", materialWeight);//桶2重量
  3806. break;
  3807. case 1:
  3808. DeviceOperate.GetInstance.WritePlcData("D1002", materialLoc);//桶2位置
  3809. DeviceOperate.GetInstance.WritePlcData("D1011", materialWeight);//桶2重量
  3810. break;
  3811. case 2:
  3812. DeviceOperate.GetInstance.WritePlcData("D1003", materialLoc);//桶3位置
  3813. DeviceOperate.GetInstance.WritePlcData("D1012", materialWeight);//桶3重量
  3814. break;
  3815. case 3:
  3816. DeviceOperate.GetInstance.WritePlcData("D1004", materialLoc);//桶4位置
  3817. DeviceOperate.GetInstance.WritePlcData("D1013", materialWeight);//桶4重量
  3818. break;
  3819. case 4:
  3820. DeviceOperate.GetInstance.WritePlcData("D1005", materialLoc);//桶5位置
  3821. DeviceOperate.GetInstance.WritePlcData("D1014", materialWeight);//桶5重量
  3822. break;
  3823. case 5:
  3824. DeviceOperate.GetInstance.WritePlcData("D1006", materialLoc);//桶6位置
  3825. DeviceOperate.GetInstance.WritePlcData("D1015", materialWeight);//桶6重量
  3826. break;
  3827. case 6:
  3828. DeviceOperate.GetInstance.WritePlcData("D1007", materialLoc);//桶7位置
  3829. DeviceOperate.GetInstance.WritePlcData("D1016", materialWeight);//桶7重量
  3830. break;
  3831. case 7:
  3832. DeviceOperate.GetInstance.WritePlcData("D1008", materialLoc);//桶8位置
  3833. DeviceOperate.GetInstance.WritePlcData("D1017", materialWeight);//桶8重量
  3834. break;
  3835. }
  3836. }
  3837. /// <summary>
  3838. /// 2号线体数据下发
  3839. /// </summary>
  3840. /// <param name="count"></param>
  3841. /// <param name="materialLoc"></param>
  3842. /// <param name="materialWeight"></param>
  3843. public void RollerTwoDataWrite(int count, ushort materialLoc, ushort materialWeight)
  3844. {
  3845. switch (count)
  3846. {
  3847. case 0:
  3848. DeviceOperate.GetInstance.WritePlcData("D1018", materialLoc);//桶1位置
  3849. DeviceOperate.GetInstance.WritePlcData("D1027", materialWeight);//桶2重量
  3850. break;
  3851. case 1:
  3852. DeviceOperate.GetInstance.WritePlcData("D1019", materialLoc);//桶2位置
  3853. DeviceOperate.GetInstance.WritePlcData("D1028", materialWeight);//桶2重量
  3854. break;
  3855. case 2:
  3856. DeviceOperate.GetInstance.WritePlcData("D1020", materialLoc);//桶3位置
  3857. DeviceOperate.GetInstance.WritePlcData("D1029", materialWeight);//桶3重量
  3858. break;
  3859. case 3:
  3860. DeviceOperate.GetInstance.WritePlcData("D1021", materialLoc);//桶4位置
  3861. DeviceOperate.GetInstance.WritePlcData("D1030", materialWeight);//桶4重量
  3862. break;
  3863. case 4:
  3864. DeviceOperate.GetInstance.WritePlcData("D1022", materialLoc);//桶5位置
  3865. DeviceOperate.GetInstance.WritePlcData("D1031", materialWeight);//桶5重量
  3866. break;
  3867. case 5:
  3868. DeviceOperate.GetInstance.WritePlcData("D1023", materialLoc);//桶6位置
  3869. DeviceOperate.GetInstance.WritePlcData("D1032", materialWeight);//桶6重量
  3870. break;
  3871. case 6:
  3872. DeviceOperate.GetInstance.WritePlcData("D1024", materialLoc);//桶7位置
  3873. DeviceOperate.GetInstance.WritePlcData("D1033", materialWeight);//桶7重量
  3874. break;
  3875. case 7:
  3876. DeviceOperate.GetInstance.WritePlcData("D1025", materialLoc);//桶8位置
  3877. DeviceOperate.GetInstance.WritePlcData("D1034", materialWeight);//桶8重量
  3878. break;
  3879. }
  3880. }
  3881. /// <summary>
  3882. /// 3号线体数据下发
  3883. /// </summary>
  3884. /// <param name="count"></param>
  3885. /// <param name="materialLoc"></param>
  3886. /// <param name="materialWeight"></param>
  3887. public void RollerThreeDataWrite(int count, ushort materialLoc, ushort materialWeight)
  3888. {
  3889. switch (count)
  3890. {
  3891. case 0:
  3892. DeviceOperate.GetInstance.WritePlcData("D1035", materialLoc);//桶1位置
  3893. DeviceOperate.GetInstance.WritePlcData("D1044", materialWeight);//桶2重量
  3894. break;
  3895. case 1:
  3896. DeviceOperate.GetInstance.WritePlcData("D1036", materialLoc);//桶2位置
  3897. DeviceOperate.GetInstance.WritePlcData("D1045", materialWeight);//桶2重量
  3898. break;
  3899. case 2:
  3900. DeviceOperate.GetInstance.WritePlcData("D1037", materialLoc);//桶3位置
  3901. DeviceOperate.GetInstance.WritePlcData("D1046", materialWeight);//桶3重量
  3902. break;
  3903. case 3:
  3904. DeviceOperate.GetInstance.WritePlcData("D1038", materialLoc);//桶4位置
  3905. DeviceOperate.GetInstance.WritePlcData("D1047", materialWeight);//桶4重量
  3906. break;
  3907. case 4:
  3908. DeviceOperate.GetInstance.WritePlcData("D1039", materialLoc);//桶5位置
  3909. DeviceOperate.GetInstance.WritePlcData("D1048", materialWeight);//桶5重量
  3910. break;
  3911. case 5:
  3912. DeviceOperate.GetInstance.WritePlcData("D1040", materialLoc);//桶6位置
  3913. DeviceOperate.GetInstance.WritePlcData("D1049", materialWeight);//桶6重量
  3914. break;
  3915. case 6:
  3916. DeviceOperate.GetInstance.WritePlcData("D1041", materialLoc);//桶7位置
  3917. DeviceOperate.GetInstance.WritePlcData("D1050", materialWeight);//桶7重量
  3918. break;
  3919. case 7:
  3920. DeviceOperate.GetInstance.WritePlcData("D1042", materialLoc);//桶8位置
  3921. DeviceOperate.GetInstance.WritePlcData("D1051", materialWeight);//桶8重量
  3922. break;
  3923. }
  3924. }
  3925. /// <summary>
  3926. /// AGV线体进料就位信号下发至PLC
  3927. /// </summary>
  3928. public void AgvArriveLineSingelSetDown(ConcurrentQueue<MaterialInfo> queue)
  3929. {
  3930. switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  3931. {
  3932. case 1:
  3933. case 4: DeviceOperate.GetInstance.WritePlcData("D1052", 1); break;//AGV进料就位信号1
  3934. case 2:
  3935. case 5: DeviceOperate.GetInstance.WritePlcData("D1053", 1); break;//AGV进料就位信号2
  3936. case 3: DeviceOperate.GetInstance.WritePlcData("D1054", 1); break;//AGV进料就位信号3
  3937. }
  3938. }
  3939. /// <summary>
  3940. /// 炒锅滚筒信号检测
  3941. /// </summary>
  3942. //public void FryPotRollerTroubleCheck()
  3943. //{
  3944. // FryPotAlarm = 0;
  3945. // FryPotTwoAlarm = 0;
  3946. // FryPotThreeAlarm = 0;
  3947. // FryPotFourAlarm = 0;
  3948. // FryPotFiveAlarm = 0;
  3949. // switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  3950. // {
  3951. // case 1:
  3952. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerTrouble == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerTrouble == 1)
  3953. // {
  3954. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3955. // return;
  3956. // }
  3957. // MessageLog.GetInstance.ShowRunLog("炒锅【1】输送滚筒故障解除,继续运行");
  3958. // FryPotAlarm = 1; break;
  3959. // case 2:
  3960. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble == 1) { FryPotTwoAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【2】输送滚筒发生故障"); } else { FryPotTwoAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble == 1)
  3961. // {
  3962. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3963. // return;
  3964. // }
  3965. // MessageLog.GetInstance.ShowRunLog("炒锅【2】输送滚筒故障解除,继续运行");
  3966. // FryPotTwoAlarm = 1; break;
  3967. // case 3:
  3968. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble == 1) { FryPotThreeAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【3】输送滚筒发生故障"); } else { FryPotThreeAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble == 1)
  3969. // {
  3970. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3971. // return;
  3972. // }
  3973. // MessageLog.GetInstance.ShowRunLog("炒锅【3】输送滚筒故障解除,继续运行");
  3974. // FryPotThreeAlarm = 1; break;
  3975. // case 4:
  3976. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble == 1) { FryPotFourAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【4】输送滚筒发生故障"); } else { FryPotFourAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble == 1)
  3977. // {
  3978. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3979. // return;
  3980. // }
  3981. // MessageLog.GetInstance.ShowRunLog("炒锅【4】输送滚筒故障解除,继续运行");
  3982. // FryPotFourAlarm = 1; break;
  3983. // case 5:
  3984. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble == 1) { FryPotFiveAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【5】输送滚筒发生故障"); } else { FryPotFiveAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble == 1)
  3985. // {
  3986. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3987. // return;
  3988. // }
  3989. // MessageLog.GetInstance.ShowRunLog("炒锅【5】输送滚筒故障解除,继续运行");
  3990. // FryPotFiveAlarm = 1; break;
  3991. // }
  3992. //}
  3993. /// <summary>
  3994. /// 炒锅1,4滚筒信号检测
  3995. /// </summary>
  3996. public void FryPotOneRollerTroubleCheck()
  3997. {
  3998. FryPotAlarm = 0;
  3999. FryPotFourAlarm = 0;
  4000. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  4001. {
  4002. case 1:
  4003. if (AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerTrouble == 1)
  4004. {
  4005. FryPotAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【1】输送滚筒发生故障");
  4006. }
  4007. else
  4008. {
  4009. FryPotAlarm = 1; return;
  4010. }
  4011. while (AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerTrouble == 1)
  4012. {
  4013. Thread.Sleep(5); if (globalVar.ExitLineOneTask)
  4014. return;
  4015. }
  4016. MessageLog.GetInstance.ShowRunLog("炒锅【1】输送滚筒故障解除,继续运行");
  4017. FryPotAlarm = 1; break;
  4018. case 4:
  4019. if (AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble == 1) { FryPotFourAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【4】输送滚筒发生故障"); } else { FryPotFourAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble == 1)
  4020. {
  4021. Thread.Sleep(5); if (globalVar.ExitLineOneTask)
  4022. return;
  4023. }
  4024. MessageLog.GetInstance.ShowRunLog("炒锅【4】输送滚筒故障解除,继续运行");
  4025. FryPotFourAlarm = 1; break;
  4026. }
  4027. }
  4028. /// <summary>
  4029. /// 炒锅2,5滚筒信号检测
  4030. /// </summary>
  4031. public void FryPotTwoRollerTroubleCheck()
  4032. {
  4033. FryPotTwoAlarm = 0;
  4034. FryPotFiveAlarm = 0;
  4035. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  4036. {
  4037. case 2:
  4038. if (AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble == 1) { FryPotTwoAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotTwoAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble == 1)
  4039. {
  4040. Thread.Sleep(5); if (globalVar.ExitLineTwoTask)
  4041. return;
  4042. }
  4043. MessageLog.GetInstance.ShowRunLog("炒锅【1】输送滚筒故障解除,继续运行");
  4044. FryPotTwoAlarm = 1; break;
  4045. case 5:
  4046. if (AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble == 1) { FryPotFiveAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【4】输送滚筒发生故障"); } else { FryPotFiveAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble == 1)
  4047. {
  4048. Thread.Sleep(5); if (globalVar.ExitLineTwoTask)
  4049. return;
  4050. }
  4051. MessageLog.GetInstance.ShowRunLog("炒锅【4】输送滚筒故障解除,继续运行");
  4052. FryPotFiveAlarm = 1; break;
  4053. }
  4054. }
  4055. /// <summary>
  4056. /// 炒锅3滚筒信号检测
  4057. /// </summary>
  4058. public void FryPotThreeRollerTroubleCheck()
  4059. {
  4060. FryPotThreeAlarm = 0;
  4061. if (AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble == 1) { FryPotThreeAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【3】输送滚筒发生故障"); } else { FryPotThreeAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble == 1)
  4062. {
  4063. Thread.Sleep(5); if (globalVar.ExitLineThreeTask)
  4064. return;
  4065. }
  4066. MessageLog.GetInstance.ShowRunLog("炒锅【3】输送滚筒故障解除,继续运行");
  4067. FryPotThreeAlarm = 1;
  4068. }
  4069. }
  4070. }