diff --git a/BPASmartClient.Business/BPASmartClient.Business.csproj b/BPASmartClient.Business/BPASmartClient.Business.csproj index b7492b30..b32e9dc1 100644 --- a/BPASmartClient.Business/BPASmartClient.Business.csproj +++ b/BPASmartClient.Business/BPASmartClient.Business.csproj @@ -8,7 +8,7 @@ - + diff --git a/BPASmartClient.Business/LocalMqtt.cs b/BPASmartClient.Business/LocalMqtt.cs index a629d7a9..7a8cefb9 100644 --- a/BPASmartClient.Business/LocalMqtt.cs +++ b/BPASmartClient.Business/LocalMqtt.cs @@ -33,7 +33,7 @@ namespace BPASmartClient.Business { MqttPushs.Name = DeviceType; LocDeviceType = DeviceType; - mQTTProxy.ConnectOk = new Action(() => + mQTTProxy.Connected = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(DeviceType)); diff --git a/BPASmartClient.Business/Plugin/MQTTMgr.cs b/BPASmartClient.Business/Plugin/MQTTMgr.cs index 7fedd3f7..2479de0d 100644 --- a/BPASmartClient.Business/Plugin/MQTTMgr.cs +++ b/BPASmartClient.Business/Plugin/MQTTMgr.cs @@ -44,7 +44,7 @@ namespace BPASmartClient.Business //主题初始化 TopicDefine.GetInstance().Initialize(Plugin.GetInstance().GetPlugin().GetDevices()); - mqttProxy.ConnectOk = () => + mqttProxy.Connected = () => { mqttProxy.Subscrib(TopicDefine.GetInstance().SubscribTopics.ToArray()); }; @@ -55,7 +55,11 @@ namespace BPASmartClient.Business var MqttServerConfig = Plugin.GetInstance().GetPlugin().MQTT_Config; var MqttServerAccount = Plugin.GetInstance().GetPlugin().Mqtt_Account; var deviceConfig = Plugin.GetInstance().GetPlugin().deviceConfigModelJsons; - string deviceId = deviceConfig[0].deviceModels[0].DeviceId; + string deviceId = ""; + if (deviceConfig.Count > 0 && deviceConfig[0].deviceModels.Count > 0) + { + deviceId = deviceConfig[0].deviceModels[0].DeviceId; + } clientId = Plugin.GetInstance().GetPlugin().ClientId; //MQTT 初始化 mqttProxy.Connect(new BPA.Communication.Base.ConfigurationOptions() diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj index 767b8ea8..f04be251 100644 --- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj +++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj @@ -463,7 +463,7 @@ - + diff --git a/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs b/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs index efa5fb98..696a7922 100644 --- a/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs +++ b/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs @@ -106,9 +106,16 @@ namespace BPASmartClient.CustomResource.Pages.Model Value = value.ToString(), Time = DateTime.Now.ToString("HH:mm:ss"), }; + try + { + var res = Sqlite.GetInstance.Base.Add(tempAlarm); + + Sqlite.GetInstance.Save(); + } + catch (Exception) + { + } - var res = Sqlite.GetInstance.Base.Add(tempAlarm); - Sqlite.GetInstance.Save(); if (Alarms.FirstOrDefault(p => p.Info == AlarmInfo) == null) { diff --git a/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs b/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs index 99fded33..8274acf9 100644 --- a/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs +++ b/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs @@ -41,10 +41,18 @@ namespace BPASmartClient.CustomResource.Pages.Model public void LogSave() { - Sqlite.GetInstance.Save(); - Sqlite.GetInstance.Save(); - Sqlite.GetInstance.Save(); - Sqlite.GetInstance.Save(); + try + { + Sqlite.GetInstance.Save(); + Sqlite.GetInstance.Save(); + Sqlite.GetInstance.Save(); + Sqlite.GetInstance.Save(); + } + catch (Exception) + { + + // throw; + } } public void ShowRecipeLog(string info) diff --git a/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs b/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs index 378cb5f2..87bc7ea1 100644 --- a/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs +++ b/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs @@ -57,19 +57,27 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel BPA.Helper.MessageLog.GetInstance.NotifyShow = new Action((o) => { - Application.Current?.Dispatcher?.Invoke(() => + try { - //ff20aefe - var temp = new MessageModel() - { - LogInfo = o, - Forground = new SolidColorBrush(Color.FromArgb(255, 32, 174, 254)) - }; - if (DebugLogViewModel.MessageModels.Count > 0) - DebugLogViewModel.MessageModels.Insert(0, temp); - else - DebugLogViewModel.MessageModels.Add(temp); - }); + Application.Current?.Dispatcher?.Invoke(() => + { + //ff20aefe + var temp = new MessageModel() + { + LogInfo = o, + Forground = new SolidColorBrush(Color.FromArgb(255, 32, 174, 254)) + }; + if (DebugLogViewModel.MessageModels.Count > 0) + DebugLogViewModel.MessageModels.Insert(0, temp); + else + DebugLogViewModel.MessageModels.Add(temp); + }); + } + catch (Exception) + { + + //throw; + } }); BPA.Helper.MessageLog.GetInstance.NotifyShowEx = new Action((o) => { diff --git a/BPASmartClient.Device/BaseDevice.cs b/BPASmartClient.Device/BaseDevice.cs index 072e3f50..c19bcca2 100644 --- a/BPASmartClient.Device/BaseDevice.cs +++ b/BPASmartClient.Device/BaseDevice.cs @@ -162,7 +162,7 @@ namespace BPASmartClient.Device /// public void DeviceProcessLogShow(string info) { - Log.Insert(0, new { Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Type = "流程", Text = info }); + Log.Insert(0, new { Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"), Type = "流程", Text = info }); MessageLog.GetInstance.DeviceProcessLogShow(DeviceId.ToString(), info); if (Log.Count > 100) { Log.RemoveAt(Log.Count - 1); } } diff --git a/BPASmartClient.Device/VariableMonitorAttribute.cs b/BPASmartClient.Device/VariableMonitorAttribute.cs index 8d4ba870..7eb17b4b 100644 --- a/BPASmartClient.Device/VariableMonitorAttribute.cs +++ b/BPASmartClient.Device/VariableMonitorAttribute.cs @@ -28,7 +28,12 @@ namespace BPASmartClient.Device if (address.Length > 0) { address = address.Trim(); - if (address.ToUpper().Contains("M") && address.Length >= 4) + if (address.ToUpper().Contains("GM") && address.Length >= 3) + { + var res = address.Remove(0, 2); + if (res != null && res.Length > 0) return (int.Parse(res) + 4096).ToString(); + } + else if (address.ToUpper().Contains("M") && address.Length >= 4) { var res = address.Substring(1).Split('.'); if (res != null && res.Length == 2) @@ -42,6 +47,19 @@ namespace BPASmartClient.Device } } } + else if (address.ToUpper().Contains("GI") && address.Length >= 3) + { + var res = address.Remove(0, 2); + if (res != null && res.Length > 0) return res; + } + else if (address.ToUpper().Contains("LB") && address.Length >= 3) + { + var res = address.Substring(2); + if (res != null && res.Length > 0) + { + if (int.TryParse(res, out int firstAddress)) return firstAddress.ToString(); + } + } else if ((address.ToUpper().Contains("VW") || address.ToUpper().Contains("VD")) && address.Length >= 3) { var res = address.Substring(2); @@ -50,8 +68,44 @@ namespace BPASmartClient.Device return ((tempAddress / 2) + 100).ToString(); } } + else if (address.ToUpper().Contains("LW") && address.Length >= 3) + { + var res = address.Substring(2); + if (res != null && int.TryParse(res, out int LwAddress)) + { + return LwAddress.ToString(); + } + } } return ""; + //if (address == null) return ""; + //if (address.Length > 0) + //{ + // address = address.Trim(); + // if (address.ToUpper().Contains("M") && address.Length >= 4) + // { + // var res = address.Substring(1).Split('.'); + // if (res != null && res.Length == 2) + // { + // if (int.TryParse(res[0], out int firstAddress) && int.TryParse(res[1], out int ExitAddress)) + // { + // if (ExitAddress >= 0 && ExitAddress <= 7) + // { + // return ((firstAddress * 8) + 320 + ExitAddress).ToString(); + // } + // } + // } + // } + // else if ((address.ToUpper().Contains("VW") || address.ToUpper().Contains("VD")) && address.Length >= 3) + // { + // var res = address.Substring(2); + // if (res != null && int.TryParse(res, out int tempAddress)) + // { + // return ((tempAddress / 2) + 100).ToString(); + // } + // } + //} + //return ""; } /// diff --git a/BPASmartClient.DosingSystemSingle/BPASmartClient.DosingSystemSingle.csproj b/BPASmartClient.DosingSystemSingle/BPASmartClient.DosingSystemSingle.csproj index 465ab84c..4ff09e8b 100644 --- a/BPASmartClient.DosingSystemSingle/BPASmartClient.DosingSystemSingle.csproj +++ b/BPASmartClient.DosingSystemSingle/BPASmartClient.DosingSystemSingle.csproj @@ -16,7 +16,7 @@ - + diff --git a/BPASmartClient.FoodStationTest/BPASmartClient.FoodStationTest.csproj b/BPASmartClient.FoodStationTest/BPASmartClient.FoodStationTest.csproj index 49bd8a14..4f950498 100644 --- a/BPASmartClient.FoodStationTest/BPASmartClient.FoodStationTest.csproj +++ b/BPASmartClient.FoodStationTest/BPASmartClient.FoodStationTest.csproj @@ -16,7 +16,7 @@ - + diff --git a/BPASmartClient.FoodStationTest/Model/RawMaterial/DeviceInquire.cs b/BPASmartClient.FoodStationTest/Model/RawMaterial/DeviceInquire.cs index fe350ef6..e8b73391 100644 --- a/BPASmartClient.FoodStationTest/Model/RawMaterial/DeviceInquire.cs +++ b/BPASmartClient.FoodStationTest/Model/RawMaterial/DeviceInquire.cs @@ -185,7 +185,7 @@ namespace BPASmartClient.FoodStationTest.Model DeviceStatus DS = new DeviceStatus(); DS.modbusTcp.IsReconnect = false; - DS.modbusTcp.ConnectOk = new Action(() => + DS.modbusTcp.Connected = new Action(() => { string DeviceName = DS.modbusTcp.Read(DeviceAddress.DeviceName, 20).Content.Trim()?.Replace(" ", "");//读取设备名称 if (DeviceName.Length > 0) diff --git a/BPASmartClient.IoT/Model/DataVReport.cs b/BPASmartClient.IoT/Model/DataVReport.cs index 543696c9..517c1671 100644 --- a/BPASmartClient.IoT/Model/DataVReport.cs +++ b/BPASmartClient.IoT/Model/DataVReport.cs @@ -199,7 +199,7 @@ namespace BPASmartDatavDeviceClient.IoT //json = APIHelper.GetInstance.GetRequest($"{url}/api/Device/Query?clientId={clientId}&deviceId={deviceId}"); json = APIHelper.GetInstance.GetRequest($"{url}/api/Device/Query?clientId={clientId}&deviceId={deviceId}"); JsonMsg> jsonMsg = Tools.JsonToObjectTools>>(json); - if (jsonMsg.obj != null && jsonMsg.obj.data != null) + if (jsonMsg != null && jsonMsg.obj != null && jsonMsg.obj.data != null) { device = jsonMsg.obj.data.FirstOrDefault(); if (device == null) return false; diff --git a/BPASmartClient.JXJFoodBigStation/App.config b/BPASmartClient.JXJFoodBigStation/App.config index 35b80a6d..5ce280c3 100644 --- a/BPASmartClient.JXJFoodBigStation/App.config +++ b/BPASmartClient.JXJFoodBigStation/App.config @@ -2,8 +2,12 @@ - - + + + + + + \ No newline at end of file diff --git a/BPASmartClient.JXJFoodBigStation/App.xaml.cs b/BPASmartClient.JXJFoodBigStation/App.xaml.cs index 6b0da0f3..8497fc7c 100644 --- a/BPASmartClient.JXJFoodBigStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodBigStation/App.xaml.cs @@ -181,6 +181,13 @@ namespace BPASmartClient.JXJFoodBigStation ToggleWindowPath = "View.HKPlcCommMonitorView" }); DeviceMonitor.Add(new SubMenumodel() + { + SubMenuName = "全局变量", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + AssemblyName = "BPASmartClient.JXJFoodBigStation", + ToggleWindowPath = "View.GlobalVarMonitorView" + }); + DeviceMonitor.Add(new SubMenumodel() { SubMenuName = "手动流程", SubMenuPermission = new Permission[] { Permission.管理员 }, diff --git a/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj b/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj index b9be36f1..8d391c88 100644 --- a/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj +++ b/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj @@ -17,8 +17,8 @@ - - + + diff --git a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs index ff7f543e..72a12cae 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs @@ -15,58 +15,76 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// plc心跳上传 /// + [PlcComm("plc心跳上传")] public static bool HeartBeatFromPlc { get; set; } /// /// 订单取消的状态位 /// + [PlcComm("订单取消的状态位")] public static bool Order_Cancel { get; set; } /// /// 订单取消的配方号 /// + [PlcComm("订单取消的配方号")] public static string Order_CancelRecipeCode { get; set; } = ""; + /// + /// 订单取消的状态步 + /// + [PlcComm("订单取消的状态步")] public static int Order_CancelStep { get; set; } /// /// 第一个配方的配料时间 /// + [PlcComm("第一个配方的配料时间")] public static DateTime DosingRecipe1Time { get; set; } /// /// 第二个配方的配料时间 /// + [PlcComm("第二个配方的配料时间")] public static DateTime DosingRecipe2Time { get; set; } /// /// 第三个配方的配料时间 /// + [PlcComm("第三个配方的配料时间")] public static DateTime DosingRecipe3Time { get; set; } /// /// 第四个配方的配料时间 /// + [PlcComm("第四个配方的配料时间")] public static DateTime DosingRecipe4Time { get; set; } /// /// plc心跳下发 /// + [PlcComm("plc心跳下发")] public static bool HeartBeatToPlc { get; set; } /// /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 /// + [PlcComm("配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方")] public static int Recipe1DosingStatus { get; set; } /// /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 /// + [PlcComm("配方2下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方")] public static int Recipe2DosingStatus { get; set; } /// /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 /// + [PlcComm("配方3下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方")] public static int Recipe3DosingStatus { get; set; } /// /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 /// + [PlcComm("配方4下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方")] public static int Recipe4DosingStatus { get; set; } - public static int[] RecipeDosingStatus { get; set; } = new int[4] { 0, 0, 0, 0 }; + public static bool[] AllowIssueRecipe { get; set; } = new bool[4] { false, false, false, false }; + public static bool[] ReceviceFinishRecipe { get; set; } = new bool[4] { false, false, false, false }; + public static bool[] DosingFinishRecipe { get; set; } = new bool[4] { false, false, false, false }; public static bool[] IsTrayArrive { get; set; } = new bool[5] { false, false, false, false,false }; @@ -75,19 +93,23 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 是否处于手动下发配方 /// + [PlcComm("是否处于手动下发配方")] public static bool IsUseLocalRecipe { get; set; } = false; /// /// 洗桶的标识符 /// + [PlcComm("洗桶的标识符")] public static bool BarrelWasherSign { get; set; } /// /// 订单请求 /// + [PlcComm("订单请求")] public static bool Order_Request { get; set; } = false; /// /// 下发配方的状态位 /// + [PlcComm("下发配方的状态位")] public static int SiemensSendRecipeStatus { get; set; } = 0; /// @@ -101,10 +123,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// public static Dictionary RawMaterialsNameCode { get; set; } = new Dictionary(); + [PlcComm("AGV送托盘")] public static ushort AGVPutTray { get; set; } + [PlcComm("AGV取托盘")] public static ushort AGVGetTray { get; set; } + [PlcComm("托盘传感器信号")] public static ushort TraySensor { get; set; } + [PlcComm("托盘气缸信号")] public static ushort TrayCylinder { get; set; } public static DB_Read HKPlc_Read = new DB_Read(); @@ -112,33 +138,41 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 是否连接海科PLC /// + [PlcComm("是否连接海科PLC")] public static bool IsAllowHKPlcConnect { get; set; } /// /// 是否连接西门子PLC /// + [PlcComm("是否连接西门子PLC")] public static bool IsAllowSiemensConnect { get; set; } /// /// 配方1配料完成 /// + [PlcComm("配方1配料完成")] public static bool Recipe1DosingFinish { get; set; } = false; /// /// 配方2配料完成 /// + [PlcComm("配方2配料完成")] public static bool Recipe2DosingFinish { get; set; } = false; /// /// 配方3配料完成 /// + [PlcComm("配方3配料完成")] public static bool Recipe3DosingFinish { get; set; } = false; /// /// 配方4配料完成 /// + [PlcComm("配方4配料完成")] public static bool Recipe4DosingFinish { get; set; } = false; /// /// 订单是否是洗桶 /// + [PlcComm("订单是否是洗桶")] public static bool Order_IsWashingBarrel { get; set; } = false; + [PlcComm("TrayEnable")] public static int TrayEnable { get; set; } = 15; } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs index 4d12381e..c003b788 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs @@ -7,6 +7,9 @@ using System.Threading.Tasks; namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC { + /// + /// 上位机只写的DB99。 + /// public class DB_Write { /// diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs index e8aaa5dc..a6ccba15 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs @@ -78,7 +78,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC { int index = Array.FindIndex(recipe.RawMaterial.ToArray(), p => p.RawMaterialBarrelNum == barrel && p.RawMaterialLocation == loc); - #region 新版本 int x = 0; if (barrel < 3) x = (barrel - 1) * 56 + 6; else if (barrel > 3) x = (barrel - 2) * 56 + 6; @@ -93,64 +92,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC HK_PLC_S7.Write(address, recipe.RawMaterial.ElementAt(index).RawMaterialWeight); MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}"); } - #endregion - - #region 旧版本 - //if (index == -1) - //{ - // switch (barrel) - // { - // case 1: - // string address = "DB99.DBD" + (6 + 4 * (loc - 1)); - // HK_PLC_S7.Write(address, 0); - // break; - // case 2: - // string address1 = "DB99.DBD" + (62 + 4 * (loc - 1)); - // HK_PLC_S7.Write(address1, 0); - // break; - // case 4: - // string address2 = "DB99.DBD" + (118 + 4 * (loc - 1)); - // HK_PLC_S7.Write(address2, 0); - // break; - // case 5: - // string address3 = "DB99.DBD" + (174 + 4 * (loc - 1)); - // HK_PLC_S7.Write(address3, 0); - // break; - // default: - // break; - - // } - //} - //else - //{ - // switch (barrel) - // { - // case 1: - // string address = "DB99.DBD" + (6 + 4 * (loc - 1)); - // HK_PLC_S7.Write(address, recipe.RawMaterial.ElementAt(index).RawMaterialWeight); - // MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}"); - // break; - // case 2: - // string address1 = "DB99.DBD" + (62 + 4 * (loc - 1)); - // HK_PLC_S7.Write(address1, recipe.RawMaterial.ElementAt(index).RawMaterialWeight); - // MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}"); - // break; - // case 4: - // string address2 = "DB99.DBD" + (118 + 4 * (loc - 1)); - // HK_PLC_S7.Write(address2, recipe.RawMaterial.ElementAt(index).RawMaterialWeight); - // MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}"); - // break; - // case 5: - // string address3 = "DB99.DBD" + (174 + 4 * (loc - 1)); - // HK_PLC_S7.Write(address3, recipe.RawMaterial.ElementAt(index).RawMaterialWeight); - // MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}"); - // break; - // default: - // break; - // } - //} - #endregion - } } } 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/PlcReceviceRecipe.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/PlcReceviceRecipe.cs deleted file mode 100644 index c2855676..00000000 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/PlcReceviceRecipe.cs +++ /dev/null @@ -1,19 +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 PlcReceviceRecipe - { - public short TrayNum { get; set; } - public short RecipeNum { get; set; } - public float[] Barrel1Weight { get; set; } = new float[14]; - public float[] Barrel2Weight { get; set; } = new float[14]; - public float[] Barrel4Weight { get; set; } = new float[14]; - public float[] Barrel5Weight { get; set; } = new float[14]; - - } -} diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index f41de36f..e8a85ecc 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -13,6 +13,7 @@ using System.Reflection; using System.Text; using System.Threading; using System.Threading.Tasks; +using System.Windows.Markup; namespace BPASmartClient.JXJFoodBigStation.Model { @@ -21,25 +22,25 @@ namespace BPASmartClient.JXJFoodBigStation.Model private volatile static ProcessControl _Instance; public static ProcessControl GetInstance => _Instance ?? (_Instance = new ProcessControl()); private ProcessControl() { } - public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus(); + //public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus(); public HKDeviceStatus HKDevice = new HKDeviceStatus(); DL_Finish_DB FinishData = new DL_Finish_DB(); /// - /// 西门子配方数据 + /// MES配方数据 /// public ObservableCollection SiemensRecipes { get; set; } = new ObservableCollection(); /// /// 本地配方数据 /// - public ObservableCollection LocalRecipes { get; set; } = new ObservableCollection(); + //public ObservableCollection LocalRecipes { get; set; } = new ObservableCollection(); /// /// 配方等待执行 /// - public ObservableCollection RecipeWaitExecute { get; set; } = new ObservableCollection(); + //public ObservableCollection RecipeWaitExecute { get; set; } = new ObservableCollection(); /// /// 配方正在执行 /// - public ObservableCollection RecipeExecuting { get; set; } = new ObservableCollection(); + //public ObservableCollection RecipeExecuting { get; set; } = new ObservableCollection(); /// /// 配方执行完成 /// @@ -54,7 +55,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model public ObservableCollection HardWareRawMaterialInfo { get; set; } = new ObservableCollection(); public ObservableCollection RawMaterialsInfo { get; set; } = new ObservableCollection(); /// - /// 西门子配方队列 + /// MES配方队列 /// public ConcurrentQueue SiemensRecipeQueue1 = new ConcurrentQueue(); public ConcurrentQueue SiemensRecipeQueue2 = new ConcurrentQueue(); @@ -62,785 +63,787 @@ namespace BPASmartClient.JXJFoodBigStation.Model public ConcurrentQueue SiemensRecipeQueue4 = new ConcurrentQueue(); public ConcurrentDictionary> SiemensRecipeQueue = new ConcurrentDictionary>(); - public ObservableCollection recipe = new ObservableCollection(); + //public ObservableCollection recipe = new ObservableCollection(); /// /// 本地配方队列 /// - public ConcurrentQueue LocalRecipeQueue1 = new ConcurrentQueue(); - public ConcurrentQueue LocalRecipeQueue2 = new ConcurrentQueue(); - public ConcurrentQueue LocalRecipeQueue3 = new ConcurrentQueue(); - public ConcurrentQueue LocalRecipeQueue4 = new ConcurrentQueue(); + //public ConcurrentQueue LocalRecipeQueue1 = new ConcurrentQueue(); + //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 + /// MESPLC的IP /// public string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; public void Init() { + //TODO:下发订单数据处理修改 ActionManage.GetInstance.Register(new Action((res) => { ObservableCollection RawMaterials = new ObservableCollection(); - if (SiemensDevice.IsConnected) - { - if (res != null && res is DL_Start_DB recipe) - { - RawMaterials.Clear(); - for (int i = 0; i < GVL_BigStation.Max_DosingSotckBinNum; i++) - { - if (string.IsNullOrEmpty(recipe.Material[i].Material_Name)) - { - - } - else - { - 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 = RawMaterialsNamePos.Keys.ToList()[index] - }); - } - else - { - MessageNotify.GetInstance.ShowAlarmLog($"本地缺少原料{recipe.Material[i].Material_Name},和西门子下发的原料名称无法对应,"); - } - } - } - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.Add(new RecipeData() - { - RecipeName = recipe.RecipeName, - RecipeCode = recipe.RecipeCode, - RawMaterial = RawMaterials, - TrayCode = recipe.Job_No, - IsWashingBarrel = recipe.Order_Type - }); - }); - } - } - }), "SiemensSendRecipe", true); - DeviceConnectInit();//设备连接初始化 - ThreadInit();//线程初始化 - VarResetInit();//变量初始化 - } - #region 本地配方--暂时不使用 - private void LocalRecipeRecevice() - { - if (LocalRecipes.Count > 0) - { - foreach (var data in LocalRecipes) - { - if (LocalRecipeQueue1.Count == 0 && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe1) - { - if (!(LocalRecipeQueue1.Contains(data.RecipeCode))) - { - LocalRecipeQueue1.Enqueue(data.RecipeCode); - } - } - else if (LocalRecipeQueue2.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe2) - { - if (!(LocalRecipeQueue2.Contains(data.RecipeCode))) - { - LocalRecipeQueue2.Enqueue(data.RecipeCode); - } - } - else if (LocalRecipeQueue3.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe3) - { - if (!(LocalRecipeQueue3.Contains(data.RecipeCode))) - { - LocalRecipeQueue3.Enqueue(data.RecipeCode); - } - } - else if (LocalRecipeQueue4.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe4) - { - if (!(LocalRecipeQueue4.Contains(data.RecipeCode))) - { - LocalRecipeQueue4.Enqueue(data.RecipeCode); - } - } - } - } - else - { - LocalRecipeQueue1.Clear(); - LocalRecipeQueue2.Clear(); - LocalRecipeQueue3.Clear(); - LocalRecipeQueue4.Clear(); - GVL_BigStation.BarrelWasherSign = false; - GVL_BigStation.Recipe1DosingStatus = 0; - GVL_BigStation.Recipe2DosingStatus = 0; - GVL_BigStation.Recipe3DosingStatus = 0; - GVL_BigStation.Recipe4DosingStatus = 0; - } - } - private void LocalRecipeDosing() - { - if (LocalRecipeQueue1.Count > 0) - { - int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue1.ElementAt(0)); - if (index >= 0 && index < LocalRecipes.Count) - { - string code = LocalRecipes.ElementAt(index).RecipeCode; - int trayCode = LocalRecipes.ElementAt(index).TrayCode; - bool Inplace = false; - switch (trayCode) - { - case 1: - Inplace = HKDevice.PlcRead.Tray1InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1)); - break; - case 2: - Inplace = HKDevice.PlcRead.Tray2InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2)); - break; - case 3: - Inplace = HKDevice.PlcRead.Tray3InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3)); - break; - case 4: - Inplace = HKDevice.PlcRead.Tray4InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4)); - break; - case 5: - Inplace = HKDevice.PlcRead.Tray5InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5)); - break; - default: - break; - } - if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0 && Inplace)//配方1是否允许下发配发 - { - if (LocalRecipes.ElementAt(index).IsWashingBarrel) - { - if (!GVL_BigStation.BarrelWasherSign) - { - GVL_BigStation.BarrelWasherSign = true; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); - - HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); - GVL_BigStation.Recipe1DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},下发完成"); - } - } - else - { - HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); - GVL_BigStation.Recipe1DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},下发完成"); - } - } - 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($"配方1,配方编号:{code},托盘编号:{trayCode},洗桶信号复位"); - } - HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", false); - StockBinParReset(); - GVL_BigStation.Recipe1DosingStatus = 2; - MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); - } - if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish) - { - if (LocalRecipes.ElementAt(index).IsWashingBarrel) - { - GVL_BigStation.BarrelWasherSign = false; - } - GVL_BigStation.Recipe1DosingStatus = 3; - switch (trayCode) - { - case 1: - HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false); - break; - case 2: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false); - break; - case 3: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false); - break; - case 4: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false); - break; - case 5: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false); - break; - default: - break; - } - MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},配料完成"); - foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) - { - if (item.RawMaterialLocation == 1) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; - } - else if (item.RawMaterialLocation == 2) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; - } - else if (item.RawMaterialLocation == 3) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; - } - else if (item.RawMaterialLocation == 4) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; - } - else if (item.RawMaterialLocation == 5) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; - } - else if (item.RawMaterialLocation == 6) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; - } - else if (item.RawMaterialLocation == 7) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; - } - else if (item.RawMaterialLocation == 8) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; - } - else if (item.RawMaterialLocation == 9) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; - } - else if (item.RawMaterialLocation == 10) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; - } - else if (item.RawMaterialLocation == 11) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; - } - else if (item.RawMaterialLocation == 12) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; - } - else if (item.RawMaterialLocation == 13) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; - } - else if (item.RawMaterialLocation == 14) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; - } - } - LocalRecipeQueue1.TryDequeue(out code); - //App.Current.Dispatcher.Invoke(() => { - // Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - //}); - LocalRecipes.RemoveAt(index); - GVL_BigStation.Recipe1DosingStatus = 0; - } - } - } - if (LocalRecipeQueue2.Count > 0) - { - int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue2.ElementAt(0)); - if (index >= 0 && index < LocalRecipes.Count) - { - string code = LocalRecipes.ElementAt(index).RecipeCode; - int trayCode = LocalRecipes.ElementAt(index).TrayCode; - bool Inplace = false; - switch (trayCode) - { - case 1: - Inplace = HKDevice.PlcRead.Tray1InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1)); - break; - case 2: - Inplace = HKDevice.PlcRead.Tray2InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2)); - break; - case 3: - Inplace = HKDevice.PlcRead.Tray3InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3)); - break; - case 4: - Inplace = HKDevice.PlcRead.Tray4InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4)); - break; - case 5: - Inplace = HKDevice.PlcRead.Tray5InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5)); - break; - default: - break; - } - if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0 && Inplace)//配方2是否允许下发配发 - { - if (LocalRecipes.ElementAt(index).IsWashingBarrel) - { - if (!GVL_BigStation.BarrelWasherSign) - { - GVL_BigStation.BarrelWasherSign = true; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); - - HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); - GVL_BigStation.Recipe2DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); - } - } - else - { - HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); - GVL_BigStation.Recipe2DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); - } - } - 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(); - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); - } - if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) - { - if (LocalRecipes.ElementAt(index).IsWashingBarrel) - { - GVL_BigStation.BarrelWasherSign = false; - } - switch (trayCode) - { - case 1: - HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false); - break; - case 2: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false); - break; - case 3: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false); - break; - case 4: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false); - break; - case 5: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false); - break; - default: - break; - } - GVL_BigStation.Recipe2DosingStatus = 3; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); - foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) - { - if (item.RawMaterialLocation == 1) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; - } - else if (item.RawMaterialLocation == 2) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; - } - else if (item.RawMaterialLocation == 3) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; - } - else if (item.RawMaterialLocation == 4) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; - } - else if (item.RawMaterialLocation == 5) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; - } - else if (item.RawMaterialLocation == 6) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; - } - else if (item.RawMaterialLocation == 7) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; - } - else if (item.RawMaterialLocation == 8) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; - } - else if (item.RawMaterialLocation == 9) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; - } - else if (item.RawMaterialLocation == 10) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; - } - else if (item.RawMaterialLocation == 11) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; - } - else if (item.RawMaterialLocation == 12) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; - } - else if (item.RawMaterialLocation == 13) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; - } - else if (item.RawMaterialLocation == 14) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; - } - } - LocalRecipeQueue2.TryDequeue(out code); - LocalRecipes.RemoveAt(index); - GVL_BigStation.Recipe2DosingStatus = 0; - } - } - } - if (LocalRecipeQueue3.Count > 0) - { - int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue3.ElementAt(0)); - if (index >= 0 && index < LocalRecipes.Count) - { - string code = LocalRecipes.ElementAt(index).RecipeCode; - int trayCode = LocalRecipes.ElementAt(index).TrayCode; - bool Inplace = false; - switch (trayCode) - { - case 1: - Inplace = HKDevice.PlcRead.Tray1InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1)); - break; - case 2: - Inplace = HKDevice.PlcRead.Tray2InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2)); - break; - case 3: - Inplace = HKDevice.PlcRead.Tray3InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3)); - break; - case 4: - Inplace = HKDevice.PlcRead.Tray4InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4)); - break; - case 5: - Inplace = HKDevice.PlcRead.Tray5InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5)); - break; - default: - break; - } - if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0 && Inplace)//配方3是否允许下发配发 - { - if (LocalRecipes.ElementAt(index).IsWashingBarrel) - { - if (!GVL_BigStation.BarrelWasherSign) - { - GVL_BigStation.BarrelWasherSign = true; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); - - HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); - GVL_BigStation.Recipe3DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); - } - } - else - { - HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); - GVL_BigStation.Recipe3DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); - } - } - 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(); - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); - } - if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2) - { - if (LocalRecipes.ElementAt(index).IsWashingBarrel) - { - GVL_BigStation.BarrelWasherSign = false; - } - switch (trayCode) - { - case 1: - HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false); - break; - case 2: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false); - break; - case 3: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false); - break; - case 4: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false); - break; - case 5: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false); - break; - default: - break; - } - GVL_BigStation.Recipe3DosingStatus = 3; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); - foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) - { - if (item.RawMaterialLocation == 1) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; - } - else if (item.RawMaterialLocation == 2) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; - } - else if (item.RawMaterialLocation == 3) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; - } - else if (item.RawMaterialLocation == 4) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; - } - else if (item.RawMaterialLocation == 5) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; - } - else if (item.RawMaterialLocation == 6) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; - } - else if (item.RawMaterialLocation == 7) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; - } - else if (item.RawMaterialLocation == 8) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; - } - else if (item.RawMaterialLocation == 9) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; - } - else if (item.RawMaterialLocation == 10) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; - } - else if (item.RawMaterialLocation == 11) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; - } - else if (item.RawMaterialLocation == 12) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; - } - else if (item.RawMaterialLocation == 13) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; - } - else if (item.RawMaterialLocation == 14) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; - } - } - HKDevice.HK_PLC_S7.Write("DB98.DBX1.1", false); - LocalRecipeQueue3.TryDequeue(out code); - LocalRecipes.RemoveAt(index); - GVL_BigStation.Recipe3DosingStatus = 0; - } - } - } - if (LocalRecipeQueue4.Count > 0) - { - int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue4.ElementAt(0)); - if (index >= 0 && index < LocalRecipes.Count) - { - string code = LocalRecipes.ElementAt(index).RecipeCode; - int trayCode = LocalRecipes.ElementAt(index).TrayCode; - bool Inplace = false; - switch (trayCode) - { - case 1: - Inplace = HKDevice.PlcRead.Tray1InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1)); - break; - case 2: - Inplace = HKDevice.PlcRead.Tray2InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2)); - break; - case 3: - Inplace = HKDevice.PlcRead.Tray3InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3)); - break; - case 4: - Inplace = HKDevice.PlcRead.Tray4InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4)); - break; - case 5: - Inplace = HKDevice.PlcRead.Tray5InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5)); - break; - default: - break; - } - if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0 && Inplace)//配方4是否允许下发配发 - { - if (LocalRecipes.ElementAt(index).IsWashingBarrel) - { - if (!GVL_BigStation.BarrelWasherSign) - { - GVL_BigStation.BarrelWasherSign = true; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); - - HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); - GVL_BigStation.Recipe4DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); - } - } - else - { - HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); - GVL_BigStation.Recipe4DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); - } - } - 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(); - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); - } - if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) - { - if (LocalRecipes.ElementAt(index).IsWashingBarrel) - { - GVL_BigStation.BarrelWasherSign = false; - } - switch (trayCode) - { - case 1: - HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false); - break; - case 2: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false); - break; - case 3: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false); - break; - case 4: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false); - break; - case 5: - HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false); - break; - default: - break; - } - GVL_BigStation.Recipe4DosingStatus = 3; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); - foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) - { - if (item.RawMaterialLocation == 1) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; - } - else if (item.RawMaterialLocation == 2) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; - } - else if (item.RawMaterialLocation == 3) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; - } - else if (item.RawMaterialLocation == 4) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; - } - else if (item.RawMaterialLocation == 5) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; - } - else if (item.RawMaterialLocation == 6) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; - } - else if (item.RawMaterialLocation == 7) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; - } - else if (item.RawMaterialLocation == 8) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; - } - else if (item.RawMaterialLocation == 9) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; - } - else if (item.RawMaterialLocation == 10) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; - } - else if (item.RawMaterialLocation == 11) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; - } - else if (item.RawMaterialLocation == 12) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; - } - else if (item.RawMaterialLocation == 13) + //if (SiemensDevice.IsConnected) + //{ + if (res != null && res is DL_Start_DB recipe) + { + RawMaterials.Clear(); + for (int i = 0; i < GVL_BigStation.Max_DosingSotckBinNum; i++) + { + if (string.IsNullOrEmpty(recipe.Material[i].Material_Name)) { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; + } - else if (item.RawMaterialLocation == 14) + else { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; + 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 = RawMaterialsNamePos.Keys.ToList()[index] + }); + } + else + { + MessageNotify.GetInstance.ShowAlarmLog($"本地缺少原料{recipe.Material[i].Material_Name},和MES系统下发的原料名称无法对应。"); + } } } - HKDevice.HK_PLC_S7.Write("DB98.DBX1.3", false); - LocalRecipeQueue4.TryDequeue(out code); - LocalRecipes.RemoveAt(index); - GVL_BigStation.Recipe4DosingStatus = 0; + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.Add(new RecipeData() + { + RecipeName = recipe.RecipeName, + RecipeCode = recipe.RecipeCode, + RawMaterial = RawMaterials, + TrayCode = recipe.Job_No, + IsWashingBarrel = recipe.Order_Type + }); + }); } - } - } + //} + }), "SiemensSendRecipe", true); + DeviceConnectInit();//设备连接初始化 + ThreadInit();//线程初始化 + VarResetInit();//变量初始化 } + #region 本地配方--暂时不使用 + //private void LocalRecipeRecevice() + //{ + // if (LocalRecipes.Count > 0) + // { + // foreach (var data in LocalRecipes) + // { + // if (LocalRecipeQueue1.Count == 0 && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe1) + // { + // if (!(LocalRecipeQueue1.Contains(data.RecipeCode))) + // { + // LocalRecipeQueue1.Enqueue(data.RecipeCode); + // } + // } + // else if (LocalRecipeQueue2.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe2) + // { + // if (!(LocalRecipeQueue2.Contains(data.RecipeCode))) + // { + // LocalRecipeQueue2.Enqueue(data.RecipeCode); + // } + // } + // else if (LocalRecipeQueue3.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe3) + // { + // if (!(LocalRecipeQueue3.Contains(data.RecipeCode))) + // { + // LocalRecipeQueue3.Enqueue(data.RecipeCode); + // } + // } + // else if (LocalRecipeQueue4.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe4) + // { + // if (!(LocalRecipeQueue4.Contains(data.RecipeCode))) + // { + // LocalRecipeQueue4.Enqueue(data.RecipeCode); + // } + // } + // } + // } + // else + // { + // LocalRecipeQueue1.Clear(); + // LocalRecipeQueue2.Clear(); + // LocalRecipeQueue3.Clear(); + // LocalRecipeQueue4.Clear(); + // GVL_BigStation.BarrelWasherSign = false; + // GVL_BigStation.Recipe1DosingStatus = 0; + // GVL_BigStation.Recipe2DosingStatus = 0; + // GVL_BigStation.Recipe3DosingStatus = 0; + // GVL_BigStation.Recipe4DosingStatus = 0; + // } + //} + //private void LocalRecipeDosing() + //{ + // if (LocalRecipeQueue1.Count > 0) + // { + // int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue1.ElementAt(0)); + // if (index >= 0 && index < LocalRecipes.Count) + // { + // string code = LocalRecipes.ElementAt(index).RecipeCode; + // int trayCode = LocalRecipes.ElementAt(index).TrayCode; + // bool Inplace = false; + // switch (trayCode) + // { + // case 1: + // Inplace = HKDevice.PlcRead.Tray1InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1)); + // break; + // case 2: + // Inplace = HKDevice.PlcRead.Tray2InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2)); + // break; + // case 3: + // Inplace = HKDevice.PlcRead.Tray3InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3)); + // break; + // case 4: + // Inplace = HKDevice.PlcRead.Tray4InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4)); + // break; + // case 5: + // Inplace = HKDevice.PlcRead.Tray5InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5)); + // break; + // default: + // break; + // } + // if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0 && Inplace)//配方1是否允许下发配发 + // { + // if (LocalRecipes.ElementAt(index).IsWashingBarrel) + // { + // if (!GVL_BigStation.BarrelWasherSign) + // { + // GVL_BigStation.BarrelWasherSign = true; + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + // MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + + // HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); + // GVL_BigStation.Recipe1DosingStatus = 1; + // MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},下发完成"); + // } + // } + // else + // { + // HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); + // GVL_BigStation.Recipe1DosingStatus = 1; + // MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},下发完成"); + // } + // } + // 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($"配方1,配方编号:{code},托盘编号:{trayCode},洗桶信号复位"); + // } + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", false); + // StockBinParReset(); + // GVL_BigStation.Recipe1DosingStatus = 2; + // MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); + // } + // if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish) + // { + // if (LocalRecipes.ElementAt(index).IsWashingBarrel) + // { + // GVL_BigStation.BarrelWasherSign = false; + // } + // GVL_BigStation.Recipe1DosingStatus = 3; + // switch (trayCode) + // { + // case 1: + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false); + // break; + // case 2: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false); + // break; + // case 3: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false); + // break; + // case 4: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false); + // break; + // case 5: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false); + // break; + // default: + // break; + // } + // MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},配料完成"); + // foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) + // { + // if (item.RawMaterialLocation == 1) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; + // } + // else if (item.RawMaterialLocation == 2) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; + // } + // else if (item.RawMaterialLocation == 3) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; + // } + // else if (item.RawMaterialLocation == 4) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; + // } + // else if (item.RawMaterialLocation == 5) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; + // } + // else if (item.RawMaterialLocation == 6) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; + // } + // else if (item.RawMaterialLocation == 7) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; + // } + // else if (item.RawMaterialLocation == 8) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; + // } + // else if (item.RawMaterialLocation == 9) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; + // } + // else if (item.RawMaterialLocation == 10) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; + // } + // else if (item.RawMaterialLocation == 11) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; + // } + // else if (item.RawMaterialLocation == 12) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; + // } + // else if (item.RawMaterialLocation == 13) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; + // } + // else if (item.RawMaterialLocation == 14) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; + // } + // } + // LocalRecipeQueue1.TryDequeue(out code); + // //App.Current.Dispatcher.Invoke(() => { + // // Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + // //}); + // LocalRecipes.RemoveAt(index); + // GVL_BigStation.Recipe1DosingStatus = 0; + // } + // } + // } + // if (LocalRecipeQueue2.Count > 0) + // { + // int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue2.ElementAt(0)); + // if (index >= 0 && index < LocalRecipes.Count) + // { + // string code = LocalRecipes.ElementAt(index).RecipeCode; + // int trayCode = LocalRecipes.ElementAt(index).TrayCode; + // bool Inplace = false; + // switch (trayCode) + // { + // case 1: + // Inplace = HKDevice.PlcRead.Tray1InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1)); + // break; + // case 2: + // Inplace = HKDevice.PlcRead.Tray2InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2)); + // break; + // case 3: + // Inplace = HKDevice.PlcRead.Tray3InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3)); + // break; + // case 4: + // Inplace = HKDevice.PlcRead.Tray4InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4)); + // break; + // case 5: + // Inplace = HKDevice.PlcRead.Tray5InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5)); + // break; + // default: + // break; + // } + // if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0 && Inplace)//配方2是否允许下发配发 + // { + // if (LocalRecipes.ElementAt(index).IsWashingBarrel) + // { + // if (!GVL_BigStation.BarrelWasherSign) + // { + // GVL_BigStation.BarrelWasherSign = true; + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + // MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + + // HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); + // GVL_BigStation.Recipe2DosingStatus = 1; + // MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + // } + // } + // else + // { + // HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); + // GVL_BigStation.Recipe2DosingStatus = 1; + // MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + // } + // } + // 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(); + // MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + // } + // if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) + // { + // if (LocalRecipes.ElementAt(index).IsWashingBarrel) + // { + // GVL_BigStation.BarrelWasherSign = false; + // } + // switch (trayCode) + // { + // case 1: + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false); + // break; + // case 2: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false); + // break; + // case 3: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false); + // break; + // case 4: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false); + // break; + // case 5: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false); + // break; + // default: + // break; + // } + // GVL_BigStation.Recipe2DosingStatus = 3; + // MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + // foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) + // { + // if (item.RawMaterialLocation == 1) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; + // } + // else if (item.RawMaterialLocation == 2) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; + // } + // else if (item.RawMaterialLocation == 3) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; + // } + // else if (item.RawMaterialLocation == 4) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; + // } + // else if (item.RawMaterialLocation == 5) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; + // } + // else if (item.RawMaterialLocation == 6) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; + // } + // else if (item.RawMaterialLocation == 7) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; + // } + // else if (item.RawMaterialLocation == 8) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; + // } + // else if (item.RawMaterialLocation == 9) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; + // } + // else if (item.RawMaterialLocation == 10) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; + // } + // else if (item.RawMaterialLocation == 11) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; + // } + // else if (item.RawMaterialLocation == 12) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; + // } + // else if (item.RawMaterialLocation == 13) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; + // } + // else if (item.RawMaterialLocation == 14) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; + // } + // } + // LocalRecipeQueue2.TryDequeue(out code); + // LocalRecipes.RemoveAt(index); + // GVL_BigStation.Recipe2DosingStatus = 0; + // } + // } + // } + // if (LocalRecipeQueue3.Count > 0) + // { + // int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue3.ElementAt(0)); + // if (index >= 0 && index < LocalRecipes.Count) + // { + // string code = LocalRecipes.ElementAt(index).RecipeCode; + // int trayCode = LocalRecipes.ElementAt(index).TrayCode; + // bool Inplace = false; + // switch (trayCode) + // { + // case 1: + // Inplace = HKDevice.PlcRead.Tray1InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1)); + // break; + // case 2: + // Inplace = HKDevice.PlcRead.Tray2InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2)); + // break; + // case 3: + // Inplace = HKDevice.PlcRead.Tray3InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3)); + // break; + // case 4: + // Inplace = HKDevice.PlcRead.Tray4InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4)); + // break; + // case 5: + // Inplace = HKDevice.PlcRead.Tray5InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5)); + // break; + // default: + // break; + // } + // if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0 && Inplace)//配方3是否允许下发配发 + // { + // if (LocalRecipes.ElementAt(index).IsWashingBarrel) + // { + // if (!GVL_BigStation.BarrelWasherSign) + // { + // GVL_BigStation.BarrelWasherSign = true; + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + // MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + + // HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); + // GVL_BigStation.Recipe3DosingStatus = 1; + // MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + // } + // } + // else + // { + // HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); + // GVL_BigStation.Recipe3DosingStatus = 1; + // MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + // } + // } + // 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(); + // MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + // } + // if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2) + // { + // if (LocalRecipes.ElementAt(index).IsWashingBarrel) + // { + // GVL_BigStation.BarrelWasherSign = false; + // } + // switch (trayCode) + // { + // case 1: + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false); + // break; + // case 2: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false); + // break; + // case 3: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false); + // break; + // case 4: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false); + // break; + // case 5: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false); + // break; + // default: + // break; + // } + // GVL_BigStation.Recipe3DosingStatus = 3; + // MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + // foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) + // { + // if (item.RawMaterialLocation == 1) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; + // } + // else if (item.RawMaterialLocation == 2) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; + // } + // else if (item.RawMaterialLocation == 3) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; + // } + // else if (item.RawMaterialLocation == 4) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; + // } + // else if (item.RawMaterialLocation == 5) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; + // } + // else if (item.RawMaterialLocation == 6) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; + // } + // else if (item.RawMaterialLocation == 7) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; + // } + // else if (item.RawMaterialLocation == 8) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; + // } + // else if (item.RawMaterialLocation == 9) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; + // } + // else if (item.RawMaterialLocation == 10) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; + // } + // else if (item.RawMaterialLocation == 11) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; + // } + // else if (item.RawMaterialLocation == 12) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; + // } + // else if (item.RawMaterialLocation == 13) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; + // } + // else if (item.RawMaterialLocation == 14) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; + // } + // } + // HKDevice.HK_PLC_S7.Write("DB98.DBX1.1", false); + // LocalRecipeQueue3.TryDequeue(out code); + // LocalRecipes.RemoveAt(index); + // GVL_BigStation.Recipe3DosingStatus = 0; + // } + // } + // } + // if (LocalRecipeQueue4.Count > 0) + // { + // int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue4.ElementAt(0)); + // if (index >= 0 && index < LocalRecipes.Count) + // { + // string code = LocalRecipes.ElementAt(index).RecipeCode; + // int trayCode = LocalRecipes.ElementAt(index).TrayCode; + // bool Inplace = false; + // switch (trayCode) + // { + // case 1: + // Inplace = HKDevice.PlcRead.Tray1InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1)); + // break; + // case 2: + // Inplace = HKDevice.PlcRead.Tray2InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2)); + // break; + // case 3: + // Inplace = HKDevice.PlcRead.Tray3InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3)); + // break; + // case 4: + // Inplace = HKDevice.PlcRead.Tray4InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4)); + // break; + // case 5: + // Inplace = HKDevice.PlcRead.Tray5InPlace; + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5)); + // break; + // default: + // break; + // } + // if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0 && Inplace)//配方4是否允许下发配发 + // { + // if (LocalRecipes.ElementAt(index).IsWashingBarrel) + // { + // if (!GVL_BigStation.BarrelWasherSign) + // { + // GVL_BigStation.BarrelWasherSign = true; + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + // MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + + // HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); + // GVL_BigStation.Recipe4DosingStatus = 1; + // MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + // } + // } + // else + // { + // HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index)); + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); + // GVL_BigStation.Recipe4DosingStatus = 1; + // MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + // } + // } + // 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(); + // MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + // } + // if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) + // { + // if (LocalRecipes.ElementAt(index).IsWashingBarrel) + // { + // GVL_BigStation.BarrelWasherSign = false; + // } + // switch (trayCode) + // { + // case 1: + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false); + // break; + // case 2: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false); + // break; + // case 3: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false); + // break; + // case 4: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false); + // break; + // case 5: + // HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false); + // break; + // default: + // break; + // } + // GVL_BigStation.Recipe4DosingStatus = 3; + // MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + // foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) + // { + // if (item.RawMaterialLocation == 1) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; + // } + // else if (item.RawMaterialLocation == 2) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; + // } + // else if (item.RawMaterialLocation == 3) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; + // } + // else if (item.RawMaterialLocation == 4) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; + // } + // else if (item.RawMaterialLocation == 5) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; + // } + // else if (item.RawMaterialLocation == 6) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; + // } + // else if (item.RawMaterialLocation == 7) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; + // } + // else if (item.RawMaterialLocation == 8) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; + // } + // else if (item.RawMaterialLocation == 9) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; + // } + // else if (item.RawMaterialLocation == 10) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; + // } + // else if (item.RawMaterialLocation == 11) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; + // } + // else if (item.RawMaterialLocation == 12) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; + // } + // else if (item.RawMaterialLocation == 13) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; + // } + // else if (item.RawMaterialLocation == 14) + // { + // item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; + // } + // } + // HKDevice.HK_PLC_S7.Write("DB98.DBX1.3", false); + // LocalRecipeQueue4.TryDequeue(out code); + // LocalRecipes.RemoveAt(index); + // GVL_BigStation.Recipe4DosingStatus = 0; + // } + // } + // } + //} #endregion + /// - /// 将西门子配方,添加到队列中 + /// 将MES配方,添加到队列中 /// private void ReceviceData() { @@ -853,145 +856,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model { if (SiemensRecipeQueue1.Count == 0 && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe1 && data.TrayCode == 1) { - if (!(SiemensRecipeQueue1.Contains(data.RecipeCode))) - { - if (SiemensDevice.DL_Status is DL_Status_DB status) - { - switch (GVL_BigStation.SiemensSendRecipeStatus) - { - 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; - } - } - } + ReceiveRecipe(SiemensRecipeQueue1, data.RecipeCode,"配方1"); } else if (SiemensRecipeQueue2.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe2 && data.TrayCode == 2) { - if (!(SiemensRecipeQueue2.Contains(data.RecipeCode))) - { - 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($"配方2,发送配方编号和请求配料标志给西门子"); - 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($"配方2,西门子确认开始配料"); - GVL_BigStation.SiemensSendRecipeStatus = 5; - } - } - if (GVL_BigStation.SiemensSendRecipeStatus == 5) - { - if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) - { - SiemensRecipeQueue2.Enqueue(data.RecipeCode); - MessageNotify.GetInstance.ShowRunLog($"配方2,配方:{data.RecipeCode},加入队列"); - GVL_BigStation.SiemensSendRecipeStatus = 0; - } - } - } - } + ReceiveRecipe(SiemensRecipeQueue2, data.RecipeCode, "配方2"); } else if (SiemensRecipeQueue3.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe3 && data.TrayCode == 3) { - if (!(SiemensRecipeQueue3.Contains(data.RecipeCode))) - { - 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($"配方3,发送配方编号和请求配料标志给西门子"); - 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($"配方3,西门子确认开始配料"); - GVL_BigStation.SiemensSendRecipeStatus = 5; - } - } - if (GVL_BigStation.SiemensSendRecipeStatus == 5) - { - if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) - { - SiemensRecipeQueue3.Enqueue(data.RecipeCode); - MessageNotify.GetInstance.ShowRunLog($"配方3,配方:{data.RecipeCode},加入队列"); - GVL_BigStation.SiemensSendRecipeStatus = 0; - } - } - } - } + ReceiveRecipe(SiemensRecipeQueue3, data.RecipeCode, "配方3"); } else if (SiemensRecipeQueue4.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe4 && data.TrayCode == 4) { - if (!(SiemensRecipeQueue4.Contains(data.RecipeCode))) - { - 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($"配方4,发送配方编号和请求配料标志给西门子"); - 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($"配方4,西门子确认开始配料"); - GVL_BigStation.SiemensSendRecipeStatus = 5; - } - } - if (GVL_BigStation.SiemensSendRecipeStatus == 5) - { - if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) - { - SiemensRecipeQueue4.Enqueue(data.RecipeCode); - MessageNotify.GetInstance.ShowRunLog($"配方4,配方:{data.RecipeCode},加入队列"); - GVL_BigStation.SiemensSendRecipeStatus = 0; - } - } - } - } + ReceiveRecipe(SiemensRecipeQueue4, data.RecipeCode, "配方4"); } } else @@ -1072,34 +949,37 @@ namespace BPASmartClient.JXJFoodBigStation.Model GVL_BigStation.Recipe1DosingFinish = false; } break; + #region 未查找到订单 case 10: - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + //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; - } + //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}"); + MessageNotify.GetInstance.ShowRunLog($"MES取消订单,但未找到订单:{GVL_BigStation.Order_CancelRecipeCode}"); GVL_BigStation.Order_Cancel = false; GVL_BigStation.Order_CancelRecipeCode = ""; GVL_BigStation.Order_CancelStep = 0; break; + #endregion + #region 配方还未下发到配料PLC case 20: - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + //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; - } + //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; @@ -1111,7 +991,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model GVL_BigStation.Order_Cancel = false; GVL_BigStation.Order_CancelRecipeCode = ""; GVL_BigStation.Order_CancelStep = 0; - break; + break; + #endregion + case 30: if (SiemensRecipeQueue1.Contains(code)) { @@ -1130,11 +1012,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model GVL_BigStation.Order_CancelStep = 61; } break; + #region 工位1 取消订单 + case 31: if (GVL_BigStation.Recipe1DosingStatus != 0) { MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true)}"); MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode)}"); + MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", false)}"); + MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBX1.4", false)}"); + GVL_BigStation.Recipe1DosingFinish = false; GVL_BigStation.Recipe1DosingStatus = 0; GVL_BigStation.Order_CancelStep = 32; MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); @@ -1146,29 +1033,34 @@ namespace BPASmartClient.JXJFoodBigStation.Model } break; case 32: - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + //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) + //if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + //{ + // SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + App.Current.Dispatcher.Invoke(() => { - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index); - }); - SiemensRecipeQueue1.TryDequeue(out code); - GVL_BigStation.Order_CancelStep = 0; - GVL_BigStation.Order_Cancel = false; - GVL_BigStation.Order_CancelRecipeCode = ""; - MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); - } + Json.Data.Recipes.RemoveAt(index); + }); + SiemensRecipeQueue1.TryDequeue(out code); + GVL_BigStation.Order_CancelStep = 0; + GVL_BigStation.Order_Cancel = false; + GVL_BigStation.Order_CancelRecipeCode = ""; + MessageNotify.GetInstance.ShowRunLog($"队列1,MES取消订单完成,订单号:{code}"); + //} break; + #endregion + #region 工位2 取消订单 case 41: if (GVL_BigStation.Recipe2DosingStatus != 0) { MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true)}"); MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode)}"); + MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", false)}"); + MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBX1.5", false)}"); GVL_BigStation.Recipe2DosingStatus = 0; GVL_BigStation.Order_CancelStep = 42; MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); @@ -1180,29 +1072,33 @@ namespace BPASmartClient.JXJFoodBigStation.Model } break; case 42: - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + //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) + //if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + // { + // SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + App.Current.Dispatcher.Invoke(() => { - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index); - }); - SiemensRecipeQueue2.TryDequeue(out code); - GVL_BigStation.Order_CancelStep = 0; - GVL_BigStation.Order_Cancel = false; - GVL_BigStation.Order_CancelRecipeCode = ""; - MessageNotify.GetInstance.ShowRunLog($"队列2,西门子取消订单完成,订单号:{code}"); - } + Json.Data.Recipes.RemoveAt(index); + }); + SiemensRecipeQueue2.TryDequeue(out code); + GVL_BigStation.Order_CancelStep = 0; + GVL_BigStation.Order_Cancel = false; + GVL_BigStation.Order_CancelRecipeCode = ""; + MessageNotify.GetInstance.ShowRunLog($"队列2,MES取消订单完成,订单号:{code}"); + //} break; + #endregion + #region 工位3 取消订单 case 51: if (GVL_BigStation.Recipe3DosingStatus != 0) { MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true)}"); MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode)}"); + MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", false)}"); + MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBX1.6", false)}"); GVL_BigStation.Recipe3DosingStatus = 0; GVL_BigStation.Order_CancelStep = 52; MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); @@ -1214,29 +1110,33 @@ namespace BPASmartClient.JXJFoodBigStation.Model } break; case 52: - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + // 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) + //if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + //{ + // SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + App.Current.Dispatcher.Invoke(() => { - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index); - }); - SiemensRecipeQueue3.TryDequeue(out code); - GVL_BigStation.Order_CancelStep = 0; - GVL_BigStation.Order_Cancel = false; - GVL_BigStation.Order_CancelRecipeCode = ""; - MessageNotify.GetInstance.ShowRunLog($"队列3,西门子取消订单完成,订单号:{code}"); - } + Json.Data.Recipes.RemoveAt(index); + }); + SiemensRecipeQueue3.TryDequeue(out code); + GVL_BigStation.Order_CancelStep = 0; + GVL_BigStation.Order_Cancel = false; + GVL_BigStation.Order_CancelRecipeCode = ""; + MessageNotify.GetInstance.ShowRunLog($"队列3,MES取消订单完成,订单号:{code}"); + //} break; + #endregion + #region 工位4 取消订单 case 61: if (GVL_BigStation.Recipe4DosingStatus != 0) { MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true)}"); MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode)}"); + MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", false)}"); + MessageNotify.GetInstance.ShowRunLog($"海科PLC写入{HKDevice.HK_PLC_S7.Write("DB99.DBX1.7", false)}"); GVL_BigStation.Recipe4DosingStatus = 0; GVL_BigStation.Order_CancelStep = 62; MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); @@ -1248,24 +1148,25 @@ namespace BPASmartClient.JXJFoodBigStation.Model } break; case 62: - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + //SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); GVL_BigStation.Order_CancelStep = 63; break; case 63: - if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + //if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + //{ + // SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + App.Current.Dispatcher.Invoke(() => { - 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; - GVL_BigStation.Order_Cancel = false; - GVL_BigStation.Order_CancelRecipeCode = ""; - MessageNotify.GetInstance.ShowRunLog($"队列4,西门子取消订单完成,订单号:{code}"); - } - break; + Json.Data.Recipes.RemoveAt(index); + }); + SiemensRecipeQueue4.TryDequeue(out code); + GVL_BigStation.Order_CancelStep = 0; + GVL_BigStation.Order_Cancel = false; + GVL_BigStation.Order_CancelRecipeCode = ""; + MessageNotify.GetInstance.ShowRunLog($"队列4,MES取消订单完成,订单号:{code}"); + //} + break; + #endregion default: break; } @@ -1275,46 +1176,55 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 配方队列,在配料过程中的逻辑处理 /// - private void RecipeInfoToHKPLC() - { - if (SiemensRecipeQueue1.Count > 0) + private void RecipeInfoToHKPLC() { - int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue1.ElementAt(0)); - if (index >= 0 && index < SiemensRecipes.Count) + if (SiemensRecipeQueue1.Count > 0) { - string code = SiemensRecipes.ElementAt(index).RecipeCode; - int trayCode = SiemensRecipes.ElementAt(index).TrayCode; - bool Inplace = false; - switch (trayCode) - { - case 1: - Inplace = HKDevice.PlcRead.Tray1InPlace;//上位机给plc发送AGV到位信号,plc固定托盘后反馈托盘是否到位 - break; - case 2: - Inplace = HKDevice.PlcRead.Tray2InPlace; - break; - case 3: - Inplace = HKDevice.PlcRead.Tray3InPlace; - break; - case 4: - Inplace = HKDevice.PlcRead.Tray4InPlace; - break; - case 5: - Inplace = HKDevice.PlcRead.Tray5InPlace; - break; - default: - break; - } - if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0 && Inplace)//配方1是否允许下发配发 + int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue1.ElementAt(0)); + if (index >= 0 && index < SiemensRecipes.Count) { - if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + string code = SiemensRecipes.ElementAt(index).RecipeCode; + int trayCode = SiemensRecipes.ElementAt(index).TrayCode; + bool Inplace = false; + switch (trayCode) + { + case 1: + Inplace = HKDevice.PlcRead.Tray1InPlace;//上位机给plc发送AGV到位信号,plc固定托盘后反馈托盘是否到位 + break; + case 2: + Inplace = HKDevice.PlcRead.Tray2InPlace; + break; + case 3: + Inplace = HKDevice.PlcRead.Tray3InPlace; + break; + case 4: + Inplace = HKDevice.PlcRead.Tray4InPlace; + break; + case 5: + Inplace = HKDevice.PlcRead.Tray5InPlace; + break; + default: + break; + } + if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0 && Inplace)//配方1是否允许下发配发 { - if (!GVL_BigStation.BarrelWasherSign) + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { - GVL_BigStation.BarrelWasherSign = true; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + if (!GVL_BigStation.BarrelWasherSign) + { + GVL_BigStation.BarrelWasherSign = true; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + GVL_BigStation.DosingRecipe1Time = DateTime.Now; + HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); + GVL_BigStation.Recipe1DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},下发完成"); + } + } + else + { GVL_BigStation.DosingRecipe1Time = DateTime.Now; HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); @@ -1322,113 +1232,113 @@ namespace BPASmartClient.JXJFoodBigStation.Model MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},下发完成"); } } - else - { - GVL_BigStation.DosingRecipe1Time = DateTime.Now; - HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); - GVL_BigStation.Recipe1DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},下发完成"); - } - } - 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($"配方1,配方编号:{code},托盘编号:{trayCode},洗桶复位"); - } - HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", false); - StockBinParReset(); - MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); - GVL_BigStation.Recipe1DosingStatus = 2; - } - if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish) - { - if (SiemensRecipes.ElementAt(index).IsWashingBarrel) - { - GVL_BigStation.BarrelWasherSign = false; - } - GVL_BigStation.Recipe1DosingFinish = true; - GVL_BigStation.Recipe1DosingStatus = 3; - MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},配料完成"); - ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); - if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe) - { - FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; - FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; - for (int i = 0; i < FinishData.Material.Length; i++) - { - FinishData.Material[i] = new UDT1(); - } - for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + 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($"配方1,配方编号:{code},托盘编号:{trayCode},洗桶复位"); + } + HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", false); + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); + GVL_BigStation.Recipe1DosingStatus = 2; + } + if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish) + { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + GVL_BigStation.BarrelWasherSign = false; + } + GVL_BigStation.Recipe1DosingFinish = true; + GVL_BigStation.Recipe1DosingStatus = 3; + MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},配料完成"); + ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); + //if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe) + //{ + // FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; + // FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; + // FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; + // for (int i = 0; i < FinishData.Material.Length; i++) + // { + // FinishData.Material[i] = new UDT1(); + // } + // for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + // { + // FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + // FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + // FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); + // MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg"); + // } + // FinishData.Ask_For_Finish = true; + // double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe1Time).TotalSeconds; + // FinishData.ProcessTime = Convert.ToInt16(a); + // SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); + MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},配料完成,将信号反馈给MES"); + //} + HKDevice.HK_PLC_S7.Write("DB99.DBX1.4", true); + GVL_BigStation.Recipe1DosingStatus = 3; + } + if (GVL_BigStation.Recipe1DosingStatus == 3 && HKDevice.PlcRead.Recipe1DosingFinish == false) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.4", false); + SiemensRecipeQueue1.TryDequeue(out code); + App.Current.Dispatcher.Invoke(() => { - FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); - MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg"); - } - FinishData.Ask_For_Finish = true; - double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe1Time).TotalSeconds; - FinishData.ProcessTime = Convert.ToInt16(a); - SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); - MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},配料完成,将信号反馈给西门子"); + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + }); + GVL_BigStation.Recipe1DosingStatus = 0; + MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},复位plc配料完成信号"); } - HKDevice.HK_PLC_S7.Write("DB99.DBX1.4", true); - GVL_BigStation.Recipe1DosingStatus = 3; - } - if (GVL_BigStation.Recipe1DosingStatus == 3 && HKDevice.PlcRead.Recipe1DosingFinish == false) - { - HKDevice.HK_PLC_S7.Write("DB99.DBX1.4", false); - SiemensRecipeQueue1.TryDequeue(out code); - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - }); - GVL_BigStation.Recipe1DosingStatus = 0; - MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},复位plc配料完成信号"); } } - } - if (SiemensRecipeQueue2.Count > 0) - { - int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue2.ElementAt(0)); - if (index >= 0 && index < SiemensRecipes.Count) + if (SiemensRecipeQueue2.Count > 0) { - string code = SiemensRecipes.ElementAt(index).RecipeCode; - int trayCode = SiemensRecipes.ElementAt(index).TrayCode; - bool Inplace = false; - switch (trayCode) - { - case 1: - Inplace = HKDevice.PlcRead.Tray1InPlace; - break; - case 2: - Inplace = HKDevice.PlcRead.Tray2InPlace; - break; - case 3: - Inplace = HKDevice.PlcRead.Tray3InPlace; - break; - case 4: - Inplace = HKDevice.PlcRead.Tray4InPlace; - break; - case 5: - Inplace = HKDevice.PlcRead.Tray5InPlace; - break; - default: - break; - } - if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0 && Inplace)//配方2是否允许下发配发 + int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue2.ElementAt(0)); + if (index >= 0 && index < SiemensRecipes.Count) { - if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + string code = SiemensRecipes.ElementAt(index).RecipeCode; + int trayCode = SiemensRecipes.ElementAt(index).TrayCode; + bool Inplace = false; + switch (trayCode) + { + case 1: + Inplace = HKDevice.PlcRead.Tray1InPlace; + break; + case 2: + Inplace = HKDevice.PlcRead.Tray2InPlace; + break; + case 3: + Inplace = HKDevice.PlcRead.Tray3InPlace; + break; + case 4: + Inplace = HKDevice.PlcRead.Tray4InPlace; + break; + case 5: + Inplace = HKDevice.PlcRead.Tray5InPlace; + break; + default: + break; + } + if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0 && Inplace)//配方2是否允许下发配发 { - if (!GVL_BigStation.BarrelWasherSign) + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { - GVL_BigStation.BarrelWasherSign = true; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + if (!GVL_BigStation.BarrelWasherSign) + { + GVL_BigStation.BarrelWasherSign = true; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + GVL_BigStation.DosingRecipe2Time = DateTime.Now; + HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); + GVL_BigStation.Recipe2DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},下发完成"); + } + } + else + { GVL_BigStation.DosingRecipe2Time = DateTime.Now; HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); @@ -1436,112 +1346,112 @@ namespace BPASmartClient.JXJFoodBigStation.Model MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},下发完成"); } } - else - { - GVL_BigStation.DosingRecipe2Time = DateTime.Now; - HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); - GVL_BigStation.Recipe2DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},下发完成"); - } - } - 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($"配方2,配方编号:{code},托盘编号:{trayCode},洗桶复位"); - } - HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", false); - StockBinParReset(); - GVL_BigStation.Recipe2DosingStatus = 2; - MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); - } - if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) - { - if (SiemensRecipes.ElementAt(index).IsWashingBarrel) - { - GVL_BigStation.BarrelWasherSign = false; - } - GVL_BigStation.Recipe2DosingFinish = true; - MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},配料完成"); - ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); - if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe) - { - FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; - FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; - for (int i = 0; i < FinishData.Material.Length; i++) - { - FinishData.Material[i] = new UDT1(); - } - for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + 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($"配方2,配方编号:{code},托盘编号:{trayCode},洗桶复位"); + } + HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", false); + StockBinParReset(); + GVL_BigStation.Recipe2DosingStatus = 2; + MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); + } + if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) + { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + GVL_BigStation.BarrelWasherSign = false; + } + GVL_BigStation.Recipe2DosingFinish = true; + MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},配料完成"); + ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); + //if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe) + //{ + // FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; + // FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; + // FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; + // for (int i = 0; i < FinishData.Material.Length; i++) + // { + // FinishData.Material[i] = new UDT1(); + // } + // for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + // { + // FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + // FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + // FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); + // MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg"); + // } + // FinishData.Ask_For_Finish = true; + // double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe2Time).TotalSeconds; + // FinishData.ProcessTime = Convert.ToInt16(a); + // SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); + MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},配料完成,将信号反馈给MES"); + //} + HKDevice.HK_PLC_S7.Write("DB99.DBX1.5", true); + GVL_BigStation.Recipe2DosingStatus = 3; + } + if (GVL_BigStation.Recipe2DosingStatus == 3 && HKDevice.PlcRead.Recipe2DosingFinish == false) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.5", false); + SiemensRecipeQueue2.TryDequeue(out code); + //RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index)); + App.Current.Dispatcher.Invoke(() => { - FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); - MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg"); - } - FinishData.Ask_For_Finish = true; - double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe2Time).TotalSeconds; - FinishData.ProcessTime = Convert.ToInt16(a); - SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); - MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},配料完成,将信号反馈给西门子"); + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + }); + GVL_BigStation.Recipe2DosingStatus = 0; + MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},,复位plc配料完成信号"); } - HKDevice.HK_PLC_S7.Write("DB99.DBX1.5", true); - GVL_BigStation.Recipe2DosingStatus = 3; - } - if (GVL_BigStation.Recipe2DosingStatus == 3 && HKDevice.PlcRead.Recipe2DosingFinish == false) - { - HKDevice.HK_PLC_S7.Write("DB99.DBX1.5", false); - SiemensRecipeQueue2.TryDequeue(out code); - RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index)); - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - }); - GVL_BigStation.Recipe2DosingStatus = 0; - MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},,复位plc配料完成信号"); } } - } - if (SiemensRecipeQueue3.Count > 0) - { - int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue3.ElementAt(0)); - if (index >= 0 && index < SiemensRecipes.Count) + if (SiemensRecipeQueue3.Count > 0) { - string code = SiemensRecipes.ElementAt(index).RecipeCode; - int trayCode = SiemensRecipes.ElementAt(index).TrayCode; - bool Inplace = false; - switch (trayCode) - { - case 1: - Inplace = HKDevice.PlcRead.Tray1InPlace; - break; - case 2: - Inplace = HKDevice.PlcRead.Tray2InPlace; - break; - case 3: - Inplace = HKDevice.PlcRead.Tray3InPlace; - break; - case 4: - Inplace = HKDevice.PlcRead.Tray4InPlace; - break; - case 5: - Inplace = HKDevice.PlcRead.Tray5InPlace; - break; - default: - break; - } - if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0 && Inplace)//配方3是否允许下发配发 + int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue3.ElementAt(0)); + if (index >= 0 && index < SiemensRecipes.Count) { - if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + string code = SiemensRecipes.ElementAt(index).RecipeCode; + int trayCode = SiemensRecipes.ElementAt(index).TrayCode; + bool Inplace = false; + switch (trayCode) + { + case 1: + Inplace = HKDevice.PlcRead.Tray1InPlace; + break; + case 2: + Inplace = HKDevice.PlcRead.Tray2InPlace; + break; + case 3: + Inplace = HKDevice.PlcRead.Tray3InPlace; + break; + case 4: + Inplace = HKDevice.PlcRead.Tray4InPlace; + break; + case 5: + Inplace = HKDevice.PlcRead.Tray5InPlace; + break; + default: + break; + } + if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0 && Inplace)//配方3是否允许下发配发 { - if (!GVL_BigStation.BarrelWasherSign)//其他配方在洗桶时,等待其他配方洗完,在发送数据 + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + if (!GVL_BigStation.BarrelWasherSign)//其他配方在洗桶时,等待其他配方洗完,在发送数据 + { + GVL_BigStation.BarrelWasherSign = true; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + GVL_BigStation.DosingRecipe3Time = DateTime.Now; + HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); + GVL_BigStation.Recipe3DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},下发完成"); + } + } + else { - GVL_BigStation.BarrelWasherSign = true; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); GVL_BigStation.DosingRecipe3Time = DateTime.Now; HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); @@ -1549,112 +1459,112 @@ namespace BPASmartClient.JXJFoodBigStation.Model MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},下发完成"); } } - else - { - GVL_BigStation.DosingRecipe3Time = DateTime.Now; - HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); - GVL_BigStation.Recipe3DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},下发完成"); - } - } - 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($"配方3,配方编号:{code},托盘编号:{trayCode},洗桶复位"); + 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($"配方3,配方编号:{code},托盘编号:{trayCode},洗桶复位"); + } + HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", false); + StockBinParReset(); + GVL_BigStation.Recipe3DosingStatus = 2; + MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); + } + if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2) + { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + GVL_BigStation.BarrelWasherSign = false; + } + GVL_BigStation.Recipe3DosingFinish = true; + GVL_BigStation.Recipe3DosingStatus = 3; + MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},配料完成"); + ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); + //if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe) + //{ + // FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; + // FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; + // FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; + // for (int i = 0; i < FinishData.Material.Length; i++) + // { + // FinishData.Material[i] = new UDT1(); + // } + // for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + // { + // FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + // FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + // FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); + // MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg"); + // } + // FinishData.Ask_For_Finish = true; + // double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe3Time).TotalSeconds; + // FinishData.ProcessTime = Convert.ToInt16(a); + // SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); + MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},配料完成,将信号反馈给MES"); + //} + HKDevice.HK_PLC_S7.Write("DB99.DBX1.6", true); + GVL_BigStation.Recipe3DosingStatus = 3; + } + if (GVL_BigStation.Recipe3DosingStatus == 3 && HKDevice.PlcRead.Recipe3DosingFinish == false) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.6", false); + SiemensRecipeQueue3.TryDequeue(out code); + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + }); + GVL_BigStation.Recipe3DosingStatus = 0; + MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},复位plc配料完成信号"); } - HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", false); - StockBinParReset(); - GVL_BigStation.Recipe3DosingStatus = 2; - MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); } - if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2) + } + if (SiemensRecipeQueue4.Count > 0) + { + int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue4.ElementAt(0)); + if (index >= 0 && index < SiemensRecipes.Count) { - if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + string code = SiemensRecipes.ElementAt(index).RecipeCode; + int trayCode = SiemensRecipes.ElementAt(index).TrayCode; + bool Inplace = false; + switch (trayCode) { - GVL_BigStation.BarrelWasherSign = false; + case 1: + Inplace = HKDevice.PlcRead.Tray1InPlace; + break; + case 2: + Inplace = HKDevice.PlcRead.Tray2InPlace; + break; + case 3: + Inplace = HKDevice.PlcRead.Tray3InPlace; + break; + case 4: + Inplace = HKDevice.PlcRead.Tray4InPlace; + break; + case 5: + Inplace = HKDevice.PlcRead.Tray5InPlace; + break; + default: + break; } - GVL_BigStation.Recipe3DosingFinish = true; - GVL_BigStation.Recipe3DosingStatus = 3; - MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},配料完成"); - ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); - if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe) + if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0 && Inplace)//配方4是否允许下发配发 { - FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; - FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; - for (int i = 0; i < FinishData.Material.Length; i++) - { - FinishData.Material[i] = new UDT1(); - } - for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { - FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); - MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg"); + if (!GVL_BigStation.BarrelWasherSign)//其他配方在洗桶时,等待其他配方洗完,在发送数据 + { + GVL_BigStation.BarrelWasherSign = true; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + GVL_BigStation.DosingRecipe4Time = DateTime.Now; + HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); + GVL_BigStation.Recipe4DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},下发完成"); + } } - FinishData.Ask_For_Finish = true; - double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe3Time).TotalSeconds; - FinishData.ProcessTime = Convert.ToInt16(a); - SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); - MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},配料完成,将信号反馈给西门子"); - } - HKDevice.HK_PLC_S7.Write("DB99.DBX1.6", true); - GVL_BigStation.Recipe3DosingStatus = 3; - } - if (GVL_BigStation.Recipe3DosingStatus == 3 && HKDevice.PlcRead.Recipe3DosingFinish == false) - { - HKDevice.HK_PLC_S7.Write("DB99.DBX1.6", false); - SiemensRecipeQueue3.TryDequeue(out code); - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - }); - GVL_BigStation.Recipe3DosingStatus = 0; - MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},复位plc配料完成信号"); - } - } - } - if (SiemensRecipeQueue4.Count > 0) - { - int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue4.ElementAt(0)); - if (index >= 0 && index < SiemensRecipes.Count) - { - string code = SiemensRecipes.ElementAt(index).RecipeCode; - int trayCode = SiemensRecipes.ElementAt(index).TrayCode; - bool Inplace = false; - switch (trayCode) - { - case 1: - Inplace = HKDevice.PlcRead.Tray1InPlace; - break; - case 2: - Inplace = HKDevice.PlcRead.Tray2InPlace; - break; - case 3: - Inplace = HKDevice.PlcRead.Tray3InPlace; - break; - case 4: - Inplace = HKDevice.PlcRead.Tray4InPlace; - break; - case 5: - Inplace = HKDevice.PlcRead.Tray5InPlace; - break; - default: - break; - } - if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0 && Inplace)//配方4是否允许下发配发 - { - if (SiemensRecipes.ElementAt(index).IsWashingBarrel) - { - if (!GVL_BigStation.BarrelWasherSign)//其他配方在洗桶时,等待其他配方洗完,在发送数据 + else { - GVL_BigStation.BarrelWasherSign = true; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); GVL_BigStation.DosingRecipe4Time = DateTime.Now; HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); @@ -1662,76 +1572,67 @@ namespace BPASmartClient.JXJFoodBigStation.Model MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},下发完成"); } } - else - { - GVL_BigStation.DosingRecipe4Time = DateTime.Now; - HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); - GVL_BigStation.Recipe4DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},下发完成"); - } - } - 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($"配方4,配方编号:{code},托盘编号:{trayCode},洗桶复位"); - } - GVL_BigStation.Recipe4DosingStatus = 2; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", false); - StockBinParReset(); - MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); - } - if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) - { - if (SiemensRecipes.ElementAt(index).IsWashingBarrel) - { - GVL_BigStation.BarrelWasherSign = false; - } - GVL_BigStation.Recipe4DosingFinish = true; - GVL_BigStation.Recipe4DosingStatus = 3; - MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},配料完成"); - ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); - if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe) - { - FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; - FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; - for (int i = 0; i < FinishData.Material.Length; i++) - { - FinishData.Material[i] = new UDT1(); - } - for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + 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($"配方4,配方编号:{code},托盘编号:{trayCode},洗桶复位"); + } + GVL_BigStation.Recipe4DosingStatus = 2; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", false); + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); + } + if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) + { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + GVL_BigStation.BarrelWasherSign = false; + } + GVL_BigStation.Recipe4DosingFinish = true; + GVL_BigStation.Recipe4DosingStatus = 3; + MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},配料完成"); + ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); + //if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe) + //{ + // FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; + // FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; + // FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; + // for (int i = 0; i < FinishData.Material.Length; i++) + // { + // FinishData.Material[i] = new UDT1(); + // } + // for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + // { + // FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + // FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + // FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); + // MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg"); + // } + // FinishData.Ask_For_Finish = true; + // double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe4Time).TotalSeconds; + // FinishData.ProcessTime = Convert.ToInt16(a); + // SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); + MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},配料完成,将信号反馈给MES"); + //} + HKDevice.HK_PLC_S7.Write("DB99.DBX1.7", true); + GVL_BigStation.Recipe4DosingStatus = 3; + } + if (GVL_BigStation.Recipe4DosingStatus == 3 && HKDevice.PlcRead.Recipe4DosingFinish == false) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.7", false); + SiemensRecipeQueue4.TryDequeue(out code); + App.Current.Dispatcher.Invoke(() => { - FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); - MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg"); - } - FinishData.Ask_For_Finish = true; - double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe4Time).TotalSeconds; - FinishData.ProcessTime = Convert.ToInt16(a); - SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); - MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},配料完成,将信号反馈给西门子"); + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + }); + GVL_BigStation.Recipe4DosingStatus = 0; + MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},复位plc配料完成信号"); } - HKDevice.HK_PLC_S7.Write("DB99.DBX1.7", true); - GVL_BigStation.Recipe4DosingStatus = 3; - } - if (GVL_BigStation.Recipe4DosingStatus == 3 && HKDevice.PlcRead.Recipe4DosingFinish == false) - { - HKDevice.HK_PLC_S7.Write("DB99.DBX1.7", false); - SiemensRecipeQueue4.TryDequeue(out code); - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - }); - GVL_BigStation.Recipe4DosingStatus = 0; - MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},复位plc配料完成信号"); } } } - } /// /// 下发plc的配方数据复位 /// @@ -1879,7 +1780,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model GVL_BigStation.RawMaterialsNameCode.Add("0060", "孜然油"); } /// - /// 设备连接 西门子和海科PLC + /// 设备连接 MES和海科PLC /// public void DeviceConnectInit() { @@ -1909,21 +1810,21 @@ namespace BPASmartClient.JXJFoodBigStation.Model { if (GVL_BigStation.IsAllowSiemensConnect) { - SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); + //SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); } } catch (Exception ex) { - MessageNotify.GetInstance.ShowRunLog("西门子plc连接失败,等待重新连接"); + MessageNotify.GetInstance.ShowRunLog("MESplc连接失败,等待重新连接"); } finally { - SiemensDevice.Init(); - MessageNotify.GetInstance.ShowRunLog("西门子plc初始化"); - if (SiemensDevice.IsConnected && GVL_BigStation.IsAllowSiemensConnect) - { - MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功"); - } + // SiemensDevice.Init(); + MessageNotify.GetInstance.ShowRunLog("MESplc初始化"); + //if (SiemensDevice.IsConnected && GVL_BigStation.IsAllowSiemensConnect) + //{ + // MessageNotify.GetInstance.ShowRunLog("MESplc连接成功"); + //} } } @@ -1936,19 +1837,21 @@ namespace BPASmartClient.JXJFoodBigStation.Model HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); MessageNotify.GetInstance.ShowRunLog("海科plc重新连接成功"); } - if (!SiemensDevice.IsConnected && GVL_BigStation.IsAllowSiemensConnect) + if (/*!SiemensDevice.IsConnected &&*/ GVL_BigStation.IsAllowSiemensConnect) { - SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); - MessageNotify.GetInstance.ShowRunLog("西门子plc重新连接"); + // SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); + MessageNotify.GetInstance.ShowRunLog("MESplc重新连接"); } Thread.Sleep(10); - }), "西门子和海科PLC重新连接", true); + }), "MES和海科PLC重新连接", true); TaskManage.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心跳 + + #region MESPLC的AGV放托盘完成信号转发到海科PLC的工位托盘到位信号 if (HKDevice.IsConnected) { if (GVL_BigStation.AGVPutTray.GetBitValue(1)) @@ -2005,17 +1908,21 @@ namespace BPASmartClient.JXJFoodBigStation.Model { 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); - } + } + #endregion + + //if (SiemensDevice.IsConnected) + //{ + // GVL_BigStation.AGVPutTray = SiemensDevice.DL_Status.AGV_Put_Done; + // GVL_BigStation.AGVGetTray = SiemensDevice.DL_Status.AGV_Get_Done; + // //转发海科PLC的五个工位托盘气缸信号和托盘传感器信号到MESPLC。 + // SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW30", GVL_BigStation.TraySensor); + // SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW32", GVL_BigStation.TrayCylinder); + // //托盘使能信号转发给MESPLC。 + // SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW34", (ushort)GVL_BigStation.TrayEnable); + //} Thread.Sleep(10); - }), "海科plc和西门子数据交互", true); + }), "海科plc和MES数据交互", true); TaskManage.GetInstance.StartLong(new Action(() => { testRawMaterialNameData();//自定义料仓名称 @@ -2044,308 +1951,310 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// public void VarResetInit() { - LocalRecipeQueue1.Clear(); - LocalRecipeQueue2.Clear(); - LocalRecipeQueue3.Clear(); - LocalRecipeQueue4.Clear(); + //LocalRecipeQueue1.Clear(); + //LocalRecipeQueue2.Clear(); + //LocalRecipeQueue3.Clear(); + //LocalRecipeQueue4.Clear(); SiemensRecipeQueue1.Clear(); SiemensRecipeQueue2.Clear(); SiemensRecipeQueue3.Clear(); SiemensRecipeQueue4.Clear(); } - public void RecipeDosing() - { - GVL_BigStation.AllowIssueRecipe[0] = HKDevice.PlcRead.IsAllowIssueRecipe1; - GVL_BigStation.AllowIssueRecipe[1] = HKDevice.PlcRead.IsAllowIssueRecipe2; - GVL_BigStation.AllowIssueRecipe[2] = HKDevice.PlcRead.IsAllowIssueRecipe3; - GVL_BigStation.AllowIssueRecipe[3] = HKDevice.PlcRead.IsAllowIssueRecipe4; - GVL_BigStation.ReceviceFinishRecipe[0] = HKDevice.PlcRead.ReceiveFinishRecipe1; - GVL_BigStation.ReceviceFinishRecipe[1] = HKDevice.PlcRead.ReceiveFinishRecipe2; - GVL_BigStation.ReceviceFinishRecipe[2] = HKDevice.PlcRead.ReceiveFinishRecipe3; - GVL_BigStation.ReceviceFinishRecipe[3] = HKDevice.PlcRead.ReceiveFinishRecipe4; - GVL_BigStation.DosingFinishRecipe[0] = HKDevice.PlcRead.Recipe1DosingFinish; - GVL_BigStation.DosingFinishRecipe[1] = HKDevice.PlcRead.Recipe2DosingFinish; - GVL_BigStation.DosingFinishRecipe[2] = HKDevice.PlcRead.Recipe3DosingFinish; - GVL_BigStation.DosingFinishRecipe[3] = HKDevice.PlcRead.Recipe4DosingFinish; - GVL_BigStation.IsTrayArrive[0] = HKDevice.PlcRead.Tray1InPlace; - GVL_BigStation.IsTrayArrive[1] = HKDevice.PlcRead.Tray2InPlace; - GVL_BigStation.IsTrayArrive[2] = HKDevice.PlcRead.Tray3InPlace; - GVL_BigStation.IsTrayArrive[3] = HKDevice.PlcRead.Tray4InPlace; - GVL_BigStation.IsTrayArrive[4] = HKDevice.PlcRead.Tray5InPlace; - #region 接收配方 - SiemensRecipes = Json.Data.Recipes; - if (SiemensRecipes.Count > 0) - { - foreach (var data in SiemensRecipes) - { - foreach (var item in SiemensRecipeQueue) - { - if (item.Value.Count == 0 && item.Key == data.TrayCode && GVL_BigStation.AllowIssueRecipe[item.Key - 1]) - { - if (SiemensDevice.DL_Status is DL_Status_DB status) - { - switch (GVL_BigStation.SiemensSendRecipeStatus) - { - 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) - { - item.Value.Enqueue(data.RecipeCode); - MessageNotify.GetInstance.ShowRunLog($"配方1,配方:{data.RecipeCode},加入队列"); - GVL_BigStation.SiemensSendRecipeStatus = 0; - } - break; - default: - break; - } - } - } - } - } - } - else - { - SiemensRecipeQueue.Clear(); - GVL_BigStation.BarrelWasherSign = false; - for (int i = 0; i < GVL_BigStation.RecipeDosingStatus.Length; i++) - { - GVL_BigStation.RecipeDosingStatus[i] = 0; - } - } - #endregion - #region 取消配方 - 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) - { - TrayCode = (short)Json.Data.Recipes.ElementAt(index).TrayCode; - } - switch (GVL_BigStation.Order_CancelStep) - { - case 0: - if (index == -1) - { - GVL_BigStation.Order_CancelStep = 10; - } - else - { - GVL_BigStation.Order_CancelStep = 20; - foreach (var item in SiemensRecipeQueue) - { - if (item.Value.Contains(code)) - { - GVL_BigStation.Order_CancelStep = 30; - } - } - } - 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; + #region 舍弃 - 不用 + //public void RecipeDosing() + //{ + // GVL_BigStation.AllowIssueRecipe[0] = HKDevice.PlcRead.IsAllowIssueRecipe1; + // GVL_BigStation.AllowIssueRecipe[1] = HKDevice.PlcRead.IsAllowIssueRecipe2; + // GVL_BigStation.AllowIssueRecipe[2] = HKDevice.PlcRead.IsAllowIssueRecipe3; + // GVL_BigStation.AllowIssueRecipe[3] = HKDevice.PlcRead.IsAllowIssueRecipe4; + // GVL_BigStation.ReceviceFinishRecipe[0] = HKDevice.PlcRead.ReceiveFinishRecipe1; + // GVL_BigStation.ReceviceFinishRecipe[1] = HKDevice.PlcRead.ReceiveFinishRecipe2; + // GVL_BigStation.ReceviceFinishRecipe[2] = HKDevice.PlcRead.ReceiveFinishRecipe3; + // GVL_BigStation.ReceviceFinishRecipe[3] = HKDevice.PlcRead.ReceiveFinishRecipe4; + // GVL_BigStation.DosingFinishRecipe[0] = HKDevice.PlcRead.Recipe1DosingFinish; + // GVL_BigStation.DosingFinishRecipe[1] = HKDevice.PlcRead.Recipe2DosingFinish; + // GVL_BigStation.DosingFinishRecipe[2] = HKDevice.PlcRead.Recipe3DosingFinish; + // GVL_BigStation.DosingFinishRecipe[3] = HKDevice.PlcRead.Recipe4DosingFinish; + // GVL_BigStation.IsTrayArrive[0] = HKDevice.PlcRead.Tray1InPlace; + // GVL_BigStation.IsTrayArrive[1] = HKDevice.PlcRead.Tray2InPlace; + // GVL_BigStation.IsTrayArrive[2] = HKDevice.PlcRead.Tray3InPlace; + // GVL_BigStation.IsTrayArrive[3] = HKDevice.PlcRead.Tray4InPlace; + // GVL_BigStation.IsTrayArrive[4] = HKDevice.PlcRead.Tray5InPlace; + // #region 接收配方 + // SiemensRecipes = Json.Data.Recipes; + // if (SiemensRecipes.Count > 0) + // { + // foreach (var data in SiemensRecipes) + // { + // foreach (var item in SiemensRecipeQueue) + // { + // if (item.Value.Count == 0 && item.Key == data.TrayCode && GVL_BigStation.AllowIssueRecipe[item.Key - 1]) + // { + // if (SiemensDevice.DL_Status is DL_Status_DB status) + // { + // switch (GVL_BigStation.SiemensSendRecipeStatus) + // { + // case 3: + // SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); + // SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + // MessageNotify.GetInstance.ShowRunLog($"配方1,发送配方编号和请求配料标志给MES"); + // 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,MES确认开始配料"); + // GVL_BigStation.SiemensSendRecipeStatus = 5; + // } + // break; + // case 5: + // if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) + // { + // item.Value.Enqueue(data.RecipeCode); + // MessageNotify.GetInstance.ShowRunLog($"配方1,配方:{data.RecipeCode},加入队列"); + // GVL_BigStation.SiemensSendRecipeStatus = 0; + // } + // break; + // default: + // break; + // } + // } + // } + // } + // } + // } + // else + // { + // SiemensRecipeQueue.Clear(); + // GVL_BigStation.BarrelWasherSign = false; + // for (int i = 0; i < GVL_BigStation.RecipeDosingStatus.Length; i++) + // { + // GVL_BigStation.RecipeDosingStatus[i] = 0; + // } + // } + // #endregion + // #region 取消配方 + // 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) + // { + // TrayCode = (short)Json.Data.Recipes.ElementAt(index).TrayCode; + // } + // switch (GVL_BigStation.Order_CancelStep) + // { + // case 0: + // if (index == -1) + // { + // GVL_BigStation.Order_CancelStep = 10; + // } + // else + // { + // GVL_BigStation.Order_CancelStep = 20; + // foreach (var item in SiemensRecipeQueue) + // { + // if (item.Value.Contains(code)) + // { + // GVL_BigStation.Order_CancelStep = 30; + // } + // } + // } + // 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($"MES取消订单,但未找到订单:{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 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: - foreach (var item in SiemensRecipeQueue) - { - if (item.Value.Contains(code)) - { - if (GVL_BigStation.RecipeDosingStatus[item.Key - 1] != 0) - { - HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); - HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); - GVL_BigStation.RecipeDosingStatus[item.Key - 1] = 0; - item.Value.TryDequeue(out code); - GVL_BigStation.Order_CancelStep = 32; - MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); - } - else - { - GVL_BigStation.Order_CancelStep = 32; - MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{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); - }); - GVL_BigStation.Order_CancelStep = 0; - MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); - } - break; - default: - break; - } - } - } - #endregion - #region 配料 - foreach (var data in SiemensRecipeQueue) - { - int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == data.Value.ElementAt(0)); - if (index >= 0 && index < SiemensRecipes.Count) - { - string code = SiemensRecipes.ElementAt(index).RecipeCode; - int trayCode = SiemensRecipes.ElementAt(index).TrayCode; - if (GVL_BigStation.RecipeDosingStatus[data.Key] == 0 && GVL_BigStation.AllowIssueRecipe[data.Key] && GVL_BigStation.IsTrayArrive[trayCode - 1])//配方4是否允许下发配发 - { - if (SiemensRecipes.ElementAt(index).IsWashingBarrel) - { - if (!GVL_BigStation.BarrelWasherSign)//其他配方在洗桶时,等待其他配方洗完,在发送数据 - { - GVL_BigStation.BarrelWasherSign = true; - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + // case 30: + // foreach (var item in SiemensRecipeQueue) + // { + // if (item.Value.Contains(code)) + // { + // if (GVL_BigStation.RecipeDosingStatus[item.Key - 1] != 0) + // { + // HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); + // HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); + // GVL_BigStation.RecipeDosingStatus[item.Key - 1] = 0; + // item.Value.TryDequeue(out code); + // GVL_BigStation.Order_CancelStep = 32; + // MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); + // } + // else + // { + // GVL_BigStation.Order_CancelStep = 32; + // MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{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); + // }); + // GVL_BigStation.Order_CancelStep = 0; + // MessageNotify.GetInstance.ShowRunLog($"队列1,MES取消订单完成,订单号:{code}"); + // } + // break; + // default: + // break; + // } + // } + // } + // #endregion + // #region 配料 + // foreach (var data in SiemensRecipeQueue) + // { + // int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == data.Value.ElementAt(0)); + // if (index >= 0 && index < SiemensRecipes.Count) + // { + // string code = SiemensRecipes.ElementAt(index).RecipeCode; + // int trayCode = SiemensRecipes.ElementAt(index).TrayCode; + // if (GVL_BigStation.RecipeDosingStatus[data.Key] == 0 && GVL_BigStation.AllowIssueRecipe[data.Key] && GVL_BigStation.IsTrayArrive[trayCode - 1])//配方4是否允许下发配发 + // { + // if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + // { + // if (!GVL_BigStation.BarrelWasherSign)//其他配方在洗桶时,等待其他配方洗完,在发送数据 + // { + // GVL_BigStation.BarrelWasherSign = true; + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + // MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); - GVL_BigStation.RecipeDosingTime[data.Key] = DateTime.Now; - HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true); - GVL_BigStation.RecipeDosingStatus[data.Key] = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); - } - } - else - { - GVL_BigStation.RecipeDosingTime[data.Key] = DateTime.Now; - HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true); - GVL_BigStation.RecipeDosingStatus[data.Key] = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); - } - } - if (GVL_BigStation.RecipeDosingStatus[data.Key] == 1 && GVL_BigStation.ReceviceFinishRecipe[data.Key]) - { - if (SiemensRecipes.ElementAt(index).IsWashingBarrel) - { - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); - } - GVL_BigStation.RecipeDosingStatus[data.Key] = 2; - HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true); - StockBinParReset(); - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); - } - if (GVL_BigStation.RecipeDosingStatus[data.Key] == 2 && GVL_BigStation.DosingFinishRecipe[data.Key]) - { - if (SiemensRecipes.ElementAt(index).IsWashingBarrel) - { - GVL_BigStation.BarrelWasherSign = false; - } - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); - ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); - if (SiemensDevice.IsConnected) - { - FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; - FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; - for (int i = 0; i < FinishData.Material.Length; i++) - { - FinishData.Material[i] = new UDT1(); - } - for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) - { - FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); - MessageNotify.GetInstance.ShowRunLog($"配方{data.Key},配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg"); - } - FinishData.Ask_For_Finish = true; - double a = DateTime.Now.Subtract(GVL_BigStation.RecipeDosingTime[data.Key]).TotalSeconds; - FinishData.ProcessTime = Convert.ToInt16(a); - SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); - MessageNotify.GetInstance.ShowRunLog($"{code}配方配料完成,将信号反馈给西门子"); - } - data.Value.TryDequeue(out code); - if (!GVL_BigStation.IsUseLocalRecipe) - { - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - }); - } - else - { - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - }); - } - HKDevice.HK_PLC_S7.Write($"DB99.DBX1.{data.Key + 3}", true); - GVL_BigStation.RecipeDosingStatus[data.Key] = 3; - } - if (GVL_BigStation.RecipeDosingStatus[data.Key] == 3 && GVL_BigStation.DosingFinishRecipe[data.Key] == false) - { - HKDevice.HK_PLC_S7.Write($"DB99.DBX1.{data.Key + 3}", false); - GVL_BigStation.RecipeDosingStatus[data.Key] = 0; - } - } - } - #endregion - } + // GVL_BigStation.RecipeDosingTime[data.Key] = DateTime.Now; + // HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); + // HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true); + // GVL_BigStation.RecipeDosingStatus[data.Key] = 1; + // MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + // } + // } + // else + // { + // GVL_BigStation.RecipeDosingTime[data.Key] = DateTime.Now; + // HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index)); + // HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true); + // GVL_BigStation.RecipeDosingStatus[data.Key] = 1; + // MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + // } + // } + // if (GVL_BigStation.RecipeDosingStatus[data.Key] == 1 && GVL_BigStation.ReceviceFinishRecipe[data.Key]) + // { + // if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + // { + // HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 + // MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); + // } + // GVL_BigStation.RecipeDosingStatus[data.Key] = 2; + // HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true); + // StockBinParReset(); + // MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); + // } + // if (GVL_BigStation.RecipeDosingStatus[data.Key] == 2 && GVL_BigStation.DosingFinishRecipe[data.Key]) + // { + // if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + // { + // GVL_BigStation.BarrelWasherSign = false; + // } + // MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + // ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); + // if (SiemensDevice.IsConnected) + // { + // FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; + // FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; + // FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; + // for (int i = 0; i < FinishData.Material.Length; i++) + // { + // FinishData.Material[i] = new UDT1(); + // } + // for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + // { + // FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + // FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + // FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); + // MessageNotify.GetInstance.ShowRunLog($"配方{data.Key},配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg"); + // } + // FinishData.Ask_For_Finish = true; + // double a = DateTime.Now.Subtract(GVL_BigStation.RecipeDosingTime[data.Key]).TotalSeconds; + // FinishData.ProcessTime = Convert.ToInt16(a); + // SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); + // MessageNotify.GetInstance.ShowRunLog($"{code}配方配料完成,将信号反馈给MES"); + // } + // data.Value.TryDequeue(out code); + // if (!GVL_BigStation.IsUseLocalRecipe) + // { + // App.Current.Dispatcher.Invoke(() => + // { + // Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + // }); + // } + // else + // { + // App.Current.Dispatcher.Invoke(() => + // { + // Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + // }); + // } + // HKDevice.HK_PLC_S7.Write($"DB99.DBX1.{data.Key + 3}", true); + // GVL_BigStation.RecipeDosingStatus[data.Key] = 3; + // } + // if (GVL_BigStation.RecipeDosingStatus[data.Key] == 3 && GVL_BigStation.DosingFinishRecipe[data.Key] == false) + // { + // HKDevice.HK_PLC_S7.Write($"DB99.DBX1.{data.Key + 3}", false); + // GVL_BigStation.RecipeDosingStatus[data.Key] = 0; + // } + // } + // } + // #endregion + //} + #endregion /// /// 读取配料完成时,每个料仓的配料重量 /// @@ -2412,5 +2321,52 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } } + + /// + /// 配方添加到执行队列 + /// + /// 执行队列 + /// 配方编码 + /// 队列名称 + /// + private void ReceiveRecipe(ConcurrentQueue recipeQueue,string recipeCode,string queueName) + { + if (!(recipeQueue.Contains(recipeCode))) + { + //if (SiemensDevice.DL_Status is DL_Status_DB status) + //{ + switch (GVL_BigStation.SiemensSendRecipeStatus) + { + case 3: + //SiemensDevice.Siemens_PLC_S7.WriteString(2331, recipeCode, 10); + //SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + MessageNotify.GetInstance.ShowRunLog($"{queueName},发送配方编号和请求配料标志给MES"); + 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($"{queueName},MES确认开始配料"); + GVL_BigStation.SiemensSendRecipeStatus = 5; + //} + break; + case 5: + //if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) + //{ + recipeQueue.Enqueue(recipeCode); + MessageNotify.GetInstance.ShowRunLog($"{queueName},配方:{recipeCode},加入队列"); + GVL_BigStation.SiemensSendRecipeStatus = 0; + //} + break; + default: + break; + } + //} + } + } + + } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs index 41e36e69..fd884d52 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace BPASmartClient.JXJFoodBigStation.Model.Siemens { - public class DL_DataColl_DB + public class DL_DataColl_DB { [Siemens(16)] public string RecipeCode { get; set; } = ""; diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs index 2a9b2928..40b50cd5 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs @@ -1,4 +1,5 @@ -using BPASmartClient.S7Net; +using BPASmartClient.JXJFoodBigStation.Model.MQTT.Message; +using BPASmartClient.S7Net; using System; using System.Collections.Generic; using System.Linq; diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensCommAddress.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensCommAddress.cs deleted file mode 100644 index 0ffa682a..00000000 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensCommAddress.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.JXJFoodBigStation.Model.Siemens -{ - public class SiemensCommAddress - { - - } - -} diff --git a/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs b/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs index 02053c8a..7762a389 100644 --- a/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs +++ b/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace BPASmartClient.JXJFoodBigStation.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml b/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml index c98b2429..e363b3a1 100644 --- a/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml @@ -383,10 +383,11 @@ - @@ -562,10 +563,12 @@ - + + @@ -716,6 +720,7 @@ + diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml index a1d57384..2d8468b8 100644 --- a/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml @@ -322,7 +322,11 @@ Text="{Binding TrayCode}" /> - + + + diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml index 0dc1e74c..6f25cbe7 100644 --- a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml @@ -160,8 +160,10 @@ x:Name="IsUseLocalRecipe" Margin="0,0,10,0" VerticalAlignment="Center" + VerticalContentAlignment="Center" Content="使用本地配方配料" FontFamily="楷体" + FontSize="20" Foreground="Aqua" IsChecked="{Binding IsUseLocalRecipe}" /> @@ -293,7 +295,7 @@ FontSize="12" Foreground="#FF2AB2E7" Text="{Binding RecipeName}" /> - + Text="配方类别:" />--> diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs index a3970fb1..da03c158 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs @@ -62,6 +62,34 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel { return; } + if (string.IsNullOrWhiteSpace(RecipeName) ) + { + MessageNotify.GetInstance.ShowDialog("配方名称不可为空,请修改后再试。",DialogType.Error); + return; + } + if (TrayCode is <=0 or >5) + { + MessageNotify.GetInstance.ShowDialog("请输入正确的托盘编号,请修改后再试。", DialogType.Error); + return; + } + foreach (RawMaterial item in RawMaterialsInfo) + { + if (item.RawMaterialLocation ==0) + { + MessageNotify.GetInstance.ShowDialog("请输入正确的原料位置,请修改后再试。", DialogType.Error); + return; + } + if (item.RawMaterialBarrelNum is <=0 or >4) + { + MessageNotify.GetInstance.ShowDialog("请输入正确的托盘桶号,请修改后再试。", DialogType.Error); + return; + } + if (item.RawMaterialWeight <=0) + { + MessageNotify.GetInstance.ShowDialog("请输入正确的原料重量,请修改后再试。", DialogType.Error); + return; + } + } var bom= Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == RecipeCode); if (bom == null)//新配方 { diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs index 776bf485..bc720586 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs @@ -113,8 +113,8 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel } Json.Data.Recipes.Clear(); - Json.Save(); Json.Data.SelectedRecipes.Clear(); + Json.Save(); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"本地配方已全部删除!"); MessageNotify.GetInstance.ShowUserLog($"手动清除所有配方。"); }); @@ -126,6 +126,11 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel return; } var res = Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode); + var res1 = Json.Data.SelectedRecipes.FirstOrDefault(p => p.RecipeCode == recipeCode); + if (res1 is not null) + { + Json.Data.SelectedRecipes.Remove(res1); + } if (res != null) { Recipes.Remove(res); diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/SelectRecipesViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/SelectRecipesViewModel.cs index ac07886c..c55c7299 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/SelectRecipesViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/SelectRecipesViewModel.cs @@ -17,6 +17,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel public SelectRecipesViewModel() { AllRecipes = new(); + SelectRecipes.Clear(); foreach (var item in Json.Data.SelectedRecipes) { SelectRecipes.Add(item); diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterialData.cs b/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterialData.cs deleted file mode 100644 index b7051d4c..00000000 --- a/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterialData.cs +++ /dev/null @@ -1,16 +0,0 @@ -using BPA.Helper; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.JXJFoodSmallStation.Model.Bom -{ - public class BomMaterialData - { - public ObservableCollection Materials { get; set; } = new ObservableCollection(); - - } -} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL/GVL.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL/GVL.cs deleted file mode 100644 index a138cf60..00000000 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL/GVL.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.JXJFoodSmallStation.Model.GVL -{ - public class GVL - { - } -} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL/ReadSmallMaterial.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL/ReadSmallMaterial.cs deleted file mode 100644 index 6e9ccdf6..00000000 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL/ReadSmallMaterial.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.JXJFoodSmallStation.Model.GVL -{ - public class ReadSmallMaterial - { - /// - /// PLC到上位机心跳 - /// - public bool Heart { get; set; } - public bool Agv1 { get; set; } - public bool Agv2 { get; set; } - public bool Agv3 { get; set; } - public bool Agv4 { get; set; } - public bool Agv5 { get; set; } - public bool Agv6 { get; set; } - /// - /// 1#托盘工位占用 - /// - public bool Tray1BeOccupied { get; set; } - /// - /// 2#托盘工位占用 - /// - public bool Tray2BeOccupied { get; set; } - /// - /// 1#托盘工位配料完成 - /// - public bool Tray1MaterialFinish { get; set; } - /// - /// 2#托盘工位配料完成 - /// - public bool Tray2MaterialFinish { get; set; } - /// - /// 接收托盘1配方数据完成 - /// - public bool Tray1ReceiveFinish { get; set; } - /// - /// 接收托盘2配方数据完成 - /// - public bool Tray2ReceiveFinish { get; set; } - - public int Reserve1 { get; set; } - public int Receive2 { get; set; } - /// - /// 托盘1_1#桶位置反馈 - /// - public float Tray1Barrel1Location { get; set; } - /// - /// 托盘1_2#桶位置反馈 - /// - public float Tray1Barrel2Location { get; set; } - /// - /// 托盘1_3#桶位置反馈 - /// - public float Tray1Barrel3Location { get; set; } - /// - /// 托盘1_4#桶位置反馈 - /// - public float Tray1Barrel4Location { get; set; } - /// - /// 托盘2_1#桶位置反馈 - /// - public float Tray2Barrel1Location { get; set; } - /// - /// 托盘2_2#桶位置反馈 - /// - public float Tray2Barrel2Location { get; set; } - /// - /// 托盘2_3#桶位置反馈 - /// - public float Tray2Barrel3Location { get; set; } - /// - /// 托盘2_4#桶位置反馈 - /// - public float Tray2Barrel4Location { get; set; } - - public int Reserve3 { get; set; } - public int Receive4 { get; set; } - /// - /// 托盘1_1#桶允许配料 - /// - public float Tray1Barrel1AllowDosing { get; set; } - /// - /// 托盘1_2#桶允许配料 - /// - public float Tray1Barrel2AllowDosing { get; set; } - /// - /// 托盘1_3#桶允许配料 - /// - public float Tray1Barrel3AllowDosing { get; set; } - /// - /// 托盘1_4#桶允许配料 - /// - public float Tray1Barrel4AllowDosing { get; set; } - /// - /// 托盘2_1#桶允许配料 - /// - public float Tray2Barrel1AllowDosing { get; set; } - /// - /// 托盘2_2#桶允许配料 - /// - public float Tray2Barrel2AllowDosing { get; set; } - /// - /// 托盘2_3#桶允许配料 - /// - public float Tray2Barrel3AllowDosing { get; set; } - /// - /// 托盘2_4#桶允许配料 - /// - public float Tray2Barrel4AllowDosing { get; set; } - - } -} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL/WriteSmallMaterial.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL/WriteSmallMaterial.cs deleted file mode 100644 index 0dd86460..00000000 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL/WriteSmallMaterial.cs +++ /dev/null @@ -1,185 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.JXJFoodSmallStation.Model.GVL -{ - public class WriteSmallMaterial - { - /// - /// PLC到上位机心跳 - /// - public bool Heart { get; set; } - public bool Agv1 { get; set; } - public bool Agv2 { get; set; } - public bool Agv3 { get; set; } - public bool Agv4{ get; set; } - public bool Agv5 { get; set; } - public bool Agv6 { get; set; } - public bool Agv7 { get; set; } - public bool Agv8 { get; set; } - public bool Agv9 { get; set; } - public bool Agv10 { get; set; } - /// - /// 下发配方到托盘1 - /// - public bool Tray1IssueRecipe { get; set; } - /// - /// 下发配方到托盘2 - /// - public bool Tray2IssueRecipe { get; set; } - public int Reserve1 { get; set; } - public int Receive2 { get; set; } - - - public bool Tray1Barrel1IsDosing1; - public bool Tray1Barrel1IsDosing2; - public bool Tray1Barrel1IsDosing3; - public bool Tray1Barrel1IsDosing4; - public bool Tray1Barrel1IsDosing5; - public bool Tray1Barrel1IsDosing6; - public bool Tray1Barrel1IsDosing7; - public bool Tray1Barrel1IsDosing8; - public bool Tray1Barrel1IsDosing9; - public bool Tray1Barrel1IsDosing10; - public bool Tray1Barrel1IsDosing11; - public bool Tray1Barrel1IsDosing12; - public bool Tray1Barrel1IsDosing13; - public bool Tray1Barrel1IsDosing14; - public bool Tray1Barrel1IsDosing15; - public bool Receive3; - public bool Tray1Barrel2IsDosing1; - public bool Tray1Barrel2IsDosing2; - public bool Tray1Barrel2IsDosing3; - public bool Tray1Barrel2IsDosing4; - public bool Tray1Barrel2IsDosing5; - public bool Tray1Barrel2IsDosing6; - public bool Tray1Barrel2IsDosing7; - public bool Tray1Barrel2IsDosing8; - public bool Tray1Barrel2IsDosing9; - public bool Tray1Barrel2IsDosing10; - public bool Tray1Barrel2IsDosing11; - public bool Tray1Barrel2IsDosing12; - public bool Tray1Barrel2IsDosing13; - public bool Tray1Barrel2IsDosing14; - public bool Tray1Barrel2IsDosing15; - public bool Receive4; - public bool Tray1Barrel3IsDosing1; - public bool Tray1Barrel3IsDosing2; - public bool Tray1Barrel3IsDosing3; - public bool Tray1Barrel3IsDosing4; - public bool Tray1Barrel3IsDosing5; - public bool Tray1Barrel3IsDosing6; - public bool Tray1Barrel3IsDosing7; - public bool Tray1Barrel3IsDosing8; - public bool Tray1Barrel3IsDosing9; - public bool Tray1Barrel3IsDosing10; - public bool Tray1Barrel3IsDosing11; - public bool Tray1Barrel3IsDosing12; - public bool Tray1Barrel3IsDosing13; - public bool Tray1Barrel3IsDosing14; - public bool Tray1Barrel3IsDosing15; - public bool Receive5; - public bool Tray1Barrel4IsDosing1; - public bool Tray1Barrel4IsDosing2; - public bool Tray1Barrel4IsDosing3; - public bool Tray1Barrel4IsDosing4; - public bool Tray1Barrel4IsDosing5; - public bool Tray1Barrel4IsDosing6; - public bool Tray1Barrel4IsDosing7; - public bool Tray1Barrel4IsDosing8; - public bool Tray1Barrel4IsDosing9; - public bool Tray1Barrel4IsDosing10; - public bool Tray1Barrel4IsDosing11; - public bool Tray1Barrel4IsDosing12; - public bool Tray1Barrel4IsDosing13; - public bool Tray1Barrel4IsDosing14; - public bool Tray1Barrel4IsDosing15; - public bool Receive6; - - public bool Tray2Barrel1IsDosing1; - public bool Tray2Barrel1IsDosing2; - public bool Tray2Barrel1IsDosing3; - public bool Tray2Barrel1IsDosing4; - public bool Tray2Barrel1IsDosing5; - public bool Tray2Barrel1IsDosing6; - public bool Tray2Barrel1IsDosing7; - public bool Tray2Barrel1IsDosing8; - public bool Tray2Barrel1IsDosing9; - public bool Tray2Barrel1IsDosing10; - public bool Tray2Barrel1IsDosing11; - public bool Tray2Barrel1IsDosing12; - public bool Tray2Barrel1IsDosing13; - public bool Tray2Barrel1IsDosing14; - public bool Tray2Barrel1IsDosing15; - public bool Receive7; - public bool Tray2Barrel2IsDosing1; - public bool Tray2Barrel2IsDosing2; - public bool Tray2Barrel2IsDosing3; - public bool Tray2Barrel2IsDosing4; - public bool Tray2Barrel2IsDosing5; - public bool Tray2Barrel2IsDosing6; - public bool Tray2Barrel2IsDosing7; - public bool Tray2Barrel2IsDosing8; - public bool Tray2Barrel2IsDosing9; - public bool Tray2Barrel2IsDosing10; - public bool Tray2Barrel2IsDosing11; - public bool Tray2Barrel2IsDosing12; - public bool Tray2Barrel2IsDosing13; - public bool Tray2Barrel2IsDosing14; - public bool Tray2Barrel2IsDosing15; - public bool Receive8; - public bool Tray2Barrel3IsDosing1; - public bool Tray2Barrel3IsDosing2; - public bool Tray2Barrel3IsDosing3; - public bool Tray2Barrel3IsDosing4; - public bool Tray2Barrel3IsDosing5; - public bool Tray2Barrel3IsDosing6; - public bool Tray2Barrel3IsDosing7; - public bool Tray2Barrel3IsDosing8; - public bool Tray2Barrel3IsDosing9; - public bool Tray2Barrel3IsDosing10; - public bool Tray2Barrel3IsDosing11; - public bool Tray2Barrel3IsDosing12; - public bool Tray2Barrel3IsDosing13; - public bool Tray2Barrel3IsDosing14; - public bool Tray2Barrel3IsDosing15; - public bool Receive9; - public bool Tray2Barrel4IsDosing1; - public bool Tray2Barrel4IsDosing2; - public bool Tray2Barrel4IsDosing3; - public bool Tray2Barrel4IsDosing4; - public bool Tray2Barrel4IsDosing5; - public bool Tray2Barrel4IsDosing6; - public bool Tray2Barrel4IsDosing7; - public bool Tray2Barrel4IsDosing8; - public bool Tray2Barrel4IsDosing9; - public bool Tray2Barrel4IsDosing10; - public bool Tray2Barrel4IsDosing11; - public bool Tray2Barrel4IsDosing12; - public bool Tray2Barrel4IsDosing13; - public bool Tray2Barrel4IsDosing14; - public bool Tray2Barrel4IsDosing15; - public bool Receive10; - public int Receive11; - - public bool StockIn1DosingFinish; - public bool StockIn2DosingFinish; - public bool StockIn3DosingFinish; - public bool StockIn4DosingFinish; - public bool StockIn5DosingFinish; - public bool StockIn6DosingFinish; - public bool StockIn7DosingFinish; - public bool StockIn8DosingFinish; - public bool StockIn9DosingFinish; - public bool StockIn10DosingFinish; - public bool StockIn11DosingFinish; - public bool StockIn12DosingFinish; - public bool StockIn13DosingFinish; - public bool StockIn14DosingFinish; - public bool StockIn15DosingFinish; - public bool Receive12; - } -} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs index b8660926..054aa0fd 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs @@ -57,15 +57,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// public ushort StockBinCylinderStatus { get; set; } - [VarComm("Global", "柔性配料料仓配料下发情况")] /// /// 料仓配料情况 /// - public ushort[] StockBinDosingIssue { get; set; } = new ushort[5] { 0, 0, 0, 0, 0 }; [VarComm("Global", "柔性配料料仓配料下发情况")] + public ushort[] StockBinDosingIssue { get; set; } = new ushort[5] { 0, 0, 0, 0, 0 }; /// /// 料仓配料情况 /// + [VarComm("Global", "柔性配料料仓配料下发情况")] public ushort[] RecipeStockBinDosing { get; set; } = new ushort[5] { 0, 0, 0, 0, 0 }; [VarComm("Global", "柔性配料料仓配料情况")] @@ -92,163 +92,161 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// public int Tray2LogicFinish { get; set; } = 0; - [VarComm("Global", "托盘1有货架")] /// /// 托盘1有货架 /// + [VarComm("Global", "托盘1有货架")] public bool Station1HaveTray { get; set; } - [VarComm("Global", "托盘2有货架")] /// /// 托盘2有货架 /// + [VarComm("Global", "托盘2有货架")] public bool Station2HaveTray { get; set; } - [VarComm("Global", "托盘1传感器信号")] /// /// 托盘1传感器信号 /// + [VarComm("Global", "托盘1传感器信号")] public bool Station1Sensor { get; set; } - [VarComm("Global", "托盘2传感器信号")] /// /// 托盘2传感器信号 /// + [VarComm("Global", "托盘2传感器信号")] public bool Station2Sensor { get; set; } - [VarComm("Global", "托盘1气缸信号")] /// /// 托盘1气缸信号 /// + [VarComm("Global", "托盘1气缸信号")] public bool Station1Cylinder { get; set; } - [VarComm("Global", "托盘2气缸信号")] /// /// 托盘2气缸信号 /// + [VarComm("Global", "托盘2气缸信号")] public bool Station2Cylinder { get; set; } - [VarComm("Global", "AGV放托盘1完成")] + /// /// AGV放托盘1完成 /// + [VarComm("Global", "AGV放托盘1完成")] public bool AGV_PutTray1Finish { get; set; } - [VarComm("Global", "AGV取托盘1完成")] /// /// AGV取托盘1完成 /// + [VarComm("Global", "AGV取托盘1完成")] public bool AGV_GetTray1Finish { get; set; } - [VarComm("Global", "AGV放托盘2完成")] /// /// AGV放托盘1完成 /// + [VarComm("Global", "AGV放托盘2完成")] public bool AGV_PutTray2Finish { get; set; } - [VarComm("Global", "AGV取托盘2完成")] /// /// AGV取托盘2完成 /// + [VarComm("Global", "AGV取托盘2完成")] public bool AGV_GetTray2Finish { get; set; } - [VarComm("Global", "托盘1气缸复位")] /// /// 托盘1气缸复位 /// + [VarComm("Global", "托盘1气缸复位")] public bool CylinderReset { get; set; } - [VarComm("Global", "发送给plc的心跳")] /// /// 发送给plc的心跳 /// + [VarComm("Global", "发送给plc的心跳")] public bool HeartBeatToPlc { get; set; } = false; [VarComm("Global", "屏蔽小料站料仓不足15个报警")] - - public bool DisEnableStockAlarm { get; set; } = false; - [VarComm("Global", "配方制作完成数量")] /// /// 配方制作完成数量 /// + [VarComm("Global", "配方制作完成数量")] public int RecipeDosingCompleNum { get; set; } = 0; - [VarComm("Global", "来自plc的心跳")] /// /// 来自plc的心跳 /// + [VarComm("Global", "来自plc的心跳")] public bool HeartBeatFromPlc { get; set; } = false; - [VarComm("Global", "是否允许西门子下发配方")] /// /// 是否允许西门子下发配方 /// + [VarComm("Global", "是否允许西门子下发配方")] public bool IsAllowSiemensSendRecipe { get; set; } = false; - [VarComm("Global", "西门子下发配方状态0=等待下发配方 1=请求下发配方 2=接收配方 3=配方接收配方完成 4=请求配料 5=西门子确认开始配料 6=西门子确认开始配料信号复位")] /// /// 西门子下发配方状态 0:等待下发配方 1:请求下发配方 2:上位机接收配方 3:配方接收配方完成 4:上位机向西门子请求配料 5:西门子确认开始配料 6:西门子确认开始配料 信号复位 /// + [VarComm("Global", "西门子下发配方状态0=等待下发配方 1=请求下发配方 2=接收配方 3=配方接收配方完成 4=请求配料 5=西门子确认开始配料 6=西门子确认开始配料信号复位")] public int SiemensSendRecipeStatus { get; set; } = 0; - [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")] /// /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料 /// + [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")] public int RecipeStatusIDTray1 { get; set; } = 0; - [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")] /// /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料 /// + [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")] public int[] RecipeProcessStatus { get; set; } = new int[5] { 0, 0, 0, 0, 0 }; - [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")] /// /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料 /// + [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")] public bool AGVIsGetTray { get; set; } = false; - [VarComm("Global", "配方2下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")] /// /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料 /// + [VarComm("Global", "配方2下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")] public int RecipeStatusIDTray2 { get; set; } = 0; - [VarComm("Global", "当前配方正在配料位置")] /// /// 当前料仓的位置 /// + [VarComm("Global", "当前配方正在配料位置")] public int StockInIsWork { get; set; } = 0; - - [VarComm("Global", "设置料仓配料完成")] /// /// 当前料仓的位置 /// + [VarComm("Global", "设置料仓配料完成")] public bool[] StockInDosingComple { get; set; } = new bool[15]; - [VarComm("Global", "是否使用粉仓配料")] /// /// 是否使用粉仓配料 /// + [VarComm("Global", "是否使用粉仓配料")] public bool IsUseWindSend { get; set; } = false; - [VarComm("Global", "粉仓正在配料")] /// /// 粉仓正在配料 /// + [VarComm("Global", "粉仓正在配料")] public bool WindSendDosing { get; set; } = false; @@ -259,16 +257,17 @@ namespace BPASmartClient.JXJFoodSmallStation.Model #region 本地模拟配方 - [VarComm("Global", "是否使用本地模拟配方")] /// /// 是否使用本地模拟配方 /// + [VarComm("Global", "是否使用本地模拟配方")] public bool IsUseLocalRecipe { get; set; } - [VarComm("Global", "是否使用本地模拟配方")] + /// - /// 是否使用本地模拟配方 + /// 不使用小料站配料 /// + [VarComm("Global", "是否使用本地模拟配方")] public bool NotUseSmallStation { get; set; } /// @@ -299,16 +298,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public bool WindSendDosingComple { get; set; } = false; - [VarComm("Global", "粉料仓配料状态")] /// /// 粉料仓配料状态(0:无意义,1:粉料仓下配方,2:plc接收配方完成,3:粉料仓配料完成,4:粉料仓配料完成信号复位,5:排料完成) /// + [VarComm("Global", "粉料仓配料状态")] public int WindSendDosingStatus { get; set; } = 0; - [VarComm("Global", "PLC的系统模式 DB44.DBX0.1")] /// /// PLC的系统模式 DB44.DBX0.1 /// + [VarComm("Global", "PLC的系统模式 DB44.DBX0.1")] public bool PlcSystemMode { get; set; } = false; [VarComm("Global", "PLC的系统模式 DB44.DBX0.1")] diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceRead.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceRead.cs deleted file mode 100644 index dee7a188..00000000 --- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceRead.cs +++ /dev/null @@ -1,16 +0,0 @@ -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/HKPlcCommAddress.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKPlcCommAddress.cs deleted file mode 100644 index 56bebdb7..00000000 --- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKPlcCommAddress.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC -{ - public class HKPlcCommAddress - { - #region 海科PLC ==> 上位机 - /// - /// 是否允许配料 - /// - public static string IsAllowDosing { get; set; } = ""; - /// - /// 当前料仓位置 - /// - public static string StockBinLocation { get; set; } = ""; - /// - /// 当前料仓的状态(0:无意义,1:到达接料位置) - /// - public static string StockState { get; set; } = ""; - #endregion - - #region 上位机 ==> 海科PLC - /// - /// 料仓位置(配置该配方,所需要多个原料桶,每个原料桶有多个料仓位置) - /// - public static string StockBinLocationToPLC { get; set; } = ""; - /// - /// 对应桶号 - /// - public static string BarrelNumToPLC { get; set; } = ""; - /// - /// 当前配料机配料完成 - /// - public static string SingleDosingFinishToPLC { get; set; } = ""; - /// - /// 当前配料料仓的位置 - /// - public static string SingleStockBinLocationToPLC { get; set; } = ""; - - public static string RecipeDosingFinish { get; set; } = ""; - #endregion - - #region AGV进出站1 - /// - /// Agv送货 进站申请 - /// - public static string DeliveryAGVApply { get; set; } = "DB3.DBX0.1"; - /// - /// Agv送货 进站申请 - /// - public static string DeliveryAGVIsApply { get; set; } = ""; - /// - /// Agv送货 进站顶升申请 - /// - public static string DeliveryAGVApplyJack { get; set; } = ""; - /// - /// Agv送货 进站顶升申请 - /// - public static string DeliveryAGVIsApplyJack { get; set; } = ""; - /// - /// Agv送货 送货完成 - /// - public static string DeliveryAGVFinsih { get; set; } = ""; - /// - /// Agv送货 工位上有货架 - /// - public static string StationHaveCargo { get; set; } = ""; - /// - /// Agv送货 进站申请 - /// - public static string PickAGVApply { get; set; } = ""; - /// - /// Agv送货 进站申请 - /// - public static string PickAGVIsApply { get; set; } = ""; - /// - /// Agv送货 取货架完成 - /// - public static string PickCargoAGVFinish { get; set; } = ""; - /// - /// Agv送货 取料完成 - /// - public static string PickAGVFinish { get; set; } = ""; - /// - /// 工位上是否有小车 - /// - public static string StationIsExistTray { get; set; } = ""; - #endregion - #region AGV进出站2 - /// - /// Agv送货 进站申请 - /// - public static string DeliveryAGVApplyStation2 { get; set; } = ""; - /// - /// Agv送货 进站申请 - /// - public static string DeliveryAGVIsApplyStation2 { get; set; } = ""; - /// - /// Agv送货 进站顶升申请 - /// - public static string DeliveryAGVApplyJackStation2 { get; set; } = ""; - /// - /// Agv送货 进站顶升申请 - /// - public static string DeliveryAGVIsApplyJackStation2 { get; set; } = ""; - /// - /// Agv送货 送货完成 - /// - public static string DeliveryAGVFinsihStation2 { get; set; } = ""; - /// - /// Agv送货 工位上有货架 - /// - public static string StationHaveCargoStation2 { get; set; } = ""; - /// - /// Agv送货 进站申请 - /// - public static string PickAGVApplyStation2 { get; set; } = ""; - /// - /// Agv送货 进站申请 - /// - public static string PickAGVIsApplyStation2 { get; set; } = ""; - /// - /// Agv送货 取货架完成 - /// - public static string PickCargoAGVFinishStation2 { get; set; } = ""; - /// - /// Agv送货 取料完成 - /// - public static string PickAGVFinishStation2 { get; set; } = ""; - /// - /// 工位上是否有货架 - /// - public static string StationIsExistTrayStation2 { get; set; } = ""; - #endregion - } -} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index c84feeea..f01eb63b 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -28,7 +28,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// /// 配方数据 /// - public ObservableCollection RemoteRecipes = new ObservableCollection(); + public ObservableCollection RemoteRecipes = new ObservableCollection(); /// /// 原料的名称和料仓的位置对应 /// @@ -41,29 +41,26 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// - /// 物料集合 + /// 物料集合(工位配方集合,五个键分别对应五个工位) /// public Dictionary> RecipeQueueTray { get; set; } = new Dictionary>(); public ConcurrentQueue RecipeQueueTray2 = new ConcurrentQueue(); - - public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus(); + //XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB(); + //public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus(); public HKDeviceStatus HKDevice = new HKDeviceStatus(); public WindSendDeviceStatus WindSendDevice = new WindSendDeviceStatus(); public ObservableCollection CommData { get; set; } = new ObservableCollection(); public ObservableCollection ProcessVar { get; set; } = new ObservableCollection(); - XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB(); + /// /// 风送PLC的DB块 /// WindSend_Write WindSendData = new WindSend_Write(); - /// - /// 接收原料数据 - /// - public RecipeRawMaterial RawMaterial; + public DateTime StockBinAlarmTime = DateTime.Now; public string? HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"]; @@ -72,17 +69,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public void Init() { - RecipeQueueTray.TryAdd(0, new ConcurrentQueue()); - RecipeQueueTray.TryAdd(1, new ConcurrentQueue()); - RecipeQueueTray.TryAdd(2, new ConcurrentQueue()); - RecipeQueueTray.TryAdd(3, new ConcurrentQueue()); - RecipeQueueTray.TryAdd(4, new ConcurrentQueue()); + for (int i = 0; i < 5; i++) + { + RecipeQueueTray.TryAdd(i, new()); + } PlcVarMonitor(); StockBinNameWithPos(); RawMaterialNameWithCode(); RegisterInit(); DeviceConnect(); - //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 + //Json.Data.RemoteRecipes = TestData.GetInstance.RemoteRecipes;//添加测试数据 TaskManage.GetInstance.StartLong(new Action(() => { GVL_SmallStation.GetInstance.DisEnableStockAlarm = Json.Data.deviceConnectPar.ShieldStockbinAlarm; @@ -91,7 +87,7 @@ 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"); - if (DeviceInquire.GetInstance.devices.Count < 15 && HKDevice.IsConnected && Json.Data.Recipes.Count > 0 && GVL_SmallStation.GetInstance.DisEnableStockBinAlarm == false && DateTime.Now.Subtract(StockBinAlarmTime).TotalSeconds >= 60 & !GVL_SmallStation.GetInstance.DisEnableStockAlarm) + if (DeviceInquire.GetInstance.devices.Count < 15 && HKDevice.IsConnected && Json.Data.RemoteRecipes.Count > 0 && GVL_SmallStation.GetInstance.DisEnableStockBinAlarm == false && DateTime.Now.Subtract(StockBinAlarmTime).TotalSeconds >= 60 & !GVL_SmallStation.GetInstance.DisEnableStockAlarm) { HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true); App.Current.Dispatcher.Invoke(() => @@ -168,6 +164,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// private void HKPlcRead() { + //读取配料PLC的DB3的值 if (HKDevice.IsConnected) { foreach (PropertyInfo item in typeof(PlcReadAddressDB3).GetProperties()) @@ -322,7 +319,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model //GVL_SmallStation.GetInstance.Station2Cylinder = HKDevice.HK_PLC_S7.Read("DB3.DBX2.4"); //GVL_SmallStation.GetInstance.RobotStatus = HKDevice.HK_PLC_S7.Read("DB3.DBW100"); //GVL_SmallStation.GetInstance.RobotProgramNum = HKDevice.HK_PLC_S7.Read("DB3.DBB102"); - if (Json.Data.Recipes.Count <= 3) + if (Json.Data.RemoteRecipes.Count <= 3) { GVL_SmallStation.GetInstance.IsAllowSiemensSendRecipe = true; } @@ -333,8 +330,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model GVL_SmallStation.GetInstance.RobotStatus = HKDevice.HK_PLC_S7.Read("DB3.DBB0"); GVL_SmallStation.GetInstance.RobotProgramNum = HKDevice.HK_PLC_S7.Read("DB3.DBB1"); } - if (SiemensDevice.IsConnected) - { + //if (SiemensDevice.IsConnected) + //{ ushort TrayCylinder = 0; ushort TraySensor = 0; if (GVL_SmallStation.GetInstance.Station1Sensor) @@ -353,10 +350,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { TrayCylinder = TrayCylinder.SetBitValue(0, false); } - this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.4", GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet); - this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW190", TraySensor);//添加工位传感器的信号 - this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号 - ushort AGV_Put = (ushort)SiemensDevice.XL_Status.AgvFinishPut; + //this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.4", GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet); + //this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW190", TraySensor);//添加工位传感器的信号 + //this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号 + ushort AGV_Put =0 /*(ushort)SiemensDevice.XL_Status.AgvFinishPut*/; if (AGV_Put.GetBitValue(1)) { GVL_SmallStation.GetInstance.AGV_PutTray1Finish = true; @@ -365,7 +362,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { GVL_SmallStation.GetInstance.AGV_PutTray1Finish = false; } - ushort AGV_Get = (ushort)SiemensDevice.XL_Status.AgvFinishGet; + ushort AGV_Get =0/* (ushort)SiemensDevice.XL_Status.AgvFinishGet*/; if (AGV_Get.GetBitValue(1)) { GVL_SmallStation.GetInstance.AGV_GetTray1Finish = true; @@ -374,7 +371,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { GVL_SmallStation.GetInstance.AGV_GetTray1Finish = false; } - } + //} } public void CancelOrder() @@ -384,7 +381,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model if (!string.IsNullOrEmpty(GVL_SmallStation.GetInstance.Order_CancelRecipeCode)) { string code = GVL_SmallStation.GetInstance.Order_CancelRecipeCode; - int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == code); + int index = Array.FindIndex(Json.Data.RemoteRecipes.ToArray(), p => p.RecipeCode == code); int[] cnt = new int[5] { -1, -1, -1, -1, -1 }; int index1 = -1; for (int i = 0; i < 5; i++) @@ -442,21 +439,21 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } break; case 3: - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); + //SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); GVL_SmallStation.GetInstance.OrderCancelStep = 4; break; case 4: - if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) - { - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); + //if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) + //{ + // SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); GVL_SmallStation.GetInstance.OrderCancelStep = 9; MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); - } + //} break; case 9: App.Current.Dispatcher.Invoke(() => { - Json.Data.Recipes.RemoveAt(index); + Json.Data.RemoteRecipes.RemoveAt(index); }); RecipeQueueTray1.TryDequeue(out code); GVL_SmallStation.GetInstance.RecipeProcessStatus[index] = 0; @@ -465,21 +462,21 @@ namespace BPASmartClient.JXJFoodSmallStation.Model GVL_SmallStation.GetInstance.OrderCancelStep = 0; break; case 20: - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); + //SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); GVL_SmallStation.GetInstance.OrderCancelStep = 21; break; case 21: - if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) - { - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); + //if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) + //{ + // SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); GVL_SmallStation.GetInstance.OrderCancelStep = 29; MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); - } + //} break; case 29: App.Current.Dispatcher.Invoke(() => { - Json.Data.Recipes.RemoveAt(index); + Json.Data.RemoteRecipes.RemoveAt(index); }); GVL_SmallStation.GetInstance.Order_Cancel = false; GVL_SmallStation.GetInstance.Order_CancelRecipeCode = ""; @@ -489,16 +486,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model //30-39为订单还未下发至上位机 case 30: - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); + //SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); GVL_SmallStation.GetInstance.OrderCancelStep = 31; break; case 31: - if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) - { - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); + //if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) + //{ + // SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); GVL_SmallStation.GetInstance.OrderCancelStep = 39; MessageNotify.GetInstance.ShowRunLog($"西门子取消订单完成,订单号:{code}"); - } + //} break; case 39: GVL_SmallStation.GetInstance.Order_Cancel = false; @@ -516,38 +513,38 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (!GVL_SmallStation.GetInstance.IsUseLocalRecipe) { - RemoteRecipes = Json.Data.Recipes; + RemoteRecipes = Json.Data.RemoteRecipes; if (RemoteRecipes.Count > 0) { foreach (var data in RemoteRecipes) { - if (data.TrayCode == 1) - { - if (SiemensDevice.XL_Status is XL_Status_DB status) - { + //if (data.TrayCode == 1) + //{ + //if (SiemensDevice.XL_Status is XL_Status_DB status) + //{ switch (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus) { case 3: - SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10); - SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true); + // SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10); + //SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true); GVL_SmallStation.GetInstance.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); + //if (SiemensDevice.XL_Status.Dosing_Confirm) + //{ + // SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串 + // SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false); GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 5; MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料"); - } + // } break; case 5: - if (SiemensDevice.XL_Status.Dosing_Confirm == false) - { + //if (SiemensDevice.XL_Status.Dosing_Confirm == false) + //{ GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 6; MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料信号复位完成"); - } + //} break; case 6: for (int i = 0; i < 5; i++) @@ -574,10 +571,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model break; default: break; - } + //} } - } + //} } } else @@ -593,13 +590,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } else { - RemoteRecipes = Json.Data.Recipes; + RemoteRecipes = Json.Data.RemoteRecipes; if (RemoteRecipes.Count > 0) { foreach (var data in RemoteRecipes) { - if (data.TrayCode == 1) - { + //if (data.TrayCode == 1) + //{ for (int i = 0; i < 5; i++) { if (GVL_SmallStation.GetInstance.NotUseSmallStation) @@ -619,7 +616,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - } + //} } } else @@ -639,6 +636,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// private void RecipeInfoToHKPLC() { + //五个工位AGV控制请求流程。 if (!GVL_SmallStation.GetInstance.NotUseSmallStation) { for (int i = 0; i < 5; i++) @@ -657,7 +655,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model break; case 1: if (GVL_SmallStation.GetInstance.Station1HaveTray) - { HKDevice.HK_PLC_S7.Write("DB4.DBX8." + i, false); GVL_SmallStation.GetInstance.Tray_AGVLogic[i] = 2; @@ -688,11 +685,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } + + //工位配料流程 foreach (var recipe in RecipeQueueTray) { + //recipeNum就是托盘号,也就是工位号。 int recipeNum = recipe.Key; + //判断工位是否有配方。 if (RecipeQueueTray[recipeNum].Count > 0) { + //从配方列表里根据配方号查找配方 int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray[recipeNum].ElementAt(0)); if (index >= 0 && index < RemoteRecipes.Count) { @@ -700,51 +702,53 @@ namespace BPASmartClient.JXJFoodSmallStation.Model int trayCode = RemoteRecipes.ElementAt(index).TrayCode; string recipeName = RemoteRecipes.ElementAt(index).RecipeName; string windSend = RemoteRecipes.ElementAt(index).ToString(); + //当前只配托盘号为1 ,即工位1 的配方。 if (trayCode == 1) { + //如果不使用小料站配料,目前没有这种工作情况。 if (GVL_SmallStation.GetInstance.NotUseSmallStation) { if (GVL_SmallStation.GetInstance.AGV_PutTray1Finish) { Thread.Sleep(5000); - var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); - if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe) - { - RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; - RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; - RecipeFinishInfo.Job_No = (short)trayCode; - for (int i = 0; i < 20; i++) - { - RecipeFinishInfo.Material[i] = new UDT1(); - } - for (int i = 0; i < 10; i++) - { - RecipeFinishInfo.Powder[i] = new UDT2(); - } - for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) - { - RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001; - } - for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++) - { - RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight; - } - RecipeFinishInfo.Ask_For_Finish = true; - RecipeFinishInfo.DosingTime = Convert.ToInt16(0); - SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); + var res = Json.Data.RemoteRecipes.FirstOrDefault(p => p.RecipeCode == code); + //if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe) + //{ + // RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; + // RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; + // RecipeFinishInfo.Job_No = (short)trayCode; + // for (int i = 0; i < 20; i++) + // { + // RecipeFinishInfo.Material[i] = new UDT1(); + // } + // for (int i = 0; i < 10; i++) + // { + // RecipeFinishInfo.Powder[i] = new UDT2(); + // } + // for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) + // { + // RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + // RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + // RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001; + // } + // for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++) + // { + // RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight; + // } + // RecipeFinishInfo.Ask_For_Finish = true; + // RecipeFinishInfo.DosingTime = Convert.ToInt16(0); + // SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子"); - } - else + // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子"); + //} + //else { MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方"); } GVL_SmallStation.GetInstance.WindSendDosing = false; App.Current.Dispatcher.Invoke(() => { - Json.Data.Recipes.Remove(res); + Json.Data.RemoteRecipes.Remove(res); }); RecipeQueueTray[recipeNum].TryDequeue(out code); GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum] = 0; @@ -760,9 +764,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (GVL_SmallStation.GetInstance.WindSendDosingStatus == 1) { + //清空风送配料数据 WindSend_Write WindSendData111 = new WindSend_Write(); WindSendDevice.Siemens_PLC_S7.WriteClass(WindSendData111, 95); Thread.Sleep(200); + //设置DB95数据并下发。 WindSendData111.TargetRecipeCode = code; WindSendData111.IsAllowDosing = true; foreach (var item in RemoteRecipes.ElementAt(index).WindSend) @@ -795,6 +801,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } GVL_SmallStation.GetInstance.WindSendDosing = true; GVL_SmallStation.GetInstance.WindSendDosingStatus = 2; + //下发配料数据 WindSendDevice.Siemens_PLC_S7.WriteClass(WindSendData111, 95); } } @@ -807,30 +814,39 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } + //如果小料仓配方下发状态为0(未下发),则下发配方。并清除该工位配方的配料情况信号。 if (GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] == 0) { GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum] = 0; + //下发工单,并置位工单下发确认。 HKDevice.IssueRecipeToPlc(RemoteRecipes.ElementAt(index).RawMaterial, recipeNum); HKDevice.HK_PLC_S7.Write("DB4.DBX2." + recipeNum, true); + //下发完成,等待开始制作。 GVL_SmallStation.GetInstance.DosingTime[recipeNum] = DateTime.Now; GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] = 1; MessageNotify.GetInstance.ShowRunLog($"托盘1,配方编号{code},配方号{recipeNum + 1},下发完成"); } + //确认是否收到工单 bool recipeReceviceFinish = HKDevice.HK_PLC_S7.Read("DB3.DBX4." + recipeNum); if (recipeReceviceFinish && GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] == 1) { + //确认PLC收到工单后,复位下发确认信号。 HKDevice.HK_PLC_S7.Write("DB4.DBX2." + recipeNum, false); GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] = 2; GVL_SmallStation.GetInstance.StockBinDosingIssue[recipeNum] = 0; MessageNotify.GetInstance.ShowRunLog($"托盘1,配方编号{code},配方号{recipeNum + 1},配方接收完成"); } + //粉料仓完毕,开始控制小料仓味魔方配料。 if (GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] == 2) { + //味魔方配料。 for (byte i = 1; i < 16; i++) { + //indexArr是各配方位置反馈。 int indexArr = -1; if (GVL_SmallStation.GetInstance.plcReadDataDB3.StockBinAllowIssue[i - 1]) { + //根据配方号查找各配方的三个桶的位置反馈。位置反馈用的是ushort转16位2进制表示。 switch (recipeNum) { case 0: @@ -849,10 +865,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model indexArr = Array.FindIndex(GVL_SmallStation.GetInstance.plcReadDataDB3.Recipe5BarrelPosReserve.ToArray(), p => p == i); break; } + //如果料桶已经到位但没有配料完成信号。 if (indexArr >= 0 && GVL_SmallStation.GetInstance.StockBinDosingIssue[recipeNum].GetBitValue((byte)i) == false) { int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg + //如果重量为0,即不需要配料。则直接设为配料完成。 if (weight <= 0) { if (i >= 1 && i <= 8) @@ -870,6 +888,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } else { + //下发小料仓味魔方配料指令。 if (loc_index >= 0) { DeviceInquire.GetInstance.GetDevice((int)i)?.Start(weight);//根据料仓编号 启动并写入每个原料重量 @@ -886,6 +905,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { //MessageNotify.GetInstance.ShowRunLog($"错误,有允许配料信号,但没有相应的位置 和桶号"); } + //味魔方配料完成后处理。 if ((DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) && indexArr >= 0 && GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum].GetBitValue((byte)i)) { int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); @@ -895,10 +915,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } else { + //配料完成后,先延时一段时间再复位。 Thread.Sleep(GVL_SmallStation.GetInstance.Time); + //获取实际下料重量后复位配料完成状态。 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}"); + + //计算误差范围是否在允许范围内,如果超出范围,则报警。 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) @@ -913,6 +938,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model }); } } + //置位味魔方配料完成信号。 if (i >= 1 && i <= 8) { string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX12." + (i - 1), true); @@ -929,6 +955,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } + + //接收到工单配料完成上升沿后。 bool DosingComple = HKDevice.HK_PLC_S7.Read("DB3.DBX6." + recipeNum); if ((RTrig.GetInstance("配方配料完成").Start(DosingComple)) || (GVL_SmallStation.GetInstance.StockBinDosingIssue[recipeNum] > 0 && DosingComple)) { @@ -937,50 +965,52 @@ namespace BPASmartClient.JXJFoodSmallStation.Model if (GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum] > 0) { for (int i = 1; i < 17; i++) - { + {//看不懂 if (GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum].GetBitValue((byte)i)) { MessageNotify.GetInstance.ShowRunLog($"料仓配料完成,但存在料仓未配料:{i}号仓"); } } } - var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); + var res = Json.Data.RemoteRecipes.FirstOrDefault(p => p.RecipeCode == code); double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.DosingTime[recipeNum]).TotalSeconds; foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) { MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g"); } - if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe) - { - RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; - RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; - RecipeFinishInfo.Job_No = (short)trayCode; - for (int i = 0; i < 20; i++) - { - RecipeFinishInfo.Material[i] = new UDT1(); - } - for (int i = 0; i < 10; i++) - { - RecipeFinishInfo.Powder[i] = new UDT2(); - } - for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) - { - RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001; - } - for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++) - { - RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight; - } - RecipeFinishInfo.Ask_For_Finish = true; - RecipeFinishInfo.DosingTime = Convert.ToInt16(a); - SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); + //if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe) + //{ + // RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; + // RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; + // RecipeFinishInfo.Job_No = (short)trayCode; + // for (int i = 0; i < 20; i++) + // { + // RecipeFinishInfo.Material[i] = new UDT1(); + // } + // for (int i = 0; i < 10; i++) + // { + // RecipeFinishInfo.Powder[i] = new UDT2(); + // } + // for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) + // { + // RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + // RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + // RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001; + // } + // for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++) + // { + // RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight; + // } + // RecipeFinishInfo.Ask_For_Finish = true; + // RecipeFinishInfo.DosingTime = Convert.ToInt16(a); + // SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子"); - MessageNotify.GetInstance.ShowRecipeLog(res.RecipeName); - } - else + // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子"); + // MessageNotify.GetInstance.ShowRecipeLog(res.RecipeName); + //} + //else + + //TODO:发送配方制作完成反馈到服务系统。 { MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方"); MessageNotify.GetInstance.ShowRecipeLog(res.RecipeName); @@ -988,7 +1018,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model GVL_SmallStation.GetInstance.WindSendDosing = false; App.Current.Dispatcher.Invoke(() => { - Json.Data.Recipes.Remove(res); + Json.Data.RemoteRecipes.Remove(res); }); RecipeQueueTray[recipeNum].TryDequeue(out code); GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum] = 0; @@ -1001,6 +1031,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } + /// + /// 复位料仓状态。 + /// private void StockBinInit() { for (int i = 1; i < 16; i++) @@ -1029,10 +1062,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } /// - /// PLC的DB3变量列表 + /// PLC的变量列表 /// public void PlcVarMonitor() { + //海科的DB3 foreach (PropertyInfo item in typeof(PlcReadAddressDB3).GetProperties()) { if (Attribute.IsDefined(item, typeof(VarCommAttribute))) @@ -1049,7 +1083,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model }); } } - + //风送PLC的DB94状态反馈 foreach (PropertyInfo item in typeof(WindSend_Read).GetProperties()) { if (Attribute.IsDefined(item, typeof(VarCommAttribute))) @@ -1101,6 +1135,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } + /// + /// 操作委托注册。 + /// public void RegisterInit() { //手动控制气缸 DB5.DBX0.0~DB5.DBX4.5 @@ -1285,8 +1322,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { ObservableCollection RawMaterials = new ObservableCollection(); ObservableCollection WindSendData = new ObservableCollection(); - if (SiemensDevice.IsConnected) - { + //if (SiemensDevice.IsConnected) + //{ if (res != null && res is XL_Start_DB recipe) { if (!string.IsNullOrEmpty(recipe.RecipeCode)) @@ -1333,7 +1370,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } App.Current.Dispatcher.Invoke(() => { - Json.Data.Recipes.Add(new RemoteRecipeData() + Json.Data.RemoteRecipes.Add(new RecipeData() { RecipeName = recipe.RecipeName, RecipeCode = recipe.RecipeCode, @@ -1344,16 +1381,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model }); } } - } + //} }), "SiemensRecipeRecive", true); //将本地配方发送到西门子配方里,执行配料 ActionManage.GetInstance.Register(new Action((res) => { - if (res != null && res is RemoteRecipeData rm) + if (res != null && res is RecipeData rm) { - //Json.Data.Recipes.Add(rm); - var newRecipe = new RemoteRecipeData(); + //Json.Data.RemoteRecipes.Add(rm); + var newRecipe = new RecipeData(); newRecipe.RecipeName = rm.RecipeName; newRecipe.RecipeCode = rm.RecipeCode; newRecipe.TrayCode = rm.TrayCode; @@ -1387,7 +1424,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model RawMaterialType = item.RawMaterialType, }); } - Json.Data.Recipes.Add(newRecipe); + Json.Data.RemoteRecipes.Add(newRecipe); } }), "LocalSimulationRecipeIssue", true); @@ -1403,7 +1440,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.4", true); }), "CLearRecipeInfo", true); ActionManage.GetInstance.Register(new Action(() => { - Json.Data.Recipes.Clear(); + Json.Data.RemoteRecipes.Clear(); GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0; GVL_SmallStation.GetInstance.WindSendDosingStatus = 0; @@ -1522,6 +1559,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model }), "RobotSetProgramNum", true); } + /// + /// 设备连接并开启重连线程。 + /// public void DeviceConnect() { try @@ -1541,12 +1581,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model HKDevice.Init(); MessageNotify.GetInstance.ShowRunLog("海科plc初始化完成"); } + //TODO:连接服务系统。 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连接成功"); + //SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); + //if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功"); } } catch (Exception ex) @@ -1555,9 +1596,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } finally { - SiemensDevice.Init(); + // SiemensDevice.Init(); MessageNotify.GetInstance.ShowRunLog("西门子plc初始化完成"); } + //连接风送设备 try { if (Json.Data.deviceConnectPar.WindSendConnect) @@ -1575,8 +1617,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model WindSendDevice.Init(); MessageNotify.GetInstance.ShowRunLog("风送粉料plc初始化完成"); } + + //一直判断是否断开了连接, 断开就重连。 TaskManage.GetInstance.StartLong(new Action(() => { + //重连海科配料PLC try { if (!HKDevice.IsConnected && Json.Data.deviceConnectPar.HKPlcConnect) @@ -1588,17 +1633,20 @@ namespace BPASmartClient.JXJFoodSmallStation.Model catch (Exception ex) { } + //TODO:重连服务系统 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重新连接成功"); - } + //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) @@ -1632,6 +1680,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } + /// + /// 风送变量复位原料设定重量及配方制作完成接收。 + /// private void WindSendReset() { float weight = (float)0.0; diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/ActionMenu.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/ActionMenu.cs deleted file mode 100644 index 85f52f2f..00000000 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/ActionMenu.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using BPA.Helper; - - -namespace BPASmartClient.JXJFoodSmallStation.Model -{ - public class ActionMenu : NotifyBase - { - public string CommandParameter { get { return _mCommandParameter; } set { _mCommandParameter = value; OnPropertyChanged(); } } - private string _mCommandParameter; - - //public Permission[] permission { get { return _mpermission; } set { _mpermission = value; OnPropertyChanged(); } } - //private Permission[] _mpermission; - - public string MenuName { get { return _mMenuName; } set { _mMenuName = value; OnPropertyChanged(); } } - private string _mMenuName; - - - //public string NameSpace { get { return _mNameSpace; } set { _mNameSpace = value; OnPropertyChanged(); } } - //private string _mNameSpace; - - - } -} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/ConveyorServer.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/ConveyorServer.cs deleted file mode 100644 index bbec856d..00000000 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/ConveyorServer.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using BPA.Helper; - -namespace BPASmartClient.JXJFoodSmallStation.Model -{ - public class ConveyorServer - { - public ConveyorServer() - { - - } - } -} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/CylinderStatusModel.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/CylinderStatusModel.cs deleted file mode 100644 index 7e5959b9..00000000 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/CylinderStatusModel.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using BPA.Helper; - -namespace BPASmartClient.JXJFoodSmallStation.Model -{ - public class CylinderStatusModel : NotifyBase - { - /// - /// 气缸原点信号 - /// - public bool HomeStatus { get { return _mHomeStatus; } set { _mHomeStatus = value; OnPropertyChanged(); } } - private bool _mHomeStatus; - - /// - /// 气缸到位信号 - /// - public bool InPlace { get { return _mInPlace; } set { _mInPlace = value; OnPropertyChanged(); } } - private bool _mInPlace; - - - - } -} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs index 6a790e7b..32e969be 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs @@ -214,13 +214,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); - for (int i = 0; i < Json.Data.Recipes.Count; i++) + for (int i = 0; i < Json.Data.RemoteRecipes.Count; i++) { - for (int m = 0; m < Json.Data.Recipes.ElementAt(i).RawMaterials.Count; m++) + for (int m = 0; m < Json.Data.RemoteRecipes.ElementAt(i).RawMaterials.Count; m++) { - if (Json.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp == ip) + if (Json.Data.RemoteRecipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp == ip) { - Json.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName; + Json.Data.RemoteRecipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName; } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/GlobalData.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/GlobalData.cs deleted file mode 100644 index 4bb2454c..00000000 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/GlobalData.cs +++ /dev/null @@ -1,15 +0,0 @@ -using BPASmartClient.Model; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.JXJFoodSmallStation.Model -{ - public class GlobalData - { - - } -} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs index a45bee4e..2fde580c 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs @@ -11,7 +11,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { public class LocaPar { - public ObservableCollection Recipes { get; set; } = new ObservableCollection(); + public ObservableCollection RemoteRecipes { get; set; } = new ObservableCollection(); /// /// 配方完成数目。 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeProcess.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeProcess.cs deleted file mode 100644 index 065795ee..00000000 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeProcess.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using BPA.Helper; - -namespace BPASmartClient.JXJFoodSmallStation.Model -{ - public class RecipeProcess : NotifyBase - { - public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } - private string _mRawMaterialName; - - - public int RawMaterialStatus { get { return _mRawMaterialStatus; } set { _mRawMaterialStatus = value; OnPropertyChanged(); } } - private int _mRawMaterialStatus; - - } -} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/LocalRecipeDataColl.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/LocalRecipeDataColl.cs index 1405375d..e0e72acc 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/LocalRecipeDataColl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/LocalRecipeDataColl.cs @@ -9,10 +9,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens { internal class LocalRecipeDataColl { - public ObservableCollection Recipes { get; set; } = new ObservableCollection(); + /// + /// 本地自定义配方集合。 + /// + public ObservableCollection RemoteRecipes { get; set; } = new ObservableCollection(); /// /// 筛选后的配方显示集合。 /// - public ObservableCollection SelectedRecipes { get; set; } = new ObservableCollection(); + public ObservableCollection SelectedRecipes { get; set; } = new ObservableCollection(); } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/NewRemoteRecipeModel.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/NewRemoteRecipeModel.cs deleted file mode 100644 index e8cef8c1..00000000 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/NewRemoteRecipeModel.cs +++ /dev/null @@ -1,74 +0,0 @@ -//using BPA.Helper; -//using BPA.Helper; -//using System; -//using System.Collections.Generic; -//using System.Linq; -//using System.Text; -//using System.Threading.Tasks; - -//namespace BPASmartClient.JXJFoodSmallStation.Model -//{ -// public class NewRemoteRecipeModel : NotifyBase -// { -// /// -// /// 原料名称 -// /// -// public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } -// private string _mRawMaterialName; - -// /// -// /// 原料对应的桶号 -// /// -// public short RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; OnPropertyChanged(); } } -// private short _mRawMaterialBarrelNum; - -// /// -// /// 原料类型 -// /// -// public string RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } } -// private string _mRawMaterialType; - -// /// -// /// 需要原料重量 -// /// -// public float RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } -// private float _mRawMaterialWeight; - -// /// -// /// 原料对应料仓的位置 -// /// -// public int RawMaterialLocation -// { -// get { return _mRawMaterialLocation; } -// set -// { -// _mRawMaterialLocation = value; -// //if (RawMaterialType == "小料") -// //{ -// // var res = Json.Data.rawMaterialStockBin.FirstOrDefault(p => p.RawMaterialLocation == value); -// // if (res != null && !string.IsNullOrEmpty(res.RawMaterialName)) -// // { -// // var temp = Json.Data.BomMaterial.FirstOrDefault(p => p.MaterialCode == res.RawMaterialName); -// // if (temp != null && !string.IsNullOrEmpty(temp.MaterialName)) -// // { -// // RawMaterialName = temp.MaterialName; -// // } -// // } -// //} -// //else if (RawMaterialType == "粉料") -// //{ -// // var res = Json.Data.windSendRawMaterial.FirstOrDefault(p => p.Location == value); -// // if (res != null) -// // { -// // RawMaterialName = res.RawMaterialName; -// // } -// //} -// ActionManage.GetInstance.Send("ChangeNotify", this); -// OnPropertyChanged(); -// } -// } -// private int _mRawMaterialLocation; - - -// } -//} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs index 29e8de7c..52d64704 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace BPASmartClient.JXJFoodSmallStation.Model { - public class RemoteRecipeData:NotifyBase + public class RecipeData:NotifyBase { /// /// 配方名称 diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeDataColl.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeDataColl.cs index e400db22..5e555673 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeDataColl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeDataColl.cs @@ -9,8 +9,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens { public class RemoteRecipeDataColl { - public ObservableCollection Recipes { get; set; } = new ObservableCollection(); - public int RecipesStatus { get; set; } + public ObservableCollection RemoteRecipes { get; set; } = new ObservableCollection(); } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensCommAddress.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensCommAddress.cs deleted file mode 100644 index b05bab8a..00000000 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensCommAddress.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens -{ - public class SiemensCommAddress - { - #region 配方地址 - /// - /// 配方状态 - /// - public static string RecipeState { get; set; } = ""; - /// - /// 配方名称 - /// - public static string RecipeName { get; set; } = ""; - /// - /// 配方ID - /// - public static string RecipeID { get; set; } = ""; - /// - /// 原料信息 - /// - public static string RawMaterial { get; set; } = ""; - #endregion - - #region AGV到位(与西门子PLC交互)西门子PLC ==> 上位机 - /// - /// 托盘的位置编号 - /// - public static string TrayLocationNum { get; set; } = ""; - /// - /// 配方ID - /// - public static string TrayRecipeID { get; set; } = ""; - /// - /// 状态信号 - /// - public static string StateSign { get; set; } = ""; - /// - /// Agv送货 进站申请 从西门子读取 - /// - public static string DeliveryAGVApply { get; set; } = ""; - /// - /// Agv送货 进站申请 写给西门子 - /// - public static string DeliveryAGVIsApply { get; set; } = ""; - /// - /// Agv送货 进站顶升申请 从西门子读取 - /// - public static string DeliveryAGVApplyJack { get; set; } = ""; - /// - /// Agv送货 进站顶升申请 写给西门子 - /// - public static string DeliveryAGVIsApplyJack { get; set; } = ""; - /// - /// Agv送货 送货完成 从西门子读取 - /// - public static string DeliveryAGVFinsih { get; set; } = ""; - /// - /// Agv送货 工位上有货架 写给西门子 - /// - public static string StationHaveCargo { get; set; } = ""; - /// - /// Agv送货 进站申请 从西门子读取 - /// - public static string PickAGVApply { get; set; } = ""; - /// - /// Agv送货 进站申请 写给西门子 - /// - public static string PickAGVIsApply { get; set; } = ""; - /// - /// Agv送货 取货架完成 从西门子读取 - /// - public static string PickCargoAGVFinish { get; set; } = ""; - /// - /// Agv送货 取料完成 写给西门子 - /// - public static string PickAGVFinish { get; set; } = ""; - /// - /// 工位上是否有小车 - /// - public static string StationIsExistCar { get; set; } = ""; - #endregion - - #region Tray配料完成(与西门子PLC交互)上位机 ==> 西门子PLC - public static string TrayLocationNumToSiemens { get; set; } = ""; - public static string TrayRecipeIDToSiemens { get; set; } = ""; - public static string TrayStateToSiemens { get; set; } = ""; - #endregion - } - public class RecipeRawMaterial - { - /// - /// 原料对应的桶号 - /// - public int[] RawMaterialBarrelNum = new int[15]; - /// - /// 需要原料重量 - /// - public double[] RawMaterialWeight = new double[15]; - /// - /// 原料对应料仓的位置 - /// - public int[] RawMaterialLocation = new int[15]; - } - -} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/TestData.cs b/BPASmartClient.JXJFoodSmallStation/Model/TestData.cs index 8e5801e2..54255f62 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/TestData.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/TestData.cs @@ -13,7 +13,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { public volatile static TestData Instance; public static TestData GetInstance => Instance ?? (Instance = new TestData()); - public ObservableCollection Recipes { get; set; } = new ObservableCollection(); + public ObservableCollection RemoteRecipes { get; set; } = new ObservableCollection(); public ObservableCollection RawMaterials { get; set; } = new ObservableCollection(); public TestData() { @@ -54,7 +54,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model RawMaterialLocation = RawMaterialLocation2 }); - Recipes.Add(new Model.RemoteRecipeData() + RemoteRecipes.Add(new Model.RecipeData() { RecipeName = recipeName, RecipeCode = recipeCode, @@ -100,7 +100,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model RawMaterialLocation = RawMaterialLocation2_2 }); - Recipes.Add(new Model.RemoteRecipeData() + RemoteRecipes.Add(new Model.RecipeData() { RecipeName = recipeName_2, RecipeCode = recipeCode_2, diff --git a/BPASmartClient.JXJFoodSmallStation/View/HardwareStatusView.xaml b/BPASmartClient.JXJFoodSmallStation/View/HardwareStatusView.xaml index 46ea2a00..87233e4e 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/HardwareStatusView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/HardwareStatusView.xaml @@ -73,7 +73,7 @@ + Text=" Kg" /> diff --git a/BPASmartClient.JXJFoodSmallStation/View/RecipeSettingsView.xaml b/BPASmartClient.JXJFoodSmallStation/View/RecipeSettingsView.xaml index dbfac736..73447ba5 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/RecipeSettingsView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/RecipeSettingsView.xaml @@ -97,7 +97,7 @@ VerticalAlignment="Top" Background="Transparent" BorderThickness="0" - ItemsSource="{Binding Recipes}" + ItemsSource="{Binding RemoteRecipes}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> diff --git a/BPASmartClient.JXJFoodSmallStation/View/SiemensRecipeReceiveView.xaml b/BPASmartClient.JXJFoodSmallStation/View/SiemensRecipeReceiveView.xaml index 116df357..0cd3f7bf 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/SiemensRecipeReceiveView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/SiemensRecipeReceiveView.xaml @@ -68,7 +68,7 @@ VerticalAlignment="Top" Background="Transparent" BorderThickness="0" - ItemsSource="{Binding Recipes}" + ItemsSource="{Binding RemoteRecipes}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/ChangeDeviceNameViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/ChangeDeviceNameViewModel.cs index 0b3877f2..3bdfe043 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/ChangeDeviceNameViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/ChangeDeviceNameViewModel.cs @@ -41,11 +41,11 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel res.RawMaterialName = DeviceName; DeviceInquire.GetInstance.devices.ElementAt(index).DeviceName = DeviceName; DeviceInquire.GetInstance.GetDevice(IpAddress).SetDeviceName(DeviceName);//设置PLC名称 - for (int i = 0; i < Json.Data.Recipes.Count; i++) + for (int i = 0; i < Json.Data.RemoteRecipes.Count; i++) { - for (int m = 0; m < Json.Data.Recipes.ElementAt(i).RawMaterials.Count; m++) + for (int m = 0; m < Json.Data.RemoteRecipes.ElementAt(i).RawMaterials.Count; m++) { - Json.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName; + Json.Data.RemoteRecipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName; } } MessageNotify.GetInstance.ShowUserLog($"修改设备名称为【{DeviceName}】"); diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/HardwareStatusViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/HardwareStatusViewModel.cs index 0821a1f2..9c976e41 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/HardwareStatusViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/HardwareStatusViewModel.cs @@ -7,7 +7,6 @@ using BPA.Helper; using System.Collections.Concurrent; using System.Collections.ObjectModel; using System.Windows; -using BPA.Helper; using BPASmartClient.JXJFoodSmallStation.Model; diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs index 3dfc6c82..fbbb0c06 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs @@ -161,9 +161,9 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel string cancelRecipeCode = CancelRecipeCode.Trim(); if (!String.IsNullOrEmpty(cancelRecipeCode) && MessageNotify.GetInstance.ShowDialog($"请确认,是否进行删除订单【{cancelRecipeCode}】操作?")) { - if (Json.Data.Recipes != null) + if (Json.Data.RemoteRecipes != null) { - int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == cancelRecipeCode); + int index = Array.FindIndex(Json.Data.RemoteRecipes.ToArray(), p => p.RecipeCode == cancelRecipeCode); if (index >= 0) { GVL_SmallStation.GetInstance.Order_Cancel = true; @@ -301,7 +301,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel MessageNotify.GetInstance.ShowUserLog($"设置柔性味魔方复位时间:{time}s"); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"{time.ToString()}:设置成功!"); }); - SiemensIsConnect = ProcessControl.GetInstance.SiemensDevice.IsConnected; + //SiemensIsConnect = ProcessControl.GetInstance.SiemensDevice.IsConnected; HKPlcIsConnect = ProcessControl.GetInstance.HKDevice.IsConnected; WindSendIsConnect = ProcessControl.GetInstance.WindSendDevice.IsConnected; } diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs index 3a234205..ba28d1d7 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs @@ -26,7 +26,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel ActionManage.GetInstance.Register(new Action((o) => { - if (o != null && o is RemoteRecipeData rm) + if (o != null && o is RecipeData rm) { RecipeName = rm.RecipeName; RecipeCode = rm.RecipeCode; @@ -167,7 +167,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel return; } } - int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == RecipeCode); + int index = Array.FindIndex(Json.Data.RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeCode); if (index >= 0) { foreach (var item in AllRawMaterial) @@ -195,11 +195,11 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel }); } } - Json.Data.Recipes.ElementAt(index).RecipeName = RecipeName; - Json.Data.Recipes.ElementAt(index).TrayCode = TrayNum; - Json.Data.Recipes.ElementAt(index).RecipeCode = RecipeCode; - Json.Data.Recipes.ElementAt(index).RawMaterial = RawMaterials; - Json.Data.Recipes.ElementAt(index).WindSend = WindSendRawMaterials; + Json.Data.RemoteRecipes.ElementAt(index).RecipeName = RecipeName; + Json.Data.RemoteRecipes.ElementAt(index).TrayCode = TrayNum; + Json.Data.RemoteRecipes.ElementAt(index).RecipeCode = RecipeCode; + Json.Data.RemoteRecipes.ElementAt(index).RawMaterial = RawMaterials; + Json.Data.RemoteRecipes.ElementAt(index).WindSend = WindSendRawMaterials; NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"修改配方完成!"); MessageNotify.GetInstance.ShowUserLog($"修改配方名称:【{RecipeName}】,配方编号:【{RecipeCode}】。"); } @@ -230,7 +230,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel }); } } - var newRemoteRecipeData = new RemoteRecipeData() + var newRemoteRecipeData = new RecipeData() { RecipeName = RecipeName, RecipeCode = RecipeCode, @@ -238,7 +238,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel RawMaterial = RawMaterials, WindSend = WindSendRawMaterials, }; - Json.Data.Recipes.Add(newRemoteRecipeData); + Json.Data.RemoteRecipes.Add(newRemoteRecipeData); //新增一条配方应该默认显示出来。 Json.Data.SelectedRecipes.Add(newRemoteRecipeData); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"自定义配方添加完成!"); diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/NewRecipeViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/NewRecipeViewModel.cs index 50799f8b..e188b6b5 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/NewRecipeViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/NewRecipeViewModel.cs @@ -83,9 +83,9 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel if (RecipeCode.Length <= 0)//新建配方 { - var res = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeName == RecipeName); + var res = Array.FindIndex(Json.Data.RemoteRecipes.ToArray(), p => p.RecipeName == RecipeName); - if (res >= 0 && res < Json.Data.Recipes.Count) + if (res >= 0 && res < Json.Data.RemoteRecipes.Count) { ErrorInfo = "该配方已存在,请重新输入"; } @@ -96,14 +96,14 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel } else//修改配方 { - var res = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipCode == RecipeCode); - if (res >= 0 && res < Json.Data.Recipes.Count) + var res = Array.FindIndex(Json.Data.RemoteRecipes.ToArray(), p => p.RecipCode == RecipeCode); + if (res >= 0 && res < Json.Data.RemoteRecipes.Count) { - Json.Data.Recipes.ElementAt(res).RecipeName = RecipeName; - Json.Data.Recipes.ElementAt(res).RawMaterials.Clear(); + Json.Data.RemoteRecipes.ElementAt(res).RecipeName = RecipeName; + Json.Data.RemoteRecipes.ElementAt(res).RawMaterials.Clear(); foreach (var item in RawMaterials) { - Json.Data.Recipes.ElementAt(res).RawMaterials.Add(item); + Json.Data.RemoteRecipes.ElementAt(res).RawMaterials.Add(item); } MessageNotify.GetInstance.ShowUserLog($"修改了一条配方,配方编号:【{RecipeCode}】"); } @@ -161,9 +161,9 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel var dates = date.Split("-").ToList(); StringBuilder sb = new StringBuilder(); dates?.ForEach((item) => { sb.Append(item); }); - Json.Data.Recipes.Add(new RecipeModel() + Json.Data.RemoteRecipes.Add(new RecipeModel() { - SerialNum = Json.Data.Recipes.Count + 1, + SerialNum = Json.Data.RemoteRecipes.Count + 1, RawMaterials = RawMaterials, RecipCode = sb.ToString(), RecipeName = RecipeName, diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs index c2ff5722..7338ce9e 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs @@ -29,13 +29,13 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { if (o != null && o is string deviceName) { - int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == deviceName); - if (index >= 0 && index < Recipes.Count) + int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeName == deviceName); + if (index >= 0 && index < RemoteRecipes.Count) { - Recipes.ElementAt(index).IsEnable = false; + RemoteRecipes.ElementAt(index).IsEnable = false; } - MessageNotify.GetInstance.ShowUserLog($"下发工单 { Recipes.ElementAt(index).RecipeName}"); - var res = Recipes.FirstOrDefault(p => p.RecipeName == deviceName); + MessageNotify.GetInstance.ShowUserLog($"下发工单 { RemoteRecipes.ElementAt(index).RecipeName}"); + var res = RemoteRecipes.FirstOrDefault(p => p.RecipeName == deviceName); App.Current.Dispatcher.Invoke(() => { UserTreeWait.Add(new RecipeModel { RecipeName = deviceName, RawMaterials = res.RawMaterials }); @@ -54,18 +54,18 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { if (devices.Count > 0) { - int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == devices.ElementAt(0)); - if (index >= 0 && index < Recipes.Count) + int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeName == devices.ElementAt(0)); + if (index >= 0 && index < RemoteRecipes.Count) { - Recipes.ElementAt(index).Are.Reset(); - Recipes.ElementAt(index).IsEnable = false; + RemoteRecipes.ElementAt(index).Are.Reset(); + RemoteRecipes.ElementAt(index).IsEnable = false; App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); UserTreeWait.RemoveAt(0); })); - CurrentRecipeName = Recipes.ElementAt(index).RecipeName; - foreach (var item in Recipes.ElementAt(index).RawMaterials) + CurrentRecipeName = RemoteRecipes.ElementAt(index).RecipeName; + foreach (var item in RemoteRecipes.ElementAt(index).RawMaterials) { DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动并写入每个原料重量 @@ -80,11 +80,11 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel }); })); } - Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成 + RemoteRecipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成 devices.TryDequeue(out string deviceName); App.Current.Dispatcher.Invoke(new Action(() => { - UserTreeCompelete.Add(Recipes.ElementAt(index));//当前配方完成后添加到已完成的配方列表 + UserTreeCompelete.Add(RemoteRecipes.ElementAt(index));//当前配方完成后添加到已完成的配方列表 })); App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); @@ -99,17 +99,17 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel TaskManage.GetInstance.StartLong(new Action(() => { - for (int i = 0; i < Recipes.Count; i++) + for (int i = 0; i < RemoteRecipes.Count; i++) { - for (int m = 0; m < Recipes.ElementAt(i).RawMaterials.Count; m++) + for (int m = 0; m < RemoteRecipes.ElementAt(i).RawMaterials.Count; m++) { - var RunStatus = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).deviceStatus.RunStatus; + var RunStatus = DeviceInquire.GetInstance.GetDevice(RemoteRecipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).deviceStatus.RunStatus; //设备状态显示 - if (Recipes.ElementAt(i).RecipeName == CurrentRecipeName) + if (RemoteRecipes.ElementAt(i).RecipeName == CurrentRecipeName) { - string deviceName = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName; - int index = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == deviceName); + string deviceName = DeviceInquire.GetInstance.GetDevice(RemoteRecipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName; + int index = Array.FindIndex(RemoteRecipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == deviceName); if (index >= 0 && index < recipeProcesses.Count) { @@ -122,34 +122,34 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel var proc = recipeProcesses.Where(p=>p.RecipeStatus==3).ToList(); if (proc != null && proc.Count > 0 && proc.Count== recipeProcesses.Count) { - int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName); - if (recipIndex >= 0 && recipIndex < Recipes.Count) + int recipIndex = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeName == CurrentRecipeName); + if (recipIndex >= 0 && recipIndex < RemoteRecipes.Count) { for (int n = 0; n < recipeProcesses.Count; n++) { - DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 - MessageNotify.GetInstance.ShowRunLog(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp); + DeviceInquire.GetInstance.GetDevice(RemoteRecipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 + MessageNotify.GetInstance.ShowRunLog(RemoteRecipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp); } App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); - Recipes.ElementAt(recipIndex).IsEnable = true; - Recipes.ElementAt(recipIndex).Are.Set(); + RemoteRecipes.ElementAt(recipIndex).IsEnable = true; + RemoteRecipes.ElementAt(recipIndex).Are.Set(); } } - //Recipes.ElementAt(i).RawMaterials.ElementAt(m).RecipeStatus = RunStatus; - //var res = Recipes.ElementAt(i).RawMaterials.Where(p => p.RecipeStatus == 3).ToList(); - //if (res != null && res.Count == Recipes.ElementAt(i).RawMaterials.Count)//配方所有配料完成下料 + //RemoteRecipes.ElementAt(i).RawMaterials.ElementAt(m).RecipeStatus = RunStatus; + //var res = RemoteRecipes.ElementAt(i).RawMaterials.Where(p => p.RecipeStatus == 3).ToList(); + //if (res != null && res.Count == RemoteRecipes.ElementAt(i).RawMaterials.Count)//配方所有配料完成下料 //{ - // for (int r = 0; r < Recipes.ElementAt(i).RawMaterials.Count; r++) + // for (int r = 0; r < RemoteRecipes.ElementAt(i).RawMaterials.Count; r++) // { - // DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(r).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 + // DeviceInquire.GetInstance.GetDevice(RemoteRecipes.ElementAt(i).RawMaterials.ElementAt(r).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 // App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); // } - // Recipes.ElementAt(i).IsEnable = true; - // Recipes.ElementAt(i).Are.Set(); + // RemoteRecipes.ElementAt(i).IsEnable = true; + // RemoteRecipes.ElementAt(i).Are.Set(); //} } } @@ -170,7 +170,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public BPARelayCommand ChangeRecipeStateCommand { get; set; } - public static ObservableCollection Recipes { get; set; } = Json.Data.Recipes; + public static ObservableCollection RemoteRecipes { get; set; } = Json.Data.RemoteRecipes; public string CurrentRecipeName { get { return _RecipeName; }set { _RecipeName = value; OnPropertyChanged(); } } private static string _RecipeName; diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs index 7cf00dba..ef9edf66 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs @@ -20,7 +20,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel ActionManage.GetInstance.CancelRegister("RecipeInfo"); ActionManage.GetInstance.Register(new Action((o) => { - if (o != null && o is RemoteRecipeData rm) + if (o != null && o is RecipeData rm) { RecipeName = rm.RecipeName; RecipeCode = rm.RecipeCode; diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs index f2d77d2d..4e994e20 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs @@ -31,7 +31,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel NotUseSmallDosing = GVL_SmallStation.GetInstance.NotUseSmallStation; IsUseLocalRecipe = GVL_SmallStation.GetInstance.IsUseLocalRecipe; IsUseWindSendDosing = GVL_SmallStation.GetInstance.IsUseWindSend; - Recipes = Json.Data.Recipes; + RemoteRecipes = Json.Data.RemoteRecipes; NewRecipe = new BPARelayCommand(() => { @@ -44,10 +44,16 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { if (MessageNotify.GetInstance.ShowDialog($"请确认,是否删除订单【{cnt}】?")) { - var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == cnt); + var res = Json.Data.RemoteRecipes.FirstOrDefault(p => p.RecipeCode == cnt); + var res1= Json.Data.SelectedRecipes.FirstOrDefault(p => p.RecipeCode == cnt); + if (res1 is not null) + { + Json.Data.SelectedRecipes.Remove(res1); + } if (res != null) { - Json.Data.Recipes.Remove(res); + Json.Data.RemoteRecipes.Remove(res); + Json.Save(); MessageNotify.GetInstance.ShowUserLog($"删除配方——{res.RecipeName}"); } } @@ -61,7 +67,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { //ActionManage.GetInstance.Send("CloseNewRemoteRecipeView"); NewLocalRecipeView nrv = new NewLocalRecipeView(); - var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == cnt); + var res = Json.Data.RemoteRecipes.FirstOrDefault(p => p.RecipeCode == cnt); if (res != null) { ActionManage.GetInstance.Send("LocalRecipeEdit", res); @@ -82,8 +88,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { if (o != null && o is string cnt) { - var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == cnt); - var res1 = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == cnt); + var res = Json.Data.RemoteRecipes.FirstOrDefault(p => p.RecipeCode == cnt); + var res1 = Json.Data.RemoteRecipes.FirstOrDefault(p => p.RecipeCode == cnt); if (MessageNotify.GetInstance.ShowDialog($"请确认,是否进行下发订单【{cnt}】操作?")) { if (res1 != null) @@ -105,10 +111,10 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel NewSimulateRecipe = new BPARelayCommand(() => { ObservableCollection RawMaterials = new ObservableCollection(); - string recipeName = "配方" + (Json.Data.Recipes.Count + 1) + ""; + string recipeName = "配方" + (Json.Data.RemoteRecipes.Count + 1) + ""; go: string recipeCode = new Random().Next(1000, 9999).ToString(); - foreach (var item in Json.Data.Recipes) + foreach (var item in Json.Data.RemoteRecipes) { if (item.RecipeCode == recipeCode) { @@ -141,17 +147,17 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel }); } } - var res = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == recipeCode); + var res = Array.FindIndex(Json.Data.RemoteRecipes.ToArray(), p => p.RecipeCode == recipeCode); if (res < 0) { - var newRemoteRecipedata = new RemoteRecipeData() + var newRemoteRecipedata = new RecipeData() { RecipeName = recipeName, RecipeCode = recipeCode, TrayCode = trayCode, RawMaterial = RawMaterials, }; - Json.Data.Recipes.Add(newRemoteRecipedata); + Json.Data.RemoteRecipes.Add(newRemoteRecipedata); //新增了配方之后应该默认显示出来。 Json.Data.SelectedRecipes.Add(newRemoteRecipedata); @@ -163,7 +169,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { if (MessageNotify.GetInstance.ShowDialog("请确认,是否清除所有本地配方?", DialogType.Warning)) { - Json.Data.Recipes.Clear(); + Json.Data.RemoteRecipes.Clear(); Json.Data.SelectedRecipes.Clear(); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"本地配方清空成功。"); MessageNotify.GetInstance.ShowUserLog("手动清除所有本地配方"); @@ -203,7 +209,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel /// /// 筛选后的配方列表。 /// - public static ObservableCollection SelectedRecipes { get; set; } + public static ObservableCollection SelectedRecipes { get; set; } public BPARelayCommand DetailsCommand { get; set; } public BPARelayCommand IssueRecipe { get; set; } @@ -212,6 +218,6 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public BPARelayCommand ClearAllRecipe { get; set; } public BPARelayCommand NewRecipe { get; set; } public BPARelayCommand SelectRecipesCommand { get; set; } - public ObservableCollection Recipes { get; set; } + public ObservableCollection RemoteRecipes { get; set; } } } diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeSettingsViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeSettingsViewModel.cs index b452f419..01e0f1e6 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeSettingsViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeSettingsViewModel.cs @@ -25,7 +25,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { public RecipeSettingsViewModel() { - Recipes = Json.Data.Recipes; + RemoteRecipes = Json.Data.RemoteRecipes; NewMaterital = new BPARelayCommand(() => { @@ -48,8 +48,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { if (o is string str) { - var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipCode == str); - if (res != null) Json.Data.Recipes.Remove(res); + var res = Json.Data.RemoteRecipes.FirstOrDefault(p => p.RecipCode == str); + if (res != null) Json.Data.RemoteRecipes.Remove(res); MessageNotify.GetInstance.ShowUserLog($"删除名称——{res.RecipeName}"); } }); @@ -60,7 +60,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { ActionManage.GetInstance.CancelRegister("Details"); NewRecipeView nrv = new NewRecipeView(); - var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipCode == str); + var res = Json.Data.RemoteRecipes.FirstOrDefault(p => p.RecipCode == str); ActionManage.GetInstance.Send("Details", res); nrv.ShowDialog(); MessageNotify.GetInstance.ShowUserLog($"编辑配方名称——{res.RecipeName}"); @@ -81,6 +81,6 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public BPARelayCommand RemoveCommand { get; set; } - public ObservableCollection Recipes { get; set; } + public ObservableCollection RemoteRecipes { get; set; } } } diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/SelectRecipesViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/SelectRecipesViewModel.cs index ab620067..e3245020 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/SelectRecipesViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/SelectRecipesViewModel.cs @@ -18,14 +18,15 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public SelectRecipesViewModel() { AllRecipes = new(); + SelectRecipes.Clear(); foreach (var item in Json.Data.SelectedRecipes) { SelectRecipes.Add(item); } - if (Json.Data.Recipes != null) + if (Json.Data.RemoteRecipes != null) { - foreach (var item in Json.Data.Recipes) + foreach (var item in Json.Data.RemoteRecipes) { AllRecipes.Add(new RecipeDataWithCheck() { @@ -79,7 +80,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public ObservableCollection AllRecipes {get; set; } - public static ObservableCollection SelectRecipes { get; set; } = new ObservableCollection(); + public static ObservableCollection SelectRecipes { get; set; } = new ObservableCollection(); /// /// 取消筛选,即关闭本窗口。 @@ -101,7 +102,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel internal class RecipeDataWithCheck:NotifyBase { - public RemoteRecipeData Recipe { get; set; } + public RecipeData Recipe { get; set; } private bool _IsSelected; public bool IsSelected diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/SiemensRecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/SiemensRecipeReceiveViewModel.cs index ce1bad1d..2697ef6e 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/SiemensRecipeReceiveViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/SiemensRecipeReceiveViewModel.cs @@ -27,7 +27,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel //ObservableCollection RawMaterials { get; set; } = new ObservableCollection(); public SiemensRecipeReceiveViewModel() { - Recipes = Json.Data.Recipes; + RemoteRecipes = Json.Data.RemoteRecipes; DetailsCommand = new BPARelayCommand((o) => { if (o != null && o is string cnt) @@ -35,7 +35,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel ActionManage.GetInstance.Send("CloseRecipeInfosView"); RecipeInfosView nrv = new RecipeInfosView(); - var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == cnt); + var res = Json.Data.RemoteRecipes.FirstOrDefault(p => p.RecipeCode == cnt); if (res != null) { ActionManage.GetInstance.Send("RecipeInfo", res); @@ -48,13 +48,13 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { if (MessageNotify.GetInstance.ShowDialog($"请确认,是否删除所有配方订单?")) { - Json.Data.Recipes.Clear(); + Json.Data.RemoteRecipes.Clear(); MessageNotify.GetInstance.ShowUserLog($"手动清除所有配方。"); } }); } public BPARelayCommand DetailsCommand { get; set; } public BPARelayCommand ClearAllRecipe { get; set; } - public ObservableCollection Recipes { get; set; } + public ObservableCollection RemoteRecipes { get; set; } } } diff --git a/BPASmartClient.JakaRobot/BPASmartClient.JakaRobot.csproj b/BPASmartClient.JakaRobot/BPASmartClient.JakaRobot.csproj index defab860..d8f487db 100644 --- a/BPASmartClient.JakaRobot/BPASmartClient.JakaRobot.csproj +++ b/BPASmartClient.JakaRobot/BPASmartClient.JakaRobot.csproj @@ -7,7 +7,7 @@ - + diff --git a/BPASmartClient.MaxWokControl/MainWindow.xaml b/BPASmartClient.MaxWokControl/MainWindow.xaml index 3e46e029..3aa1ab76 100644 --- a/BPASmartClient.MaxWokControl/MainWindow.xaml +++ b/BPASmartClient.MaxWokControl/MainWindow.xaml @@ -1,12 +1,13 @@ - - - - + + diff --git a/BPASmartClient.Modbus/BPASmartClient.Modbus.csproj b/BPASmartClient.Modbus/BPASmartClient.Modbus.csproj index da719a10..4588e916 100644 --- a/BPASmartClient.Modbus/BPASmartClient.Modbus.csproj +++ b/BPASmartClient.Modbus/BPASmartClient.Modbus.csproj @@ -5,7 +5,7 @@ - + diff --git a/BPASmartClient.Model/BPASmartClient.Model.csproj b/BPASmartClient.Model/BPASmartClient.Model.csproj index f7881186..8881f2e4 100644 --- a/BPASmartClient.Model/BPASmartClient.Model.csproj +++ b/BPASmartClient.Model/BPASmartClient.Model.csproj @@ -16,7 +16,7 @@ - + diff --git a/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs b/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs index 673d005d..2f21354e 100644 --- a/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs +++ b/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs @@ -25,7 +25,7 @@ namespace BPASmartClient.Model public string DeviceIp { get; set; } /// - /// 料筒位置 + /// 桶号 /// public int Loc { get { return _mLoc; } set { _mLoc = value; OnPropertyChanged(); } } private int _mLoc; @@ -114,9 +114,9 @@ namespace BPASmartClient.Model set { _mRecipeStatus = value; - if (value == 1 && Status != Status.配料完成) Status = Status.等待配料; - else if (value == 2) Status = Status.正在配料; - else if (value == 3) Status = Status.配料完成; + //if (value == 1 && Status != Status.配料完成) Status = Status.等待配料; + //else if (value == 2) Status = Status.正在配料; + //else if (value == 3) Status = Status.配料完成; OnPropertyChanged(); } } diff --git a/BPASmartClient.MorkMV1/DataServer.cs b/BPASmartClient.MorkMV1/DataServer.cs index 607168dc..f29653f5 100644 --- a/BPASmartClient.MorkMV1/DataServer.cs +++ b/BPASmartClient.MorkMV1/DataServer.cs @@ -23,7 +23,7 @@ namespace BPASmartClient.MorkMV1 MqttHelper mQTTProxy = new MqttHelper(); public void Init() { - mQTTProxy.ConnectOk = new Action(() => + mQTTProxy.Connected = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); TaskManage.GetInstance.StartLong(new Action(() => diff --git a/BPASmartClient.MorkS/DataServer.cs b/BPASmartClient.MorkS/DataServer.cs index 695a772b..2eee8ea6 100644 --- a/BPASmartClient.MorkS/DataServer.cs +++ b/BPASmartClient.MorkS/DataServer.cs @@ -23,7 +23,7 @@ namespace BPASmartClient.MorkS MqttHelper mQTTProxy = new MqttHelper(); public void Init() { - mQTTProxy.ConnectOk = new Action(() => + mQTTProxy.Connected = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); TaskManage.GetInstance.StartLong(new Action(() => diff --git a/BPASmartClient.MorkS3/DataServer.cs b/BPASmartClient.MorkS3/DataServer.cs index 9d8f74c2..411758cf 100644 --- a/BPASmartClient.MorkS3/DataServer.cs +++ b/BPASmartClient.MorkS3/DataServer.cs @@ -23,7 +23,7 @@ namespace BPASmartClient.MorkS3 MqttHelper mQTTProxy = new MqttHelper(); public void Init() { - mQTTProxy.ConnectOk = new Action(() => + mQTTProxy.Connected = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); TaskManage.GetInstance.StartLong(new Action(() => diff --git a/BPASmartClient.MorkSUpgradedVer/DataServer.cs b/BPASmartClient.MorkSUpgradedVer/DataServer.cs index ad3b8786..124fa7e2 100644 --- a/BPASmartClient.MorkSUpgradedVer/DataServer.cs +++ b/BPASmartClient.MorkSUpgradedVer/DataServer.cs @@ -22,7 +22,7 @@ namespace BPASmartClient.MorkSUpgradedVer MqttHelper mQTTProxy = new MqttHelper(); public void Init() { - mQTTProxy.ConnectOk = new Action(() => + mQTTProxy.Connected = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); TaskManage.GetInstance.StartLong(new Action(() => diff --git a/BPASmartClient.Nfc/BPASmartClient.Nfc.csproj b/BPASmartClient.Nfc/BPASmartClient.Nfc.csproj index ba33798a..20304eea 100644 --- a/BPASmartClient.Nfc/BPASmartClient.Nfc.csproj +++ b/BPASmartClient.Nfc/BPASmartClient.Nfc.csproj @@ -21,7 +21,7 @@ - + diff --git a/BPASmartClient.S7Net/BPASmartClient.S7Net.csproj b/BPASmartClient.S7Net/BPASmartClient.S7Net.csproj index 3c694624..b271d5fe 100644 --- a/BPASmartClient.S7Net/BPASmartClient.S7Net.csproj +++ b/BPASmartClient.S7Net/BPASmartClient.S7Net.csproj @@ -7,7 +7,7 @@ - + diff --git a/BPASmartClient.ScreenALL/App.xaml b/BPASmartClient.ScreenALL/App.xaml index ac841497..3ca651bb 100644 --- a/BPASmartClient.ScreenALL/App.xaml +++ b/BPASmartClient.ScreenALL/App.xaml @@ -1,8 +1,7 @@ - - - - + + diff --git a/BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj b/BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj index 4531e799..b124378c 100644 --- a/BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj +++ b/BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj @@ -24,7 +24,7 @@ - + diff --git a/BPASmartClient.SerialPort/BPASmartClient.SerialPort.csproj b/BPASmartClient.SerialPort/BPASmartClient.SerialPort.csproj index 2c99f76d..6ad8b951 100644 --- a/BPASmartClient.SerialPort/BPASmartClient.SerialPort.csproj +++ b/BPASmartClient.SerialPort/BPASmartClient.SerialPort.csproj @@ -5,7 +5,7 @@ - + diff --git a/BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj b/BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj index c436e43d..a45bf86a 100644 --- a/BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj +++ b/BPASmartClient.SmallBatchingSystem/BPASmartClient.SmallBatchingSystem.csproj @@ -21,7 +21,7 @@ - + diff --git a/BPASmartClient.TourismCollege/App.xaml b/BPASmartClient.TourismCollege/App.xaml deleted file mode 100644 index e972e9cd..00000000 --- a/BPASmartClient.TourismCollege/App.xaml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/BPASmartClient.TourismCollege/App.xaml.cs b/BPASmartClient.TourismCollege/App.xaml.cs deleted file mode 100644 index 66a0f914..00000000 --- a/BPASmartClient.TourismCollege/App.xaml.cs +++ /dev/null @@ -1,296 +0,0 @@ -using BPASmartClient.CustomResource.Pages.ViewModel; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using System.Windows; - -namespace BPASmartClient.TourismCollege -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - public static Window MainWindow; - protected override void OnStartup(StartupEventArgs e) - { - bool createNew; - MessageLog.GetInstance.NotifyShow = new Action(o => - { - DebugLogViewModel.MessageModels.Add(new MessageModel() - { - LogInfo = o, - Forground = System.Windows.Media.Brushes.DeepSkyBlue - }); - }); - MessageLog.GetInstance.NotifyShowEx = new Action(o => - { - DebugLogViewModel.MessageModels.Add(new MessageModel() - { - LogInfo = o, - Forground = System.Windows.Media.Brushes.Red - }); - }); - new EventWaitHandle(false, EventResetMode.AutoReset, "BPASmartClient.TourismCollege", out createNew); - if (!createNew) - { - MessageBox.Show("程序已启动"); - App.Current.Shutdown(); - Environment.Exit(0); - } - base.OnStartup(e); - SystemHelper.GetInstance.CreateDesktopShortcut(); - MenuInit(); - DataInit(); - MainView mv = new MainView(); - mv.TitleName = $"智能炒锅控制系统"; - LoginView lv = new LoginView(); - var res = lv.ShowDialog(); - if (res != null && res == true) - { - BPASmartClient.CustomResource.Pages.Model.MessageNotify.GetInstance.ShowUserLog("用户登录"); - mv.Show(); - } - else - mv.Close(); - MainWindow = mv; - } - - protected override void OnExit(ExitEventArgs e) - { - base.OnExit(e); - BPASmartClient.CustomResource.Pages.Model.MessageNotify.GetInstance.LogSave(); - TaskManage.GetInstance.Dispose(); - } - - private void MenuInit() - { - NfcServer.GetInstance.Init(); - - #region 配方管理菜单 - ObservableCollection RecipeManage = new ObservableCollection(); - RecipeManage.Add(new SubMenumodel() - { - SubMenuName = "配方管理", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.RecipeSettingsView" - }); - - RecipeManage.Add(new SubMenumodel() - { - SubMenuName = "配方下发", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.RecipeControlView" - }); - - MenuManage.GetInstance.menuModels.Add(new MenuModel() - { - MainMenuIcon = "", - MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - MainMenuName = "配方管理", - Alias = "Recipe Management", - subMenumodels = RecipeManage, - }); - #endregion - - #region 参数设置 - ObservableCollection ParSet = new ObservableCollection(); - ParSet.Add(new SubMenumodel() - { - SubMenuName = "原料参数设置", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.DeviceMaterialParView" - }); - - ParSet.Add(new SubMenumodel() - { - SubMenuName = "设备参数设置", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.CommParSetView" - }); - - //ParSet.Add(new SubMenumodel() - //{ - // SubMenuName = "出料口管理设置", - // SubMenuPermission = new Permission[] { Permission.管理员 }, - // AssemblyName = "BPASmartClient.DosingSystem", - // ToggleWindowPath = "View.OutletManagementView" - //}); - - MenuManage.GetInstance.menuModels.Add(new MenuModel() - { - MainMenuIcon = "", - MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - MainMenuName = "参数设置", - Alias = "Parameter Set", - subMenumodels = ParSet, - }); - #endregion - - #region 手动控制 - ObservableCollection ManualControl = new ObservableCollection(); - ManualControl.Add(new SubMenumodel() - { - SubMenuName = "气缸手动控制", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.ManualControlView" - }); - - ManualControl.Add(new SubMenumodel() - { - SubMenuName = "输送带手动控制", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.ConveyerBeltManualView" - }); - - ManualControl.Add(new SubMenumodel() - { - SubMenuName = "配料输送带控制", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.TempManageControlView" - }); - - //ManualControl.Add(new SubMenumodel() - //{ - // SubMenuName = "料仓控制", - // SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, - // AssemblyName = "BPASmartClient.DosingSystem", - // ToggleWindowPath = "View.StockControlView" - //}); - MenuManage.GetInstance.menuModels.Add(new MenuModel() - { - MainMenuIcon = "", - MainMenuName = "手动控制", - MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - Alias = "Parameter Set", - subMenumodels = ManualControl, - }); - #endregion - - #region 消息日志 - ObservableCollection InfoLog = new ObservableCollection(); - InfoLog.Add(new SubMenumodel() - { - SubMenuName = "操作日志", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.UserLogView" - }); - - InfoLog.Add(new SubMenumodel() - { - SubMenuName = "运行日志", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.RunLogView" - }); - - InfoLog.Add(new SubMenumodel() - { - SubMenuName = "报警记录", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.AlarmView" - }); - - InfoLog.Add(new SubMenumodel() - { - SubMenuName = "调试日志", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.DebugLogView" - }); - - MenuManage.GetInstance.menuModels.Add(new MenuModel() - { - MainMenuIcon = "", - MainMenuName = "消息日志", - MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - Alias = "Message Log", - subMenumodels = InfoLog, - }); - #endregion - - #region 硬件设备监控 - ObservableCollection DeviceMonitor = new ObservableCollection(); - DeviceMonitor.Add(new SubMenumodel() - { - SubMenuName = "原料设备列表", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.DeviceListView" - }); - - DeviceMonitor.Add(new SubMenumodel() - { - SubMenuName = "设备状态", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.HardwareStatusView" - }); - - MenuManage.GetInstance.menuModels.Add(new MenuModel() - { - MainMenuIcon = "", - MainMenuName = "设备监控", - MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - Alias = "Device Monitor", - subMenumodels = DeviceMonitor, - }); - #endregion - - #region 用户管理 - ObservableCollection UserManager = new ObservableCollection(); - UserManager.Add(new SubMenumodel() - { - SubMenuName = "用户登录", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.SubPagLoginView" - }); - - UserManager.Add(new SubMenumodel() - { - SubMenuName = "密码修改", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.PasswordChangeView" - }); - UserManager.Add(new SubMenumodel() - { - SubMenuName = "用户管理", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.UserManagerView" - }); - - MenuManage.GetInstance.menuModels.Add(new MenuModel() - { - MainMenuIcon = "", - MainMenuName = "用户管理", - MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - Alias = "User Management", - subMenumodels = UserManager, - }); - #endregion - } - - private void DataInit() - { - - } - - } -} diff --git a/BPASmartClient.TourismCollege/AssemblyInfo.cs b/BPASmartClient.TourismCollege/AssemblyInfo.cs deleted file mode 100644 index 8b5504ec..00000000 --- a/BPASmartClient.TourismCollege/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -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/BPASmartClient.TourismCollege/BPASmartClient.TourismCollege.csproj b/BPASmartClient.TourismCollege/BPASmartClient.TourismCollege.csproj deleted file mode 100644 index bb14476b..00000000 --- a/BPASmartClient.TourismCollege/BPASmartClient.TourismCollege.csproj +++ /dev/null @@ -1,31 +0,0 @@ - - - - WinExe - net6.0-windows - enable - true - hbl.ico - - - - - - - - - - - - - - - - - - - - - - - diff --git a/BPASmartClient.TourismCollege/GlobalUsing.cs b/BPASmartClient.TourismCollege/GlobalUsing.cs deleted file mode 100644 index 419dd12c..00000000 --- a/BPASmartClient.TourismCollege/GlobalUsing.cs +++ /dev/null @@ -1,21 +0,0 @@ -global using System; -global using System.Collections.Generic; -global using System.Collections.ObjectModel; -global using System.Configuration; -global using System.Data; -global using System.Linq; -global using System.Threading; -global using System.Threading.Tasks; -global using System.Windows; -global using System.Diagnostics; -global using System.IO; -global using System.Drawing; -global using System.Windows.Media; -global using BPA.Helper; -global using BPA.Communication; -global using BPASmartClient.CustomResource.Pages.Enums; -global using BPASmartClient.CustomResource.Pages.Model; -global using BPASmartClient.CustomResource.Pages.View; -global using BPASmartClient.CustomResource.Pages.ViewModel; - - diff --git a/BPASmartClient.TourismCollege/Models/RawMaterial.cs b/BPASmartClient.TourismCollege/Models/RawMaterial.cs deleted file mode 100644 index f4af982d..00000000 --- a/BPASmartClient.TourismCollege/Models/RawMaterial.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.TourismCollege.Models -{ - /// - /// 生料类,包括辅料,主料。 - /// - public class RawMaterial - { - public int ID { get; set; } - public string Name { get; set; } - /// - /// 是不是辅料。 - /// - public bool IsCondiments { get; set; } - } -} diff --git a/BPASmartClient.TourismCollege/Viewmodels/ItemStorageViewModel.cs b/BPASmartClient.TourismCollege/Viewmodels/ItemStorageViewModel.cs deleted file mode 100644 index 6aa6fd46..00000000 --- a/BPASmartClient.TourismCollege/Viewmodels/ItemStorageViewModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.TourismCollege.Viewmodels -{ - internal class ItemStorageViewModel - { - } -} diff --git a/BPASmartClient.TourismCollege/Viewmodels/RecipeManageViewModel.cs b/BPASmartClient.TourismCollege/Viewmodels/RecipeManageViewModel.cs deleted file mode 100644 index a261a206..00000000 --- a/BPASmartClient.TourismCollege/Viewmodels/RecipeManageViewModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.TourismCollege.ViewModels -{ - public class RecipeManageViewModel - { - } -} diff --git a/BPASmartClient.TourismCollege/Views/ItemStorageView.xaml b/BPASmartClient.TourismCollege/Views/ItemStorageView.xaml deleted file mode 100644 index 0eddd3e3..00000000 --- a/BPASmartClient.TourismCollege/Views/ItemStorageView.xaml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - -