|
- 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(() =>
- {
- //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("更新菜单");
- ThreadManage.GetInstance().Start(FirePot1_Process, "炒锅1流程");
- ThreadManage.GetInstance().Start(FirePot2_Process, "炒锅2流程");
- 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");//炒锅设定加热挡位1-5
- ActionManage.GetInstance.Register(FirePot_SetStirGear, "FirePot_SetStirGear");//炒锅设定搅拌挡位1-5
- ActionManage.GetInstance.Register(FirePot_SetTurnSpeed, "FirePot_SetTurnSpeed");//炒锅翻转速度0-800
- ActionManage.GetInstance.Register(FirePot_SetPotAngle, "FirePot_SetPotAngle");//设定炒锅角度挡位1-4
- ActionManage.GetInstance.Register(FirePot_StartPassWay, "FirePot_StartPassWay");//通道出料需求值+启动
-
- ActionManage.GetInstance.Register(FirePot_StartFire, "FirePot_StartFire");//炒锅加热启动
- ActionManage.GetInstance.Register(FirePot_StartFire, "FirePot_StopFire");//炒锅关闭加热
- ActionManage.GetInstance.Register(FirePot_StartStir, "FirePot_StartStir");//炒锅搅拌启动
- ActionManage.GetInstance.Register(FirePot_StartStir, "FirePot_StopStir");//炒锅搅拌停止
-
- ActionManage.GetInstance.Register(FirePot_PotGotoOrigin, "FirePot_PotGotoOrigin");//炒锅回原点
- ActionManage.GetInstance.Register(FirePot_StartOutFood, "FirePot_StartOutFood");//出餐启动
- ActionManage.GetInstance.Register(FirePot_Clean, "FirePot_Clean");//清洗
-
- ActionManage.GetInstance.Register(FirePot_Reset, "FirePot_Reset");//复位;
- ActionManage.GetInstance.Register(FirePot_StartPumpWater, "FirePot_StartPumpWater");//抽水启动
- ActionManage.GetInstance.Register(FirePot_StartPumpWater, "FirePot_StopPumpWater");//抽水关闭
- ActionManage.GetInstance.Register(FirePot_PotGotoInFoodPosition, "FirePot_PotGotoInFoodPosition");//炒锅去投料位置
-
- 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.FryPan1_InitComplete && morkBF.FryPan1_ManualOrAutoMode && !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()
- {
- if (morkBF.FirePan2_Order.Count > 0 && morkBF.FryPan2_InitComplete && morkBF.FryPan2_ManualOrAutoMode && !morkBF.FirePan2_Busy)
- {
- if (morkBF.FirePan2_Order.TryDequeue(out FryPotMessages result))
- {
- morkBF.FirePan2_Busy = true;
- morkBF.FryPot2_CurrentProcess = result.fryPotProcesses;
- foreach (var item in result.fryPotProcesses)
- {
- switch (item.fryActions)
- {
- case FryAction.冷锅加热:
- FirePot_PotPerHeat(item, 2);
- MessageLog.GetInstance.Show("炒锅2---冷锅加热完成");
- break;
- case FryAction.热油:
- FirePot_HeatOil(item, 2);
- MessageLog.GetInstance.Show("炒锅2---热油完成");
- break;
- case FryAction.机器人加调料:
- FirePot_RobotGetSeasoning(item, 2);
- MessageLog.GetInstance.Show("炒锅2---机器人加调料完成");
- break;
- case FryAction.通道出调料:
- FirePot_PasswayOutSeasoning(item, 2);
- MessageLog.GetInstance.Show("炒锅2---通道出调料完成");
- break;
- case FryAction.炒制菜品:
- FirePot_FryFood(item, 2);
- MessageLog.GetInstance.Show("炒锅2---炒制菜品完成");
- 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}完成");
-
- }
- }
- }
-
-
- #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()}]任务");
- }
-
- /// <summary>
- /// PLC——>上位机(PLC反馈的数据)
- /// </summary>
- public override void ReadData()
- {
- GetStatus("M40.0",new Action<object>((o)=>
- {
- if (o == null) return;
- if(o is bool[] values&&values.Length == 18)
- {
- morkBF.FryPan1_InitComplete = values[0];
- morkBF.FryPan1_ManualOrAutoMode = values[1];
- morkBF.FryPan1_EStop = values[2];
- morkBF.FryPan1_InPosition1 = values[3];
- morkBF.FryPan1_InPosition2 = values[4];
- morkBF.FryPan1_InPosition3 = values[5];
- morkBF.FryPan1_InPosition4 = values[6];
- morkBF.FryPan1_InPositionUnload = values[7];
- morkBF.FryPan1_InPositionload = values[8];
- morkBF.FryPan1_InPositionWashPot = values[9];
- morkBF.FryPan1_UnloadFinishCH1 = values[10];
- morkBF.FryPan1_UnloadFinishCH2 = values[11];
- morkBF.FryPan1_UnloadFinishCH3 = values[12];
- morkBF.FryPan1_UnloadFinishCH4 = values[13];
- morkBF.FryPan1_UnloadFinishCH5 = values[14];
- morkBF.FryPan1_UnloadFinishCH6 = values[15];
- morkBF.FryPan1_UnloadFinishCH7 = values[16];
- morkBF.FryPan1_UnloadFinishCH8 = values[17];
- }
- }),0);
-
- GetStatus("VW200", new Action<object>((o) =>
- {
- if (o == null) return;
- if (o is short[] values&&values.Length == 4)
- {
- morkBF.FryPan1_TemperatureNow = values[0];
- morkBF.FryPan1_MixingSpeedNow = values[1];
- morkBF.FryPan1_FryAngle = values[2];
- morkBF.FryPan1_HeatingGearNow = values[3];
- }
- }), 0);
- GetStatus("M40.0", new Action<object>((o) =>
- {
- if (o == null) return;
- if (o is bool[] values && values.Length == 18)
- {
- morkBF.FryPan2_InitComplete = values[0];
- morkBF.FryPan2_ManualOrAutoMode = values[1];
- morkBF.FryPan2_EStop = values[2];
- morkBF.FryPan2_InPosition1 = values[3];
- morkBF.FryPan2_InPosition2 = values[4];
- morkBF.FryPan2_InPosition3 = values[5];
- morkBF.FryPan2_InPosition4 = values[6];
- morkBF.FryPan2_InPositionUnload = values[7];
- morkBF.FryPan2_InPositionload = values[8];
- morkBF.FryPan2_InPositionWashPot = values[9];
- morkBF.FryPan2_UnloadFinishCH1 = values[10];
- morkBF.FryPan2_UnloadFinishCH2 = values[11];
- morkBF.FryPan2_UnloadFinishCH3 = values[12];
- morkBF.FryPan2_UnloadFinishCH4 = values[13];
- morkBF.FryPan2_UnloadFinishCH5 = values[14];
- morkBF.FryPan2_UnloadFinishCH6 = values[15];
- morkBF.FryPan2_UnloadFinishCH7 = values[16];
- morkBF.FryPan2_UnloadFinishCH8 = values[17];
- }
- }), 1);
-
- GetStatus("VW200", new Action<object>((o) =>
- {
- if (o == null) return;
- if (o is short[] values && values.Length == 4)
- {
- morkBF.FryPan2_TemperatureNow = values[0];
- morkBF.FryPan2_MixingSpeedNow = values[1];
- morkBF.FryPan2_FryAngle = values[2];
- morkBF.FryPan2_HeatingGearNow = values[3];
- }
- }), 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="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>
- /// 设置炒锅翻转速度
- /// </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>
- /// 炒锅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>
- /// 炒锅搅拌启停
- /// </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>
- /// 炒锅复位
- /// </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_SetFireGearLock(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("M10.2", value);
- }
- else if (fryNo == 2)
- {
- FirePot2_Write("M10.2", value);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 炒锅1设置搅拌挡位锁定
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_SetStirGearLock(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("M10.3", value);
- }
- else if (fryNo == 2)
- {
- FirePot1_Write("M10.3", value);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 设置炒锅翻转速度锁定
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_SetTurnSpeedLock(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("M10.4", value);
- }
- else if (fryNo == 2)
- {
- FirePot1_Write("M10.4", value);
- }
- }
- Thread.Sleep(200);
- }
- /// <summary>
- /// 设定炒锅角度值锁定
- /// </summary>
- /// <param name="o"></param>
- private void FirePot_SetPotAngleLock(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.1", value);
- }
- else if (fryNo == 2)
- {
- FirePot1_Write("M11.1", value);
- }
- }
- Thread.Sleep(200);
- }
- /// <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_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_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_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.FryPan1_TemperatureNow > 0 ? WorkStatus.工作 : WorkStatus.待机,
- WorkStatus_2 = morkBF.FryPan2_TemperatureNow > 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.FryPan1_HeatingGearNow.ToString(),
- MaxWok_HeatGear_2 = morkBF.FryPan2_HeatingGearNow.ToString(),
- MaxWok_StirGear_1 = morkBF.FryPan1_FryAngle.ToString(),
- MaxWok_StirGear_2 = morkBF.FryPan2_FryAngle.ToString(),
- MaxWok_FlipSpeed_1 = morkBF.FryPan1_MixingSpeedNow.ToString(),
- MaxWok_FlipSpeed_2 = morkBF.FryPan2_MixingSpeedNow.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.未执行;
- }
- }
- }
- }
|