|
- using BPA.Message;
- using BPA.Message.Enum;
- using BPASmartClient.Business;
- using BPASmartClient.Device;
- using BPASmartClient.EventBus;
- using BPASmartClient.Helper;
- using BPASmartClient.Message;
- using BPASmartClient.Model;
- using BPASmartClient.Model.大炒;
- using BPASmartClient.MorkBF.Model;
- using BPASmartClient.MorkBF.ViewModel;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using static BPASmartClient.EventBus.EventBus;
- using static BPASmartClient.Model.大炒.FryPotMessages;
-
- namespace BPASmartClient.MorkBF
- {
- public class Control_MorkBF : BaseDevice
- {
- GVL_MorkBF morkBF = new GVL_MorkBF();
- DataReport dataReport = new DataReport();
-
- public override DeviceClientType DeviceType => DeviceClientType.MORKCS;
-
- int RobotLeadTime = 5;//机器人提前动作时间 s
-
- public override void DoMain()
- {
- IsHealth = true;
- BPASmartClient.Helper.Json<LocalFryPotMessage>.Read();
- MonitorViewModel.DeviceId = DeviceId;
- ActionManage.GetInstance.Register(new Action(() =>
- {
- GlobalFoodMenu.LocalFoodMenus.Clear();
- if(BPASmartClient.Helper.Json<LocalFryPotMessage>.Data.FryPotMessage.Count>0)
- {
- foreach (var item in BPASmartClient.Helper.Json<LocalFryPotMessage>.Data.FryPotMessage)
- {
- GlobalFoodMenu.LocalFoodMenus.Add(new FoodMenuModel { GoodKey = item.GoodKey, GoodName = item.GoodName });
- }
- }
-
- }), "更新菜单");
- CommandRegist();//调试
- ServerInit();
- DataParse();//数据解析
- ScreenDataServer();//大屏数据上报
- ActionManage.GetInstance.Send("更新菜单");
- DeviceProcessLogShow("MORKF 设备初始化完成");
- }
-
- 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}次订单");
-
- }
-
- });
- }
-
- 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;
- }
- });
- }
- /// <summary>
- /// 调试
- /// </summary>
- /// <exception cref="NotImplementedException"></exception>
- private void CommandRegist()
- {
- #region 炒锅1
- ActionManage.GetInstance.Register(FirePot1_SetFireGear, "FirePot1_SetFireGear");//炒锅1设定加热挡位
- ActionManage.GetInstance.Register(FirePot1_StartFire, "FirePot1_StartFire");//炒锅1加热启动
- ActionManage.GetInstance.Register(FirePot1_StartFire, "FirePot1_StopFire");//炒锅1关闭加热
- ActionManage.GetInstance.Register(FirePot1_SetStirGear, "FirePot1_SetStirGear");//炒锅1设定搅拌挡位
- ActionManage.GetInstance.Register(FirePot1_StartStir, "FirePot1_StartStir");//炒锅1搅拌启动
- ActionManage.GetInstance.Register(FirePot1_StartStir, "FirePot1_StopStir");//炒锅1搅拌停止
- ActionManage.GetInstance.Register(FirePot1_SetTurnSpeed, "FirePot1_SetTurnSpeed");//炒锅1翻转频率设定
- #endregion
- #region 炒锅2
- ActionManage.GetInstance.Register(FirePot2_SetFireGear, "FirePot2_SetFireGear");//炒锅2设定加热挡位
- ActionManage.GetInstance.Register(FirePot2_StartFire, "FirePot2_StartFire");//炒锅2加热启动
- ActionManage.GetInstance.Register(FirePot2_StartFire, "FirePot2_StopFire");//炒锅2关闭加热
- ActionManage.GetInstance.Register(FirePot2_SetStirGear, "FirePot2_SetStirGear");//炒锅2设定搅拌挡位
- ActionManage.GetInstance.Register(FirePot2_StartStir, "FirePot2_StartStir");//炒锅2搅拌启动
- ActionManage.GetInstance.Register(FirePot2_StartStir, "FirePot2_StopStir");//炒锅2搅拌停止
- ActionManage.GetInstance.Register(FirePot2_SetTurnSpeed, "FirePot2_SetTurnSpeed");//炒锅2翻转频率设定
- #endregion
- #region 炒锅通用
- ActionManage.GetInstance.Register(FirePot_Reset, "FirePot_Reset");//复位;
- ActionManage.GetInstance.Register(FirePot_PotGotoOrigin, "FirePot_PotGotoOrigin");//炒锅回原点
- ActionManage.GetInstance.Register(FirePot_PotGotoP1, "FirePot_PotGotoP1");//炒锅去位置1
- ActionManage.GetInstance.Register(FirePot_PotGotoP2, "FirePot_PotGotoP2");//炒锅去位置2
- ActionManage.GetInstance.Register(FirePot_PotGotoP3, "FirePot_PotGotoP3");//炒锅去位置3
- ActionManage.GetInstance.Register(FirePot_PotGotoP4, "FirePot_PotGotoP4");//炒锅去位置4
- //ActionManage.GetInstance.Register(FirePot_PotGotoOutFoodPosition, "FirePot_PotGotoOutFoodPositiong");//炒锅去出餐位置
- ActionManage.GetInstance.Register(FirePot_PotGotoInFoodPosition, "FirePot_PotGotoInFoodPosition");//炒锅去投料位置
- ActionManage.GetInstance.Register(FirePot_StartOutFood, "FirePot_StartOutFood");//出餐启动
- ActionManage.GetInstance.Register(FirePot_Clean, "FirePot_Clean");//清洗
- ActionManage.GetInstance.Register(FirePot_StartPumpWater, "FirePot_StartPumpWater");//抽水启动
- ActionManage.GetInstance.Register(FirePot_StartPumpOil, "FirePot_StartPumpOil");//抽油启动
- #endregion
- #region 机器人
- ActionManage.GetInstance.Register(RobotStart, "RobotStart");//机器人启动
- ActionManage.GetInstance.Register(RobotStop, "RobotStop");//机器人停止
- ActionManage.GetInstance.Register(RobotReset, "RobotReset");//复位
- ActionManage.GetInstance.Register(RobotProgramStart, "RobotProgramStart");//程序启动
- ActionManage.GetInstance.Register(Robot_Pot1AllowInMaterail, "Robot_Pot1AllowInMaterail");//1号炒锅允许机器人投料
- ActionManage.GetInstance.Register(Robot_Pot1OutFoodInSlowDown, "Robot_Pot1OutFoodInSlowDown");//1号炒锅出餐倒料到减速位
- ActionManage.GetInstance.Register(Robot_Pot1OutFood, "Robot_Pot1OutFoodInSlowDown");//1号炒锅出餐倒料完成
- ActionManage.GetInstance.Register(Robot_Pot2AllowInMaterail, "Robot_Pot2AllowInMaterail");//2号炒锅允许机器人投料
- ActionManage.GetInstance.Register(Robot_Pot2OutFoodInSlowDown, "Robot_Pot2OutFoodInSlowDown");//2号炒锅出餐倒料到减速位
- ActionManage.GetInstance.Register(Robot_Pot2OutFood, "Robot_Pot2OutFood");//2号炒锅出餐倒料完成
- ActionManage.GetInstance.Register(RobotActionStart, "Robot_Pot2OutFood");//2号炒锅出餐倒料完成
-
-
- #endregion
-
- }
-
- public override void MainTask()
- {
- if(morkBF.FirePan1_Order.Count>0&& morkBF.FirePot1_InitCompleted&&morkBF.FirePot2_IsAuto&&!morkBF.FirePan1_Busy)
- {
- ThreadManage.GetInstance().Start(FirePot1_Process, "炒锅1流程");
- }
-
- if(morkBF.RobotActinQueue.Count>0&&! morkBF.Robot_Origin)//机器人在原点为
- {
- if( morkBF.RobotActinQueue.TryDequeue(out RobotAction_Pot robotAction))
- {
- morkBF.Robot_IsBusy =true;
- RobotProcess(robotAction);
- }
- }
- }
-
- private void FirePot1_Process()
- {
-
- if(morkBF.FirePan1_Order.TryDequeue(out FryPotMessages result))
- {
-
- morkBF.FirePan1_Busy = true;
- morkBF.FryPot1_CurrentProcess = result.fryPotProcesses;
- foreach (var item in result.fryPotProcesses)
- {
- switch (item.fryActions)
- {
- case FryAction.冷锅加热:
- FirePot_PotPerHeat(item, 1);
- MessageLog.GetInstance.Show("炒锅1---冷锅加热完成");
- break;
-
- case FryAction.热油:
- FirePot_HeatOil(item,1);
- MessageLog.GetInstance.Show("炒锅1---热油完成");
- break;
- case FryAction.加调料:
- FirePot_AddSeasoning(item, 1);
- MessageLog.GetInstance.Show("炒锅1---加调料完成");
- break;
- case FryAction.加辅料:
- FirePot_AddAccessories(item,1);
- MessageLog.GetInstance.Show("炒锅1---加辅料完成");
- break;
- case FryAction.炒制菜品:
- FirePot_FryFood(item,1);
- MessageLog.GetInstance.Show("炒锅1---炒制菜品完成");
- break;
-
- default:
- break;
- }
- }
-
- }
- }
-
- private void FirePot2_Process()
- {
-
- }
-
-
- #region 炒锅流程功能
-
- private bool IsRobotNextWork(List<FryPotProcess> currentProcess, int currentFryTime)
- {
- bool res = false;
- if(currentProcess.Count> currentFryTime)
- {
- if (currentProcess[currentFryTime + 1].fryActions == FryAction.加调料 ||
- currentProcess[currentFryTime + 1].fryActions == FryAction.加辅料 ||
- currentProcess[currentFryTime + 1].fryActions == FryAction.炒制菜品)
- {
- res = true;
- }
- }
- return res;
- }
-
- /// <summary>
- /// 冷锅预热
- /// </summary>
- private void FirePot_PotPerHeat(FryPotProcess item,int i)
- {
- bool isRobotWork = false;
- if(i == 1)//炒锅1
- {
- FirePot1_SetFireGear(item.FryGear);
- Thread.Sleep(200);
- FirePot1_StartFire(true);
- isRobotWork = IsRobotNextWork(morkBF.FryPot1_CurrentProcess,item.FryTime);
- }
- else if(i == 2)//炒锅2
- {
- FirePot2_SetFireGear(item.FryGear);
- FirePot2_StartFire(true);
- isRobotWork = IsRobotNextWork(morkBF.FryPot2_CurrentProcess, item.FryTime);
- }
- if (isRobotWork && item.FryDuration > RobotLeadTime) Thread.Sleep((item.FryDuration - RobotLeadTime) * 1000);//提前10秒机器人去取物料
- else Thread.Sleep(item.FryDuration * 1000);
-
-
- }
-
- /// <summary>
- /// 热油
- /// </summary>
- private void FirePot_HeatOil(FryPotProcess item, int i)
- {
- bool isRobotWork = false;
- if (item.FryGear != 0)
- {
- FirePot1_SetFireGear(item.FryGear);//设定加热挡位
- FirePot1_StartFire(true);//开启加热
- isRobotWork = IsRobotNextWork(morkBF.FryPot1_CurrentProcess, item.FryTime);
- }
- if (item.StirGear != 0)
- {
- FirePot1_SetStirGear(item.StirGear);//设定搅拌挡位
- FirePot1_StartFire(true);//开启搅拌
- isRobotWork = IsRobotNextWork(morkBF.FryPot2_CurrentProcess, item.FryTime);
- }
- if (isRobotWork && item.FryDuration > RobotLeadTime) Thread.Sleep((item.FryDuration - RobotLeadTime) * 1000);//提前10秒机器人去取物料
- else Thread.Sleep(item.FryDuration * 1000);//加热时间;
- }
-
- /// <summary>
- /// 加调料
- /// </summary>
- private void FirePot_AddSeasoning(FryPotProcess item,int i)
- {
-
- if(i == 1)
- {
-
- morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot =1,robotActionModel = RobotActionModel.取1号炒锅调料盆倒入1号炒锅});
- Thread.Sleep(item.FryDuration);
-
- }
-
- else if(i == 2)
- {
- morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = RobotActionModel.取2号炒锅调料盆倒入2号炒锅 });
- Thread.Sleep(item.FryDuration);
- }
-
- }
-
- /// <summary>
- /// 加辅料
- /// </summary>
- private void FirePot_AddAccessories(FryPotProcess item, int i)
- {
- if (i == 1)
- {
-
- morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 1, robotActionModel = RobotActionModel.取1号炒锅辅料盆1倒入1号炒锅 });
- Thread.Sleep(item.FryDuration);
-
- }
-
- else if (i == 2)
- {
- morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = RobotActionModel.取2号炒锅辅料盆1倒入2号炒锅 });
- Thread.Sleep(item.FryDuration);
- }
-
- }
-
- /// <summary>
- /// 炒制菜品
- /// </summary>
- private void FirePot_FryFood(FryPotProcess item, int i)
- {
- bool isRobotWork = false;
- if (i == 1)
- {
- morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 1, robotActionModel = (RobotActionModel)item.accessories[0].Loc });
- while (!morkBF.FirePot1_CompleteSingle[item.accessories[0].Loc])//取菜信号是否完成
- {
- Thread.Sleep(100);
- }
- isRobotWork = IsRobotNextWork(morkBF.FryPot2_CurrentProcess, item.FryTime);
-
-
- }
-
- else if (i == 2)
- {
- morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = (RobotActionModel)(item.accessories[0].Loc+19) });//炒制菜品位置
- while (!morkBF.FirePot2_CompleteSingle[item.accessories[0].Loc])//取菜信号是否完成
- {
- Thread.Sleep(100);
- }
- isRobotWork = IsRobotNextWork(morkBF.FryPot2_CurrentProcess, item.FryTime);
-
- }
- if (isRobotWork && item.FryDuration > RobotLeadTime) Thread.Sleep((item.FryDuration - RobotLeadTime) * 1000);//提前10秒机器人去取物料
- else Thread.Sleep(item.FryDuration * 1000);//加热时间;
- }
- #endregion
-
- /// <summary>
- /// 机器人进程
- /// </summary>
- /// <param name="robotAction"></param>
- private void RobotProcess(RobotAction_Pot robotAction)
- {
- Robot_Write("GI0",(int)robotAction.robotActionModel);
- while (morkBF.Robot_ActionCallback != (int)robotAction.robotActionModel)//机器人动作执行完动作反馈
- {
- Thread.Sleep(100);
- }
- if(robotAction.Pot == 1)//炒锅1
- {
- if (robotAction.robotActionModel == RobotActionModel.取1号空盆出餐)
- {
- Robot_Write("GM520", true);//机器人去出餐倒料减速位置
- while(!morkBF.Robot_ArriveFirePot1)//机器人到位,请求1#炒锅倒菜
- {
- Thread.Sleep(100);
- }
- FirePot_StartOutFood(1);//炒锅出餐;
- while (!morkBF.FirePot1_PotOnOutFoodPosition)//炒锅在出餐倒料位置反馈
- {
- Thread.Sleep(1000);
- }
- Thread.Sleep(6 * 1000);//等待6s出餐
- Robot_Write("GM521", true);//机器人出餐到料完成
-
- }
- else
- {
- FirePot_Write("M11.6", true);//炒锅去投料位置
- while (!morkBF.FirePot1_PotOnIntoFoodPosition)//等待炒锅允许倒料
- {
- Thread.Sleep(100);
- }
- Robot_Write("GM531", true);//机器人投料
- }
-
- }
- else if (robotAction.Pot == 2)
- {
- if (robotAction.robotActionModel == RobotActionModel.取1号空盆出餐)
- {
- Robot_Write("GM522", true);//炒锅去出餐倒料减速位置
- while (!morkBF.Robot_ArriveFirePot2)//机器人到位,请求1#炒锅倒菜
- {
- Thread.Sleep(100);
- }
- FirePot_StartOutFood(2);//炒锅去出餐倒料位置
- while (!morkBF.FirePot2_PotOnOutFoodPosition)//炒锅在出餐倒料位置反馈
- {
- Thread.Sleep(1000);
- }
- Thread.Sleep(6 * 1000);//等待20s出餐
- Robot_Write("GM523", true);//机器人出餐倒料完成
-
- }
- else
- {
- FirePot_Write("M16.7", true);
- while (!morkBF.FirePot2_PotOnIntoFoodPosition)
- {
- Thread.Sleep(100);
- }
- Robot_Write("GM531", true);
- }
-
- }
-
- while(!morkBF.Robot_Origin)
- {
- Thread.Sleep(1000);
- }
- morkBF.Robot_IsBusy = false;
- MessageLog.GetInstance.Show($"机器人完成[{robotAction.robotActionModel.ToString()}]任务");
- }
-
- public override void ReadData()
- {
- GetStatus("M20.0",new Action<object>((o)=>
- {
- if (o == null) return;
- if(o is bool[] values&&values.Length == 19)
- {
- morkBF.FirePot1_InitCompleted = values[0];
- morkBF.FirePot1_IsAuto = values[1];
- morkBF.FirePot1_Emergencystop = values[2];
- morkBF.FirePot1_MealTubExist = values[3];
- morkBF.FirePot1_VegetablesTub1Exist = values[4];
- morkBF.FirePot1_VegetablesTub2Exist = values[5];
- morkBF.FirePot1_Seasoning1Exist = values[6];
- morkBF.FirePot1_Seasoning2Exist = values[7];
- morkBF.FirePot1_Accessories1Exist = values[8];
- morkBF.FirePot1_Accessories2Exist = values[9];
- morkBF.FirePot1_OutFoodTubExist = values[10];
- morkBF.FirePot1_OnOrigin = values[11];
- morkBF.FirePot1_FirePosition1 = values[12];
- morkBF.FirePot1_FirePosition2 = values[13];
- morkBF.FirePot1_FirePosition3 = values[14];
- morkBF.FirePot1_FirePosition4 = values[15];
- morkBF.FirePot1_PotOnOutFoodPosition = values[16];
- morkBF.FirePot1_PotOnIntoFoodPosition = values[17];
- morkBF.FirePot1_PotOnCleanPosition = values[18];
-
- }
- }),0);
-
- GetStatus("VW120", new Action<object>((o) =>
- {
- if (o == null) return;
- if (o is int[] values&&values.Length == 2)
- {
- morkBF.FirePot1_Temperature = values[0];
- morkBF.FirePot1_Pulse = values[1];
-
- }
- }), 0);
-
- GetStatus("M25.0", new Action<object>((o) =>
- {
- if (o == null) return;
- if (o is bool[] values&& values.Length == 19)
- {
- morkBF.FirePot2_InitCompleted = values[0];
- morkBF.FirePot2_IsAuto = values[1];
- morkBF.FirePot2_Emergencystop = values[2];
- morkBF.FirePot2_MealTubExist = values[3];
- morkBF.FirePot2_VegetablesTub1Exist = values[4];
- morkBF.FirePot2_VegetablesTub2Exist = values[5];
- morkBF.FirePot2_Seasoning1Exist = values[6];
- morkBF.FirePot2_Seasoning2Exist = values[7];
- morkBF.FirePot2_Accessories1Exist = values[8];
- morkBF.FirePot2_Accessories2Exist = values[9];
- morkBF.FirePot2_OutFoodTubExist = values[10];
- morkBF.FirePot2_OnOrigin = values[11];
- morkBF.FirePot2_FirePosition1 = values[12];
- morkBF.FirePot2_FirePosition2 = values[13];
- morkBF.FirePot2_FirePosition3 = values[14];
- morkBF.FirePot2_FirePosition4 = values[15];
- morkBF.FirePot2_PotOnOutFoodPosition = values[16];
- morkBF.FirePot2_PotOnIntoFoodPosition = values[17];
- morkBF.FirePot2_PotOnCleanPosition = values[18];
-
- }
- }), 0);
-
- GetStatus("VW150", new Action<object>((o) =>
- {
- if (o == null) return;
- if (o is int[] values&& values.Length == 2)
- {
- morkBF.FirePot2_Temperature = values[0];
- morkBF.FirePot2_Pulse = values[1];
-
- }
- }), 0);
- GetStatus("GM500", new Action<object>((o) =>
- {
- if (o == null) return;
- if (o is bool[] values && values.Length == 7)
- {
-
- morkBF.FirePot1_CompleteSingle[0] = values[0];
- morkBF.FirePot1_CompleteSingle[1] = values[1];
- morkBF.FirePot1_CompleteSingle[2] = values[2];
- morkBF.Robot_FirePot1OutSeasoning = values[3];
- morkBF.Robot_FirePot1OutAccessories = values[4];
- morkBF.Robot_ArriveFirePot1 = values[5];
- morkBF.Robot_FirePot1OutFoodComplete = values[6];
-
- }
- }), 1);
- GetStatus("GM510", new Action<object>((o) =>
- {
- if (o == null) return;
- if (o is bool[] values && values.Length == 7)
- {
- morkBF.FirePot2_CompleteSingle[0] = values[0];
- morkBF.FirePot2_CompleteSingle[1] = values[1];
- morkBF.FirePot2_CompleteSingle[2] = values[2];
- morkBF.Robot_FirePot2OutSeasoning = values[3];
- morkBF.Robot_FirePot2OutAccessories = values[4];
- morkBF.Robot_ArriveFirePot2 = values[5];
- morkBF.Robot_FirePot2OutFoodComplete = values[6];
-
- }
- }), 1);
- GetStatus("GI5", new Action<object>((o) =>
- {
- if (o == null) return;
- if (o is int[] values && values.Length == 1)
- {
- morkBF.Robot_ActionCallback = values[0];
- }
- }), 1);
-
- GetStatus("VW2250", new Action<object>((o) =>
- {
- if (o == null) return;
- if (o is int[] values && values.Length == 1)
- {
- dataReport.FirePot1_PotState = values[0];
- }
- }), 1);
- GetStatus("VW2350", new Action<object>((o) =>
- {
- if (o == null) return;
- if (o is int[] values && values.Length == 1)
- {
- dataReport.FirePot2_PotState = values[0];
- }
- }), 1);
-
- }
-
- public override void ResetProgram()
- {
- morkBF = null;
- morkBF = new GVL_MorkBF();
- }
-
- public override void SimOrder()
- {
-
- }
-
- public override void Stop()
- {
-
- }
-
- /// <summary>
- /// 获取炒锅PLC的所有状态
- /// </summary>
- /// <param name="key"></param>
- /// <param name="action"></param>
- /// <param name="num">炒锅编号</param>
- private void GetStatus(string key, Action<object> action, int num)
- {
- if (dicPort2peripheralStatus.ContainsKey(num))
- {
- if (dicPort2peripheralStatus[num].ContainsKey(key))
- {
- action((object)dicPort2peripheralStatus[num][key]);//获取PLC指定地址的状态值
- }
- }
- }
-
- #region 控制
- private void FirePot_Write(string address, object value, int i = 0)
- {
- WriteControlExact(address, value, i);
- }
- private void Robot_Write(string address, object value, int i = 1)
- {
- WriteControlExact(address, value, i);
- }
- #region 炒锅1
-
- /// <summary>
- /// 炒锅1设定加热挡位
- /// </summary>
- /// <param name="o"></param>
- private void FirePot1_SetFireGear(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString(), out int value))
- {
- FirePot_Write("VW100", (ushort)value);
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 炒锅1加热启停
- /// </summary>
- /// <param name="b"></param>
- private void FirePot1_StartFire(object o)
- {
- if (o == null) return;
- if (bool.TryParse(o.ToString(), out bool value))
- {
- FirePot_Write("M10.0", value);
- }
- Thread.Sleep(200);
- FirePot_Write("M10.2", true);
- }
- /// <summary>
- /// 炒锅1设置搅拌挡位
- /// </summary>
- /// <param name="o"></param>
- private void FirePot1_SetStirGear(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString(), out int value))
- {
- FirePot_Write("VW102", (ushort)value);
- }
- Thread.Sleep(200);
- FirePot_Write("M10.3", true);
- }
- /// <summary>
- /// 炒锅1搅拌启停
- /// </summary>
- /// <param name="o"></param>
- private void FirePot1_StartStir(object o)
- {
- if (o == null) return;
- if (bool.TryParse(o.ToString(), out bool value))
- {
- FirePot_Write("M10.1", value);
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 设置炒锅1翻转速度
- /// </summary>
- /// <param name="o"></param>
- private void FirePot1_SetTurnSpeed(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString(), out int value))
- {
- FirePot_Write("VW104", (ushort)value);
- }
- Thread.Sleep(200);
- FirePot_Write("M10.4", true);
- Thread.Sleep(200);
- }
- #endregion
-
- #region 炒锅2
- /// <summary>
- /// 炒锅2设定加热挡位
- /// </summary>
- /// <param name="o"></param>
- private void FirePot2_SetFireGear(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString(), out int value))
- {
- FirePot_Write("VW130", (ushort)value);
- }
- Thread.Sleep(200);
- FirePot_Write("M15.2", true);
- }
- /// <summary>
- /// 炒锅2加热启停
- /// </summary>
- /// <param name="b"></param>
- private void FirePot2_StartFire(object o)
- {
- if (o == null) return;
- if (o is bool value)
- {
- FirePot_Write("M15.0", value);
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 炒锅2设置搅拌挡位
- /// </summary>
- /// <param name="o"></param>
- private void FirePot2_SetStirGear(object o)
- {
- if (o == null) return;
- if (o is int value)
- {
- FirePot_Write("VW132", (ushort)value);
- }
- Thread.Sleep(200);
- FirePot_Write("M15.3", true);
- Thread.Sleep(200);
- }
- /// <summary>
- /// 炒锅2搅拌启停
- /// </summary>
- /// <param name="o"></param>
- private void FirePot2_StartStir(object o)
- {
- if (o == null) return;
- if (o is bool value)
- {
- FirePot_Write("M15.1", value);
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 设置炒锅2翻转速度
- /// </summary>
- /// <param name="o"></param>
- private void FirePot2_SetTurnSpeed(object o)
- {
- if (o == null) return;
- if (o is int value)
- {
- FirePot_Write("VW134", (ushort)value);
- }
- Thread.Sleep(200);
- FirePot_Write("M15.4", true);
- Thread.Sleep(200);
- }
-
- #endregion
-
- #region 炒锅通用
- /// <summary>
- /// 炒锅复位
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_Reset(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString(), out int i))
- {
- if (i == 1)
- {
-
- }
- else if (i == 2)
- {
-
- }
- }
-
-
- }
- /// <summary>
- /// 炒锅回原点
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_PotGotoOrigin(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString(), out int i))
- {
- if (i == 1)
- {
- FirePot_Write("M10.5", true);
- }
- else if (i == 2)
- {
- FirePot_Write("M15.5", true);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 炒锅去位置1
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_PotGotoP1(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString(), out int i))
- {
- if (i == 1)
- {
- FirePot_Write("M11.2", true);
- }
- else if (i == 2)
- {
- FirePot_Write("M16.2", true);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 炒锅去位置2
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_PotGotoP2(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString(), out int i))
- {
- if (i == 1)
- {
- FirePot_Write("M11.3", true);
- }
- else if (i == 2)
- {
- FirePot_Write("M16.3", true);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 炒锅去位置3
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_PotGotoP3(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString(), out int i))
- {
- if (i == 1)
- {
- FirePot_Write("M11.4", true);
- }
- else if (i == 2)
- {
- FirePot_Write("M16.4", true);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 炒锅去位置4
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_PotGotoP4(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString(), out int i))
- {
- if (i == 1)
- {
- FirePot_Write("M11.5", true);
- }
- else if (i == 2)
- {
- FirePot_Write("M16.5", true);
- }
- }
- Thread.Sleep(200);
- }
- ///// <summary>
- ///// 炒锅去出餐位置
- ///// </summary>
- ///// <param name="o"></param>
- //private void FirePot_PotGotoOutFoodPositiong(object o)
- //{
- // if (o == null) return;
- // if (o is int i)
- // {
- // if (i == 1)
- // {
- // FirePot_Write("M11.6", true);
- // }
- // else if (i == 2)
- // {
- // FirePot_Write("M16.6", true);
- // }
- // }
- // Thread.Sleep(200);
- //}
- /// <summary>
- /// 炒锅去投料位置
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_PotGotoInFoodPosition(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString() ,out int i))
- {
- if (i == 1)
- {
- FirePot_Write("M11.6", true);
- }
- else if (i == 2)
- {
- FirePot_Write("M16.6", true);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 出餐启动
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_StartOutFood(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString(), out int i))
- {
- if (i == 1)
- {
- FirePot_Write("M10.6", true);
- }
- else if (i == 2)
- {
- FirePot_Write("M15.6", true);
- }
-
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 清洗
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_Clean(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString(), out int i))
- {
- if (i == 1)
- {
- if(morkBF.FirePot1_OnOrigin) FirePot_Write("M10.7", true);
-
- }
- else if (i == 2)
- {
- if (morkBF.FirePot2_OnOrigin) FirePot_Write("M15.7", true);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 抽水启动
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_StartPumpWater(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString(), out int i))
- {
- if (i == 1)
- {
- FirePot_Write("M11.0", true);
- }
- else if (i == 2)
- {
- FirePot_Write("M16.0", true);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 抽油启动
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_StartPumpOil(object o)
- {
- if (o == null) return;
- if (int.TryParse(o.ToString(), out int i))
- {
- if (i == 1)
- {
- FirePot_Write("M16.0", true);
- }
- else if (i == 2)
- {
- FirePot_Write("M16.1", true);
- }
- }
- Thread.Sleep(200);
- }
- #endregion
-
- #region 机器人
- /// <summary>
- /// 机器人启动
- /// </summary>
- private void RobotStart()
- {
- Robot_Write("GM600",true);
- Thread.Sleep(200);
- }
- /// <summary>
- /// 机器人停止
- /// </summary>
- private void RobotStop()
- {
- Robot_Write("GM601", true);
- Thread.Sleep(200);
- }
- /// <summary>
- /// 机器人复位
- /// </summary>
- private void RobotReset()
- {
- Robot_Write("GM602", true);
- Thread.Sleep(200);
- }
- /// <summary>
- /// 机器人程序重启
- /// </summary>
- private void RobotProgramStart()
- {
- Robot_Write("GM603", true);
- Thread.Sleep(200);
- }
- /// <summary>
- /// 1号炒锅允许机器人投料(炒锅在投料位给出)
- /// </summary>
- private void Robot_Pot1AllowInMaterail()
- {
- Robot_Write("GM531", true);
- Thread.Sleep(200);
- }
- /// <summary>
- /// 1号炒锅出餐倒料到减速位
- /// </summary>
- private void Robot_Pot1OutFoodInSlowDown()
- {
- Robot_Write("GM620", true);
- Thread.Sleep(200);
- }
- /// <summary>
- /// 1号炒锅出餐倒料完成
- /// </summary>
- private void Robot_Pot1OutFood()
- {
- Robot_Write("GM521", true);
- Thread.Sleep(200);
- }
- /// <summary>
- /// 2号炒锅允许机器人投料(炒锅在投料位给出)
- /// </summary>
- private void Robot_Pot2AllowInMaterail()
- {
- Robot_Write("GM530", true);
- Thread.Sleep(200);
- }
- /// <summary>
- /// 2号炒锅出餐倒料到减速位。开始倒菜
- /// </summary>
- private void Robot_Pot2OutFoodInSlowDown()
- {
- Robot_Write("GM522", true);
- Thread.Sleep(200);
- }
- /// <summary>
- /// 2号炒锅出餐倒料完成
- /// </summary>
- private void Robot_Pot2OutFood()
- {
- Robot_Write("GM523", true);
- Thread.Sleep(200);
- }
- /// <summary>
- ///
- /// </summary>
- private void RobotActionStart(object o)
- {
- if (o == null) return;
- if(int.TryParse(o.ToString(), out int value))
- {
- Robot_Write("GI0",value);
- }
- Thread.Sleep(200);
- }
- #endregion
-
-
-
- #endregion
-
-
- private void ScreenDataServer()
- {
- LocalMqtt.GetInstance.Init(ScreenDeviceType.大炒);
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- List<StatsModel> statsModels = new List<StatsModel>();
- statsModels.Add(new StatsModel() { Name = "帝王蟹", Count = 666 });
- ScreenModelMaxWok maxWok = new ScreenModelMaxWok
- {
- IsRun = IsHealth ? IsRun.运行 : IsRun.停止,
- WorkStatus_1 = morkBF.FirePot1_Temperature > 0 ? WorkStatus.工作 : WorkStatus.待机,
- WorkStatus_2 = morkBF.FirePot2_Temperature > 0 ? WorkStatus.工作 : WorkStatus.待机,
- RobotStatu = morkBF.Robot_ActionCallback == 0? WorkStatus.待机 : WorkStatus.工作,
- Alarm = new List<AlarmModel>(),
- FailuresCount = 0,
- StatsCount = statsModels,
- MaxWok_Dishes_1 = "满汉全席",
- MaxWok_Dishes_2 = "海鲜大餐",
- MaxWok_Task_1 = ((PotState)dataReport.FirePot1_PotState).ToString(),
- MaxWok_Task_2 = ((PotState)dataReport.FirePot2_PotState).ToString(),
- MaxWok_Process_1 = SetFirePotPorcess(new Random().Next(0,11)),
- MaxWok_Process_2 = SetFirePotPorcess(new Random().Next(0, 11)),
- MaxWok_HeatGear_1 = morkBF.FirePot1_FireGear.ToString(),
- MaxWok_HeatGear_2 = morkBF.FirePot2_FireGear.ToString(),
- MaxWok_StirGear_1 = morkBF.FirePot1_StirGear.ToString(),
- MaxWok_StirGear_2 = morkBF.FirePot2_StirGear.ToString(),
- MaxWok_FlipSpeed_1 = morkBF.FirePot1_FlipSpeed.ToString(),
- MaxWok_FlipSpeed_2 = morkBF.FirePot2_FlipSpeed.ToString(),
- MaxWok_Temp_1 = new Random().Next(250, 450).ToString(),
- MaxWok_Temp_2 = new Random().Next(250, 450).ToString(),
- MaxWok_OrderCount_1 = 2,
- MaxWok_OrderCount_2 = 2,
- MaxWok_ErrorOrderCount_1 = 0,
- MaxWok_ErrorOrderCount_2 = 0,
-
- };
- LocalMqtt.GetInstance.Publish(maxWok);
- Thread.Sleep(1000);
-
- }), "大屏数据上报");
-
- }
-
- private List<ProcessModel> SetFirePotPorcess(int potState)
- {
-
- if (potState > 0)
- {
- if(potState <=3)
- {
- SetState(2);
- }
- else if(potState>3&&potState < 9) SetState(3);
- else if(potState == 9) SetState(4);
- else if (potState == 10) SetState(5);
- }
- else
- {
- foreach(var item in dataReport.processModels)
- {
- item.Status = ProcessStatus.未执行;
- }
- }
- return dataReport.processModels;
-
-
- }
-
- public void SetState(int c )
- {
- for (int i = 0; i < dataReport.processModels.Count; i++)
- {
- if (i == c)
- {
- dataReport.processModels[i].Status = ProcessStatus.正在执行;
- }
- else if( i<c) dataReport.processModels[i].Status = ProcessStatus.执行完成;
- else if (i > c ) dataReport.processModels[i].Status = ProcessStatus.未执行;
- }
- }
- }
- }
|