From ee563fbfd3f3329e4838daadaa57aaa14c87c103 Mon Sep 17 00:00:00 2001 From: pengliangyang <1406009520@qq.com> Date: Fri, 5 May 2023 13:40:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Model/GVL_SmallStation.cs | 7 ++ .../Model/ProcessControl.cs | 87 +++++++++++++------ .../Model/RawMaterial/DeviceAddress.cs | 10 +++ .../Model/RawMaterial/DeviceInquire.cs | 15 ++++ .../Model/WindSend/WindSendDeviceStatus.cs | 65 +++++++++++--- .../Model/WindSend/WindSend_Read.cs | 8 ++ .../View/DeviceListView.xaml | 27 ++++++ .../ViewModel/DeviceListViewModel.cs | 19 ++++ .../ViewModel/NewLocalRecipeViewModel.cs | 9 +- 9 files changed, 205 insertions(+), 42 deletions(-) diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs index d2d872c0..dba1e0b7 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs @@ -286,6 +286,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// public bool WindSendDosingComple { get; set; } = false; + + [VarComm("Global", "粉料仓配料状态")] + /// + /// 粉料仓配料状态(0:无意义,1:粉料仓下配方,2:plc接收配方完成,3:粉料仓配料完成,4:粉料仓配料完成信号复位,5:排料完成) + /// + public int WindSendDosingStatus { get; set; } = 0; + [VarComm("Global", "PLC的系统模式 DB44.DBX0.1")] /// /// PLC的系统模式 DB44.DBX0.1 diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index 0c571639..2df8c253 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -528,6 +528,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model RecipeQueueTray[i].Clear(); GVL_SmallStation.GetInstance.RecipeProcessStatus[i] = 0; } + GVL_SmallStation.GetInstance.WindSendDosingStatus = 0; } } else @@ -568,6 +569,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model RecipeQueueTray[i].Clear(); GVL_SmallStation.GetInstance.RecipeProcessStatus[i] = 0; } + GVL_SmallStation.GetInstance.WindSendDosingStatus = 0; } } } @@ -691,41 +693,74 @@ namespace BPASmartClient.JXJFoodSmallStation.Model else { //粉料仓下发配方 - if (GVL_SmallStation.GetInstance.IsUseWindSend && GVL_SmallStation.GetInstance.Tray_AGVLogic[recipeNum] == 2 && GVL_SmallStation.GetInstance.WindSendDosing == false) + if (GVL_SmallStation.GetInstance.IsUseWindSend && GVL_SmallStation.GetInstance.WindSendDosing == false /*&& GVL_SmallStation.GetInstance.Tray_AGVLogic[recipeNum] == 2*/) { if (WindSendDevice.IsConnected) { - WindSendData.TargetRecipeCode = code; - WindSendData.IsAllowDosing = true; - foreach (var item in RemoteRecipes.ElementAt(index).WindSend) + if (GVL_SmallStation.GetInstance.WindSendDosingStatus == 1) { - if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(0).RawMaterialName) + WindSendData.TargetRecipeCode = code; + WindSendData.IsAllowDosing = true; + foreach (var item in RemoteRecipes.ElementAt(index).WindSend) { - WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight; - } - if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(1).RawMaterialName) - { - WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight; - } - if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(2).RawMaterialName) - { - WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight; - } - if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(3).RawMaterialName) - { - WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight; - } - if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(4).RawMaterialName) - { - WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight; + if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(0).RawMaterialName || item.Location == 1) + { + WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight; + MessageNotify.GetInstance.ShowRunLog($"风送料仓{item.RawMaterialName},设定重量{item.RawMaterialWeight}"); + } + else + { + WindSendData.RawMaterial1_SetWeight = 0; + } + if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(1).RawMaterialName || item.Location == 2) + { + WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight; + MessageNotify.GetInstance.ShowRunLog($"风送料仓{item.RawMaterialName},设定重量{item.RawMaterialWeight}"); + } + else + { + WindSendData.RawMaterial2_SetWeight = 0; + } + if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(2).RawMaterialName || item.Location == 3) + { + WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight; + MessageNotify.GetInstance.ShowRunLog($"风送料仓{item.RawMaterialName},设定重量{item.RawMaterialWeight}"); + } + else + { + WindSendData.RawMaterial3_SetWeight = 0; + } + if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(3).RawMaterialName || item.Location == 4) + { + WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight; + MessageNotify.GetInstance.ShowRunLog($"风送料仓{item.RawMaterialName},设定重量{item.RawMaterialWeight}"); + } + else + { + WindSendData.RawMaterial4_SetWeight = 0; + } + if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(4).RawMaterialName || item.Location == 5) + { + WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight; + MessageNotify.GetInstance.ShowRunLog($"风送料仓{item.RawMaterialName},设定重量{item.RawMaterialWeight}"); + } + else + { + WindSendData.RawMaterial5_SetWeight = 0; + } } + GVL_SmallStation.GetInstance.WindSendDosing = true; + GVL_SmallStation.GetInstance.WindSendDosingStatus = 2; + WindSendDevice.Siemens_PLC_S7.WriteClass(WindSendData, 95); } - GVL_SmallStation.GetInstance.WindSendDosing = true; - WindSendDevice.Siemens_PLC_S7.WriteClass(WindSendData, 95); } else { - MessageNotify.GetInstance.ShowRunLog($"风送设备PLC未连接"); + if (Delay.GetInstance("delayTime").Start(true,60)) + { + Delay.GetInstance("delayTime").Start(false, 60); + MessageNotify.GetInstance.ShowRunLog($"风送设备PLC未连接"); + } } } if (GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] == 0) @@ -1247,6 +1282,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model Json.Data.Recipes.Clear(); GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0; + GVL_SmallStation.GetInstance.WindSendDosingStatus = 0; + GVL_SmallStation.GetInstance.Order_Cancel = false; GVL_SmallStation.GetInstance.Order_CancelRecipeCode = ""; GVL_SmallStation.GetInstance.OrderCancelStep = 0; diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs index 81e4e381..de6009a3 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs @@ -28,6 +28,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// public static string Start { get; set; } = "LW20"; + /// + /// 开盖地址 + /// + public static string OpenLid { get; set; } = ""; + + /// + /// 关盖地址 + /// + public static string CloseLid { get; set; } = ""; + /// /// 下料重量反馈地址 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs index 0163f1c3..c0a5081b 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs @@ -385,6 +385,21 @@ namespace BPASmartClient.JXJFoodSmallStation.Model this.modbusTcp.SetString(DeviceAddress.DeviceName, name); } + /// + /// 开盖 + /// + public void OpenLid() + { + //modbusTcp.Write(DeviceAddress.OpenLid, (ushort)1); + } + /// + /// 关盖 + /// + public void CloseLid() + { + //modbusTcp.Write(DeviceAddress.CloseLid, (ushort)1); + } + public bool StatusReset() { return this.modbusTcp.Write(DeviceAddress.FinfishStatus, (ushort)1); diff --git a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs index 2d24260c..b50fe91c 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs @@ -29,19 +29,62 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet = readData.HoodLiftInPlace; Siemens_PLC_S7.Write("DB95.DBX38.2", GVL_SmallStation.GetInstance.Station1HaveTray);//工站1有托盘 - if (res1.RecipeReceiveFinish) - { - Siemens_PLC_S7.Write("DB95.DBX38.0", false); - } - if (RTrig.GetInstance("CurrentCompleteSign").Start(readData.CurrentCompleteSign)) + switch (GVL_SmallStation.GetInstance.WindSendDosingStatus) { - GVL_SmallStation.GetInstance.WindSendDosingComple = true; - Siemens_PLC_S7.Write("DB95.DBX38.1", true); - } - if (TTrig.GetInstance("CurrentCompleteSign").Start(readData.CurrentCompleteSign)) - { - Siemens_PLC_S7.Write("DB95.DBX38.1", false); + case 0: + if (res1.IsAllowIssue) + { + GVL_SmallStation.GetInstance.WindSendDosingStatus = 1; + } + break; + case 2: + if (res1.RecipeReceiveFinish) + { + Siemens_PLC_S7.Write("DB95.DBX38.0", false); + GVL_SmallStation.GetInstance.WindSendDosingStatus = 3; + } + break; + case 3: + if (RTrig.GetInstance("CurrentCompleteSign").Start(readData.CurrentCompleteSign)) + { + Siemens_PLC_S7.Write("DB95.DBX38.1", true); + GVL_SmallStation.GetInstance.WindSendDosingStatus = 4; + } + break; + case 4: + if (TTrig.GetInstance("CurrentCompleteSign").Start(readData.CurrentCompleteSign)) + { + Siemens_PLC_S7.Write("DB95.DBX38.1", false); + GVL_SmallStation.GetInstance.WindSendDosingStatus = 5; + } + break; + case 5: + if (readData.HoodLiftInPlace && readData.DisChargeComple) + { + GVL_SmallStation.GetInstance.WindSendDosingComple = true; + GVL_SmallStation.GetInstance.WindSendDosingStatus = 0; + } + break; + //case 5: + // if (TTrig.GetInstance("HoodLiftInPlaceSign").Start(readData.HoodLiftInPlace)) + // { + // GVL_SmallStation.GetInstance.WindSendDosingStatus = 6; + // } + // break; + //case 6: + // if (RTrig.GetInstance("HoodLiftInPlaceSign").Start(readData.HoodLiftInPlace)) + // { + // GVL_SmallStation.GetInstance.WindSendDosingStatus = 7; + // } + // break; + //case 7: + // GVL_SmallStation.GetInstance.WindSendDosingComple = true; + // GVL_SmallStation.GetInstance.WindSendDosingStatus = 0; + // break; + default: + break; } + } //测试 /*var res = this.Siemens_PLC_S7.ReadClass(95); diff --git a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Read.cs b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Read.cs index dc1b9b68..222a2f6c 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Read.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Read.cs @@ -22,6 +22,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.WindSend /// public bool CurrentCompleteSign { get; set; } /// + /// 允许下发信号 + /// + public bool IsAllowIssue { get; set; } + /// + /// 排料完成信号 + /// + public bool DisChargeComple { get; set; } + /// /// 当前配方编码 /// [Siemens(16)] diff --git a/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml b/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml index 4513cf9c..b637d2f5 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml @@ -97,6 +97,7 @@ + + + +