|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496 |
- 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;
-
-
- namespace BPASmartClient.MorkF
- {
- public class Control_MorkF : BaseDevice
- {
- public override DeviceClientType DeviceType => DeviceClientType.MORKSF;
- public AutoResetEvent minorReset = new AutoResetEvent(false);
- public AutoResetEvent mainReset = new AutoResetEvent(false);
- GVL_MorkF morkF = new GVL_MorkF();//全局对象声明
- public StirFryBom stirFryBom = new StirFryBom();//创建获取流程的对象
-
- 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.灶取锅 } });
- }
- /// <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()
- {
- ////模拟流程
- //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 = 3 });
- //stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油, StirFryPotAction.停止火力 }, During = 3 });
- //stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.停止火力, StirFryPotAction.低速旋转 }, During = 15 });
-
- //stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入A料, }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转 } });
- //stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.快速旋转, StirFryPotAction.停止火力 }, During = 5 });
- //stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入B料, }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转 } });
- //stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, PotActions = new List<StirFryPotAction>() { StirFryPotAction.快速旋转, StirFryPotAction.停止火力 }, During = 5 });
- //stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入C料, }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转 } });
- //stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.快速旋转, StirFryPotAction.停止火力 }, During = 3 });
- //stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
- //stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T12, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } });
- //队列
- string subId = Guid.NewGuid().ToString();
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = 1 });//A料
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = 2 });//B料
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = 3 });//C料
- morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId });
- resultorder.AddRange(new int[] { 1, 2, 3 });
- morkF.listStirBom.Add(stirFryBom);
- }
- #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();
- }
- });
- }
-
- private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
- {
- EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid });
- }
-
- /// <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>
- 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}次订单");
- foreach (var item in order.MorkOrder.GoodBatchings)
- {
- var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId);
- if (res != null)
- {
- if (ushort.TryParse(res.BatchingLoc, out ushort loc))
- {
-
- //if (morkF.TakeMaterialQueue.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
- //将一个商品的ABC料位置存入队列
- morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, BatchingId = res.BatchingId, MaterialLoc = ushort.Parse(res.BatchingLoc) });
- }
-
-
-
- //int index = 0;
- //if (recipeBoms != null)
- //{
- // index = Array.FindIndex(recipeBoms.RecipeIds?.ToArray(), p => p.RecipeId == order.MorkOrder.RecipeId);
- // index++;
- //}
- if (morkF.TakePlateQueue.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
- morkF.TakePlateQueue.Enqueue(new OrderLocInfo()
- {
- SuborderId = order.MorkOrder.SuborderId,
- BatchingId = res.BatchingId
- //RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0
- });
-
-
- }
- }
- //根据ID 查找对应制作流程,
-
- }
- });
- }
- //}
- /// <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.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.灶取锅:
- OutDishTask();//执行出餐操作
- CleanPotTask();//洗锅操作
- break;
- }
-
- }
-
- }));
- //炒锅线程操作
- Task taskPot = Task.Run(new Action(() =>
- {
- foreach (var temp in res.PotActions)
- {
- switch (temp)
- {
- case StirFryPotAction.NONE:
- break;
- case StirFryPotAction.大火t1s:
- KitchenAdjustGears(3);
- Task.Delay(1000).Wait(); //大火加热1s//执行大火锅干操作
- break;
- case StirFryPotAction.加油:
- AddOil();//注油//执行加油操作
- break;
- case StirFryPotAction.中火t2s:
- KitchenAdjustGears(2);
- Task.Delay(2000).Wait();//执行操作
- break;
- case StirFryPotAction.小火持续:
- KitchenAdjustGears(1);
- break;
- case StirFryPotAction.中火持续:
- KitchenAdjustGears(5);
- break;
- case StirFryPotAction.大火持续:
- KitchenAdjustGears(7);
- break;
- case StirFryPotAction.停止火力:
- KitchenAdjustGears(0);//关闭灶加热
- break;
- case StirFryPotAction.搅拌臂上位:
- TurnUpStatusDetect();//执行搅拌臂上位操作
- break;
- case StirFryPotAction.搅拌臂下位:
- TurnDownStatusDetect();//执行搅拌臂下位操作
- break;
- case StirFryPotAction.低速旋转:
- TurnMachineGearsControl(1);//执行搅拌臂速度1挡操作
- break;
- case StirFryPotAction.快速旋转:
- TurnMachineGearsControl(2);//执行搅拌臂速度3挡操作
- break;
- case StirFryPotAction.停止旋转:
- TurnMachineGearsControl(0);//执行搅拌臂速度0挡操作
- break;
- }
- }
- }));
- Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束
- Task.Delay(res.During * 1000).Wait();//当前流程延迟
- if (morkF.MainProcessWait)
- {
-
- KitchenAdjustGears(0);//关闭灶加热
- morkF.MinorProessStatus = false;
- morkF.MainProcessStatus = true;
- //阻塞辅流程
- 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.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.灶取锅:
- OutDishTask();//执行出餐操作
- CleanPotTask();//洗锅操作
- break;
- }
-
- }
-
- }));
- //炒锅线程操作
- Task taskPot = Task.Run(new Action(() =>
- {
- foreach (var temp in res.PotActions)
- {
- switch (temp)
- {
- case StirFryPotAction.NONE:
- break;
- case StirFryPotAction.大火t1s:
- KitchenAdjustGears(3);
- Task.Delay(1000).Wait(); //大火加热1s//执行大火锅干操作
- break;
- case StirFryPotAction.加油:
- AddOil();//注油//执行加油操作
- break;
- case StirFryPotAction.中火t2s:
- KitchenAdjustGears(2);
- Task.Delay(2000).Wait();//执行操作
- break;
- case StirFryPotAction.小火持续:
- KitchenAdjustGears(1);
- break;
- case StirFryPotAction.中火持续:
- KitchenAdjustGears(5);
- break;
- case StirFryPotAction.大火持续:
- KitchenAdjustGears(7);
- break;
- case StirFryPotAction.停止火力:
- KitchenAdjustGears(0);//关闭灶加热
- break;
- case StirFryPotAction.搅拌臂上位:
- TurnUpStatusDetect();//执行搅拌臂上位操作
- break;
- case StirFryPotAction.搅拌臂下位:
- TurnDownStatusDetect();//执行搅拌臂下位操作
- break;
- case StirFryPotAction.低速旋转:
- TurnMachineGearsControl(1);//执行搅拌臂速度1挡操作
- break;
- case StirFryPotAction.快速旋转:
- TurnMachineGearsControl(2);//执行搅拌臂速度3挡操作
- break;
- case StirFryPotAction.停止旋转:
- TurnMachineGearsControl(0);//执行搅拌臂速度0挡操作
- break;
- }
- }
- }));
-
- Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束
- Task.Delay(res.During * 1000).Wait();//当前流程延迟
- if (morkF.MinorProcessWait)
- {
- KitchenAdjustGears(0);//关闭灶加热
- morkF.MinorProessStatus = true;
- morkF.MainProcessStatus = false;
- //阻塞主流程
- mainReset.WaitOne();
- }
- morkF.MinorProessStatus = false;
- morkF.MainProcessStatus = true;
-
- }
- morkF.MainOutMealComplete = true;
- }
- else
- {
- morkF.MainProcessExcuteLock = false;//解除流程自锁
- }
- }));
- }
-
- }
- /// <summary>
- /// 信号处理
- /// </summary>
- private void SingleProcess()
- {
-
-
- //主流程出餐完成,相应变量复位
- if (morkF.MainOutMealComplete)
- {
- morkF.TakePlateLock = false;
- morkF.PotInPlace = false;
- morkF.MainProcessExcuteLock = false;
- morkF.MainOrderMaterialCom = false;
- }
- //辅流程出餐完成,相应变量复位
- if (morkF.MinorOutMealComplete)
- {
- morkF.TakePlateLock = false;
- morkF.SecondPotInPlace = false;
- morkF.MinorProcessExcuteLock = false;
- morkF.MinorOrderMaterialCom = false;
- }
-
- }
-
- /// <summary>
- /// 转台控制
- /// </summary>
- private void TurntableControl()
- {
- //正常轮询
- //if (morkF.TakeMaterialQueue.Count > 0 && !morkF.TurnTableLock)
- //{
- // var result = orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == morkF.TakeMaterialQueue.ElementAt(0).BatchingId).ToList();
-
- // if (result != null)
- // {
- // if (ushort.TryParse(result[0].BatchingLoc, out ushort loc))
- // {
- // TurnMaterialStore(loc);
- // DeviceProcessLogShow($"转台转到【{loc}】位置");
- // morkF.TurnTableLock = true; //取料完成后置false
- // }
- // }
- // elseDeviceProcessLogShow("未找到可用的物料信息");
- //}
-
- //调试代码
- if (morkF.TakeMaterialQueue.Count > 0 && !morkF.TurnTableLock)
- {
- // var result = orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == morkF.TakeMaterialQueue.ElementAt(0).BatchingId).ToList();
- if (resultorder != null)
- {
-
- TurnMaterialStore(resultorder[0]);
- DeviceProcessLogShow($"转台转到【{resultorder[0]}】位置");
- resultorder.RemoveAt(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();
- if (morkF.MainProcessStatus)
- morkF.MainCurrentOrderId = order.SuborderId;
- if (morkF.MinorProessStatus)
- morkF.MinorCurrentOrderId = order.SuborderId;
- morkF.TakePlateLock = true; //订单完成后置false
- morkF.MainOutMealComplete = false;
- morkF.MinorOutMealComplete = false;
- // OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COOKING);
- DeviceProcessLogShow($"订单【{order.SuborderId}】执行取碗控制");
- }
- }
- }
-
- /// <summary>
- /// 取锅到灶台
- /// </summary>
- /// <exception cref="NotImplementedException"></exception>
- private void TakePotTask()
- {
- //while (!((!morkF.CleanModule && !morkF.KitchenOneStatus && morkF.CleanComplete) || (!morkF.SecondCleanModule && !morkF.KitchenSecondStatus && morkF.SecondCleanComplete)))
- //{
- // Task.Delay(5).Wait();
- //}
- 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完成复位
- }
- if (!morkF.SecondCleanModule && !morkF.KitchenSecondStatus && morkF.SecondCleanComplete)
- {
- //取2号锅到2号灶台
- TakePotToKitchen(2);
- morkF.CurrentPutPotLoc = 2;
- WriteData("M2.0", false);//清洗模组2完成复位
- }
- if (morkF.MainProcessStatus)
- DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】执行取锅到灶台控制");
- if (morkF.MinorProessStatus)
- DeviceProcessLogShow($"订单【{ morkF.MinorCurrentOrderId}】执行取锅到灶台控制");
- if (morkF.CurrentPutPotLoc == 1)
- {
- while (!morkF.PutPotToKitchenComlete)
- {
- Task.Delay(5).Wait();
- }
- morkF.PotInPlace = morkF.PutPotToKitchenComlete;//锅到位
- WriteData("M14.0", false);//机器人取锅完成复位
- }
- if (morkF.CurrentPutPotLoc == 2)
- {
- while (!morkF.PutPotToSecondKitchenComlete)
- {
- Task.Delay(5).Wait();
- }
- morkF.SecondPotInPlace = morkF.PutPotToSecondKitchenComlete;
- WriteData("M14.4", false);//机器人取锅完成复位
- }
-
-
- Thread.Sleep(2000);
-
-
-
-
- }
- /// <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;
- while (morkF.RoobotIdle || (!morkF.PotInPlace && !morkF.SecondPotInPlace) || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅到位
- {
- Task.Delay(5).Wait();
- }
- if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- {
- loc = order.MaterialLoc;
- TakeBurden(loc);
- TurnReset(loc);//转台复位
-
- DeviceProcessLogShow($"订单【{ order.SuborderId}】,执行到转台{loc}位置取料");
- }
- //等待取料完成
- while (!morkF.TakeMaterialComplete)
- {
- Task.Delay(5).Wait();
- }
-
- if (morkF.MainProcessStatus)
- {
- morkF.MainOrderMaterialCom = false;
- WriteData("M14.1", false);//机器人取料完成复位
- }
- if (morkF.MinorProessStatus)
- {
- morkF.MinorOrderMaterialCom = false;
- WriteData("M14.5", false);//机器人取料完成复位
- }
- morkF.TurnTableLock = false;//转台互锁解除
-
-
- }
- /// <summary>
- /// 取素菜B料
- /// </summary>
- private void TakeBurdenBTask()
- {
- while (morkF.RoobotIdle || (!morkF.PotInPlace && !morkF.SecondPotInPlace) || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅到位
- {
- Task.Delay(5).Wait();
- }
- if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- {
- int loc = order.MaterialLoc;
- TakeBurden(loc);
- TurnReset(loc);//转台复位
- DeviceProcessLogShow($"订单【{ order.SuborderId}】,执行取B料");
- }
- //等待取料完成
- while (!morkF.TakeMaterialComplete)
- {
- Task.Delay(5).Wait();
- }
- morkF.MainOrderMaterialCom = false;
- if (morkF.MainProcessStatus)
- {
- morkF.MainOrderMaterialCom = false;
- WriteData("M14.1", false);//机器人取料完成复位
- }
- if (morkF.MinorProessStatus)
- {
- morkF.MinorOrderMaterialCom = false;
- WriteData("M14.5", false);//机器人取料完成复位
- }
- morkF.TurnTableLock = false;//转台互锁解除
- //while (!morkF.FallMaterialComplete)//等待倒料完成
- //{
- // Task.Delay(5).Wait();
- //}
- //MessageLog.GetInstance.Show($"订单【{ order.SuborderId}】,B料倒料完成");
- }
- /// <summary>
- /// 取调味品C料
- /// </summary>
- /// <exception cref="NotImplementedException"></exception>
- private void TakeBurdenCTask()
- {
- while (morkF.RoobotIdle || (!morkF.PotInPlace && !morkF.SecondPotInPlace) || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅到位
- {
- Task.Delay(5).Wait();
- }
- if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
- {
- int loc = order.MaterialLoc;
- TakeBurden(loc);
- TurnReset(loc);//转台复位
- DeviceProcessLogShow($"订单【{ order.SuborderId}】,执行取C料");
- }
- DeviceProcessLogShow($"剩余配料数量{morkF.TakeMaterialQueue.Count}");
- //等待取料完成
- while (!morkF.TakeMaterialComplete)
- {
- Task.Delay(5).Wait();
- }
- morkF.MainOrderMaterialCom = false;
- if (morkF.MainProcessStatus)
- {
- morkF.MainOrderMaterialCom = false;
- WriteData("M14.1", false);//机器人取料完成复位
- }
- if (morkF.MinorProessStatus)
- {
- morkF.MinorOrderMaterialCom = false;
- WriteData("M14.5", false);//机器人取料完成复位
- }
- morkF.TurnTableLock = false;//转台互锁解除
- //while (!morkF.FallMaterialComplete)
- //{
- // Task.Delay(5).Wait();
- //}
- //morkF.SingelOrderMaterialCom = true;
- //MessageLog.GetInstance.Show($"订单【{ order.SuborderId}】,C料倒料完成");
- //}
- }
- /// <summary>
- /// 出餐
- /// </summary>
- private void OutDishTask()
- {
- //while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足
- //{
- // Task.Delay(5).Wait();
- //}
- while (morkF.RoobotIdle || (!morkF.CleanComplete && !morkF.SecondCleanComplete) || !morkF.ProvidePlateComplete)//等待条件满足
- {
- Task.Delay(5).Wait();
- }
-
- if (morkF.TakePlateQueue.Count == 0)
- {
- WriteData("M0.7", false);//无订单关闭抽风机
- }
- RobotOutMeal();
- WriteData("M1.2", false);//供盘复位
- if (morkF.MainProcessStatus)
- DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】执行取锅到清洗台控制");
- if (morkF.MinorProessStatus)
- DeviceProcessLogShow($"订单【{ morkF.MinorCurrentOrderId}】执行取锅到清洗台控制");
-
- }
-
- /// <summary>
- /// 洗锅放锅
- /// </summary>
- private void CleanPotTask()
- {
- while (!morkF.PlaceRinseTableComplete || ((morkF.CleanModule && !morkF.MainProcessStatus) && (morkF.SecondCleanModule && !morkF.MinorProessStatus)))
- {
- Task.Delay(5).Wait();
- }
- if (morkF.MainProcessStatus)
- {
-
- WriteData("M14.2", false);//机器人2号锅出餐完成复位
- CleanModuleControl("Start");
- DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】执行清洗操作");
- morkF.MainProcessFlag = false;
- minorReset.Set();
- }
- if (morkF.MinorProessStatus)
- {
- WriteData("M14.6", false);//机器人2号锅出餐完成复位
- CleanModuleControl("Start");
- 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 TurnDownStatusDetect()
- {
- TurnMachineOrientControl("Down");
-
- if (morkF.MainProcessStatus)
- {
- while (!morkF.TurnMachineDownComplete)//等待翻转机下降完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.3", false);//下降完成复位
- }
- if (morkF.MinorProessStatus)
- {
- 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 TurnUpStatusDetect()
- {
- while (morkF.RoobotIdle)//机器人忙碌
- {
- Task.Delay(5).Wait();
- }
- TurnMachineOrientControl("Top");//翻转机上升
- if (morkF.MainProcessStatus)
- {
- while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.1", false);//上升完成复位
- }
- if (morkF.MinorProessStatus)
- {
- while (!morkF.SecondTurnMachineUpComplete)//等待翻转机上升完成以及取料完成
- {
- Task.Delay(5).Wait();
- }
- WriteData("M8.5", false);//上升完成复位
- }
- if (morkF.MainProcessStatus)//代表主流程执行的操作
- {
- 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;
- DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】,配料倒料完成");
- }
- else //辅程准备阻塞
- {
- morkF.MainProcessWait = true;
- }
- }
- else if (morkF.MinorProessStatus)//代表辅流程执行的操作
- {
- if (!morkF.MinorOrderMaterialCom)
- {
- WriteData("M14.3", true);//倒料
- while (!morkF.SecondFallMaterialComplete)//等待倒料完成
- {
- Task.Delay(5).Wait();
- }
- morkF.MaterialCount++;
- WriteData("M14.3", false);//倒料复位
- if (morkF.MaterialCount == 3)
- {
- //允许执行下一个订单流程
- morkF.MaterialCount = 0;
- morkF.MainProcessFlag = true;
-
- }
- morkF.MinorOrderMaterialCom = true;
- 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 });
- }
- /// <summary>
- /// 灶台档位调节
- /// </summary>
- public void KitchenAdjustGears(int number)
- {
- while (!morkF.PotInPlace)
- {
- Task.Delay(5).Wait();
- }
-
- switch (number)
- {
- case 0:
- if (morkF.MainProcessStatus)
- WriteData("M4.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
- if (morkF.MinorProessStatus)
- 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;
-
- }
- if (morkF.MainProcessStatus)
- DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】执行取锅到灶台控制");
- if (morkF.MinorProessStatus)
- DeviceProcessLogShow($"订单【{ morkF.MinorCurrentOrderId}】执行取锅到灶台控制");
- }
- 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 RobotOutMeal()
- {
- if (morkF.MainProcessStatus)
- WriteData("M14.2", true);//1号锅出餐
- if (morkF.MinorProessStatus)
- WriteData("M14.6", true);//2号锅出餐
- }
- /// <summary>
- /// 注油
- /// </summary>
- public void AddOil()
- {
- while (!morkF.PotInPlace)
- {
- Task.Delay(5).Wait();
- }
- if (morkF.MainProcessStatus)
- WriteData("M2.7", true);//加油
- if (morkF.MinorProessStatus)
- WriteData("M3.1", true);//加油
- WriteData("M0.7", true);//打开抽风机
- DeviceProcessLogShow("开始注油");
- while (!morkF.FallOilComplete || !morkF.SecondOilComplete)
- {
- Task.Delay(5).Wait();
- }
- DeviceProcessLogShow("注油完成");
-
- }
- /// <summary>
- /// 翻转机方向控制
- /// </summary>
- /// <param name="orientation"></param>
- public void TurnMachineOrientControl(string orientation)
- {
- switch (orientation)
- {
- case "Top": if (morkF.MainProcessStatus) WriteData("M8.0", true); if (morkF.MinorProessStatus) WriteData("M8.4", true); break;
- case "Down": if (morkF.MainProcessStatus) WriteData("M8.2", true); if (morkF.MinorProessStatus) WriteData("M8.6", true); break;
- }
- DeviceProcessLogShow($"翻转机执行{orientation}操作");
- }
- /// <summary>
- /// 翻转机档位控制
- /// </summary>
- public void TurnMachineGearsControl(int gear)
- {
- while (!morkF.PotInPlace)
- {
- Task.Delay(5).Wait();
- }
- switch (gear)
- {
- case 0: if (morkF.MainProcessStatus) WriteData("M7.0", true); Task.Delay(1000).Wait(); if (morkF.MinorProessStatus) WriteData("M7.4", true); break;//关闭翻炒机
- case 1: if (morkF.MainProcessStatus) WriteData("M7.1", true); if (morkF.MinorProessStatus) WriteData("M7.5", true); break;//翻炒机1挡
- case 2: if (morkF.MainProcessStatus) WriteData("M7.2", true); if (morkF.MinorProessStatus) WriteData("M7.6", true); break;//翻炒机2挡
- case 3: if (morkF.MainProcessStatus) WriteData("M7.3", true); if (morkF.MinorProessStatus) WriteData("M7.7", true); break;//翻炒机3挡
- }
- DeviceProcessLogShow($"翻转机档位调至{gear}挡");
- }
- /// <summary>
- /// 倒A,B,C料
- /// </summary>
- public void TakeBurden(int loc)
- {
- if (morkF.MainProcessStatus && morkF.PotInPlace)
- WriteData("M14.1", true);//机器人倒料至1号锅
- if (morkF.MinorProessStatus && morkF.SecondPotInPlace)
- WriteData("M14.5", true);//机器人倒料至2号锅
- }
- /// <summary>
- /// 清洗模组1启停控制
- /// </summary>
- public void CleanModuleControl(string status)
- {
- if (morkF.MainProcessStatus)
- {
- if (status == "Start")
- {
- WriteData("M1.4", true);
- }
- if (status == "Stop")
- {
- WriteData("M1.4", false);
- }
- DeviceProcessLogShow($"清洗模组1执行【{status}】操作");
- }
- if (morkF.MinorProessStatus)
- {
- 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()
- {
- }
- }
- }
|