diff --git a/BPASmartClient.AGV/AGVHelper.cs b/BPASmartClient.AGV/AGVHelper.cs index 50e08d91..b26f8923 100644 --- a/BPASmartClient.AGV/AGVHelper.cs +++ b/BPASmartClient.AGV/AGVHelper.cs @@ -52,9 +52,94 @@ namespace BPASmartClient.AGV request.Abort(); } return retString;//返回响应报文 - - } - + /// + /// AGV去1号线体装桶 + /// + /// + public string AgvToLineOneLoadRoller() + { + string url = ""; + string head = ""; + string body = ""; + return HttpRequest(url,head,body); + } + /// + /// AGV去2号线体装桶 + /// + /// + public string AgvToLineTwoLoadRoller() + { + string url = ""; + string head = ""; + string body = ""; + return HttpRequest(url, head, body); + } + /// + /// AGV去3号线体装桶 + /// + /// + public string AgvToLineThreeLoadRoller() + { + string url = ""; + string head = ""; + string body = ""; + return HttpRequest(url, head, body); + } + /// + /// AGV离开炒锅1 + /// + /// + public string AgvLeaveFryPotOne() + { + string url = ""; + string head = ""; + string body = ""; + return HttpRequest(url, head, body); + } + /// + /// AGV离开炒锅2 + /// + /// + public string AgvLeaveFryPotTwo() + { + string url = ""; + string head = ""; + string body = ""; + return HttpRequest(url, head, body); + } + /// + /// AGV离开炒锅3 + /// + /// + public string AgvLeaveFryPotThree() + { + string url = ""; + string head = ""; + string body = ""; + return HttpRequest(url, head, body); + } + /// + /// AGV离开炒锅4 + /// + /// + public string AgvLeaveFryPotFour() + { + string url = ""; + string head = ""; + string body = ""; + return HttpRequest(url, head, body); + } + /// + /// AGV离开炒锅5 + /// + /// + public string AgvLeaveFryPotFive() + { + string url = ""; + string head = ""; + string body = ""; + return HttpRequest(url, head, body); + } } } diff --git a/BPASmartClient.Helper/RTrig.cs b/BPASmartClient.Helper/RTrig.cs index 86cd4ea4..469cebb6 100644 --- a/BPASmartClient.Helper/RTrig.cs +++ b/BPASmartClient.Helper/RTrig.cs @@ -15,7 +15,7 @@ namespace BPASmartClient.Helper private volatile static ConcurrentDictionary _Instance; public static RTrig GetInstance(string name) { - if (_Instance == null) _Instance = new ConcurrentDictionary(); + if (_Instance == null) _Instance = new ConcurrentDictionary(); if (!_Instance.ContainsKey(name)) _Instance.TryAdd(name, new RTrig()); return _Instance[name]; } diff --git a/BPASmartClient.Helper/ThreadManage.cs b/BPASmartClient.Helper/ThreadManage.cs index 479efa1a..47598773 100644 --- a/BPASmartClient.Helper/ThreadManage.cs +++ b/BPASmartClient.Helper/ThreadManage.cs @@ -32,6 +32,10 @@ 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/Control/DosingLogicControl.cs b/FryPot_DosingSystem/Control/DosingLogicControl.cs index fcce3b34..829f849c 100644 --- a/FryPot_DosingSystem/Control/DosingLogicControl.cs +++ b/FryPot_DosingSystem/Control/DosingLogicControl.cs @@ -1,4 +1,6 @@ -using BPASmartClient.Helper; +using BPASmartClient.AGV; +using BPASmartClient.Helper; +using BPASmartClient.Message; using FryPot_DosingSystem.Model; using System; using System.Collections.Concurrent; @@ -14,13 +16,78 @@ namespace FryPot_DosingSystem.Control internal class DosingLogicControl { public static DosingLogicControl _instance; - public static DosingLogicControl GetInstance=>_instance ??= new DosingLogicControl(); - public ConcurrentDictionary PlcReadData=new ConcurrentDictionary(); + public static DosingLogicControl GetInstance => _instance ??= new DosingLogicControl(); + public ConcurrentDictionary PlcReadData = new ConcurrentDictionary(); + /// + /// 配方队列 + /// + public ConcurrentQueue RecipeQuene = new ConcurrentQueue(); + /// + /// 进料原料队列 + /// + public ConcurrentQueue InputMaterialQuene = new ConcurrentQueue(); + /// + /// 出料原料队列 + /// + public ConcurrentQueue OutputMaterialQuene = new ConcurrentQueue(); + /// + /// 全局变量对象声明 + /// + GlobalVariable globalVar; + + #region 上位机内部变量 + int lineAlarm = 0;//线体故障信号 1:无故障 -1:故障 + int FryPotAlarm = 0;//炒锅滚筒故障信号 1:无故障 -1:故障 + int ReicpeNum = 0;//记录接收到的配方数 + #endregion + #region agv临时变量 + bool agvArriveLine = false;//agv是否到达线体装料位置 + bool agvArriveFryPot = false;//agv是否到达炒锅送料位置 + bool agvFryPotEmptyRollerArrive = false;//agv是否拿到炒锅空桶 + #endregion public DosingLogicControl() { + globalVar = new GlobalVariable(); + ActionManage.GetInstance.Register(new Action(RecipeDataParse), "RecipeSetDown"); + ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.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"); + ResetProgram(); + ReadPlcData(); IniteTask(); } /// + /// 主任务重启 + /// + private void ResetProgram() + { + ThreadManage.GetInstance().StartLong(new Action(() => + { + if (RTrig.GetInstance("ResetProgram").Start(globalVar.PlcInite == 1))//判断是否初始化 一初始化就重启主任务 + { + MessageLog.GetInstance.Show("主任务正在重启"); + ThreadManage.GetInstance().StopTask("MainTask", new Action(() => + { + ThreadManage.GetInstance().StopTask("MainViewReadPlcData", 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.Show("主任务重启完成"); + })); + })); + } + + Thread.Sleep(10); + }), "ResetProgram"); + } + /// /// 实时获取plc数据 /// public void ReadPlcData() @@ -29,93 +96,96 @@ namespace FryPot_DosingSystem.Control { GetAddressData("D2001", new Action((data) => { - GlobalVariable.rollerLineOne.StationOne = data[0]; - GlobalVariable.rollerLineOne.StationTwo = data[1]; - GlobalVariable.rollerLineOne.StationThree = data[2]; - GlobalVariable.rollerLineOne.StationFour = data[3]; - GlobalVariable.rollerLineOne.StationFive = data[4]; - GlobalVariable.rollerLineOne.StationSix = data[5]; - GlobalVariable.rollerLineOne.StationSeven = data[6]; - GlobalVariable.rollerLineOne.StationEight = data[7]; + globalVar.rollerLineOne.StationOne = data[0]; + globalVar.rollerLineOne.StationTwo = data[1]; + globalVar.rollerLineOne.StationThree = data[2]; + globalVar.rollerLineOne.StationFour = data[3]; + globalVar.rollerLineOne.StationFive = data[4]; + globalVar.rollerLineOne.StationSix = data[5]; + globalVar.rollerLineOne.StationSeven = data[6]; + globalVar.rollerLineOne.StationEight = data[7]; })); GetAddressData("D2011", new Action((data) => { - GlobalVariable.rollerLineTwo.StationOne = data[0]; - GlobalVariable.rollerLineTwo.StationTwo = data[1]; - GlobalVariable.rollerLineTwo.StationThree = data[2]; - GlobalVariable.rollerLineTwo.StationFour = data[3]; - GlobalVariable.rollerLineTwo.StationFive = data[4]; - GlobalVariable.rollerLineTwo.StationSix = data[5]; - GlobalVariable.rollerLineTwo.StationSeven = data[6]; - GlobalVariable.rollerLineTwo.StationEight = data[7]; + globalVar.rollerLineTwo.StationOne = data[0]; + globalVar.rollerLineTwo.StationTwo = data[1]; + globalVar.rollerLineTwo.StationThree = data[2]; + globalVar.rollerLineTwo.StationFour = data[3]; + globalVar.rollerLineTwo.StationFive = data[4]; + globalVar.rollerLineTwo.StationSix = data[5]; + globalVar.rollerLineTwo.StationSeven = data[6]; + globalVar.rollerLineTwo.StationEight = data[7]; })); GetAddressData("D2021", new Action((data) => { - GlobalVariable.rollerLineThree.StationOne = data[0]; - GlobalVariable.rollerLineThree.StationTwo = data[1]; - GlobalVariable.rollerLineThree.StationThree = data[2]; - GlobalVariable.rollerLineThree.StationFour = data[3]; - GlobalVariable.rollerLineThree.StationFive = data[4]; - GlobalVariable.rollerLineThree.StationSix = data[5]; - GlobalVariable.rollerLineThree.StationSeven = data[6]; - GlobalVariable.rollerLineThree.StationEight = data[7]; + globalVar.rollerLineThree.StationOne = data[0]; + globalVar.rollerLineThree.StationTwo = data[1]; + globalVar.rollerLineThree.StationThree = data[2]; + globalVar.rollerLineThree.StationFour = data[3]; + globalVar.rollerLineThree.StationFive = data[4]; + globalVar.rollerLineThree.StationSix = data[5]; + globalVar.rollerLineThree.StationSeven = data[6]; + globalVar.rollerLineThree.StationEight = data[7]; })); GetAddressData("D2040", new Action((data) => { - GlobalVariable.fryPotOne.InputMaterialRollerRunningSingle = data[0]; - GlobalVariable.fryPotTwo.InputMaterialRollerRunningSingle = data[1]; - GlobalVariable.fryPotThree.InputMaterialRollerRunningSingle = data[2]; - GlobalVariable.fryPotFour.InputMaterialRollerRunningSingle = data[3]; - GlobalVariable.fryPotFive.InputMaterialRollerRunningSingle= data[4]; + globalVar.fryPotOne.InputMaterialRollerRunningSingle = data[0]; + globalVar.fryPotTwo.InputMaterialRollerRunningSingle = data[1]; + globalVar.fryPotThree.InputMaterialRollerRunningSingle = data[2]; + globalVar.fryPotFour.InputMaterialRollerRunningSingle = data[3]; + globalVar.fryPotFive.InputMaterialRollerRunningSingle = data[4]; })); GetAddressData("D2045", new Action((data) => { - GlobalVariable.fryPotOne.InputMaterialArrivedSingle = data[0]; - GlobalVariable.fryPotTwo.InputMaterialArrivedSingle = data[1]; - GlobalVariable.fryPotThree.InputMaterialArrivedSingle = data[2]; - GlobalVariable.fryPotFour.InputMaterialArrivedSingle = data[3]; - GlobalVariable.fryPotFive.InputMaterialArrivedSingle = data[4]; + globalVar.fryPotOne.InputMaterialArrivedSingle = data[0]; + globalVar.fryPotTwo.InputMaterialArrivedSingle = data[1]; + globalVar.fryPotThree.InputMaterialArrivedSingle = data[2]; + globalVar.fryPotFour.InputMaterialArrivedSingle = data[3]; + globalVar.fryPotFive.InputMaterialArrivedSingle = data[4]; })); GetAddressData("D2050", new Action((data) => { - GlobalVariable.fryPotOne.EmptyBarrelArrivedSingle = data[0]; - GlobalVariable.fryPotTwo.EmptyBarrelArrivedSingle = data[1]; - GlobalVariable.fryPotThree.EmptyBarrelArrivedSingle = data[2]; - GlobalVariable.fryPotFour.EmptyBarrelArrivedSingle = data[3]; - GlobalVariable.fryPotFive.EmptyBarrelArrivedSingle = data[4]; + globalVar.fryPotOne.EmptyBarrelArrivedSingle = data[0]; + globalVar.fryPotTwo.EmptyBarrelArrivedSingle = data[1]; + globalVar.fryPotThree.EmptyBarrelArrivedSingle = data[2]; + globalVar.fryPotFour.EmptyBarrelArrivedSingle = data[3]; + globalVar.fryPotFive.EmptyBarrelArrivedSingle = data[4]; })); GetAddressData("D2065", new Action((data) => { - GlobalVariable.fryPotOne.EmptyBarrelRollerRunningSingle = data[0]; - GlobalVariable.fryPotTwo.EmptyBarrelRollerRunningSingle = data[1]; - GlobalVariable.fryPotThree.EmptyBarrelRollerRunningSingle = data[2]; - GlobalVariable.fryPotFour.EmptyBarrelRollerRunningSingle = data[3]; - GlobalVariable.fryPotFive.EmptyBarrelRollerRunningSingle = data[4]; + globalVar.fryPotOne.EmptyBarrelRollerRunningSingle = data[0]; + globalVar.fryPotTwo.EmptyBarrelRollerRunningSingle = data[1]; + globalVar.fryPotThree.EmptyBarrelRollerRunningSingle = data[2]; + globalVar.fryPotFour.EmptyBarrelRollerRunningSingle = data[3]; + globalVar.fryPotFive.EmptyBarrelRollerRunningSingle = data[4]; })); GetAddressData("D2070", new Action((data) => { - GlobalVariable.fryPotOne.RollerTroubleSingle = data[0]; - GlobalVariable.fryPotTwo.RollerTroubleSingle = data[1]; - GlobalVariable.fryPotThree.RollerTroubleSingle = data[2]; - GlobalVariable.fryPotFour.RollerTroubleSingle = data[3]; - GlobalVariable.fryPotFive.RollerTroubleSingle = data[4]; + globalVar.fryPotOne.RollerTroubleSingle = data[0]; + globalVar.fryPotTwo.RollerTroubleSingle = data[1]; + globalVar.fryPotThree.RollerTroubleSingle = data[2]; + globalVar.fryPotFour.RollerTroubleSingle = data[3]; + globalVar.fryPotFive.RollerTroubleSingle = data[4]; })); - GetAddressData("D2078",new Action(data => { - GlobalVariable.rollerLineOne.RecipeCompleteSingle = data[0]; - GlobalVariable.rollerLineTwo.RecipeCompleteSingle = data[1]; - GlobalVariable.rollerLineThree.RecipeCompleteSingle = data[2]; + GetAddressData("D2078", new Action(data => + { + globalVar.rollerLineOne.RecipeCompleteSingle = data[0]; + globalVar.rollerLineTwo.RecipeCompleteSingle = data[1]; + globalVar.rollerLineThree.RecipeCompleteSingle = data[2]; })); - GetAddressData("D2075",new Action(data => { - - GlobalVariable.CleadBarrelEnterSingle = data[0]; + GetAddressData("D2075", new Action(data => + { + + globalVar.CleadBarrelEnterSingle = data[0]; })); - GetAddressData("D2077", new Action(data => { + GetAddressData("D2077", new Action(data => + { - GlobalVariable.CleadBarrelExitSingle = data[0]; + globalVar.CleadBarrelExitSingle = data[0]; })); Thread.Sleep(10); }), "MainViewReadPlcData"); - + } /// @@ -125,7 +195,7 @@ namespace FryPot_DosingSystem.Control /// public void GetAddressData(string address, Action action) { - PlcReadData= DeviceOperate.GetInstance.GetAllData(); + PlcReadData = DeviceOperate.GetInstance.GetAllData(); if (PlcReadData.ContainsKey(address)) { action((ushort[])(PlcReadData[address])); @@ -137,7 +207,7 @@ namespace FryPot_DosingSystem.Control /// /// public void WritePlcData(string address, ushort Value) - { + { DeviceOperate.GetInstance.WritePlcData(address, Value); } /// @@ -145,18 +215,655 @@ namespace FryPot_DosingSystem.Control /// public void IniteTask() { - ThreadManage.GetInstance().StartLong(new Action(() => { - + ThreadManage.GetInstance().StartLong(new Action(() => + { MainTask(); - }),"启动主任务循环",true); + }), "MainTask"); + } + /// + /// 配方数据接收 + /// + public void RecipeDataParse(object obj) + { + if (obj != null && obj is NewRecipeModel recipe) + { + RecipeQuene.Enqueue(recipe); + ReicpeNum++; + MessageLog.GetInstance.Show($"接收到{ReicpeNum}个配方"); + } + } /// /// 开启主任务 /// public void MainTask() - { - - + { + RecipeDataToPlc(); + AgvLoadRoller(); + FryPotInputMaterial(); + FryPotOutputMaterial(); + } + /// + /// 数据下发PLC + /// + public void RecipeDataToPlc() + { + if (RecipeQuene.Count > 0 && OutputMaterialQuene.Count == 0 && InputMaterialQuene.Count == 0)//后续添加其它限制条件 + { + + if (RecipeQuene.TryDequeue(out NewRecipeModel result)) + { + MessageLog.GetInstance.Show($"开始制作【{result.RecipeName}】 配方"); + for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料 + { + //将配方中原料加入新的队列 + InputMaterialQuene.Enqueue(new MaterialInfo() + { + materialType = result.materialCollection[i], + materialId = result.RecipeId + }); + ushort n = result.materialCollection[i].MaterialLoc; + switch (n / 100) + { + case 1: + case 4: RollerOneDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//1号滚筒线桶号以及重量数据下发 + case 2: + case 5: RollerTwoDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//2号滚筒线桶号以及重量数据下发 + case 3: RollerThreeDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//3号滚筒线桶号以及重量数据下发 + } + } + switch (result.materialCollection[0].MaterialLoc / 100) + { + case 1: + DeviceOperate.GetInstance.WritePlcData("D1009", (ushort)result.materialCollection.Count); break;//发送1号滚筒线工序数据 + case 2: + DeviceOperate.GetInstance.WritePlcData("D1026", (ushort)result.materialCollection.Count); break;//发送2号滚筒线工序数据 + case 3: + DeviceOperate.GetInstance.WritePlcData("D1043", (ushort)result.materialCollection.Count); break;//发送3号滚筒线工序数据 + } + } + } + + } + /// + /// AGV到配方对应线体装桶以及出料到炒锅 + /// + public void AgvLoadRoller() + { + lineAlarm = 0; + if (InputMaterialQuene.Count > 0) + { + switch (InputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100) + { + case 1: + case 4: AgvToLineOneLoadRoller(); AgvFromLineOneToFryPot(); break;//AGV到1号线体装桶 + case 2: + case 5: AgvToLineTwoLoadRoller(); AgvFromLineTwoToFryPot(); break;//AGV到2号线体装桶 + case 3: AgvToLineThreeLoadRoller(); AgvFromLineThreeToFryPot(); break;//AGV到3号线体装桶 + } + } + + } + /// + /// AGV从炒锅送料位置到倒料过程处理 + /// + public void FryPotInputMaterial() + { + if (OutputMaterialQuene.Count > 0 && !globalVar.InOrOutputLock) + { + while (!agvArriveFryPot)//等待agv到达炒锅位置 + { + Thread.Sleep(5); + if (globalVar.ExitMainTask) + return; + } + AgvArriveFryPotSingleSetDown(); + FryPotRollerTroubleCheck(); + if (FryPotAlarm == 1)//炒锅滚筒无故障 + { + //炒锅滚筒进料运行到位处理 + FryPotInputMaterialRollerOperate(); + globalVar.InOrOutputLock = true; + } + else + { + //MessageLog.GetInstance.ShowEx($"警告:炒锅{OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100}滚筒故障!!!"); + } + } + + } + /// + /// 炒锅出桶 + /// + public void FryPotOutputMaterial() + { + if (OutputMaterialQuene.Count > 0 && globalVar.InOrOutputLock) + { + while (!agvArriveFryPot)//等待agv到达炒锅位置 + { + Thread.Sleep(5); + if (globalVar.ExitMainTask) + return; + } + AgvArriveFryPotOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号 + FryPotRollerTroubleCheck(); + if (FryPotAlarm == 1)//无故障 + { + FryPotOutEmpetyRollerOperate(); + if (OutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料 + { + while (!agvFryPotEmptyRollerArrive)//等待AGV拿到出桶空桶 + { + Thread.Sleep(5); + if (globalVar.ExitMainTask) + return; + } + //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅 + globalVar.AllowAgvToLineLoadRoller = true; + globalVar.InOrOutputLock = false; + } + } + else//有故障 + { + + } + } + } + /// + /// 炒锅滚筒进料运行到位处理 + /// + public void FryPotInputMaterialRollerOperate() + { + switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100) + { + case 1: + while (globalVar.fryPotOne.InputMaterialArrivedSingle == 0 || globalVar.fryPotOne.InputMaterialRollerRunningSingle == 0) + { + Thread.Sleep(5); if (globalVar.ExitMainTask) + return; + } + MessageLog.GetInstance.Show($"炒锅【1】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break; + case 2: + while (globalVar.fryPotTwo.InputMaterialArrivedSingle == 0 || globalVar.fryPotTwo.InputMaterialRollerRunningSingle == 0) + { + Thread.Sleep(5); if (globalVar.ExitMainTask) + return; + } + MessageLog.GetInstance.Show($"炒锅【2】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break; + case 3: + while (globalVar.fryPotThree.InputMaterialArrivedSingle == 0 || globalVar.fryPotThree.InputMaterialRollerRunningSingle == 0) + { + Thread.Sleep(5); if (globalVar.ExitMainTask) + return; + } + MessageLog.GetInstance.Show($"炒锅【3】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break; + case 4: + while (globalVar.fryPotFour.InputMaterialArrivedSingle == 0 || globalVar.fryPotFour.InputMaterialRollerRunningSingle == 0) + { + Thread.Sleep(5); if (globalVar.ExitMainTask) + return; + } + MessageLog.GetInstance.Show($"炒锅【4】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break; + case 5: + while (globalVar.fryPotFive.InputMaterialArrivedSingle == 0 || globalVar.fryPotFive.InputMaterialRollerRunningSingle == 0) + { + Thread.Sleep(5); if (globalVar.ExitMainTask) + return; + } + MessageLog.GetInstance.Show($"炒锅【5】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break; + } + + } + /// + /// 炒锅滚筒空桶出桶处理 + /// + public void FryPotOutEmpetyRollerOperate() + { + switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100) + { + case 1: while (globalVar.fryPotOne.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotOne.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask) + return; + } MessageLog.GetInstance.Show($"炒锅【1】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break; + case 2: while (globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotTwo.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask) + return; + } MessageLog.GetInstance.Show($"炒锅【2】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break; + case 3: while (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotThree.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask) + return; + } MessageLog.GetInstance.Show($"炒锅【3】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break; + case 4: while (globalVar.fryPotFour.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotFour.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask) + return; + } MessageLog.GetInstance.Show($"炒锅【4】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break; + case 5: while (globalVar.fryPotFive.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotFive.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask) + return; + } MessageLog.GetInstance.Show($"炒锅【5】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break; + + } + } + /// + /// 发送agv送料就位信号至PLC(线体到炒锅) + /// + public void AgvArriveFryPotSingleSetDown() + { + switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100) + { + case 1: DeviceOperate.GetInstance.WritePlcData("D1055", 1); break;//agv到炒锅1送料就位信号 + case 2: DeviceOperate.GetInstance.WritePlcData("D1056", 1); break;//agv到炒锅2送料就位信号 + case 3: DeviceOperate.GetInstance.WritePlcData("D1057", 1); break;//agv到炒锅3送料就位信号 + case 4: DeviceOperate.GetInstance.WritePlcData("D1058", 1); break;//agv到炒锅4送料就位信号 + case 5: DeviceOperate.GetInstance.WritePlcData("D1059", 1); break;//agv到炒锅5送料就位信号 + } + } + /// + /// 发送agv回桶就位信号至PLC + /// + public void AgvArriveFryPotOutEmptyRollerSingleSetDown() + { + switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100) + { + case 1: DeviceOperate.GetInstance.WritePlcData("D1060", 1); break;//agv到炒锅1送料就位信号 + case 2: DeviceOperate.GetInstance.WritePlcData("D1061", 1); break;//agv到炒锅2送料就位信号 + case 3: DeviceOperate.GetInstance.WritePlcData("D1062", 1); break;//agv到炒锅3送料就位信号 + case 4: DeviceOperate.GetInstance.WritePlcData("D1063", 1); break;//agv到炒锅4送料就位信号 + case 5: DeviceOperate.GetInstance.WritePlcData("D1064", 1); break;//agv到炒锅5送料就位信号 + } + } + /// + /// 处理agv从线体1到送料到炒锅的条件 + /// + /// + public void AgvFromLineOneToFryPot() + { + erp: if (lineAlarm == 1)//无故障 + { + while (!agvArriveLine)//等待AGV到线体装料位置 + { + Thread.Sleep(5); + if (globalVar.ExitMainTask) + return; + } + agvArriveLine = false; + AgvArriveLineSingelSetDown(); + if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo)) + { + while (!(globalVar.rollerLineOne.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号 + { + Thread.Sleep(5); + if (globalVar.ExitMainTask) + return; + } + OutputMaterialQuene.Enqueue(materialInfo); + //原料到位,agv到位,agv运料到炒锅 + } + + } + else//有故障 + { + while (lineAlarm == -1) + { + Thread.Sleep(50); + if (globalVar.ExitMainTask) + return; + } + MessageLog.GetInstance.Show("线体【1】滚筒故障解除,继续运行"); + lineAlarm = 1; + goto erp; + } + } + /// + /// 处理agv从线体2到送料到炒锅的条件 + /// + /// + public void AgvFromLineTwoToFryPot() + { + erp: if (lineAlarm == 1)//无故障 + { + while (!agvArriveLine)//等待AGV到线体装料位置 + { + Thread.Sleep(5); + if (globalVar.ExitMainTask) + return; + } + agvArriveLine = false; + AgvArriveLineSingelSetDown(); + if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo)) + { + while (!(globalVar.rollerLineTwo.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号 + { + Thread.Sleep(5); + if (globalVar.ExitMainTask) + return; + } + OutputMaterialQuene.Enqueue(materialInfo); + //原料到位,agv到位,agv运料到炒锅 + } + + } + else//有故障 + { + while (lineAlarm == -1) + { + Thread.Sleep(50); + if (globalVar.ExitMainTask) + return; + } + MessageLog.GetInstance.Show("线体【2】滚筒故障解除,继续运行"); + lineAlarm = 1; + goto erp; + } } + /// + /// 处理agv从线体3到送料到炒锅的条件 + /// + /// + public void AgvFromLineThreeToFryPot() + { + erp: if (lineAlarm == 1)//无故障 + { + while (!agvArriveLine)//等待AGV到线体装料位置 + { + Thread.Sleep(5); + if (globalVar.ExitMainTask) + return; + } + agvArriveLine = false; + AgvArriveLineSingelSetDown(); + if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo)) + { + while (!(globalVar.rollerLineThree.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号 + { + Thread.Sleep(5); + if (globalVar.ExitMainTask) + return; + } + OutputMaterialQuene.Enqueue(materialInfo); + //原料到位,agv到位,agv运料到炒锅 + } + + } + else//有故障 + { + while (lineAlarm == -1) + { + Thread.Sleep(50); + if (globalVar.ExitMainTask) + return; + } + MessageLog.GetInstance.Show("线体【3】滚筒故障解除,继续运行"); + lineAlarm = 1; + goto erp; + } + } + public void AgvToLineOneLoadRoller() + { + if (globalVar.rollerLineOne.OutMaterialingTroubleSingle == 0)//输送线无故障 + { + if (InputMaterialQuene.Count > 0) + { + while (!globalVar.AllowAgvToLineLoadRoller || globalVar.rollerLineOne.OutMaterialingSingle == 0) + { + Thread.Sleep(5); + if (globalVar.ExitMainTask) + return; + } + AGVHelper.GetInstance.AgvToLineOneLoadRoller(); + MessageLog.GetInstance.Show("AGV去1号线体"); + globalVar.AllowAgvToLineLoadRoller = false; + } + } + else + { + MessageLog.GetInstance.ShowEx("警告:滚筒输送线体【1】故障!!!"); + lineAlarm = -1; + } + lineAlarm = 1; + } + public void AgvToLineTwoLoadRoller() + { + if (globalVar.rollerLineTwo.OutMaterialingTroubleSingle == 0)//输送线无故障 + { + if (InputMaterialQuene.Count > 0) + { + while (!globalVar.AllowAgvToLineLoadRoller || globalVar.rollerLineOne.OutMaterialingSingle == 0) //后续考虑是否用while + { + Thread.Sleep(5); + if (globalVar.ExitMainTask) + return; + } + AGVHelper.GetInstance.AgvToLineTwoLoadRoller(); + MessageLog.GetInstance.Show("AGV去2号线体"); + globalVar.AllowAgvToLineLoadRoller = false; + } + + } + else + { + MessageLog.GetInstance.ShowEx("警告:滚筒输送线体【2】故障!!!"); + lineAlarm = -1; + } + lineAlarm = 1; + } + public void AgvToLineThreeLoadRoller() + { + if (globalVar.rollerLineThree.OutMaterialingTroubleSingle == 0)//输送线无故障 + { + if (InputMaterialQuene.Count > 0) + { + while (!globalVar.AllowAgvToLineLoadRoller || globalVar.rollerLineOne.OutMaterialingSingle == 0) //后续考虑是否用while + { + Thread.Sleep(5); + if (globalVar.ExitMainTask) + return; + } + AGVHelper.GetInstance.AgvToLineThreeLoadRoller(); + MessageLog.GetInstance.Show("AGV去3号线体"); + globalVar.AllowAgvToLineLoadRoller = false; + } + + } + else + { + MessageLog.GetInstance.ShowEx("警告:滚筒输送线体【3】故障!!!"); + lineAlarm = -1; + } + lineAlarm = 1; + } + /// + /// 1号线体数据下发 + /// + /// + /// + /// + public void RollerOneDataWrite(int count, ushort materialLoc, ushort materialWeight) + { + switch (count) + { + case 0: + DeviceOperate.GetInstance.WritePlcData("D1001", materialLoc);//桶1位置 + DeviceOperate.GetInstance.WritePlcData("D1010", materialWeight);//桶2重量 + break; + case 1: + DeviceOperate.GetInstance.WritePlcData("D1002", materialLoc);//桶2位置 + DeviceOperate.GetInstance.WritePlcData("D1011", materialWeight);//桶2重量 + break; + case 2: + DeviceOperate.GetInstance.WritePlcData("D1003", materialLoc);//桶3位置 + DeviceOperate.GetInstance.WritePlcData("D1012", materialWeight);//桶3重量 + break; + case 3: + DeviceOperate.GetInstance.WritePlcData("D1004", materialLoc);//桶4位置 + DeviceOperate.GetInstance.WritePlcData("D1013", materialWeight);//桶4重量 + break; + case 4: + DeviceOperate.GetInstance.WritePlcData("D1005", materialLoc);//桶5位置 + DeviceOperate.GetInstance.WritePlcData("D1014", materialWeight);//桶5重量 + break; + case 5: + DeviceOperate.GetInstance.WritePlcData("D1006", materialLoc);//桶6位置 + DeviceOperate.GetInstance.WritePlcData("D1015", materialWeight);//桶6重量 + break; + case 6: + DeviceOperate.GetInstance.WritePlcData("D1007", materialLoc);//桶7位置 + DeviceOperate.GetInstance.WritePlcData("D1016", materialWeight);//桶7重量 + break; + case 7: + DeviceOperate.GetInstance.WritePlcData("D1008", materialLoc);//桶8位置 + DeviceOperate.GetInstance.WritePlcData("D1017", materialWeight);//桶8重量 + break; + + } + } + /// + /// 2号线体数据下发 + /// + /// + /// + /// + public void RollerTwoDataWrite(int count, ushort materialLoc, ushort materialWeight) + { + switch (count) + { + case 0: + DeviceOperate.GetInstance.WritePlcData("D1018", materialLoc);//桶1位置 + DeviceOperate.GetInstance.WritePlcData("D1027", materialWeight);//桶2重量 + break; + case 1: + DeviceOperate.GetInstance.WritePlcData("D1019", materialLoc);//桶2位置 + DeviceOperate.GetInstance.WritePlcData("D1028", materialWeight);//桶2重量 + break; + case 2: + DeviceOperate.GetInstance.WritePlcData("D1020", materialLoc);//桶3位置 + DeviceOperate.GetInstance.WritePlcData("D1029", materialWeight);//桶3重量 + break; + case 3: + DeviceOperate.GetInstance.WritePlcData("D1021", materialLoc);//桶4位置 + DeviceOperate.GetInstance.WritePlcData("D1030", materialWeight);//桶4重量 + break; + case 4: + DeviceOperate.GetInstance.WritePlcData("D1022", materialLoc);//桶5位置 + DeviceOperate.GetInstance.WritePlcData("D1031", materialWeight);//桶5重量 + break; + case 5: + DeviceOperate.GetInstance.WritePlcData("D1023", materialLoc);//桶6位置 + DeviceOperate.GetInstance.WritePlcData("D1032", materialWeight);//桶6重量 + break; + case 6: + DeviceOperate.GetInstance.WritePlcData("D1024", materialLoc);//桶7位置 + DeviceOperate.GetInstance.WritePlcData("D1033", materialWeight);//桶7重量 + break; + case 7: + DeviceOperate.GetInstance.WritePlcData("D1025", materialLoc);//桶8位置 + DeviceOperate.GetInstance.WritePlcData("D1034", materialWeight);//桶8重量 + break; + + } + } + /// + /// 3号线体数据下发 + /// + /// + /// + /// + public void RollerThreeDataWrite(int count, ushort materialLoc, ushort materialWeight) + { + switch (count) + { + case 0: + DeviceOperate.GetInstance.WritePlcData("D1035", materialLoc);//桶1位置 + DeviceOperate.GetInstance.WritePlcData("D1044", materialWeight);//桶2重量 + break; + case 1: + DeviceOperate.GetInstance.WritePlcData("D1036", materialLoc);//桶2位置 + DeviceOperate.GetInstance.WritePlcData("D1045", materialWeight);//桶2重量 + break; + case 2: + DeviceOperate.GetInstance.WritePlcData("D1037", materialLoc);//桶3位置 + DeviceOperate.GetInstance.WritePlcData("D1046", materialWeight);//桶3重量 + break; + case 3: + DeviceOperate.GetInstance.WritePlcData("D1038", materialLoc);//桶4位置 + DeviceOperate.GetInstance.WritePlcData("D1047", materialWeight);//桶4重量 + break; + case 4: + DeviceOperate.GetInstance.WritePlcData("D1039", materialLoc);//桶5位置 + DeviceOperate.GetInstance.WritePlcData("D1048", materialWeight);//桶5重量 + break; + case 5: + DeviceOperate.GetInstance.WritePlcData("D1040", materialLoc);//桶6位置 + DeviceOperate.GetInstance.WritePlcData("D1049", materialWeight);//桶6重量 + break; + case 6: + DeviceOperate.GetInstance.WritePlcData("D1041", materialLoc);//桶7位置 + DeviceOperate.GetInstance.WritePlcData("D1050", materialWeight);//桶7重量 + break; + case 7: + DeviceOperate.GetInstance.WritePlcData("D1042", materialLoc);//桶8位置 + DeviceOperate.GetInstance.WritePlcData("D1051", materialWeight);//桶8重量 + break; + + } + + } + /// + /// AGV进料就位信号下发至PLC + /// + public void AgvArriveLineSingelSetDown() + { + switch (InputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100) + { + case 1: + case 4: DeviceOperate.GetInstance.WritePlcData("D1052", 1); break;//AGV进料就位信号1 + case 2: + case 5: DeviceOperate.GetInstance.WritePlcData("D1053", 1); break;//AGV进料就位信号2 + case 3: DeviceOperate.GetInstance.WritePlcData("D1054", 1); break;//AGV进料就位信号3 + } + + } + /// + /// 炒锅滚筒信号检测 + /// + public void FryPotRollerTroubleCheck() + { + FryPotAlarm = 0; + switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100) + { + case 1: + if (globalVar.fryPotOne.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotOne.RollerTroubleSingle == 1) + { + Thread.Sleep(50); if (globalVar.ExitMainTask) + return; + } + FryPotAlarm = 1; break; + case 2: + if (globalVar.fryPotTwo.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotTwo.RollerTroubleSingle == 1) + { + Thread.Sleep(50); if (globalVar.ExitMainTask) + return; + } + FryPotAlarm = 1; break; + case 3: + if (globalVar.fryPotThree.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotThree.RollerTroubleSingle == 1) + { + Thread.Sleep(50); if (globalVar.ExitMainTask) + return; + } + FryPotAlarm = 1; break; + case 4: + if (globalVar.fryPotFour.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotFour.RollerTroubleSingle == 1) + { + Thread.Sleep(50); if (globalVar.ExitMainTask) + return; + } + FryPotAlarm = 1; break; + case 5: + if (globalVar.fryPotFive.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotFive.RollerTroubleSingle == 1) + { + Thread.Sleep(50); if (globalVar.ExitMainTask) + return; + } + FryPotAlarm = 1; break; + + } + } + } } diff --git a/FryPot_DosingSystem/Control/GlobalVariable.cs b/FryPot_DosingSystem/Control/GlobalVariable.cs index 9c6df3cb..90119a8e 100644 --- a/FryPot_DosingSystem/Control/GlobalVariable.cs +++ b/FryPot_DosingSystem/Control/GlobalVariable.cs @@ -9,48 +9,70 @@ namespace FryPot_DosingSystem.Control /// /// plc变量 /// - internal static class GlobalVariable + internal class GlobalVariable { /// /// 滚筒线1 /// - public static RollerLineOne rollerLineOne = new RollerLineOne(); + public RollerLineOne rollerLineOne = new RollerLineOne(); /// /// 滚筒线2 /// - public static RollerLineTwo rollerLineTwo = new RollerLineTwo(); + public RollerLineTwo rollerLineTwo = new RollerLineTwo(); /// /// 滚筒线3 /// - public static RollerLineThree rollerLineThree = new RollerLineThree(); + public RollerLineThree rollerLineThree = new RollerLineThree(); /// /// 炒锅1 /// - public static FryPotOne fryPotOne= new FryPotOne(); + public FryPotOne fryPotOne= new FryPotOne(); /// /// 炒锅2 /// - public static FryPotTwo fryPotTwo= new FryPotTwo(); + public FryPotTwo fryPotTwo= new FryPotTwo(); /// /// 炒锅3 /// - public static FryPotThree fryPotThree= new FryPotThree(); + public FryPotThree fryPotThree= new FryPotThree(); /// /// 炒锅4 /// - public static FryPotFour fryPotFour= new FryPotFour(); + public FryPotFour fryPotFour= new FryPotFour(); /// /// 炒锅5 /// - public static FryPotFive fryPotFive= new FryPotFive(); + public FryPotFive fryPotFive= new FryPotFive(); /// /// 洗桶进桶滚筒运行信号 /// - public static ushort CleadBarrelEnterSingle { get; set; } + public ushort CleadBarrelEnterSingle { get; set; } /// /// 洗桶出桶滚筒运行信号 /// - public static ushort CleadBarrelExitSingle { get; set; } + public ushort CleadBarrelExitSingle { get; set; } + /// + /// PLC初始化状态 + /// + public ushort PlcInite { get; set; } + #region 上位机内部逻辑条件 + /// + /// 退出主任务循环 + /// + public bool ExitMainTask { get; set; } + /// + /// 允许AGV去线体装桶条件 + /// + public bool AllowAgvToLineLoadRoller { get; set; } = true; + /// + /// 配方唯一ID + /// + public string RecipeId { get; set; } + /// + /// 进桶出桶互锁 + /// + public bool InOrOutputLock { get; set; } + #endregion } /// @@ -102,6 +124,8 @@ namespace FryPot_DosingSystem.Control /// 当前线体配方完成信号 /// public ushort RecipeCompleteSingle { get; set; } + + } /// /// 滚筒线2相关变量 diff --git a/FryPot_DosingSystem/Control/MaterialInfo.cs b/FryPot_DosingSystem/Control/MaterialInfo.cs new file mode 100644 index 00000000..d01c47e1 --- /dev/null +++ b/FryPot_DosingSystem/Control/MaterialInfo.cs @@ -0,0 +1,15 @@ +using FryPot_DosingSystem.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FryPot_DosingSystem.Control +{ + internal class MaterialInfo + { + public MaterialType materialType { get; set;} + public string materialId { get; set; }//原料所属配方的唯一ID + } +} diff --git a/FryPot_DosingSystem/FryPot_DosingSystem.csproj b/FryPot_DosingSystem/FryPot_DosingSystem.csproj index abb88dad..a9bd93f1 100644 --- a/FryPot_DosingSystem/FryPot_DosingSystem.csproj +++ b/FryPot_DosingSystem/FryPot_DosingSystem.csproj @@ -21,6 +21,7 @@ + diff --git a/FryPot_DosingSystem/Model/MaterialType.cs b/FryPot_DosingSystem/Model/MaterialType.cs index 5a5a2503..8da0a32d 100644 --- a/FryPot_DosingSystem/Model/MaterialType.cs +++ b/FryPot_DosingSystem/Model/MaterialType.cs @@ -22,13 +22,13 @@ namespace FryPot_DosingSystem.Model /// /// 原料重量 /// - private string _materialWeight; - public string MaterialWeight { get { return _materialWeight; }set { _materialWeight = value;OnPropertyChanged(); } } + private ushort _materialWeight; + public ushort MaterialWeight { get { return _materialWeight; }set { _materialWeight = value;OnPropertyChanged(); } } /// /// 原料对应桶位置 /// - private string _materialLoc; - public string MaterialLoc { get { return _materialLoc; } set { _materialLoc = value; OnPropertyChanged(); } } + private ushort _materialLoc; + public ushort MaterialLoc { get { return _materialLoc; } set { _materialLoc = value; OnPropertyChanged(); } } } diff --git a/FryPot_DosingSystem/Model/RecipeModel.cs b/FryPot_DosingSystem/Model/RecipeModel.cs index b7015cb3..053bab08 100644 --- a/FryPot_DosingSystem/Model/RecipeModel.cs +++ b/FryPot_DosingSystem/Model/RecipeModel.cs @@ -22,7 +22,7 @@ namespace FryPot_DosingSystem.Model public string RecipeName { get { return _recipeName; } set { _recipeName = value;OnPropertyChanged(); } } /// - /// 配发下发状况信息 + /// 配方下发状况信息 /// private string _recipeSetInfo; public string RecipeSetInfo { get { return _recipeSetInfo; } set { _recipeSetInfo = value; OnPropertyChanged(); } } diff --git a/FryPot_DosingSystem/View/MainWindow.xaml b/FryPot_DosingSystem/View/MainWindow.xaml index d6cc90ee..42eaebc4 100644 --- a/FryPot_DosingSystem/View/MainWindow.xaml +++ b/FryPot_DosingSystem/View/MainWindow.xaml @@ -226,6 +226,11 @@ ScrollViewer.HorizontalScrollBarVisibility="Hidden" Margin="5,0,5,0" Content="开机启动" IsChecked="{Binding AutoStart}" /> + private UserInfo _currentLoginAccount; - public UserInfo CurrentLoginAccount { get { return _currentLoginAccount; } set { _currentLoginAccount = value;OnPropertyChanged(); } } + public UserInfo CurrentLoginAccount { get { return _currentLoginAccount; } set { _currentLoginAccount = value; OnPropertyChanged(); } } /// /// 不同权限显示不同菜单 /// @@ -47,6 +47,28 @@ namespace FryPot_DosingSystem.ViewModel /// public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } } + private bool _status; + /// + /// 设备初始化状态 + /// + public bool Status + { + get { return _status; } + set + { + if (value) + { + ActionManage.GetInstance.Send("StartPlcInite"); + } + else + { + ActionManage.GetInstance.Send("EndPlcInite"); + } + _status = value; + OnPropertyChanged(); + } + } + private Authority authority; public Authority Authority { @@ -65,15 +87,15 @@ namespace FryPot_DosingSystem.ViewModel } public MainViewModel() { - LogViewModel model= LogViewModel.GetInstance; - DeviceOperate deviceOperate=DeviceOperate.GetInstance;//开启实时PLC数据读取 + LogViewModel model = LogViewModel.GetInstance; + DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取 DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序 TogglePag = new RelayCommand(DoNavChanged); Login = new RelayCommand(() => { ActionManage.GetInstance.CancelRegister("ContentUpdate"); ActionManage.GetInstance.Register(new Func(() => { return "注册"; }), "ContentUpdate"); - DoNavChanged("AdministratorLoginView.用户登陆"); + DoNavChanged("AdministratorLoginView.用户登陆"); UserManagement = false; }); PasswordChange = new RelayCommand(() => @@ -106,7 +128,7 @@ namespace FryPot_DosingSystem.ViewModel menus.Add(new ActionMenu() { MenuName = "状态监测", CommandParameter = "HardWareStatusView.状态监测", Authority = new Authority[] { Authority.管理员, Authority.技术员, Authority.操作员, Authority.观察员 } }); menus.Add(new ActionMenu() { MenuName = "日志信息", CommandParameter = "LogView.日志信息", Authority = new Authority[] { Authority.管理员, Authority.技术员, Authority.操作员, Authority.观察员 } }); menus.Add(new ActionMenu() { MenuName = "报警记录", CommandParameter = "", Authority = new Authority[] { Authority.管理员, Authority.技术员, Authority.操作员, Authority.观察员 } }); - + } public void DoNavChanged(object obj) @@ -135,7 +157,7 @@ namespace FryPot_DosingSystem.ViewModel var strs = str.Split("-="); if (strs != null && strs.Length == 3) { - var us = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == strs[0] && p.Password == strs[1]&& strs[2] == p.Authority.ToString()); + var us = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == strs[0] && p.Password == strs[1] && strs[2] == p.Authority.ToString()); if (us != null) { Authority = us.Authority; diff --git a/FryPot_DosingSystem/ViewModel/RecipeSetDownViewModel.cs b/FryPot_DosingSystem/ViewModel/RecipeSetDownViewModel.cs index 7e1aacfa..08f064f1 100644 --- a/FryPot_DosingSystem/ViewModel/RecipeSetDownViewModel.cs +++ b/FryPot_DosingSystem/ViewModel/RecipeSetDownViewModel.cs @@ -1,4 +1,5 @@ using BPASmartClient.Helper; +using BPASmartClient.Message; using FryPot_DosingSystem.Model; using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; @@ -56,7 +57,9 @@ namespace FryPot_DosingSystem.ViewModel /// public void RecipeSetDown(NewRecipeModel recipeModel) { + ActionManage.GetInstance.Send("RecipeSetDown",recipeModel); recipeModel.RecipeSetInfo = "下发成功"; + } } } diff --git a/SmartClient.sln b/SmartClient.sln index ff853afa..c36c1760 100644 --- a/SmartClient.sln +++ b/SmartClient.sln @@ -100,7 +100,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTJuicer" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.AGV", "BPASmartClient.AGV\BPASmartClient.AGV.csproj", "{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MorkT_Show", "BPASmartClient.MorkT_Show\BPASmartClient.MorkT_Show.csproj", "{3653724D-3683-4722-B978-EB88DD4AE5DB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkT_Show", "BPASmartClient.MorkT_Show\BPASmartClient.MorkT_Show.csproj", "{3653724D-3683-4722-B978-EB88DD4AE5DB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FryPot_DosingSystem", "FryPot_DosingSystem\FryPot_DosingSystem.csproj", "{D638DFA2-D160-4D32-912F-385BC04A9382}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -936,6 +938,26 @@ Global {3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x64.Build.0 = Release|Any CPU {3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x86.ActiveCfg = Release|Any CPU {3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x86.Build.0 = Release|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|ARM.ActiveCfg = Debug|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|ARM.Build.0 = Debug|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|ARM64.Build.0 = Debug|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|x64.ActiveCfg = Debug|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|x64.Build.0 = Debug|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|x86.ActiveCfg = Debug|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|x86.Build.0 = Debug|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Release|Any CPU.Build.0 = Release|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Release|ARM.ActiveCfg = Release|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Release|ARM.Build.0 = Release|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Release|ARM64.ActiveCfg = Release|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Release|ARM64.Build.0 = Release|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Release|x64.ActiveCfg = Release|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Release|x64.Build.0 = Release|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Release|x86.ActiveCfg = Release|Any CPU + {D638DFA2-D160-4D32-912F-385BC04A9382}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -982,6 +1004,7 @@ Global {724087A3-E7E7-4494-B844-414FF5CD1D40} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} {507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} {3653724D-3683-4722-B978-EB88DD4AE5DB} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} + {D638DFA2-D160-4D32-912F-385BC04A9382} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC}