From 1d3c4cf335d44da1e1270b7f54ed803df6773cfa Mon Sep 17 00:00:00 2001 From: pengliangyang <1406009520@qq.com> Date: Tue, 7 Mar 2023 17:33:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/Model/AlarmHelper.cs | 2 +- .../Pages/View/RunLogView.xaml | 2 +- .../Pages/View/UserLogView.xaml | 2 +- BPASmartClient.JXJFoodBigStation/App.xaml.cs | 11 +- .../BPASmartClient.JXJFoodBigStation.csproj | 7 + .../Model/GVL_BigStation.cs | 59 +- .../Model/HK_PLC/HKDeviceStatus.cs | 14 +- .../Model/HK_PLC/HKPlcCommAddress.cs | 13 - .../Model/HK_PLC/StockBinName.cs | 28 +- .../Model/HardWare/BomMaterial.cs | 16 + .../Model/ProcessControl.cs | 901 +++++++---- .../Model/RawMaterial/RawMaterial.cs | 14 +- .../Model/Siemens/SiemensDeviceStatus.cs | 77 +- .../View/BomOfMaterialView.xaml | 122 ++ .../View/BomOfMaterialView.xaml.cs | 28 + .../View/ManualFlowView.xaml | 85 +- .../View/SiemensRecipeSendDownView.xaml | 2 +- .../View/StockBinRawMaterialView.xaml | 36 +- .../ViewModel/BomOfMaterialViewModel.cs | 75 + .../ViewModel/ManualFlowViewModel.cs | 69 +- .../ViewModel/RecipeInfosViewModel.cs | 10 +- .../ViewModel/RecipeSendDownViewModel.cs | 2 +- .../ViewModel/StockBinRawMaterialViewModel.cs | 28 +- .../App.xaml.cs | 9 +- .../Model/GVL/PlcCommAttribute.cs | 20 + .../Model/GVL/PlcInfos.cs | 27 + .../Model/GVL_SmallStation.cs | 73 +- .../Model/HK_PLC/DataComm.cs | 41 - .../Model/HK_PLC/HKDeviceRead.cs | 16 + .../Model/HK_PLC/HKDeviceStatus.cs | 71 +- .../Model/HK_PLC/PlcReadAddressDB3.cs | 171 ++- .../Model/ProcessControl.cs | 1315 ++++++++++------- .../Model/RawMaterial/DeviceInquire.cs | 8 +- .../Model/RawMaterial/DeviceParModel.cs | 3 + .../Model/Siemens/RemoteRecipeData.cs | 1 + .../Model/Siemens/RemoteRecipeDataColl.cs | 2 + .../Model/Siemens/SiemensDeviceStatus.cs | 58 +- .../View/DeviceMaterialParView.xaml | 33 +- .../View/ManualFlowView.xaml | 4 +- .../View/PlcVarMonitorView.xaml | 99 ++ .../View/PlcVarMonitorView.xaml.cs | 28 + .../View/RobotView.xaml | 197 +-- .../ViewModel/ManualFlowViewModel.cs | 34 +- .../ViewModel/PlcVarMonitorViewModel.cs | 23 + .../ViewModel/RobotViewModel.cs | 87 +- .../ViewModel/StockBinRawMaterialViewModel.cs | 2 +- BPASmartClient.JakaRobot/JaKaHelper.cs | 3 +- BPASmartClient.S7Net/EntityClassResolution.cs | 2 +- .../ViewModel/RecipeControlViewModel.cs | 2 +- SmartClient.sln | 4 +- WpfControlLibrary1/AssemblyInfo.cs | 10 + WpfControlLibrary1/UserControl1.xaml | 12 + WpfControlLibrary1/UserControl1.xaml.cs | 28 + WpfControlLibrary1/WpfControlLibrary1.csproj | 9 + 54 files changed, 2699 insertions(+), 1296 deletions(-) delete mode 100644 BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs create mode 100644 BPASmartClient.JXJFoodBigStation/Model/HardWare/BomMaterial.cs create mode 100644 BPASmartClient.JXJFoodBigStation/View/BomOfMaterialView.xaml create mode 100644 BPASmartClient.JXJFoodBigStation/View/BomOfMaterialView.xaml.cs create mode 100644 BPASmartClient.JXJFoodBigStation/ViewModel/BomOfMaterialViewModel.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/GVL/PlcCommAttribute.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/GVL/PlcInfos.cs delete mode 100644 BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/DataComm.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceRead.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/View/PlcVarMonitorView.xaml create mode 100644 BPASmartClient.JXJFoodSmallStation/View/PlcVarMonitorView.xaml.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/ViewModel/PlcVarMonitorViewModel.cs create mode 100644 WpfControlLibrary1/AssemblyInfo.cs create mode 100644 WpfControlLibrary1/UserControl1.xaml create mode 100644 WpfControlLibrary1/UserControl1.xaml.cs create mode 100644 WpfControlLibrary1/WpfControlLibrary1.csproj diff --git a/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs b/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs index 785250d5..a1aa60c6 100644 --- a/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs +++ b/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs @@ -25,7 +25,7 @@ namespace BPASmartClient.CustomResource.Pages.Model if (string.IsNullOrEmpty(name)) name = typeof(AlarmT).Name; if (_Instance == null) _Instance = new ConcurrentDictionary(); if (!_Instance.ContainsKey(name)) _Instance.TryAdd(name, new AlarmT()); - return _Instance[name]; + return _Instance[name]; } } private AlarmHelper() { } diff --git a/BPASmartClient.CustomResource/Pages/View/RunLogView.xaml b/BPASmartClient.CustomResource/Pages/View/RunLogView.xaml index e265a036..3067d1df 100644 --- a/BPASmartClient.CustomResource/Pages/View/RunLogView.xaml +++ b/BPASmartClient.CustomResource/Pages/View/RunLogView.xaml @@ -234,7 +234,7 @@ + VerticalScrollBarVisibility="Visible"> diff --git a/BPASmartClient.CustomResource/Pages/View/UserLogView.xaml b/BPASmartClient.CustomResource/Pages/View/UserLogView.xaml index 94b69fe5..58ac02a5 100644 --- a/BPASmartClient.CustomResource/Pages/View/UserLogView.xaml +++ b/BPASmartClient.CustomResource/Pages/View/UserLogView.xaml @@ -310,7 +310,7 @@ + VerticalScrollBarVisibility="Visible"> diff --git a/BPASmartClient.JXJFoodBigStation/App.xaml.cs b/BPASmartClient.JXJFoodBigStation/App.xaml.cs index fc562273..354b9dc1 100644 --- a/BPASmartClient.JXJFoodBigStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodBigStation/App.xaml.cs @@ -57,6 +57,7 @@ namespace BPASmartClient.JXJFoodBigStation Json.Save(); Json.Save(); Json.Save(); + Json.Save(); base.OnExit(e); MessageNotify.GetInstance.LogSave(); ThreadManage.GetInstance().Dispose(); @@ -104,6 +105,13 @@ namespace BPASmartClient.JXJFoodBigStation AssemblyName = "BPASmartClient.JXJFoodBigStation", ToggleWindowPath = "View.StockBinRawMaterialView" }); + StockBinManage.Add(new SubMenumodel() + { + SubMenuName = "MES原料数据", + SubMenuPermission = new Permission[] { Permission.管理员 }, + AssemblyName = "BPASmartClient.JXJFoodBigStation", + ToggleWindowPath = "View.BomOfMaterialView" + }); MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", @@ -141,7 +149,7 @@ namespace BPASmartClient.JXJFoodBigStation InfoLog.Add(new SubMenumodel() { SubMenuName = "调试日志", - SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 }, + SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 }, AssemblyName = "BPASmartClient.CustomResource", ToggleWindowPath = "Pages.View.DebugLogView" }); @@ -223,6 +231,7 @@ namespace BPASmartClient.JXJFoodBigStation Json.Read(); Json.Read(); Json.Read(); + Json.Read(); } } diff --git a/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj b/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj index 6a9d7c00..d487ecaa 100644 --- a/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj +++ b/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj @@ -32,6 +32,9 @@ True Settings.settings + + Code + Code @@ -52,6 +55,10 @@ $(DefaultXamlRuntime) Designer + + $(DefaultXamlRuntime) + Designer + $(DefaultXamlRuntime) Designer diff --git a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs index 476ffcf6..624df1bd 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs @@ -16,13 +16,32 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// plc心跳上传 /// public static bool HeartBeatFromPlc { get; set; } + /// + /// 订单取消的状态位 + /// public static bool Order_Cancel { get; set; } - + /// + /// 订单取消的配方号 + /// public static string Order_CancelRecipeCode { get; set; } = ""; + public static int Order_CancelStep { get; set; } + /// + /// 第一个配方的配料时间 + /// public static DateTime DosingRecipe1Time { get; set; } + /// + /// 第二个配方的配料时间 + /// public static DateTime DosingRecipe2Time { get; set; } + /// + /// 第三个配方的配料时间 + /// public static DateTime DosingRecipe3Time { get; set; } + /// + /// 第四个配方的配料时间 + /// public static DateTime DosingRecipe4Time { get; set; } + /// /// plc心跳下发 /// @@ -48,14 +67,29 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// public static bool IsUseLocalRecipe { get; set; } = false; + /// + /// 洗桶的标识符 + /// public static bool BarrelWasherSign { get; set; } /// /// 订单请求 /// public static bool Order_Request { get; set; } = false; + /// + /// 下发配方的状态位 + /// public static int SiemensSendRecipeStatus { get; set; } = 0; + /// + /// 大料站最大的料仓数目 + /// public const int Max_DosingSotckBinNum = 14; + public static StockBinName stockBinName { get; set; } = new StockBinName(); + + /// + /// 原料的名称和原料编号对应,Mes提供的信息 + /// + public static Dictionary RawMaterialsNameCode { get; set; } = new Dictionary(); public static ushort AGVPutTray { get; set; } public static ushort AGVGetTray { get; set; } @@ -64,30 +98,37 @@ namespace BPASmartClient.JXJFoodBigStation.Model public static ushort TrayCylinder { get; set; } public static DB_Read HKPlc_Read = new DB_Read(); - public static bool IsUseLocalName { get; set; } = true; - public static bool IsAllowHKPlcConnect { get; set; } - public static bool IsAllowSiemensConnect { get; set; } /// - /// 海科plc初始化完成标志 + /// 是否连接海科PLC /// - public static bool HKPlcInitComple { get; set; } + public static bool IsAllowHKPlcConnect { get; set; } /// - /// 西门子plc初始化完成标志 + /// 是否连接西门子PLC /// - public static bool SiemensInitComple { get; set; } + public static bool IsAllowSiemensConnect { get; set; } /// - /// + /// 配方1配料完成 /// public static bool Recipe1DosingFinish { get; set; } = false; + /// + /// 配方2配料完成 + /// public static bool Recipe2DosingFinish { get; set; } = false; + /// + /// 配方3配料完成 + /// public static bool Recipe3DosingFinish { get; set; } = false; + /// + /// 配方4配料完成 + /// public static bool Recipe4DosingFinish { get; set; } = false; /// /// 订单是否是洗桶 /// public static bool Order_IsWashingBarrel { get; set; } = false; + public static int TrayEnable { get; set; } = 15; } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs index aa60f2d7..b384f96d 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs @@ -18,7 +18,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC public bool IsConnected => HK_PLC_S7.IsConnected; public DB_Read PlcRead = new DB_Read(); public DL_DataColl_DB DataColl =new DL_DataColl_DB(); - public StockBinName StockBinName = new StockBinName(); public void Init() { try @@ -29,12 +28,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC catch (Exception ex) { MessageNotify.GetInstance.ShowRunLog("DB99块初始化值 失败"); } - ThreadManage.GetInstance().StartLong(new Action(() => - { + ThreadManage.GetInstance().StartLong(new Action(() => + {/* + var res = HK_PLC_S7.ReadClass(97);//料仓里原料的编码 + if (res != null && res is StockBinName data9) + { + GVL_BigStation.stockBinName = data9; + }*/ if (IsConnected) { var res1 = HK_PLC_S7.ReadClass(98); - var res2 = HK_PLC_S7.ReadClass(97); + var res2 = HK_PLC_S7.ReadClass(97);//料仓里原料的编码 if (res1 != null && res1 is DB_Read data1) { PlcRead = data1; @@ -42,7 +46,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC } if (res2 != null && res2 is StockBinName data2) { - StockBinName = data2; + GVL_BigStation.stockBinName = data2; } var res3 = HK_PLC_S7.ReadClass(48); if (res3 != null && res3 is DL_DataColl_DB data) diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs deleted file mode 100644 index b571013d..00000000 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC -{ - public class HKPlcCommAddress - { - - } -} diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs index d3fc305f..0aa62220 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs @@ -9,33 +9,33 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC { public class StockBinName { - [Siemens(6)] + [Siemens(4)] public string RawMaterialName1 { get; set; } = ""; - [Siemens(6)] + [Siemens(4)] public string RawMaterialName2 { get; set; } = ""; - [Siemens(6)] + [Siemens(4)] public string RawMaterialName3 { get; set; } = ""; - [Siemens(6)] + [Siemens(4)] public string RawMaterialName4 { get; set; } = ""; - [Siemens(6)] + [Siemens(4)] public string RawMaterialName5 { get; set; } = ""; - [Siemens(6)] + [Siemens(4)] public string RawMaterialName6 { get; set; } = ""; - [Siemens(6)] + [Siemens(4)] public string RawMaterialName7 { get; set; } = ""; - [Siemens(6)] + [Siemens(4)] public string RawMaterialName8 { get; set; } = ""; - [Siemens(6)] + [Siemens(4)] public string RawMaterialName9 { get; set; } = ""; - [Siemens(6)] + [Siemens(4)] public string RawMaterialName10 { get; set; } = ""; - [Siemens(6)] + [Siemens(4)] public string RawMaterialName11 { get; set; } = ""; - [Siemens(6)] + [Siemens(4)] public string RawMaterialName12 { get; set; } = ""; - [Siemens(6)] + [Siemens(4)] public string RawMaterialName13 { get; set; } = ""; - [Siemens(6)] + [Siemens(4)] public string RawMaterialName14 { get; set; } = ""; } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/HardWare/BomMaterial.cs b/BPASmartClient.JXJFoodBigStation/Model/HardWare/BomMaterial.cs new file mode 100644 index 00000000..6dc11273 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/HardWare/BomMaterial.cs @@ -0,0 +1,16 @@ +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.Model +{ + public class BomMaterial + { + public ObservableCollection RawMaterials { get; set; } = new ObservableCollection(); + + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index 52566728..b5f1a742 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Configuration; using System.Linq; +using System.Reflection; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -46,8 +47,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 原料的名称和料仓的位置对应 /// - public Dictionary RawMaterialsNamePos = new Dictionary(); - public ObservableCollection RawMaterialsInfo => Json.Data.RawMaterial; + public ConcurrentDictionary RawMaterialsNamePos = new ConcurrentDictionary(); + /// + /// 硬件料仓的原料信息 + /// + public ObservableCollection HardWareRawMaterialInfo { get; set; } = new ObservableCollection(); + public ObservableCollection RawMaterialsInfo { get; set; } = new ObservableCollection(); /// /// 西门子配方队列 /// @@ -62,10 +67,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model public ConcurrentQueue LocalRecipeQueue2 = new ConcurrentQueue(); public ConcurrentQueue LocalRecipeQueue3 = new ConcurrentQueue(); public ConcurrentQueue LocalRecipeQueue4 = new ConcurrentQueue(); + + /// + /// 海科PLC的IP + /// + public string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"]; + /// + /// 西门子PLC的IP + /// + public string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; public void Init() { - testRawMaterialNameData();//自定义料仓名称 - ActionManage.GetInstance.CancelRegister("SiemensSendRecipe"); ActionManage.GetInstance.Register(new Action((res) => { ObservableCollection RawMaterials = new ObservableCollection(); @@ -76,19 +88,20 @@ namespace BPASmartClient.JXJFoodBigStation.Model RawMaterials.Clear(); for (int i = 0; i < GVL_BigStation.Max_DosingSotckBinNum; i++) { - if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name)) + int index = RawMaterialsNamePos.Values.ToList().IndexOf(recipe.Material[i].Material_Name); + if (index>=0) { RawMaterials.Add(new RawMaterial() { RawMaterialName = recipe.Material[i].Material_Name, RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum, RawMaterialWeight = recipe.Material[i].Material_Weight, - RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name] + RawMaterialLocation = RawMaterialsNamePos.Keys.ToList()[index] }); } else { - MessageNotify.GetInstance.ShowAlarmLog($"本地原料名称和西门子下发的原料名称无法对应,原料位置:{i}"); + MessageNotify.GetInstance.ShowAlarmLog($"本地原料名称和西门子下发的原料名称无法对应,原料名称:{recipe.Material[i].Material_Name},"); } } App.Current.Dispatcher.Invoke(() => @@ -105,155 +118,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } }), "SiemensSendRecipe", true); - string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"]; - string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; - GVL_BigStation.IsAllowHKPlcConnect = ConfigurationManager.AppSettings["HKPlc_Connect"].ToLower() == "true" ? true : false; - GVL_BigStation.IsAllowSiemensConnect = ConfigurationManager.AppSettings["Siemens_Connect"].ToLower() == "true" ? true : false; - try - { - if (GVL_BigStation.IsAllowHKPlcConnect) - { - HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); - } - } - catch (Exception ex) - { - MessageNotify.GetInstance.ShowAlarmLog("海科plc连接失败,等待重新连接"); - } - finally - { - HKDevice.Init(); - MessageNotify.GetInstance.ShowRunLog("海科plc初始化"); - if (HKDevice.IsConnected && GVL_BigStation.IsAllowHKPlcConnect) - { - MessageNotify.GetInstance.ShowRunLog("海科plc连接成功"); - } - } - try - { - if (GVL_BigStation.IsAllowSiemensConnect) - { - SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); - } - } - catch (Exception ex) - { - MessageNotify.GetInstance.ShowAlarmLog("西门子plc连接失败,等待重新连接"); - } - finally - { - SiemensDevice.Init(); - MessageNotify.GetInstance.ShowRunLog("西门子plc初始化"); - if (SiemensDevice.IsConnected && GVL_BigStation.IsAllowSiemensConnect) - { - MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功"); - } - } - ThreadManage.GetInstance().StartLong(new Action(() => - { - if (!HKDevice.IsConnected && GVL_BigStation.IsAllowHKPlcConnect) - { - HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); - MessageNotify.GetInstance.ShowRunLog("海科plc重新连接成功"); - } - if (!SiemensDevice.IsConnected && GVL_BigStation.IsAllowSiemensConnect) - { - SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); - MessageNotify.GetInstance.ShowRunLog("西门子plc重新连接"); - } - GVL_BigStation.HeartBeatToPlc = !GVL_BigStation.HeartBeatToPlc; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.0", GVL_BigStation.HeartBeatToPlc); - GVL_BigStation.HeartBeatFromPlc = HKDevice.PlcRead.HeartBeat;//读取plc心跳 - if (HKDevice.IsConnected) - { - if (GVL_BigStation.AGVPutTray.GetBitValue(1)) - { - HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", true); - } - else - { - HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false); - } - if (GVL_BigStation.AGVPutTray.GetBitValue(2)) - { - HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", true); - } - else - { - HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false); - } - if (GVL_BigStation.AGVPutTray.GetBitValue(3)) - { - HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", true); - } - else - { - HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false); - } - if (GVL_BigStation.AGVPutTray.GetBitValue(4)) - { - HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", true); - } - else - { - HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false); - } - if (GVL_BigStation.AGVPutTray.GetBitValue(5)) - { - HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", true); - } - else - { - HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false); - } - GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(1, HKDevice.PlcRead.Tray1Sensor); - GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(2, HKDevice.PlcRead.Tray2Sensor); - GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(3, HKDevice.PlcRead.Tray3Sensor); - GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(4, HKDevice.PlcRead.Tray4Sensor); - GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(5, HKDevice.PlcRead.Tray5Sensor); - GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(1, !HKDevice.PlcRead.Tray1Cylinder); - GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(2, !HKDevice.PlcRead.Tray2Cylinder); - GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(3, !HKDevice.PlcRead.Tray3Cylinder); - GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(4, !HKDevice.PlcRead.Tray4Cylinder); - GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(5, !HKDevice.PlcRead.Tray5Cylinder); - if (HKDevice.PlcRead.IsAllowIssueRecipe1 || HKDevice.PlcRead.IsAllowIssueRecipe2 || HKDevice.PlcRead.IsAllowIssueRecipe3 || HKDevice.PlcRead.IsAllowIssueRecipe4) - { - GVL_BigStation.Order_Request = true; - } - } - if (SiemensDevice.IsConnected) - { - GVL_BigStation.AGVPutTray = SiemensDevice.DL_Status.AGV_Put_Done; - GVL_BigStation.AGVGetTray = SiemensDevice.DL_Status.AGV_Get_Done; - SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW30", GVL_BigStation.TraySensor); - SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW32", GVL_BigStation.TrayCylinder); - SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW34", (ushort)15); - } - Thread.Sleep(10); - }),"海科plc和西门子数据交互",true); - LocalRecipeQueue1.Clear(); - LocalRecipeQueue2.Clear(); - LocalRecipeQueue3.Clear(); - LocalRecipeQueue4.Clear(); - SiemensRecipeQueue1.Clear(); - SiemensRecipeQueue2.Clear(); - SiemensRecipeQueue3.Clear(); - SiemensRecipeQueue4.Clear(); - ThreadManage.GetInstance().StartLong(new Action(() => - { - testRawMaterialNameData();//自定义料仓名称 - if (GVL_BigStation.IsUseLocalRecipe) - { - LocalRecipeRecevice(); - LocalRecipeDosing(); - } - else - { - ReceviceData(); - RecipeInfoToHKPLC(); - } - Thread.Sleep(10); - }), "配方数据执行流程", true); + //testRawMaterialNameData();//自定义料仓名称 + DeviceConnectInit();//设备连接初始化 + ThreadInit();//线程初始化 + VarResetInit();//变量初始化 } private void LocalRecipeRecevice() { @@ -365,6 +233,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1) { + if (LocalRecipes.ElementAt(index).IsWashingBarrel) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶复位 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶信号复位"); + } HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", false); StockBinParReset(); GVL_BigStation.Recipe1DosingStatus = 2; @@ -375,8 +248,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (LocalRecipes.ElementAt(index).IsWashingBarrel) { GVL_BigStation.BarrelWasherSign = false; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶复位 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶信号复位"); } GVL_BigStation.Recipe1DosingStatus = 3; switch (trayCode) @@ -528,6 +399,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.ReceiveFinishRecipe2 && GVL_BigStation.Recipe2DosingStatus == 1) { + if (LocalRecipes.ElementAt(index).IsWashingBarrel) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶复位 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶信号复位"); + } GVL_BigStation.Recipe2DosingStatus = 2; HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", false); StockBinParReset(); @@ -538,8 +414,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (LocalRecipes.ElementAt(index).IsWashingBarrel) { GVL_BigStation.BarrelWasherSign = false; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶复位 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶信号复位"); } switch (trayCode) { @@ -691,6 +565,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.ReceiveFinishRecipe3 && GVL_BigStation.Recipe3DosingStatus == 1) { + if (LocalRecipes.ElementAt(index).IsWashingBarrel) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶复位 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶信号复位"); + } GVL_BigStation.Recipe3DosingStatus = 2; HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", false); StockBinParReset(); @@ -701,8 +580,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (LocalRecipes.ElementAt(index).IsWashingBarrel) { GVL_BigStation.BarrelWasherSign = false; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶复位 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶信号复位"); } switch (trayCode) { @@ -855,6 +732,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.ReceiveFinishRecipe4 && GVL_BigStation.Recipe4DosingStatus == 1) { + if (LocalRecipes.ElementAt(index).IsWashingBarrel) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶复位 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶信号复位"); + } GVL_BigStation.Recipe4DosingStatus = 2; HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", false); StockBinParReset(); @@ -865,8 +747,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (LocalRecipes.ElementAt(index).IsWashingBarrel) { GVL_BigStation.BarrelWasherSign = false; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶复位 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶信号复位"); } switch (trayCode) { @@ -974,31 +854,33 @@ namespace BPASmartClient.JXJFoodBigStation.Model { if (SiemensDevice.DL_Status is DL_Status_DB status) { - if (GVL_BigStation.SiemensSendRecipeStatus == 3) - { - SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); - SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); - MessageNotify.GetInstance.ShowRunLog($"配方1,发送配方编号和请求配料标志给西门子"); - GVL_BigStation.SiemensSendRecipeStatus = 4; - } - if (GVL_BigStation.SiemensSendRecipeStatus == 4) - { - if (SiemensDevice.DL_Status.Dosing_Start_ACK) - { - SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); - SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); - MessageNotify.GetInstance.ShowRunLog($"配方1,西门子确认开始配料"); - GVL_BigStation.SiemensSendRecipeStatus = 5; - } - } - if (GVL_BigStation.SiemensSendRecipeStatus == 5) + switch (GVL_BigStation.SiemensSendRecipeStatus) { - if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) - { - SiemensRecipeQueue1.Enqueue(data.RecipeCode); - MessageNotify.GetInstance.ShowRunLog($"配方1,配方:{data.RecipeCode},加入队列"); - GVL_BigStation.SiemensSendRecipeStatus = 0; - } + case 3: + SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + MessageNotify.GetInstance.ShowRunLog($"配方1,发送配方编号和请求配料标志给西门子"); + GVL_BigStation.SiemensSendRecipeStatus = 4; + break; + case 4: + if (SiemensDevice.DL_Status.Dosing_Start_ACK) + { + SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); + MessageNotify.GetInstance.ShowRunLog($"配方1,西门子确认开始配料"); + GVL_BigStation.SiemensSendRecipeStatus = 5; + } + break; + case 5: + if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) + { + SiemensRecipeQueue1.Enqueue(data.RecipeCode); + MessageNotify.GetInstance.ShowRunLog($"配方1,配方:{data.RecipeCode},加入队列"); + GVL_BigStation.SiemensSendRecipeStatus = 0; + } + break; + default: + break; } } } @@ -1123,156 +1005,228 @@ namespace BPASmartClient.JXJFoodBigStation.Model GVL_BigStation.Recipe4DosingStatus = 0; } + + } + public void Order_Cancel() + { if (GVL_BigStation.Order_Cancel) //订单取消 { if (!string.IsNullOrEmpty(GVL_BigStation.Order_CancelRecipeCode)) { + string code = GVL_BigStation.Order_CancelRecipeCode; int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == GVL_BigStation.Order_CancelRecipeCode); + short TrayCode = 0; if (index >= 0) { - string code = GVL_BigStation.Order_CancelRecipeCode; - short TrayCode = (short)Json.Data.Recipes.ElementAt(index).TrayCode; - if (SiemensRecipeQueue1.Contains(code) || SiemensRecipeQueue2.Contains(code) || SiemensRecipeQueue3.Contains(code) || SiemensRecipeQueue4.Contains(code)) - { - if (SiemensRecipeQueue1.Contains(code)) + TrayCode = (short)Json.Data.Recipes.ElementAt(index).TrayCode; + } + switch (GVL_BigStation.Order_CancelStep) + { + case 0: + if (index == -1) { - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index); - }); - if (GVL_BigStation.Recipe1DosingStatus != 0) + GVL_BigStation.Order_CancelStep = 10; + } + else + { + if (SiemensRecipeQueue1.Contains(code) || SiemensRecipeQueue2.Contains(code) || SiemensRecipeQueue3.Contains(code) || SiemensRecipeQueue4.Contains(code)) { - HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); - HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); - MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); + GVL_BigStation.Order_CancelStep = 30; } else { - MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); + GVL_BigStation.Order_CancelStep = 20; } + } + break; + case 10: + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + GVL_BigStation.Order_CancelStep = 11; + break; + case 11: + if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + GVL_BigStation.Order_CancelStep = 12; + } + break; + case 12: + MessageNotify.GetInstance.ShowRunLog($"西门子取消订单,但未找到订单:{GVL_BigStation.Order_CancelRecipeCode}"); + GVL_BigStation.Order_Cancel = false; + GVL_BigStation.Order_CancelRecipeCode = ""; + GVL_BigStation.Order_CancelStep = 0; + break; + + case 20: + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + GVL_BigStation.Order_CancelStep = 21; + break; + case 21: + if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + GVL_BigStation.Order_CancelStep = 22; + } + break; + case 22: + GVL_BigStation.SiemensSendRecipeStatus = 0; + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + MessageNotify.GetInstance.ShowRunLog($"正在执行请求订单流程,配方还未到PLC,订单号:{GVL_BigStation.Order_CancelRecipeCode}"); + GVL_BigStation.Order_Cancel = false; + GVL_BigStation.Order_CancelRecipeCode = ""; + GVL_BigStation.Order_CancelStep = 0; + break; + case 30: + if (SiemensRecipeQueue1.Contains(code)) + { + GVL_BigStation.Order_CancelStep = 31; + } + else if (SiemensRecipeQueue2.Contains(code)) + { + GVL_BigStation.Order_CancelStep = 41; + } + else if (SiemensRecipeQueue3.Contains(code)) + { + GVL_BigStation.Order_CancelStep = 51; + } + else if (SiemensRecipeQueue4.Contains(code)) + { + GVL_BigStation.Order_CancelStep = 61; + } + break; + case 31: + if (GVL_BigStation.Recipe1DosingStatus != 0) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); + HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); GVL_BigStation.Recipe1DosingStatus = 0; - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); - while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false ) - { - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); - SiemensRecipeQueue1.TryDequeue(out code); - MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); - } + GVL_BigStation.Order_CancelStep = 32; + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); + } + else + { + GVL_BigStation.Order_CancelStep = 32; + MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); } - if (SiemensRecipeQueue2.Contains(code)) + break; + case 32: + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + GVL_BigStation.Order_CancelStep = 33; + break; + case 33: + if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) { + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); App.Current.Dispatcher.Invoke(() => { Json.Data.Recipes.RemoveAt(index); }); - if (GVL_BigStation.Recipe2DosingStatus != 0) - { - HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); - HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); - MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); - } - else - { - MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); - } + SiemensRecipeQueue1.TryDequeue(out code); + GVL_BigStation.Order_CancelStep = 0; + MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); + } + break; + case 41: + if (GVL_BigStation.Recipe2DosingStatus != 0) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); + HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); GVL_BigStation.Recipe2DosingStatus = 0; - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); - while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) - { - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); - SiemensRecipeQueue2.TryDequeue(out code); - MessageNotify.GetInstance.ShowRunLog($"队列2,西门子取消订单完成,订单号:{code}"); - } + GVL_BigStation.Order_CancelStep = 42; + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); } - if (SiemensRecipeQueue3.Contains(code)) + else { - GVL_BigStation.Recipe3DosingStatus = 0; - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index); - }); - if (GVL_BigStation.Recipe3DosingStatus != 0) - { - HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); - HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); - MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); - } - else - { - MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); - } - GVL_BigStation.Recipe3DosingStatus = 0; - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); - while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) - { - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); - SiemensRecipeQueue3.TryDequeue(out code); - MessageNotify.GetInstance.ShowRunLog($"队列3,西门子取消订单完成,订单号:{code}"); - } + GVL_BigStation.Order_CancelStep = 42; + MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); } - if (SiemensRecipeQueue4.Contains(code)) + break; + case 42: + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + GVL_BigStation.Order_CancelStep = 43; + break; + case 43: + if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) { - GVL_BigStation.Recipe4DosingStatus = 0; + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); App.Current.Dispatcher.Invoke(() => { Json.Data.Recipes.RemoveAt(index); }); - if (GVL_BigStation.Recipe4DosingStatus != 0) - { - HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); - HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); - MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); - } - else - { - MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); - } - GVL_BigStation.Recipe4DosingStatus = 0; - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); - while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) - { - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); - SiemensRecipeQueue4.TryDequeue(out code); - MessageNotify.GetInstance.ShowRunLog($"队列4,西门子取消订单完成,订单号:{code}"); - } + SiemensRecipeQueue2.TryDequeue(out code); + GVL_BigStation.Order_CancelStep = 0; + MessageNotify.GetInstance.ShowRunLog($"队列2,西门子取消订单完成,订单号:{code}"); } - GVL_BigStation.Order_Cancel = false; - GVL_BigStation.Order_CancelRecipeCode = ""; - } - else - { - if (GVL_BigStation.SiemensSendRecipeStatus != 0 || GVL_BigStation.SiemensSendRecipeStatus != 1) + break; + case 51: + if (GVL_BigStation.Recipe3DosingStatus != 0) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); + HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); + GVL_BigStation.Recipe3DosingStatus = 0; + GVL_BigStation.Order_CancelStep = 52; + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); + } + else { - GVL_BigStation.SiemensSendRecipeStatus = 0; + GVL_BigStation.Order_CancelStep = 52; + MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); + } + break; + case 52: + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + GVL_BigStation.Order_CancelStep = 53; + break; + case 53: + if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); App.Current.Dispatcher.Invoke(() => { Json.Data.Recipes.RemoveAt(index); }); - MessageNotify.GetInstance.ShowRunLog($"正在执行请求订单流程,配方还未到PLC,订单号:{GVL_BigStation.Order_CancelRecipeCode}"); + SiemensRecipeQueue3.TryDequeue(out code); + GVL_BigStation.Order_CancelStep = 0; + MessageNotify.GetInstance.ShowRunLog($"队列3,西门子取消订单完成,订单号:{code}"); + } + break; + case 61: + if (GVL_BigStation.Recipe4DosingStatus != 0) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); + HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); + GVL_BigStation.Recipe4DosingStatus = 0; + GVL_BigStation.Order_CancelStep = 62; + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); } else { - MessageNotify.GetInstance.ShowRunLog($"订单取消异常,订单号:{GVL_BigStation.Order_CancelRecipeCode}"); + GVL_BigStation.Order_CancelStep = 62; + MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); } - GVL_BigStation.Order_Cancel = false; - GVL_BigStation.Order_CancelRecipeCode = ""; + break; + case 62: SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); - while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + GVL_BigStation.Order_CancelStep = 63; + break; + case 63: + if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) { SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + SiemensRecipeQueue4.TryDequeue(out code); + GVL_BigStation.Order_CancelStep = 0; + MessageNotify.GetInstance.ShowRunLog($"队列4,西门子取消订单完成,订单号:{code}"); } - } - } - else - { - GVL_BigStation.Order_Cancel = false; - GVL_BigStation.Order_CancelRecipeCode = ""; - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); - while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) - { - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); - } - MessageNotify.GetInstance.ShowRunLog($"西门子取消订单,但未找到订单:{GVL_BigStation.Order_CancelRecipeCode}"); + break; + default: + break; } } } @@ -1337,6 +1291,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1) { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); + } HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", false); StockBinParReset(); MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); @@ -1347,8 +1306,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { GVL_BigStation.BarrelWasherSign = false; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); } GVL_BigStation.Recipe1DosingFinish = true; GVL_BigStation.Recipe1DosingStatus = 3; @@ -1509,6 +1466,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.ReceiveFinishRecipe2 && GVL_BigStation.Recipe2DosingStatus == 1) { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); + } HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", false); StockBinParReset(); GVL_BigStation.Recipe2DosingStatus = 2; @@ -1519,8 +1481,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { GVL_BigStation.BarrelWasherSign = false; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); } GVL_BigStation.Recipe2DosingFinish = true; GVL_BigStation.Recipe2DosingStatus = 3; @@ -1680,6 +1640,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.ReceiveFinishRecipe3 && GVL_BigStation.Recipe3DosingStatus == 1) { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); + } HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", false); StockBinParReset(); GVL_BigStation.Recipe3DosingStatus = 2; @@ -1690,8 +1655,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { GVL_BigStation.BarrelWasherSign = false; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); } GVL_BigStation.Recipe3DosingFinish = true; GVL_BigStation.Recipe3DosingStatus = 3; @@ -1851,6 +1814,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.ReceiveFinishRecipe4 && GVL_BigStation.Recipe4DosingStatus == 1) { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); + } GVL_BigStation.Recipe4DosingStatus = 2; HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", false); StockBinParReset(); @@ -1861,10 +1829,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { GVL_BigStation.BarrelWasherSign = false; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); } - GVL_BigStation.Recipe1DosingFinish = true; + GVL_BigStation.Recipe4DosingFinish = true; GVL_BigStation.Recipe4DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial) @@ -1973,7 +1939,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// private void StockBinParReset() { - HKDevice.HK_PLC_S7.Write("DB99.DBW2.0", 0);// + HKDevice.HK_PLC_S7.Write("DB99.DBW2.0", 0); HKDevice.HK_PLC_S7.Write("DB99.DBW4.0", 0); for (int i = 0; i < 56; i++) { @@ -1983,25 +1949,322 @@ namespace BPASmartClient.JXJFoodBigStation.Model } private void testRawMaterialNameData() { - /* RawMaterialsInfo.Clear(); - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0007", RawMaterialLocation = 1 });//备料大蒜 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0015", RawMaterialLocation = 2 });//花椒酱 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0005", RawMaterialLocation = 3 });//榨菜丁 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0018", RawMaterialLocation = 4 });//炸豌豆 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0019", RawMaterialLocation = 5 });//高水分糍粑海椒 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0033", RawMaterialLocation = 6 });//辣豆瓣 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0030", RawMaterialLocation = 11 });//备用生姜 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0012", RawMaterialLocation = 12 });//豆豉细粒*/ - foreach (var material in RawMaterialsInfo) + //RawMaterialsInfo = Json.Data.RawMaterial; + //foreach (var material in RawMaterialsInfo) + //{ + // if (!string.IsNullOrEmpty(material.RawMaterialName)) + // { + // if (!RawMaterialsNamePos.ContainsKey(material.RawMaterialName)) + // { + // RawMaterialsNamePos.Add(material.RawMaterialName, (short)material.RawMaterialLocation); + // } + // } + //} + if (RawMaterialsNamePos.Count == 14) + { + for (int i = 0; i < typeof(StockBinName).GetProperties().Length; i++) + { + PropertyInfo pro = GVL_BigStation.stockBinName.GetType().GetProperty(typeof(StockBinName).GetProperties()[i].Name); + RawMaterialsNamePos[i+1] = pro.GetValue(GVL_BigStation.stockBinName, null).ToString(); + } + /* RawMaterialsNamePos[1] = GVL_BigStation.stockBinName.RawMaterialName1; + RawMaterialsNamePos[2] = GVL_BigStation.stockBinName.RawMaterialName2; + RawMaterialsNamePos[3] = GVL_BigStation.stockBinName.RawMaterialName3; + RawMaterialsNamePos[4] = GVL_BigStation.stockBinName.RawMaterialName4; + RawMaterialsNamePos[5] = GVL_BigStation.stockBinName.RawMaterialName5; + RawMaterialsNamePos[6] = GVL_BigStation.stockBinName.RawMaterialName6; + RawMaterialsNamePos[7] = GVL_BigStation.stockBinName.RawMaterialName7; + RawMaterialsNamePos[8] = GVL_BigStation.stockBinName.RawMaterialName8; + RawMaterialsNamePos[9] = GVL_BigStation.stockBinName.RawMaterialName9; + RawMaterialsNamePos[10] = GVL_BigStation.stockBinName.RawMaterialName10; + RawMaterialsNamePos[11] = GVL_BigStation.stockBinName.RawMaterialName11; + RawMaterialsNamePos[12] = GVL_BigStation.stockBinName.RawMaterialName12; + RawMaterialsNamePos[13] = GVL_BigStation.stockBinName.RawMaterialName13; + RawMaterialsNamePos[14] = GVL_BigStation.stockBinName.RawMaterialName14;*/ + } + else + { + RawMaterialsNamePos.TryAdd(1, GVL_BigStation.stockBinName.RawMaterialName1); + RawMaterialsNamePos.TryAdd(2, GVL_BigStation.stockBinName.RawMaterialName2); + RawMaterialsNamePos.TryAdd(3, GVL_BigStation.stockBinName.RawMaterialName3); + RawMaterialsNamePos.TryAdd(4, GVL_BigStation.stockBinName.RawMaterialName4); + RawMaterialsNamePos.TryAdd(5, GVL_BigStation.stockBinName.RawMaterialName5); + RawMaterialsNamePos.TryAdd(6, GVL_BigStation.stockBinName.RawMaterialName6); + RawMaterialsNamePos.TryAdd(7, GVL_BigStation.stockBinName.RawMaterialName7); + RawMaterialsNamePos.TryAdd(8, GVL_BigStation.stockBinName.RawMaterialName8); + RawMaterialsNamePos.TryAdd(9, GVL_BigStation.stockBinName.RawMaterialName9); + RawMaterialsNamePos.TryAdd(10, GVL_BigStation.stockBinName.RawMaterialName10); + RawMaterialsNamePos.TryAdd(11, GVL_BigStation.stockBinName.RawMaterialName11); + RawMaterialsNamePos.TryAdd(12, GVL_BigStation.stockBinName.RawMaterialName12); + RawMaterialsNamePos.TryAdd(13, GVL_BigStation.stockBinName.RawMaterialName13); + RawMaterialsNamePos.TryAdd(14, GVL_BigStation.stockBinName.RawMaterialName14); + foreach (var item in RawMaterialsNamePos) + { + HardWareRawMaterialInfo.Add(new RawMaterial() { RawMaterialCount = HardWareRawMaterialInfo.Count + 1, RawMaterialLocation = item.Key, RawMaterialName = item.Value, RawMaterialChineseName = "" }); + } + } + foreach (var item in RawMaterialsNamePos) { - if (!string.IsNullOrEmpty(material.RawMaterialName)) + int num = Array.FindIndex(Json.Data.RawMaterials.ToArray(), p => p.RawMaterialName == item.Value); + int index = Array.FindIndex(HardWareRawMaterialInfo.ToArray(), p => p.RawMaterialLocation == item.Key); + if (index == -1) { - if (!RawMaterialsNamePos.ContainsKey(material.RawMaterialName)) + HardWareRawMaterialInfo.Clear(); + } + else if (num >= 0 && index >= 0) + { + string name = Json.Data.RawMaterials.ElementAt(num).RawMaterialChineseName; + HardWareRawMaterialInfo.ElementAt(index).RawMaterialLocation = item.Key; + HardWareRawMaterialInfo.ElementAt(index).RawMaterialName = item.Value; + HardWareRawMaterialInfo.ElementAt(index).RawMaterialChineseName = name; + } + else if (num == -1) + { + HardWareRawMaterialInfo.ElementAt(index).RawMaterialLocation = item.Key; + HardWareRawMaterialInfo.ElementAt(index).RawMaterialName = ""; + HardWareRawMaterialInfo.ElementAt(index).RawMaterialChineseName = ""; + } + } + } + /// + /// MES的物料名称和物料编码对应 + /// + public void RawMaterialNameWithCode() + { + GVL_BigStation.RawMaterialsNameCode.Add("0001", "色拉油"); + GVL_BigStation.RawMaterialsNameCode.Add("0002", "一级菜油"); + GVL_BigStation.RawMaterialsNameCode.Add("0003", "菜籽油"); + GVL_BigStation.RawMaterialsNameCode.Add("0004", "青花椒油"); + GVL_BigStation.RawMaterialsNameCode.Add("0005", "卤牛肉丁"); + GVL_BigStation.RawMaterialsNameCode.Add("0006", "冻鸡肉丁"); + GVL_BigStation.RawMaterialsNameCode.Add("0007", "香菇丁"); + GVL_BigStation.RawMaterialsNameCode.Add("0008", "高水分糍粑海椒"); + GVL_BigStation.RawMaterialsNameCode.Add("0009", "低水分糍粑海椒"); + GVL_BigStation.RawMaterialsNameCode.Add("0010", "辣豆瓣"); + GVL_BigStation.RawMaterialsNameCode.Add("0011", "整豆豉"); + GVL_BigStation.RawMaterialsNameCode.Add("0012", "豆豉细粒"); + GVL_BigStation.RawMaterialsNameCode.Add("0013", "卤黄豆"); + GVL_BigStation.RawMaterialsNameCode.Add("0014", "野山椒粒"); + GVL_BigStation.RawMaterialsNameCode.Add("0015", "竹笋丁"); + GVL_BigStation.RawMaterialsNameCode.Add("0016", "香辣酱辣椒酱"); + GVL_BigStation.RawMaterialsNameCode.Add("0017", "芽菜粒"); + GVL_BigStation.RawMaterialsNameCode.Add("0018", "榨菜丁"); + GVL_BigStation.RawMaterialsNameCode.Add("0019", "盐菜"); + GVL_BigStation.RawMaterialsNameCode.Add("0020", "洋葱丁"); + GVL_BigStation.RawMaterialsNameCode.Add("0021", "番茄酱"); + GVL_BigStation.RawMaterialsNameCode.Add("0022", "甜豆瓣"); + GVL_BigStation.RawMaterialsNameCode.Add("0023", "甜面酱"); + GVL_BigStation.RawMaterialsNameCode.Add("0024", "芝麻酱"); + GVL_BigStation.RawMaterialsNameCode.Add("0025", "炸花生"); + GVL_BigStation.RawMaterialsNameCode.Add("0026", "盐渍青椒丁"); + GVL_BigStation.RawMaterialsNameCode.Add("0027", "备料剁红椒"); + GVL_BigStation.RawMaterialsNameCode.Add("0028", "萝卜丁"); + GVL_BigStation.RawMaterialsNameCode.Add("0029", "油芝麻"); + GVL_BigStation.RawMaterialsNameCode.Add("0030", "生姜"); + GVL_BigStation.RawMaterialsNameCode.Add("0031", "大蒜"); + GVL_BigStation.RawMaterialsNameCode.Add("0032", "榨菜酱"); + GVL_BigStation.RawMaterialsNameCode.Add("0033", "炸碗豆"); + GVL_BigStation.RawMaterialsNameCode.Add("0034", "大头菜丁"); + GVL_BigStation.RawMaterialsNameCode.Add("0035", "酱油"); + GVL_BigStation.RawMaterialsNameCode.Add("0036", "I+G"); + GVL_BigStation.RawMaterialsNameCode.Add("0037", "味精"); + GVL_BigStation.RawMaterialsNameCode.Add("0038", "白糖"); + GVL_BigStation.RawMaterialsNameCode.Add("0039", "食盐"); + GVL_BigStation.RawMaterialsNameCode.Add("0040", "花椒酱"); + GVL_BigStation.RawMaterialsNameCode.Add("0041", "调味膏2"); + GVL_BigStation.RawMaterialsNameCode.Add("0042", "调味膏5"); + GVL_BigStation.RawMaterialsNameCode.Add("0043", "十三香调味膏"); + GVL_BigStation.RawMaterialsNameCode.Add("0044", "酱香膏"); + GVL_BigStation.RawMaterialsNameCode.Add("0045", "芽菜香料粉"); + GVL_BigStation.RawMaterialsNameCode.Add("0046", "香料A"); + GVL_BigStation.RawMaterialsNameCode.Add("0047", "香料D"); + GVL_BigStation.RawMaterialsNameCode.Add("0048", "猪肉精膏"); + GVL_BigStation.RawMaterialsNameCode.Add("0049", "调味膏3"); + GVL_BigStation.RawMaterialsNameCode.Add("0050", "柠檬酸粉"); + GVL_BigStation.RawMaterialsNameCode.Add("0051", "辣椒红"); + GVL_BigStation.RawMaterialsNameCode.Add("0052", "辣椒油树脂"); + GVL_BigStation.RawMaterialsNameCode.Add("0053", "水态混和酸"); + GVL_BigStation.RawMaterialsNameCode.Add("0054", "加水稀释后防腐剂"); + GVL_BigStation.RawMaterialsNameCode.Add("0055", "异维C钠粉"); + GVL_BigStation.RawMaterialsNameCode.Add("0056", "琼脂粉"); + GVL_BigStation.RawMaterialsNameCode.Add("0057", "香葱油"); + GVL_BigStation.RawMaterialsNameCode.Add("0058", "水态甜味剂"); + GVL_BigStation.RawMaterialsNameCode.Add("0059", "孜然粉"); + GVL_BigStation.RawMaterialsNameCode.Add("0060", "孜然油"); + } + /// + /// 设备连接 西门子和海科PLC + /// + public void DeviceConnectInit() + { + GVL_BigStation.IsAllowHKPlcConnect = ConfigurationManager.AppSettings["HKPlc_Connect"].ToLower() == "true" ? true : false; + GVL_BigStation.IsAllowSiemensConnect = ConfigurationManager.AppSettings["Siemens_Connect"].ToLower() == "true" ? true : false; + try + { + if (GVL_BigStation.IsAllowHKPlcConnect) + { + HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); + } + } + catch (Exception ex) + { + MessageNotify.GetInstance.ShowRunLog("海科plc连接失败,等待重新连接"); + } + finally + { + HKDevice.Init(); + MessageNotify.GetInstance.ShowRunLog("海科plc初始化"); + if (HKDevice.IsConnected && GVL_BigStation.IsAllowHKPlcConnect) + { + MessageNotify.GetInstance.ShowRunLog("海科plc连接成功"); + } + } + try + { + if (GVL_BigStation.IsAllowSiemensConnect) + { + SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); + } + } + catch (Exception ex) + { + MessageNotify.GetInstance.ShowRunLog("西门子plc连接失败,等待重新连接"); + } + finally + { + SiemensDevice.Init(); + MessageNotify.GetInstance.ShowRunLog("西门子plc初始化"); + if (SiemensDevice.IsConnected && GVL_BigStation.IsAllowSiemensConnect) + { + MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功"); + } + } + } + + public void ThreadInit() + { + ThreadManage.GetInstance().StartLong(new Action(() => + { + if (!HKDevice.IsConnected && GVL_BigStation.IsAllowHKPlcConnect) + { + HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); + MessageNotify.GetInstance.ShowRunLog("海科plc重新连接成功"); + } + if (!SiemensDevice.IsConnected && GVL_BigStation.IsAllowSiemensConnect) + { + SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); + MessageNotify.GetInstance.ShowRunLog("西门子plc重新连接"); + } + Thread.Sleep(10); + }), "西门子和海科PLC重新连接", true); + ThreadManage.GetInstance().StartLong(new Action(() => + { + GVL_BigStation.HeartBeatToPlc = !GVL_BigStation.HeartBeatToPlc; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.0", GVL_BigStation.HeartBeatToPlc); + GVL_BigStation.HeartBeatFromPlc = HKDevice.PlcRead.HeartBeat;//读取plc心跳 + if (HKDevice.IsConnected) + { + if (GVL_BigStation.AGVPutTray.GetBitValue(1)) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", true); + } + else + { + HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false); + } + if (GVL_BigStation.AGVPutTray.GetBitValue(2)) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", true); + } + else + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false); + } + if (GVL_BigStation.AGVPutTray.GetBitValue(3)) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", true); + } + else + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false); + } + if (GVL_BigStation.AGVPutTray.GetBitValue(4)) { - RawMaterialsNamePos.Add(material.RawMaterialName, (short)material.RawMaterialLocation); + HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", true); + } + else + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false); + } + if (GVL_BigStation.AGVPutTray.GetBitValue(5)) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", true); + } + else + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false); + } + GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(1, HKDevice.PlcRead.Tray1Sensor); + GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(2, HKDevice.PlcRead.Tray2Sensor); + GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(3, HKDevice.PlcRead.Tray3Sensor); + GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(4, HKDevice.PlcRead.Tray4Sensor); + GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(5, HKDevice.PlcRead.Tray5Sensor); + GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(1, !HKDevice.PlcRead.Tray1Cylinder); + GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(2, !HKDevice.PlcRead.Tray2Cylinder); + GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(3, !HKDevice.PlcRead.Tray3Cylinder); + GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(4, !HKDevice.PlcRead.Tray4Cylinder); + GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(5, !HKDevice.PlcRead.Tray5Cylinder); + if (HKDevice.PlcRead.IsAllowIssueRecipe1 || HKDevice.PlcRead.IsAllowIssueRecipe2 || HKDevice.PlcRead.IsAllowIssueRecipe3 || HKDevice.PlcRead.IsAllowIssueRecipe4) + { + GVL_BigStation.Order_Request = true; } } - } + if (SiemensDevice.IsConnected) + { + GVL_BigStation.AGVPutTray = SiemensDevice.DL_Status.AGV_Put_Done; + GVL_BigStation.AGVGetTray = SiemensDevice.DL_Status.AGV_Get_Done; + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW30", GVL_BigStation.TraySensor); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW32", GVL_BigStation.TrayCylinder); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW34", (ushort)GVL_BigStation.TrayEnable); + } + Thread.Sleep(10); + }), "海科plc和西门子数据交互", true); + ThreadManage.GetInstance().StartLong(new Action(() => + { + testRawMaterialNameData();//自定义料仓名称 + if (GVL_BigStation.Order_Cancel) + { + Order_Cancel(); + } + else + { + if (GVL_BigStation.IsUseLocalRecipe) + { + LocalRecipeRecevice(); + LocalRecipeDosing(); + } + else + { + ReceviceData(); + RecipeInfoToHKPLC(); + } + } + Thread.Sleep(10); + }), "配方数据执行流程", true); + } + /// + /// 初始化变量复位 + /// + public void VarResetInit() + { + LocalRecipeQueue1.Clear(); + LocalRecipeQueue2.Clear(); + LocalRecipeQueue3.Clear(); + LocalRecipeQueue4.Clear(); + SiemensRecipeQueue1.Clear(); + SiemensRecipeQueue2.Clear(); + SiemensRecipeQueue3.Clear(); + SiemensRecipeQueue4.Clear(); } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterial.cs b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterial.cs index e25effb7..125b6ae7 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterial.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterial.cs @@ -10,10 +10,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model public class RawMaterial :ObservableObject { private int _mIp; - public int DeviceIp { get { return _mIp; } set { _mIp = value; }} + public int DeviceIp { get { return _mIp; } set { _mIp = value; OnPropertyChanged(); } } - public short RawMaterialCount { get { return _mRawMaterialCount; } set { _mRawMaterialCount = value; OnPropertyChanged(); } } - private short _mRawMaterialCount; + public int RawMaterialCount { get { return _mRawMaterialCount; } set { _mRawMaterialCount = value; OnPropertyChanged(); } } + private int _mRawMaterialCount; + + /// + /// 原料中文名 + /// + public string RawMaterialChineseName { get { return _mRawMaterialChineseName; } set { _mRawMaterialChineseName = value; OnPropertyChanged(); } } + private string _mRawMaterialChineseName; /// /// 原料名称 @@ -36,7 +42,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 实际的下料中重量 /// - public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } } + public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; OnPropertyChanged(); } } private float _mLaying_Off_Weight; /// diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs index ff22a4a4..1456067a 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs @@ -62,73 +62,22 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens } if (res2 != null && res2 is DL_Finish_DB finish) { - if (GVL_BigStation.Recipe1DosingFinish == true) + if (finish.Ask_For_Finish_PLC &&(GVL_BigStation.Recipe1DosingFinish || GVL_BigStation.Recipe2DosingFinish || GVL_BigStation.Recipe3DosingFinish || GVL_BigStation.Recipe4DosingFinish)) { - if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(finish.Ask_For_Finish_PLC)) + finish.Order_No = ""; + finish.Product_Code = ""; + finish.job_No = 0; + for (int i = 0; i < 20; i++) { - finish.Order_No = ""; - finish.Product_Code = ""; - finish.job_No = 0; - for (int i = 0; i < 20; i++) - { - finish.Material[i] = new UDT1(); - } - finish.Ask_For_Finish = false; - finish.ProcessTime = 0; - this.Siemens_PLC_S7.WriteClass(finish, 2361); - GVL_BigStation.Recipe1DosingFinish = false; - } - } - else if (GVL_BigStation.Recipe2DosingFinish == true) - { - if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(finish.Ask_For_Finish_PLC)) - { - finish.Order_No = ""; - finish.Product_Code = ""; - finish.job_No = 0; - for (int i = 0; i < 20; i++) - { - finish.Material[i] = new UDT1(); - } - finish.Ask_For_Finish = false; - finish.ProcessTime = 0; - this.Siemens_PLC_S7.WriteClass(finish, 2361); - GVL_BigStation.Recipe2DosingFinish = false; - } - } - else if (GVL_BigStation.Recipe3DosingFinish == true) - { - if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(finish.Ask_For_Finish_PLC)) - { - finish.Order_No = ""; - finish.Product_Code = ""; - finish.job_No = 0; - for (int i = 0; i < 20; i++) - { - finish.Material[i] = new UDT1(); - } - finish.Ask_For_Finish = false; - finish.ProcessTime = 0; - this.Siemens_PLC_S7.WriteClass(finish, 2361); - GVL_BigStation.Recipe3DosingFinish = false; - } - } - else if (GVL_BigStation.Recipe4DosingFinish == true) - { - if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(finish.Ask_For_Finish_PLC)) - { - finish.Order_No = ""; - finish.Product_Code = ""; - finish.job_No = 0; - for (int i = 0; i < 20; i++) - { - finish.Material[i] = new UDT1(); - } - finish.Ask_For_Finish = false; - finish.ProcessTime = 0; - this.Siemens_PLC_S7.WriteClass(finish, 2361); - GVL_BigStation.Recipe4DosingFinish = false; + finish.Material[i] = new UDT1(); } + finish.Ask_For_Finish = false; + finish.ProcessTime = 0; + this.Siemens_PLC_S7.WriteClass(finish, 2361); + if (GVL_BigStation.Recipe1DosingFinish) GVL_BigStation.Recipe1DosingFinish = false; + if (GVL_BigStation.Recipe2DosingFinish) GVL_BigStation.Recipe2DosingFinish = false; + if (GVL_BigStation.Recipe3DosingFinish) GVL_BigStation.Recipe3DosingFinish = false; + if (GVL_BigStation.Recipe4DosingFinish) GVL_BigStation.Recipe4DosingFinish = false; } } Thread.Sleep(10); diff --git a/BPASmartClient.JXJFoodBigStation/View/BomOfMaterialView.xaml b/BPASmartClient.JXJFoodBigStation/View/BomOfMaterialView.xaml new file mode 100644 index 00000000..cebe958f --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/View/BomOfMaterialView.xaml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.JXJFoodBigStation/View/BomOfMaterialView.xaml.cs b/BPASmartClient.JXJFoodBigStation/View/BomOfMaterialView.xaml.cs new file mode 100644 index 00000000..6c013785 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/View/BomOfMaterialView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BPASmartClient.JXJFoodBigStation.View +{ + /// + /// HKPlcCommMonitor.xaml 的交互逻辑 + /// + public partial class BomOfMaterialView : UserControl + { + public BomOfMaterialView() + { + InitializeComponent(); + } + } +} diff --git a/BPASmartClient.JXJFoodBigStation/View/ManualFlowView.xaml b/BPASmartClient.JXJFoodBigStation/View/ManualFlowView.xaml index 98100d7f..084de0e0 100644 --- a/BPASmartClient.JXJFoodBigStation/View/ManualFlowView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/ManualFlowView.xaml @@ -78,19 +78,90 @@ Height="40" Margin="5,0,5,0" Command="{Binding ClearAllRecipe}" - Content="清除所有配方" + Content="清除西门子所有配方" FontSize="20" Panel.ZIndex="0" Style="{StaticResource ImageButtonStyle}"> - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml b/BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml index 0e61653d..b90c7de9 100644 --- a/BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml @@ -529,7 +529,7 @@ VerticalAlignment="Top" Background="Transparent" HorizontalScrollBarVisibility="Hidden" - VerticalScrollBarVisibility="Hidden"> + VerticalScrollBarVisibility="Visible"> diff --git a/BPASmartClient.JXJFoodBigStation/View/StockBinRawMaterialView.xaml b/BPASmartClient.JXJFoodBigStation/View/StockBinRawMaterialView.xaml index dd78dd20..a0ea54b5 100644 --- a/BPASmartClient.JXJFoodBigStation/View/StockBinRawMaterialView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/StockBinRawMaterialView.xaml @@ -13,12 +13,12 @@ + - - + - @@ -50,19 +49,18 @@ - + - - + - + - + @@ -81,8 +79,7 @@ - - - + + + diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/BomOfMaterialViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/BomOfMaterialViewModel.cs new file mode 100644 index 00000000..81339514 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/BomOfMaterialViewModel.cs @@ -0,0 +1,75 @@ +using BPASmartClient.CustomResource.Pages.Model; +using BPASmartClient.CustomResource.UserControls; +using BPASmartClient.CustomResource.UserControls.MessageShow; +using BPASmartClient.Helper; +using BPASmartClient.JXJFoodBigStation.Model; +using BPASmartClient.JXJFoodBigStation.Model.HK_PLC; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.Input; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.ViewModel +{ + public class BomOfMaterialViewModel : ObservableObject + { + public BomOfMaterialViewModel() + { + RawMaterialInfo = Json.Data.RawMaterials; + /*if (RawMaterialInfo.Count ==0) + { + Json.Data.RawMaterials.Clear(); + ProcessControl.GetInstance.RawMaterialNameWithCode();//原料的名称和编码对应 :西门子mes定义的物料编码 + foreach (var item in GVL_BigStation.RawMaterialsNameCode) + { + Json.Data.RawMaterials.Add(new RawMaterial() { RawMaterialCount = Json.Data.RawMaterials.Count + 1, RawMaterialName = item.Key, RawMaterialChineseName = item.Value }); + } + RawMaterialInfo = Json.Data.RawMaterials; + NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"读取程序的Bom清单"); + }*/ + AddMaterial = new RelayCommand(() => + { + RawMaterialInfo.Add(new RawMaterial() + { + RawMaterialCount = Json.Data.RawMaterials.Count +1 , + }); + }); + SaveMaterials = new RelayCommand(() => + { + if (MessageNotify.GetInstance.ShowDialog("请确认是否保存!") == true) + { + Json.Save(); + MessageNotify.GetInstance.ShowUserLog($"Mes物料清单保存成功"); + NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功"); + } + }); + RemoveCommand = new RelayCommand((Count) => + { + if (Count is int cnt) + { + var res = RawMaterialInfo.FirstOrDefault(p => p.RawMaterialCount == cnt); + if (res != null) + { + if (MessageNotify.GetInstance.ShowDialog("请确认是否删除!") == true) + { + RawMaterialInfo.Remove(res); + NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"删除成功"); + } + } + } + }); + } + public ObservableCollection RawMaterialInfo { get; set; } = new ObservableCollection(); + public RelayCommand AddMaterial { get; set; } + public RelayCommand SaveMaterials { get; set; } + public RelayCommand RemoveCommand { get; set; } + + } +} diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/ManualFlowViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/ManualFlowViewModel.cs index 89b8a58f..44d109e2 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/ManualFlowViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/ManualFlowViewModel.cs @@ -10,6 +10,7 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Reflection; +using System.Runtime.CompilerServices; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -49,10 +50,36 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel Json.Data.Recipes.Clear(); GVL_BigStation.SiemensSendRecipeStatus = 0; }); + CancelRecipeCommand = new RelayCommand(() => + { + if (Json.Data.Recipes != null) + { + int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == CancelRecipeCode); + if (index >= 0) + { + GVL_BigStation.Order_Cancel = true; + GVL_BigStation.Order_CancelRecipeCode = CancelRecipeCode; + } + } + }); ThreadManage.GetInstance().StartLong(new Action(() => { Heartbeat = GVL_BigStation.HeartBeatFromPlc; Thread.Sleep(100); + StockBin1Name = GVL_BigStation.stockBinName.RawMaterialName1; + StockBin2Name = GVL_BigStation.stockBinName.RawMaterialName2; + StockBin3Name = GVL_BigStation.stockBinName.RawMaterialName3; + StockBin4Name = GVL_BigStation.stockBinName.RawMaterialName4; + StockBin5Name = GVL_BigStation.stockBinName.RawMaterialName5; + StockBin6Name = GVL_BigStation.stockBinName.RawMaterialName6; + StockBin7Name = GVL_BigStation.stockBinName.RawMaterialName7; + StockBin8Name = GVL_BigStation.stockBinName.RawMaterialName8; + StockBin9Name = GVL_BigStation.stockBinName.RawMaterialName9; + StockBin10Name = GVL_BigStation.stockBinName.RawMaterialName10; + StockBin11Name = GVL_BigStation.stockBinName.RawMaterialName11; + StockBin12Name = GVL_BigStation.stockBinName.RawMaterialName12; + StockBin13Name = GVL_BigStation.stockBinName.RawMaterialName13; + StockBin14Name = GVL_BigStation.stockBinName.RawMaterialName14; }), "设备状态读取",true); } public RelayCommand Tray1InPlace { get; set; } @@ -62,7 +89,45 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel public RelayCommand Tray5InPlace { get; set; } public RelayCommand ClearTrayInPlace { get; set; } public RelayCommand ClearAllRecipe { get; set; } - public bool Heartbeat { get { return _mHeartbeat; } set { _mHeartbeat = value; OnPropertyChanged(); } } - private bool _mHeartbeat; + public static bool Heartbeat { get { return _mHeartbeat; } set { _mHeartbeat = value; OnStaticPropertyChanged(); } } + private static bool _mHeartbeat; + + public string CancelRecipeCode { get { return _CancelRecipeCode; } set { _CancelRecipeCode = value; OnPropertyChanged(); } } + public string _CancelRecipeCode { get; set; } + public static string StockBin1Name { get { return _StockBin1Name; } set { _StockBin1Name = value; OnStaticPropertyChanged(); } } + public static string _StockBin1Name { get; set; } + public static string StockBin2Name { get { return _StockBin2Name; } set { _StockBin2Name = value; OnStaticPropertyChanged(); } } + public static string _StockBin2Name { get; set; } + public static string StockBin3Name { get { return _StockBin3Name; } set { _StockBin3Name = value; OnStaticPropertyChanged(); } } + public static string _StockBin3Name { get; set; } + public static string StockBin4Name { get { return _StockBin4Name; } set { _StockBin4Name = value; OnStaticPropertyChanged(); } } + public static string _StockBin4Name { get; set; } + public static string StockBin5Name { get { return _StockBin5Name; } set { _StockBin5Name = value; OnStaticPropertyChanged(); } } + public static string _StockBin5Name { get; set; } + public static string StockBin6Name { get { return _StockBin6Name; } set { _StockBin6Name = value; OnStaticPropertyChanged(); } } + public static string _StockBin6Name { get; set; } + public static string StockBin7Name { get { return _StockBin7Name; } set { _StockBin7Name = value; OnStaticPropertyChanged(); } } + public static string _StockBin7Name { get; set; } + public static string StockBin8Name { get { return _StockBin8Name; } set { _StockBin8Name = value; OnStaticPropertyChanged(); } } + public static string _StockBin8Name { get; set; } + public static string StockBin9Name { get { return _StockBin9Name; } set { _StockBin9Name = value; OnStaticPropertyChanged(); } } + public static string _StockBin9Name { get; set; } + public static string StockBin10Name { get { return _StockBin10Name; } set { _StockBin10Name = value; OnStaticPropertyChanged(); } } + public static string _StockBin10Name { get; set; } + public static string StockBin11Name { get { return _StockBin11Name; } set { _StockBin11Name = value; OnStaticPropertyChanged(); } } + public static string _StockBin11Name { get; set; } + public static string StockBin12Name { get { return _StockBin12Name; } set { _StockBin12Name = value; OnStaticPropertyChanged(); } } + public static string _StockBin12Name { get; set; } + public static string StockBin13Name { get { return _StockBin13Name; } set { _StockBin13Name = value; OnStaticPropertyChanged(); } } + public static string _StockBin13Name { get; set; } + public static string StockBin14Name { get { return _StockBin14Name; } set { _StockBin14Name = value; OnStaticPropertyChanged(); } } + public static string _StockBin14Name { get; set; } + public RelayCommand CancelRecipeCommand { get; set; } + + public static event EventHandler StaticPropertyChanged; + public static void OnStaticPropertyChanged([CallerMemberName] string PropName = "") + { + StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName)); + } } } diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs index 9c1ecc13..6e9ac351 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs @@ -34,7 +34,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel IsWashingBarrel = rm.IsWashingBarrel; foreach (var item in rm.RawMaterial) { - item.RawMaterialCount = (short)Array.FindIndex(ProcessControl.GetInstance.RawMaterialsInfo.ToArray(), p => p.RawMaterialName == item.RawMaterialName); + item.RawMaterialCount = Array.FindIndex(ProcessControl.GetInstance.RawMaterialsInfo.ToArray(), p => p.RawMaterialName == item.RawMaterialName); RawMaterialsInfo.Add(item); } } @@ -69,13 +69,13 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel { if (IsWashingBarrel) { - Json.Data.Recipes.Add(new RecipeData { RecipeCode = recipeCode,RecipeName = RecipeName, TrayCode = TrayCode, IsWashingBarrel = IsWashingBarrel }); + Json.Data.Recipes.Add(new RecipeData { RecipeCode = recipeCode,RecipeName = RecipeName, TrayCode = TrayCode, IsWashingBarrel = IsWashingBarrel, OrderType="洗桶" }); if (RawMaterialsInfo.Count > 0) NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, App.MainWindow, "提示", $"订单类型为洗桶,不保存原料信息"); } else { - Json.Data.Recipes.Add(new RecipeData { RecipeCode = recipeCode, RawMaterial = RawMaterialsInfo, RecipeName = RecipeName, TrayCode = TrayCode, IsWashingBarrel = IsWashingBarrel }); + Json.Data.Recipes.Add(new RecipeData { RecipeCode = recipeCode, RawMaterial = RawMaterialsInfo, RecipeName = RecipeName, TrayCode = TrayCode, IsWashingBarrel = IsWashingBarrel, OrderType = "配料" }); } Json.Save(); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"配方保存完成"); @@ -110,7 +110,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel } }); - RemoveRecipe = new RelayCommand((index) => { + RemoveRecipe = new RelayCommand((index) => { var res = RawMaterialsInfo.FirstOrDefault(p => p.RawMaterialCount == index); if (res != null) RawMaterialsInfo.Remove(res); @@ -137,7 +137,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel public RelayCommand Comfirm { get; set; } - public RelayCommand RemoveRecipe { get; set; } + public RelayCommand RemoveRecipe { get; set; } public ObservableCollection RawMaterialsInfo { get; set; } = new ObservableCollection() ; diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs index 14a76d48..4f9acbb1 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs @@ -47,7 +47,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel if (!ProcessControl.GetInstance.LocalRecipes.Contains(res)) { ProcessControl.GetInstance.LocalRecipes.Add(res); - MessageNotify.GetInstance.ShowAlarmLog($"手动下发配方:{recipeName}完成"); + MessageNotify.GetInstance.ShowRunLog($"手动下发配方:{recipeName}完成"); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"配方下发完成"); } } diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/StockBinRawMaterialViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/StockBinRawMaterialViewModel.cs index f5ade366..0e6767b9 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/StockBinRawMaterialViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/StockBinRawMaterialViewModel.cs @@ -22,33 +22,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel { public StockBinRawMaterialViewModel() { - RawMaterialInfo = Json.Data.RawMaterial; - RemoveCommand = new RelayCommand((loc) => - { - if (loc is int pos) - { - var res = RawMaterialInfo.FirstOrDefault(p => p.RawMaterialLocation == pos); - if (res != null) RawMaterialInfo.Remove(res); - } - }); - SaveRawMaterialPara = new RelayCommand(() => - { - Json.Save(); - foreach (var item in Json.Data.RawMaterial) - { - MessageNotify.GetInstance.ShowUserLog($"料仓位置:"+ item.RawMaterialLocation+ ",物料编码:" + item.RawMaterialName); - } - MessageNotify.GetInstance.ShowUserLog($"原料与料仓对应关系保存成功"); - NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功"); - }); - UpdateRawMaterial = new RelayCommand(() => - { - RawMaterialInfo.Add(new RawMaterial() { RawMaterialCount = (short)(RawMaterialInfo.Count + 1)}); - }); } - public ObservableCollection RawMaterialInfo { get; set; } = new ObservableCollection(); - public RelayCommand RemoveCommand { get; set; } - public RelayCommand SaveRawMaterialPara { get; set; } - public RelayCommand UpdateRawMaterial { get; set; } + public ObservableCollection RawMaterialInfo => ProcessControl.GetInstance.HardWareRawMaterialInfo; } } diff --git a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs index 191917d2..70aafb9e 100644 --- a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs @@ -37,6 +37,7 @@ namespace BPASmartClient.JXJFoodSmallStation } BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut(); base.OnStartup(e); + MenuInit(); DataInit(); Init(); @@ -249,7 +250,13 @@ namespace BPASmartClient.JXJFoodSmallStation AssemblyName = "BPASmartClient.JXJFoodSmallStation", ToggleWindowPath = "View.DeviceListView" }); - + DeviceMonitor.Add(new SubMenumodel() + { + SubMenuName = "变量监控", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + AssemblyName = "BPASmartClient.JXJFoodSmallStation", + ToggleWindowPath = "View.PlcVarMonitorView" + }); DeviceMonitor.Add(new SubMenumodel() { SubMenuName = "设备状态", diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL/PlcCommAttribute.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL/PlcCommAttribute.cs new file mode 100644 index 00000000..8d72460d --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL/PlcCommAttribute.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.GVL +{ + [AttributeUsage(AttributeTargets.Property)] + public sealed class PlcCommAttribute:Attribute + { + public PlcCommAttribute(string address,string des) + { + Address = address; + Describe = des; + } + public string Describe { get; set; } + public string Address { get; set; } + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL/PlcInfos.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL/PlcInfos.cs new file mode 100644 index 00000000..472a0ef7 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL/PlcInfos.cs @@ -0,0 +1,27 @@ +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.GVL +{ + public class PlcInfos: ObservableObject + { + public int Count { get { return _Count; } set { _Count = value;OnPropertyChanged(); } } + private int _Count { get; set; } + + public string Name { get { return _Name; } set { _Name = value; OnPropertyChanged(); } } + private string _Name { get; set; } + public string Address { get { return _Address; } set { _Address = value; OnPropertyChanged(); } } + private string _Address { get; set; } + public string Type { get { return _Type; } set { _Type = value; OnPropertyChanged(); } } + private string _Type { get; set; } + public string Describe { get { return _Describe; } set { _Describe = value; OnPropertyChanged(); } } + private string _Describe { get; set; } + public string Value { get { return _Value; } set { _Value = value; OnPropertyChanged(); } } + private string _Value { get; set; } + + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs index 6e50873a..3313406a 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs @@ -1,4 +1,5 @@ -using BPASmartClient.JXJFoodSmallStation.Model.Siemens; +using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC; +using BPASmartClient.JXJFoodSmallStation.Model.Siemens; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -15,12 +16,24 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public static GVL_SmallStation GetInstance => SmallStation ?? (SmallStation = new GVL_SmallStation()); private GVL_SmallStation() { } + public static PlcReadAddressDB3 plcReadDataDB3 { get; set; } = new PlcReadAddressDB3(); + + /// + /// 订单取消 + /// public static bool Order_Cancel { get; set; } + /// + /// 取消订单的编号 + /// public static string Order_CancelRecipeCode { get; set; } = ""; /// /// 托盘1托盘到位 逻辑完成 /// - public static bool TrayLogicFinish { get; set; } = false; + public static int Tray1LogicFinish { get; set; } = 0; + /// + /// 托盘2托盘到位 逻辑完成 + /// + public static int Tray2LogicFinish { get; set; } = 0; /// /// 托盘1有货架 /// @@ -29,20 +42,39 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// 托盘2有货架 /// public static bool Station2HaveTray { get; set; } - + /// + /// 托盘2有货架 + /// + public static int nStep { get; set; } + /// + /// 托盘1传感器信号 + /// public static bool Station1Sensor { get; set; } /// /// 托盘2传感器信号 /// public static bool Station2Sensor { get; set; } + /// + /// 托盘1气缸信号 + /// public static bool Station1Cylinder { get; set; } /// /// 托盘2气缸信号 /// public static bool Station2Cylinder { get; set; } - + /// + /// AGV放托盘1完成 + /// public static bool AGV_PutTray1Finish { get; set; } + /// + /// AGV取托盘1完成 + /// public static bool AGV_GetTray1Finish { get; set; } + + + public static bool AGV_PutTray2Finish { get; set; } + public static bool AGV_GetTray2Finish { get; set; } + public static bool CylinderReset { get; set; } /// /// 配料站料仓数目 @@ -59,13 +91,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// public static bool IsAllowSiemensSendRecipe { get; set; } = false; /// - /// 西门子下发配方状态 0:等待下发配方 1:请求下发配方 2:上位机接收配方 3:配方接收完成 4:请求配料 5:西门子开始配料确认 6:配方配料完成 7:配料完成确认 + /// 西门子下发配方状态 0:等待下发配方 1:请求下发配方 2:上位机接收配方 3:配方接收配方完成 4:上位机向西门子请求配料 5:西门子确认开始配料 6:西门子确认开始配料 信号复位 /// public static int SiemensSendRecipeStatus { get; set; } = 0; /// /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 /// - public int RecipeStatusID { get; set; } = 0; + public int RecipeStatusIDTray1 { get; set; } = 0; /// /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 @@ -146,6 +178,35 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// 系统运行状态 /// public static int Time { get; set; } = 1000; + /// + /// 取消订单的步骤: 1-9:配料过程中配方1取消配方 10-19:配料过程中配方2取消配方 20-29:下发订单的过程中取消订单(订单未到达上位机) 30-39:下发订单的过程中取消订单(订单未到达PLC) + /// + public static int OrderCancelStep = 0; + + /// + /// 机器人的状态 + /// + public static ushort RobotStatus = 0; + /// + /// 机器人的状态 + /// + public static byte RobotProgramNum = 0; #endregion } + public enum IssueRecipeCondition + { + 等待小料站PLC允许下配方, + 等待西门子下发配方, + 等待西门子下发配方信号复位, + 等待上位机请求配料, + 等待西门子确认配料, + 等待西门子确认配料信号复位, + } + public enum ProcessCondition + { + 等待AGV到位, + 等待小料站PLC接受配方完成, + 等待配方配料完成, + 等待AGV取托盘完成 + } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/DataComm.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/DataComm.cs deleted file mode 100644 index f47bd894..00000000 --- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/DataComm.cs +++ /dev/null @@ -1,41 +0,0 @@ -using BPASmartClient.Helper; -using BPASmartClient.Modbus; -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC -{ - public class DataComm - { - public volatile static DataComm Instance; - public static DataComm GetInstance => Instance ?? (new DataComm()); - public DataComm() { } - /// - /// 是否允许配料 - /// - public bool IsAllowDosing { get { return _mIsAllowDosing; } set { _mIsAllowDosing = value; } } - private bool _mIsAllowDosing; - - public bool DosingFinishToPLC { get { return _mDosingFinishToPLC; } set { _mDosingFinishToPLC = value; } } - private bool _mDosingFinishToPLC; - - private int _mStockBinLocationToPLC; - public int StockBinLocationToPLC { get { return _mStockBinLocationToPLC; } set { _mStockBinLocationToPLC = value; } } - - public bool StatusSignToBPA { get { return _mStatusSignToBPA; } set { _mStatusSignToBPA = value; } } - private bool _mStatusSignToBPA; - - private int _mStockBinLocationToBPA; - public int StockBinLocationToBPA { get { return _mStockBinLocationToBPA; } set { _mStockBinLocationToBPA = value; } } - - private int _mBarrelNumToPLC; - public int BarrelNumToPLC { get { return _mBarrelNumToPLC; } set { _mBarrelNumToPLC = value; } } - - /*public ConcurrentDictionary DeviceLists = new ConcurrentDictionary();*/ - } - -} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceRead.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceRead.cs new file mode 100644 index 00000000..dee7a188 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceRead.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC +{ + public class HKDeviceRead + { + public bool HeartBeat { get; set; } + public bool SystemMode { get; set; } + public bool SystemStart { get; set; } + public bool SystemPause { get; set; } + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs index c6809398..6ccc889a 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs @@ -27,42 +27,47 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC { DeviceStatus = data; } + var res1 = this.HK_PLC_S7.ReadClass(3); + if (res1 != null && res1 is PlcReadAddressDB3 data1) + { + GVL_SmallStation.plcReadDataDB3 = data1; + } } }),"海科PLC设备状态",true); } - /// - /// 单个配料机配料完成 - /// - /// - public void SingleDosing(uint value) - { - if (IsConnected) - { - HK_PLC_S7.Write(HKPlcCommAddress.SingleStockBinLocationToPLC, value); - HK_PLC_S7.Write(HKPlcCommAddress.SingleDosingFinishToPLC, (ushort)1); - } - } - /// - /// 复位plc允许接料信号 - /// - public void AllowDosingSignReset() - { - HK_PLC_S7.Write(HKPlcCommAddress.IsAllowDosing,(ushort)0); - } - /// - /// 复位plc到达某料仓信号 - /// - public void StockStateSignReset() - { - HK_PLC_S7.Write(HKPlcCommAddress.StockState, (ushort)0); - } - /// - /// 复位一个配方配料完成信号 - /// - public void RecipeDosingFinishReset() - { - HK_PLC_S7.Write(HKPlcCommAddress.RecipeDosingFinish, (ushort)0); - } + ///// + ///// 单个配料机配料完成 + ///// + ///// + //public void SingleDosing(uint value) + //{ + // if (IsConnected) + // { + // HK_PLC_S7.Write(HKPlcCommAddress.SingleStockBinLocationToPLC, value); + // HK_PLC_S7.Write(HKPlcCommAddress.SingleDosingFinishToPLC, (ushort)1); + // } + //} + ///// + ///// 复位plc允许接料信号 + ///// + //public void AllowDosingSignReset() + //{ + // HK_PLC_S7.Write(HKPlcCommAddress.IsAllowDosing,(ushort)0); + //} + ///// + ///// 复位plc到达某料仓信号 + ///// + //public void StockStateSignReset() + //{ + // HK_PLC_S7.Write(HKPlcCommAddress.StockState, (ushort)0); + //} + ///// + ///// 复位一个配方配料完成信号 + ///// + //public void RecipeDosingFinishReset() + //{ + // HK_PLC_S7.Write(HKPlcCommAddress.RecipeDosingFinish, (ushort)0); + //} /// /// 下发配方数据 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs index ec42c683..8891ccf7 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs @@ -1,4 +1,5 @@ -using System; +using BPASmartClient.JXJFoodSmallStation.Model.GVL; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,8 +9,170 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC { public class PlcReadAddressDB3 { - public bool[] VarBool { get; set; } =new bool[17]; - public Single[] BarrelPos { get; set; } = new Single[8]; - public bool[] IsAllowDosing { get; set; } = new bool[8]; + [PlcComm("DB3.DBX0.0","心跳")] + public bool HeartBeat { get; set; } + [PlcComm("DB3.DBX0.1", "备用1")] + public bool Standby1 { get; set; } + [PlcComm("DB3.DBX0.2", "备用2")] + public bool Standby2 { get; set; } + [PlcComm("DB3.DBX0.3", "备用3")] + public bool Standby3 { get; set; } + [PlcComm("DB3.DBX0.4", "备用4")] + public bool Standby4 { get; set; } + [PlcComm("DB3.DBX0.5", "备用5")] + public bool Standby5 { get; set; } + [PlcComm("DB3.DBX0.6", "备用6")] + public bool Standby6 { get; set; } + [PlcComm("DB3.DBX0.7", "工站1有托盘")] + public bool WorkStation1HaveTray { get; set; } + + [PlcComm("DB3.DBX1.0", "工站2有托盘")] + public bool WorkStation2HaveTray { get; set; } + [PlcComm("DB3.DBX1.1", "工站1配料完成")] + public bool WorkStation1DosingComplete { get; set; } + [PlcComm("DB3.DBX1.2", "工站2配料完成")] + public bool WorkStation2DosingComplete { get; set; } + [PlcComm("DB3.DBX1.3", "工站1接收配方完成")] + public bool WorkStation1ReceviceRecipeComplete { get; set; } + [PlcComm("DB3.DBX1.4", "工站2接收配方完成")] + public bool WorkStation2ReceviceRecipeComplete { get; set; } + [PlcComm("DB3.DBX1.5", "工站1气缸报警")] + public bool WorkStation1CylinderAlarm { get; set; } + [PlcComm("DB3.DBX1.6", "工站2气缸报警")] + public bool WorkStation2CylinderAlarm { get; set; } + [PlcComm("DB3.DBX1.7", "允许配方1下发配方")] + public bool AllowRecipe1Issue { get; set; } + + [PlcComm("DB3.DBX2.0", "允许配方2下发配方")] + public bool AllowRecipe2Issue { get; set; } + [PlcComm("DB3.DBX2.1", "工站1传感器信号")] + public bool WorkStation1Sensor { get; set; } + [PlcComm("DB3.DBX2.2", "工站2传感器信号")] + public bool WorkStation2Sensor { get; set; } + [PlcComm("DB3.DBX2.3", "工站1气缸信号,false=伸出")] + public bool WorkStation1Cylinder { get; set; } + [PlcComm("DB3.DBX2.4", "工站2气缸信号,false=伸出")] + public bool WorkStation2Cylinder { get; set; } + [PlcComm("DB3.DBX2.5", "工站1取消订单")] + public bool WorkStation1OrderCancel { get; set; } + [PlcComm("DB3.DBX2.6", "工站2取消订单")] + public bool WorkStation2OrderCancel { get; set; } + [PlcComm("DB3.DBX2.7", "备用7")] + public bool Standby7 { get; set; } + [PlcComm("DB3.DBB3", "备用")] + public byte Standby81 { get; set; } + [PlcComm("DB3.DBB4", "备用")] + public byte Standby82 { get; set; } + [PlcComm("DB3.DBB5", "备用")] + public byte Standby83 { get; set; } + [PlcComm("DB3.DBW6", "备用")] + public int Standby9 { get; set; } + + [PlcComm("DB3.DBD10", "工站1_1号桶的位置")] + public int WorkStation1Barrel1Pos { get; set; } + [PlcComm("DB3.DBD14", "工站1_2号桶的位置")] + public int WorkStation1Barrel2Pos { get; set; } + [PlcComm("DB3.DBD18", "工站1_3号桶的位置")] + public int WorkStation1Barrel3Pos { get; set; } + [PlcComm("DB3.DBD22", "工站1_4号桶的位置")] + public int WorkStation1Barrel4Pos { get; set; } + [PlcComm("DB3.DBD26", "工站2_1号桶的位置")] + public int WorkStation2Barrel1Pos { get; set; } + [PlcComm("DB3.DBD30", "工站2_2号桶的位置")] + public int WorkStation2Barrel2Pos { get; set; } + [PlcComm("DB3.DBD34", "工站2_3号桶的位置")] + public int WorkStation2Barrel3Pos { get; set; } + [PlcComm("DB3.DBD38", "工站2_4号桶的位置")] + public int WorkStation2Barrel4Pos { get; set; } + + [PlcComm("DB3.DBD42", "备用")] + public int StandBy42 { get; set; } + [PlcComm("DB3.DBD46", "备用")] + public int StandBy46 { get; set; } + + [PlcComm("DB3.DBX50.0", "工站1_1号桶允许配料")] + public bool WorkStation1Barrel1AllowDosing { get; set; } + [PlcComm("DB3.DB50.1", "工站1_2号桶允许配料")] + public bool WorkStation1Barrel2AllowDosing { get; set; } + [PlcComm("DB3.DB50.2", "工站1_3号桶允许配料")] + public bool WorkStation1Barrel3AllowDosing { get; set; } + [PlcComm("DB3.DB50.3", "工站1_4号桶允许配料")] + public bool WorkStation1Barrel4AllowDosing { get; set; } + [PlcComm("DB3.DB50.4", "工站2_1号桶允许配料")] + public bool WorkStation2Barrel1AllowDosing { get; set; } + [PlcComm("DB3.DB50.5", "工站2_2号桶允许配料")] + public bool WorkStation2Barrel2AllowDosing { get; set; } + [PlcComm("DB3.DB50.6", "工站2_3号桶允许配料")] + public bool WorkStation2Barrel3AllowDosing { get; set; } + [PlcComm("DB3.DB50.7", "工站2_4号桶允许配料")] + public bool WorkStation2Barrel4AllowDosing { get; set; } + + [PlcComm("DB3.DBD52", "备用")] + public int Standby15 { get; set; } + [PlcComm("DB3.DBD56", "备用")] + public int Standby16 { get; set; } + [PlcComm("DB3.DBD60", "备用")] + public int Standby17 { get; set; } + [PlcComm("DB3.DBD64", "备用")] + public int Standby18 { get; set; } + [PlcComm("DB3.DBD68", "备用")] + public int Standby19 { get; set; } + [PlcComm("DB3.DBD72", "备用")] + public int Standby20 { get; set; } + [PlcComm("DB3.DBD76", "备用")] + public int Standby21 { get; set; } + [PlcComm("DB3.DBD80", "备用")] + public int Standby22 { get; set; } + [PlcComm("DB3.DBD84", "备用")] + public int Standby23 { get; set; } + [PlcComm("DB3.DBD88", "备用")] + public int Standby24 { get; set; } + [PlcComm("DB3.DBD92", "备用")] + public int Standby25 { get; set; } + [PlcComm("DB3.DBD96", "备用")] + public int Standby26 { get; set; } + + [PlcComm("DB3.DBX100.0", "机器人运行模式")] + public bool RobotRunMode { get; set; } + [PlcComm("DB3.DBX100.1", "机器人自动运行")] + public bool RobotAutoRun { get; set; } + [PlcComm("DB3.DBX100.2", "机器人停止")] + public bool RobotStop { get; set; } + [PlcComm("DB3.DBX100.3", "机器人运行")] + public bool RobotRun { get; set; } + [PlcComm("DB3.DBX100.4", "机器人运行报警")] + public bool RobotRunAlarm { get; set; } + [PlcComm("DB3.DBX100.5", "机器人在原点")] + public bool RobotInHomed { get; set; } + [PlcComm("DB3.DBX100.6", "机器人备用")] + public bool Standby30 { get; set; } + [PlcComm("DB3.DBX100.7", "机器人取空桶完成")] + public bool RobotGetEmptyBarrelComplete { get; set; } + + [PlcComm("DB3.DBX101.0", "机器人放空桶完成")] + public bool RobotPutEmptyBarrelComplete { get; set; } + [PlcComm("DB3.DBX101.1", "机器人取满桶完成")] + public bool RobotGetFullBarrelComplete { get; set; } + [PlcComm("DB3.DBX101.2", "机器人放满桶完成")] + public bool RobotPutFullBarrelComplete { get; set; } + [PlcComm("DB3.DBX101.3", "备用")] + public bool Standby31 { get; set; } + [PlcComm("DB3.DBX101.4", "备用")] + public bool Standby32 { get; set; } + [PlcComm("DB3.DBX101.5", "备用")] + public bool Standby33 { get; set; } + [PlcComm("DB3.DBX101.6", "备用")] + public bool Standby34 { get; set; } + [PlcComm("DB3.DBX101.7", "备用")] + public bool Standby35 { get; set; } + + [PlcComm("DB3.DBB102", "机器人运行的程序号")] + public byte RobotProgramNum { get; set; } + [PlcComm("DB3.DBB103", "备用")] + public byte Standby36 { get; set; } + [PlcComm("DB3.DBB104", "备用")] + public byte Standby37 { get; set; } + [PlcComm("DB3.DBB105", "备用")] + public byte Standby38 { get; set; } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index bf45b196..2c87f223 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -1,5 +1,6 @@ using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.Helper; +using BPASmartClient.JXJFoodSmallStation.Model.GVL; using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC; using BPASmartClient.JXJFoodSmallStation.Model.RawMaterial; using BPASmartClient.JXJFoodSmallStation.Model.Siemens; @@ -11,6 +12,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Configuration; using System.Linq; +using System.Reflection; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -18,7 +20,7 @@ using System.Threading.Tasks; namespace BPASmartClient.JXJFoodSmallStation.Model { public class ProcessControl - { + { private volatile static ProcessControl _Instance; public static ProcessControl GetInstance => _Instance ?? (_Instance = new ProcessControl()); private ProcessControl() { } @@ -50,283 +52,17 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// 接收原料数据 /// public RecipeRawMaterial RawMaterial; - public void Init() - { - testData(); - /*for (int i = 0; i < 16; i++) - { - if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null) - { - if (!RawMaterialsNamePos.ContainsKey(DeviceInquire.GetInstance.GetDevice(i).DeviceName)) - { - RawMaterialsNamePos.Add(DeviceInquire.GetInstance.GetDevice(i).DeviceName, (short)DeviceInquire.GetInstance.GetDevice(i).deviceStatus.DeviceNum); - } - } - }*/ - ActionManage.GetInstance.CancelRegister("SiemensRecipeRecive"); - ActionManage.GetInstance.Register(new Action((res) => - { - ObservableCollection RawMaterials = new ObservableCollection(); - ObservableCollection WindSendData = new ObservableCollection(); - if (SiemensDevice.IsConnected) - { - if (res != null && res is XL_Start_DB recipe) - { - if (!string.IsNullOrEmpty(recipe.RecipeCode)) { - RawMaterials.Clear(); - for (int i = 0; i < GVL_SmallStation.Max_DosingSotckBinNum; i++) - { - if (!string.IsNullOrEmpty(recipe.Material[i].Material_Name)) - { - if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name)) - { - RawMaterials.Add(new RemoteRecipeRawMaterial() - { - RawMaterialName = recipe.Material[i].Material_Name, - RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum, - RawMaterialWeight = recipe.Material[i].Material_Weight, - RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name] - }); - } - else - { - MessageNotify.GetInstance.ShowRunLog($"原料:{recipe.Material[i].Material_Name},不在配料表"); - //MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合"); - } - } - else - { - break; - } - } - for (int i = 0; i < GVL_SmallStation.Max_PowderSotckBinNum; i++) - { - if (!string.IsNullOrEmpty(recipe.Powder[i].Powder_Name)) - { - WindSendData.Add(new WindSendRawMaterial() - { - RawMaterialName = recipe.Powder[i].Powder_Name, - RawMaterialWeight = recipe.Powder[i].Powder_Weight - }); - } - else - { - break; - } - } - App.Current.Dispatcher.Invoke(() => { - Json.Data.Recipes.Add(new RemoteRecipeData() - { - RecipeName = recipe.RecipeName, - RecipeCode = recipe.RecipeCode, - RawMaterial = RawMaterials, - TrayCode = recipe.StockCode, - WindSend = WindSendData - }); - }); - } - } - } - }), "SiemensRecipeRecive", true); - ActionManage.GetInstance.CancelRegister("SiemensRecipeFinish"); - ActionManage.GetInstance.Register(new Action((res) => - { - if (SiemensDevice.IsConnected) - { - if (res != null && res is RemoteRecipeData recipe) - { - RecipeFinishInfo.Order_No = recipe.RecipeCode; - RecipeFinishInfo.Product_Code = recipe.RecipeName; - RecipeFinishInfo.Job_No = (short)recipe.TrayCode; - for (int i = 0; i < recipe.RawMaterial.Count; i++) - { - RecipeFinishInfo.Material[i] = new UDT1(); - RecipeFinishInfo.Material[i].Material_Name = recipe.RawMaterial.ElementAt(i).RawMaterialName; - RecipeFinishInfo.Material[i].Material_BarrelNum = recipe.RawMaterial.ElementAt(i).RawMaterialBarrelNum; - RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = recipe.RawMaterial.ElementAt(i).Laying_Off_Weight; - } - for (int i = 0; i < recipe.WindSend.Count; i++) - { - RecipeFinishInfo.Powder[i] = new UDT2(); - RecipeFinishInfo.Powder[i].Powder_Name = recipe.RawMaterial.ElementAt(i).RawMaterialName; - RecipeFinishInfo.Powder[i].Powder_Weight = recipe.RawMaterial.ElementAt(i).Laying_Off_Weight; - } - if (GVL_SmallStation.SiemensSendRecipeStatus == 6) - { - GVL_SmallStation.SiemensSendRecipeStatus = 7; - RecipeFinishInfo.Ask_For_Finish = true; - SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); - } - } - } - }), "SiemensRecipeFinish", true); - ActionManage.GetInstance.CancelRegister("LocalSimulationRecipeIssue"); - ActionManage.GetInstance.Register(new Action((res) => - { - if (res != null && res is RemoteRecipeData recipe) - { - Json.Data.Recipes.Add(recipe); - } - }), "LocalSimulationRecipeIssue", true); - - ActionManage.GetInstance.Register(new Action(() => - { - Json.Data.Recipes.Clear(); - GVL_SmallStation.SiemensSendRecipeStatus = 0; - MessageNotify.GetInstance.ShowRunLog("系统流程复位,等待西门子重新下发订单"); - }), "BPASystemReset",true); + public string? HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"]; + public string? Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; + public string? WindSend_PLC_IP = ConfigurationManager.AppSettings["WindSend_IP"]; - string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"]; - string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; - string WindSend_PLC_IP = ConfigurationManager.AppSettings["WindSend_IP"]; - try - { - if (Json.Data.deviceConnectPar.HKPlcConnect) - { - HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP); - if (HKDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科plc连接成功"); - } - } - catch (Exception ex) - { - MessageNotify.GetInstance.ShowAlarmLog("海科plc连接失败,等待重新连接"); - } - finally - { - HKDevice.Init(); - MessageNotify.GetInstance.ShowRunLog("海科plc初始化完成"); - } - try - { - if (Json.Data.deviceConnectPar.SiemensConnect) - { - SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); - if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功"); - } - } - catch (Exception ex) - { - MessageNotify.GetInstance.ShowAlarmLog("西门子plc连接失败,等待重新连接"); - } - finally - { - SiemensDevice.Init(); - MessageNotify.GetInstance.ShowRunLog("西门子plc初始化完成"); - } - try - { - if (Json.Data.deviceConnectPar.WindSendConnect) - { - WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP); - if (WindSendDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("风送plc连接成功"); - } - } - catch (Exception ex) - { - MessageNotify.GetInstance.ShowAlarmLog("粉料plc连接失败,等待重新连接"); - } - finally - { - WindSendDevice.Init(); - MessageNotify.GetInstance.ShowRunLog("风送粉料plc初始化完成"); - } - ThreadManage.GetInstance().StartLong(new Action(() => - { - try - { - if (!HKDevice.IsConnected && Json.Data.deviceConnectPar.HKPlcConnect) - { - HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP); - if (HKDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接成功"); - } - } - catch (Exception ex) - { - } - try - { - if (!SiemensDevice.IsConnected && Json.Data.deviceConnectPar.SiemensConnect) - { - SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); - if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子PLC重新连接成功"); - } - } - catch (Exception ex) - { - } - try - { - if (!WindSendDevice.IsConnected && Json.Data.deviceConnectPar.WindSendConnect) - { - WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP); - if (WindSendDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("风送plc重新连接成功"); - } - } - catch (Exception ex) - { - } - Thread.Sleep(50); - }), "设备连接", true); - RecipeQueueTray1.Clear(); - //手动控制系统模式 - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.0", true); }), "SystemStart", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.0", false); }), "SystemStop", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.2", true); }), "SystemPause", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.2", false); }), "SystemReset", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.1", false); }), "SystemAutoMode", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.1", true); }), "SystemDebugMode", true); - //流程控制 - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.3", true); }), "ManualSystemReset", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.4", true); }), "CLearRecipeInfo", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", true); }), "AGVPutTrayFinish", true); - //手动控制电机轴 - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.6", true); }), "StartAxisLoadCommand", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.6", false); }), "StopAxisLoadCommand", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.7", true); }), "StartAxisMidCommand", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.7", false); }), "StopAxisMidCommand", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.0", true); }), "StartAxisUnLoadCommand", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.0", false); }), "StopAxisUnLoadCommand", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.1", true); }), "StartAxis1Command", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.1", false); }), "StopAxis1Command", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.2", true); }), "StartAxis2Command", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.2", false); }), "StopAxis2Command", true); - //电机速度 - ActionManage.GetInstance.Register(new Action((o) => - { - if (o != null && o is short value) - { - HKDevice.HK_PLC_S7.Write("DB47.DBD8", value); - } - }), "AxisLoadSpeedSet", true); - ActionManage.GetInstance.Register(new Action((o) => - { - if (o != null && o is short value) - { - HKDevice.HK_PLC_S7.Write("DB47.DBD10", value); - } - }), "AxisMidSpeedSet", true); - ActionManage.GetInstance.Register(new Action((o) => - { - if (o != null && o is short value) - { - HKDevice.HK_PLC_S7.Write("DB47.DBD12", value); - } - }), "AxisUnLoadSpeedSet", true); - ActionManage.GetInstance.Register(new Action((o) => - { - if (o != null && o is float value) - { - HKDevice.HK_PLC_S7.Write("DB47.DBD0", value); - } - }), "Axis1SpeedSet", true); - ActionManage.GetInstance.Register(new Action((o) => - { - if (o != null && o is float value) - { - HKDevice.HK_PLC_S7.Write("DB47.DBD4", value); - } - }), "Axis2SpeedSet", true); + public void Init() + { + plcVarMonitor(); + StockBinNameWithPos(); + RegisterInit(); + DeviceConnect(); //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 ThreadManage.GetInstance().StartLong(new Action(() => { @@ -335,26 +71,34 @@ namespace BPASmartClient.JXJFoodSmallStation.Model GVL_SmallStation.GetInstance.HeartBeatToPlc = !GVL_SmallStation.GetInstance.HeartBeatToPlc; HKDevice.HK_PLC_S7.Write("DB4.DBX0.0", GVL_SmallStation.GetInstance.HeartBeatToPlc); GVL_SmallStation.GetInstance.HeartBeatFromPlc = HKDevice.HK_PLC_S7.Read("DB45.DBX0.0"); - //获取系统状态 - GVL_SmallStation.SystemStatus = HKDevice.HK_PLC_S7.Read("DB44.DBX0.0");//系统启停 - GVL_SmallStation.SystemMode = HKDevice.HK_PLC_S7.Read("DB44.DBX0.1");//系统模式 - GVL_SmallStation.SystemRunStatus = HKDevice.HK_PLC_S7.Read("DB44.DBX0.2");//系统暂停 } Thread.Sleep(200); - }), "通信心跳", true); + }), "海科plc通信心跳", true); ThreadManage.GetInstance().StartLong(new Action(() => { - DeviceStatusDispose(); - ReceviceData(); - RecipeInfoToHKPLC(); + if (GVL_SmallStation.Order_Cancel) + { + CancelOrder();//订单取消 + } + else + { + ReceviceData();//配方请求 + RecipeInfoToHKPLC();//配方配料 + } Thread.Sleep(10); - }), "西门子配发下发流程处理", true); + }), "小料站流程控制", true); + ThreadManage.GetInstance().StartLong(new Action(() => + { + Real_Time_Data(); + Thread.Sleep(10); + }), "西门子PLC和小料站PLC的实时数据", true); ThreadManage.GetInstance().StartLong(new Action(() => { if (HKDevice.IsConnected) { ManualOpen(); ManualClose(); + HKPlcRead(); } Thread.Sleep(10); }), "手动操作", true); @@ -370,7 +114,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model GVL_SmallStation.GetInstance.Cylinder_JackInfo[i + 8] = HKDevice.HK_PLC_S7.Read("DB5.DBX0." + i); } } - private void ManualOpen() + private void ManualOpen() { ActionManage.GetInstance.Register(new Action((o) => { @@ -379,7 +123,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model if (o.ToString().Contains("升降气缸")) { int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2)); - if (index >= 1 && index <= 15) + if (index >= 1 && index <= 15) { string address = "DB5.DBX" + (index / 8) + "." + (index % 8 - 1); if (index == 8) address = "DB5.DBX0.7"; @@ -434,7 +178,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model else if (o.ToString().Contains("托盘气缸1_1")) { HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", false);//默认伸出 - } + } else if (o.ToString().Contains("托盘气缸1_2")) { HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", false); @@ -530,13 +274,30 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } }), "ManualClose", true);//根据下发的配方ID将 托盘的位置信息添加到配方中 } + public ObservableCollection CommData = new ObservableCollection(); + private void HKPlcRead() + { + foreach (PropertyInfo item in typeof(PlcReadAddressDB3).GetProperties()) + { + int index = Array.FindIndex(CommData.ToArray(), p => p.Name == item.Name); + if (index >= 0) + { + CommData.ElementAt(index).Value = GVL_SmallStation.plcReadDataDB3.GetType().GetProperty(item.Name).GetValue(GVL_SmallStation.plcReadDataDB3, null).ToString(); + } + } + } /// - /// + /// 小料站和西门子PLC之间的实时数据 /// - private void DeviceStatusDispose() + private void Real_Time_Data() { if (HKDevice.IsConnected) { + //获取系统状态 + GVL_SmallStation.SystemStatus = HKDevice.HK_PLC_S7.Read("DB44.DBX0.0");//系统启停 + GVL_SmallStation.SystemMode = HKDevice.HK_PLC_S7.Read("DB44.DBX0.1");//系统模式 + GVL_SmallStation.SystemRunStatus = HKDevice.HK_PLC_S7.Read("DB44.DBX0.2");//系统暂停 + GVL_SmallStation.Station1HaveTray = HKDevice.HK_PLC_S7.Read("DB3.DBX0.7");//工站1 有货架 GVL_SmallStation.Station2HaveTray = HKDevice.HK_PLC_S7.Read("DB3.DBX1.0");//工站2 有货架 if (GVL_SmallStation.WindSendDosingComple) @@ -545,7 +306,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model GVL_SmallStation.WindSendDosingComple = false; MessageNotify.GetInstance.ShowRunLog("风送配料完成信号,发给产线plc信号"); } - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1")) + if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1")) { HKDevice.HK_PLC_S7.Write("DB4.DBX1.7", false); } @@ -553,56 +314,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { GVL_SmallStation.IsAllowSiemensSendRecipe = true; } - GVL_SmallStation.Station1Sensor = HKDevice.HK_PLC_S7.Read("DB3.DBX2.1"); GVL_SmallStation.Station2Sensor = HKDevice.HK_PLC_S7.Read("DB3.DBX2.2"); GVL_SmallStation.Station1Cylinder = HKDevice.HK_PLC_S7.Read("DB3.DBX2.3"); GVL_SmallStation.Station2Cylinder = HKDevice.HK_PLC_S7.Read("DB3.DBX2.4"); - if (!GVL_SmallStation.TrayLogicFinish) - { - if (GVL_SmallStation.AGV_PutTray1Finish) - { - HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", true); - GVL_SmallStation.AGV_PutTray1Finish = false; - MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc"); - } - if (GVL_SmallStation.Station1HaveTray) - { - HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", false); - GVL_SmallStation.TrayLogicFinish = true; - MessageNotify.GetInstance.ShowRunLog("托盘1有货架"); - } - else - { - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.5") == true) - { - if (GVL_SmallStation.CylinderReset) - { - HKDevice.HK_PLC_S7.Write("DB4.DBX1.5", true); - } - MessageNotify.GetInstance.ShowRunLog("气缸收紧错位"); - } - else - { - HKDevice.HK_PLC_S7.Write("DB4.DBX1.5", false); - } - } - } - else - { - if (GVL_SmallStation.AGV_GetTray1Finish) - { - HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", true); - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.7") == true) - { - HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", false); - GVL_SmallStation.TrayLogicFinish = false; - GVL_SmallStation.AGV_GetTray1Finish = false; - } - } - } + GVL_SmallStation.RobotStatus = HKDevice.HK_PLC_S7.Read("DB3.DBW100"); + GVL_SmallStation.RobotProgramNum = HKDevice.HK_PLC_S7.Read("DB3.DBB102"); + } - if (SiemensDevice.IsConnected) + if (SiemensDevice.IsConnected) { ushort TrayCylinder = 0; ushort TraySensor = 0; @@ -625,20 +345,214 @@ namespace BPASmartClient.JXJFoodSmallStation.Model this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.4", GVL_SmallStation.WindSendAllowAGVPutGet); this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW190", TraySensor);//添加工位传感器的信号 this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号 - - if (RTrig.GetInstance("AGV_PutTray1Finish1111").Start(SiemensDevice.XL_Status.AgvFinishPut == 1)) + ushort AGV_Put = (ushort)SiemensDevice.XL_Status.AgvFinishPut; + if (AGV_Put.Get16bitValue(1)) { GVL_SmallStation.AGV_PutTray1Finish = true; } - if (RTrig.GetInstance("AGV_GetTray1Finish111").Start(SiemensDevice.XL_Status.AgvFinishGet == 1)) + else + { + GVL_SmallStation.AGV_PutTray1Finish = false; + } + + + ushort AGV_Get = (ushort)SiemensDevice.XL_Status.AgvFinishGet; + + if (AGV_Get.Get16bitValue(1)) { GVL_SmallStation.AGV_GetTray1Finish = true; } + else + { + GVL_SmallStation.AGV_GetTray1Finish = false; + } + } + } + + public void CancelOrder() + { + if (GVL_SmallStation.Order_Cancel) //订单取消 + { + if (!string.IsNullOrEmpty(GVL_SmallStation.Order_CancelRecipeCode)) + { + string code = GVL_SmallStation.Order_CancelRecipeCode; + int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == code); + + switch (GVL_SmallStation.OrderCancelStep) + { + case 0://前提条件判断 + if (index == -1) + { + GVL_SmallStation.OrderCancelStep = 30; + MessageNotify.GetInstance.ShowRunLog($"配方中并未找到订单{code}"); + } + else + { + if (RecipeQueueTray1.Contains(GVL_SmallStation.Order_CancelRecipeCode)) + { + GVL_SmallStation.OrderCancelStep = 1; + } + else if (RecipeQueueTray2.Contains(GVL_SmallStation.Order_CancelRecipeCode)) + { + GVL_SmallStation.OrderCancelStep = 10; + } + else + { + GVL_SmallStation.OrderCancelStep = 20; + } + } + break; + + //Case 1-9为 + case 1: + if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 != 0) + { + GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0; + HKDevice.HK_PLC_S7.Write("DB4.DBX2.1", true); + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,正在取消订单:{code}"); + GVL_SmallStation.OrderCancelStep = 2; + } + else + { + MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); + GVL_SmallStation.OrderCancelStep = 3; + } + break; + case 2: + if (HKDevice.HK_PLC_S7.Read("DB3.DBX2.5")) + { + if (GVL_SmallStation.Station1Cylinder == false) + { + GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0; + GVL_SmallStation.OrderCancelStep = 3; + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); + } + } + break; + case 3: + SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); + GVL_SmallStation.OrderCancelStep = 4; + break; + case 4: + if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); + GVL_SmallStation.OrderCancelStep = 9; + MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); + } + break; + case 9: + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + RecipeQueueTray1.TryDequeue(out code); + GVL_SmallStation.Tray1LogicFinish = 0; + GVL_SmallStation.Order_Cancel = false; + GVL_SmallStation.Order_CancelRecipeCode = ""; + GVL_SmallStation.OrderCancelStep = 0; + break; + + + case 10: + if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 != 0) + { + GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0; + HKDevice.HK_PLC_S7.Write("DB4.DBX2.2", true); + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,正在取消订单:{code}"); + GVL_SmallStation.OrderCancelStep = 11; + } + else + { + MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); + GVL_SmallStation.OrderCancelStep = 12; + } + break; + case 11: + if (HKDevice.HK_PLC_S7.Read("DB3.DBX2.6")) + { + if (GVL_SmallStation.Station2Cylinder == false) + { + GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0; + GVL_SmallStation.OrderCancelStep = 12; + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); + } + } + break; + + case 12: + SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); + GVL_SmallStation.OrderCancelStep = 13; + break; + case 13: + if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); + GVL_SmallStation.OrderCancelStep = 14; + MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); + } + break; + case 19: + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + RecipeQueueTray2.TryDequeue(out code); + GVL_SmallStation.Order_Cancel = false; + GVL_SmallStation.Tray2LogicFinish = 0; + GVL_SmallStation.Order_CancelRecipeCode = ""; + GVL_SmallStation.OrderCancelStep = 0; + break; + + //20-29为订单还未下发至PLC + case 20: + SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); + GVL_SmallStation.OrderCancelStep = 21; + break; + case 21: + if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); + GVL_SmallStation.OrderCancelStep = 29; + MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); + } + break; + case 29: + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + GVL_SmallStation.Order_Cancel = false; + GVL_SmallStation.Order_CancelRecipeCode = ""; + GVL_SmallStation.SiemensSendRecipeStatus = 0; + GVL_SmallStation.OrderCancelStep = 0; + break; + + //30-39为订单还未下发至上位机 + case 30: + SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); + GVL_SmallStation.OrderCancelStep = 31; + break; + case 31: + if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); + GVL_SmallStation.OrderCancelStep = 39; + MessageNotify.GetInstance.ShowRunLog($"西门子取消订单完成,订单号:{code}"); + } + break; + case 39: + GVL_SmallStation.Order_Cancel = false; + GVL_SmallStation.Order_CancelRecipeCode = ""; + GVL_SmallStation.OrderCancelStep = 0; + break; + } + } } } - /// - /// 将配方添加到配方队列中 - /// + /// + /// 将配方添加到配方队列中 + /// private void ReceviceData() { if (!GVL_SmallStation.GetInstance.IsUseLocalRecipe) @@ -654,32 +568,37 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (SiemensDevice.XL_Status is XL_Status_DB status) { - if (GVL_SmallStation.SiemensSendRecipeStatus == 3) - { - GVL_SmallStation.SiemensSendRecipeStatus = 4; - SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10); - SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true); - MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料"); - } - if (GVL_SmallStation.SiemensSendRecipeStatus == 4) + switch (GVL_SmallStation.SiemensSendRecipeStatus) { - if (SiemensDevice.XL_Status.Dosing_Confirm) - { - GVL_SmallStation.SiemensSendRecipeStatus = 5; - SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串 - SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false); - MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},配料信号复位"); - } - } - if (GVL_SmallStation.SiemensSendRecipeStatus == 5) - { - MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料"); - if (SiemensDevice.XL_Status.Dosing_Confirm == false) - { + case 3: + SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true); + GVL_SmallStation.SiemensSendRecipeStatus = 4; + MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料"); + break; + case 4: + if (SiemensDevice.XL_Status.Dosing_Confirm) + { + SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串 + SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false); + GVL_SmallStation.SiemensSendRecipeStatus = 5; + MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料"); + } + break; + case 5: + if (SiemensDevice.XL_Status.Dosing_Confirm == false) + { + GVL_SmallStation.SiemensSendRecipeStatus = 6; + MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料信号复位完成"); + } + break; + case 6: RecipeQueueTray1.Enqueue(data.RecipeCode); - GVL_SmallStation.SiemensSendRecipeStatus = 6; + GVL_SmallStation.SiemensSendRecipeStatus = 0; MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},加入队列"); - } + break; + default: + break; } } } @@ -690,28 +609,37 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (SiemensDevice.XL_Status is XL_Status_DB status) { - if (GVL_SmallStation.SiemensSendRecipeStatus == 3) - { - GVL_SmallStation.SiemensSendRecipeStatus = 4; - SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10); - SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true); - } - if (GVL_SmallStation.SiemensSendRecipeStatus == 4) - { - if (SiemensDevice.XL_Status.Dosing_Confirm) - { - GVL_SmallStation.SiemensSendRecipeStatus = 5; - SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10); - SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false); - } - } - if (GVL_SmallStation.SiemensSendRecipeStatus == 5) + switch (GVL_SmallStation.SiemensSendRecipeStatus) { - if (SiemensDevice.XL_Status.Dosing_Confirm == false) - { - GVL_SmallStation.SiemensSendRecipeStatus = 0; + case 3: + SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true); + GVL_SmallStation.SiemensSendRecipeStatus = 4; + MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料"); + break; + case 4: + if (SiemensDevice.XL_Status.Dosing_Confirm) + { + SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串 + SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false); + GVL_SmallStation.SiemensSendRecipeStatus = 5; + MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料"); + } + break; + case 5: + if (SiemensDevice.XL_Status.Dosing_Confirm == false) + { + GVL_SmallStation.SiemensSendRecipeStatus = 6; + MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料信号复位完成"); + } + break; + case 6: RecipeQueueTray2.Enqueue(data.RecipeCode); - } + GVL_SmallStation.SiemensSendRecipeStatus = 0; + MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},加入队列"); + break; + default: + break; } } } @@ -722,11 +650,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { RecipeQueueTray1.Clear(); RecipeQueueTray2.Clear(); - GVL_SmallStation.GetInstance.RecipeStatusID = 0; + /*GVL_SmallStation.Tray1LogicFinish = 0; + GVL_SmallStation.Tray2LogicFinish = 0;*/ + GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0; GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0; } } - else + else { RemoteRecipes = Json.Data.Recipes; if (RemoteRecipes.Count > 0) @@ -744,9 +674,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (!(RecipeQueueTray2.Contains(data.RecipeCode))) { - RecipeQueueTray2.Enqueue(data.RecipeCode); - } + } } } } @@ -754,6 +683,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { RecipeQueueTray1.Clear(); RecipeQueueTray2.Clear(); + /*GVL_SmallStation.Tray1LogicFinish = 0; + GVL_SmallStation.Tray2LogicFinish = 0;*/ GVL_SmallStation.GetInstance.DosingTray1 = false; GVL_SmallStation.GetInstance.DosingTray1Loc = 0; @@ -761,135 +692,125 @@ namespace BPASmartClient.JXJFoodSmallStation.Model GVL_SmallStation.GetInstance.DosingTray2 = false; GVL_SmallStation.GetInstance.DosingTray2Loc = 0; - GVL_SmallStation.GetInstance.RecipeStatusID = 0; + GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0; GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0; } } - if (GVL_SmallStation.Order_Cancel) //订单取消 + } + /// + /// 执行配方队列中的第一个配方 + /// + private void RecipeInfoToHKPLC() + { + switch (GVL_SmallStation.Tray1LogicFinish) { - if (!string.IsNullOrEmpty(GVL_SmallStation.Order_CancelRecipeCode)) - { - string code = GVL_SmallStation.Order_CancelRecipeCode; - int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == code); - if (index >= 0) + case 0: + if (GVL_SmallStation.AGV_PutTray1Finish && RecipeQueueTray1.Count > 0) { - short TrayCode = (short)Json.Data.Recipes.ElementAt(index).TrayCode; - if (RecipeQueueTray1.Contains(code) || RecipeQueueTray1.Contains(code)) + HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", true); + GVL_SmallStation.AGV_PutTray1Finish = false; + GVL_SmallStation.Tray1LogicFinish = 1; + MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc"); + } + break; + case 1: + if (GVL_SmallStation.Station1HaveTray) + { + HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", false); + GVL_SmallStation.Tray1LogicFinish = 2; + MessageNotify.GetInstance.ShowRunLog("托盘1有货架"); + } + else + { + if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.5") == true) { - if (RecipeQueueTray1.Contains(code)) - { - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index); - }); - if (GVL_SmallStation.GetInstance.RecipeStatusID != 0) - { - HKDevice.HK_PLC_S7.Write("DB4.DBX2.1", true); - DateTime dateTime = DateTime.Now; - MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,正在取消订单:{code}"); - while (!(HKDevice.HK_PLC_S7.Read("DB3.DBX2.5") || DateTime.Now.Subtract(dateTime).TotalSeconds >= 10)) - { - if (DateTime.Now.Subtract(dateTime).TotalSeconds > 1) - { - MessageNotify.GetInstance.ShowRunLog($"等待PLC取消订单完成:{code}"); - } - } - MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); - } - else - { - MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); - } - GVL_SmallStation.GetInstance.RecipeStatusID = 0; - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); - while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX440.1") == false) - { - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); - RecipeQueueTray1.TryDequeue(out code); - MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); - } - } - else if (RecipeQueueTray2.Contains(code)) + if (GVL_SmallStation.CylinderReset) { - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index); - }); - if (GVL_SmallStation.GetInstance.RecipeStatusID != 0) - { - HKDevice.HK_PLC_S7.Write("DB4.DBX2.2", true); - DateTime dateTime = DateTime.Now; - MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,正在取消订单:{code}"); - while (!(HKDevice.HK_PLC_S7.Read("DB3.DBX2.6") || DateTime.Now.Subtract(dateTime).TotalSeconds >= 10)) - { - if (DateTime.Now.Subtract(dateTime).TotalSeconds > 1) - { - MessageNotify.GetInstance.ShowRunLog($"等待PLC取消订单完成:{code}"); - } - } - MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,已经取消订单:{code}"); - } - else - { - MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); - } - GVL_SmallStation.GetInstance.RecipeStatusID = 0; - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); - while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX440.1") == false) - { - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); - RecipeQueueTray2.TryDequeue(out code); - MessageNotify.GetInstance.ShowRunLog($"队列2,西门子取消订单完成,订单号:{code}"); - } + HKDevice.HK_PLC_S7.Write("DB4.DBX1.5", true); } - GVL_SmallStation.Order_Cancel = false; - GVL_SmallStation.Order_CancelRecipeCode = ""; + MessageNotify.GetInstance.ShowRunLog("气缸收紧错位"); } else { - if (GVL_SmallStation.SiemensSendRecipeStatus != 0 || GVL_SmallStation.SiemensSendRecipeStatus != 1) - { - GVL_SmallStation.SiemensSendRecipeStatus = 0; - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index); - }); - MessageNotify.GetInstance.ShowRunLog($"正在执行请求订单流程,配方还未到PLC,订单号:{code}"); - } - else - { - MessageNotify.GetInstance.ShowRunLog($"订单取消异常,订单号:{code}"); - } - - GVL_SmallStation.Order_Cancel = false; - GVL_SmallStation.Order_CancelRecipeCode = ""; - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); - while (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) - { - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); - } + GVL_SmallStation.Tray1LogicFinish = 1; + HKDevice.HK_PLC_S7.Write("DB4.DBX1.5", false); } } + break; + case 2: + if (GVL_SmallStation.AGV_GetTray1Finish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 0) + { + HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", true); + GVL_SmallStation.Tray1LogicFinish = 3; + MessageNotify.GetInstance.ShowRunLog("AGV取托盘完成"); + } + break; + case 3: + if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.7") == true) + { + HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", false); + GVL_SmallStation.Tray1LogicFinish = 0; + GVL_SmallStation.AGV_GetTray1Finish = false; + MessageNotify.GetInstance.ShowRunLog("plc允许下配方,复位取托盘完成信号"); + } + break; + default: + break; + } + switch (GVL_SmallStation.Tray2LogicFinish) + { + case 0: + if (GVL_SmallStation.AGV_PutTray2Finish) + { + HKDevice.HK_PLC_S7.Write("DB4.DBX1.0", true); + GVL_SmallStation.AGV_PutTray2Finish = false; + GVL_SmallStation.Tray2LogicFinish = 1; + MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc"); + } + break; + case 1: + if (GVL_SmallStation.Station2HaveTray) + { + HKDevice.HK_PLC_S7.Write("DB4.DBX1.0", false); + GVL_SmallStation.Tray2LogicFinish = 2; + MessageNotify.GetInstance.ShowRunLog("托盘1有货架"); + } else { - GVL_SmallStation.Order_Cancel = false; - GVL_SmallStation.Order_CancelRecipeCode = ""; - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); - while (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) + if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.6") == true) { - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); + if (GVL_SmallStation.CylinderReset) + { + HKDevice.HK_PLC_S7.Write("DB4.DBX1.6", true); + } + MessageNotify.GetInstance.ShowRunLog("气缸收紧错位"); + } + else + { + GVL_SmallStation.Tray2LogicFinish = 1; + HKDevice.HK_PLC_S7.Write("DB4.DBX1.6", false); } - MessageNotify.GetInstance.ShowRunLog($"西门子取消订单,但未找到订单:{code}"); } - } + break; + case 2: + if (GVL_SmallStation.AGV_GetTray2Finish && GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 0) + { + HKDevice.HK_PLC_S7.Write("DB4.DBX1.2", true); + GVL_SmallStation.Tray2LogicFinish = 3; + } + break; + case 3: + if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.7") == true) + { + HKDevice.HK_PLC_S7.Write("DB4.DBX1.2", false); + GVL_SmallStation.Tray2LogicFinish = 0; + GVL_SmallStation.AGV_GetTray2Finish = false; + } + break; + default: + break; } - } - /// - /// 执行配方队列中的第一个配方 - /// - private void RecipeInfoToHKPLC() - { - if (RecipeQueueTray1.Count > 0 && GVL_SmallStation.TrayLogicFinish) + if (RecipeQueueTray1.Count > 0 && GVL_SmallStation.Tray1LogicFinish == 2) { int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray1.ElementAt(0)); if (index >= 0 && index < RemoteRecipes.Count) @@ -900,31 +821,31 @@ namespace BPASmartClient.JXJFoodSmallStation.Model string windSend = RemoteRecipes.ElementAt(index).ToString(); if (trayCode == 1) { - if (GVL_SmallStation.GetInstance.RecipeStatusID == 0) + if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 0) { - if (GVL_SmallStation.GetInstance.IsUseWindSend) + if (GVL_SmallStation.GetInstance.IsUseWindSend) { WindSendData.TargetRecipeCode = code; WindSendData.IsAllowDosing = true; - foreach (var item in RemoteRecipes.ElementAt(index).WindSend) + foreach (var item in RemoteRecipes.ElementAt(index).WindSend) { - if (item.RawMaterialName == "0037") + if (item.RawMaterialName == "0037" || item.RawMaterialName == "粉料1") { WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight; } - if (item.RawMaterialName == "0038") + if (item.RawMaterialName == "0038" || item.RawMaterialName == "粉料2") { WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight; } - if (item.RawMaterialName == "") + if (item.RawMaterialName == "0039" || item.RawMaterialName == "粉料3") { WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight; } - if (item.RawMaterialName == "") + if (item.RawMaterialName == "0045" || item.RawMaterialName == "粉料4") { WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight; } - if (item.RawMaterialName == "0036") + if (item.RawMaterialName == "0046" || item.RawMaterialName == "粉料5") { WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight; } @@ -936,18 +857,18 @@ namespace BPASmartClient.JXJFoodSmallStation.Model HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation); } HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true); - GVL_SmallStation.GetInstance.RecipeStatusID = 1; + GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 1; MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成"); GVL_SmallStation.GetInstance.time1 = DateTime.Now; } - - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.3") && GVL_SmallStation.GetInstance.RecipeStatusID == 1) + + if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.3") && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 1) { HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", false); - GVL_SmallStation.GetInstance.RecipeStatusID = 2; + GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 2; MessageNotify.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成"); } - if (GVL_SmallStation.GetInstance.RecipeStatusID == 2) + if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 2) { if (GVL_SmallStation.GetInstance.DosingTray1 == false && GVL_SmallStation.GetInstance.DosingTray1Loc == 0) { @@ -973,7 +894,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14"); MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料"); - if (res > 0 && res is float loc) + if (res > 0 && res is float loc) { int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000; @@ -1034,7 +955,21 @@ namespace BPASmartClient.JXJFoodSmallStation.Model int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback; bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset(); - MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}"); + MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}"); + float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000); + int iIndex = Array.FindIndex(Json.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName); + if (iIndex >= 0) + { + if (Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange) + { + HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true); + App.Current.Dispatcher.Invoke(() => + { + MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning); + HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false); + }); + } + } if (info) { MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送成功"); @@ -1088,14 +1023,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight; } - if (GVL_SmallStation.SiemensSendRecipeStatus == 6) - { - double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds; - GVL_SmallStation.SiemensSendRecipeStatus = 7; - RecipeFinishInfo.Ask_For_Finish = true; - RecipeFinishInfo.DosingTime = Convert.ToInt16(a); - SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); - } + double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds; + RecipeFinishInfo.Ask_For_Finish = true; + RecipeFinishInfo.DosingTime = Convert.ToInt16(a); + SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); } App.Current.Dispatcher.Invoke(() => { @@ -1103,13 +1034,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model }); RecipeQueueTray1.TryDequeue(out code); HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false); - GVL_SmallStation.GetInstance.RecipeStatusID = 0; + GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0; } } - } + } } } - if (RecipeQueueTray2.Count > 0 && GVL_SmallStation.Station2HaveTray) + if (RecipeQueueTray2.Count > 0 && GVL_SmallStation.Tray2LogicFinish == 2) { int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray2.ElementAt(0)); if (index >= 0 && index < RemoteRecipes.Count) @@ -1221,6 +1152,17 @@ namespace BPASmartClient.JXJFoodSmallStation.Model int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback; bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset(); + float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight); + int iIndex = Array.FindIndex(Json.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName); + if (iIndex >= 0) + { + if (Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange) + { + HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true); + MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning); + HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false); + } + } if (info) { MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送成功"); @@ -1274,7 +1216,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - private void StockBinInit() + private void StockBinInit() { for (int i = 1; i < 16; i++) { @@ -1284,7 +1226,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - private void DosingDevice(int Index,int DeviceID) + private void DosingDevice(int Index, int DeviceID) { if (RTrig.GetInstance("Tray2StatusDevice" + DeviceID).Start(DeviceInquire.GetInstance.GetDevice(DeviceID).deviceStatus.RunStatus == 3)) { @@ -1302,18 +1244,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - public void testData() + /// + /// 料仓的位置和原料名称的对应 + /// + public void StockBinNameWithPos() { - //RawMaterialsNamePos.Add("0051", 3); - //RawMaterialsNamePos.Add("0052", 4); - //RawMaterialsNamePos.Add("0054", 5); - //RawMaterialsNamePos.Add("0057", 6); - //RawMaterialsNamePos.Add("0050", 8); - //RawMaterialsNamePos.Add("0048", 13); - - //RawMaterialsNamePos.Add("0036", 13);//I+G - //RawMaterialsNamePos.Add("0037", 13);//味精 - //RawMaterialsNamePos.Add("0038", 13);//白糖 RawMaterialsNamePos.Clear(); foreach (var material in RawMaterialsInfo) { @@ -1325,18 +1260,308 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - } - - public short SetBitValue(short data, byte offset, bool val) + public void plcVarMonitor() { - if (offset > 16 || offset < 1) + foreach (PropertyInfo item in typeof(PlcReadAddressDB3).GetProperties()) { - return data; + CommData.Add(new PlcInfos() + { + Count = CommData.Count + 1, + Name = item.Name, + Address = GVL_SmallStation.plcReadDataDB3.GetType().GetProperty(item.Name).GetCustomAttribute().Address, + Type = item.PropertyType.ToString(), + Describe = GVL_SmallStation.plcReadDataDB3.GetType().GetProperty(item.Name).GetCustomAttribute().Describe, + Value = GVL_SmallStation.plcReadDataDB3.GetType().GetProperty(item.Name).GetValue(GVL_SmallStation.plcReadDataDB3, null).ToString() + }); } + } + public void RegisterInit() + { + //西门子配方处理 + ActionManage.GetInstance.Register(new Action((res) => + { + ObservableCollection RawMaterials = new ObservableCollection(); + ObservableCollection WindSendData = new ObservableCollection(); + if (SiemensDevice.IsConnected) + { + if (res != null && res is XL_Start_DB recipe) + { + if (!string.IsNullOrEmpty(recipe.RecipeCode)) + { + RawMaterials.Clear(); + for (int i = 0; i < GVL_SmallStation.Max_DosingSotckBinNum; i++) + { + if (!string.IsNullOrEmpty(recipe.Material[i].Material_Name)) + { + if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name)) + { + RawMaterials.Add(new RemoteRecipeRawMaterial() + { + RawMaterialName = recipe.Material[i].Material_Name, + RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum, + RawMaterialWeight = recipe.Material[i].Material_Weight, + RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name] + }); + } + else + { + MessageNotify.GetInstance.ShowRunLog($"原料:{recipe.Material[i].Material_Name},不在配料表"); + //MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合"); + } + } + else + { + break; + } + } + for (int i = 0; i < GVL_SmallStation.Max_PowderSotckBinNum; i++) + { + if (!string.IsNullOrEmpty(recipe.Powder[i].Powder_Name)) + { + WindSendData.Add(new WindSendRawMaterial() + { + RawMaterialName = recipe.Powder[i].Powder_Name, + RawMaterialWeight = recipe.Powder[i].Powder_Weight + }); + } + else + { + break; + } + } + App.Current.Dispatcher.Invoke(() => { + Json.Data.Recipes.Add(new RemoteRecipeData() + { + RecipeName = recipe.RecipeName, + RecipeCode = recipe.RecipeCode, + RawMaterial = RawMaterials, + TrayCode = recipe.StockCode, + WindSend = WindSendData + }); + }); + } + } + } + }), "SiemensRecipeRecive", true); + ActionManage.GetInstance.Register(new Action((res) => + { + // if (SiemensDevice.IsConnected) + // { + // if (res != null && res is RemoteRecipeData recipe) + // { + // RecipeFinishInfo.Order_No = recipe.RecipeCode; + // RecipeFinishInfo.Product_Code = recipe.RecipeName; + // RecipeFinishInfo.Job_No = (short)recipe.TrayCode; + // for (int i = 0; i < recipe.RawMaterial.Count; i++) + // { + // RecipeFinishInfo.Material[i] = new UDT1(); + // RecipeFinishInfo.Material[i].Material_Name = recipe.RawMaterial.ElementAt(i).RawMaterialName; + // RecipeFinishInfo.Material[i].Material_BarrelNum = recipe.RawMaterial.ElementAt(i).RawMaterialBarrelNum; + // RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = recipe.RawMaterial.ElementAt(i).Laying_Off_Weight; + // } + // for (int i = 0; i < recipe.WindSend.Count; i++) + // { + // RecipeFinishInfo.Powder[i] = new UDT2(); + // RecipeFinishInfo.Powder[i].Powder_Name = recipe.RawMaterial.ElementAt(i).RawMaterialName; + // RecipeFinishInfo.Powder[i].Powder_Weight = recipe.RawMaterial.ElementAt(i).Laying_Off_Weight; + // } + // if (GVL_SmallStation.SiemensSendRecipeStatus == 6) + // { + // GVL_SmallStation.SiemensSendRecipeStatus = 7; + // RecipeFinishInfo.Ask_For_Finish = true; + // SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); + // } + // } + // } + }), "SiemensRecipeFinish", true); + ActionManage.GetInstance.Register(new Action((res) => + { + if (res != null && res is RemoteRecipeData recipe) + { + Json.Data.Recipes.Add(recipe); + } + }), "LocalSimulationRecipeIssue", true); + ActionManage.GetInstance.Register(new Action(() => + { + Json.Data.Recipes.Clear(); + GVL_SmallStation.SiemensSendRecipeStatus = 0; + + MessageNotify.GetInstance.ShowRunLog("系统流程复位,等待西门子重新下发订单"); + }), "BPASystemReset", true); + //手动控制系统模式 + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.0", true); }), "SystemStart", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.0", false); }), "SystemStop", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.2", true); }), "SystemPause", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.2", false); }), "SystemReset", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.1", false); }), "SystemAutoMode", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.1", true); }), "SystemDebugMode", true); + //流程控制 + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.3", true); }), "ManualSystemReset", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.4", true); }), "CLearRecipeInfo", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", true); }), "AGVPutTrayFinish", true); + //手动控制电机轴 + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.6", true); }), "StartAxisLoadCommand", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.6", false); }), "StopAxisLoadCommand", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.7", true); }), "StartAxisMidCommand", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.7", false); }), "StopAxisMidCommand", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.0", true); }), "StartAxisUnLoadCommand", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.0", false); }), "StopAxisUnLoadCommand", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.1", true); }), "StartAxis1Command", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.1", false); }), "StopAxis1Command", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.2", true); }), "StartAxis2Command", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.2", false); }), "StopAxis2Command", true); + //电机速度 + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null && o is short value) + { + HKDevice.HK_PLC_S7.Write("DB47.DBD8", value); + } + }), "AxisLoadSpeedSet", true); + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null && o is short value) + { + HKDevice.HK_PLC_S7.Write("DB47.DBD10", value); + } + }), "AxisMidSpeedSet", true); + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null && o is short value) + { + HKDevice.HK_PLC_S7.Write("DB47.DBD12", value); + } + }), "AxisUnLoadSpeedSet", true); + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null && o is float value) + { + HKDevice.HK_PLC_S7.Write("DB47.DBD0", value); + } + }), "Axis1SpeedSet", true); + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null && o is float value) + { + HKDevice.HK_PLC_S7.Write("DB47.DBD4", value); + } + }), "Axis2SpeedSet", true); - short num = (short)(1 << offset - 1); - return (short)(val ? (data | num) : (data & ~num)); + + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null && o is string address) + { + HKDevice.HK_PLC_S7.Write(address, true); + } + }), "RobotSendTrueCommand", true); + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null && o is string address) + { + HKDevice.HK_PLC_S7.Write(address, false); + } + }), "RobotSendFalseCommand", true); + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null && o is short Value) + { + HKDevice.HK_PLC_S7.Write("DB4.DBB102", (byte)Value); + } + }), "RobotSetProgramNum", true); + + } + public void DeviceConnect() + { + try + { + if (Json.Data.deviceConnectPar.HKPlcConnect) + { + HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP); + if (HKDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科plc连接成功"); + } + } + catch (Exception ex) + { + MessageNotify.GetInstance.ShowAlarmLog("海科plc连接失败,等待重新连接"); + } + finally + { + HKDevice.Init(); + MessageNotify.GetInstance.ShowRunLog("海科plc初始化完成"); + } + try + { + if (Json.Data.deviceConnectPar.SiemensConnect) + { + SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); + if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功"); + } + } + catch (Exception ex) + { + MessageNotify.GetInstance.ShowAlarmLog("西门子plc连接失败,等待重新连接"); + } + finally + { + SiemensDevice.Init(); + MessageNotify.GetInstance.ShowRunLog("西门子plc初始化完成"); + } + try + { + if (Json.Data.deviceConnectPar.WindSendConnect) + { + WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP); + if (WindSendDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("风送plc连接成功"); + } + } + catch (Exception ex) + { + MessageNotify.GetInstance.ShowAlarmLog("粉料plc连接失败,等待重新连接"); + } + finally + { + WindSendDevice.Init(); + MessageNotify.GetInstance.ShowRunLog("风送粉料plc初始化完成"); + } + ThreadManage.GetInstance().StartLong(new Action(() => + { + try + { + if (!HKDevice.IsConnected && Json.Data.deviceConnectPar.HKPlcConnect) + { + HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP); + if (HKDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接成功"); + } + } + catch (Exception ex) + { + } + try + { + if (!SiemensDevice.IsConnected && Json.Data.deviceConnectPar.SiemensConnect) + { + SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); + if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子PLC重新连接成功"); + } + } + catch (Exception ex) + { + } + try + { + if (!WindSendDevice.IsConnected && Json.Data.deviceConnectPar.WindSendConnect) + { + WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP); + if (WindSendDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("风送plc重新连接成功"); + } + } + catch (Exception ex) + { + } + Thread.Sleep(50); + }), "设备连接", true); } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs index c945af8a..382c3ef4 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs @@ -177,7 +177,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model private void _myPing_PingCompleted(object sender, PingCompletedEventArgs e) { - if (e.Reply.Status == IPStatus.Success) + if (e.Reply != null && e.Reply.Status == IPStatus.Success) { string ip = e.Reply.Address.ToString(); if (!DeviceLists.ContainsKey(ip)) @@ -280,7 +280,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } else IPQueues.Enqueue(e.Reply.Address.ToString()); } - else IPQueues.Enqueue(e.Reply.Address.ToString()); + else + { + if (e.Reply != null) + IPQueues.Enqueue(e.Reply.Address.ToString()); + } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs index 0c5c3d1c..c49c30e1 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs @@ -64,6 +64,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public int StirringSpeed { get { return _mStirringSpeed; } set { _mStirringSpeed = value; OnPropertyChanged(); } } private int _mStirringSpeed; + public float ErrorRange { get { return _mErrorRange; } set { _mErrorRange = value; OnPropertyChanged(); } } + private float _mErrorRange; + /// /// 是否重复 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs index 8d8a160e..ed82b7d0 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs @@ -38,5 +38,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// public ObservableCollection WindSend { get; set; } = new ObservableCollection(); + } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeDataColl.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeDataColl.cs index b412208c..e400db22 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeDataColl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeDataColl.cs @@ -10,5 +10,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens public class RemoteRecipeDataColl { public ObservableCollection Recipes { get; set; } = new ObservableCollection(); + public int RecipesStatus { get; set; } + } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs index 70b95a09..825041db 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs @@ -29,35 +29,52 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens //var DataColl = this.Siemens_PLC_S7.ReadClass(2291); if (Start != null && Start is XL_Start_DB st) { - if (GVL_SmallStation.IsAllowSiemensSendRecipe && GVL_SmallStation.SiemensSendRecipeStatus == 0) + switch (GVL_SmallStation.SiemensSendRecipeStatus) { - GVL_SmallStation.SiemensSendRecipeStatus = 1; - this.Siemens_PLC_S7.Write("DB2201.DBX450.0", true); + case 0: + if (GVL_SmallStation.IsAllowSiemensSendRecipe) + { + this.Siemens_PLC_S7.Write("DB2201.DBX450.0", true); + GVL_SmallStation.SiemensSendRecipeStatus = 1; + } + break; + case 1: + if (Start.Order_Request_ACK) + { + if (!string.IsNullOrEmpty(st.RecipeCode)) + { + GVL_SmallStation.SiemensSendRecipeStatus = 2; + ActionManage.GetInstance.Send("SiemensRecipeRecive", st); + this.Siemens_PLC_S7.Write("DB2201.DBX450.0", false); + } + } + break; + case 2: + if (Start.Order_Request_ACK == false) + { + GVL_SmallStation.IsAllowSiemensSendRecipe = false; + GVL_SmallStation.SiemensSendRecipeStatus = 3; + } + break; } - if (Start.Order_Request_ACK && GVL_SmallStation.SiemensSendRecipeStatus == 1) + if (RTrig.GetInstance("Order_Cancel").Start(st.Order_Cancel)) //订单取消 { - if (!string.IsNullOrEmpty(st.RecipeCode)) + if (GVL_SmallStation.Order_Cancel == false) { - GVL_SmallStation.SiemensSendRecipeStatus = 2; - ActionManage.GetInstance.Send("SiemensRecipeRecive", st); - this.Siemens_PLC_S7.Write("DB2201.DBX450.0", false); + GVL_SmallStation.Order_Cancel = true; + GVL_SmallStation.Order_CancelRecipeCode = st.RecipeCode; + GVL_SmallStation.OrderCancelStep = 0; + MessageNotify.GetInstance.ShowRunLog($"西门子下发取消工单指令:{st.RecipeName}"); + } + else + { + MessageNotify.GetInstance.ShowRunLog($"订单正在取消,请等待订单{ GVL_SmallStation.Order_CancelRecipeCode}取消完成,再取消订单:{st.RecipeName}"); } - } - if (Start.Order_Request_ACK == false && GVL_SmallStation.SiemensSendRecipeStatus == 2) - { - GVL_SmallStation.IsAllowSiemensSendRecipe = false; - GVL_SmallStation.SiemensSendRecipeStatus = 3; - } - if (RTrig.GetInstance("Order_Cancel").Start(st.Order_Cancel)) //订单取消 - { - GVL_SmallStation.Order_Cancel = true; - GVL_SmallStation.Order_CancelRecipeCode = st.RecipeCode; - MessageNotify.GetInstance.ShowRunLog($"西门子下发取消工单指令:{st.RecipeName}"); } } if (Finish != null && Finish is XL_Finish_DB FinishData) { - if (FinishData.Ask_For_Finish_PLC && GVL_SmallStation.SiemensSendRecipeStatus == 7) + if (FinishData.Ask_For_Finish_PLC) { FinishData.Order_No = ""; FinishData.Product_Code = ""; @@ -70,7 +87,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens { FinishData.Powder[i] = new UDT2(); } - GVL_SmallStation.SiemensSendRecipeStatus = 0; FinishData.Ask_For_Finish = false; FinishData.DosingTime = 0; this.Siemens_PLC_S7.WriteClass(FinishData, 2261); diff --git a/BPASmartClient.JXJFoodSmallStation/View/DeviceMaterialParView.xaml b/BPASmartClient.JXJFoodSmallStation/View/DeviceMaterialParView.xaml index f6216d5b..66182267 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/DeviceMaterialParView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/DeviceMaterialParView.xaml @@ -166,6 +166,7 @@ + @@ -227,15 +228,21 @@ Text="搅拌速度" /> + + + + - @@ -259,6 +266,7 @@ + - + - - - + @@ -226,16 +166,17 @@ Panel.ZIndex="0" Style="{StaticResource ImageButtonStyle}"> - + - + + - + + + + + + + diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs index 9322b444..f367620c 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs @@ -76,33 +76,44 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel switch (GVL_SmallStation.SiemensSendRecipeStatus) { case 0: - OrderStatus = "初始状态"; + OrderStatus = IssueRecipeCondition.等待小料站PLC允许下配方.ToString(); break; case 1: - OrderStatus = "向西门子请求配方"; + OrderStatus = IssueRecipeCondition.等待西门子下发配方.ToString(); break; case 2: - OrderStatus = "上位机接收到配方"; + OrderStatus = IssueRecipeCondition.等待西门子下发配方信号复位.ToString(); break; case 3: - OrderStatus = "西门子确认上位机接收到配方"; + OrderStatus = IssueRecipeCondition.等待上位机请求配料.ToString(); break; case 4: - OrderStatus = "上位机向西门子请求配料"; + OrderStatus = IssueRecipeCondition.等待西门子确认配料.ToString(); break; case 5: - OrderStatus = "西门子确认配料"; + OrderStatus = IssueRecipeCondition.等待西门子确认配料信号复位.ToString(); break; case 6: - OrderStatus = "上位机将配方进行配料"; - break; - case 7: - OrderStatus = "配料完成"; + OrderStatus = "上位机将配方添加到队列中"; break; default: OrderStatus = "无意义"; break; } + switch (GVL_SmallStation.GetInstance.RecipeStatusIDTray1) + { + case 0: + OrderDosingStatus = ProcessCondition.等待AGV到位.ToString(); + break; + case 1: + OrderDosingStatus = ProcessCondition.等待小料站PLC接受配方完成.ToString(); + break; + case 2: + OrderDosingStatus = ProcessCondition.等待配方配料完成.ToString(); + break; + default: + break; + } Thread.Sleep(100); }), "流程手动设备状态读取",true); TimeSet = new RelayCommand(() => @@ -126,7 +137,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel private int _mtime; public static string OrderStatus { get { return _mOrderStatus; } set { _mOrderStatus = value; OnStaticPropertyChanged(); } } private static string _mOrderStatus = "无意义"; - + public static string OrderDosingStatus { get { return _mOrderDosingStatus; } set { _mOrderDosingStatus = value; OnStaticPropertyChanged(); } } + private static string _mOrderDosingStatus = "无意义"; public static event EventHandler StaticPropertyChanged; public static void OnStaticPropertyChanged([CallerMemberName] string PropName = "") { diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/PlcVarMonitorViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/PlcVarMonitorViewModel.cs new file mode 100644 index 00000000..1317ea02 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/PlcVarMonitorViewModel.cs @@ -0,0 +1,23 @@ +using BPASmartClient.JXJFoodSmallStation.Model; +using BPASmartClient.JXJFoodSmallStation.Model.GVL; +using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.ViewModel +{ + public class PlcVarMonitorViewModel : ObservableObject + { + public PlcVarMonitorViewModel() + { + + } + public ObservableCollection plcInfos => ProcessControl.GetInstance.CommData; + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RobotViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RobotViewModel.cs index 00e74683..7910aae8 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/RobotViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RobotViewModel.cs @@ -23,19 +23,100 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { public RobotViewModel() { + ThreadManage.GetInstance().StartLong(() => + { + IsRunProgramNum = GVL_SmallStation.RobotProgramNum; + RobotIsAutoMode = GVL_SmallStation.RobotStatus.GetBitValue(1); + RobotIsAutoRun = GVL_SmallStation.RobotStatus.GetBitValue(2); + RobotIsStop = GVL_SmallStation.RobotStatus.GetBitValue(3); + RobotIsRun = GVL_SmallStation.RobotStatus.GetBitValue(4); + RobotIsAlarm = GVL_SmallStation.RobotStatus.GetBitValue(5); + RobotIsHomed = GVL_SmallStation.RobotStatus.GetBitValue(6); + RobotGetEmptyBarrelComplete = GVL_SmallStation.RobotStatus.GetBitValue(8); + RobotPutEmptyBarrelComplete = GVL_SmallStation.RobotStatus.GetBitValue(9); + RobotGetFullBarrelComplete = GVL_SmallStation.RobotStatus.GetBitValue(10); + RobotPutFullBarrelComplete = GVL_SmallStation.RobotStatus.GetBitValue(11); + + },"机器人状态",true); + SystemStart = new RelayCommand(() => { + ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX100.0"); + }); + SystemStop = new RelayCommand(() => { + ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX100.1"); + }); + EStopReset = new RelayCommand(() => { + ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX100.2"); + }); + + TestRobotRun = new RelayCommand(() => { + ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX100.4"); + }); + AutoMode = new RelayCommand(() => { + ActionManage.GetInstance.Send("RobotSendFalseCommand", "DB4.DBX100.3"); + }); + TestMode = new RelayCommand(() => { + ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX100.3"); + }); + + RobotGetEmptyBarrel = new RelayCommand(() => { + ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX100.7"); + }); + RobotPutEmptyBarrel = new RelayCommand(() => { + ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX101.0"); + }); + RobotGetFullBarrel = new RelayCommand(() => { + ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX101.1"); + }); + RobotPutFullBarrel = new RelayCommand(() => { + ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX101.2"); + }); + SetProgramNumCommand = new RelayCommand(() =>{ + ActionManage.GetInstance.Send("RobotSetProgramNum", SetProgramNum); + }); } public RelayCommand SystemStart { get; set; } public RelayCommand SystemStop { get; set; } - public RelayCommand SystemReset { get; set; } - public RelayCommand AlarmReset { get; set; } + public RelayCommand EStopReset { get; set; } + public RelayCommand TestRobotRun { get; set; } - public RelayCommand Tray1Cylinder { get; set; } + public RelayCommand AutoMode { get; set; } + public RelayCommand TestMode { get; set; } + + public RelayCommand RobotGetEmptyBarrel { get; set; } + public RelayCommand RobotPutEmptyBarrel { get; set; } + public RelayCommand RobotGetFullBarrel { get; set; } + public RelayCommand RobotPutFullBarrel { get; set; } + public RelayCommand SetProgramNumCommand { get; set; } public short IsRunProgramNum { get { return _runProgramNum; } set { _runProgramNum = value;OnPropertyChanged(); } } private short _runProgramNum; public short SetProgramNum { get { return _SetProgramNum; } set { _SetProgramNum = value; OnPropertyChanged(); } } private short _SetProgramNum; + + public bool RobotIsAutoMode { get { return _RobotIsAutoMode; } set { _RobotIsAutoMode = value; OnPropertyChanged(); } } + private bool _RobotIsAutoMode; + public bool RobotIsAutoRun { get { return _RobotIsAutoRun; } set { _RobotIsAutoRun = value; OnPropertyChanged(); } } + private bool _RobotIsAutoRun; + public bool RobotIsStop { get { return _RobotIsStop; } set { _RobotIsStop = value; OnPropertyChanged(); } } + private bool _RobotIsStop; + public bool RobotIsRun { get { return _RobotIsRun; } set { _RobotIsRun = value; OnPropertyChanged(); } } + private bool _RobotIsRun; + public bool RobotIsAlarm { get { return _RobotIsAlarm; } set { _RobotIsAlarm = value; OnPropertyChanged(); } } + private bool _RobotIsAlarm; + public bool RobotIsHomed { get { return _RobotIsHomed; } set { _RobotIsHomed = value; OnPropertyChanged(); } } + private bool _RobotIsHomed; + public bool RobotGetEmptyBarrelComplete { get { return _RobotGetEmptyBarrelComplete; } set { _RobotGetEmptyBarrelComplete = value; OnPropertyChanged(); } } + private bool _RobotGetEmptyBarrelComplete; + public bool RobotPutEmptyBarrelComplete { get { return _RobotPutEmptyBarrelComplete; } set { _RobotPutEmptyBarrelComplete = value; OnPropertyChanged(); } } + private bool _RobotPutEmptyBarrelComplete; + public bool RobotGetFullBarrelComplete { get { return _RobotGetFullBarrelComplete; } set { _RobotGetFullBarrelComplete = value; OnPropertyChanged(); } } + private bool _RobotGetFullBarrelComplete; + + public bool RobotPutFullBarrelComplete { get { return _RobotPutFullBarrelComplete; } set { _RobotPutFullBarrelComplete = value; OnPropertyChanged(); } } + private bool _RobotPutFullBarrelComplete; + + public static event EventHandler StaticPropertyChanged; public static void OnStaticPropertyChanged([CallerMemberName] string PropName = "") { diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/StockBinRawMaterialViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/StockBinRawMaterialViewModel.cs index c7ecea4d..67ede639 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/StockBinRawMaterialViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/StockBinRawMaterialViewModel.cs @@ -34,7 +34,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel SaveRawMaterialPara = new RelayCommand(() => { Json.Save(); - ProcessControl.GetInstance.testData(); + ProcessControl.GetInstance.StockBinNameWithPos(); foreach (var item in Json.Data.rawMaterialStockBin) { MessageNotify.GetInstance.ShowUserLog($"料仓位置:"+ item.RawMaterialLocation+ ",物料编码:" + item.RawMaterialName); diff --git a/BPASmartClient.JakaRobot/JaKaHelper.cs b/BPASmartClient.JakaRobot/JaKaHelper.cs index 1402fff6..85c0ce2f 100644 --- a/BPASmartClient.JakaRobot/JaKaHelper.cs +++ b/BPASmartClient.JakaRobot/JaKaHelper.cs @@ -86,7 +86,6 @@ namespace BPASmartClient.JakaRobot { jakaAPI.create_handler(ip.ToCharArray(), ref rshd); login = true; - } catch (Exception ex) { @@ -98,7 +97,7 @@ namespace BPASmartClient.JakaRobot } Thread.Sleep(3000); } - } + } if (login && IsDeviceFirstInit==false) { try diff --git a/BPASmartClient.S7Net/EntityClassResolution.cs b/BPASmartClient.S7Net/EntityClassResolution.cs index 90d60ade..924af76a 100644 --- a/BPASmartClient.S7Net/EntityClassResolution.cs +++ b/BPASmartClient.S7Net/EntityClassResolution.cs @@ -27,7 +27,7 @@ namespace BPASmartClient.S7Net numBytes += 0.125; break; case "Byte": - IncrementToEven(ref numBytes); + //IncrementToEven(ref numBytes); numBytes += 1.0; break; case "Int16": diff --git a/DosingSystem/ViewModel/RecipeControlViewModel.cs b/DosingSystem/ViewModel/RecipeControlViewModel.cs index 41efb490..f5667637 100644 --- a/DosingSystem/ViewModel/RecipeControlViewModel.cs +++ b/DosingSystem/ViewModel/RecipeControlViewModel.cs @@ -574,7 +574,7 @@ namespace BPASmartClient.DosingSystem.ViewModel else { int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt); - Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel); + Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel); } if (Location1 >= 0) { diff --git a/SmartClient.sln b/SmartClient.sln index fe0ca1ff..d42e1fe1 100644 --- a/SmartClient.sln +++ b/SmartClient.sln @@ -204,13 +204,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "设备监控", "设备监 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MaxWokControl", "BPASmartClient.MaxWokControl\BPASmartClient.MaxWokControl.csproj", "{888382C0-6750-4E81-BED3-0F38775DCCCB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MorkSUpgradedVer", "BPASmartClient.MorkSUpgradedVer\BPASmartClient.MorkSUpgradedVer.csproj", "{C467ACE0-1BB4-44F0-9B5E-AFFFB58846D3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkSUpgradedVer", "BPASmartClient.MorkSUpgradedVer\BPASmartClient.MorkSUpgradedVer.csproj", "{C467ACE0-1BB4-44F0-9B5E-AFFFB58846D3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkS3", "BPASmartClient.MorkS3\BPASmartClient.MorkS3.csproj", "{B38F72AE-3C15-4C4E-A47E-DB2B9B318F02}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.RobotGripper", "BPASmartClient.RobotGripper\BPASmartClient.RobotGripper.csproj", "{5EBC34EB-4EE8-4C70-BAAA-C7F637D5E10F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MilkTeaCube", "BPASmartClient.MilkTeaCube\BPASmartClient.MilkTeaCube.csproj", "{915F0718-B7AC-428D-ACD5-7DAACC28539F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MilkTeaCube", "BPASmartClient.MilkTeaCube\BPASmartClient.MilkTeaCube.csproj", "{915F0718-B7AC-428D-ACD5-7DAACC28539F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/WpfControlLibrary1/AssemblyInfo.cs b/WpfControlLibrary1/AssemblyInfo.cs new file mode 100644 index 00000000..8b5504ec --- /dev/null +++ b/WpfControlLibrary1/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/WpfControlLibrary1/UserControl1.xaml b/WpfControlLibrary1/UserControl1.xaml new file mode 100644 index 00000000..dead4a4b --- /dev/null +++ b/WpfControlLibrary1/UserControl1.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/WpfControlLibrary1/UserControl1.xaml.cs b/WpfControlLibrary1/UserControl1.xaml.cs new file mode 100644 index 00000000..fc7b24ea --- /dev/null +++ b/WpfControlLibrary1/UserControl1.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace WpfControlLibrary1 +{ + /// + /// Interaction logic for UserControl1.xaml + /// + public partial class UserControl1 : UserControl + { + public UserControl1() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/WpfControlLibrary1/WpfControlLibrary1.csproj b/WpfControlLibrary1/WpfControlLibrary1.csproj new file mode 100644 index 00000000..c6ee76c2 --- /dev/null +++ b/WpfControlLibrary1/WpfControlLibrary1.csproj @@ -0,0 +1,9 @@ + + + + net6.0-windows + enable + true + + +