From 8947af01d93a73638bef4bf95f6728e19b8a07eb Mon Sep 17 00:00:00 2001 From: ZhaoGang <15196688790@163.com> Date: Wed, 16 Aug 2023 10:41:52 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=A4=A7=E6=96=99=E7=AB=99=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=85=A8=E5=B1=80=E5=8F=98=E9=87=8F=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.JXJFoodBigStation/App.xaml.cs | 7 + .../Model/GVL_BigStation.cs | 40 ++++- .../View/GlobalVarMonitorView.xaml | 143 ++++++++++++++++++ .../View/GlobalVarMonitorView.xaml.cs | 28 ++++ .../ViewModel/GlobalVarMonitorViewModel.cs | 77 ++++++++++ 5 files changed, 292 insertions(+), 3 deletions(-) create mode 100644 BPASmartClient.JXJFoodBigStation/View/GlobalVarMonitorView.xaml create mode 100644 BPASmartClient.JXJFoodBigStation/View/GlobalVarMonitorView.xaml.cs create mode 100644 BPASmartClient.JXJFoodBigStation/ViewModel/GlobalVarMonitorViewModel.cs diff --git a/BPASmartClient.JXJFoodBigStation/App.xaml.cs b/BPASmartClient.JXJFoodBigStation/App.xaml.cs index d801614e..1fc554ab 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/Model/GVL_BigStation.cs b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs index ff7f543e..8a24218d 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs @@ -15,79 +15,101 @@ 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 }; + public static bool[] IsTrayArrive { get; set; } = new bool[5] { false, false, false, false, false }; public static DateTime[] RecipeDosingTime { get; set; } = new DateTime[4] { DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now }; /// /// 是否处于手动下发配方 /// + [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; } -} +} \ No newline at end of file diff --git a/BPASmartClient.JXJFoodBigStation/View/GlobalVarMonitorView.xaml b/BPASmartClient.JXJFoodBigStation/View/GlobalVarMonitorView.xaml new file mode 100644 index 00000000..61e633a1 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/View/GlobalVarMonitorView.xaml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/BPASmartClient.JXJFoodBigStation/View/GlobalVarMonitorView.xaml.cs b/BPASmartClient.JXJFoodBigStation/View/GlobalVarMonitorView.xaml.cs new file mode 100644 index 00000000..de490a71 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/View/GlobalVarMonitorView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BPASmartClient.JXJFoodBigStation.View +{ + /// + /// GlobalVarMonitorView.xaml 的交互逻辑 + /// + public partial class GlobalVarMonitorView : UserControl + { + public GlobalVarMonitorView() + { + InitializeComponent(); + } + } +} diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/GlobalVarMonitorViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/GlobalVarMonitorViewModel.cs new file mode 100644 index 00000000..8812e3f3 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/GlobalVarMonitorViewModel.cs @@ -0,0 +1,77 @@ +using BPA.Helper; +using BPASmartClient.JXJFoodBigStation.Model; +using BPASmartClient.JXJFoodBigStation.Model.HK_PLC; + + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.ViewModel +{ + public class GlobalVarMonitorViewModel : NotifyBase + { + + public static ObservableCollection PlcInfo { get; set; } = new ObservableCollection(); + + + public GlobalVarMonitorViewModel() + { + Type type = typeof(GVL_BigStation); + PropertyInfo[] properties = type.GetProperties(); + + if (PlcInfo.Count == 0) + { + foreach (PropertyInfo mi in properties) + { + PropertyInfo a = type.GetProperty(mi.Name); + object ab = a.GetValue(null); + + var num = GVL_BigStation.HKPlc_Read; + var res = a.GetCustomAttribute(); + string describe = ""; + if (res != null) + { + describe = res.Describe; + PlcInfo.Add(new PlcVarMonitor() + { + SerialNum = PlcInfo.Count + 1, + Variable = mi.Name, + Type = mi.PropertyType.Name, + Describe = describe, + NowValue = ab.ToString(), + }); + } + else + { + describe = ""; + } + } + } + + ThreadManage.GetInstance().StartLong(new Action(() => + { + foreach (PropertyInfo mi in properties) + { + PropertyInfo a = type.GetProperty(mi.Name); + object ab = a.GetValue(null); + int index = Array.FindIndex(PlcInfo.ToArray(), p => p.Variable == mi.Name); + if (index != -1) + { + PlcInfo.ElementAt(index).NowValue = ab.ToString(); + } + } + Thread.Sleep(100); + }), "Global变量读取", true); + + + } + } + +} \ No newline at end of file