diff --git a/BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs b/BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs index 65788bcb..3476f95f 100644 --- a/BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs +++ b/BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs @@ -64,8 +64,8 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel } }); - AlarmInfos = MessageLog.GetInstance.alarmLogs; - + //AlarmInfos = MessageLog.GetInstance.alarmLogs; + AlarmInfos = AlarmHelper.Alarms; } private void GetHistoryAlarm() diff --git a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs index 92abc22f..f7904b09 100644 --- a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs @@ -56,21 +56,21 @@ namespace BPASmartClient.JXJFoodSmallStation #region 配方管理菜单 ObservableCollection RecipeManage = new ObservableCollection(); - /*RecipeManage.Add(new SubMenumodel() + RecipeManage.Add(new SubMenumodel() { SubMenuName = "本地配方管理", SubMenuPermission = new Permission[] { Permission.管理员 }, AssemblyName = "BPASmartClient.JXJFoodSmallStation", ToggleWindowPath = "View.RecipeSettingsView" - });*/ + }); - /*RecipeManage.Add(new SubMenumodel() + RecipeManage.Add(new SubMenumodel() { SubMenuName = "本地配方下发", SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 }, AssemblyName = "BPASmartClient.JXJFoodSmallStation", ToggleWindowPath = "View.RecipeControlView" - });*/ + }); RecipeManage.Add(new SubMenumodel() { SubMenuName = "服务配方管理", @@ -87,6 +87,24 @@ namespace BPASmartClient.JXJFoodSmallStation }); #endregion + #region 参数设置 + ObservableCollection ParSet = new ObservableCollection(); + ParSet.Add(new SubMenumodel() + { + SubMenuName = "原料参数设置", + SubMenuPermission = new Permission[] { Permission.管理员 }, + AssemblyName = "BPASmartClient.JXJFoodSmallStation", + ToggleWindowPath = "View.DeviceMaterialParView" + }); + MenuManage.GetInstance.menuModels.Add(new MenuModel() + { + MainMenuIcon = "", + MainMenuName = "参数设置", + Alias = "Parameter Set", + subMenumodels = ParSet, + }); + #endregion + #region 消息日志 ObservableCollection InfoLog = new ObservableCollection(); InfoLog.Add(new SubMenumodel() @@ -174,14 +192,21 @@ namespace BPASmartClient.JXJFoodSmallStation AssemblyName = "BPASmartClient.CustomResource", ToggleWindowPath = "Pages.View.PasswordChangeView" }); - - /* UserManager.Add(new SubMenumodel() + UserManager.Add(new SubMenumodel() { - SubMenuName = "NFC登录设置", + SubMenuName = "用户管理", SubMenuPermission = new Permission[] { Permission.管理员 }, AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.NfcSetView" - });*/ + ToggleWindowPath = "Pages.View.UserManagerView" + }); + + /* UserManager.Add(new SubMenumodel() + { + SubMenuName = "NFC登录设置", + SubMenuPermission = new Permission[] { Permission.管理员 }, + AssemblyName = "BPASmartClient.CustomResource", + ToggleWindowPath = "Pages.View.NfcSetView" + });*/ MenuManage.GetInstance.menuModels.Add(new MenuModel() { diff --git a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj index b6e0a466..f033f6a2 100644 --- a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj +++ b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj @@ -19,4 +19,31 @@ + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Converter/DataTableRedundantConverter.cs b/BPASmartClient.JXJFoodSmallStation/Model/Converter/DataTableRedundantConverter.cs new file mode 100644 index 00000000..d3aeae3f --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Converter/DataTableRedundantConverter.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; + +namespace BPASmartClient.JXJFoodSmallStation.Converter +{ + public class DataTableRedundantConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && value is bool bit) + { + if (bit) + return new SolidColorBrush(Color.FromArgb(255, 245, 63, 98)); + else + return new SolidColorBrush(Color.FromArgb(255, 42, 178, 231)); + } + return default; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Converter/RunStatusConvert.cs b/BPASmartClient.JXJFoodSmallStation/Model/Converter/RunStatusConvert.cs new file mode 100644 index 00000000..56a2a661 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Converter/RunStatusConvert.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace BPASmartClient.JXJFoodSmallStation.Converter +{ + public class RunStatusConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is ushort tempValue) + { + if (tempValue == 1) return "等待配料"; + if (tempValue == 2) return "配料中"; + if (tempValue == 3) return "配料完成"; + } + return "等待配料"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + public class EnbleConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is ushort tempValue) + { + if (tempValue == 0) return true; + if (tempValue == 1) return false; + + } + return true; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + public class IntToSourceConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is ushort tempValue) + { + if (tempValue == 0) return "本地原料"; + if (tempValue == 1) return "设备原料"; + + } + return "未知"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs b/BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs index 9a7fce73..afff4ad6 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs @@ -12,6 +12,8 @@ using System.Threading; using System.Threading.Tasks; using BPASmartClient.CustomResource.UserControls.MessageShow; using BPASmartClient.CustomResource.Pages.Model; +using System.Collections.ObjectModel; +using BPASmartClient.Model; namespace BPASmartClient.JXJFoodSmallStation.Model { @@ -27,10 +29,46 @@ namespace BPASmartClient.JXJFoodSmallStation.Model List InvalidIP = new List();//无效 IP 集合 List IPLists = new List();//启动 Ping 任务IP集合 ConcurrentQueue IPQueues = new ConcurrentQueue();//pincomplete 完成队列 - ConcurrentDictionary DeviceLocation = new ConcurrentDictionary(); + + public ObservableCollection TopDeviceCurrentStatuses { get; set; } = new ObservableCollection(); + public ObservableCollection BottomDeviceCurrentStatuses { get; set; } = new ObservableCollection(); + public ObservableCollection devices { get; set; } = new ObservableCollection(); + private void DeviceDataInit() + { + ThreadManage.GetInstance().StartLong(new Action(() => + { + for (int i = 0; i < DeviceLists.Count; i++) + { + string deviceName = DeviceLists.ElementAt(i).Value.DeviceName; + int TopIndex = Array.FindIndex(TopDeviceCurrentStatuses.ToArray(), p => p.DeviceName == deviceName); + int BottomIndex = Array.FindIndex(BottomDeviceCurrentStatuses.ToArray(), p => p.DeviceName == deviceName); + if (TopIndex >= 0 && TopIndex < TopDeviceCurrentStatuses.Count) + { + TopDeviceCurrentStatuses.ElementAt(TopIndex).Weight = DeviceLists.ElementAt(i).Value.deviceStatus.WeightFeedback; + TopDeviceCurrentStatuses.ElementAt(TopIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum; + } + + if (BottomIndex >= 0 && BottomIndex < BottomDeviceCurrentStatuses.Count) + { + BottomDeviceCurrentStatuses.ElementAt(BottomIndex).Weight = DeviceLists.ElementAt(i).Value.deviceStatus.WeightFeedback; + BottomDeviceCurrentStatuses.ElementAt(BottomIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum; + } + + int deviceIndex = Array.FindIndex(devices.ToArray(), p => p.IpAddress == DeviceLists.ElementAt(i).Key); + if (deviceIndex >= 0 && deviceIndex < devices.Count) + { + devices.ElementAt(i).DeviceName = DeviceLists.ElementAt(i).Value.DeviceName; + } + } + Thread.Sleep(200); + }), "设备状态监听"); + } + public void Init() { + devices.Add(new Devices() { DeviceName = "测试", IpAddress = "192.168.0.1" }); IpAddressLines(); + DeviceDataInit(); ThreadManage.GetInstance().StartLong(new Action(() => { if (IPQueues.Count >= IPLists.Count) @@ -54,14 +92,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model return new DeviceStatus(); } - public DeviceStatus GetDeviceObject(int location) + public List GetDevice() { - if (location >= 1 && location <= 15) + List deviceStatuses = new List(); + foreach (var device in DeviceLists) { - var res = DeviceLists.Values.FirstOrDefault(p => p.RawMaterialLocation == location); - if (res != null) return res; + deviceStatuses.Add(device.Value); } - return new DeviceStatus(); + return deviceStatuses; } private void IpAddressLines() @@ -96,20 +134,27 @@ namespace BPASmartClient.JXJFoodSmallStation.Model DS.modbusTcp.ConnectOk = new Action(() => { - string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20);//读取设备名称 - int rawMaterialLocation = DS.modbusTcp.GetAddress(DeviceAddress.Location); + string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20).Trim()?.Replace(" ", "");//读取设备名称 if (DeviceName.Length > 0) { DeviceLists.TryAdd(ip, DS); - DeviceLists[ip].Init(DeviceName, rawMaterialLocation); + DeviceLists[ip].Init(DeviceName); DeviceLists[ip].modbusTcp.IsReconnect = false; App.Current.Dispatcher.Invoke(new Action(() => { - DeviceListViewModel.devices.Add(new Devices() - { - DeviceName = DeviceName, - IpAddress = ip - });//加入连接的(有名称的)设备列表 + //DeviceListViewModel.devices.Add(new Devices() + //{ + // DeviceName = DeviceName, + // IpAddress = ip + //});//加入连接的(有名称的)设备列表 + + devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip }); + + if (TopDeviceCurrentStatuses.Count <= 8) + TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); + else + BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); + for (int i = 0; i < Json.Data.Recipes.Count; i++) { @@ -118,12 +163,21 @@ namespace BPASmartClient.JXJFoodSmallStation.Model if (Json.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp == ip) { Json.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName; - Json.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMateriaLocation = rawMaterialLocation; } } } - if (!NewRecipeViewModel.RawMaterialNames.Contains(DeviceName)) - NewRecipeViewModel.RawMaterialNames.Add(DeviceName); + if (Global.DeviceRawMaterials.Count > 0) + { + if (Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == DeviceName) == null) + { + Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip, RawMaterialSource = 1 }); + } + } + else + { + Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip, RawMaterialSource = 1 }); + } + })); } else @@ -141,14 +195,25 @@ namespace BPASmartClient.JXJFoodSmallStation.Model DS.modbusTcp.Disconnect = new Action(() => { if (InvalidIP.Contains(ip)) InvalidIP.Remove(ip); - var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip); - if (res != null && DeviceListViewModel.devices.Contains(res)) + //var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip); + var res = devices.FirstOrDefault(P => P.IpAddress == ip); + //if (res != null && DeviceListViewModel.devices.Contains(res)) + if (res != null && devices.Contains(res)) + { App.Current.Dispatcher.Invoke(new Action(() => { - DeviceListViewModel.devices.Remove(res); - if (NewRecipeViewModel.RawMaterialNames.Contains(res.DeviceName)) - NewRecipeViewModel.RawMaterialNames.Remove(res.DeviceName); + //DeviceListViewModel.devices.Remove(res); + devices.Remove(res); + var item = Global.DeviceRawMaterials.FirstOrDefault(P => P.RawMaterialName == res.DeviceName); + if (item != null) Global.DeviceRawMaterials.Remove(item); + + var topRes = TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == res.DeviceName); + var bottomRes = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == res.DeviceName); + if (topRes != null) TopDeviceCurrentStatuses.Remove(topRes); + if (bottomRes != null) BottomDeviceCurrentStatuses.Remove(bottomRes); })); + } + if (DeviceLists.ContainsKey(ip)) DeviceLists[ip].Dispose(); }); @@ -166,35 +231,51 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public class DeviceStatus { + #region 对象属性声明 public string DeviceName = String.Empty; public string IpAddress => modbusTcp.IPAdress; - public bool IsConnected => modbusTcp.Connected; - public int RawMaterialLocation { get; set; } + /// /// 设备状态 /// public RawMaterialDeviceStatus deviceStatus { get; set; } = new RawMaterialDeviceStatus(); + + + public ModbusTcp modbusTcp = new ModbusTcp(); + + public bool IsConnected => modbusTcp.Connected; #endregion - public void Init(string DeviceName,int rawMaterialLocation) + + public void Init(string DeviceName) { this.DeviceName = DeviceName; - this.RawMaterialLocation = rawMaterialLocation; + AlarmHelper.Init(); if (modbusTcp.Connected) { ThreadManage.GetInstance().StartLong(new Action(() => { //获取设备运行状态 - var res = this.modbusTcp.Read(DeviceAddress.RunStatus); - if (res != null && res is ushort[] ushortValue) - { - if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0]; - } - //获取设备料仓剩余重量 - deviceStatus.WeightFeedback = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback); - deviceStatus.CutWeightFeedback = this.modbusTcp.GetUint(DeviceAddress.CutWeightFeedback); - deviceStatus.RawMaterialType =(ushort) this.modbusTcp.GetUint(DeviceAddress.RawMaterialType); + //var res = this.modbusTcp.Read(DeviceAddress.RunStatus); + //if (res != null && res is ushort[] ushortValue) + //{ + // if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0]; + //} + + + this.DeviceName = modbusTcp.GetString(DeviceAddress.DeviceName, 20).Trim()?.Replace(" ", ""); + deviceStatus.RunStatus = (ushort)this.modbusTcp.ReadShort(DeviceAddress.RunStatus); //获取设备运行状态 + deviceStatus.WeightFeedback = (float)this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);//获取设备料仓剩余重量 + 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); + AlarmHelper.Alarm.EStop2 = deviceStatus.DeviceAlarmCode.Get16bitValue(7); + AlarmHelper.Alarm.SiloUpperLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(8); + AlarmHelper.Alarm.SiloLowerLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(9); Thread.Sleep(100); }), $"{DeviceName} 开始监听", true); } @@ -205,28 +286,36 @@ namespace BPASmartClient.JXJFoodSmallStation.Model this.modbusTcp.Write(DeviceAddress.DeviceName, new ushort[20]); this.modbusTcp.SetString(DeviceAddress.DeviceName, name); } + public void StatusReset() { - this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0);//OutRawMaterialFinish复位出料完成信号 - } - public void OutRawMaterialReset() - { - this.modbusTcp.Write(DeviceAddress.OutRawMaterialFinish, (ushort)0); + this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0); } + public void Dispose() { ThreadManage.GetInstance().StopTask($"{DeviceName} 开始监听"); } - /// - /// 设置出料重量,触发出料信号 - /// - /// - public void Start(uint Value) + + public void Start(float Value) { if (modbusTcp.Connected) { - modbusTcp.SetUint(DeviceAddress.WeightSet, Value);//写入配方量 + modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量 modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 + //配料设备参数写入 + var res = Json.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName); + if (res != null) + { + modbusTcp.SetReal(DeviceAddress.SlowlyAddWeight, res.SlowlyAddWeight); + modbusTcp.SetReal(DeviceAddress.PreCloseValveWeight, res.PreCloseValveWeight); + modbusTcp.SetUint(DeviceAddress.RapidAcceleration, (uint)res.RapidAcceleration); + modbusTcp.SetUint(DeviceAddress.SlowAcceleration, (uint)res.SlowAcceleration); + modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed); + modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight); + modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo); + modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed); + } } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index 23ecc220..c27a8b9f 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -247,13 +247,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model double weight = SmallStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; if (loc_index >= 1 && loc_index <= 15) { - DeviceInquire.GetInstance.GetDeviceObject(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 + //DeviceInquire.GetInstance.GetDeviceObject(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 SmallStation.StockInIsWork = loc_index; HKDevice.StockStateSignReset(); } } } - if (RTrig.GetInstance("OutRawMaterialFinish").Start(DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).modbusTcp.Read(DeviceAddress.OutRawMaterialFinish) is bool)) + /*if (RTrig.GetInstance("OutRawMaterialFinish").Start(DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).modbusTcp.Read(DeviceAddress.OutRawMaterialFinish) is bool)) { HKDevice.SingleDosing((uint)SmallStation.StockInIsWork); DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).OutRawMaterialReset(); @@ -263,7 +263,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model HKDevice.RecipeDosingFinishReset(); SmallStation.RecipeQueue.TryDequeue(out code); Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - } + }*/ } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/AlarmInfo.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/AlarmInfo.cs new file mode 100644 index 00000000..04db6341 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/AlarmInfo.cs @@ -0,0 +1,48 @@ +using BPASmartClient.CustomResource.Pages.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model +{ + public class AlarmInfo + { + /// + /// 1#急停 + /// + [Alarm("1#急停")] + public bool EStop1 { get; set; } + + /// + /// 伺服故障 + /// + [Alarm("伺服故障")] + public bool Servo { get; set; } + + /// + /// 变频器故障 + /// + [Alarm("变频器故障")] + public bool Inverter { get; set; } + + /// + /// 2#急停 + /// + [Alarm("2#急停")] + public bool EStop2 { get; set; } + + /// + /// 料仓上限 + /// + [Alarm("料仓上限")] + public bool SiloUpperLimit { get; set; } + + /// + /// 料仓下限 + /// + [Alarm("料仓下限")] + public bool SiloLowerLimit { get; set; } + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs index 46afc716..85307518 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs @@ -8,95 +8,91 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { public class DeviceAddress { - #region 源地址 - ///// - ///// 设备名称起始地址 - ///// - //public static string DeviceName { get; set; } = "LW0"; - - ///// - ///// 料仓重量反馈起始地址 - ///// - //public static string WeightFeedback { get; set; } = "LW52";//LW204 + /// + /// 设备名称起始地址 + /// + public static string DeviceName { get; set; } = "LW0"; - ///// - ///// 重量设置地址 - ///// - //public static string WeightSet { get; set; } = "LW21";//LW200 + /// + /// 料仓重量反馈起始地址 + /// + public static string WeightFeedback { get; set; } = "LW52"; - ///// - ///// 启动信号地址 - ///// - //public static string Start { get; set; } = "LW20";//LW210 + /// + /// 重量设置地址 + /// + public static string WeightSet { get; set; } = "LW21"; - ///// - ///// 下料重量反馈地址 - ///// - //public static string CutWeightFeedback { get; set; } = "LW54";//LW202 + /// + /// 启动信号地址 + /// + public static string Start { get; set; } = "LW20"; - ///// - ///// 设备运行状态地址 - ///// - //public static string RunStatus { get; set; } = "LW55";//LW206 + /// + /// 下料重量反馈地址 + /// + public static string CutWeightFeedback { get; set; } = "LW54"; - ///// - ///// 料仓的位置 - ///// - //public static string Location { get; set; } = "LW53"; - #endregion + /// + /// 设备编号 + /// + public static string DeviceNum { get; set; } = "LW57"; - #region 上位机下发 /// - /// 原料出料重量 + /// 设备故障编码 /// - public static string WeightSet { get; set; } = "LW11"; + public static string DeviceAlarmCode { get; set; } = "LW51"; + /// - /// 启动开始配料 + /// 原料设备类型 + /// 1:膏体,2:液体,3:粉体 /// - public static string Start { get; set; } = "LW12"; - #endregion - #region 上位机读取 + public static string MaterialDeviceType { get; set; } = "LW56"; + /// /// 设备运行状态地址 /// - public static string RunStatus { get; set; } = "LW50"; + public static string RunStatus { get; set; } = "LW60"; + /// - /// 报警字 + /// 慢加重量 /// - public static string AlarmInfo { get; set; } = "LW51"; + public static string SlowlyAddWeight { get; set; } = "LW23"; + /// - /// 原料名称 + /// 提前关阀重量 /// - public static string DeviceName { get; set; } = "LW52"; + public static string PreCloseValveWeight { get; set; } = "LW25"; + /// - /// 料仓的位置 + /// 快加速度 /// - public static string Location { get; set; } = "LW53"; + public static string RapidAcceleration { get; set; } = "LW27"; + /// - /// 原料类型 + /// 慢加速度 /// - public static string RawMaterialType { get; set; } = "LW54"; + public static string SlowAcceleration { get; set; } = "LW29"; + /// - /// 出料完成信号 + /// 伺服手动速度 /// - public static string OutRawMaterialFinish { get; set; } = "LW55"; + public static string ServoManualSpeed { get; set; } = "LW31"; + /// - /// 料仓重量反馈起始地址 + /// 料仓上限重量 /// - public static string WeightFeedback { get; set; } = "LW56"; + public static string SiloUpperLimitWeight { get; set; } = "LW33"; + /// - /// 下料重量反馈地址 + /// 料仓下限重量 /// - public static string CutWeightFeedback { get; set; } = "LW57"; - #endregion - - - + public static string LowerLimitWeightOfSilo { get; set; } = "LW35"; - - - - + /// + /// 搅拌速度 + /// + public static string StirringSpeed { get; set; } = "LW37"; } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/DeviceCurrentStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs similarity index 78% rename from BPASmartClient.JXJFoodSmallStation/Model/DeviceCurrentStatus.cs rename to BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs index 299ada75..b122df2b 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/DeviceCurrentStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Toolkit.Mvvm.ComponentModel; -namespace BPASmartClient.JXJFoodSmallStation.Model +namespace BPASmartClient.JXJFoodSmallStation { public class DeviceCurrentStatus : ObservableObject { @@ -18,6 +18,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model private bool _mRunStatus; + public int DeviceNum { get { return _mDeviceNum; } set { _mDeviceNum = value; OnPropertyChanged(); } } + private int _mDeviceNum; + public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } private string _mDeviceName; diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs new file mode 100644 index 00000000..f402a8b1 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs @@ -0,0 +1,15 @@ +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; + +namespace BPASmartClient.JXJFoodSmallStation +{ + public class DevicePar + { + public ObservableCollection deviceParModels { get; set; } = new ObservableCollection(); + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs new file mode 100644 index 00000000..d768b403 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Toolkit.Mvvm.ComponentModel; + +namespace BPASmartClient.JXJFoodSmallStation +{ + public class DeviceParModel : ObservableObject + { + /// + /// 原料名称 + /// + public string MaterialName { get { return _mMaterialName; } set { _mMaterialName = value; OnPropertyChanged(); } } + private string _mMaterialName = string.Empty; + + /// + /// 慢加重量 + /// + public float SlowlyAddWeight { get { return _mSlowlyAddWeight; } set { _mSlowlyAddWeight = value; OnPropertyChanged(); } } + private float _mSlowlyAddWeight; + + /// + /// 提前关阀重量 + /// + public float PreCloseValveWeight { get { return _mPreCloseValveWeight; } set { _mPreCloseValveWeight = value; OnPropertyChanged(); } } + private float _mPreCloseValveWeight; + + /// + /// 快加速度 + /// + public int RapidAcceleration { get { return _mRapidAcceleration; } set { _mRapidAcceleration = value; OnPropertyChanged(); } } + private int _mRapidAcceleration; + + /// + /// 慢加速度 + /// + public int SlowAcceleration { get { return _mSlowAcceleration; } set { _mSlowAcceleration = value; OnPropertyChanged(); } } + private int _mSlowAcceleration; + + /// + /// 伺服手动速度 + /// + public int ServoManualSpeed { get { return _mServoManualSpeed; } set { _mServoManualSpeed = value; OnPropertyChanged(); } } + private int _mServoManualSpeed; + + /// + /// 料仓上限重量 + /// + public int SiloUpperLimitWeight { get { return _mSiloUpperLimitWeight; } set { _mSiloUpperLimitWeight = value; OnPropertyChanged(); } } + private int _mSiloUpperLimitWeight; + + /// + /// 料仓下限重量 + /// + public int LowerLimitWeightOfSilo { get { return _mLowerLimitWeightOfSilo; } set { _mLowerLimitWeightOfSilo = value; OnPropertyChanged(); } } + private int _mLowerLimitWeightOfSilo; + + /// + /// 搅拌速度 + /// + public int StirringSpeed { get { return _mStirringSpeed; } set { _mStirringSpeed = value; OnPropertyChanged(); } } + private int _mStirringSpeed; + + /// + /// 是否重复 + /// + [Newtonsoft.Json.JsonIgnore] + public bool IsRedundant { get { return _mIsRedundant; } set { _mIsRedundant = value; OnPropertyChanged(); } } + private bool _mIsRedundant; + + + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/GlobalData.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/GlobalData.cs new file mode 100644 index 00000000..4bb2454c --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/GlobalData.cs @@ -0,0 +1,15 @@ +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 c293856c..1c8ced08 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs @@ -5,11 +5,14 @@ using System.Text; using System.Threading.Tasks; using System.Collections.ObjectModel; using BPASmartClient.JXJFoodSmallStation.ViewModel; +using BPASmartClient.Model; namespace BPASmartClient.JXJFoodSmallStation.Model { public class LocaPar { public ObservableCollection Recipes { get; set; } = new ObservableCollection(); + + } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs index 6bc51f52..61b4febb 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs @@ -11,8 +11,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// /// 原料类型 - /// 1:液体 - /// 2:膏体 + /// 1:膏体 + /// 2:液体 /// 3:粉体 /// public ushort RawMaterialType { get; set; } @@ -39,7 +39,22 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// /// 设备运行状态 + /// 0:未知 + /// 1:等待配料 + /// 2:配料中 + /// 3:配料完成 /// public ushort RunStatus { get; set; } + + /// + /// 设备故障编码 + /// + public ushort DeviceAlarmCode { get; set; } + + /// + /// 设备料仓编号 + /// + public ushort DeviceNum { get; set; } + } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs index 8286807a..7fe70363 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; -using BPASmartClient.JXJFoodSmallStation.ViewModel; using BPASmartClient.Model; using Microsoft.Toolkit.Mvvm.ComponentModel; diff --git a/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml b/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml index 0d0f2cb0..2bb91f48 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml @@ -44,15 +44,7 @@ - - - - - - + - - - + CornerRadius="0"> + + + - + + + + + + +