|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359 |
- using BPA.Message;
- using BPA.Message.Enum;
- using BPASmartClient.Device;
- using BPASmartClient.EventBus;
- using BPASmartClient.Helper;
- using BPASmartClient.Message;
- using BPASmartClient.Model;
- using BPASmartClient.Model.PLC;
- using BPA.Models;
- using static BPASmartClient.EventBus.EventBus;
- using BPASmartClient.Model.小炒机;
- using BPASmartClient.MorkF.Model;
-
- namespace BPASmartClient.MorkF
- {
- public class Control_MorkF : BaseDevice
- {
- public override DeviceClientType DeviceType => DeviceClientType.MORKCS;
- public AutoResetEvent minorReset = new AutoResetEvent(false);
- public AutoResetEvent mainReset = new AutoResetEvent(false);
- GVL_MorkF morkF = new GVL_MorkF();//全局对象声明
- public StirFryBom stirFryBom = new StirFryBom();//创建获取流程的对象
- List<StirFryGoods> stirFryGoods = new List<StirFryGoods>();//创建商品对象
- List<int> resultorder = new List<int>();//调试变量
- /// <summary>
- /// 入口
- /// </summary>
- public override void DoMain()
- {
- CommandRegist();//调试
- ServerInit();
- DataParse();//数据解析
- DeviceProcessLogShow("MORKF 设备初始化完成");
- }
- #region 调试代码
- public void CommandRegist()
- {
- ActionManage.GetInstance.Register(PLCInite, "InitCommand");
- ActionManage.GetInstance.Register(InitialData, "SimultaorOrder");
- ActionManage.GetInstance.Register(MaterialOne, "MaterialOne");
- ActionManage.GetInstance.Register(MaterialTwo, "MaterialTwo");
- ActionManage.GetInstance.Register(MaterialThree, "MaterialThree");
- ActionManage.GetInstance.Register(MaterialFour, "MaterialFour");
- ActionManage.GetInstance.Register(MaterialFive, "MaterialFive");
- ActionManage.GetInstance.Register(ManualOpenExhaust, "OpenExhaust");
- ActionManage.GetInstance.Register(CloseExhaust, "CloaseExhaust");
- ActionManage.GetInstance.Register(StartQX, "StartQXOne");
- ActionManage.GetInstance.Register(StartQX, "StartQXTwo");
-
- ActionManage.GetInstance.Register(ShreddCabbage, "ShreddCabbage");
- ActionManage.GetInstance.Register(FryPork, "FryPork");
- ActionManage.GetInstance.Register(XingBaoGu, "XingBaoGu");
-
- ActionManage.GetInstance.Register(TakePot, "TakePot");
- ActionManage.GetInstance.Register(TakePotReset, "TakePotReset");
- ActionManage.GetInstance.Register(TakeMaterial, "TakeMaterial");
- ActionManage.GetInstance.Register(ManualOutMeal, "OutMeal");
-
- ActionManage.GetInstance.Register<Action>(AddOil, "AddOil");
- ActionManage.GetInstance.Register(TakeOff, "TakeOff");
- ActionManage.GetInstance.Register(OneBlock, "OneBlock");
- ActionManage.GetInstance.Register(TwoBlock, "TwoBlock");
- ActionManage.GetInstance.Register(ThreeBlock, "ThreeBlock");
- ActionManage.GetInstance.Register(OverTurnOff, "OverTurnOff");
- ActionManage.GetInstance.Register(OverOneBlock, "OverOneBlock");
- ActionManage.GetInstance.Register(OverTwoBlock, "OverTwoBlock");
- ActionManage.GetInstance.Register(OverThreeBlock, "OverThreeBlock");
- ActionManage.GetInstance.Register(OverGoOn, "OverGoOn");
- ActionManage.GetInstance.Register(OverGoDown, "OverGoDown");
- ActionManage.GetInstance.Register(AutoModel, "AutoModel");
- ActionManage.GetInstance.Register(ManualModel, "ManualModel");
-
- ActionManage.GetInstance.Register<Action>(AddOil, "SecAddOil");
- ActionManage.GetInstance.Register(TakeOff, "SecTakeOff");
- ActionManage.GetInstance.Register(OneBlock, "SecOneBlock");
- ActionManage.GetInstance.Register(TwoBlock, "SecTwoBlock");
- ActionManage.GetInstance.Register(ThreeBlock, "SecThreeBlock");
- ActionManage.GetInstance.Register(OverTurnOff, "SecOverTurnOff");
- ActionManage.GetInstance.Register(OverOneBlock, "SecOverOneBlock");
- ActionManage.GetInstance.Register(OverTwoBlock, "SecOverTwoBlock");
- ActionManage.GetInstance.Register(OverThreeBlock, "SecOverThreeBlock");
- ActionManage.GetInstance.Register(OverGoOn, "SecOverGoOn");
- ActionManage.GetInstance.Register(OverGoDown, "SecOverGoDown");
- ActionManage.GetInstance.Register(AutoModel, "SecAutoModel");
- ActionManage.GetInstance.Register(ManualModel, "SecManualModel");
- }
- /// <summary>
- /// 手撕包菜流程
- /// </summary>
- public void ShreddCabbage()
- {
- if (stirFryBom.StirFryActions.Count > 0)
- {
- stirFryBom.StirFryActions.Clear();
- }
- //流程
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List<StirFryPotAction>() { StirFryPotAction.大火持续 }, During = 5 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.取A料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 6 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.停止火力, StirFryPotAction.搅拌臂上位 } });//加A料
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.取B料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 6 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加B料
-
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.取C料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 9 });
-
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加C料
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } });
- morkF.listStirBom.Add(stirFryBom);
- }
- /// <summary>
- /// 盐煎肉流程
- /// </summary>
- public void FryPork()
- {
- if (stirFryBom.StirFryActions.Count > 0)
- {
- stirFryBom.StirFryActions.Clear();
- }
- //流程
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 15 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油, StirFryPotAction.停止火力 }, During = 19 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
-
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入A料 } });
-
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 20 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力 }, During = 35 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位, } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入B料 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 22 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T12, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入C料 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T13, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 70 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T14, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T15, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } });
- }
- /// <summary>
- /// 酱烧杏鲍菇流程
- /// </summary>
- public void XingBaoGu()
- {
- if (stirFryBom.StirFryActions.Count > 0)
- {
- stirFryBom.StirFryActions.Clear();
- }
- //流程
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入A料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 5 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油 }, During = 12 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加A料
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入B料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 25 });
-
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加B料
-
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入C料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 });
-
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加C料
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 55 });
- stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } });
- }
- public void StartQX(object obj)
- {
-
- if ((int)obj == 1)
- WriteData("M1.4", true);
- if ((int)obj == 2)
- WriteData("M1.7", true);
- }
- public void ManualOpenExhaust()
- {
- WriteData("M0.7", true);
- }
- public void CloseExhaust()
- {
- WriteData("M0.7", false);
- }
- public void TakeMaterial()
- {
- WriteData("M14.1", true);
- }
- public void ManualOutMeal()
- {
- WriteData("M14.2", true);
- }
- public void MaterialOne()
- {
- WriteData("M13.0", true);
- }
-
- public void MaterialTwo()
- {
- WriteData("M13.1", true);
- }
- public void MaterialThree()
- {
- WriteData("M13.2", true);
- }
- public void MaterialFour()
- {
- WriteData("M13.3", true);
- }
- public void MaterialFive()
- {
- WriteData("M13.4", true);
- }
- public void AutoModel(object obj)
- {
-
- WriteData("0.3", true);
-
- }
- public void ManualModel()
- {
- WriteData("0.2", true);
- }
- public void AddOil(object obj)
- {
- if ((int)obj == 1)
- {
- Task.Run(() => { WriteData("M2.7", true); Task.Delay(4000).Wait(); WriteData("M2.7", false); });
- }
-
- if ((int)obj == 2)
- {
- Task.Run(() => { WriteData("M3.1", true); Task.Delay(4000).Wait(); WriteData("M3.1", false); });
- }
- }
- public void TakePot(object obj)
- {
- WriteData("M14.0", true);
- }
-
- public void TakePotReset(object obj)
- {
- WriteData("M14.0", false);
- }
- public void TakeOff(object obj)
- {
- if ((int)obj == 1)
- WriteData("M4.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
- if ((int)obj == 2)
- WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
- }
-
- public void OneBlock(object obj)
- {
- if ((int)obj == 1)
- WriteData("M4.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
- if ((int)obj == 2)
- WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
-
-
- }
- public void TwoBlock(object obj)
- {
- if ((int)obj == 1)
- WriteData("M4.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
- if ((int)obj == 2)
- WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
- }
- public void ThreeBlock(object obj)
- {
- if ((int)obj == 1)
- WriteData("M4.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
- if ((int)obj == 2)
- WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
- }
- public void OverTurnOff(object obj)
- {
- if ((int)obj == 1)
- WriteData("M7.0", true);
- if ((int)obj == 2)
- WriteData("M7.4", true);
- }
- public void OverOneBlock(object obj)
- {
- if ((int)obj == 1)
- WriteData("M7.1", true);
- if ((int)obj == 2)
- WriteData("M7.5", true);
- }
- public void OverTwoBlock(object obj)
- {
- if ((int)obj == 1)
- WriteData("M7.2", true);
- if ((int)obj == 2)
- WriteData("M7.6", true);
- }
- public void OverThreeBlock(object obj)
- {
- if ((int)obj == 1)
- WriteData("M7.3", true);
- if ((int)obj == 2)
- WriteData("M7.7", true);
- }
- public void OverGoOn(object obj)
- {
- if ((int)obj == 1)
- WriteData("M8.0", true);
- if ((int)obj == 2)
- WriteData("M8.4", true);
- }
-
- public void OverGoDown(object obj)
- {
- if ((int)obj == 1)
- WriteData("M8.2", true);
- if ((int)obj == 2)
- WriteData("M8.6", true);
- }
- public void FlowInite()
- {
-
- }
- /// <summary>
- /// 订单初始化
- /// </summary>
- private void InitialData()
- {
- string subId = Guid.NewGuid().ToString();
- //单个订单
- //string subId = Guid.NewGuid().ToString();
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 1 } });//A料
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 2 } });//B料
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 3 } });//C料
- //morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId });
- //resultorder.AddRange(new int[] { 1, 2, 3 });
-
- for (int i = 0; i < morkF.listStirBom.Count; i++)
- {
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List<int>() { 1 } });//A料
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List<int>() { 2 } });//B料
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List<int>() { 3 } });//C料
- morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i });
- //resultorder.AddRange(new int[] { 1, 2, 3 });
- }
-
- //多个订单
- //string subId = Guid.NewGuid().ToString();
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 1 } });//A料
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 2 } });//B料
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 3 } });//C料
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1, MaterialLoc = new List<int>() { 1 } });//A料
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1, MaterialLoc = new List<int>() { 2 } });//B料
- //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1, MaterialLoc = new List<int>() { 3 } });//C料
- //morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId });
- //morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1 });
- //resultorder.AddRange(new int[] { 1, 2, 3 });
- //resultorder.AddRange(new int[] { 1, 2, 3 });
-
- }
- #endregion
-
- public override void ResetProgram()
- {
- morkF = null;
- morkF = new GVL_MorkF();
- }
-
- /// <summary>
- /// PLC数据读取
- /// </summary>
- public override void ReadData()
- {
-
- GetStatus("M0.1", new Action<bool[]>((bools) =>
- {
- Initing = bools[0];
- morkF.InitialComplete = Initing;
- }));
- GetStatus("M1.0", new Action<bool[]>((bools) =>
- {
- morkF.ProvidePlateModule = bools[0];
- morkF.ProvidePlateComplete = bools[2];
- morkF.CleanModule = bools[3];
- morkF.CleanComplete = bools[5];
- }));
- GetStatus("M2.0", new Action<bool[]>((bools) =>
- {
- morkF.KitchenOneStatus = bools[1];
- morkF.KitchenSecondStatus = bools[4];
- morkF.FallOilComplete = bools[8];
- }));
- GetStatus("M8.0", new Action<bool[]>((bools) =>
- {
- morkF.TurnMachineUpComplete = bools[1];
- morkF.TurnMachineDownComplete = bools[3];
- }));
- GetStatus("M13.5", new Action<bool[]>((bools) =>
- {
- morkF.MaterialArriveComplete = bools[0];
- }));
- GetStatus("M16.0", new Action<bool[]>((bools) =>
- {
- morkF.PutPotToKitchenComlete = bools[1];
- morkF.TakeMaterialComplete = bools[2];
- morkF.FallMaterialComplete = bools[3];
- morkF.PlaceRinseTableComplete = bools[5];
- morkF.RoobotIdle = bools[6];
- }));
-
- }
- private void ServerInit()
- {
- //物料信息
- EventBus.EventBus.GetInstance().Subscribe<MaterialDeliveryEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
- {
- if (@event == null) return;
- if (@event is MaterialDeliveryEvent material)
- {
- orderMaterialDelivery = material.orderMaterialDelivery;
-
- }
- });
-
- //配方数据信息
- EventBus.EventBus.GetInstance().Subscribe<RecipeBomEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
- {
- if (@event == null) return;
- if (@event is RecipeBomEvent recipe)
- {
- recipeBoms = recipe.recipeBoms;
- WriteRecipeBoms();
- }
- });
- //小炒流程信息
- EventBus.EventBus.GetInstance().Subscribe<StirFryGoodsEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callback)
- {
- if (@event == null) return;
- if (@event is StirFryGoodsEvent stirFry)
- {
- stirFryGoods = stirFry.stirFrymessage.stirFryGoods;
- MessageLog.GetInstance.Show("接收到小炒流程信息");
- //流程解析
- foreach (var item in stirFryGoods)
- {
- MessageLog.GetInstance.ShowEx($"执行菜谱{item.GoodsKey}");
- // morkF.listStirBom.Add(item.StirFryBomInfo);//添加订单制作流程
- foreach (var items in item.StirFryBomInfo.StirFryActions)
- {
- MessageLog.GetInstance.Show($"执行流程{items.Time}");
- foreach (var pro in items.RobotActions)
- {
- switch (pro)
- {
- case StirFryRobotAction.等待:
- MessageLog.GetInstance.Show($"等待");
- break;
- case StirFryRobotAction.清洗槽取锅:
- MessageLog.GetInstance.Show($"清洗槽取锅");
- break;
- case StirFryRobotAction.灶放锅:
- MessageLog.GetInstance.Show($"灶放锅");
- break;
- case StirFryRobotAction.清洗槽放锅:
- MessageLog.GetInstance.Show($"清洗槽放锅");
- break;
- case StirFryRobotAction.取A料:
- MessageLog.GetInstance.Show($"取A料");
- break;
- case StirFryRobotAction.取B料:
- MessageLog.GetInstance.Show($"取B料");
- break;
- case StirFryRobotAction.取C料:
- MessageLog.GetInstance.Show($"取C料");
- break;
- case StirFryRobotAction.加入A料:
- MessageLog.GetInstance.Show($"加入A料");
- break;
- case StirFryRobotAction.加入B料:
- MessageLog.GetInstance.Show($"加入B料");
- break;
- case StirFryRobotAction.加入C料:
- MessageLog.GetInstance.Show($"加入C料");
- break;
- case StirFryRobotAction.切换快速:
- MessageLog.GetInstance.Show($"切换快速");
- break;
- case StirFryRobotAction.切换中速:
- MessageLog.GetInstance.Show($"切换中速");
- break;
- case StirFryRobotAction.丢料盒:
- MessageLog.GetInstance.Show($"丢料盒");
- break;
- case StirFryRobotAction.倒菜:
- MessageLog.GetInstance.Show($"倒菜");
- break;
- case StirFryRobotAction.灶取锅:
- MessageLog.GetInstance.Show($"灶取锅");
- break;
- }
- }
- foreach (var pro in items.PotActions)
- {
- switch (pro)
- {
- case StirFryPotAction.NONE:
- break;
- case StirFryPotAction.加热:
- MessageLog.GetInstance.Show($"加热");
- break;
- case StirFryPotAction.大火t1s:
- MessageLog.GetInstance.Show($"大火1s");
- break;
- case StirFryPotAction.加油:
- MessageLog.GetInstance.Show($"加油");
- break;
- case StirFryPotAction.中火t2s:
- MessageLog.GetInstance.Show($"中火2s");
- break;
- case StirFryPotAction.小火持续:
- MessageLog.GetInstance.Show($"小火持续");
- break;
- case StirFryPotAction.中火持续:
- MessageLog.GetInstance.Show($"中火持续");
- break;
- case StirFryPotAction.大火持续:
- MessageLog.GetInstance.Show($"大火持续");
- break;
- case StirFryPotAction.停止火力:
- MessageLog.GetInstance.Show($"停止火力");
- break;
- case StirFryPotAction.搅拌臂上位:
- MessageLog.GetInstance.Show($"搅拌臂上位");
- break;
- case StirFryPotAction.搅拌臂中位:
- MessageLog.GetInstance.Show($"搅拌臂中位");
- break;
- case StirFryPotAction.搅拌臂下位:
- MessageLog.GetInstance.Show($"搅拌臂下位");
- break;
- case StirFryPotAction.低速旋转:
- MessageLog.GetInstance.Show($"低速旋转");
- break;
- case StirFryPotAction.快速旋转:
- MessageLog.GetInstance.Show($"快速旋转");
- break;
- case StirFryPotAction.停止旋转:
- MessageLog.GetInstance.Show($"停止旋转");
- break;
- }
- }
- }
- }
- }
- });
- }
- /// <summary>
- /// 订单状态发布
- /// </summary>
- /// <param name="subid"></param>
- /// <param name="oRDER_STATUS"></param>
- private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
- {
- EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid });
- }
-
-
-
- /// <summary>
- /// 数据解析
- /// </summary>
- private void DataParse()
- {
- EventBus.EventBus.GetInstance().Subscribe<DoOrderEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle)
- {
- if (@event == null) return;
- if (@event is DoOrderEvent order)
- {
- if (order.MorkOrder.GoodBatchings == null) return;
- OrderCount++;
- DeviceProcessLogShow($"接收到{OrderCount}次订单");
-
- var res = stirFryGoods?.FirstOrDefault(p => p.GoodsKey == order.MorkOrder.RecipeId);//匹配订单对应制作流程
- if (res != null)
- {
- morkF.listStirBom.Add(res.StirFryBomInfo);//添加订单制作流程
- if (morkF.TakeMaterialQueue.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
- {
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, MaterialLoc = res.StirFryBomInfo.ALoc });
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, MaterialLoc = res.StirFryBomInfo.BLoc });
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, MaterialLoc = res.StirFryBomInfo.CLoc });
-
- }
-
-
- //foreach (var item in order.MorkOrder.GoodBatchings)
- //{
- if (morkF.TakePlateQueue.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
- {
- morkF.TakePlateQueue.Enqueue(new OrderLocInfo()
- {
- SuborderId = order.MorkOrder.SuborderId,
-
- });
- }
- //}
- }
- }
-
- });
- }
- //}
- /// <summary>
- /// 主任务
- /// </summary>
- public override void MainTask()
- {
- TakePlatelTask();
- TurntableControl();
- MainProcessExecute();
- MinorProcessExcute();
- SingleProcess();
- }
- //辅流程执行
- private void MinorProcessExcute()
- {
- if (!morkF.MinorProcessExcuteLock)
- {
- morkF.MinorProcessExcuteLock = true;
- Task.Run(() =>
- {
- if (morkF.MinorProcessFlag && !morkF.RoobotIdle && morkF.TakeMaterialQueue.Count > 0 && morkF.listStirBom.Count > 0 )
- {
- morkF.MinorProessStatus = true;
- morkF.MainProcessStatus = false;
- StirFryBom bom = morkF.listStirBom.ElementAt(0);
- morkF.listStirBom.RemoveAt(0);
- foreach (var res in bom.StirFryActions)
- {
- DeviceProcessLogShow($"执行流程{res.Time}");
- //机器人线程
- Task taskRobot = Task.Run(new Action(() =>
- {
- foreach (var temp in res.RobotActions)
- {
- switch (temp)
- {
- case StirFryRobotAction.清洗槽取锅:
- TakePotTask();//执行取锅操作
- break;
- case StirFryRobotAction.取A料:
- TakeBurdenATask();//执行取A料操作
- break;
- case StirFryRobotAction.取B料:
- TakeBurdenATask();//执行取B料操作
- break;
- case StirFryRobotAction.取C料:
- TakeBurdenCTask();//执行取C料操作
- break;
- case StirFryRobotAction.灶取锅:
- MinorProcessOutDishTask();//执行出餐操作
- MinorProcessCleanPotTask();//洗锅操作
- break;
- }
-
- }
-
- }));
- //炒锅线程操作
- Task taskPot = Task.Run(new Action(() =>
- {
- foreach (var temp in res.PotActions)
- {
- switch (temp)
- {
- case StirFryPotAction.NONE:
- break;
- case StirFryPotAction.大火t1s:
- MinorProcessKitchenAdjustGears(3);
- // Task.Delay(1000).Wait(); //大火加热1s//执行大火锅干操作
- break;
- case StirFryPotAction.加油:
- AddOil();//注油//执行加油操作
- break;
- case StirFryPotAction.中火t2s:
- MinorProcessKitchenAdjustGears(2);
- Task.Delay(2000).Wait();//执行操作
- break;
- case StirFryPotAction.小火持续:
- MinorProcessKitchenAdjustGears(1);
- break;
- case StirFryPotAction.中火持续:
- MinorProcessKitchenAdjustGears(5);
- break;
- case StirFryPotAction.大火持续:
- MinorProcessKitchenAdjustGears(7);
- break;
- case StirFryPotAction.停止火力:
- MinorProcessKitchenAdjustGears(0);//关闭灶加热
- break;
- case StirFryPotAction.搅拌臂上位:
- MinorProcessTurnUpStatusDetect();//执行搅拌臂上位操作
- break;
- case StirFryPotAction.搅拌臂下位:
- MinorProcessTurnDownStatusDetect();//执行搅拌臂下位操作
- break;
- case StirFryPotAction.低速旋转:
- MinorProcessTurnMachineGearsControl(1);//执行搅拌臂速度1挡操作
- break;
- case StirFryPotAction.快速旋转:
- MinorProcessTurnMachineGearsControl(2);//执行搅拌臂速度3挡操作
- break;
- case StirFryPotAction.停止旋转:
- MinorProcessTurnMachineGearsControl(0);//执行搅拌臂速度0挡操作
- break;
- }
- }
- }));
- Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束
- Task.Delay(res.During * 1000).Wait();//当前流程延迟
- if (morkF.MainProcessWait)
- {
- if (morkF.MainHasTakeMaterial)
- {
-
- }
- else
- {
- MinorProcessKitchenAdjustGears(0);//关闭灶加热
- //阻塞辅流程
- minorReset.WaitOne();
- //morkF.MinorProessStatus = true;
- //morkF.MainProcessStatus = false;
- }
-
- }
-
- }
- morkF.MinorOutMealComplete = true;
- }
- else
- {
- morkF.MinorProcessExcuteLock = false;//解除辅流程自锁
- }
- });
- }
- }
-
- //机器人,锅灶主流程执行
- public void MainProcessExecute()
- {
- if (!morkF.MainProcessExcuteLock)
- {
- morkF.MainProcessExcuteLock = true;
- Task.Run(new Action(() =>
- {
- if (!morkF.RoobotIdle && morkF.InitialComplete && morkF.TakeMaterialQueue.Count > 0 && morkF.MainProcessFlag&& morkF.listStirBom.Count > 0)
- {
- morkF.MainProcessStatus = true;
- morkF.MinorProessStatus = false;
- StirFryBom bom = morkF.listStirBom.ElementAt(0);
- morkF.listStirBom.RemoveAt(0);
- foreach (var res in bom.StirFryActions)//遍历所有流程
- {
- DeviceProcessLogShow($"执行流程{res.Time}");
- //机器人线程
- Task taskRobot = Task.Run(new Action(() =>
- {
- foreach (var temp in res.RobotActions)
- {
- switch (temp)
- {
- case StirFryRobotAction.清洗槽取锅:
- TakePotTask();//执行取锅操作
- break;
- case StirFryRobotAction.取A料:
- TakeBurdenATask();//执行取A料操作
- break;
- case StirFryRobotAction.取B料:
- TakeBurdenATask();//执行取B料操作
- break;
- case StirFryRobotAction.取C料:
- TakeBurdenCTask();//执行取C料操作
- break;
- case StirFryRobotAction.灶取锅:
- MainProcessOutDishTask();//执行出餐操作
- MainProcessCleanPotTask();//洗锅操作
- break;
- }
-
- }
-
- }));
- //炒锅线程操作
- Task taskPot = Task.Run(new Action(() =>
- {
- foreach (var temp in res.PotActions)
- {
- switch (temp)
- {
- case StirFryPotAction.NONE:
- break;
- case StirFryPotAction.大火t1s:
- MainProcessKitchenAdjustGears(3);
- // Task.Delay(1000).Wait(); //大火加热1s//执行大火锅干操作
- break;
- case StirFryPotAction.加油:
- AddOil();//注油//执行加油操作
- break;
- case StirFryPotAction.中火t2s:
- MainProcessKitchenAdjustGears(2);
- Task.Delay(2000).Wait();//执行操作
- break;
- case StirFryPotAction.小火持续:
- MainProcessKitchenAdjustGears(1);
- break;
- case StirFryPotAction.中火持续:
- MainProcessKitchenAdjustGears(5);
- break;
- case StirFryPotAction.大火持续:
- MainProcessKitchenAdjustGears(7);
- break;
- case StirFryPotAction.停止火力:
- MainProcessKitchenAdjustGears(0);//关闭灶加热
- break;
- case StirFryPotAction.搅拌臂上位:
- MainProcessTurnUpStatusDetect();//执行搅拌臂上位操作
- break;
- case StirFryPotAction.搅拌臂下位:
- MainProcessTurnDownStatusDetect();//执行搅拌臂下位操作
- break;
- case StirFryPotAction.低速旋转:
- MainProcessTurnMachineGearsControl(1);//执行搅拌臂速度1挡操作
- break;
- case StirFryPotAction.快速旋转:
- MainProcessTurnMachineGearsControl(2);//执行搅拌臂速度3挡操作
- break;
- case StirFryPotAction.停止旋转:
- MainProcessTurnMachineGearsControl(0);//执行搅拌臂速度0挡操作
- break;
- }
- }
- }));
- Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束
- Task.Delay(res.During * 1000).Wait();//当前流程延迟
- #region 两口锅逻辑
- //if (morkF.MinorProcessWait)
- //{
- // if (morkF.MinorHasTakeMaterial)//针对主流程准备出餐但辅流程机器人忙碌情况下,辅流程不阻塞
- // {
- // }
- // else
- // {
- // MainProcessKitchenAdjustGears(0);//关闭灶加热
- // //阻塞主流程
- // mainReset.WaitOne();
- // //morkF.MinorProessStatus = false;
- // //morkF.MainProcessStatus = true;
- // }
-
- //}
- #endregion
- }
- morkF.MainOutMealComplete = true;
- }
- else
- {
- morkF.MainProcessExcuteLock = false;//解除流程自锁
- }
- }));
- }
-
- }
- /// <summary>
- /// 信号处理
- /// </summary>
- private void SingleProcess()
- {
-
-
- //主流程出餐完成,相应变量复位
- if (morkF.MainOutMealComplete)
- {
- morkF.MainOutMealComplete = false;
- morkF.TakePlateLock = false;
- morkF.MainProcessExcuteLock = false;
- morkF.MainOrderMaterialCom = false;
- morkF.MainProcessWait = false;//主流程出餐完成取消辅流程线程阻塞
-
- #region 单口锅逻辑
- morkF.PotInPlace = false;
- #endregion
- #region 两口锅逻辑
- //if (morkF.MainProcessPotLoc == 1)
- //{
- // morkF.PotInPlace = false;
- //}
- //else if (morkF.MainProcessPotLoc == 2)
- //{
- // morkF.SecondPotInPlace = false;
- //}
- #endregion
- }
- //辅流程出餐完成,相应变量复位
- if (morkF.MinorOutMealComplete)
- {
- morkF.MinorOutMealComplete = false;
- morkF.TakePlateLock = false;
- morkF.MinorProcessExcuteLock = false;
- morkF.MinorOrderMaterialCom = false;
- morkF.MinorProcessWait = false;//辅流程出餐完成取消主流程线程阻塞
- if (morkF.MinorProcessPotLoc == 1)
- {
- morkF.PotInPlace = false;
- }
- else if (morkF.MinorProcessPotLoc == 2)
- {
- morkF.SecondPotInPlace = false;
- }
- }
-
- }
-
- /// <summary>
- /// 转台控制
- /// </summary>
- private void TurntableControl()
- {
- //模拟订单
- if (morkF.TakeMaterialQueue.Count > 0 && !morkF.TurnTableLock && General_Config.SimOrderAllow)
- {
- if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo info))
- {
- TurnMaterialStore(info.MaterialLoc[0]);
- DeviceProcessLogShow($"转台转到【{info.MaterialLoc[0]}】位置");
- morkF.TurnTableLock = true;
- }
- else
- {
- DeviceProcessLogShow("当前订单未找到可用的物料信息");
- }
-
- }
- //正式订单
- if (morkF.TakeMaterialQueue.Count > 0 && !morkF.TurnTableLock)
- {
- //var result = orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == morkF.TakeMaterialQueue.ElementAt(0).BatchingId).ToList();
- var materialLoc = morkF.TakeMaterialQueue.ElementAt(0).MaterialLoc;
- if (materialLoc.Count != 0)
- {
- TurnMaterialStore(materialLoc[0]);
- DeviceProcessLogShow($"转台转到【{materialLoc[0]}】位置");
- morkF.TurnTableLock = true; //取料完成后置false
-
- }
- else
- {
- DeviceProcessLogShow("当前订单未找到可用的物料信息");
- }
-
- }
-
-
- }
-
-
- /// <summary>
- /// 供盘
- /// </summary>
- /// <exception cref="NotImplementedException"></exception>
- private void TakePlatelTask()
- {
- if (!morkF.RoobotIdle && morkF.InitialComplete && morkF.TakePlateQueue.Count > 0 && !morkF.ProvidePlateModule && !morkF.TakePlateLock)
- {
-
- if (morkF.TakePlateQueue.TryDequeue(out OrderLocInfo order))
- {
- StartTakePlate();
- #region 两口锅逻辑
- //if (morkF.MainProcessStatus)
- // morkF.MainCurrentOrderId = order.SuborderId;
-
- //if (morkF.MinorProessStatus)
- // morkF.MinorCurrentOrderId = order.SuborderId;
- #endregion
- #region 单口锅逻辑
- morkF.CurrentOrderId = order.SuborderId;
- #endregion
- morkF.TakePlateLock = true; //订单完成后置false
-
-
- DeviceProcessLogShow($"订单【{order.SuborderId}】执行取碗控制");
- }
- }
- }
-
- /// <summary>
- /// 取锅到灶台
- /// </summary>
- /// <exception cref="NotImplementedException"></exception>
- private void TakePotTask()
- {
-
- while (morkF.CleanModule || morkF.KitchenOneStatus || !morkF.CleanComplete || morkF.RoobotIdle)//等待取锅条件满足
- {
- Task.Delay(5).Wait();
- }
-
- #region 单口锅逻辑
- //if (!morkF.CleanModule && !morkF.KitchenOneStatus && morkF.CleanComplete)
- //{
- //取1号锅到1号灶台
- TakePotToKitchen(1);
- WriteData("M1.5", false);//清洗模组1完成复位
- DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行取锅到灶台控制");
- while (!morkF.PutPotToKitchenComlete)
- {
- Task.Delay(5).Wait();
- }
- morkF.PotInPlace = true;//锅到位
- WriteData("M14.0", false);//机器人取锅完成复位
- //}
- #endregion
- #region 两口锅逻辑
- //while (!((!morkF.CleanModule || !morkF.SecondCleanModule) && (!morkF.KitchenOneStatus || !morkF.KitchenSecondStatus) && (morkF.CleanComplete || morkF.SecondCleanComplete)))//等待取锅条件满足
- //{
- // Task.Delay(5).Wait();
- //}
- //while (morkF.RoobotIdle)//等待机器人空闲
- //{
- // Task.Delay(5).Wait();
- //}
- //if (!morkF.CleanModule && !morkF.KitchenOneStatus && morkF.CleanComplete)
- //{
- // //取1号锅到1号灶台
- // TakePotToKitchen(1);
- // morkF.CurrentPutPotLoc = 1;
- // WriteData("M1.5", false);//清洗模组1完成复位
- // DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行取锅到灶台控制");
-
- //}
- //else if (!morkF.SecondCleanModule && !morkF.KitchenOneStatus && morkF.SecondCleanComplete)
- //{
- // //取2号锅到1号灶台
- // TakePotToKitchen(1);
- // morkF.CurrentPutPotLoc = 1;
- // WriteData("M2.0", false);//清洗模组2完成复位
- //}
- //if (!morkF.SecondCleanModule && !morkF.KitchenSecondStatus && morkF.SecondCleanComplete)
- //{
- // //取2号锅到2号灶台
- // TakePotToKitchen(2);
- // morkF.CurrentPutPotLoc = 2;
- // WriteData("M2.0", false);//清洗模组2完成复位
- //}
- //else if (!morkF.CleanModule && !morkF.KitchenSecondStatus && morkF.CleanComplete)
- //{
- // //取1号锅到2号灶台
- // TakePotToKitchen(2);
- // morkF.CurrentPutPotLoc = 2;
- // WriteData("M2.0", false);//清洗模组1完成复位
- //}
- //if (morkF.MainProcessStatus)
- //{
- // morkF.MainProcessPotLoc = morkF.CurrentPutPotLoc;
- // DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】执行取锅到灶台控制");
- //}
- //if (morkF.MinorProessStatus)
- //{
- // morkF.MinorProcessPotLoc = morkF.CurrentPutPotLoc;
- // DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】执行取锅到灶台控制");
- //}
- //if (morkF.CurrentPutPotLoc == 1)
- //{
- // while (!morkF.PutPotToKitchenComlete)
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.PotInPlace = true;//锅到位
- // WriteData("M14.0", false);//机器人取锅完成复位
- //}
- //if (morkF.CurrentPutPotLoc == 2)
- //{
- // while (!morkF.PutPotToSecondKitchenComlete)
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.SecondPotInPlace = true;
- // WriteData("M14.4", false);//机器人取锅完成复位
- //}
- #endregion
-
- Thread.Sleep(2000);
-
-
-
-
- }
-
- /// <summary>
- /// 写入配方数据到 PLC
- /// </summary>
- private void WriteRecipeBoms()
- {
- //List<ushort> recipeBoms = new List<ushort>();
- //if (this.recipeBoms == null) return;
- //foreach (var item in this.recipeBoms.RecipeIds)
- //{
- // foreach (var rec in item.Recipes)
- // {
- // recipeBoms.Add((ushort)rec);
- // }
- //}
- //if (recipeBoms.Count > 0)
- //{
- // //配方数据地址范围:VW2000 - VW2278
- // WriteData("VW2000", recipeBoms.ToArray());
- //}
- //else {DeviceProcessLogShow("配方数据为空"); }
- }
- /// <summary>
- /// 转台复位
- /// </summary>
- /// <param name="loc"></param>
- public void TurnReset(int loc)
- {
- switch (loc)
- {
- case 1: WriteData("M13.0", false); break;
- case 2: WriteData("M13.1", false); break;
- case 3: WriteData("M13.2", false); break;
- case 4: WriteData("M13.3", false); break;
- case 5: WriteData("M13.4", false); break;
- }
- }
- /// <summary>
- /// 取素菜A料
- /// </summary>
- private void TakeBurdenATask()
- {
- int loc = 0;
- #region 单口锅逻辑
- while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- {
- Task.Delay(5).Wait();
- }
- if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- {
- loc = order.MaterialLoc[0];
- TakeBurden();
- TurnReset(loc);//转台复位
-
- DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- }
- //等待取料完成
- while (!morkF.TakeMaterialComplete)
- {
- Task.Delay(5).Wait();
- }
- WriteData("M14.1", false);//机器人取料完成复位
- #endregion
- #region 两口锅逻辑
- //if (morkF.MainProcessStatus)
- //{
- // if (morkF.MainProcessPotLoc == 1)
- // {
- // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // else
- // {
- // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- // {
- // loc = order.MaterialLoc[0];
- // TakeBurden();
- // TurnReset(loc);//转台复位
-
- // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- // }
- // //等待取料完成
- // while (!morkF.TakeMaterialComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.MainOrderMaterialCom = false;
- // morkF.MainHasTakeMaterial = true;
- // WriteData("M14.1", false);//机器人取料完成复位
- //}
- //if (morkF.MinorProessStatus)
- //{
- // if (morkF.MinorProcessPotLoc == 1)
- // {
- // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // else
- // {
- // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- // {
- // loc = order.MaterialLoc[0];
- // TakeBurden();
- // TurnReset(loc);//转台复位
-
- // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- // }
- // //等待取料完成
- // while (!morkF.TakeMaterialComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.MinorOrderMaterialCom = false;
- // morkF.MinorHasTakeMaterial = true;
- // WriteData("M14.5", false);//机器人取料完成复位
- //}
- #endregion
- morkF.TurnTableLock = false;//转台互锁解除
-
-
- }
-
- /// <summary>
- /// 取素菜B料
- /// </summary>
- private void TakeBurdenBTask()
- {
- int loc = 0;
- //while (morkF.RoobotIdle || (!morkF.PotInPlace && !morkF.SecondPotInPlace) || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅到位
- //{
- // Task.Delay(5).Wait();
- //}
- if (morkF.MainProcessStatus)
- {
- if (morkF.MainProcessPotLoc == 1)
- {
- while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- {
- Task.Delay(5).Wait();
- }
- }
- else
- {
- while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
- {
- Task.Delay(5).Wait();
- }
- }
- if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- {
- loc = order.MaterialLoc[0];
- TakeBurden();
- TurnReset(loc);//转台复位
-
- DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- }
- //等待取料完成
- while (!morkF.TakeMaterialComplete)
- {
- Task.Delay(5).Wait();
- }
- morkF.MainOrderMaterialCom = false;
- morkF.MainHasTakeMaterial = true;
- WriteData("M14.1", false);//机器人取料完成复位
- }
- if (morkF.MinorProessStatus)
- {
- if (morkF.MinorProcessPotLoc == 1)
- {
- while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- {
- Task.Delay(5).Wait();
- }
- }
- else
- {
- while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
- {
- Task.Delay(5).Wait();
- }
- }
- if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- {
- loc = order.MaterialLoc[0];
- TakeBurden();
- TurnReset(loc);//转台复位
-
- DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- }
- //等待取料完成
- while (!morkF.TakeMaterialComplete)
- {
- Task.Delay(5).Wait();
- }
- morkF.MinorOrderMaterialCom = false;
- morkF.MinorHasTakeMaterial = true;
- WriteData("M14.5", false);//机器人取料完成复位
- }
- morkF.TurnTableLock = false;//转台互锁解除
- }
- /// <summary>
- /// 取调味品C料
- /// </summary>
- /// <exception cref="NotImplementedException"></exception>
- private void TakeBurdenCTask()
- {
- #region 单口锅逻辑
- int loc = 0;
- while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- {
- Task.Delay(5).Wait();
- }
- if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- {
- loc = order.MaterialLoc[0];
- TakeBurden();
- TurnReset(loc);//转台复位
-
- DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- }
- //等待取料完成
- while (!morkF.TakeMaterialComplete)
- {
- Task.Delay(5).Wait();
- }
-
- WriteData("M14.1", false);//机器人取料完成复位
- morkF.TurnTableLock = false;//转台互锁解除
- #endregion
- #region 两口锅逻辑
- //int loc = 0;
-
- //if (morkF.MainProcessStatus)
- //{
- // if (morkF.MainProcessPotLoc == 1)
- // {
- // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // else
- // {
- // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- // {
- // loc = order.MaterialLoc[0];
- // TakeBurden();
- // TurnReset(loc);//转台复位
-
- // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- // }
- // //等待取料完成
- // while (!morkF.TakeMaterialComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.MainOrderMaterialCom = false;
- // morkF.MainHasTakeMaterial = true;
- // WriteData("M14.1", false);//机器人取料完成复位
- //}
- //if (morkF.MinorProessStatus)
- //{
- // if (morkF.MinorProcessPotLoc == 1)
- // {
- // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // else
- // {
- // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- // {
- // loc = order.MaterialLoc[0];
- // TakeBurden();
- // TurnReset(loc);//转台复位
-
- // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
- // }
- // //等待取料完成
- // while (!morkF.TakeMaterialComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.MinorOrderMaterialCom = false;
- // morkF.MinorHasTakeMaterial = true;
- // WriteData("M14.5", false);//机器人取料完成复位
- //}
- //morkF.TurnTableLock = false;//转台互锁解除
- #endregion
- }
- /// <summary>
- /// 主流程出餐
- /// </summary>
- private void MainProcessOutDishTask()
- {
- //while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足
- //{
- // Task.Delay(5).Wait();
- //}
- #region 单口锅逻辑
- while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足
- {
- Task.Delay(5).Wait();
- }
- if (morkF.TakePlateQueue.Count == 0)
- {
- WriteData("M0.7", false);//无订单关闭抽风机
- }
- MainProcessRobotOutMeal();
- WriteData("M1.2", false);//供盘复位
- DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行取锅到清洗台控制");
- #endregion
- #region 两口锅逻辑
- //while (morkF.RoobotIdle || (morkF.CleanModule && morkF.SecondCleanModule) || !morkF.ProvidePlateComplete)//等待条件满足
- //{
- // Task.Delay(5).Wait();
- //}
- //if (morkF.TakePlateQueue.Count == 0)
- //{
- // WriteData("M0.7", false);//无订单关闭抽风机
- //}
- //MainProcessRobotOutMeal();
- //WriteData("M1.2", false);//供盘复位
- //DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】执行取锅到清洗台控制");
- #endregion
-
- }
- /// <summary>
- /// 复流程流程出餐
- /// </summary>
- private void MinorProcessOutDishTask()
- {
- //while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足
- //{
- // Task.Delay(5).Wait();
- //}
- while (morkF.RoobotIdle || (morkF.CleanModule && morkF.SecondCleanModule) || !morkF.ProvidePlateComplete)//等待条件满足
- {
- Task.Delay(5).Wait();
- }
- if (morkF.TakePlateQueue.Count == 0)
- {
- WriteData("M0.7", false);//无订单关闭抽风机
- }
- MinorProcessRobotOutMeal();
- WriteData("M1.2", false);//供盘复位
- DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】执行取锅到清洗台控制");
- }
- /// <summary>
- /// 主流程洗锅放锅
- /// </summary>
- private void MainProcessCleanPotTask()
- {
- #region 单口锅逻辑
- while (!morkF.PlaceRinseTableComplete || morkF.CleanModule)
- {
- Task.Delay(5).Wait();
- }
- WriteData("M14.2", false);//机器人出餐完成复位
- CleanModuleControl("Start", 1);
- DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行清洗操作");
- #endregion
- #region 两口锅逻辑
- //while ((!morkF.PlaceRinseTableComplete || morkF.CleanModule) && (!morkF.PlaceRinseSecondTableComplete || morkF.SecondCleanModule))
- //{
- // Task.Delay(5).Wait();
- //}
-
- //WriteData("M14.2", false);//机器人出餐完成复位
- //if (morkF.PlaceRinseTableComplete && !morkF.CleanModule)
- //{
- // CleanModuleControl("Start", 1);
- //}
- //if (morkF.PlaceRinseSecondTableComplete && !morkF.SecondCleanModule)
- //{
- // CleanModuleControl("Start", 2);
- //}
- //DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】执行清洗操作");
- //morkF.MainProcessFlag = false;
- //minorReset.Set();
- #endregion
- //OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COMPLETED_COOK);
- }
-
- /// <summary>
- /// 辅流程洗锅放锅
- /// </summary>
- private void MinorProcessCleanPotTask()
- {
- while ((!morkF.PlaceRinseTableComplete || morkF.CleanModule) && (!morkF.PlaceRinseSecondTableComplete || morkF.SecondCleanModule))
- {
- Task.Delay(5).Wait();
- }
-
- WriteData("M14.6", false);//机器人出餐完成复位
- if (morkF.PlaceRinseTableComplete && !morkF.CleanModule)
- {
- CleanModuleControl("Start", 1);
- }
- if (morkF.PlaceRinseSecondTableComplete && !morkF.SecondCleanModule)
- {
- CleanModuleControl("Start", 2);
- }
- DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】执行清洗操作");
- morkF.MinorProcessFlag = false;
- mainReset.Set();
-
- //OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COMPLETED_COOK);
- }
- /// <summary>
- /// 任务复位重启
- /// </summary>
- //private void ResetProgram()
- //{
- // ThreadManage.GetInstance().StartLong(new Action(() =>
- // {
- // if (RTrig.GetInstance("ResetProgram").Start(morkF.DevicDataInite))
- // {
- // ThreadManage.GetInstance().StopTask("MainTask", new Action(() =>
- // {
- // ThreadManage.GetInstance().StopTask("ReadPLCData", new Action(() =>
- // {
- // morkF = null;
- // morkF = new GVL_MorkF();
- // ActionManage.GetInstance.Send("ResetProgram");
- // ActionManage.GetInstance.Send("ClearOrders");
- // ReadData();
- // Main();
- // }));
- // }));
- // }
-
- // Thread.Sleep(10);
- // }), "ResetProgram");
- //}
- /// <summary>
- /// 主流程翻转机下降及状态检测
- /// </summary>
- public void MainProcessTurnDownStatusDetect()
- {
- int potLoc = MainProcessTurnMachineOrientControl("Down");
-
- if (potLoc == 1)
- {
- while (!morkF.TurnMachineDownComplete)//等待翻转机下降完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.3", false);//下降完成复位
- }
- if (potLoc == 2)
- {
- while (!morkF.SecondTurnMachineDownComplete)//等待翻转机下降完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.7", false);//下降完成复位
- }
- DeviceProcessLogShow($"翻转机下降完成");
-
- }
- /// <summary>
- /// 辅流程翻转机下降及状态检测
- /// </summary>
- public void MinorProcessTurnDownStatusDetect()
- {
- int potLoc = MinorProcessTurnMachineOrientControl("Down");
-
- if (potLoc == 1)
- {
- while (!morkF.TurnMachineDownComplete)//等待翻转机下降完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.3", false);//下降完成复位
- }
- if (potLoc == 2)
- {
- while (!morkF.SecondTurnMachineDownComplete)//等待翻转机下降完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.7", false);//下降完成复位
- }
- DeviceProcessLogShow($"翻转机下降完成");
- //if (morkF.MaterialCount == 3 && morkF.MainProcessStatus)
- //{
- // morkF.MainProcessWait = true;
- //}
- //else if (morkF.MaterialCount == 3 && morkF.MinorProessStatus)
- //{
- // morkF.MinorProcessWait = true;
- //}
-
- }
- /// <summary>
- /// 主流程翻转机上升及状态检测
- /// </summary>
- public void MainProcessTurnUpStatusDetect()
- {
- //while (morkF.RoobotIdle)//机器人忙碌
- //{
- // Task.Delay(5).Wait();
- //}
- MainProcessTurnMachineOrientControl("Top");//翻转机上升
- #region 单口锅逻辑
- while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.1", false);//上升完成复位
- WriteData("M14.3", true);//倒料
- while (!morkF.FallMaterialComplete)//等待倒料完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M14.3", false);//倒料复位
- DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】,配料倒料完成");
- #endregion
- #region 两口锅逻辑
- //if (morkF.MainProcessPotLoc == 1)
- //{
- // while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成
- // {
- // Task.Delay(5).Wait();
- // }
- // WriteData("M8.1", false);//上升完成复位
- // if (!morkF.MainOrderMaterialCom)
- // {
- // WriteData("M14.3", true);//倒料
- // while (!morkF.FallMaterialComplete)//等待倒料完成
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.MaterialCount++;
- // WriteData("M14.3", false);//倒料复位
- // if (morkF.MaterialCount == 3)
- // {
- // //允许执行下一个订单流程
- // morkF.MaterialCount = 0;
- // morkF.MinorProcessFlag = true;
-
- // }
- // morkF.MainOrderMaterialCom = true;
- // morkF.MainHasTakeMaterial = false;
- // DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】,配料倒料完成");
- // }
- // else //辅程准备阻塞
- // {
- // morkF.MainProcessWait = true;
- // }
- //}
- //if (morkF.MainProcessPotLoc == 2)
- //{
- // while (!morkF.SecondTurnMachineUpComplete)//等待翻转机上升完成以及取料完成
- // {
- // Task.Delay(5).Wait();
- // }
- // WriteData("M8.5", false);//上升完成复位
- // if (!morkF.MainOrderMaterialCom)
- // {
- // WriteData("M14.7", true);//倒料
- // while (!morkF.SecondFallMaterialComplete)//等待倒料完成
- // {
- // Task.Delay(5).Wait();
- // }
- // morkF.MaterialCount++;
- // WriteData("M14.7", false);//倒料复位
- // if (morkF.MaterialCount == 3)
- // {
- // //允许执行下一个订单流程
- // morkF.MaterialCount = 0;
- // morkF.MinorProcessFlag = true;
-
- // }
- // morkF.MainOrderMaterialCom = true;
- // morkF.MainHasTakeMaterial = false;
- // DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】,配料倒料完成");
- // }
- // else //辅流程准备阻塞
- // {
- // morkF.MainProcessWait = true;
- // }
- //}
- #endregion
- DeviceProcessLogShow("翻转机上升完成");
- }
- /// <summary>
- /// 辅流程翻转机上升及状态检测
- /// </summary>
- public void MinorProcessTurnUpStatusDetect()
- {
- while (morkF.RoobotIdle)//机器人忙碌
- {
- Task.Delay(5).Wait();
- }
- MinorProcessTurnMachineOrientControl("Top");//翻转机上升
-
- if (morkF.MinorProcessPotLoc == 1)
- {
- while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.1", false);//上升完成复位
- if (!morkF.MinorOrderMaterialCom)
- {
- WriteData("M14.3", true);//倒料
- while (!morkF.FallMaterialComplete)//等待倒料完成
- {
- Task.Delay(5).Wait();
- }
- morkF.MaterialCount++;
- WriteData("M14.3", false);//倒料复位
- if (morkF.MaterialCount == 3)
- {
- //允许执行下一个订单流程
- morkF.MaterialCount = 0;
- morkF.MainProcessFlag = true;
-
- }
- morkF.MinorOrderMaterialCom = true;
- morkF.MinorHasTakeMaterial = false;
- DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】,配料倒料完成");
- }
- else //主程准备阻塞
- {
- morkF.MinorProcessWait = true;
- }
- }
- if (morkF.MinorProcessPotLoc == 2)
- {
- while (!morkF.SecondTurnMachineUpComplete)//等待翻转机上升完成以及取料完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.5", false);//上升完成复位
- if (!morkF.MinorOrderMaterialCom)
- {
- WriteData("M14.7", true);//倒料
- while (!morkF.SecondFallMaterialComplete)//等待倒料完成
- {
- Task.Delay(5).Wait();
- }
- morkF.MaterialCount++;
- WriteData("M14.7", false);//倒料复位
- if (morkF.MaterialCount == 3)
- {
- //允许执行下一个订单流程
- morkF.MaterialCount = 0;
- morkF.MainProcessFlag = true;
-
- }
- morkF.MinorOrderMaterialCom = true;
- morkF.MinorHasTakeMaterial = false;
- DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】,配料倒料完成");
- }
- else //主流程准备阻塞
- {
- morkF.MinorProcessWait = true;
- }
- }
- DeviceProcessLogShow("翻转机上升完成");
-
- }
- private void GetStatus(string key, Action<bool[]> action)
- {
- if (peripheralStatus.ContainsKey(key))
- {
- action((bool[])peripheralStatus[key]);//获取PLC指定地址的状态值
- }
- }
- /// <summary>
- /// 写数据
- /// </summary>
- /// <param name="address"></param>
- /// <param name="value"></param>
- private void WriteData(string address, object value)
- {
- EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value });
- }
-
- public void FirstPotGears(int number)
- {
- switch (number)
- {
- case 0:
- //if (morkF.MainProcessStatus && morkF.PotInPlace)
- WriteData("M4.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
- //if (morkF.MinorProessStatus && morkF.SecondPotInPlace)
- // WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
- break;
- case 1:
- // if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
- break;
- case 2:
- //if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
- break;
- case 3:
- //if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
- break;
- case 4:
- // if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
- break;
- case 5:
- if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
- break;
- case 6:
- // if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
- break;
- case 7:
- // if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
- break;
- case 8:
- //if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
- break;
- case 9:
- //if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
- break;
-
- }
- }
-
- public void SecondPotGears(int number)
- {
- switch (number)
- {
- case 0:
- //if (morkF.MainProcessStatus && morkF.PotInPlace)
- WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
- //if (morkF.MinorProessStatus && morkF.SecondPotInPlace)
- // WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
- break;
- case 1:
- // if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
- break;
- case 2:
- //if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
- break;
- case 3:
- //if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
- break;
- case 4:
- // if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
- break;
- case 5:
- if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
- break;
- case 6:
- // if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
- break;
- case 7:
- // if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
- break;
- case 8:
- //if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
- break;
- case 9:
- //if (morkF.MainProcessStatus)
- WriteData("M5.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
- //if (morkF.MinorProessStatus)
- // WriteData("M5.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
- break;
-
- }
- }
- /// <summary>
- /// 主流程灶台档位调节
- /// </summary>
- public void MainProcessKitchenAdjustGears(int number)
- {
- #region 单口锅逻辑
- while (!morkF.PotInPlace)
- {
- Task.Delay(5).Wait();
- }
- FirstPotGears(number);
- DeviceProcessLogShow($"灶台【{morkF.CurrentOrderId}】档位调节至【{number}】挡");
- #endregion
-
- #region 两口锅逻辑
- //if (morkF.MainProcessPotLoc == 1)
- //{
- // while (!morkF.PotInPlace)
- // {
- // Task.Delay(5).Wait();
- // }
- // FirstPotGears(number);
- //}
- //if (morkF.MainProcessPotLoc == 2)
- //{
- // while (!morkF.SecondPotInPlace)
- // {
- // Task.Delay(5).Wait();
- // }
- // SecondPotGears(number);
- //}
- //DeviceProcessLogShow($"灶台【{morkF.MainProcessPotLoc}】档位调节至【{number}】挡");
- #endregion
-
- }
- /// <summary>
- /// 辅流程灶台档位调节
- /// </summary>
- public void MinorProcessKitchenAdjustGears(int number)
- {
- if (morkF.MinorProcessPotLoc == 1)
- {
- while (!morkF.PotInPlace)
- {
- Task.Delay(5).Wait();
- }
- FirstPotGears(number);
- }
- if (morkF.MinorProcessPotLoc == 2)
- {
- while (!morkF.SecondPotInPlace)
- {
- Task.Delay(5).Wait();
- }
- SecondPotGears(number);
- }
- DeviceProcessLogShow($"灶台【{morkF.MinorProcessPotLoc}】档位调节至【{number}】挡");
- }
- /// <summary>
- /// PLC转台控制
- /// </summary>
- /// <param name="loc"></param>
- public void TurnMaterialStore(int loc)
- {
- switch (loc)
- {
- case 1:
- WriteData("M13.0", true);
- break;
- case 2:
- WriteData("M13.1", true);
- break;
- case 3:
- WriteData("M13.2", true);
- break;
- case 4:
- WriteData("M13.3", true);
- break;
- case 5:
- WriteData("M13.4", true);
- break;
- }
-
- }
- public void PLCInite()
- {
- WriteData("M0.0", true);
-
- }
- /// <summary>
- /// 供盘启动
- /// </summary>
- public void StartTakePlate()
- {
- WriteData("M1.1", true);
- }
- /// <summary>
- /// 取锅到灶台
- /// </summary>
- public void TakePotToKitchen(int loc)
- {
- if (loc == 1)
- WriteData("M14.0", true);
- if (loc == 2)
- WriteData("M14.4", true);
- }
- /// <summary>
- /// 主流程机器人出餐并将锅放置清洗台位置
- /// </summary>
- public void MainProcessRobotOutMeal()
- {
- #region 单口锅逻辑
- WriteData("M14.2", true);//1号锅出餐
- #endregion
- #region 两口锅逻辑
- //if (morkF.MainProcessPotLoc == 1)
- //{
- // WriteData("M14.2", true);//1号锅出餐
- //}
- //else if (morkF.MainProcessPotLoc == 2)
- //{
- // WriteData("M14.6", true);//2号锅出餐
- //}
- #endregion
- }
-
- /// <summary>
- /// 复流程机器人出餐并将锅放置清洗台位置
- /// </summary>
- public void MinorProcessRobotOutMeal()
- {
-
- if (morkF.MinorProcessPotLoc == 1)
- {
- WriteData("M14.2", true);//1号锅出餐
- }
- else if (morkF.MinorProcessPotLoc == 2)
- {
- WriteData("M14.6", true);//2号锅出餐
- }
-
-
- }
- public void OpenDraft()
- {
- WriteData("M0.7", true);//打开抽风机
- }
- /// <summary>
- /// 注油
- /// </summary>
- public void AddOil()
- {
- #region 单口锅逻辑
- while (!morkF.PotInPlace)
- {
- Task.Delay(5).Wait();
- }
- WriteData("M2.7", true);//加油
- OpenDraft();
- DeviceProcessLogShow("开始注油");
- while (!morkF.FallOilComplete)
- {
- Task.Delay(5).Wait();
- }
- #endregion
- #region 两口锅逻辑
- //if (morkF.MainProcessStatus)
- //{
- // if (morkF.MainProcessPotLoc == 1)
- // {
- // while (!morkF.PotInPlace)
- // {
- // Task.Delay(5).Wait();
- // }
- // WriteData("M2.7", true);//加油
- // OpenDraft();
- // DeviceProcessLogShow("开始注油");
- // while (!morkF.FallOilComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // if (morkF.MainProcessPotLoc == 2)
- // {
- // while (!morkF.SecondPotInPlace)
- // {
- // Task.Delay(5).Wait();
- // }
- // WriteData("M3.1", true);//加油
- // OpenDraft();
- // DeviceProcessLogShow("开始注油");
- // while (!morkF.SecondOilComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- //}
- //if (morkF.MinorProessStatus)
- //{
- // if (morkF.MinorProcessPotLoc == 1)
- // {
- // while (!morkF.PotInPlace)
- // {
- // Task.Delay(5).Wait();
- // }
- // WriteData("M2.7", true);//加油
- // OpenDraft();
- // DeviceProcessLogShow("开始注油");
- // while (!morkF.FallOilComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- // if (morkF.MinorProcessPotLoc == 2)
- // {
- // while (!morkF.SecondPotInPlace)
- // {
- // Task.Delay(5).Wait();
- // }
- // WriteData("M3.1", true);//加油
- // OpenDraft();
- // DeviceProcessLogShow("开始注油");
- // while (!morkF.SecondOilComplete)
- // {
- // Task.Delay(5).Wait();
- // }
- // }
- //}
- #endregion
- //while (!morkF.FallOilComplete || !morkF.SecondOilComplete)
- //{
- // Task.Delay(5).Wait();
- //}
- DeviceProcessLogShow("注油完成");
-
- }
- public void FirstPotTurnMachine(string orientation)
- {
- switch (orientation)
- {
- case "Top": WriteData("M8.0", true); break;
- case "Down": WriteData("M8.2", true); break;
- }
- }
- public void SecondPotTurnMachine(string orientation)
- {
- switch (orientation)
- {
- case "Top": WriteData("M8.4", true); break;
- case "Down": WriteData("M8.6", true); break;
- }
- }
-
- /// <summary>
- /// 主流程翻转机方向控制
- /// </summary>
- /// <param name="orientation"></param>
- public int MainProcessTurnMachineOrientControl(string orientation)
- {
- int potLoc = 0;
- #region 单口锅逻辑
- FirstPotTurnMachine(orientation);
- potLoc = 1;
- #endregion
- #region 两口锅逻辑
- //if (morkF.MainProcessPotLoc == 1)
- //{
- // FirstPotTurnMachine(orientation);
- // potLoc = 1;
- //}
- //if (morkF.MainProcessPotLoc == 2)
- //{
- // SecondPotTurnMachine(orientation);
- // potLoc = 2;
- //}
- #endregion
- DeviceProcessLogShow($"翻转机执行{orientation}操作");
-
- return potLoc;
- }
- /// <summary>
- /// 辅流程翻转机方向控制
- /// </summary>
- /// <param name="orientation"></param>
- public int MinorProcessTurnMachineOrientControl(string orientation)
- {
- int potLoc = 0;
-
- if (morkF.MinorProcessPotLoc == 1)
- {
- FirstPotTurnMachine(orientation);
- potLoc = 1;
- }
- if (morkF.MinorProcessPotLoc == 2)
- {
- SecondPotTurnMachine(orientation);
- potLoc = 2;
- }
-
- DeviceProcessLogShow($"翻转机执行{orientation}操作");
- return potLoc;
- }
- public void FirstPotTurnMachine(int gear)
- {
- while (!morkF.PotInPlace)
- {
- Task.Delay(5).Wait();
- }
- switch (gear)
- {
- case 0: WriteData("M7.0", true); Task.Delay(1000).Wait(); break;//关闭翻炒机
- case 1: WriteData("M7.1", true); break;//翻炒机1挡
- case 2: WriteData("M7.2", true); break;//翻炒机2挡
- case 3: WriteData("M7.3", true); break;//翻炒机3挡
- }
- }
- public void SecondPotTurnMachine(int gear)
- {
- while (!morkF.SecondPotInPlace)
- {
- Task.Delay(5).Wait();
- }
- switch (gear)
- {
- case 0: WriteData("M7.4", true); Task.Delay(1000).Wait(); break;//关闭翻炒机
- case 1: WriteData("M7.5", true); break;//翻炒机1挡
- case 2: WriteData("M7.6", true); break;//翻炒机2挡
- case 3: WriteData("M7.7", true); break;//翻炒机3挡
- }
- }
-
- /// <summary>
- /// 主流程翻转机档位控制
- /// </summary>
- public void MainProcessTurnMachineGearsControl(int gear)
- {
- #region 单口锅逻辑
- FirstPotTurnMachine(gear);
- DeviceProcessLogShow($"炒锅【{morkF.CurrentOrderId}】翻转机档位调至{gear}挡");
- #endregion
- #region 两口锅逻辑
- //if (morkF.MainProcessPotLoc == 1)
- //{
- // FirstPotTurnMachine(gear);
- //}
- //if (morkF.MainProcessPotLoc == 2)
- //{
- // SecondPotTurnMachine(gear);
- //}
- //DeviceProcessLogShow($"炒锅【{morkF.MainProcessPotLoc}】翻转机档位调至{gear}挡");
- #endregion
- }
- /// <summary>
- /// 辅流程翻转机档位控制
- /// </summary>
- public void MinorProcessTurnMachineGearsControl(int gear)
- {
- if (morkF.MinorProcessPotLoc == 1)
- {
- FirstPotTurnMachine(gear);
- }
- if (morkF.MinorProcessPotLoc == 2)
- {
- SecondPotTurnMachine(gear);
- }
-
- DeviceProcessLogShow($"炒锅【{morkF.MinorProcessPotLoc}】翻转机档位调至{gear}挡");
- }
- /// <summary>
- /// 取A,B,C料
- /// </summary>
- public void TakeBurden()
- {
- #region 单口锅逻辑
- WriteData("M14.1", true);//机器人取料至1号锅
- #endregion
- #region 两口锅逻辑
- //if (morkF.PotInPlace)
- // WriteData("M14.1", true);//机器人取料至1号锅
- //if (morkF.SecondPotInPlace)
- // WriteData("M14.5", true);//机器人取料至2号锅
- #endregion
- }
- /// <summary>
- /// 清洗模组1启停控制
- /// </summary>
- public void CleanModuleControl(string status, int loc)
- {
- if (loc == 1)
- {
- if (status == "Start")
- {
- WriteData("M1.4", true);
- }
- if (status == "Stop")
- {
- WriteData("M1.4", false);
- }
- DeviceProcessLogShow($"清洗模组1执行【{status}】操作");
- }
- if (loc == 2)
- {
- if (status == "Start")
- {
- WriteData("M1.7", true);
- }
- if (status == "Stop")
- {
- WriteData("M1.7", false);
- }
- DeviceProcessLogShow($"清洗模组2执行【{status}】操作");
- }
- }
-
- public override void Stop()
- {
-
- }
-
- public override void SimOrder()
- {
-
- }
- }
- }
|