diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
index 3a68670b..3098ed7c 100644
--- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
+++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
@@ -175,8 +175,12 @@
+
+
+
+
@@ -189,6 +193,7 @@
+
@@ -299,10 +304,15 @@
+
+
+
+
+
diff --git a/BPASmartClient.CustomResource/Image/系统名称.png b/BPASmartClient.CustomResource/Image/系统名称.png
new file mode 100644
index 00000000..240fb030
Binary files /dev/null and b/BPASmartClient.CustomResource/Image/系统名称.png differ
diff --git a/BPASmartClient.CustomResource/Image/红色圆角矩形背景.png b/BPASmartClient.CustomResource/Image/红色圆角矩形背景.png
new file mode 100644
index 00000000..77809434
Binary files /dev/null and b/BPASmartClient.CustomResource/Image/红色圆角矩形背景.png differ
diff --git a/BPASmartClient.CustomResource/Image/组合边框1.1.png b/BPASmartClient.CustomResource/Image/组合边框1.1.png
new file mode 100644
index 00000000..7ab35e56
Binary files /dev/null and b/BPASmartClient.CustomResource/Image/组合边框1.1.png differ
diff --git a/BPASmartClient.CustomResource/Image/组合边框1.png b/BPASmartClient.CustomResource/Image/组合边框1.png
new file mode 100644
index 00000000..d37574ff
Binary files /dev/null and b/BPASmartClient.CustomResource/Image/组合边框1.png differ
diff --git a/BPASmartClient.CustomResource/Image/蓝色背景.png b/BPASmartClient.CustomResource/Image/蓝色背景.png
new file mode 100644
index 00000000..855dadb9
Binary files /dev/null and b/BPASmartClient.CustomResource/Image/蓝色背景.png differ
diff --git a/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs b/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs
index c7080c4c..e45218ff 100644
--- a/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs
+++ b/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs
@@ -37,11 +37,11 @@ namespace BPASmartClient.CustomResource.Pages.Model
{
bool value = Convert.ToBoolean(Alarm.GetType().GetProperty(item.Name)?.GetValue(Alarm));
EdgeAlarm(value, AlarmModel.AlarmInfo, 1, AlarmModel.AlarmLevel, AlarmModel.AlarmType);
- }
+ }
}
}
Thread.Sleep(100);
- }), "报警通用模块监听");
+ }), $"{typeof(AlarmT)},报警通用模块监听");
}
@@ -57,7 +57,7 @@ namespace BPASmartClient.CustomResource.Pages.Model
if (!delays.ContainsKey(text)) delays.TryAdd(text, Delay.GetInstance(text));
if (edgeType == AlarmTriggerType.Rising ? delays[text].Start(Trigger, delay) : delays[text].Start(!Trigger, delay))
{
- if (edgeType == AlarmTriggerType.Rising ? !flagbit[text] :flagbit[text])
+ if (edgeType == AlarmTriggerType.Rising ? !flagbit[text] : flagbit[text])
{
AddAlarm(Trigger, text, alarmLevel);
flagbit[text] = edgeType == AlarmTriggerType.Rising ? true : false;
diff --git a/BPASmartClient.CustomResource/Pages/Model/UserInfo.cs b/BPASmartClient.CustomResource/Pages/Model/UserInfo.cs
index f3b0efb4..d7da48b9 100644
--- a/BPASmartClient.CustomResource/Pages/Model/UserInfo.cs
+++ b/BPASmartClient.CustomResource/Pages/Model/UserInfo.cs
@@ -27,7 +27,7 @@ namespace BPASmartClient.CustomResource.Pages.Model
public string Password { get { return _password; } set { _password = value; OnPropertyChanged(); } }
private string _password = "admin";
- public string CardId { get; set; } = String.Empty;
+ public string CardId { get; set; } = string.Empty;
public List locaRawMaterials { get; set; } = new List();
diff --git a/BPASmartClient.CustomResource/RecDictionarys/DatePickeerDictionary.xaml b/BPASmartClient.CustomResource/RecDictionarys/DatePickeerDictionary.xaml
index f79ffa21..8ee95e36 100644
--- a/BPASmartClient.CustomResource/RecDictionarys/DatePickeerDictionary.xaml
+++ b/BPASmartClient.CustomResource/RecDictionarys/DatePickeerDictionary.xaml
@@ -354,7 +354,7 @@
-
+
diff --git a/BPASmartClient.CustomResource/RecDictionarys/RecButtonStyle.xaml b/BPASmartClient.CustomResource/RecDictionarys/RecButtonStyle.xaml
index 66931049..72ae075d 100644
--- a/BPASmartClient.CustomResource/RecDictionarys/RecButtonStyle.xaml
+++ b/BPASmartClient.CustomResource/RecDictionarys/RecButtonStyle.xaml
@@ -29,4 +29,38 @@
+
+
\ No newline at end of file
diff --git a/BPASmartClient.CustomResource/RecDictionarys/TextBoxStyle.xaml b/BPASmartClient.CustomResource/RecDictionarys/TextBoxStyle.xaml
index 0ad862ac..189830b1 100644
--- a/BPASmartClient.CustomResource/RecDictionarys/TextBoxStyle.xaml
+++ b/BPASmartClient.CustomResource/RecDictionarys/TextBoxStyle.xaml
@@ -17,13 +17,11 @@
Opacity="0.7"
SnapsToDevicePixels="true">
-
-
+
diff --git a/BPASmartClient.CustomResource/UserControls/BatchingMachine.xaml b/BPASmartClient.CustomResource/UserControls/BatchingMachine.xaml
index 12af351a..6a7e1d65 100644
--- a/BPASmartClient.CustomResource/UserControls/BatchingMachine.xaml
+++ b/BPASmartClient.CustomResource/UserControls/BatchingMachine.xaml
@@ -41,35 +41,57 @@
Fill="{StaticResource fillColor}"
Stroke="{StaticResource BorderColor}" />
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
diff --git a/BPASmartClient.Helper/ExpandMethod.cs b/BPASmartClient.Helper/ExpandMethod.cs
index ab8ba30d..2e9201c5 100644
--- a/BPASmartClient.Helper/ExpandMethod.cs
+++ b/BPASmartClient.Helper/ExpandMethod.cs
@@ -149,7 +149,17 @@ namespace BPASmartClient.Helper
}
-
+ ///
+ /// 获取16位整数中指定位的值
+ ///
+ /// 要获取的整数
+ /// 偏移量 范围(1-16)
+ ///
+ public static bool Get16bitValue(this ushort data, byte offset)
+ {
+ if (offset > 16 || offset < 1) return false;
+ return (data & 1 << offset - 1) == 0 ? false : true;
+ }
diff --git a/BPASmartClient.Modbus/ModbusTcp.cs b/BPASmartClient.Modbus/ModbusTcp.cs
index eae3d234..b17e4d9f 100644
--- a/BPASmartClient.Modbus/ModbusTcp.cs
+++ b/BPASmartClient.Modbus/ModbusTcp.cs
@@ -145,31 +145,31 @@ namespace BPASmartClient.Modbus
return LwAddress;
}
}
- else if (address.ToUpper().Contains("D") && address.Length == 5)
+ else if (address.ToUpper().Contains("D") && address.Length == 5)
{
try
{
string head = (Convert.ToInt32(address.Substring(1, 1))).ToString();
int num = Convert.ToInt32(address.Substring(2, 3));
int len = num.ToString().Length;
- string tail=string.Empty;
+ string tail = string.Empty;
switch (len)
- {
-
- case 1:
+ {
+
+ case 1:
if ((Convert.ToInt32(address.Substring(4, 1))).ToString().Length > 1)
{
tail = "0" + (Convert.ToInt32(address.Substring(4, 1))).ToString();
}
- else
+ else
{
tail = "00" + (Convert.ToInt32(address.Substring(4, 1))).ToString();
}
break;
case 2:
- if ((Convert.ToInt32(address.Substring(3, 2))).ToString().Length >2)
+ if ((Convert.ToInt32(address.Substring(3, 2))).ToString().Length > 2)
{
- tail =(Convert.ToInt32(address.Substring(3, 2))).ToString();
+ tail = (Convert.ToInt32(address.Substring(3, 2))).ToString();
}
else
{
@@ -180,21 +180,21 @@ namespace BPASmartClient.Modbus
tail = (Convert.ToInt32(address.Substring(2, 3))).ToString();
break;
}
-
+
address = head + tail;
return Convert.ToInt32(address);
}
catch (Exception)
{
//打印日志
-
+
}
-
+
}
}
return -1;
}
-
+
private void ExceptionHandling(Exception ex)
{
if (ex.InnerException is SocketException)
@@ -208,7 +208,15 @@ namespace BPASmartClient.Modbus
}
}
- //public object ReadHC(stri)
+ public short ReadShort(string address)
+ {
+ var res = Read(address);
+ if (res != null && res is short[] shorts && shorts.Length == 1)
+ {
+ return shorts[0];
+ }
+ return 0;
+ }
public object Read(string address, ushort len = 1, byte slaveAddress = 1)
{
@@ -222,7 +230,7 @@ namespace BPASmartClient.Modbus
commandType = CommandType.Coils;
return master.ReadCoils(slaveAddress, startAddress, len);
}
- else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW")|| address.ToUpper().Contains("D"))
+ else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW") || address.ToUpper().Contains("D"))
{
commandType = CommandType.HoldingRegisters;
return master.ReadHoldingRegisters(slaveAddress, startAddress, len);
@@ -232,7 +240,7 @@ namespace BPASmartClient.Modbus
commandType = CommandType.Inputs;
return master.ReadInputs(slaveAddress, startAddress, len);
}
-
+
}
catch (Exception ex)
{
@@ -241,6 +249,7 @@ namespace BPASmartClient.Modbus
}
return default(object);
}
+
#region 180项目调用
public int GetAddress(string address, string target)
{
@@ -251,15 +260,15 @@ namespace BPASmartClient.Modbus
{
try
{
- string head = "4"+(Convert.ToInt32(address.Substring(1, 1)) - 1).ToString();
+ string head = "4" + (Convert.ToInt32(address.Substring(1, 1)) - 1).ToString();
string tail = address.Substring(2, 3);
- address = head + tail;
+ address = head + tail;
return Convert.ToInt32(address);
}
catch (Exception)
{
//打印日志
-
+
}
}
@@ -291,11 +300,11 @@ namespace BPASmartClient.Modbus
public void Write(string address, T value, string target, byte slaveAddress = 1)
{
if (address == null || tcpClient == null) return;
- ushort startAddress = (ushort)GetAddress(address,target);
+ ushort startAddress = (ushort)GetAddress(address, target);
CommandType commandType = CommandType.Coils;
try
{
-
+
if (address.ToUpper().Contains("D"))
{
commandType = CommandType.HoldingRegisters;
@@ -303,17 +312,19 @@ namespace BPASmartClient.Modbus
{
master.WriteSingleRegister(slaveAddress, startAddress, ushortValue);
}
-
+
}
-
+
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx($"写入地址:【{address}:= {startAddress}】,写入类型:【{commandType.ToString()}】出错,{ex.ToString()}");
ExceptionHandling(ex);
}
- }
+ }
#endregion
+
+
public void Write(string address, T value, byte slaveAddress = 1)
{
if (address == null || tcpClient == null) return;
@@ -329,7 +340,7 @@ namespace BPASmartClient.Modbus
else if (value is bool[] boolsValue)
master.WriteMultipleCoils(slaveAddress, startAddress, boolsValue);
}
- else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW")|| address.ToUpper().Contains("D"))
+ else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW") || address.ToUpper().Contains("D"))
{
commandType = CommandType.HoldingRegisters;
if (value is ushort ushortValue)
diff --git a/DosingSystem/App.xaml.cs b/DosingSystem/App.xaml.cs
index 2ec8c014..b1a583e4 100644
--- a/DosingSystem/App.xaml.cs
+++ b/DosingSystem/App.xaml.cs
@@ -30,8 +30,6 @@ namespace BPASmartClient.DosingSystem
MenuInit();
DataInit();
DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化
- //NewMaterialDeviceParView newMaterialDeviceParView = new NewMaterialDeviceParView();
- //newMaterialDeviceParView.ShowDialog();
MainView mv = new MainView();
//mv.Show();
LoginView lv = new LoginView();
@@ -50,6 +48,7 @@ namespace BPASmartClient.DosingSystem
{
base.OnExit(e);
Json.Save();
+ Json.Save();
MessageLog.GetInstance.LogSave();
ThreadManage.GetInstance().Dispose();
}
@@ -85,6 +84,25 @@ namespace BPASmartClient.DosingSystem
});
#endregion
+ #region 参数设置
+ ObservableCollection ParSet = new ObservableCollection();
+ ParSet.Add(new SubMenumodel()
+ {
+ SubMenuName = "原料参数设置",
+ SubMenuPermission = new Permission[] { Permission.管理员 },
+ AssemblyName = "BPASmartClient.DosingSystem",
+ 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()
@@ -202,6 +220,7 @@ namespace BPASmartClient.DosingSystem
{
Config.GetInstance.Init();
Json.Read();
+ Json.Read();
Json.Read();
}
diff --git a/DosingSystem/Converter/DataTableRedundantConverter.cs b/DosingSystem/Converter/DataTableRedundantConverter.cs
new file mode 100644
index 00000000..fd16d65b
--- /dev/null
+++ b/DosingSystem/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.DosingSystem.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/DosingSystem/Model/AlarmInfo.cs b/DosingSystem/Model/AlarmInfo.cs
new file mode 100644
index 00000000..00dd0772
--- /dev/null
+++ b/DosingSystem/Model/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.DosingSystem.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/DosingSystem/Model/DeviceAddress.cs b/DosingSystem/Model/DeviceAddress.cs
index 7752c667..66228f92 100644
--- a/DosingSystem/Model/DeviceAddress.cs
+++ b/DosingSystem/Model/DeviceAddress.cs
@@ -38,6 +38,17 @@ namespace BPASmartClient.DosingSystem.Model
///
public static string DeviceNum { get; set; } = "LW57";
+ ///
+ /// 设备故障编码
+ ///
+ public static string DeviceAlarmCode { get; set; } = "LW51";
+
+ ///
+ /// 原料设备类型
+ /// 1:膏体,2:液体,3:粉体
+ ///
+ public static string MaterialDeviceType { get; set; } = "LW56";
+
///
/// 设备运行状态地址
///
diff --git a/DosingSystem/Model/DeviceCurrentStatus.cs b/DosingSystem/Model/DeviceCurrentStatus.cs
index b40dc61e..6a727d95 100644
--- a/DosingSystem/Model/DeviceCurrentStatus.cs
+++ b/DosingSystem/Model/DeviceCurrentStatus.cs
@@ -18,6 +18,9 @@ namespace BPASmartClient.DosingSystem.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/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs
index a1258241..39ffe443 100644
--- a/DosingSystem/Model/DeviceInquire.cs
+++ b/DosingSystem/Model/DeviceInquire.cs
@@ -13,6 +13,7 @@ using System.Threading.Tasks;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.Model;
+using System.Collections.ObjectModel;
namespace BPASmartClient.DosingSystem.Model
{
@@ -29,9 +30,45 @@ namespace BPASmartClient.DosingSystem.Model
List IPLists = new List();//启动 Ping 任务IP集合
ConcurrentQueue IPQueues = new ConcurrentQueue();//pincomplete 完成队列
+ 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)
@@ -55,6 +92,16 @@ namespace BPASmartClient.DosingSystem.Model
return new DeviceStatus();
}
+ public List GetDevice()
+ {
+ List deviceStatuses = new List();
+ foreach (var device in DeviceLists)
+ {
+ deviceStatuses.Add(device.Value);
+ }
+ return deviceStatuses;
+ }
+
private void IpAddressLines()
{
IPLists.Clear();
@@ -87,7 +134,7 @@ namespace BPASmartClient.DosingSystem.Model
DS.modbusTcp.ConnectOk = new Action(() =>
{
- string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20).Trim();//读取设备名称
+ string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20).Trim()?.Replace(" ", "");//读取设备名称
if (DeviceName.Length > 0)
{
DeviceLists.TryAdd(ip, DS);
@@ -95,11 +142,19 @@ namespace BPASmartClient.DosingSystem.Model
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++)
{
@@ -115,12 +170,12 @@ namespace BPASmartClient.DosingSystem.Model
{
if (Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == DeviceName) == null)
{
- Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip ,RawMaterialSource = 1});
+ Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip, RawMaterialSource = 1 });
}
}
else
{
- Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip , RawMaterialSource = 1 });
+ Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip, RawMaterialSource = 1 });
}
}));
@@ -140,15 +195,25 @@ namespace BPASmartClient.DosingSystem.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);
+ //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();
});
@@ -186,22 +251,31 @@ namespace BPASmartClient.DosingSystem.Model
public void Init(string DeviceName)
{
this.DeviceName = DeviceName;
+ 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];
- }
+ //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);
- var resddd = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);
- var rrr = this.modbusTcp.Read(DeviceAddress.WeightFeedback);
- var t = this.modbusTcp.GetReal(DeviceAddress.CutWeightFeedback);
+
+ 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);
@@ -230,6 +304,19 @@ namespace BPASmartClient.DosingSystem.Model
{
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/DosingSystem/Model/DeviceParModel.cs b/DosingSystem/Model/DeviceParModel.cs
index fe840fa6..f7400050 100644
--- a/DosingSystem/Model/DeviceParModel.cs
+++ b/DosingSystem/Model/DeviceParModel.cs
@@ -3,54 +3,73 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Microsoft.Toolkit.Mvvm.ComponentModel;
namespace BPASmartClient.DosingSystem.Model
{
- public class DeviceParModel
+ public class DeviceParModel : ObservableObject
{
///
/// 原料名称
///
- public string MaterialName { get; set; } = string.Empty;
+ public string MaterialName { get { return _mMaterialName; } set { _mMaterialName = value; OnPropertyChanged(); } }
+ private string _mMaterialName = string.Empty;
///
/// 慢加重量
///
- public float SlowlyAddWeight { get; set; }
+ public float SlowlyAddWeight { get { return _mSlowlyAddWeight; } set { _mSlowlyAddWeight = value; OnPropertyChanged(); } }
+ private float _mSlowlyAddWeight;
///
/// 提前关阀重量
///
- public float PreCloseValveWeight { get; set; }
+ public float PreCloseValveWeight { get { return _mPreCloseValveWeight; } set { _mPreCloseValveWeight = value; OnPropertyChanged(); } }
+ private float _mPreCloseValveWeight;
///
/// 快加速度
///
- public int RapidAcceleration { get; set; }
+ public int RapidAcceleration { get { return _mRapidAcceleration; } set { _mRapidAcceleration = value; OnPropertyChanged(); } }
+ private int _mRapidAcceleration;
///
/// 慢加速度
///
- public int SlowAcceleration { get; set; }
+ public int SlowAcceleration { get { return _mSlowAcceleration; } set { _mSlowAcceleration = value; OnPropertyChanged(); } }
+ private int _mSlowAcceleration;
///
/// 伺服手动速度
///
- public int ServoManualSpeed { get; set; }
+ public int ServoManualSpeed { get { return _mServoManualSpeed; } set { _mServoManualSpeed = value; OnPropertyChanged(); } }
+ private int _mServoManualSpeed;
///
/// 料仓上限重量
///
- public int SiloUpperLimitWeight { get; set; }
+ public int SiloUpperLimitWeight { get { return _mSiloUpperLimitWeight; } set { _mSiloUpperLimitWeight = value; OnPropertyChanged(); } }
+ private int _mSiloUpperLimitWeight;
///
/// 料仓下限重量
///
- public int LowerLimitWeightOfSilo { get; set; }
+ public int LowerLimitWeightOfSilo { get { return _mLowerLimitWeightOfSilo; } set { _mLowerLimitWeightOfSilo = value; OnPropertyChanged(); } }
+ private int _mLowerLimitWeightOfSilo;
///
/// 搅拌速度
///
- public int StirringSpeed { get; set; }
+ 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/DosingSystem/Model/RawMaterialDeviceStatus.cs b/DosingSystem/Model/RawMaterialDeviceStatus.cs
index 1febc8a9..777fe2a3 100644
--- a/DosingSystem/Model/RawMaterialDeviceStatus.cs
+++ b/DosingSystem/Model/RawMaterialDeviceStatus.cs
@@ -11,8 +11,8 @@ namespace BPASmartClient.DosingSystem.Model
///
/// 原料类型
- /// 1:液体
- /// 2:膏体
+ /// 1:膏体
+ /// 2:液体
/// 3:粉体
///
public ushort RawMaterialType { get; set; }
@@ -39,7 +39,22 @@ namespace BPASmartClient.DosingSystem.Model
///
/// 设备运行状态
+ /// 0:未知
+ /// 1:等待配料
+ /// 2:配料中
+ /// 3:配料完成
///
public ushort RunStatus { get; set; }
+
+ ///
+ /// 设备故障编码
+ ///
+ public ushort DeviceAlarmCode { get; set; }
+
+ ///
+ /// 设备料仓编号
+ ///
+ public ushort DeviceNum { get; set; }
+
}
}
diff --git a/DosingSystem/View/DeviceListView.xaml b/DosingSystem/View/DeviceListView.xaml
index 7021d8db..6b01ea58 100644
--- a/DosingSystem/View/DeviceListView.xaml
+++ b/DosingSystem/View/DeviceListView.xaml
@@ -71,19 +71,16 @@
Height="150"
VerticalAlignment="Top"
BorderBrush="#00BEFA"
- BorderThickness="2"
+ BorderThickness="0"
ClipToBounds="True"
- CornerRadius="8">
-
-
-
+ CornerRadius="0">
+
+
+
-
+
+
+
+
+
+
+
+
+
diff --git a/DosingSystem/View/DeviceMaterialParView.xaml b/DosingSystem/View/DeviceMaterialParView.xaml
new file mode 100644
index 00000000..40c70a77
--- /dev/null
+++ b/DosingSystem/View/DeviceMaterialParView.xaml
@@ -0,0 +1,369 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DosingSystem/View/DeviceMaterialParView.xaml.cs b/DosingSystem/View/DeviceMaterialParView.xaml.cs
new file mode 100644
index 00000000..b585e57c
--- /dev/null
+++ b/DosingSystem/View/DeviceMaterialParView.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.DosingSystem.View
+{
+ ///
+ /// DeviceMaterialParView.xaml 的交互逻辑
+ ///
+ public partial class DeviceMaterialParView : UserControl
+ {
+ public DeviceMaterialParView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/DosingSystem/View/HardwareStatusView.xaml b/DosingSystem/View/HardwareStatusView.xaml
index 405d9e5f..28beb084 100644
--- a/DosingSystem/View/HardwareStatusView.xaml
+++ b/DosingSystem/View/HardwareStatusView.xaml
@@ -17,231 +17,96 @@
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
diff --git a/DosingSystem/View/NewMaterialDeviceParView.xaml b/DosingSystem/View/NewMaterialDeviceParView.xaml
deleted file mode 100644
index 587f887b..00000000
--- a/DosingSystem/View/NewMaterialDeviceParView.xaml
+++ /dev/null
@@ -1,525 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/DosingSystem/View/NewMaterialDeviceParView.xaml.cs b/DosingSystem/View/NewMaterialDeviceParView.xaml.cs
deleted file mode 100644
index f39464e3..00000000
--- a/DosingSystem/View/NewMaterialDeviceParView.xaml.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using BPASmartClient.DosingSystem.Model;
-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.Shapes;
-
-namespace BPASmartClient.DosingSystem.View
-{
- ///
- /// NewMaterialDeviceParView.xaml 的交互逻辑
- ///
- public partial class NewMaterialDeviceParView : Window
- {
- public NewMaterialDeviceParView()
- {
- InitializeComponent();
- this.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); };
- this.DragMove();
- }
-
- private void ComboBox_KeyUp(object sender, KeyEventArgs e)
- {
- var res = sender as ComboBox;
- Json.Read();
- if (res.Text != null && res.Text != String.Empty)
- {
- var datas = Json.Data.deviceParModels.Where(s => s.MaterialName.Contains(res.Text.Trim()));
- if (datas.Count() > 0)
- {
- res.ItemsSource = datas;
- res.IsDropDownOpen = true;
- }
- else
- {
- res.IsDropDownOpen = false;
- }
- }
- }
-
- private void ComboBox_LostFocus(object sender, RoutedEventArgs e)
- {
-
- }
- }
-}
diff --git a/DosingSystem/View/RecipeSettingsView.xaml b/DosingSystem/View/RecipeSettingsView.xaml
index a6ce4361..8e721ae5 100644
--- a/DosingSystem/View/RecipeSettingsView.xaml
+++ b/DosingSystem/View/RecipeSettingsView.xaml
@@ -90,75 +90,6 @@
-
-
-
-
ChangeNameCommand { get; set; }
- public static ObservableCollection devices { get; set; } = new ObservableCollection();
+ //public static ObservableCollection devices { get; set; } = new ObservableCollection();
+ public static ObservableCollection devices { get; set; }
}
public class Devices : ObservableObject
diff --git a/DosingSystem/ViewModel/DeviceMaterialParViewModel.cs b/DosingSystem/ViewModel/DeviceMaterialParViewModel.cs
new file mode 100644
index 00000000..c71fbe5d
--- /dev/null
+++ b/DosingSystem/ViewModel/DeviceMaterialParViewModel.cs
@@ -0,0 +1,69 @@
+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.DosingSystem.Model;
+using BPASmartClient.Helper;
+using Microsoft.Toolkit.Mvvm.Input;
+using BPASmartClient.CustomResource.UserControls.MessageShow;
+using BPASmartClient.CustomResource.UserControls;
+using System.Diagnostics;
+
+namespace BPASmartClient.DosingSystem.ViewModel
+{
+ public class DeviceMaterialParViewModel : ObservableObject
+ {
+ public DeviceMaterialParViewModel()
+ {
+ deviceParModels = Json.Data.deviceParModels;
+ RemoveCommand = new RelayCommand