|
- 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 BPASmartClient.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(() =>
- //{
- // FoodMenuViewModel.GetInstance().FoodMenus.Clear();
- // if(BPASmartClient.Helper.Json<LocalFryPotMessage>.Data.FryPotMessage.Count>0)
- // {
- // foreach (var item in BPASmartClient.Helper.Json<LocalFryPotMessage>.Data.FryPotMessage)
- // {
- // FoodMenuViewModel.GetInstance().FoodMenus.Add(new FoodMenuModel { GoodKey = item.GoodKey, GoodName = item.GoodName });
- // }
- // }
-
- //}), "更新菜单");
- CommandRegist();//调试
- ServerInit();
- DataParse();//数据解析
- ScreenDataServer();//大屏数据上报
- ActionManage.GetInstance.Send("更新菜单");
- //ThreadManage.GetInstance().Start(FirePot1_Process, "炒锅1流程");
- 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 炒锅
- ActionManage.GetInstance.Register(FirePot_SetFireGear, "FirePot_SetFireGear");//炒锅设定加热挡位
- ActionManage.GetInstance.Register(FirePot_StartFire, "FirePot_StartFire");//炒锅加热启动
- ActionManage.GetInstance.Register(FirePot_StartFire, "FirePot_StopFire");//炒锅关闭加热
- ActionManage.GetInstance.Register(FirePot_SetStirGear, "FirePot_SetStirGear");//炒锅设定搅拌挡位
- ActionManage.GetInstance.Register(FirePot_StartStir, "FirePot_StartStir");//炒锅搅拌启动
- ActionManage.GetInstance.Register(FirePot_StartStir, "FirePot_StopStir");//炒锅搅拌停止
- ActionManage.GetInstance.Register(FirePot_SetTurnSpeed, "FirePot_SetTurnSpeed");//炒锅翻转频率设定
- ActionManage.GetInstance.Register(FirePot_SetPotAngle, "FirePot_SetPotAngle");//设定炒锅角度
- ActionManage.GetInstance.Register(FirePot_StartPassWay, "FirePot_StartPassWay");//炒锅翻转频率设定
-
- ActionManage.GetInstance.Register(FirePot_Reset, "FirePot_Reset");//复位;
- ActionManage.GetInstance.Register(FirePot_PotGotoOrigin, "FirePot_PotGotoOrigin");//炒锅回原点
- 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_StartPumpWater, "FirePot_StopPumpWater");//抽水关闭
- ActionManage.GetInstance.Register(FirePot_PushReach, "FirePot_PushReach");//推杆伸出
- ActionManage.GetInstance.Register(FirePot_PushRetract, "FirePot_PushRetract");//推杆缩回
- ActionManage.GetInstance.Register(FirePot_PotForward, "FirePot_PotForward");//翻转正转
- ActionManage.GetInstance.Register(FirePot_PotReversal, "FirePot_PotReversal");//翻转反转
- #endregion
- #region 机器人
-
- ActionManage.GetInstance.Register(RobotAction, "RobotAction");//上使能
-
-
- #endregion
-
- }
-
- public override void MainTask()
- {
-
- if(morkBF.RobotActinQueue.Count>0&&! morkBF.Robot_Start)//机器人启动
- {
- if( morkBF.RobotActinQueue.TryDequeue(out RobotAction_Pot robotAction))
- {
- morkBF.Robot_IsBusy =true;
- RobotProcess(robotAction);
- }
- }
- }
-
- private void FirePot1_Process()
- {
- if (morkBF.FirePan1_Order.Count > 0 && morkBF.FirePot1_InitCompleted && morkBF.FirePot2_IsAuto && !morkBF.FirePan1_Busy)
- {
- 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_RobotGetSeasoning(item, 1);
- MessageLog.GetInstance.Show("炒锅1---机器人加调料完成");
- break;
- case FryAction.通道出调料:
- FirePot_PasswayOutSeasoning(item, 1);
- MessageLog.GetInstance.Show("炒锅1---通道出调料完成");
- break;
- case FryAction.炒制菜品:
- FirePot_FryFood(item, 1);
- MessageLog.GetInstance.Show("炒锅1---炒制菜品完成");
- break;
- default:
- break;
- }
- }
- FirePot_StartFire(new object[] { 1, false });//关火
- Thread.Sleep(result.FryOffStirTime*1000);//关火翻炒时间
- FirePot_StartStir(new object[] { 1, false });//关闭搅拌
- Message.MessageLog.GetInstance.Show($"炒锅1炒制{result.GoodName}完成");
-
- }
- }
- }
-
- private void FirePot2_Process()
- {
-
- }
-
-
- #region 炒锅流程功能
-
- /// <summary>
- /// 判断下个动作是否需要机器人
- /// </summary>
- /// <param name="i"></param>
- /// <param name="currentFryTime"></param>
- /// <returns></returns>
- private bool IsRobotNextWork(int i, int currentFryTime)
- {
- bool res = false;
- List<FryPotProcess> currentProcess = new List<FryPotProcess>();
- currentProcess = i == 1 ? morkBF.FryPot1_CurrentProcess: morkBF.FryPot2_CurrentProcess;
-
- if (currentProcess.Count> currentFryTime)
- {
- if (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;
-
- FirePot_SetFireGear(new object[]{ i, item.FryGear});//设定加热挡位
- FirePot_StartFire(new object[] { i, true });
- isRobotWork = IsRobotNextWork(i,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)
- {
- FirePot_SetFireGear(new object[] { i, item.FryGear });//设定加热挡位
- FirePot_StartFire(new object[] { i, true });
- }
- if (item.StirGear != 0)
- {
- FirePot_SetStirGear(new object[] { i, item.StirGear });//设定搅拌挡位
- FirePot_StartStir(new object[] { i, true });
-
- }
- isRobotWork = IsRobotNextWork(i, 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_PasswayOutSeasoning(FryPotProcess item,int i)
- {
- foreach(var acc in item.accessories)
- {
- FirePot_StartPassWay(new object[] { i, acc.Loc, acc.Qry });
- }
- }
-
- /// <summary>
- /// 机器人取调料
- /// </summary>
- private void FirePot_RobotGetSeasoning(FryPotProcess item, int i)
- {
-
- morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot
- {
- Pot = i,
- MainTask = BPASmartClient.Model.大炒.MainTask.机器人炒制任务,
- subTask1 = (SubTask1)item.accessories[0].Loc + 9,
- subTask2 = (SubTask2)i
- });
- }
-
-
-
- /// <summary>
- /// 炒制菜品
- /// </summary>
- private void FirePot_FryFood(FryPotProcess item, int i)
- {
- bool isRobotWork = false;
- morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot
- {
- Pot = i,
- MainTask = BPASmartClient.Model.大炒.MainTask.机器人炒制任务,
- subTask1 = (SubTask1)item.accessories[1].Loc,
- subTask2 =(SubTask2)i
- });
- while (!morkBF.FirePot1_CompleteSingle[item.accessories[0].Loc])//取菜信号是否完成
- {
- Thread.Sleep(100);
- }
- isRobotWork = IsRobotNextWork(i, 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.MainTask);//设定机器人主要任务
- while(morkBF.Robot_GI0ActionCallback != (int)robotAction.MainTask)//等待主程序完成反馈
- {
- Thread.Sleep(300);
- }
- if((int)robotAction.subTask1>0&& (int)robotAction.subTask1<16)//任务1
- {
- Robot_Write("GI1", (int)robotAction.subTask1);
- Thread.Sleep(1000);
- while (morkBF.Robot_GI1ActionCallback != (int)robotAction.subTask1)//等待子程序1完成反馈
- {
- Thread.Sleep(300);
- }
- }
- if((int)robotAction.subTask1>15) //出餐
- {
-
- }
-
- if ((int)robotAction.subTask2 > 0)//任务2
- {
- Robot_Write("GI2", (int)robotAction.subTask2);
- Thread.Sleep(1000);
- while (morkBF.Robot_GI2ActionCallback != (int)robotAction.subTask2)//等待子程序2完成反馈
- {
- Thread.Sleep(300);
- }
- while (morkBF.Robot_OutMaterialCompleted)//等待子程序2完成反馈
- {
- Thread.Sleep(300);
- }
- }
- if ((int)robotAction.subTask3 > 0)//任务3
- {
- Robot_Write("GI3", (int)robotAction.subTask3);
- Thread.Sleep(1000);
- while (morkBF.Robot_GI3ActionCallback != (int)robotAction.subTask3)//等待子程序3完成反馈
- {
- Thread.Sleep(300);
- }
- }
- if ((int)robotAction.subTask4 > 0)//任务4
- {
- Robot_Write("GI4", (int)robotAction.subTask4);
- Thread.Sleep(1000);
- while (morkBF.Robot_GI4ActionCallback != (int)robotAction.subTask4)//等待主程序4完成反馈
- {
- Thread.Sleep(300);
- }
- }
-
-
- MessageLog.GetInstance.Show($"机器人完成[{robotAction.MainTask.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("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 FirePot1_Write(string address, object value, int i = 0)
- {
- WriteControlExact(address, value, i);
- }
- private void FirePot2_Write(string address, object value, int i = 1)
- {
- WriteControlExact(address, value, i);
- }
- private void Robot_Write(string address, object value, int i = 2)
- {
- WriteControlExact(address, value, i);
- }
-
- #region 炒锅
-
- /// <summary>
- /// 炒锅设定加热挡位
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_SetFireGear(object[] o)
- {
- if (o == null) return;
- if (o.Length == 2 && o[0] is int fryNo && o[1] is int value)
- {
- if(fryNo == 1)
- {
- FirePot1_Write("VW100", (ushort)value);
- }
- else if(fryNo == 2)
- {
- FirePot2_Write("VW100", (ushort)value);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 炒锅1加热启停
- /// </summary>
- /// <param name="b"></param>
- private void FirePot_StartFire(object[] o)
- {
- if (o == null) return;
- if (o.Length == 2 && o[0] is int fryNo && o[1] is bool value)
- {
- if (fryNo == 1)
- {
- FirePot1_Write("M10.0", value);
- }
- else if (fryNo == 2)
- {
- FirePot2_Write("M10.0", value);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 炒锅1设置搅拌挡位
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_SetStirGear(object[] o)
- {
- if (o == null) return;
- if (o.Length == 2 && o[0] is int fryNo && o[1] is int value)
- {
- if (fryNo == 1)
- {
- FirePot1_Write("VW102", (ushort)value);
- }
- else if (fryNo == 2)
- {
- FirePot2_Write("VW102", (ushort)value);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 炒锅1搅拌启停
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_StartStir(object[] o)
- {
- if (o == null) return;
- if (o.Length == 2 && o[0] is int fryNo && o[1] is bool value)
- {
- if (fryNo == 1)
- {
- FirePot1_Write("M10.1", value);
- }
- else if (fryNo == 2)
- {
- FirePot2_Write("M10.1", value);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 设置炒锅1翻转速度
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_SetTurnSpeed(object[] o)
- {
- if (o == null) return;
- if (o.Length == 2 && o[0] is int fryNo && o[1] is int value)
- {
- if (fryNo == 1)
- {
- FirePot1_Write("VW104", (ushort)value);
- }
- else if (fryNo == 2)
- {
- FirePot2_Write("VW104", (ushort)value);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 设定炒锅角度
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_SetPotAngle(object[] o)
- {
- if (o == null) return;
- if (o.Length == 2 && o[0] is int fryNo && o[1] is int value)
- {
- if (fryNo == 1)
- {
- FirePot1_Write("VW106", (ushort)value);
- }
- else if (fryNo == 2)
- {
- FirePot2_Write("VW106", (ushort)value);
- }
- }
- Thread.Sleep(200);
- }
-
- /// <summary>
- /// 通道出料启动
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_StartPassWay(object[] o)
- {
- if (o == null) return;
- if (o.Length == 3 && o[0] is int fryNo && o[1] is int value1&& o[2] is int value2)
- {
- if (fryNo == 1)
- {
- FirePot1_Write(morkBF.Fire_PasswayValue[value1], (ushort)value2);//写入需求值
- Thread.Sleep(200);
- FirePot1_Write(morkBF.Fire_PasswayWrite[value1], true);//启动通道哦
- }
- else if (fryNo == 2)
- {
- FirePot2_Write(morkBF.Fire_PasswayValue[value1], (ushort)value2);
- Thread.Sleep(200);
- FirePot2_Write(morkBF.Fire_PasswayWrite[value1], true);
- }
- }
- Thread.Sleep(200);
- }
-
-
-
- /// <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 (o is int i)
- {
- if (i == 1)
- {
- FirePot1_Write("M10.5", true);
- }
- else if (i == 2)
- {
- FirePot2_Write("M10.5", true);
- }
- }
- Thread.Sleep(200);
- }
-
- /// <summary>
- /// 炒锅去投料位置
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_PotGotoInFoodPosition(object o)
- {
- if (o == null) return;
- if (o is int i)
- {
- if (i == 1)
- {
- FirePot1_Write("M11.2", true);
- }
- else if (i == 2)
- {
- FirePot2_Write("M11.2", true);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 出餐启动
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_StartOutFood(object o)
- {
- if (o == null) return;
- if (o is int i)
- {
- if (i == 1)
- {
- FirePot1_Write("M10.6", true);
- }
- else if (i == 2)
- {
- FirePot2_Write("M10.6", true);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 清洗
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_Clean(object o)
- {
- if (o == null) return;
- if (o is int i)
- {
- if (i == 1)
- {
- FirePot1_Write("M10.7", true);
-
- }
- else if (i == 2)
- {
- FirePot2_Write("M10.7", true);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 抽水启动
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_StartPumpWater(object[] o)
- {
- if (o == null) return;
- if (o.Length == 2 && o[0] is int fryNo && o[1] is int value)
- {
- if (fryNo == 1)
- {
- FirePot1_Write("M11.0", value);
- }
- else if (fryNo == 2)
- {
- FirePot2_Write("M11.0", value);
- }
- }
- Thread.Sleep(200);
- }
-
- /// <summary>
- /// 推杆伸出
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_PushReach(object o)
- {
- if (o == null) return;
- if (o is int i)
- {
- if (i == 1)
- {
- FirePot1_Write("M12.3", true);
-
- }
- else if (i == 2)
- {
- FirePot2_Write("M12.3", true);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 推杆缩回
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_PushRetract(object o)
- {
- if (o == null) return;
- if (o is int i)
- {
- if (i == 1)
- {
- FirePot1_Write("M12.4", true);
-
- }
- else if (i == 2)
- {
- FirePot2_Write("M12.4", true);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 翻转正转
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_PotForward(object o)
- {
- if (o == null) return;
- if (o is int i)
- {
- if (i == 1)
- {
- FirePot1_Write("M12.5", true);
-
- }
- else if (i == 2)
- {
- FirePot2_Write("M12.5", true);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 翻转正转
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_PotReversal(object o)
- {
- if (o == null) return;
- if (o is int i)
- {
- if (i == 1)
- {
- FirePot1_Write("M12.6", true);
-
- }
- else if (i == 2)
- {
- FirePot2_Write("M12.6", true);
- }
- }
- Thread.Sleep(200);
- }
-
-
- #endregion
-
- #region 机器人
- private void RobotAction(object[] o)
- {
- if (o[0] is int value)
- {
- switch (value)
- {
- case 0:
- Robot_Write("GI0", (ushort)(MainTask)o[1]);
- break;
- case 1:
- Robot_Write("GI1", (ushort)(SubTask1)o[1]);
- break;
- case 2:
- Robot_Write("GI2", (ushort)(SubTask2)o[1]);
- break;
- case 3:
- Robot_Write("GI3", (ushort)(SubTask3)o[1]);
- break;
- case 4:
- Robot_Write("GI4", (ushort)(SubTask4)o[1]);
- break;
- default:
- break;
- }
- }
- }
-
- #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 = WorkStatus.工作,
- Alarm = new List<BPA.Message.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.未执行;
- }
- }
- }
- }
|