diff --git a/BPASmartClient.JXJFoodBigStation/App.config b/BPASmartClient.JXJFoodBigStation/App.config index 5ff78b1a..e5c7f162 100644 --- a/BPASmartClient.JXJFoodBigStation/App.config +++ b/BPASmartClient.JXJFoodBigStation/App.config @@ -1,9 +1,7 @@  - - + - \ No newline at end of file diff --git a/BPASmartClient.JXJFoodBigStation/App.xaml.cs b/BPASmartClient.JXJFoodBigStation/App.xaml.cs index baed6677..600674cb 100644 --- a/BPASmartClient.JXJFoodBigStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodBigStation/App.xaml.cs @@ -46,6 +46,7 @@ namespace BPASmartClient.JXJFoodBigStation { base.OnExit(e); MessageLog.GetInstance.LogSave(); + Json.Save(); ThreadManage.GetInstance().Dispose(); } @@ -169,6 +170,7 @@ namespace BPASmartClient.JXJFoodBigStation { //Config.GetInstance.Init(); //Json.Read(); + Json.Read(); } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs index 28d2c8ca..4096510d 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs @@ -39,6 +39,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 是否处于手动下发配方 /// - public bool IsAllowManual { get; set; } + public bool IsAllowManual { get; set; } = true; } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index 22d04b0f..5c66ea6c 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -91,11 +91,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; try { - //HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); + HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); //SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); if (HKDevice.IsConnected) { HKDevice.Init(); + MessageLog.GetInstance.ShowRunLog("海科plc连接成功"); } if (SiemensDevice.IsConnected) { @@ -106,11 +107,22 @@ namespace BPASmartClient.JXJFoodBigStation.Model { } + + ActionManage.GetInstance.CancelRegister("ManualSendRecipe"); + ActionManage.GetInstance.Register(new Action((o) => + { + if (o !=null && o is RecipeData a) + { + Json.Data.Recipes.Add(a); + } + }), "ManualSendRecipe", true); RecipeQueue.Clear(); + + //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 ThreadManage.GetInstance().StartLong(new Action(() => { - ReadPLCDeviceInfo(); + //ReadPLCDeviceInfo(); ReceviceData(); RecipeInfoToHKPLC(); Thread.Sleep(10); diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs index cbefe1df..867b7d44 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs @@ -38,7 +38,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel //配方下发逻辑 var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName); if (res != null) - ActionManage.GetInstance.Send("手动下发本地配方", res); + ActionManage.GetInstance.Send("ManualSendRecipe", res); } }); } diff --git a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs index 93bb59d2..b7ad1236 100644 --- a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs @@ -125,11 +125,19 @@ namespace BPASmartClient.JXJFoodSmallStation ObservableCollection ManualControl = new ObservableCollection(); ManualControl.Add(new SubMenumodel() { - SubMenuName = "手动控制", + SubMenuName = "手动控制硬件", SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, AssemblyName = "BPASmartClient.JXJFoodSmallStation", ToggleWindowPath = "View.ManualControlView" }); + ManualControl.Add(new SubMenumodel() + { + SubMenuName = "手动控制信号", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + AssemblyName = "BPASmartClient.JXJFoodSmallStation", + ToggleWindowPath = "View.ManualCommView" + + }); MenuManage.GetInstance.menuModels.Add(new MenuModel() { diff --git a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj index 4ee61c76..4b2fecbf 100644 --- a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj +++ b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj @@ -26,6 +26,10 @@ $(DefaultXamlRuntime) + + $(DefaultXamlRuntime) + Designer + $(DefaultXamlRuntime) Designer diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs index e93643bf..0f995bc9 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs @@ -14,6 +14,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model private volatile static GVL_SmallStation SmallStation; public static GVL_SmallStation GetInstance => SmallStation ?? (SmallStation = new GVL_SmallStation()); private GVL_SmallStation() { } + public bool HeartBeatToPlc { get; set; } = false; + public bool HeartBeatFromPlc { get; set; } = false; /// /// 是否允许西门子下发配方 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs index 084aab3c..d3304a56 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs @@ -19,14 +19,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC { if (IsConnected) { - ThreadManage.GetInstance().StartLong(new Action(() => + + /*ThreadManage.GetInstance().StartLong(new Action(() => { if (!IsConnected) { MessageLog.GetInstance.ShowRunLog("海科PLC断开连接"); } Thread.Sleep(10); - }),"信号收发处理"); + }),"信号收发处理");*/ } } /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcManualComm.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcManualComm.cs new file mode 100644 index 00000000..e09a56ec --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcManualComm.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC +{ + public class PlcManualComm + { + public int SerialNum { get; set;} + public string Address { get; set; } + public string Describe { get; set; } + public string NowValue { get; set; } + public string SetValue { get; set; } + + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index 294ebadb..56795827 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -106,57 +106,88 @@ namespace BPASmartClient.JXJFoodSmallStation.Model Json.Data.Recipes.Add(recipe); } }), "LocalSimulationRecipeIssue", true); - string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"]; string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; string WindSend_PLC_IP = ConfigurationManager.AppSettings["WindSend_IP"]; try { - //HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP); + HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP); //SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); //WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200,WindSend_PLC_IP); if (HKDevice.IsConnected) { HKDevice.Init(); - MessageLog.GetInstance.ShowUserLog("海科plc连接成功,并初始化完成"); + MessageLog.GetInstance.ShowRunLog("海科plc连接成功,并初始化完成"); } if (SiemensDevice.IsConnected) { SiemensDevice.Init(); - MessageLog.GetInstance.ShowUserLog("西门子plc连接成功,并初始化完成"); + MessageLog.GetInstance.ShowRunLog("西门子plc连接成功,并初始化完成"); } if (WindSendDevice.IsConnected) { WindSendDevice.Init(); - MessageLog.GetInstance.ShowUserLog("风送plc连接成功,并初始化完成"); + MessageLog.GetInstance.ShowRunLog("风送plc连接成功,并初始化完成"); } } catch(Exception ex) { } + ActionManage.GetInstance.CancelRegister("SystemStart"); + ActionManage.GetInstance.Register(new Action(() => + { + HKDevice.HK_PLC_S7.Write("DB44.DBX0.0", true); + }), "SystemStart", true); + ActionManage.GetInstance.CancelRegister("SystemStop"); + ActionManage.GetInstance.Register(new Action(() => + { + HKDevice.HK_PLC_S7.Write("DB44.DBX0.0", false); + }), "SystemStop", true); + ActionManage.GetInstance.CancelRegister("SystemPause"); + ActionManage.GetInstance.Register(new Action(() => + { + HKDevice.HK_PLC_S7.Write("DB44.DBX0.2", true); + }), "SystemPause", true); + ActionManage.GetInstance.CancelRegister("SystemReset"); + ActionManage.GetInstance.Register(new Action(() => + { + HKDevice.HK_PLC_S7.Write("DB44.DBX0.2", false); + }), "SystemReset", true); + + ActionManage.GetInstance.CancelRegister("SystemAutoMode"); + ActionManage.GetInstance.Register(new Action(() => + { + HKDevice.HK_PLC_S7.Write("DB44.DBX0.1", false); + }), "SystemAutoMode", true); + ActionManage.GetInstance.CancelRegister("SystemDebugMode"); + ActionManage.GetInstance.Register(new Action(() => + { + HKDevice.HK_PLC_S7.Write("DB44.DBX0.1", true); + }), "SystemDebugMode", true); RecipeQueue.Clear(); //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 ThreadManage.GetInstance().StartLong(new Action(() => { + HeartHKPlc(); ReceviceData(); RecipeInfoToHKPLC(); Thread.Sleep(10); }), "西门子配发下发流程处理", true); - ThreadManage.GetInstance().StartLong(new Action(() => + /* ThreadManage.GetInstance().StartLong(new Action(() => { if (SiemensDevice.IsConnected && HKDevice.IsConnected) { - /*AgvGetInDelivery(); - AgvGetInPickUp();*/ + *//*AgvGetInDelivery(); + AgvGetInPickUp();*//* } Thread.Sleep(10); - }), "AGV进站送取货", true); + }), "AGV进站送取货", true);*/ ThreadManage.GetInstance().StartLong(new Action(() => { if (HKDevice.IsConnected) { - GetStatus(); + //GetStatus(); ManualOpen(); ManualClose(); } @@ -172,15 +203,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model for (int i = 0; i < 7; i++) { GVL_SmallStation.GetInstance.Cylinder_JackInfo[i + 8] = HKDevice.HK_PLC_S7.Read("DB5.DBX0." + i); - } + }/* ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("M10.0", true); }), "ManualEStop", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("M10.0", false); - }), "ManualEReset", true); + }), "ManualEReset", true);*/ } private void ManualOpen() { @@ -580,9 +612,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model break; } } - /// - /// 将配方添加到配方队列中 - /// + private void HeartHKPlc() + { + if (HKDevice.IsConnected) + { + 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("DB3.DBX0.0"); + + } + } + /// + /// 将配方添加到配方队列中 + /// private void ReceviceData() { RemoteRecipes = Json.Data.Recipes; @@ -674,7 +716,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model GVL_SmallStation.GetInstance.RecipeStatusID = 2; MessageLog.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成"); } - if (GVL_SmallStation.GetInstance.RecipeStatusID == 2) + if (GVL_SmallStation.GetInstance.RecipeStatusID == 2) { if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.0"))) { @@ -760,16 +802,23 @@ namespace BPASmartClient.JXJFoodSmallStation.Model MessageLog.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成"); int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback; - string info = DeviceInquire.GetInstance.GetDevice(i).StatusReset(); - MessageLog.GetInstance.ShowRunLog(info); + bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset(); + if (info) + { + MessageLog.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送成功"); + } + else + { + MessageLog.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送失败"); + } if (i >= 1 && i <= 8) { - string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true); + string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4); MessageLog.GetInstance.ShowRunLog(commInfo); } else if (i >= 9 && i <= 15) { - string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true); + string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4); MessageLog.GetInstance.ShowRunLog(commInfo1); } GVL_SmallStation.GetInstance.DosingTray1 = false; @@ -884,7 +933,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model if (res > 0 && res is float loc) { int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeightW; + double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; if (loc_index >= 0) { DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量 @@ -923,16 +972,23 @@ namespace BPASmartClient.JXJFoodSmallStation.Model MessageLog.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{recipeName},{i}号仓,配料完成"); int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback; - string info = DeviceInquire.GetInstance.GetDevice(i).StatusReset(); - MessageLog.GetInstance.ShowRunLog(info); + bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset(); + if (info) + { + MessageLog.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送成功"); + } + else + { + MessageLog.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送失败"); + } if (i >= 1 && i <= 8) { - string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true); + string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4); MessageLog.GetInstance.ShowRunLog(commInfo); } else if (i >= 9 && i <= 15) { - string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true); + string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4); MessageLog.GetInstance.ShowRunLog(commInfo1); } GVL_SmallStation.GetInstance.DosingTray2 = false; diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs index 10f0f3c8..ad4988b0 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs @@ -45,7 +45,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model TopDeviceCurrentStatuses.ElementAt(TopIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum; TopDeviceCurrentStatuses.ElementAt(TopIndex).RunStatus = DeviceLists.ElementAt(i).Value.deviceStatus.RunStatus; } - if (BottomIndex >= 0 && BottomIndex < BottomDeviceCurrentStatuses.Count) { BottomDeviceCurrentStatuses.ElementAt(BottomIndex).Weight = DeviceLists.ElementAt(i).Value.deviceStatus.WeightFeedback; @@ -296,6 +295,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public void Init(string DeviceName) { + modbusTcp.Show += new Action((s) => + { + if (s != null) MessageLog.GetInstance.ShowRunLog(s); + }); + + modbusTcp.ShowEx += new Action((s) => + { + if (s != null) MessageLog.GetInstance.ShowRunLog(s); + }); this.DeviceName = DeviceName; AlarmHelper.Init(); if (modbusTcp.Connected) @@ -309,11 +317,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model // if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0]; //} deviceStatus.RunStatus = (ushort)this.modbusTcp.ReadShort(DeviceAddress.RunStatus); //获取设备运行状态 - deviceStatus.WeightFeedback = (float)this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);//获取设备料仓剩余重量 + deviceStatus.WeightFeedback = (Int16)this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);//获取设备料仓剩余重量 deviceStatus.NowWeightFeedback = (float)this.modbusTcp.GetUint(DeviceAddress.CutWeightFeedback);//获取下料重量 deviceStatus.DeviceNum = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceNum);//获取设备编号 deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceAlarmCode);//获取设备故障编码 - AlarmHelper.Alarm.EStop1 = deviceStatus.DeviceAlarmCode.Get16bitValue(1); AlarmHelper.Alarm.Servo = deviceStatus.DeviceAlarmCode.Get16bitValue(2); AlarmHelper.Alarm.Inverter = deviceStatus.DeviceAlarmCode.Get16bitValue(3); @@ -332,7 +339,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model this.modbusTcp.SetString(DeviceAddress.DeviceName, name); } - public string StatusReset() + public bool StatusReset() { return this.modbusTcp.Write(DeviceAddress.FinfishStatus, (ushort)1); //var res = modbusTcp.Read(DeviceAddress.RunStatus); @@ -348,14 +355,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model if (modbusTcp.Connected) { modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量 - string returnValue = modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 - if (returnValue.Substring(0, 2) == "成功") + bool returnValue = modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 + if (returnValue) { - MessageLog.GetInstance.ShowRunLog("发送成功" + returnValue); + MessageLog.GetInstance.ShowRunLog($"发送成功" + DeviceAddress.Start); } else { - MessageLog.GetInstance.ShowRunLog("发送失败" + returnValue); + MessageLog.GetInstance.ShowRunLog($"发送失败" + DeviceAddress.Start); } //配料设备参数写入 var res = Json.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName); @@ -369,7 +376,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight); modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo); modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed * 100); - MessageLog.GetInstance.ShowRunLog($"参数下发完成"); + MessageLog.GetInstance.ShowRunLog($"{res.MaterialName},参数下发完成"); } } } diff --git a/BPASmartClient.JXJFoodSmallStation/View/HardwareStatusView.xaml b/BPASmartClient.JXJFoodSmallStation/View/HardwareStatusView.xaml index efff9b75..a23db287 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/HardwareStatusView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/HardwareStatusView.xaml @@ -107,7 +107,6 @@ Text="{Binding RunStatus}" /> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.JXJFoodSmallStation/View/ManualCommView.xaml.cs b/BPASmartClient.JXJFoodSmallStation/View/ManualCommView.xaml.cs new file mode 100644 index 00000000..9f015671 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/View/ManualCommView.xaml.cs @@ -0,0 +1,29 @@ +using BPASmartClient.Helper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BPASmartClient.JXJFoodSmallStation.View +{ + /// + /// DeviceMaterialParView.xaml 的交互逻辑 + /// + public partial class ManualCommView : UserControl + { + public ManualCommView() + { + InitializeComponent(); + } + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/View/ManualControlView.xaml b/BPASmartClient.JXJFoodSmallStation/View/ManualControlView.xaml index 4f9bd4db..ec40089b 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/ManualControlView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/ManualControlView.xaml @@ -101,19 +101,37 @@ + + + + (devices.OrderBy(item => item.Serial)); } public RelayCommand ChangeNameCommand { get; set; } @@ -38,6 +43,9 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public class Devices : ObservableObject { + public int Serial { get { return _mSerial; } set { _mSerial = value; OnPropertyChanged(); } } + private int _mSerial; + public string IpAddress { get { return _mIpAddress; } set { _mIpAddress = value; OnPropertyChanged(); } } private string _mIpAddress; diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/HardwareStatusViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/HardwareStatusViewModel.cs index 578e3c79..11b897d5 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/HardwareStatusViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/HardwareStatusViewModel.cs @@ -18,7 +18,12 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public HardwareStatusViewModel() { TopDeviceCurrentStatuses = DeviceInquire.GetInstance.TopDeviceCurrentStatuses; + BottomDeviceCurrentStatuses = DeviceInquire.GetInstance.BottomDeviceCurrentStatuses; + + TopDeviceCurrentStatuses = new ObservableCollection(TopDeviceCurrentStatuses.OrderByDescending(item => item.DeviceNum)); + + BottomDeviceCurrentStatuses = new ObservableCollection(BottomDeviceCurrentStatuses.OrderBy(item => item.DeviceNum)); } public ObservableCollection TopDeviceCurrentStatuses { get; set; } diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualCommViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualCommViewModel.cs new file mode 100644 index 00000000..bcb26efc --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualCommViewModel.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System.Collections.ObjectModel; +using BPASmartClient.JXJFoodSmallStation.Model; +using BPASmartClient.Helper; +using Microsoft.Toolkit.Mvvm.Input; +using BPASmartClient.CustomResource.UserControls.MessageShow; +using BPASmartClient.CustomResource.UserControls; +using System.Diagnostics; +using BPASmartClient.JXJFoodSmallStation.Model.Siemens; +using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC; + +namespace BPASmartClient.JXJFoodSmallStation.ViewModel +{ + public class ManualCommViewModel : ObservableObject + { + public ManualCommViewModel() + { + for (int i = 0; i < 8; i++) + { + if (i < 4) + { + PlcInfo.Add(new PlcManualComm() + { + SerialNum = PlcInfo.Count + 1, + Address = "DB3.DBD" + (10 + 4 * i), + Describe = $"托盘1_{i + 1}#桶位置反馈", + }); + } + else + { + PlcInfo.Add(new PlcManualComm() + { + SerialNum = PlcInfo.Count + 1, + Address = "DB3.DBD" + (10 + 4 * i), + Describe = $"托盘2_{i-3}#桶位置反馈", + }); + } + + } + } + public ObservableCollection PlcInfo { get; set; } = new ObservableCollection(); + + public RelayCommand SetParCommand { get; set; } + + public RelayCommand Connect { get; set; } + + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs index f6373ae0..8a412611 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs @@ -78,13 +78,30 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { ActionManage.GetInstance.Send("ManualClose", o); }); - EStopCommand = new RelayCommand(() => + SystemStartCommand = new RelayCommand(() => { - ActionManage.GetInstance.Send("ManualEStop"); + ActionManage.GetInstance.Send("SystemStart"); }); - EResetCommand = new RelayCommand(() => + SystemStopCommand = new RelayCommand(() => { - ActionManage.GetInstance.Send("ManualEReset"); + ActionManage.GetInstance.Send("SystemStop"); + }); + SystemPauseCommand = new RelayCommand(() => + { + ActionManage.GetInstance.Send("SystemPause"); + }); + SystemResetCommand = new RelayCommand(() => + { + ActionManage.GetInstance.Send("SystemReset"); + }); + + DebugMode = new RelayCommand(() => + { + ActionManage.GetInstance.Send("SystemDebugMode"); + }); + AutoMode = new RelayCommand(() => + { + ActionManage.GetInstance.Send("SystemAutoMode"); }); } @@ -108,8 +125,14 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public RelayCommand Close { get; set; } - public RelayCommand EStopCommand { get; set; } - public RelayCommand EResetCommand { get; set; } + public RelayCommand SystemStartCommand { get; set; } + public RelayCommand SystemStopCommand { get; set; } + public RelayCommand SystemPauseCommand { get; set; } + + public RelayCommand SystemResetCommand { get; set; } + + public RelayCommand AutoMode { get; set; } + public RelayCommand DebugMode { get; set; } } diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs index def92ffc..e9ec4d45 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs @@ -37,7 +37,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { var res = RawMaterial.FirstOrDefault(p => p.RawMaterialLocation == (int)o); if (res != null) RawMaterial.Remove(res); - NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"{o.ToString()}:原料删除成功!"); + //NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"{o.ToString()}:原料删除成功!"); }); AddCommand = new RelayCommand(() => diff --git a/BPASmartClient.Modbus/ModbusTcp.cs b/BPASmartClient.Modbus/ModbusTcp.cs index 8734228e..35322660 100644 --- a/BPASmartClient.Modbus/ModbusTcp.cs +++ b/BPASmartClient.Modbus/ModbusTcp.cs @@ -567,7 +567,7 @@ namespace BPASmartClient.Modbus } catch (Exception ex) { - MessageLog.GetInstance.Show(ex.ToString()); + //MessageLog.GetInstance.Show(ex.ToString()); tcpClient = null; Connect(); } diff --git a/BPASmartClient.S7Net/SiemensHelper.cs b/BPASmartClient.S7Net/SiemensHelper.cs index 7ec56301..ae03de2b 100644 --- a/BPASmartClient.S7Net/SiemensHelper.cs +++ b/BPASmartClient.S7Net/SiemensHelper.cs @@ -58,12 +58,30 @@ namespace BPASmartClient.S7Net return myPlc?.Read(dataType, db, address, varType, count); } - public string Write(string address, TValue value) + public string Write(string address, TValue value,int Retries = 1) { if (IsConnected) { - myPlc?.Write(address, value); - return $"成功,地址:{address},值:{value}"; + int count = 0; + if (Retries == 1 || Retries == 0) + { + myPlc?.Write(address, value); + return $"成功,地址:{address},值:{value}"; + } + else + { + while (count < Retries) + { + count++; + myPlc?.Write(address, value); + var res = myPlc?.Read(address); + if (res != null && res.ToString() == value.ToString()) + { + break; + } + } + return $"成功,发送了{count}次,地址:{address},值:{value}"; + } } else {