diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj index becbdc01..21014f94 100644 --- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj +++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj @@ -22,6 +22,9 @@ + + + @@ -223,6 +226,9 @@ + + + diff --git a/BPASmartClient.CustomResource/Image/AGV/AGV小车.png b/BPASmartClient.CustomResource/Image/AGV/AGV小车.png new file mode 100644 index 00000000..4b51b829 Binary files /dev/null and b/BPASmartClient.CustomResource/Image/AGV/AGV小车.png differ diff --git a/BPASmartClient.CustomResource/Image/AGV/AGV炒锅.png b/BPASmartClient.CustomResource/Image/AGV/AGV炒锅.png new file mode 100644 index 00000000..81c8bdc0 Binary files /dev/null and b/BPASmartClient.CustomResource/Image/AGV/AGV炒锅.png differ diff --git a/BPASmartClient.CustomResource/Image/AGV/agv.png b/BPASmartClient.CustomResource/Image/AGV/agv.png new file mode 100644 index 00000000..816e71ef Binary files /dev/null and b/BPASmartClient.CustomResource/Image/AGV/agv.png differ diff --git a/BPASmartClient.CustomResource/Themes/MyStyle.xaml b/BPASmartClient.CustomResource/Themes/MyStyle.xaml index 535552ab..acdc7f56 100644 --- a/BPASmartClient.CustomResource/Themes/MyStyle.xaml +++ b/BPASmartClient.CustomResource/Themes/MyStyle.xaml @@ -172,6 +172,13 @@ + diff --git a/BPASmartClient.Helper/ThreadManage.cs b/BPASmartClient.Helper/ThreadManage.cs index 47598773..479efa1a 100644 --- a/BPASmartClient.Helper/ThreadManage.cs +++ b/BPASmartClient.Helper/ThreadManage.cs @@ -32,10 +32,6 @@ namespace BPASmartClient.Helper if (CancellationTokenSources.ContainsKey(guid + key)) { CancellationTokenSources[guid + key]?.Cancel(); - if (key.Equals("MainTask")) - { - ActionManage.GetInstance.Send("FryPotDosingMainTaskExit"); - } ActionManage.GetInstance.Register(ExitCallback, guid + key); } else diff --git a/FryPot_DosingSystem/AGV/WhichCart.cs b/FryPot_DosingSystem/AGV/WhichCart.cs index eb915f41..6e84b46a 100644 --- a/FryPot_DosingSystem/AGV/WhichCart.cs +++ b/FryPot_DosingSystem/AGV/WhichCart.cs @@ -59,7 +59,8 @@ namespace FryPot_DosingSystem.AGV public enum IsBool { Yes, - No + No, + OnllYes } /// /// 是否运行 diff --git a/FryPot_DosingSystem/Control/DosingLogicControl.cs b/FryPot_DosingSystem/Control/DosingLogicControl.cs index c4c3a4af..9ac1d5fb 100644 --- a/FryPot_DosingSystem/Control/DosingLogicControl.cs +++ b/FryPot_DosingSystem/Control/DosingLogicControl.cs @@ -84,9 +84,9 @@ namespace FryPot_DosingSystem.Control bool LThreeErrorRecipe;//线体3错误配方标识 #endregion #region agv临时变量 - bool agvArriveUpLoad = false;//agv是否到达线体1装料位置 - bool agvArriveLTwoUpLoad = false;//agv是否到达线体2装料位置 - bool agvArriveLThreeUpLoad = false;//agv是否到达线体3装料位置 + bool agvArriveUpLoad = false;//agv是否到达线体1上料位置 + bool agvArriveLTwoUpLoad = false;//agv是否到达线体2上料位置 + bool agvArriveLThreeUpLoad = false;//agv是否到达线体3上料位置 bool agvArriveUnLoad = false;//线体1 agv是否到达炒锅送料位置 bool LTwoagvArriveUnLoad = false;//线体2 agv是否到达炒锅送料位置 @@ -218,15 +218,15 @@ namespace FryPot_DosingSystem.Control globalVar = new GlobalVariable(); hardWareStatusModel = HardWareStatusViewModel.GetInstance; ActionManage.GetInstance.Register(new Action(RecipeDataParse), "RecipeSetDown"); - ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); }), "ClearRecipes"); + ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); LTwoInputMaterialQuene.Clear(); LTwoOutputMaterialQuene.Clear(); LThreeInputMaterialQuene.Clear(); LThreeOutputMaterialQuene.Clear(); }), "ClearRecipes"); ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 1; }), "StartPlcInite"); ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 0; }), "EndPlcInite"); ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitMainTask = true; }), "FryPotDosingMainTaskExit"); HubHelper.GetInstance.Report = new Action(AgvTaskUpReportDataAnalysis); HubHelper.GetInstance.Upstreamrequest = new Action(AgvFeedBackUpReportDataAnalysis); - ResetProgram(); + // ResetProgram(); ReadPlcData(); - IniteTask(); + MainTask(); CommandRegist(); } @@ -433,19 +433,28 @@ namespace FryPot_DosingSystem.Control if (RTrig.GetInstance("ResetProgram").Start(globalVar.PlcInite == 1))//判断是否初始化 一初始化就重启主任务 { MessageLog.GetInstance.ShowUserLog("主任务正在重启"); - ThreadManage.GetInstance().StopTask("MainTask", new Action(() => + + ThreadManage.GetInstance().StopTask("MainViewReadPlcData", new Action(() => { - ThreadManage.GetInstance().StopTask("MainViewReadPlcData", new Action(() => + ActionManage.GetInstance.CancelRegister("RecipeSetDown"); + ActionManage.GetInstance.Register(new Action(RecipeDataParse), "RecipeSetDown"); + ActionManage.GetInstance.Send("ClearRecipes"); + ThreadManage.GetInstance().StopTask("滚筒线1任务线程", new Action(() => { - globalVar = null; - globalVar = new GlobalVariable(); - ReicpeNum = 0; - ActionManage.GetInstance.CancelRegister("RecipeSetDown"); - ActionManage.GetInstance.Register(new Action(RecipeDataParse), "RecipeSetDown"); - ActionManage.GetInstance.Send("ClearRecipes"); - ReadPlcData(); - IniteTask(); - MessageLog.GetInstance.ShowUserLog("主任务重启完成"); + ThreadManage.GetInstance().StopTask("滚筒线2任务线程", new Action(() => + { + ThreadManage.GetInstance().StopTask("滚筒线3任务线程", new Action(() => + { + globalVar = null; + globalVar = new GlobalVariable(); + ReicpeNum = 0; + ReadPlcData(); + MainTask(); + MessageLog.GetInstance.ShowUserLog("主任务重启完成"); + + })); + })); + })); })); } @@ -624,7 +633,6 @@ namespace FryPot_DosingSystem.Control } else { - hardWareStatusModel.RollerTwoModel.RollerAlarmState = Color.FromRgb(255, 51, 153);//有故障 } if (globalVar.rollerLineTwo.OutMaterialingSingle == 1)//运行中 @@ -689,13 +697,13 @@ namespace FryPot_DosingSystem.Control /// /// 初始化任务 /// - public void IniteTask() - { - ThreadManage.GetInstance().StartLong(new Action(() => - { - MainTask(); - }), "MainTask"); - } + //public void IniteTask() + //{ + // ThreadManage.GetInstance().StartLong(new Action(() => + // { + // MainTask(); + // }), "MainTask"); + //} /// /// 配方数据接收 /// @@ -762,9 +770,11 @@ namespace FryPot_DosingSystem.Control //LOneFryPotOutputMaterial(); //LTwoFryPotOutputMaterial(); //LThreeFryPotOutputMaterial(); - LineOneProcessExecute(); - LineTwoProcessExecute(); - LineThreeProcessExecute(); + ThreadManage.GetInstance().StartLong(new Action(() => { LineOneProcessExecute();Thread.Sleep(10); }) , "滚筒线1任务线程"); + ThreadManage.GetInstance().StartLong(new Action(() => { LineTwoProcessExecute(); Thread.Sleep(10); }), "滚筒线2任务线程"); + ThreadManage.GetInstance().StartLong(new Action(() => { LineThreeProcessExecute(); Thread.Sleep(10); }), "滚筒线3任务线程"); + + } /// /// 线体1的执行流程 @@ -774,14 +784,14 @@ namespace FryPot_DosingSystem.Control if (!globalVar.LOneTaskLock) { globalVar.LOneTaskLock = true; - Task.Run(new Action(() => - { - LOneRecipeDataToPlc(); - LOneLoadRoller(); - LOneFryPotInputMaterial(); - LOneFryPotOutputMaterial(); - globalVar.LOneTaskLock = false; - })); + LOneRecipeDataToPlc(); + LOneLoadRoller(); + LOneFryPotInputMaterial(); + LOneFallMaterial(); + LOneFryPotOutputMaterial(); + LOneEmptyOperate(); + globalVar.LOneTaskLock = false; + } @@ -794,14 +804,14 @@ namespace FryPot_DosingSystem.Control if (!globalVar.LTwoTaskLock) { globalVar.LTwoTaskLock = true; - Task.Run(new Action(() => - { - LTwoRecipeDataToPlc(); - LTwoAgvLoadRoller(); - LTwoFryPotInputMaterial(); - LTwoFryPotOutputMaterial(); - globalVar.LTwoTaskLock = false; - })); + LTwoRecipeDataToPlc(); + LTwoAgvLoadRoller(); + LTwoFryPotInputMaterial(); + LTwoFallMaterial(); + LTwoFryPotOutputMaterial(); + LTwoEmptyOperate(); + globalVar.LTwoTaskLock = false; + } } /// @@ -812,14 +822,14 @@ namespace FryPot_DosingSystem.Control if (!globalVar.LThreeTaskLock) { globalVar.LThreeTaskLock = true; - Task.Run(new Action(() => - { - LThreeRecipeDataToPlc(); - LThreeAgvLoadRoller(); - LThreeFryPotInputMaterial(); - LThreeFryPotOutputMaterial(); - globalVar.LThreeTaskLock = false; - })); + LThreeRecipeDataToPlc(); + LThreeAgvLoadRoller(); + LThreeFryPotInputMaterial(); + LThreeFallMaterial(); + LThreeFryPotOutputMaterial(); + LThreeEmptyOperate(); + globalVar.LThreeTaskLock = false; + } } @@ -950,7 +960,7 @@ namespace FryPot_DosingSystem.Control MessageLog.GetInstance.ShowUserLog($"【1】号滚筒线开始制作【{result.RecipeName}】 配方"); for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料 { - if (result.materialCollection.Count<=8&&result.materialCollection[i].MaterialLoc % 100 == i + 1 && result.materialCollection[i].MaterialLoc / 100 == headNum && (headNum == 1 || headNum == 4)) + if (result.materialCollection.Count <= 8 && result.materialCollection[i].MaterialLoc % 100 == i + 1 && result.materialCollection[i].MaterialLoc / 100 == headNum && (headNum == 1 || headNum == 4)) { //将配方中原料加入新的队列 InputMaterialQuene.Enqueue(new MaterialInfo() @@ -1123,25 +1133,28 @@ namespace FryPot_DosingSystem.Control /// public void LOneFryPotInputMaterial() { - if (OutputMaterialQuene.Count > 0 && !globalVar.InOrOutputLock) + if (OutputMaterialQuene.Count > 0 && agvArriveUnLoad && globalVar.AgvToFryPot&&!globalVar.PotOneInputMaterialArrive) { - while (!agvArriveUnLoad)//等待agv到达炒锅位置 - { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } - agvArriveUnLoad = false; MessageLog.GetInstance.ShowRunLog("AGV到达【1】号线体指定炒锅下料位置"); AgvArriveFryPotOneOrFourSingleSetDown(); + agvArriveUnLoad = false; + globalVar.PotOneInputMaterialArrive = true; + } + } + + public void LOneFallMaterial() + { + if (!globalVar.InOrOutputLock && (globalVar.fryPotOne.InputMaterialArrivedSingle == 1 || globalVar.fryPotFour.InputMaterialArrivedSingle == 1) && globalVar.PotOneInputMaterialArrive&&OutputMaterialQuene.Count>0&&!globalVar.PotOneOutputRollerArrive) + { FryPotOneRollerTroubleCheck(); if (FryPotAlarm == 1 || FryPotFourAlarm == 1)//炒锅滚筒无故障 { //炒锅滚筒进料运行到位处理 FryPotOneOrFourInputMaterialRollerOperate(); + AgvFromFryPotOneOrFourToClean();//上游下发搬运任务给AGV globalVar.InOrOutputLock = true; + globalVar.PotOneOutputRollerArrive = true; } - } } /// @@ -1149,25 +1162,27 @@ namespace FryPot_DosingSystem.Control /// public void LTwoFryPotInputMaterial() { - if (LTwoOutputMaterialQuene.Count > 0 && !globalVar.LTwoInOrOutputLock) + if (LTwoOutputMaterialQuene.Count > 0 && LTwoagvArriveUnLoad && globalVar.LTwoAgvToFryPot && !globalVar.LTwoPotInputMaterialArrive) { - while (!LTwoagvArriveUnLoad)//等待agv到达炒锅位置 - { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } - LTwoagvArriveUnLoad = false; MessageLog.GetInstance.ShowRunLog("AGV到达【2】号线体指定炒锅下料位置"); AgvArriveFryPotTwoOrFiveSingleSetDown(); + LTwoagvArriveUnLoad = false; + globalVar.LTwoPotInputMaterialArrive = true; + } + } + public void LTwoFallMaterial() + { + if (!globalVar.LTwoInOrOutputLock && (globalVar.fryPotTwo.InputMaterialArrivedSingle == 1 || globalVar.fryPotFive.InputMaterialArrivedSingle == 1) && globalVar.LTwoPotInputMaterialArrive && LTwoOutputMaterialQuene.Count > 0 && !globalVar.LTwoPotOutputRollerArrive) + { FryPotTwoRollerTroubleCheck(); if (FryPotTwoAlarm == 1 || FryPotFiveAlarm == 1)//炒锅滚筒无故障 { //炒锅滚筒进料运行到位处理 FryPotTwoOrFiveInputMaterialRollerOperate(); + AgvFromFryPotTwoOrFiveToClean();//上游下发搬运任务给AGV globalVar.LTwoInOrOutputLock = true; + globalVar.LTwoPotOutputRollerArrive = true; } - } } /// @@ -1175,25 +1190,28 @@ namespace FryPot_DosingSystem.Control /// public void LThreeFryPotInputMaterial() { - if (LThreeOutputMaterialQuene.Count > 0 && !globalVar.LThreeInOrOutputLock) + if (LThreeOutputMaterialQuene.Count > 0 && LThreeagvArriveUnLoad && globalVar.LThreeAgvToFryPot && !globalVar.LThreePotInputMaterialArrive) { - while (!LThreeagvArriveUnLoad)//等待agv到达炒锅位置 - { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } - LThreeagvArriveUnLoad = false; MessageLog.GetInstance.ShowRunLog("AGV到达【3】号线体指定炒锅下料位置"); AgvArriveFryPotThreeSingleSetDown(); + LThreeagvArriveUnLoad = false; + globalVar.LThreePotInputMaterialArrive = true; + } + } + + public void LThreeFallMaterial() + { + if (!globalVar.LThreeInOrOutputLock && globalVar.fryPotThree.InputMaterialArrivedSingle == 1 && globalVar.LThreePotInputMaterialArrive && LThreeOutputMaterialQuene.Count > 0 && !globalVar.LThreePotOutputRollerArrive) + { FryPotThreeRollerTroubleCheck(); if (FryPotThreeAlarm == 1)//炒锅滚筒无故障 { //炒锅滚筒进料运行到位处理 FryPotThreeInputMaterialRollerOperate(); + AgvFromFryPotThreeToClean();//上游下发搬运任务给AGV globalVar.LThreeInOrOutputLock = true; + globalVar.LThreePotOutputRollerArrive = true; } - } } /// @@ -1237,117 +1255,123 @@ namespace FryPot_DosingSystem.Control /// public void LOneFryPotOutputMaterial() { - if (OutputMaterialQuene.Count > 0 && globalVar.InOrOutputLock) + if (OutputMaterialQuene.Count > 0 && globalVar.InOrOutputLock && agvArriveUpLoad && globalVar.PotOneOutputRollerArrive&& !globalVar.AgvArrivePot) { - AgvFromFryPotOneOrFourToClean();//上游下发搬运任务给AGV - while (!agvArriveUpLoad)//等待agv到达炒锅位置 - { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } - agvArriveUpLoad = false; + MessageLog.GetInstance.ShowRunLog("AGV到达【1】号滚筒线对应炒锅空桶上料位置"); AgvArriveFryPotOneOrFourOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号 + agvArriveUpLoad = false; + globalVar.AgvArrivePot = true; + } + } + public void LOneEmptyOperate() + { + if ((globalVar.fryPotOne.EmptyBarrelArrivedSingle == 1 || globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 1) && agvFryPotEmptyRollerArrive&&OutputMaterialQuene.Count>0&& globalVar.AgvArrivePot) + { FryPotOneRollerTroubleCheck(); if (FryPotAlarm == 1 || FryPotFourAlarm == 1)//无故障 { FryPotOneOrFourOutEmpetyRollerOperate(); if (OutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料 { - while (!agvFryPotEmptyRollerArrive)//等待AGV拿到出桶空桶 - { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } agvFryPotEmptyRollerArrive = false; + agvArriveUpLoad = false; MessageLog.GetInstance.ShowRunLog("AGV在【1】号滚筒线对应炒锅空桶上料完成,将进行空桶回收"); //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅 globalVar.AllowAgvToLineLoadRoller = true; globalVar.InOrOutputLock = false; + globalVar.LoadRoller = false; + globalVar.AgvToFryPot = false; + globalVar.PotOneInputMaterialArrive = false; + globalVar.PotOneOutputRollerArrive = false; + globalVar.AgvArrivePot = false; } } - } + } + /// /// 线体2对应炒锅出桶 /// public void LTwoFryPotOutputMaterial() { - if (LTwoOutputMaterialQuene.Count > 0 && globalVar.LTwoInOrOutputLock) + if (LTwoOutputMaterialQuene.Count > 0 && globalVar.LTwoInOrOutputLock && agvArriveLTwoUpLoad && globalVar.LTwoPotOutputRollerArrive && !globalVar.LTwoAgvArrivePot) { - AgvFromFryPotTwoOrFiveToClean();//上游下发搬运任务给AGV - while (!agvArriveLTwoUpLoad)//等待agv到达炒锅上料位置 - { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } - agvArriveLTwoUpLoad = false; + MessageLog.GetInstance.ShowRunLog("AGV到达【2】号滚筒线对应炒锅空桶上料位置"); AgvArriveFryPotTwoOrFiveOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号 + agvArriveLTwoUpLoad = false; + globalVar.LTwoAgvArrivePot = true; + } + } + + public void LTwoEmptyOperate() + { + if ((globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 1 || globalVar.fryPotFive.EmptyBarrelArrivedSingle == 1) && LTwoagvFryPotEmptyRollerArrive && LTwoOutputMaterialQuene.Count > 0 && globalVar.LTwoAgvArrivePot) + { FryPotTwoRollerTroubleCheck(); if (FryPotTwoAlarm == 1 || FryPotFiveAlarm == 1)//无故障 { FryPotTwoOrFiveOutEmpetyRollerOperate(); if (LTwoOutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料 { - while (!LTwoagvFryPotEmptyRollerArrive)//等待AGV拿到出桶空桶 - { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } LTwoagvFryPotEmptyRollerArrive = false; + agvArriveLTwoUpLoad = false; MessageLog.GetInstance.ShowRunLog("AGV在【2】号滚筒线对应炒锅空桶上料完成,将进行空桶回收"); //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅 globalVar.AllowAgvToLineTwoLoadRoller = true; globalVar.LTwoInOrOutputLock = false; + globalVar.LTwoLoadRoller = false; + globalVar.LTwoAgvToFryPot = false; + globalVar.LTwoPotInputMaterialArrive = false; + globalVar.LTwoPotOutputRollerArrive = false; + globalVar.LTwoAgvArrivePot = false; } } - } + } /// /// 线体3对应炒锅出桶 /// public void LThreeFryPotOutputMaterial() { - if (LThreeOutputMaterialQuene.Count > 0 && globalVar.LThreeInOrOutputLock) + if (LThreeOutputMaterialQuene.Count > 0 && globalVar.LThreeInOrOutputLock && agvArriveLThreeUpLoad && globalVar.LThreePotOutputRollerArrive && !globalVar.LThreeAgvArrivePot) { - AgvFromFryPotThreeToClean();//上游下发搬运任务给AGV - while (!agvArriveLThreeUpLoad)//等待agv到达炒锅位置 - { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } - agvArriveLThreeUpLoad = false; + MessageLog.GetInstance.ShowRunLog("AGV到达【3】号滚筒线对应炒锅空桶上料位置"); AgvArriveFryPotThreeOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号 + agvArriveLThreeUpLoad = false; + globalVar.LThreeAgvArrivePot = true; + } + } + + public void LThreeEmptyOperate() + { + if (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 1 && LThreeagvFryPotEmptyRollerArrive && LThreeOutputMaterialQuene.Count > 0 && globalVar.LThreeAgvArrivePot) + { FryPotThreeRollerTroubleCheck(); - if (FryPotThreeAlarm == 1)//无故障 + if (FryPotThreeAlarm == 1 )//无故障 { FryPotThreeOutEmpetyRollerOperate(); if (LThreeOutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料 { - while (!LThreeagvFryPotEmptyRollerArrive)//等待AGV拿到出桶空桶 - { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } LThreeagvFryPotEmptyRollerArrive = false; + agvArriveLThreeUpLoad = false; MessageLog.GetInstance.ShowRunLog("AGV在【3】号滚筒线对应炒锅空桶上料完成,将进行空桶回收"); //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅 globalVar.AllowAgvToLineThreeLoadRoller = true; globalVar.LThreeInOrOutputLock = false; + globalVar.LThreeLoadRoller = false; + globalVar.LThreeAgvToFryPot = false; + globalVar.LThreePotInputMaterialArrive = false; + globalVar.LThreePotOutputRollerArrive = false; + globalVar.LThreeAgvArrivePot = false; } } - } + } /// /// 炒锅滚筒进料运行到位处理 @@ -1402,18 +1426,18 @@ namespace FryPot_DosingSystem.Control switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100) { case 1: - while (globalVar.fryPotOne.InputMaterialArrivedSingle == 0) - { - Thread.Sleep(5); if (globalVar.ExitMainTask) - return; - } + //while (globalVar.fryPotOne.InputMaterialArrivedSingle == 0) + //{ + // Thread.Sleep(5); if (globalVar.ExitMainTask) + // return; + //} MessageLog.GetInstance.ShowRunLog($"炒锅【1】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break; case 4: - while (globalVar.fryPotFour.InputMaterialArrivedSingle == 0) - { - Thread.Sleep(5); if (globalVar.ExitMainTask) - return; - } + //while (globalVar.fryPotFour.InputMaterialArrivedSingle == 0) + //{ + // Thread.Sleep(5); if (globalVar.ExitMainTask) + // return; + //} MessageLog.GetInstance.ShowRunLog($"炒锅【4】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break; } } @@ -1430,14 +1454,14 @@ namespace FryPot_DosingSystem.Control Thread.Sleep(5); if (globalVar.ExitMainTask) return; } - MessageLog.GetInstance.ShowRunLog($"炒锅【2】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break; + MessageLog.GetInstance.ShowRunLog($"炒锅【2】原料:{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break; case 5: while (globalVar.fryPotFive.InputMaterialArrivedSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask) return; } - MessageLog.GetInstance.ShowRunLog($"炒锅【5】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break; + MessageLog.GetInstance.ShowRunLog($"炒锅【5】原料:{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break; } } public void FryPotThreeInputMaterialRollerOperate() @@ -1447,7 +1471,7 @@ namespace FryPot_DosingSystem.Control Thread.Sleep(5); if (globalVar.ExitMainTask) return; } - MessageLog.GetInstance.ShowRunLog($"炒锅【3】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); + MessageLog.GetInstance.ShowRunLog($"炒锅【3】原料:{LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); } /// /// 炒锅滚筒空桶出桶处理 @@ -1502,18 +1526,18 @@ namespace FryPot_DosingSystem.Control switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100) { case 1: - while (globalVar.fryPotOne.EmptyBarrelArrivedSingle == 0) - { - Thread.Sleep(5); if (globalVar.ExitMainTask) - return; - } + //while (globalVar.fryPotOne.EmptyBarrelArrivedSingle == 0) + //{ + // Thread.Sleep(5); if (globalVar.ExitMainTask) + // return; + //} MessageLog.GetInstance.ShowRunLog($"炒锅【1】原料:【{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break; case 4: - while (globalVar.fryPotFour.EmptyBarrelArrivedSingle == 0) - { - Thread.Sleep(5); if (globalVar.ExitMainTask) - return; - } + //while (globalVar.fryPotFour.EmptyBarrelArrivedSingle == 0) + //{ + // Thread.Sleep(5); if (globalVar.ExitMainTask) + // return; + //} MessageLog.GetInstance.ShowRunLog($"炒锅【4】原料:【{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break; } } @@ -1763,30 +1787,23 @@ namespace FryPot_DosingSystem.Control /// public void AgvFromLineOneToFryPot() { - erp: if (AlarmHelper.Alarm.LOneRollerTrouble == 0)//无故障 + erp: if (AlarmHelper.Alarm.LOneRollerTrouble ==0) { - while (!agvArriveUpLoad)//等待AGV到线体装料位置 + if (agvArriveUpLoad && globalVar.LoadRoller && globalVar.rollerLineOne.StationEight == InputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.AgvToFryPot)//无故障 { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } - agvArriveUpLoad = false; - MessageLog.GetInstance.ShowRunLog("AGV到达【1】号滚筒线装桶位置"); - AgvArriveLineSingelSetDown(InputMaterialQuene); - if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo)) - { - while (!(globalVar.rollerLineOne.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号 + MessageLog.GetInstance.ShowRunLog("AGV到达【1】号滚筒线装桶位置"); + AgvArriveLineSingelSetDown(InputMaterialQuene); + if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo)) { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; + MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶"); + OutputMaterialQuene.Enqueue(materialInfo); + agvArriveUpLoad = false; + globalVar.AgvToFryPot = true; + //原料到位,agv到位,agv自行运料到炒锅 } - MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶"); - OutputMaterialQuene.Enqueue(materialInfo); - //原料到位,agv到位,agv自行运料到炒锅 - } + + } } else//有故障 { @@ -1809,26 +1826,20 @@ namespace FryPot_DosingSystem.Control { erp: if (AlarmHelper.Alarm.LTwoRollerTrouble == 0)//无故障 { - while (!agvArriveLTwoUpLoad)//等待AGV到线体装料位置 + if (agvArriveLTwoUpLoad && globalVar.LTwoLoadRoller && globalVar.rollerLineTwo.StationEight == LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.LTwoAgvToFryPot)//无故障 { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } - agvArriveLTwoUpLoad = false; - MessageLog.GetInstance.ShowRunLog("AGV到达【2】号滚筒线装桶位置"); - AgvArriveLineSingelSetDown(LTwoInputMaterialQuene); - if (LTwoInputMaterialQuene.TryDequeue(out MaterialInfo materialInfo)) - { - while (!(globalVar.rollerLineTwo.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号 + MessageLog.GetInstance.ShowRunLog("AGV到达【2】号滚筒线装桶位置"); + AgvArriveLineSingelSetDown(LTwoInputMaterialQuene); + if (LTwoInputMaterialQuene.TryDequeue(out MaterialInfo materialInfo)) { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; + MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶"); + LTwoOutputMaterialQuene.Enqueue(materialInfo); + agvArriveLTwoUpLoad = false; + globalVar.LTwoAgvToFryPot = true; + //原料到位,agv到位,agv自行运料到炒锅 } - MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶"); - LTwoOutputMaterialQuene.Enqueue(materialInfo); - //原料到位,agv到位,agv运料到炒锅 + + } } @@ -1853,26 +1864,20 @@ namespace FryPot_DosingSystem.Control { erp: if (AlarmHelper.Alarm.LThreeRollerTrouble == 0)//无故障 { - while (!agvArriveLThreeUpLoad)//等待AGV到线体装料位置 - { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } - agvArriveLThreeUpLoad = false; - MessageLog.GetInstance.ShowRunLog("AGV到达【3】号滚筒线装桶位置"); - AgvArriveLineSingelSetDown(LThreeInputMaterialQuene); - if (LThreeInputMaterialQuene.TryDequeue(out MaterialInfo materialInfo)) + if (agvArriveLThreeUpLoad && globalVar.LThreeLoadRoller && globalVar.rollerLineThree.StationEight == LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.LThreeAgvToFryPot)//无故障 { - while (!(globalVar.rollerLineThree.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号 + MessageLog.GetInstance.ShowRunLog("AGV到达【3】号滚筒线装桶位置"); + AgvArriveLineSingelSetDown(LThreeInputMaterialQuene); + if (LThreeInputMaterialQuene.TryDequeue(out MaterialInfo materialInfo)) { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; + MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶"); + LThreeOutputMaterialQuene.Enqueue(materialInfo); + agvArriveLThreeUpLoad = false; + globalVar.LThreeAgvToFryPot = true; + //原料到位,agv到位,agv自行运料到炒锅 } - MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶"); - LThreeOutputMaterialQuene.Enqueue(materialInfo); - //原料到位,agv到位,agv运料到炒锅 + + } } @@ -1935,14 +1940,8 @@ namespace FryPot_DosingSystem.Control { if (AlarmHelper.Alarm.LOneRollerTrouble == 0)//输送线无故障 { - if (InputMaterialQuene.Count > 0) + if (InputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineLoadRoller && globalVar.rollerLineOne.OutMaterialingSingle == 1 && !globalVar.LoadRoller) { - while (!globalVar.AllowAgvToLineLoadRoller || globalVar.rollerLineOne.OutMaterialingSingle == 0) - { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } e: string id = Guid.NewGuid().ToString("N"); if (id == LOnerobotJobId) goto e; @@ -1951,74 +1950,81 @@ namespace FryPot_DosingSystem.Control LOnerobotJobId = id; Thread.Sleep(500); LineCarryTaskErrorCodeAnalysis(info, 1); + globalVar.LoadRoller = true; + + } } - else - { - MessageLog.GetInstance.ShowRunLog("警告:滚筒输送线体【1】故障!!!"); - // lineAlarm = -1; - } - // lineAlarm = 1; + //else + //{ + // MessageLog.GetInstance.ShowRunLog("警告:滚筒输送线体【1】故障!!!"); + // // lineAlarm = -1; + //} + //// lineAlarm = 1; } public void AgvToLineTwoLoadRoller() { if (AlarmHelper.Alarm.LTwoRollerTrouble == 0)//输送线无故障 { - if (LTwoInputMaterialQuene.Count > 0) + if (LTwoInputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineTwoLoadRoller && globalVar.rollerLineTwo.OutMaterialingSingle == 1 && !globalVar.LTwoLoadRoller) { - while (!globalVar.AllowAgvToLineTwoLoadRoller || globalVar.rollerLineTwo.OutMaterialingSingle == 0) //后续考虑是否用while - { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } - p: string id = Guid.NewGuid().ToString(); + e: string id = Guid.NewGuid().ToString("N"); if (id == LTworobotJobId) - goto p; + goto e; + string info = AGVHelper.GetInstance.AgvToLineTwoLoadRoller(id); - // MessageLog.GetInstance.ShowRunLog("AGV去【2】号滚筒线装桶"); LTworobotJobId = id; Thread.Sleep(500); LineCarryTaskErrorCodeAnalysis(info, 2); + globalVar.LTwoLoadRoller = true; } - - } - else - { - MessageLog.GetInstance.ShowRunLog("警告:滚筒输送线体【2】故障!!!"); - //lineAlarm = -1; } - // lineAlarm = 1; } public void AgvToLineThreeLoadRoller() { if (AlarmHelper.Alarm.LThreeRollerTrouble == 0)//输送线无故障 { - if (LThreeInputMaterialQuene.Count > 0) + if (LThreeInputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineThreeLoadRoller && globalVar.rollerLineThree.OutMaterialingSingle == 1 && !globalVar.LThreeLoadRoller) { - while (!globalVar.AllowAgvToLineThreeLoadRoller || globalVar.rollerLineThree.OutMaterialingSingle == 0) //后续考虑是否用while - { - Thread.Sleep(5); - if (globalVar.ExitMainTask) - return; - } - g: string id = Guid.NewGuid().ToString(); + e: string id = Guid.NewGuid().ToString("N"); if (id == LThreerobotJobId) - goto g; + goto e; + string info = AGVHelper.GetInstance.AgvToLineThreeLoadRoller(id); - // MessageLog.GetInstance.ShowRunLog("AGV去【3】号滚筒线装桶"); LThreerobotJobId = id; Thread.Sleep(500); LineCarryTaskErrorCodeAnalysis(info, 3); + globalVar.LThreeLoadRoller = true; } - - } - else - { - MessageLog.GetInstance.ShowRunLog("警告:滚筒输送线体【3】故障!!!"); - // lineAlarm = -1; } - // lineAlarm = 1; + + //if (AlarmHelper.Alarm.LThreeRollerTrouble == 0)//输送线无故障 + //{ + // if (LThreeInputMaterialQuene.Count > 0) + // { + // while (!globalVar.AllowAgvToLineThreeLoadRoller || globalVar.rollerLineThree.OutMaterialingSingle == 0) //后续考虑是否用while + // { + // Thread.Sleep(5); + // if (globalVar.ExitMainTask) + // return; + // } + // g: string id = Guid.NewGuid().ToString(); + // if (id == LThreerobotJobId) + // goto g; + // string info = AGVHelper.GetInstance.AgvToLineThreeLoadRoller(id); + // // MessageLog.GetInstance.ShowRunLog("AGV去【3】号滚筒线装桶"); + // LThreerobotJobId = id; + // Thread.Sleep(500); + // LineCarryTaskErrorCodeAnalysis(info, 3); + // } + + //} + //else + //{ + // MessageLog.GetInstance.ShowRunLog("警告:滚筒输送线体【3】故障!!!"); + // // lineAlarm = -1; + //} + } /// /// 1号线体数据下发 diff --git a/FryPot_DosingSystem/Control/GlobalVariable.cs b/FryPot_DosingSystem/Control/GlobalVariable.cs index c2afb2e6..9975503e 100644 --- a/FryPot_DosingSystem/Control/GlobalVariable.cs +++ b/FryPot_DosingSystem/Control/GlobalVariable.cs @@ -115,7 +115,36 @@ namespace FryPot_DosingSystem.Control /// public string LThreeCurrentRecipeName { get; set; } = string.Empty; #endregion + #region 线体1流程互锁变量 + public bool LoadRoller { get; set; } + + public bool AgvToFryPot { get; set; } + + public bool PotOneInputMaterialArrive { get; set; } + public bool PotOneOutputRollerArrive { get; set; } + public bool AgvArrivePot { get; set; } + #endregion + #region 线体2流程互锁变量 + + public bool LTwoLoadRoller { get; set; } + + public bool LTwoAgvToFryPot { get; set; } + + public bool LTwoPotInputMaterialArrive { get; set; } + public bool LTwoPotOutputRollerArrive { get; set; } + public bool LTwoAgvArrivePot { get; set; } + #endregion + #region 线体3流程互锁变量 + + public bool LThreeLoadRoller { get; set; } + + public bool LThreeAgvToFryPot { get; set; } + + public bool LThreePotInputMaterialArrive { get; set; } + public bool LThreePotOutputRollerArrive { get; set; } + public bool LThreeAgvArrivePot { get; set; } + #endregion } /// /// 滚筒线1相关变量 diff --git a/FryPot_DosingSystem/View/AgvView.xaml b/FryPot_DosingSystem/View/AgvView.xaml index 3c826bbe..d0911b4d 100644 --- a/FryPot_DosingSystem/View/AgvView.xaml +++ b/FryPot_DosingSystem/View/AgvView.xaml @@ -506,11 +506,21 @@ + - + + + + + + + + + + @@ -634,7 +644,7 @@ - - - - - - - + + + + + + 停车桩测试 + 1 + + + + + + 料筒控制 + 1 + + + + + + 设置物料 + 1 + 1 + + + + + + 小车测试 + 1 + + + + + + + 小车?物品 + 1 + + + + + + + + + - - @@ -1235,18 +1290,155 @@ 炒锅(5)号 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 满料桶滚筒线 - (1)号 + (1)满料桶滚筒线 - (2)号 + (2)满料桶滚筒线 - (3)号 + (3)满料桶滚筒线 空桶滚筒线 @@ -1255,22 +1447,22 @@ - 停车桩(1号) + 停车桩(1号) - 停车桩(2号) + 停车桩(2号) - 停车桩(3号) + 停车桩(3号) - 停车桩(4号) + 停车桩(4号) - 充电桩(1号) + 充电桩(5号) - 充电桩(2号) + 充电桩(6号) @@ -1282,5 +1474,6 @@ + diff --git a/FryPot_DosingSystem/View/AgvView.xaml.cs b/FryPot_DosingSystem/View/AgvView.xaml.cs index de598ba4..9aa2b5e0 100644 --- a/FryPot_DosingSystem/View/AgvView.xaml.cs +++ b/FryPot_DosingSystem/View/AgvView.xaml.cs @@ -27,46 +27,147 @@ namespace FryPot_DosingSystem.View { InitializeComponent(); this.DataContext = AgvViewModel.GetInstance(); + 控制命令.ItemsSource = AgvViewModel.GetInstance().GetCommand(); } private void Button_Click(object sender, RoutedEventArgs e) { - // AgvViewModel.GetInstance().cartModel_1.cartMotionTrajectory = CartMotionTrajectory.Stop; - AgvViewModel.GetInstance().ParkingPileModel_1.isBool = IsBool.No; - AgvViewModel.GetInstance().cartModel_1.isBool=IsBool.No; - AgvViewModel.GetInstance().cartModel_1.cartMotionTrajectory = CartMotionTrajectory.qc_1; + int id = 1; + if (sender is Button) + { + byte[] data; + bool istrue = false; + Button button = sender as Button; + if (button.Tag != null) + { + switch (button.Tag.ToString()) + { + case "设置有车": + try + { + id=int.Parse(tcz_text.Text.ToString()); + } + catch (Exception ex) + { + MessageBox.Show("只能输入 1-5 的数字!"); + return; + } + AgvViewModel.GetInstance().Set停车桩(id, IsBool.Yes); + break; + case "设置无车": + + try + { + id = int.Parse(tcz_text.Text.ToString()); + } + catch (Exception ex) + { + MessageBox.Show("只能输入 1-5 的数字!"); + return; + } + AgvViewModel.GetInstance().Set停车桩(id, IsBool.No); + break; + case "启动": + try + { + id = int.Parse(liaotong_text.Text.ToString()); + } + catch (Exception ex) + { + MessageBox.Show("只能输入 1-5 的数字!"); + return; + } + AgvViewModel.GetInstance().Set滚筒线状态(id, IsRun.Start); + break; + case "停止": + try + { + id = int.Parse(liaotong_text.Text.ToString()); + } + catch (Exception ex) + { + MessageBox.Show("只能输入 1-5 的数字!"); + return; + } + AgvViewModel.GetInstance().Set滚筒线状态(id, IsRun.Stop); + break; + case "设置物料": + try + { + id = int.Parse(liaotongwuliao_text.Text.ToString()); + } + catch (Exception ex) + { + MessageBox.Show("只能输入 1-8 的数字!"); + return; + } + AgvViewModel.GetInstance().Set滚筒线上数量(id, liaotongwuliaoshuliang_text.Text); + break; + case "小车停止": + try + { + id = int.Parse(xiaoche_text.Text.ToString()); + } + catch (Exception ex) + { + MessageBox.Show("只能输入 1-4 的数字!"); + return; + } + AgvViewModel.GetInstance().Set小车停止(id); + break; + case "运行小车": + try + { + id = int.Parse(xiaoche_text.Text.ToString()); + } + catch (Exception ex) + { + MessageBox.Show("只能输入 1-4 的数字!"); + return; + } + AgvViewModel.GetInstance().Set小车运动(id, AgvViewModel.GetInstance().GetCommandValue(控制命令.Text)); + break; + case "有菜和碗": + try + { + id = int.Parse(xiaochewuping_text.Text.ToString()); + } + catch (Exception ex) + { + MessageBox.Show("只能输入 1-4 的数字!"); + return; + } + AgvViewModel.GetInstance().Set小车是否承载物品(id, IsBool.Yes); + break; + case "只有碗": + try + { + id = int.Parse(xiaochewuping_text.Text.ToString()); + } + catch (Exception ex) + { + MessageBox.Show("只能输入 1-4 的数字!"); + return; + } + AgvViewModel.GetInstance().Set小车是否承载物品(id, IsBool.OnllYes); + break; + case "无物品": + try + { + id = int.Parse(xiaochewuping_text.Text.ToString()); + } + catch (Exception ex) + { + MessageBox.Show("只能输入 1-4 的数字!"); + return; + } + AgvViewModel.GetInstance().Set小车是否承载物品(id, IsBool.No); + break; - + } + } + } } - private void Button_Click_1(object sender, RoutedEventArgs e) - { - AgvViewModel.GetInstance().RollerLines_1.isRun = IsRun.Start; - } - - private void StopButton_Click(object sender, RoutedEventArgs e) - { - AgvViewModel.GetInstance().RollerLines_1.isRun = IsRun.Stop; - AgvViewModel.GetInstance().cartModel_1.isBool = IsBool.Yes; - AgvViewModel.GetInstance().cartModel_1.cartMotionTrajectory = CartMotionTrajectory.yc_1_1; - } - - private void Button_Click_2(object sender, RoutedEventArgs e) - { - AgvViewModel.GetInstance().cartModel_1.isBool = IsBool.No; - AgvViewModel.GetInstance().cartModel_1.cartMotionTrajectory = CartMotionTrajectory.hs_1; - } - - private void Button_Click_3(object sender, RoutedEventArgs e) - { - AgvViewModel.GetInstance().cartModel_1.cartMotionTrajectory = CartMotionTrajectory.hj; - AgvViewModel.GetInstance().ParkingPileModel_1.isBool = IsBool.Yes; - } - - private void Button_Click_4(object sender, RoutedEventArgs e) - { - AgvViewModel.GetInstance().cartModel_1.cartMotionTrajectory = CartMotionTrajectory.Stop; - - } } } diff --git a/FryPot_DosingSystem/ViewModel/AgvViewModel.cs b/FryPot_DosingSystem/ViewModel/AgvViewModel.cs index c6a29caf..6013f8ac 100644 --- a/FryPot_DosingSystem/ViewModel/AgvViewModel.cs +++ b/FryPot_DosingSystem/ViewModel/AgvViewModel.cs @@ -2,9 +2,12 @@ using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; +using System.Windows; namespace FryPot_DosingSystem.ViewModel { @@ -30,25 +33,306 @@ namespace FryPot_DosingSystem.ViewModel cartModel_2 = new CartModel(); cartModel_3 = new CartModel(); cartModel_4 = new CartModel(); - + //初始化滚筒线 RollerLines_1 = new RollerLinesModel(); RollerLines_2 = new RollerLinesModel(); RollerLines_3 = new RollerLinesModel(); RollerLines_4 = new RollerLinesModel(); - + //初始化停车桩 ParkingPileModel_1 = new ParkingPileModel { isBool = IsBool.Yes }; ParkingPileModel_2 = new ParkingPileModel { isBool = IsBool.Yes }; ParkingPileModel_3 = new ParkingPileModel { isBool = IsBool.Yes }; ParkingPileModel_4 = new ParkingPileModel { isBool = IsBool.Yes }; ParkingPileModel_5 = new ParkingPileModel { isBool = IsBool.No }; ParkingPileModel_6 = new ParkingPileModel { isBool = IsBool.No }; + //初始化炒锅 + wokModel_1 = new WokModel(); + wokModel_2 = new WokModel(); + wokModel_3 = new WokModel(); + wokModel_4 = new WokModel(); + wokModel_5 = new WokModel(); + Test(); + } + #endregion + #region 公共调用函数 + public void Test() + { RollerLines_2.DishesNum = "3"; + + + wokModel_1.goodsName = "番茄炒蛋"; + wokModel_1.workflows = new ObservableCollection + { + new WorkflowModel {id=1,Name="取番茄",isBool= IsBool.Yes}, + new WorkflowModel {id=2,Name="取蛋" } }; } - #endregion + /// + /// 设置停车桩或充电桩 + /// + /// 设置哪一个停车桩:1 2 3(5 6 为充电桩) + /// 是否有小车 + public void Set停车桩(int id, IsBool isBool) + { + try + { + switch (id) + { + case 1: + ParkingPileModel_1.isBool = isBool; + break; + case 2: + ParkingPileModel_2.isBool = isBool; + break; + case 3: + ParkingPileModel_3.isBool = isBool; + break; + case 4: + ParkingPileModel_4.isBool = isBool; + break; + case 5: + ParkingPileModel_5.isBool = isBool; + break; + case 6: + ParkingPileModel_6.isBool = isBool; + break; + } + + } + catch (Exception ex) + { + + } + } + /// + /// 小车停止 + /// + /// 默认:1 2 3 4,代表四辆车 + public void Set小车停止(int id) + { + try + { + switch (id) + { + case 1: + cartModel_1.cartMotionTrajectory = CartMotionTrajectory.Stop; + break; + case 2: + cartModel_2.cartMotionTrajectory = CartMotionTrajectory.Stop; + break; + case 3: + cartModel_3.cartMotionTrajectory = CartMotionTrajectory.Stop; + break; + case 4: + cartModel_4.cartMotionTrajectory = CartMotionTrajectory.Stop; + break; + } + + } + catch (Exception ex) + { + + } + } + /// + /// 控制小车运行 + /// + /// 默认:1 2 3 4,代表四辆车 + /// + public void Set小车运动(int id, CartMotionTrajectory cart) + { + try + { + switch (id) + { + case 1: + cartModel_1.cartMotionTrajectory = CartMotionTrajectory.Stop; + Thread.Sleep(10); + cartModel_1.cartMotionTrajectory = cart; + break; + case 2: + cartModel_2.cartMotionTrajectory = CartMotionTrajectory.Stop; + Thread.Sleep(10); + cartModel_2.cartMotionTrajectory = cart; + break; + case 3: + cartModel_3.cartMotionTrajectory = CartMotionTrajectory.Stop; + Thread.Sleep(10); + cartModel_3.cartMotionTrajectory = cart; + break; + case 4: + cartModel_4.cartMotionTrajectory = CartMotionTrajectory.Stop; + Thread.Sleep(10); + cartModel_4.cartMotionTrajectory = cart; + break; + } + + } + catch (Exception ex) + { + + } + } + /// + /// 小车是否承载物品 + /// + /// 默认:1 2 3 4,代表四辆车 + /// + public void Set小车是否承载物品(int id, IsBool cart) + { + try + { + switch (id) + { + case 1: + cartModel_1.isBool = cart; + break; + case 2: + cartModel_2.isBool = cart; + break; + case 3: + cartModel_3.isBool = cart; + break; + case 4: + cartModel_4.isBool = cart; + break; + } + + } + catch (Exception ex) + { + + } + } + /// + /// 滚筒线状态 + /// + /// 默认:1 2 3 4,代表四条滚筒线,(4 代表空桶线) + /// + public void Set滚筒线状态(int id, IsRun cart) + { + try + { + switch (id) + { + case 1: + RollerLines_1.isRun = cart; + break; + case 2: + RollerLines_2.isRun = cart; + break; + case 3: + RollerLines_3.isRun = cart; + break; + case 4: + RollerLines_4.isRun = cart; + break; + } + + } + catch (Exception ex) + { + + } + } + /// + /// 滚筒线上数量 + /// + /// 默认:1 2 3 4,代表四条滚筒线,(4 代表空桶线) + /// 默认: 1 - 8,最多承载 8个菜品或者8个空碗 + public void Set滚筒线上数量(int id, string cart) + { + try + { + switch (id) + { + case 1: + RollerLines_1.DishesNum = cart; + break; + case 2: + RollerLines_2.DishesNum = cart; + break; + case 3: + RollerLines_3.DishesNum = cart; + break; + case 4: + RollerLines_4.DishesNum = cart; + break; + } - #region 公共函数 + } + catch (Exception ex) + { + } + } + /// + /// 设置炒锅显示流程 + /// + /// 默认:1 2 3 4 5,代表五个炒锅 + /// + public void Set炒锅显示流程(int id, WokModel mode) + { + try + { + switch (id) + { + case 1: + wokModel_1=mode; + break; + case 2: + wokModel_2 = mode; + break; + case 3: + wokModel_3 = mode; + break; + case 4: + wokModel_4 = mode; + break; + case 5: + wokModel_5 = mode; + break; + } + + } + catch (Exception ex) + { + + } + } + #endregion + + #region 其他函数 + /// + /// 获取所有命令 + /// + public List GetCommand() + { + List vs = new List(); + try + { + vs = System.Enum.GetNames(typeof(CartMotionTrajectory))?.ToList(); + } + catch (Exception ex) + { + return vs; + } + return vs; + } + /// + /// 根据命令获取值 + /// + public CartMotionTrajectory GetCommandValue(string name) + { + return ToEnumValue(name); + } + /// + /// 根据枚举名称获取枚举值 + /// + public T ToEnumValue(string name) + { + return (T)Enum.Parse(typeof(T), name); + } #endregion #region 4个滚筒线控制 @@ -312,6 +596,98 @@ namespace FryPot_DosingSystem.ViewModel } #endregion + #region 5个炒锅流程控制 + /// + /// 一号炒锅工作流程 + /// + private WokModel _wokModel_1; + public WokModel wokModel_1 + { + get + { + return _wokModel_1; + } + set + { + if (_wokModel_1 == value) + return; + _wokModel_1 = value; + OnPropertyChanged("wokModel_1"); + } + } + /// + /// 二号炒锅工作流程 + /// + private WokModel _wokModel_2; + public WokModel wokModel_2 + { + get + { + return _wokModel_2; + } + set + { + if (_wokModel_2 == value) + return; + _wokModel_2 = value; + OnPropertyChanged("wokModel_2"); + } + } + /// + /// 三号炒锅工作流程 + /// + private WokModel _wokModel_3; + public WokModel wokModel_3 + { + get + { + return _wokModel_3; + } + set + { + if (_wokModel_3 == value) + return; + _wokModel_3 = value; + OnPropertyChanged("wokModel_3"); + } + } + /// + /// 四号炒锅工作流程 + /// + private WokModel _wokModel_4; + public WokModel wokModel_4 + { + get + { + return _wokModel_4; + } + set + { + if (_wokModel_4 == value) + return; + _wokModel_4 = value; + OnPropertyChanged("wokModel_4"); + } + } + /// + /// 五号炒锅工作流程 + /// + private WokModel _wokModel_5; + public WokModel wokModel_5 + { + get + { + return _wokModel_5; + } + set + { + if (_wokModel_5 == value) + return; + _wokModel_5 = value; + OnPropertyChanged("wokModel_5"); + } + } + #endregion } /// @@ -319,7 +695,6 @@ namespace FryPot_DosingSystem.ViewModel /// public class CartModel : ObservableObject { - /// /// 车上是否有物品 /// @@ -333,11 +708,10 @@ namespace FryPot_DosingSystem.ViewModel set { _isBool = value; - Text= _isBool.ToString(); + Text = _isBool.ToString(); OnPropertyChanged("isBool"); } } - /// /// 车运动轨迹方式 /// @@ -351,7 +725,7 @@ namespace FryPot_DosingSystem.ViewModel set { _cartMotionTrajectory = value; - Tag= _cartMotionTrajectory.ToString(); + Tag = _cartMotionTrajectory.ToString(); OnPropertyChanged("cartMotionTrajectory"); } } @@ -437,7 +811,7 @@ namespace FryPot_DosingSystem.ViewModel set { _isRun = value; - Text= _isRun.ToString(); + Text = _isRun.ToString(); OnPropertyChanged("isBool"); } } @@ -460,7 +834,7 @@ namespace FryPot_DosingSystem.ViewModel try { count = int.Parse(_DishesNum); - if (count > 0 && count <= 8) + if (count >= 0 && count <= 8) { _DishesNum = count.ToString(); } @@ -475,8 +849,6 @@ namespace FryPot_DosingSystem.ViewModel OnPropertyChanged("DishesNum"); } } - - private string _Text = IsRun.Stop.ToString(); public string Text { @@ -491,6 +863,203 @@ namespace FryPot_DosingSystem.ViewModel } } } + /// + /// 炒锅 流程控制 + /// + public class WokModel : ObservableObject + { + /// + /// id + /// + private string _id; + public string id + { + get + { + return _id; + } + set + { + _id = value; + OnPropertyChanged("id"); + } + } + /// + /// 订单id + /// + private string _orderID; + public string orderID + { + get + { + return _orderID; + } + set + { + _orderID = value; + OnPropertyChanged("orderID"); + } + } + /// + /// 商品名称 + /// + private string _goodsName; + public string goodsName + { + get + { + return _goodsName; + } + set + { + _goodsName = value; + OnPropertyChanged("goodsName"); + } + } + /// + /// 其他信息 + /// + private string _other; + public string other + { + get + { + return _other; + } + set + { + _other = value; + OnPropertyChanged("other"); + } + } + /// + /// 工作流程 + /// + private ObservableCollection _workflows = new ObservableCollection(); + public ObservableCollection workflows + { + get + { + return _workflows; + } + set + { + _workflows = value; + OnPropertyChanged("workflows"); + } + } + public WokModel() + { + id = Guid.NewGuid().ToString(); + workflows = new ObservableCollection(); + } + } + /// + /// 工作流程 + /// + public class WorkflowModel : ObservableObject + { + /// + /// 序号默认:1-10 + /// + private int _id=1; + public int id + { + get + { + return _id; + } + set + { + _id = value; + xh = GetXH.ID(_id); + OnPropertyChanged("id"); + } + } + /// + /// 名称 + /// + private string _Name; + public string Name + { + get + { + return _Name; + } + set + { + _Name = value; + OnPropertyChanged("Name"); + } + } + /// + /// 是否已完成当前步骤 + /// + private IsBool _isBool = IsBool.No; + public IsBool isBool + { + get + { + return _isBool; + } + set + { + _isBool = value; + if (_isBool == IsBool.Yes) + { + visibility = Visibility.Visible; + } + else + { + visibility = Visibility.Collapsed; + } + OnPropertyChanged("isBool"); + } + } + private Visibility _visibility = Visibility.Collapsed; + public Visibility visibility + { + get + { + return _visibility; + } + set + { + _visibility = value; + OnPropertyChanged("visibility"); + } + } + private string _xh; + public string xh + { + get + { + return _xh; + } + set + { + _xh = value; + OnPropertyChanged("xh"); + } + } + } + /// + /// 获取序号 + /// + static class GetXH + { + //①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳㉑㉒㉓㉔㉕㉖㉗㉘㉙㉚㉛㉜㉝㉞㉟㊱㊲㊳㊴㊵㊶㊷㊸㊹㊺㊻㊼㊽㊾㊿ + public static string ID(int i) + { + string strbu = "① "; + string str = "①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳㉑㉒㉓㉔㉕㉖㉗㉘㉙㉚㉛㉜㉝㉞㉟㊱㊲㊳㊴㊵㊶㊷㊸㊹㊺㊻㊼㊽㊾㊿"; + if (i <= 50) + { + strbu= str.Substring(i-1, 1)+" "; + } + return strbu; + } + } }