From 921c32d139a6497b36664826b337f78656f011c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Fri, 11 Mar 2022 18:02:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=89=E4=BB=A3=E6=9C=BA=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E6=90=AD=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HBLConsole.Business/Devices/MORKS.cs | 107 ++-- HBLConsole.Business/MessageServer/Base.cs | 21 + HBLConsole.GVL/CircuitAttribute.cs | 2 - HBLConsole.GVL/MORKS.cs | 1 + HBLConsole.Interface/IDeviceType.cs | 13 + .../CommunicationPar/CommunicationPar.cs | 16 + .../CommunicationPar/CommunicationSet.cs | 58 +++ .../CommunicationPar/ModbusRtu.cs | 50 ++ .../CommunicationPar/ModbusTcp.cs | 19 + HBLConsole.Model/CommunicationPar/Siemens.cs | 45 ++ HBLConsole.Model/DeviceManagermentResult.cs | 14 + HBLConsole.Model/Enums/DisplayFormat.cs | 15 + HBLConsole.Model/Enums/EAlarmType.cs | 29 ++ HBLConsole.Model/Enums/EAlongTriggerType.cs | 24 + HBLConsole.Model/Enums/EAnalogAlarmType.cs | 19 + HBLConsole.Model/Enums/EDataType.cs | 22 + HBLConsole.Model/Enums/EDeviceType.cs | 16 + HBLConsole.Model/Enums/EOperatorType.cs | 39 ++ HBLConsole.Model/Enums/EParity.cs | 15 + HBLConsole.Model/Enums/ESiemensPlcType.cs | 16 + HBLConsole.Model/HBLConsole.Model.csproj | 5 + HBLConsole.Model/SerialDeviceBase.cs | 41 ++ HBLConsole.Model/SimOrderData.cs | 3 +- HBLConsole.Model/TcpDeviceBase.cs | 21 + HBLConsole.Model/UniversalBase.cs | 17 + HBLConsole.PryUserControl/BeveledButton.xaml | 34 -- HBLConsole.PryUserControl/Quadrilateral.xaml | 20 + .../Quadrilateral.xaml.cs | 96 ++++ HBLConsole.PryUserControl/TitleTextBlock.xaml | 27 + .../TitleTextBlock.xaml.cs | 38 ++ HBLConsole.Service/ActionManagerment.cs | 13 +- HBLConsole.Service/Json.cs | 12 + HBLConsole/App.config | 2 +- HBLConsole/Converter/VisibleConvert.cs | 32 ++ .../View/DeviceManagermentSetView.xaml | 196 +++++++ .../View/DeviceManagermentSetView.xaml.cs | 84 +++ .../DeviceManagermentSetViewModel.cs | 68 +++ HBLConsole/HBLConsole.csproj | 6 - HBLConsole/Resources/Fonts/iconfont.ttf | Bin 2432 -> 5348 bytes .../ResourceDictionarys/BasicStyle.xaml | 465 ++++++++++++++++- HBLConsole/View/DebugView.xaml | 40 +- HBLConsole/View/DeviceManageView.xaml | 489 ++++++++++++++++++ HBLConsole/View/DeviceManageView.xaml.cs | 28 + HBLConsole/View/MainView.xaml | 14 +- HBLConsole/View/ProcessMonitoringView.xaml | 12 + HBLConsole/View/ProcessMonitoringView.xaml.cs | 28 + HBLConsole/ViewModel/DebugViewModel.cs | 24 +- HBLConsole/ViewModel/DeviceManageViewModel.cs | 132 +++++ .../ViewModel/ProcessMonitoringViewModel.cs | 123 +++++ 49 files changed, 2470 insertions(+), 141 deletions(-) create mode 100644 HBLConsole.Interface/IDeviceType.cs create mode 100644 HBLConsole.Model/CommunicationPar/CommunicationPar.cs create mode 100644 HBLConsole.Model/CommunicationPar/CommunicationSet.cs create mode 100644 HBLConsole.Model/CommunicationPar/ModbusRtu.cs create mode 100644 HBLConsole.Model/CommunicationPar/ModbusTcp.cs create mode 100644 HBLConsole.Model/CommunicationPar/Siemens.cs create mode 100644 HBLConsole.Model/DeviceManagermentResult.cs create mode 100644 HBLConsole.Model/Enums/DisplayFormat.cs create mode 100644 HBLConsole.Model/Enums/EAlarmType.cs create mode 100644 HBLConsole.Model/Enums/EAlongTriggerType.cs create mode 100644 HBLConsole.Model/Enums/EAnalogAlarmType.cs create mode 100644 HBLConsole.Model/Enums/EDataType.cs create mode 100644 HBLConsole.Model/Enums/EDeviceType.cs create mode 100644 HBLConsole.Model/Enums/EOperatorType.cs create mode 100644 HBLConsole.Model/Enums/EParity.cs create mode 100644 HBLConsole.Model/Enums/ESiemensPlcType.cs create mode 100644 HBLConsole.Model/SerialDeviceBase.cs create mode 100644 HBLConsole.Model/TcpDeviceBase.cs create mode 100644 HBLConsole.Model/UniversalBase.cs create mode 100644 HBLConsole.PryUserControl/Quadrilateral.xaml create mode 100644 HBLConsole.PryUserControl/Quadrilateral.xaml.cs create mode 100644 HBLConsole.PryUserControl/TitleTextBlock.xaml create mode 100644 HBLConsole.PryUserControl/TitleTextBlock.xaml.cs create mode 100644 HBLConsole/Converter/VisibleConvert.cs create mode 100644 HBLConsole/DialogWindow/View/DeviceManagermentSetView.xaml create mode 100644 HBLConsole/DialogWindow/View/DeviceManagermentSetView.xaml.cs create mode 100644 HBLConsole/DialogWindow/ViewModel/DeviceManagermentSetViewModel.cs create mode 100644 HBLConsole/View/DeviceManageView.xaml create mode 100644 HBLConsole/View/DeviceManageView.xaml.cs create mode 100644 HBLConsole/View/ProcessMonitoringView.xaml create mode 100644 HBLConsole/View/ProcessMonitoringView.xaml.cs create mode 100644 HBLConsole/ViewModel/DeviceManageViewModel.cs create mode 100644 HBLConsole/ViewModel/ProcessMonitoringViewModel.cs diff --git a/HBLConsole.Business/Devices/MORKS.cs b/HBLConsole.Business/Devices/MORKS.cs index b45a1dd..469e27d 100644 --- a/HBLConsole.Business/Devices/MORKS.cs +++ b/HBLConsole.Business/Devices/MORKS.cs @@ -24,25 +24,6 @@ namespace HBLConsole.Business.Devices public GVL.MORKS mORKS { get; set; } = new GVL.MORKS(); - /// - /// 写入配方数据到 PLC - /// - private void WriteRecipeBoms() - { - List recipeBoms = new List(); - foreach (var item in Json.GetInstance.Base.recipeBoms.RecipeIds) - { - foreach (var rec in item.Recipes) - { - recipeBoms.Add((ushort)rec); - } - } - if (ModbusTcpHelper.GetInstance.Write(1100, WriteType.HoldingRegisters, recipeBoms.ToArray())) - { - MessageLog.GetInstance.Show("成功写入配方数据"); - } - } - public void Init() { //Modbus TCP连接成功 @@ -60,9 +41,7 @@ namespace HBLConsole.Business.Devices //Modbus Tcp 连接 //ModbusTcpHelper.GetInstance.ModbusTcpConnect("192.168.1.11", 508); - // ModbusTcpHelper.GetInstance.ModbusTcpConnect("127.0.0.1"); - // Action action; - //action.inv + ModbusTcpHelper.GetInstance.ModbusTcpConnect("127.0.0.1"); //模拟订单 SimOrder(); @@ -73,6 +52,9 @@ namespace HBLConsole.Business.Devices List batchingInfos = new List(); + /// + /// 心跳状态 + /// private void Heartbeat() { HeartbeatReport.GetInstance.GetMessage = new Action(() => @@ -225,24 +207,21 @@ namespace HBLConsole.Business.Devices if (o is SimOrderData simOrderData) { string subId = Guid.NewGuid().ToString(); - if (simOrderData.IsEnableRandom) - { + if (simOrderData.NoodleIsEnableRandom) NoodleLoc = (ushort)(new Random().Next(1, 6)); - BowlLoc = (ushort)(new Random().Next(10, 12)); - } else - { NoodleLoc = (ushort)simOrderData.NoodleLoc; - BowlLoc = (ushort)simOrderData.BowlLoc; - } + + if (simOrderData.BowlIsEnableRandom) + BowlLoc = (ushort)(new Random().Next(10, 12)); + else + BowlLoc = (ushort)simOrderData.BowlLoc; mORKS.RBTakeNoodleTask.Enqueue(new GVL.OrderLocInfo() { Loc = NoodleLoc, SuborderId = subId }); mORKS.TakeBowlTask.Enqueue(new GVL.OrderLocInfo() { Loc = BowlLoc, SuborderId = subId }); MessageLog.GetInstance.Show($"添加订单:面条位置【{NoodleLoc}】,碗位置【{BowlLoc}】"); } } - - }), "SimOrder"); } @@ -311,12 +290,10 @@ namespace HBLConsole.Business.Devices { mORKS.AllowRun = mORKS.InitComplete && !mORKS.TemperatureReached; - if (mORKS.AllowRun) - { - TakeBowlTask(); + TakeBowlTask(); + + TakeNoodleTask(); - TakeNoodleTask(); - } OutNoodleTask(); SingleDetect(); @@ -333,7 +310,7 @@ namespace HBLConsole.Business.Devices /// private void TakeBowlTask() { - if (mORKS.TakeBowlTask.Count > 0 && !mORKS.TakeBowlIdle && !mORKS.TakeBowlInterlock) + if (mORKS.AllowRun && mORKS.TakeBowlTask.Count > 0 && !mORKS.TakeBowlIdle && !mORKS.TakeBowlInterlock) { if (mORKS.TakeBowlTask.TryDequeue(out GVL.OrderLocInfo orderLocInfo)) { @@ -398,25 +375,30 @@ namespace HBLConsole.Business.Devices private void TakeNoodleTask() { //取面控制 - if (mORKS.RobotIdle && !mORKS.RobotTaskInterlock && mORKS.AllowTakeNoodle && mORKS.TurntableMoveInPlace && !mORKS.TakeNoodleInterlock && !mORKS.OutNoodleing && mORKS.RBTakeNoodleTask.Count > 0) + if (mORKS.AllowRun && mORKS.RobotIdle && !mORKS.RobotTaskInterlock && mORKS.AllowTakeNoodle && mORKS.TurntableMoveInPlace && !mORKS.TakeNoodleInterlock && !mORKS.OutNoodleing && mORKS.RBTakeNoodleTask.Count > 0) { - if (mORKS.RBTakeNoodleTask.TryDequeue(out GVL.OrderLocInfo orderLocInfo)) + int loc = Array.FindIndex(mORKS.NoodleCookerStatus, p => p == false);//查找煮面炉空闲位置 + if (loc >= 0 && loc <= 5) { - //设置转台位置 - SetTurntableLoc(orderLocInfo.Loc); - //设置倒面位置 - int loc = Array.FindIndex(mORKS.NoodleCookerStatus, p => p == false);//查找煮面炉空闲位置 - if (loc >= 0 && loc <= 5) + if (mORKS.RBTakeNoodleTask.TryDequeue(out GVL.OrderLocInfo orderLocInfo)) { + //设置转台位置 + SetTurntableLoc(orderLocInfo.Loc); + //设置倒面位置 + + //if (loc >= 0 && loc <= 5) + //{ CookNodelId[loc] = orderLocInfo.SuborderId; SetFallNoodleLoc((ushort)(loc + 1)); + //} + //机器人开始取面 + RobotTakeNoodle(); + SimpleFactory.GetInstance.OrderChanged(orderLocInfo.SuborderId, ORDER_STATUS.COOKING); + MessageLog.GetInstance.Show($"订单【{orderLocInfo.SuborderId}】,转台:[{orderLocInfo}],煮面栏:[{loc + 1}]"); + mORKS.TakeNoodleInterlock = true; } - //机器人开始取面 - RobotTakeNoodle(); - SimpleFactory.GetInstance.OrderChanged(orderLocInfo.SuborderId, ORDER_STATUS.COOKING); - MessageLog.GetInstance.Show($"订单【{orderLocInfo.SuborderId}】,转台:[{orderLocInfo}],煮面栏:[{loc + 1}]"); - mORKS.TakeNoodleInterlock = true; } + } } @@ -500,11 +482,33 @@ namespace HBLConsole.Business.Devices int OutMealRequstCount = mORKS.CookNoodlesComplete.Where(p => p == true).ToList().Count; int mlCount = mORKS.NoodleCookerStatus.Where(p => p == true).ToList().Count; mORKS.RobotTaskInterlock = OutMealRequstCount > 0 && mORKS.AllowFallNoodle && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0); - } #region PLC 控制函数 + + /// + /// 写入配方数据到 PLC + /// + private void WriteRecipeBoms() + { + List recipeBoms = new List(); + foreach (var item in Json.GetInstance.Base.recipeBoms.RecipeIds) + { + foreach (var rec in item.Recipes) + { + recipeBoms.Add((ushort)rec); + } + } + if (recipeBoms.Count > 0) + { + if (ModbusTcpHelper.GetInstance.Write(1100, WriteType.HoldingRegisters, recipeBoms.ToArray())) + { + MessageLog.GetInstance.Show("成功写入配方数据"); + } + } + } + /// /// 转台移动 /// @@ -531,8 +535,9 @@ namespace HBLConsole.Business.Devices { ushort addRess = (ushort)(1136 + num - 1); ModbusTcpHelper.GetInstance.Write(addRess, WriteType.Coils, false); + MessageLog.GetInstance.Show($"{num}号煮面口占用复位"); } - MessageLog.GetInstance.Show($"{num}号煮面口占用复位"); + } /// diff --git a/HBLConsole.Business/MessageServer/Base.cs b/HBLConsole.Business/MessageServer/Base.cs index 6530b54..805d101 100644 --- a/HBLConsole.Business/MessageServer/Base.cs +++ b/HBLConsole.Business/MessageServer/Base.cs @@ -32,15 +32,25 @@ namespace HBLConsole.Business.MessageServer } } + /// + /// 接收来自MQTT 推送的物料信息 + /// + /// + /// public override void GetBatchingInfo(T batchingInfo) { if (batchingInfo == null) return; if (batchingInfo is OrderMaterialDelivery BatchingInfos) { Json.GetInstance.Base.orderMaterialDelivery = BatchingInfos; + MessageLog.GetInstance.Show("收到推送的物料信息"); } } + /// + /// 通过接口获取物料信息 + /// + /// public override void GetBatchingInfo(int ClientId) { string result = string.Empty; @@ -64,6 +74,11 @@ namespace HBLConsole.Business.MessageServer }); } + /// + /// 接收MQTT 推送过来的辅料信息 + /// + /// + /// public override void GetRecipeBom(T recipeBomInfo) { if (recipeBomInfo == null) return; @@ -74,6 +89,12 @@ namespace HBLConsole.Business.MessageServer MessageLog.GetInstance.Show("接收到辅料信息"); } + /// + /// 订单状态改变 + /// + /// + /// + /// public override bool OrderStatusChange(string subOrderId, ORDER_STATUS status) { string result = string.Empty; diff --git a/HBLConsole.GVL/CircuitAttribute.cs b/HBLConsole.GVL/CircuitAttribute.cs index 284c6e2..7f5456d 100644 --- a/HBLConsole.GVL/CircuitAttribute.cs +++ b/HBLConsole.GVL/CircuitAttribute.cs @@ -55,8 +55,6 @@ namespace HBLConsole.GVL { ProcessData.GetInstance.Conditions[item].Add(new Condition() { propertyIllustrate = propertyIllustrate }); } - - } } diff --git a/HBLConsole.GVL/MORKS.cs b/HBLConsole.GVL/MORKS.cs index 6d269be..dea3d6a 100644 --- a/HBLConsole.GVL/MORKS.cs +++ b/HBLConsole.GVL/MORKS.cs @@ -39,6 +39,7 @@ namespace HBLConsole.GVL /// /// 允许运行 /// + [Circuit(new string[] { "机器人取面", "取碗控制" }, "允许运行")] public bool AllowRun { get; set; } /// diff --git a/HBLConsole.Interface/IDeviceType.cs b/HBLConsole.Interface/IDeviceType.cs new file mode 100644 index 0000000..992a368 --- /dev/null +++ b/HBLConsole.Interface/IDeviceType.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Interface +{ + public interface IDeviceType + { + //void Init(); + } +} diff --git a/HBLConsole.Model/CommunicationPar/CommunicationPar.cs b/HBLConsole.Model/CommunicationPar/CommunicationPar.cs new file mode 100644 index 0000000..b2663d8 --- /dev/null +++ b/HBLConsole.Model/CommunicationPar/CommunicationPar.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + /// + /// 通讯参数 + /// + public class CommunicationPar + { + public List communicationSets = new List(); + } +} diff --git a/HBLConsole.Model/CommunicationPar/CommunicationSet.cs b/HBLConsole.Model/CommunicationPar/CommunicationSet.cs new file mode 100644 index 0000000..1b5d105 --- /dev/null +++ b/HBLConsole.Model/CommunicationPar/CommunicationSet.cs @@ -0,0 +1,58 @@ +using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.Input; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using HBLConsole.Interface; + + +namespace HBLConsole.Model +{ + public class CommunicationSet : ObservableObject + { + public CommunicationSet() + { + RemoveCommand = new RelayCommand((o) => { if (RemoveAction != null) RemoveAction(o); }); + } + + public Action RemoveAction { get; set; } + + + public IDeviceType Device { get { return _mDevice; } set { _mDevice = value; OnPropertyChanged(); } } + private IDeviceType _mDevice; + + + //public Siemens CommSiemens { get { return _mCommSiemens; } set { _mCommSiemens = value; OnPropertyChanged(); } } + //private Siemens _mCommSiemens; + + //public ModbusTcp CommModbusTcp { get { return _mCommModbusTcp; } set { _mCommModbusTcp = value; OnPropertyChanged(); } } + //private ModbusTcp _mCommModbusTcp; + + //public ModbusRtu CommModbusRtu { get { return _mCommModbusRtu; } set { _mCommModbusRtu = value; OnPropertyChanged(); } } + //private ModbusRtu _mCommModbusRtu; + + /// + /// 是否激活 + /// + public bool IsActive { get { return _mIsActive; } set { _mIsActive = value; OnPropertyChanged(); } } + private bool _mIsActive = true; + + /// + /// 新增设备名称 + /// + public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } + private string _mDeviceName; + + /// + /// 设备类型 + /// + public EDeviceType deviceType { get { return _mdeviceType; } set { _mdeviceType = value; OnPropertyChanged(); } } + private EDeviceType _mdeviceType; + + + + public RelayCommand RemoveCommand { get; set; } + } +} diff --git a/HBLConsole.Model/CommunicationPar/ModbusRtu.cs b/HBLConsole.Model/CommunicationPar/ModbusRtu.cs new file mode 100644 index 0000000..52ea9c0 --- /dev/null +++ b/HBLConsole.Model/CommunicationPar/ModbusRtu.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO.Ports; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + public class ModbusRtu : SerialDeviceBase + { + public ModbusRtu() + { + Init(); + } + + public ObservableCollection Ports { get; set; } = new ObservableCollection(); + + public ObservableCollection BaudRates { get; set; } = new ObservableCollection(); + + public ObservableCollection Paritys { get; set; } = new ObservableCollection(); + + private void Init() + { + Ports.Clear(); + foreach (var item in SerialPort.GetPortNames()) + { + Ports.Add(item); + } + + + BaudRates.Clear(); + BaudRates.Add("110"); + int initValue = 300; + for (int i = 0; i < 17; i++) + { + BaudRates.Add(initValue.ToString()); + initValue *= 2; + } + + + Paritys.Clear(); + foreach (var item in Enum.GetNames(typeof(EParity))) + { + Paritys.Add(item); + } + } + } +} diff --git a/HBLConsole.Model/CommunicationPar/ModbusTcp.cs b/HBLConsole.Model/CommunicationPar/ModbusTcp.cs new file mode 100644 index 0000000..0df3ba9 --- /dev/null +++ b/HBLConsole.Model/CommunicationPar/ModbusTcp.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace HBLConsole.Model +{ + public class ModbusTcp : TcpDeviceBase + { + /// + /// 站号,默认为 1 + /// + public int StationNo { get; set; } = 1; + + + } +} diff --git a/HBLConsole.Model/CommunicationPar/Siemens.cs b/HBLConsole.Model/CommunicationPar/Siemens.cs new file mode 100644 index 0000000..eb46200 --- /dev/null +++ b/HBLConsole.Model/CommunicationPar/Siemens.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + public class Siemens : TcpDeviceBase + { + public Siemens() + { + Init(); + } + + /// + /// 插槽号 + /// + public int Slot { get; set; } = 0; + + /// + /// 机架号 + /// + public int Rack { get; set; } = 0; + + /// + /// PLC 类型 + /// + public string PlcType { get; set; } + + public ObservableCollection PlcTypes { get; set; } = new ObservableCollection(); + + private void Init() + { + PlcTypes.Clear(); + foreach (var item in Enum.GetNames(typeof(ESiemensPlcType))) + { + PlcTypes.Add(item.Substring(1)); + } + } + + + } +} diff --git a/HBLConsole.Model/DeviceManagermentResult.cs b/HBLConsole.Model/DeviceManagermentResult.cs new file mode 100644 index 0000000..5b0e1ef --- /dev/null +++ b/HBLConsole.Model/DeviceManagermentResult.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + public class DeviceManagermentResult + { + public string DeviceType { get; set; } + public string DeviceName { get; set; } + } +} diff --git a/HBLConsole.Model/Enums/DisplayFormat.cs b/HBLConsole.Model/Enums/DisplayFormat.cs new file mode 100644 index 0000000..8841896 --- /dev/null +++ b/HBLConsole.Model/Enums/DisplayFormat.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + internal enum DisplayFormat + { + 二进制, + 十进制, + 十六进制, + } +} diff --git a/HBLConsole.Model/Enums/EAlarmType.cs b/HBLConsole.Model/Enums/EAlarmType.cs new file mode 100644 index 0000000..b632b20 --- /dev/null +++ b/HBLConsole.Model/Enums/EAlarmType.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + /// + /// 报警类型 + /// + public enum EAlarmType + { + /// + /// 无报警 + /// + 无 = 1, + + /// + /// 模拟量报警 + /// + 模拟量报警 = 2, + + /// + /// 离散量报警 + /// + 离散量报警 = 3 + } +} diff --git a/HBLConsole.Model/Enums/EAlongTriggerType.cs b/HBLConsole.Model/Enums/EAlongTriggerType.cs new file mode 100644 index 0000000..6433a03 --- /dev/null +++ b/HBLConsole.Model/Enums/EAlongTriggerType.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + /// + /// 沿触发类型枚举 + /// + public enum EAlongTriggerType + { + /// + /// 下降沿触发 + /// + 下降沿 = 1, + /// + /// 上升沿触发 + /// + 上升沿 = 2 + } + +} diff --git a/HBLConsole.Model/Enums/EAnalogAlarmType.cs b/HBLConsole.Model/Enums/EAnalogAlarmType.cs new file mode 100644 index 0000000..5728b21 --- /dev/null +++ b/HBLConsole.Model/Enums/EAnalogAlarmType.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + /// + /// 模拟量报警类型 + /// + public enum EAnalogAlarmType + { + 高高报警 = 1, + 高报警 = 2, + 低报警 = 3, + 低低报警 = 4, + } +} diff --git a/HBLConsole.Model/Enums/EDataType.cs b/HBLConsole.Model/Enums/EDataType.cs new file mode 100644 index 0000000..d3242df --- /dev/null +++ b/HBLConsole.Model/Enums/EDataType.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + /// + /// 数据类型枚举 + /// + public enum EDataType + { + Bool = 1, + Byte = 2, + Int = 3, + Word = 4, + Dint = 5, + Dword = 6, + Float = 7 + } +} diff --git a/HBLConsole.Model/Enums/EDeviceType.cs b/HBLConsole.Model/Enums/EDeviceType.cs new file mode 100644 index 0000000..86652bc --- /dev/null +++ b/HBLConsole.Model/Enums/EDeviceType.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + public enum EDeviceType + { + Siemens, + ModbusRtu, + ModbusTcp, + SerialPort, + } +} diff --git a/HBLConsole.Model/Enums/EOperatorType.cs b/HBLConsole.Model/Enums/EOperatorType.cs new file mode 100644 index 0000000..eb6a7f7 --- /dev/null +++ b/HBLConsole.Model/Enums/EOperatorType.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + /// + /// 判断操作符枚举 + /// + public enum EOperatorType + { + /// + /// 大于 + /// + P_GT = 1, + /// + /// 大于等于 + /// + P_GE = 2, + /// + /// 等于 + /// + P_EQ = 3, + /// + /// 不等于 + /// + P_NE = 4, + /// + /// 小于 + /// + P_LT = 5, + /// + /// 小于等于 + /// + P_LE = 6 + } +} diff --git a/HBLConsole.Model/Enums/EParity.cs b/HBLConsole.Model/Enums/EParity.cs new file mode 100644 index 0000000..21bbf20 --- /dev/null +++ b/HBLConsole.Model/Enums/EParity.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + public enum EParity + { + 无, + 奇校验, + 偶校验 + } +} diff --git a/HBLConsole.Model/Enums/ESiemensPlcType.cs b/HBLConsole.Model/Enums/ESiemensPlcType.cs new file mode 100644 index 0000000..b94bad5 --- /dev/null +++ b/HBLConsole.Model/Enums/ESiemensPlcType.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + public enum ESiemensPlcType + { + S1200, + S1500, + S300_400, + S200_Smart + } +} diff --git a/HBLConsole.Model/HBLConsole.Model.csproj b/HBLConsole.Model/HBLConsole.Model.csproj index 77dc8f1..01617fa 100644 --- a/HBLConsole.Model/HBLConsole.Model.csproj +++ b/HBLConsole.Model/HBLConsole.Model.csproj @@ -6,6 +6,11 @@ + + + + + diff --git a/HBLConsole.Model/SerialDeviceBase.cs b/HBLConsole.Model/SerialDeviceBase.cs new file mode 100644 index 0000000..36b4b8d --- /dev/null +++ b/HBLConsole.Model/SerialDeviceBase.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + public class SerialDeviceBase : UniversalBase + { + /// + /// 串口端口 + /// + public string ComSerialPort { get; set; } + + /// + /// 波特率,110,300--115200(从300开始乘以2,直到结果等于115200) + /// + public string BaudRate { get; set; } = "9600"; + + /// + /// 数据位,默认为 8 + /// + public int DataBit { get; set; } = 8; + + /// + /// 停止位,默认为 1 + /// + public int StopBit { get; set; } = 1; + + /// + /// 站号,默认为 1 + /// + public int StationNo { get; set; } = 1; + + /// + /// 奇偶校验,无,奇校验,偶校验 + /// + public string Parity { get; set; } + } +} diff --git a/HBLConsole.Model/SimOrderData.cs b/HBLConsole.Model/SimOrderData.cs index d79b741..dd0a3b5 100644 --- a/HBLConsole.Model/SimOrderData.cs +++ b/HBLConsole.Model/SimOrderData.cs @@ -10,6 +10,7 @@ namespace HBLConsole.Model { public int NoodleLoc { get; set; } public int BowlLoc { get; set; } - public bool IsEnableRandom { get; set; } + public bool NoodleIsEnableRandom { get; set; } + public bool BowlIsEnableRandom { get; set; } } } diff --git a/HBLConsole.Model/TcpDeviceBase.cs b/HBLConsole.Model/TcpDeviceBase.cs new file mode 100644 index 0000000..5819355 --- /dev/null +++ b/HBLConsole.Model/TcpDeviceBase.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HBLConsole.Model +{ + public class TcpDeviceBase : UniversalBase + { + /// + /// IP地址 + /// + public string IP { get; set; } = "192.168.0.1"; + + /// + /// 端口号,默认 102 + /// + public int PortNum { get; set; } = 102; + } +} diff --git a/HBLConsole.Model/UniversalBase.cs b/HBLConsole.Model/UniversalBase.cs new file mode 100644 index 0000000..b1dbe51 --- /dev/null +++ b/HBLConsole.Model/UniversalBase.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using HBLConsole.Interface; + +namespace HBLConsole.Model +{ + public class UniversalBase : IDeviceType + { + /// + /// 显示/隐藏设置 + /// + public bool IsVisible { get; set; } = true; + } +} diff --git a/HBLConsole.PryUserControl/BeveledButton.xaml b/HBLConsole.PryUserControl/BeveledButton.xaml index c1e0086..761a8d8 100644 --- a/HBLConsole.PryUserControl/BeveledButton.xaml +++ b/HBLConsole.PryUserControl/BeveledButton.xaml @@ -8,40 +8,6 @@ d:DesignHeight="30" d:DesignWidth="100" mc:Ignorable="d"> - - - + + + + + + diff --git a/HBLConsole.PryUserControl/Quadrilateral.xaml.cs b/HBLConsole.PryUserControl/Quadrilateral.xaml.cs new file mode 100644 index 0000000..ba177ca --- /dev/null +++ b/HBLConsole.PryUserControl/Quadrilateral.xaml.cs @@ -0,0 +1,96 @@ +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 HBLConsole.PryUserControl +{ + /// + /// Quadrilateral.xaml 的交互逻辑 + /// + public partial class Quadrilateral : UserControl + { + public Quadrilateral() + { + InitializeComponent(); + } + + + public static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + (d as Quadrilateral).Refresh(); + } + + /// + /// 依赖属性更改的委托 + /// + private void Refresh() + { + this.poly.Fill = FillColor; + this.poly.StrokeThickness = StrokeThickness; + this.poly.Stroke = Stroke; + } + + #region FillColor:填充颜色 依赖属性 + /// + /// 填充颜色 + /// + public Brush FillColor + { + get { return (Brush)GetValue(FillColorProperty); } + set { SetValue(FillColorProperty, value); } + } + public static readonly DependencyProperty FillColorProperty = + DependencyProperty.Register("FillColor", typeof(Brush), typeof(Quadrilateral), + new PropertyMetadata(default(Brush), new PropertyChangedCallback(OnPropertyChanged))); + #endregion + + #region 外边线宽度 + /// + /// 外边线宽度 + /// + public int StrokeThickness + { + get { return (int)GetValue(StrokeThicknessProperty); } + set { SetValue(StrokeThicknessProperty, value); } + } + public static readonly DependencyProperty StrokeThicknessProperty = + DependencyProperty.Register("StrokeThickness", typeof(int), typeof(Quadrilateral), + new PropertyMetadata(0, new PropertyChangedCallback(OnPropertyChanged))); + #endregion + + #region 外边框颜色 + /// + /// 外边框颜色 + /// + public Brush Stroke + { + get { return (Brush)GetValue(StrokeProperty); } + set { SetValue(StrokeProperty, value); } + } + public static readonly DependencyProperty StrokeProperty = + DependencyProperty.Register("Stroke", typeof(Brush), typeof(Quadrilateral), + new PropertyMetadata(default(Brush), new PropertyChangedCallback(OnPropertyChanged))); + #endregion + + private void Canvas_SizeChanged(object sender, SizeChangedEventArgs e) + { + PointCollection points = new PointCollection(); + points.Add(new Point(0, 0)); + points.Add(new Point(e.NewSize.Width - (e.NewSize.Height / 2), 0)); + points.Add(new Point(e.NewSize.Width, e.NewSize.Height)); + points.Add(new Point(e.NewSize.Height / 2, e.NewSize.Height)); + this.poly.Points = points; + } + } +} diff --git a/HBLConsole.PryUserControl/TitleTextBlock.xaml b/HBLConsole.PryUserControl/TitleTextBlock.xaml new file mode 100644 index 0000000..ddb5189 --- /dev/null +++ b/HBLConsole.PryUserControl/TitleTextBlock.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + diff --git a/HBLConsole.PryUserControl/TitleTextBlock.xaml.cs b/HBLConsole.PryUserControl/TitleTextBlock.xaml.cs new file mode 100644 index 0000000..82b9093 --- /dev/null +++ b/HBLConsole.PryUserControl/TitleTextBlock.xaml.cs @@ -0,0 +1,38 @@ +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 HBLConsole.PryUserControl +{ + /// + /// TitleTextBlock.xaml 的交互逻辑 + /// + public partial class TitleTextBlock : UserControl + { + public TitleTextBlock() + { + InitializeComponent(); + } + + private void Canvas_SizeChanged(object sender, SizeChangedEventArgs e) + { + PointCollection points = new PointCollection(); + points.Add(new Point(0, 0)); + points.Add(new Point(e.NewSize.Width - (e.NewSize.Height / 2), 0)); + points.Add(new Point(e.NewSize.Width, e.NewSize.Height)); + points.Add(new Point(0, e.NewSize.Height)); + this.poly.Points = points; + } + } +} diff --git a/HBLConsole.Service/ActionManagerment.cs b/HBLConsole.Service/ActionManagerment.cs index 9aee338..44625c6 100644 --- a/HBLConsole.Service/ActionManagerment.cs +++ b/HBLConsole.Service/ActionManagerment.cs @@ -16,12 +16,23 @@ namespace HBLConsole.Service private static ConcurrentDictionary actions = new ConcurrentDictionary(); - private static ConcurrentDictionary actionManagers = new ConcurrentDictionary(); + //private static ConcurrentDictionary actionManagers = new ConcurrentDictionary(); static readonly object SendLock = new object(); static readonly object SendParLock = new object(); static readonly object RegisterLock = new object(); + /// + /// 注销委托 + /// + /// + public void LogOut(string name) + { + if (actions.ContainsKey(name)) + { + actions.TryRemove(name, out Delegation t); + } + } public void Send(string name, object token, Action action = null) { diff --git a/HBLConsole.Service/Json.cs b/HBLConsole.Service/Json.cs index 346038c..55b7279 100644 --- a/HBLConsole.Service/Json.cs +++ b/HBLConsole.Service/Json.cs @@ -48,5 +48,17 @@ namespace HBLConsole.Service } + public void ReadIntres() + { + if (File.Exists(path)) + { + string JsonString = File.ReadAllText(path); + + var result = JsonConvert.DeserializeObject(JsonString); + if (result != null) { Base = result; } + } + } + + } } diff --git a/HBLConsole/App.config b/HBLConsole/App.config index af9f483..1e2ee8f 100644 --- a/HBLConsole/App.config +++ b/HBLConsole/App.config @@ -11,7 +11,7 @@ - + diff --git a/HBLConsole/Converter/VisibleConvert.cs b/HBLConsole/Converter/VisibleConvert.cs new file mode 100644 index 0000000..09c8920 --- /dev/null +++ b/HBLConsole/Converter/VisibleConvert.cs @@ -0,0 +1,32 @@ +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; + +namespace HBLConsole.Converter +{ + public class VisibleConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && parameter != null) + { + + if (value.ToString() == parameter.ToString()) + { + return Visibility.Visible; + } + } + return Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/HBLConsole/DialogWindow/View/DeviceManagermentSetView.xaml b/HBLConsole/DialogWindow/View/DeviceManagermentSetView.xaml new file mode 100644 index 0000000..0de847c --- /dev/null +++ b/HBLConsole/DialogWindow/View/DeviceManagermentSetView.xaml @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +