@@ -24,25 +24,6 @@ namespace HBLConsole.Business.Devices | |||||
public GVL.MORKS mORKS { get; set; } = new GVL.MORKS(); | public GVL.MORKS mORKS { get; set; } = new GVL.MORKS(); | ||||
/// <summary> | |||||
/// 写入配方数据到 PLC | |||||
/// </summary> | |||||
private void WriteRecipeBoms() | |||||
{ | |||||
List<ushort> recipeBoms = new List<ushort>(); | |||||
foreach (var item in Json<BatchingInfoPar>.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() | public void Init() | ||||
{ | { | ||||
//Modbus TCP连接成功 | //Modbus TCP连接成功 | ||||
@@ -60,9 +41,7 @@ namespace HBLConsole.Business.Devices | |||||
//Modbus Tcp 连接 | //Modbus Tcp 连接 | ||||
//ModbusTcpHelper.GetInstance.ModbusTcpConnect("192.168.1.11", 508); | //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(); | SimOrder(); | ||||
@@ -73,6 +52,9 @@ namespace HBLConsole.Business.Devices | |||||
List<BatchingInfo> batchingInfos = new List<BatchingInfo>(); | List<BatchingInfo> batchingInfos = new List<BatchingInfo>(); | ||||
/// <summary> | |||||
/// 心跳状态 | |||||
/// </summary> | |||||
private void Heartbeat() | private void Heartbeat() | ||||
{ | { | ||||
HeartbeatReport.GetInstance.GetMessage = new Action(() => | HeartbeatReport.GetInstance.GetMessage = new Action(() => | ||||
@@ -225,24 +207,21 @@ namespace HBLConsole.Business.Devices | |||||
if (o is SimOrderData simOrderData) | if (o is SimOrderData simOrderData) | ||||
{ | { | ||||
string subId = Guid.NewGuid().ToString(); | string subId = Guid.NewGuid().ToString(); | ||||
if (simOrderData.IsEnableRandom) | |||||
{ | |||||
if (simOrderData.NoodleIsEnableRandom) | |||||
NoodleLoc = (ushort)(new Random().Next(1, 6)); | NoodleLoc = (ushort)(new Random().Next(1, 6)); | ||||
BowlLoc = (ushort)(new Random().Next(10, 12)); | |||||
} | |||||
else | else | ||||
{ | |||||
NoodleLoc = (ushort)simOrderData.NoodleLoc; | 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.RBTakeNoodleTask.Enqueue(new GVL.OrderLocInfo() { Loc = NoodleLoc, SuborderId = subId }); | ||||
mORKS.TakeBowlTask.Enqueue(new GVL.OrderLocInfo() { Loc = BowlLoc, SuborderId = subId }); | mORKS.TakeBowlTask.Enqueue(new GVL.OrderLocInfo() { Loc = BowlLoc, SuborderId = subId }); | ||||
MessageLog.GetInstance.Show($"添加订单:面条位置【{NoodleLoc}】,碗位置【{BowlLoc}】"); | MessageLog.GetInstance.Show($"添加订单:面条位置【{NoodleLoc}】,碗位置【{BowlLoc}】"); | ||||
} | } | ||||
} | } | ||||
}), "SimOrder"); | }), "SimOrder"); | ||||
} | } | ||||
@@ -311,12 +290,10 @@ namespace HBLConsole.Business.Devices | |||||
{ | { | ||||
mORKS.AllowRun = mORKS.InitComplete && !mORKS.TemperatureReached; | mORKS.AllowRun = mORKS.InitComplete && !mORKS.TemperatureReached; | ||||
if (mORKS.AllowRun) | |||||
{ | |||||
TakeBowlTask(); | |||||
TakeBowlTask(); | |||||
TakeNoodleTask(); | |||||
TakeNoodleTask(); | |||||
} | |||||
OutNoodleTask(); | OutNoodleTask(); | ||||
SingleDetect(); | SingleDetect(); | ||||
@@ -333,7 +310,7 @@ namespace HBLConsole.Business.Devices | |||||
/// </summary> | /// </summary> | ||||
private void TakeBowlTask() | 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)) | if (mORKS.TakeBowlTask.TryDequeue(out GVL.OrderLocInfo orderLocInfo)) | ||||
{ | { | ||||
@@ -398,25 +375,30 @@ namespace HBLConsole.Business.Devices | |||||
private void TakeNoodleTask() | 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; | CookNodelId[loc] = orderLocInfo.SuborderId; | ||||
SetFallNoodleLoc((ushort)(loc + 1)); | 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 OutMealRequstCount = mORKS.CookNoodlesComplete.Where(p => p == true).ToList().Count; | ||||
int mlCount = mORKS.NoodleCookerStatus.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); | mORKS.RobotTaskInterlock = OutMealRequstCount > 0 && mORKS.AllowFallNoodle && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0); | ||||
} | } | ||||
#region PLC 控制函数 | #region PLC 控制函数 | ||||
/// <summary> | |||||
/// 写入配方数据到 PLC | |||||
/// </summary> | |||||
private void WriteRecipeBoms() | |||||
{ | |||||
List<ushort> recipeBoms = new List<ushort>(); | |||||
foreach (var item in Json<BatchingInfoPar>.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("成功写入配方数据"); | |||||
} | |||||
} | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 转台移动 | /// 转台移动 | ||||
/// </summary> | /// </summary> | ||||
@@ -531,8 +535,9 @@ namespace HBLConsole.Business.Devices | |||||
{ | { | ||||
ushort addRess = (ushort)(1136 + num - 1); | ushort addRess = (ushort)(1136 + num - 1); | ||||
ModbusTcpHelper.GetInstance.Write(addRess, WriteType.Coils, false); | ModbusTcpHelper.GetInstance.Write(addRess, WriteType.Coils, false); | ||||
MessageLog.GetInstance.Show($"{num}号煮面口占用复位"); | |||||
} | } | ||||
MessageLog.GetInstance.Show($"{num}号煮面口占用复位"); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -32,15 +32,25 @@ namespace HBLConsole.Business.MessageServer | |||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 接收来自MQTT 推送的物料信息 | |||||
/// </summary> | |||||
/// <typeparam name="T"></typeparam> | |||||
/// <param name="batchingInfo"></param> | |||||
public override void GetBatchingInfo<T>(T batchingInfo) | public override void GetBatchingInfo<T>(T batchingInfo) | ||||
{ | { | ||||
if (batchingInfo == null) return; | if (batchingInfo == null) return; | ||||
if (batchingInfo is OrderMaterialDelivery BatchingInfos) | if (batchingInfo is OrderMaterialDelivery BatchingInfos) | ||||
{ | { | ||||
Json<BatchingInfoPar>.GetInstance.Base.orderMaterialDelivery = BatchingInfos; | Json<BatchingInfoPar>.GetInstance.Base.orderMaterialDelivery = BatchingInfos; | ||||
MessageLog.GetInstance.Show("收到推送的物料信息"); | |||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 通过接口获取物料信息 | |||||
/// </summary> | |||||
/// <param name="ClientId"></param> | |||||
public override void GetBatchingInfo(int ClientId) | public override void GetBatchingInfo(int ClientId) | ||||
{ | { | ||||
string result = string.Empty; | string result = string.Empty; | ||||
@@ -64,6 +74,11 @@ namespace HBLConsole.Business.MessageServer | |||||
}); | }); | ||||
} | } | ||||
/// <summary> | |||||
/// 接收MQTT 推送过来的辅料信息 | |||||
/// </summary> | |||||
/// <typeparam name="T"></typeparam> | |||||
/// <param name="recipeBomInfo"></param> | |||||
public override void GetRecipeBom<T>(T recipeBomInfo) | public override void GetRecipeBom<T>(T recipeBomInfo) | ||||
{ | { | ||||
if (recipeBomInfo == null) return; | if (recipeBomInfo == null) return; | ||||
@@ -74,6 +89,12 @@ namespace HBLConsole.Business.MessageServer | |||||
MessageLog.GetInstance.Show("接收到辅料信息"); | MessageLog.GetInstance.Show("接收到辅料信息"); | ||||
} | } | ||||
/// <summary> | |||||
/// 订单状态改变 | |||||
/// </summary> | |||||
/// <param name="subOrderId"></param> | |||||
/// <param name="status"></param> | |||||
/// <returns></returns> | |||||
public override bool OrderStatusChange(string subOrderId, ORDER_STATUS status) | public override bool OrderStatusChange(string subOrderId, ORDER_STATUS status) | ||||
{ | { | ||||
string result = string.Empty; | string result = string.Empty; | ||||
@@ -55,8 +55,6 @@ namespace HBLConsole.GVL | |||||
{ | { | ||||
ProcessData.GetInstance.Conditions[item].Add(new Condition() { propertyIllustrate = propertyIllustrate }); | ProcessData.GetInstance.Conditions[item].Add(new Condition() { propertyIllustrate = propertyIllustrate }); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -39,6 +39,7 @@ namespace HBLConsole.GVL | |||||
/// <summary> | /// <summary> | ||||
/// 允许运行 | /// 允许运行 | ||||
/// </summary> | /// </summary> | ||||
[Circuit(new string[] { "机器人取面", "取碗控制" }, "允许运行")] | |||||
public bool AllowRun { get; set; } | public bool AllowRun { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -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(); | |||||
} | |||||
} |
@@ -0,0 +1,16 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace HBLConsole.Model | |||||
{ | |||||
/// <summary> | |||||
/// 通讯参数 | |||||
/// </summary> | |||||
public class CommunicationPar | |||||
{ | |||||
public List<CommunicationSet> communicationSets = new List<CommunicationSet>(); | |||||
} | |||||
} |
@@ -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<object>((o) => { if (RemoveAction != null) RemoveAction(o); }); | |||||
} | |||||
public Action<object> 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; | |||||
/// <summary> | |||||
/// 是否激活 | |||||
/// </summary> | |||||
public bool IsActive { get { return _mIsActive; } set { _mIsActive = value; OnPropertyChanged(); } } | |||||
private bool _mIsActive = true; | |||||
/// <summary> | |||||
/// 新增设备名称 | |||||
/// </summary> | |||||
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } | |||||
private string _mDeviceName; | |||||
/// <summary> | |||||
/// 设备类型 | |||||
/// </summary> | |||||
public EDeviceType deviceType { get { return _mdeviceType; } set { _mdeviceType = value; OnPropertyChanged(); } } | |||||
private EDeviceType _mdeviceType; | |||||
public RelayCommand<object> RemoveCommand { get; set; } | |||||
} | |||||
} |
@@ -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<string> Ports { get; set; } = new ObservableCollection<string>(); | |||||
public ObservableCollection<string> BaudRates { get; set; } = new ObservableCollection<string>(); | |||||
public ObservableCollection<string> Paritys { get; set; } = new ObservableCollection<string>(); | |||||
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); | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// 站号,默认为 1 | |||||
/// </summary> | |||||
public int StationNo { get; set; } = 1; | |||||
} | |||||
} |
@@ -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(); | |||||
} | |||||
/// <summary> | |||||
/// 插槽号 | |||||
/// </summary> | |||||
public int Slot { get; set; } = 0; | |||||
/// <summary> | |||||
/// 机架号 | |||||
/// </summary> | |||||
public int Rack { get; set; } = 0; | |||||
/// <summary> | |||||
/// PLC 类型 | |||||
/// </summary> | |||||
public string PlcType { get; set; } | |||||
public ObservableCollection<string> PlcTypes { get; set; } = new ObservableCollection<string>(); | |||||
private void Init() | |||||
{ | |||||
PlcTypes.Clear(); | |||||
foreach (var item in Enum.GetNames(typeof(ESiemensPlcType))) | |||||
{ | |||||
PlcTypes.Add(item.Substring(1)); | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -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; } | |||||
} | |||||
} |
@@ -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 | |||||
{ | |||||
二进制, | |||||
十进制, | |||||
十六进制, | |||||
} | |||||
} |
@@ -0,0 +1,29 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace HBLConsole.Model | |||||
{ | |||||
/// <summary> | |||||
/// 报警类型 | |||||
/// </summary> | |||||
public enum EAlarmType | |||||
{ | |||||
/// <summary> | |||||
/// 无报警 | |||||
/// </summary> | |||||
无 = 1, | |||||
/// <summary> | |||||
/// 模拟量报警 | |||||
/// </summary> | |||||
模拟量报警 = 2, | |||||
/// <summary> | |||||
/// 离散量报警 | |||||
/// </summary> | |||||
离散量报警 = 3 | |||||
} | |||||
} |
@@ -0,0 +1,24 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace HBLConsole.Model | |||||
{ | |||||
/// <summary> | |||||
/// 沿触发类型枚举 | |||||
/// </summary> | |||||
public enum EAlongTriggerType | |||||
{ | |||||
/// <summary> | |||||
/// 下降沿触发 | |||||
/// </summary> | |||||
下降沿 = 1, | |||||
/// <summary> | |||||
/// 上升沿触发 | |||||
/// </summary> | |||||
上升沿 = 2 | |||||
} | |||||
} |
@@ -0,0 +1,19 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace HBLConsole.Model | |||||
{ | |||||
/// <summary> | |||||
/// 模拟量报警类型 | |||||
/// </summary> | |||||
public enum EAnalogAlarmType | |||||
{ | |||||
高高报警 = 1, | |||||
高报警 = 2, | |||||
低报警 = 3, | |||||
低低报警 = 4, | |||||
} | |||||
} |
@@ -0,0 +1,22 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace HBLConsole.Model | |||||
{ | |||||
/// <summary> | |||||
/// 数据类型枚举 | |||||
/// </summary> | |||||
public enum EDataType | |||||
{ | |||||
Bool = 1, | |||||
Byte = 2, | |||||
Int = 3, | |||||
Word = 4, | |||||
Dint = 5, | |||||
Dword = 6, | |||||
Float = 7 | |||||
} | |||||
} |
@@ -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, | |||||
} | |||||
} |
@@ -0,0 +1,39 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace HBLConsole.Model | |||||
{ | |||||
/// <summary> | |||||
/// 判断操作符枚举 | |||||
/// </summary> | |||||
public enum EOperatorType | |||||
{ | |||||
/// <summary> | |||||
/// 大于 | |||||
/// </summary> | |||||
P_GT = 1, | |||||
/// <summary> | |||||
/// 大于等于 | |||||
/// </summary> | |||||
P_GE = 2, | |||||
/// <summary> | |||||
/// 等于 | |||||
/// </summary> | |||||
P_EQ = 3, | |||||
/// <summary> | |||||
/// 不等于 | |||||
/// </summary> | |||||
P_NE = 4, | |||||
/// <summary> | |||||
/// 小于 | |||||
/// </summary> | |||||
P_LT = 5, | |||||
/// <summary> | |||||
/// 小于等于 | |||||
/// </summary> | |||||
P_LE = 6 | |||||
} | |||||
} |
@@ -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 | |||||
{ | |||||
无, | |||||
奇校验, | |||||
偶校验 | |||||
} | |||||
} |
@@ -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 | |||||
} | |||||
} |
@@ -6,6 +6,11 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | <PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | ||||
<PackageReference Include="System.IO.Ports" Version="6.0.0" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\HBLConsole.Interface\HBLConsole.Interface.csproj" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// 串口端口 | |||||
/// </summary> | |||||
public string ComSerialPort { get; set; } | |||||
/// <summary> | |||||
/// 波特率,110,300--115200(从300开始乘以2,直到结果等于115200) | |||||
/// </summary> | |||||
public string BaudRate { get; set; } = "9600"; | |||||
/// <summary> | |||||
/// 数据位,默认为 8 | |||||
/// </summary> | |||||
public int DataBit { get; set; } = 8; | |||||
/// <summary> | |||||
/// 停止位,默认为 1 | |||||
/// </summary> | |||||
public int StopBit { get; set; } = 1; | |||||
/// <summary> | |||||
/// 站号,默认为 1 | |||||
/// </summary> | |||||
public int StationNo { get; set; } = 1; | |||||
/// <summary> | |||||
/// 奇偶校验,无,奇校验,偶校验 | |||||
/// </summary> | |||||
public string Parity { get; set; } | |||||
} | |||||
} |
@@ -10,6 +10,7 @@ namespace HBLConsole.Model | |||||
{ | { | ||||
public int NoodleLoc { get; set; } | public int NoodleLoc { get; set; } | ||||
public int BowlLoc { get; set; } | public int BowlLoc { get; set; } | ||||
public bool IsEnableRandom { get; set; } | |||||
public bool NoodleIsEnableRandom { get; set; } | |||||
public bool BowlIsEnableRandom { get; set; } | |||||
} | } | ||||
} | } |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// IP地址 | |||||
/// </summary> | |||||
public string IP { get; set; } = "192.168.0.1"; | |||||
/// <summary> | |||||
/// 端口号,默认 102 | |||||
/// </summary> | |||||
public int PortNum { get; set; } = 102; | |||||
} | |||||
} |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// 显示/隐藏设置 | |||||
/// </summary> | |||||
public bool IsVisible { get; set; } = true; | |||||
} | |||||
} |
@@ -8,40 +8,6 @@ | |||||
d:DesignHeight="30" | d:DesignHeight="30" | ||||
d:DesignWidth="100" | d:DesignWidth="100" | ||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
<!--<UserControl.Resources> | |||||
<Style x:Key="BeveledButtonStyle" TargetType="Button"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="Width" Value="100" /> | |||||
<Setter Property="FontSize" Value="18" /> | |||||
<Setter Property="Foreground" Value="Aqua" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="Button"> | |||||
<Grid x:Name="gr"> | |||||
<ContentControl | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
Foreground="{TemplateBinding Foreground}" /> | |||||
<Polygon | |||||
x:Name="poly" | |||||
Points="0 0,80 0,100 30,20 30" | |||||
Stroke="#FF34F7F7" | |||||
StrokeThickness="2" /> | |||||
</Grid> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter TargetName="poly" Property="Fill" Value="#2234F7F7" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
</UserControl.Resources>--> | |||||
<Grid> | <Grid> | ||||
<Canvas | <Canvas | ||||
Name="canvas" | Name="canvas" | ||||
@@ -0,0 +1,20 @@ | |||||
<UserControl x:Class="HBLConsole.PryUserControl.Quadrilateral" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:HBLConsole.PryUserControl" | |||||
mc:Ignorable="d" | |||||
d:DesignHeight="30" | |||||
d:DesignWidth="100" | |||||
> | |||||
<Grid> | |||||
<Canvas | |||||
Name="canvas" | |||||
Width="auto" | |||||
Height="auto" | |||||
SizeChanged="Canvas_SizeChanged"> | |||||
<Polygon x:Name="poly" /> | |||||
</Canvas> | |||||
</Grid> | |||||
</UserControl> |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// Quadrilateral.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class Quadrilateral : UserControl | |||||
{ | |||||
public Quadrilateral() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
public static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |||||
{ | |||||
(d as Quadrilateral).Refresh(); | |||||
} | |||||
/// <summary> | |||||
/// 依赖属性更改的委托 | |||||
/// </summary> | |||||
private void Refresh() | |||||
{ | |||||
this.poly.Fill = FillColor; | |||||
this.poly.StrokeThickness = StrokeThickness; | |||||
this.poly.Stroke = Stroke; | |||||
} | |||||
#region FillColor:填充颜色 依赖属性 | |||||
/// <summary> | |||||
/// 填充颜色 | |||||
/// </summary> | |||||
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 外边线宽度 | |||||
/// <summary> | |||||
/// 外边线宽度 | |||||
/// </summary> | |||||
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 外边框颜色 | |||||
/// <summary> | |||||
/// 外边框颜色 | |||||
/// </summary> | |||||
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; | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,27 @@ | |||||
<UserControl | |||||
x:Class="HBLConsole.PryUserControl.TitleTextBlock" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:HBLConsole.PryUserControl" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
d:DesignHeight="30" | |||||
d:DesignWidth="100" | |||||
mc:Ignorable="d"> | |||||
<Grid> | |||||
<Canvas | |||||
Name="canvas" | |||||
Width="auto" | |||||
Height="auto" | |||||
SizeChanged="Canvas_SizeChanged"> | |||||
<Polygon x:Name="poly"> | |||||
<Polygon.Fill> | |||||
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5"> | |||||
<GradientStop Color="#ff1247EC" /> | |||||
<GradientStop Offset="1" Color="#111247EC" /> | |||||
</LinearGradientBrush> | |||||
</Polygon.Fill> | |||||
</Polygon> | |||||
</Canvas> | |||||
</Grid> | |||||
</UserControl> |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// TitleTextBlock.xaml 的交互逻辑 | |||||
/// </summary> | |||||
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; | |||||
} | |||||
} | |||||
} |
@@ -16,12 +16,23 @@ namespace HBLConsole.Service | |||||
private static ConcurrentDictionary<string, Delegation> actions = new ConcurrentDictionary<string, Delegation>(); | private static ConcurrentDictionary<string, Delegation> actions = new ConcurrentDictionary<string, Delegation>(); | ||||
private static ConcurrentDictionary<string, ActionManagerment> actionManagers = new ConcurrentDictionary<string, ActionManagerment>(); | |||||
//private static ConcurrentDictionary<string, ActionManagerment> actionManagers = new ConcurrentDictionary<string, ActionManagerment>(); | |||||
static readonly object SendLock = new object(); | static readonly object SendLock = new object(); | ||||
static readonly object SendParLock = new object(); | static readonly object SendParLock = new object(); | ||||
static readonly object RegisterLock = new object(); | static readonly object RegisterLock = new object(); | ||||
/// <summary> | |||||
/// 注销委托 | |||||
/// </summary> | |||||
/// <param name="name"></param> | |||||
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) | public void Send(string name, object token, Action action = null) | ||||
{ | { | ||||
@@ -48,5 +48,17 @@ namespace HBLConsole.Service | |||||
} | } | ||||
public void ReadIntres() | |||||
{ | |||||
if (File.Exists(path)) | |||||
{ | |||||
string JsonString = File.ReadAllText(path); | |||||
var result = JsonConvert.DeserializeObject<T>(JsonString); | |||||
if (result != null) { Base = result; } | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -11,7 +11,7 @@ | |||||
<!--客户端ID--> | <!--客户端ID--> | ||||
<!--MorkD = 2,MorkS 且时且多 = 8,MorkS 珠海 = 9,冰淇淋 = 4,咖啡机 = 13--> | <!--MorkD = 2,MorkS 且时且多 = 8,MorkS 珠海 = 9,冰淇淋 = 4,咖啡机 = 13--> | ||||
<add key="ClientId" value="8"/> | |||||
<add key="ClientId" value="2"/> | |||||
</appSettings> | </appSettings> |
@@ -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(); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,196 @@ | |||||
<Window | |||||
x:Class="HBLConsole.DialogWindow.View.DeviceManagermentSetView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:HBLConsole.DialogWindow.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:vm="clr-namespace:HBLConsole.DialogWindow.ViewModel" | |||||
Title="DeviceManagermentSetView" | |||||
Width="400" | |||||
Height="275" | |||||
AllowsTransparency="True" | |||||
Background="{x:Null}" | |||||
Opacity="0.8" | |||||
Topmost="True" | |||||
WindowStartupLocation="CenterScreen" | |||||
WindowStyle="None" | |||||
mc:Ignorable="d"> | |||||
<Window.DataContext> | |||||
<vm:DeviceManagermentSetViewModel /> | |||||
</Window.DataContext> | |||||
<Window.Resources> | |||||
<ResourceDictionary Source="../../Resources/ResourceDictionarys/BasicStyle.xaml"> | |||||
<ResourceDictionary.MergedDictionaries> | |||||
<ResourceDictionary> | |||||
<Style x:Key="buttonStyle" TargetType="Button"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="Width" Value="100" /> | |||||
<Setter Property="FontSize" Value="18" /> | |||||
<Setter Property="Foreground" Value="Aqua" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="Button"> | |||||
<Grid x:Name="gr"> | |||||
<ContentControl | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
Foreground="{TemplateBinding Foreground}" /> | |||||
<Polygon | |||||
x:Name="poly" | |||||
Points="0 0,80 0,100 30,20 30" | |||||
Stroke="#FF34F7F7" | |||||
StrokeThickness="2" /> | |||||
</Grid> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter TargetName="poly" Property="Fill" Value="#2234F7F7" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
</ResourceDictionary> | |||||
</ResourceDictionary.MergedDictionaries> | |||||
</ResourceDictionary> | |||||
</Window.Resources> | |||||
<Grid Background="#103153"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="35" /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<!--#region 标题栏设置--> | |||||
<Border | |||||
x:Name="MoveBorder" | |||||
Height="35" | |||||
VerticalAlignment="Top" | |||||
Background="#0C2349" | |||||
BorderBrush="#55ffffff" | |||||
BorderThickness="0,0,0,1"> | |||||
<StackPanel Orientation="Horizontal"> | |||||
<Image Margin="15,5,0,5" Source="../../Resources/Images/hbl.png" /> | |||||
<TextBlock | |||||
Name="tbTitle" | |||||
Margin="10,0" | |||||
HorizontalAlignment="Left" | |||||
VerticalAlignment="Center" | |||||
FontSize="18" | |||||
Foreground="White" | |||||
Text="设备管理" /> | |||||
</StackPanel> | |||||
</Border> | |||||
<UniformGrid | |||||
Width="150" | |||||
Height="30" | |||||
HorizontalAlignment="Right" | |||||
Columns="3"> | |||||
<Button | |||||
Name="ButMin" | |||||
Content="" | |||||
Style="{StaticResource TitleBarStyle}" | |||||
Visibility="Hidden" /> | |||||
<Button | |||||
Name="ButMax" | |||||
Content="" | |||||
Style="{StaticResource TitleBarStyle}" | |||||
Visibility="Hidden" /> | |||||
<Button | |||||
Name="ButClose" | |||||
Content="" | |||||
FontSize="30" | |||||
Style="{StaticResource TitleBarStyle}" /> | |||||
</UniformGrid> | |||||
<!--#endregion--> | |||||
<!--#region 内容显示区--> | |||||
<Grid Grid.Row="1" Margin="20"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock | |||||
HorizontalAlignment="Right" | |||||
VerticalAlignment="Center" | |||||
FontFamily="楷体" | |||||
FontSize="20" | |||||
Foreground="#FF34F7F7" | |||||
Text="请选择设备类型:" /> | |||||
<ComboBox | |||||
Grid.Column="1" | |||||
VerticalAlignment="Center" | |||||
BorderBrush="#FF23CACA" | |||||
BorderThickness="1" | |||||
FontFamily="楷体" | |||||
FontSize="20" | |||||
Foreground="#ff23caca" | |||||
IsEditable="False" | |||||
ItemsSource="{Binding DeviceType}" | |||||
SelectedIndex="0" | |||||
Style="{StaticResource ComboBoxStyle}" | |||||
Text="{Binding devcieManagerResult.DeviceType}" /> | |||||
<TextBlock | |||||
Grid.Row="1" | |||||
HorizontalAlignment="Right" | |||||
VerticalAlignment="Center" | |||||
FontFamily="楷体" | |||||
FontSize="20" | |||||
Foreground="#FF34F7F7" | |||||
Text="请输入设备名称:" /> | |||||
<TextBox | |||||
Grid.Row="1" | |||||
Grid.Column="1" | |||||
Margin="0,10" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Text="{Binding devcieManagerResult.DeviceName}" /> | |||||
<TextBlock | |||||
TextWrapping="Wrap" | |||||
Grid.Row="2" | |||||
Grid.ColumnSpan="2" | |||||
Margin="20,0,0,0" | |||||
VerticalAlignment="Center" | |||||
FontFamily="楷体" | |||||
FontSize="16" | |||||
Foreground="#FFE2415C" | |||||
Text="{Binding LogInfo}" /> | |||||
<Button | |||||
Grid.Row="3" | |||||
Margin="20,10" | |||||
Command="{Binding CancelCommand}" | |||||
Content="取消" | |||||
Style="{StaticResource buttonStyle}" /> | |||||
<Button | |||||
Grid.Row="3" | |||||
Grid.Column="1" | |||||
Margin="20,10" | |||||
Command="{Binding ConfirmCommand}" | |||||
Content="确认" | |||||
Style="{StaticResource buttonStyle}" /> | |||||
</Grid> | |||||
<!--#endregion--> | |||||
</Grid> | |||||
</Window> |
@@ -0,0 +1,84 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Diagnostics; | |||||
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; | |||||
using Microsoft.Toolkit.Mvvm.Messaging; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
using HBLConsole.Model; | |||||
using HBLConsole.Service; | |||||
namespace HBLConsole.DialogWindow.View | |||||
{ | |||||
/// <summary> | |||||
/// DeviceManagermentSetView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class DeviceManagermentSetView : Window | |||||
{ | |||||
public DeviceManagermentSetView() | |||||
{ | |||||
InitializeComponent(); | |||||
this.MoveBorder.MouseLeftButtonDown += (o, e) => { this.DragMove(); }; | |||||
this.ButMin.Click += (o, e) => { this.WindowState = WindowState.Minimized; }; | |||||
this.ButMax.Click += (o, e) => { this.WindowState = this.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; }; | |||||
this.ButClose.Click += (o, e) => { this.DialogResult = false; }; | |||||
this.MaxWidth = SystemParameters.WorkArea.Width; | |||||
this.MaxHeight = SystemParameters.WorkArea.Height; | |||||
ActionManagerment.GetInstance.Register(new Action<object>((s) => | |||||
{ | |||||
this.Tag = s; | |||||
this.DialogResult = false; | |||||
ActionManagerment.GetInstance.LogOut("Cancel"); | |||||
this.Close(); | |||||
}), "Cancel"); | |||||
ActionManagerment.GetInstance.Register(new Action<object>((s) => | |||||
{ | |||||
this.Tag = s; | |||||
this.DialogResult = true; | |||||
ActionManagerment.GetInstance.LogOut("Confirm"); | |||||
this.Close(); | |||||
}), "Confirm"); | |||||
//DelegationNotifi.GetInstance.Cancel = new Action<DeviceManagermentResult>((s) => | |||||
//{ | |||||
// this.Tag = s; | |||||
// this.DialogResult = false; | |||||
// DelegationNotifi.GetInstance.Cancel = null; | |||||
// this.Close(); | |||||
//}); | |||||
//DelegationNotifi.GetInstance.Confirm = new Action<DeviceManagermentResult>((s) => | |||||
//{ | |||||
// this.Tag = s; | |||||
// this.DialogResult = true; | |||||
// DelegationNotifi.GetInstance.Cancel = null; | |||||
// this.Close(); | |||||
//}); | |||||
} | |||||
//private void ThisDialogResult(DeviceManagermentResult s, bool result) | |||||
//{ | |||||
// this.Tag = s; | |||||
// this.DialogResult = result; | |||||
// //DelegationNotifi.GetInstance.Cancel = null; | |||||
// ActionManagerment.GetInstance.LogOut("Cancel"); | |||||
// this.Close(); | |||||
//} | |||||
} | |||||
} |
@@ -0,0 +1,68 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
using System.Collections.Concurrent; | |||||
using System.Collections.ObjectModel; | |||||
using Microsoft.Toolkit.Mvvm.Input; | |||||
using Microsoft.Toolkit.Mvvm.Messaging; | |||||
using System.Diagnostics; | |||||
using HBLConsole.Model; | |||||
using HBLConsole.Service; | |||||
namespace HBLConsole.DialogWindow.ViewModel | |||||
{ | |||||
public class DeviceManagermentSetViewModel : ObservableObject | |||||
{ | |||||
public DeviceManagermentSetViewModel() | |||||
{ | |||||
Init(); | |||||
CancelCommand = new RelayCommand(() => | |||||
{ | |||||
ActionManagerment.GetInstance.Send("Cancel", devcieManagerResult); | |||||
}); | |||||
ConfirmCommand = new RelayCommand(() => | |||||
{ | |||||
var res = ActionManagerment.GetInstance.SendResult("AddDeviceVerify", devcieManagerResult); | |||||
if (res != null) | |||||
{ | |||||
if (res is bool blen) | |||||
{ | |||||
if (blen) | |||||
{ | |||||
ActionManagerment.GetInstance.Send("Confirm", devcieManagerResult); | |||||
} | |||||
else | |||||
{ | |||||
LogInfo = $"警告:设备【{devcieManagerResult.DeviceName}】已存在,请重试"; | |||||
} | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
public ObservableCollection<string> DeviceType { get; set; } = new ObservableCollection<string>(); | |||||
public RelayCommand CancelCommand { get; set; } | |||||
public RelayCommand ConfirmCommand { get; set; } | |||||
private void Init() | |||||
{ | |||||
DeviceType.Clear(); | |||||
foreach (var item in Enum.GetNames(typeof(EDeviceType))) { DeviceType.Add(item); } | |||||
} | |||||
public DeviceManagermentResult devcieManagerResult { get { return _mdevcieManagerResult; } set { _mdevcieManagerResult = value; OnPropertyChanged(); } } | |||||
private DeviceManagermentResult _mdevcieManagerResult = new DeviceManagermentResult(); | |||||
public string LogInfo { get { return _mLogInfo; } set { _mLogInfo = value; OnPropertyChanged(); } } | |||||
private string _mLogInfo; | |||||
} | |||||
} |
@@ -191,12 +191,6 @@ | |||||
<Resource Include="Resources\Images\黑菠萝科技.png" /> | <Resource Include="Resources\Images\黑菠萝科技.png" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | |||||
<Folder Include="DialogWindow\View\" /> | |||||
<Folder Include="DialogWindow\ViewModel\" /> | |||||
<Folder Include="Converter\" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\HBLConsole.MainConsole\HBLConsole.MainConsole.csproj" /> | <ProjectReference Include="..\HBLConsole.MainConsole\HBLConsole.MainConsole.csproj" /> | ||||
<ProjectReference Include="..\HBLConsole.Model\HBLConsole.Model.csproj" /> | <ProjectReference Include="..\HBLConsole.Model\HBLConsole.Model.csproj" /> | ||||
@@ -4,10 +4,15 @@ | |||||
xmlns:con="clr-namespace:HBLConsole.Converter" | xmlns:con="clr-namespace:HBLConsole.Converter" | ||||
xmlns:pry="clr-namespace:HBLConsole.PryUserControl;assembly=HBLConsole.PryUserControl"> | xmlns:pry="clr-namespace:HBLConsole.PryUserControl;assembly=HBLConsole.PryUserControl"> | ||||
<!--#region 全局样式--> | |||||
<SolidColorBrush x:Key="TextBlockForeground" Color="#9934F7F7" /> | |||||
<!--#endregion--> | |||||
<!--#region 转换器--> | <!--#region 转换器--> | ||||
<con:ColorConverter x:Key="ColorConverter" /> | <con:ColorConverter x:Key="ColorConverter" /> | ||||
<!--<con:ColorConverter x:Key="ColorConverter" />--> | <!--<con:ColorConverter x:Key="ColorConverter" />--> | ||||
<con:TextConverter x:Key="TextConverter" /> | <con:TextConverter x:Key="TextConverter" /> | ||||
<con:VisibleConvert x:Key="VisibleConvert" /> | |||||
<!--#endregion--> | <!--#endregion--> | ||||
<!--#region 右斜边按钮--> | <!--#region 右斜边按钮--> | ||||
@@ -62,7 +67,7 @@ | |||||
<Setter Property="Template"> | <Setter Property="Template"> | ||||
<Setter.Value> | <Setter.Value> | ||||
<ControlTemplate TargetType="{x:Type RadioButton}"> | <ControlTemplate TargetType="{x:Type RadioButton}"> | ||||
<Grid x:Name="gr" SnapsToDevicePixels="True"> | |||||
<Grid SnapsToDevicePixels="True"> | |||||
<pry:BeveledButton | <pry:BeveledButton | ||||
x:Name="bb" | x:Name="bb" | ||||
@@ -460,4 +465,462 @@ | |||||
</Style> | </Style> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
<!--#region TextBox 样式--> | |||||
<Style x:Key="InputTextboxStyle" TargetType="TextBox"> | |||||
<Setter Property="Margin" Value="3,0,0,0" /> | |||||
<Setter Property="BorderThickness" Value="0" /> | |||||
<Setter Property="FontSize" Value="14" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
</Style> | |||||
<!--#endregion--> | |||||
<!--#region 新建按钮--> | |||||
<ControlTemplate x:Key="NewButtonTemp" TargetType="Button"> | |||||
<Border | |||||
x:Name="br" | |||||
Background="Transparent" | |||||
BorderBrush="#FF19B7EC" | |||||
BorderThickness="2"> | |||||
<StackPanel | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Orientation="Horizontal"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontFamily="../Fonts/#iconfont" | |||||
Text="" /> | |||||
<ContentControl | |||||
Margin="10,0,5,0" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
Foreground="{TemplateBinding Foreground}" /> | |||||
</StackPanel> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||||
</Trigger> | |||||
<Trigger Property="IsPressed" Value="true"> | |||||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
<!--#endregion--> | |||||
<!--#region 保存按钮--> | |||||
<ControlTemplate x:Key="SaveButtonTemp" TargetType="Button"> | |||||
<Border | |||||
x:Name="br" | |||||
Background="Transparent" | |||||
BorderBrush="#FF19B7EC" | |||||
BorderThickness="2"> | |||||
<StackPanel | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Orientation="Horizontal"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontFamily="../Fonts/#iconfont" | |||||
FontSize="20" | |||||
Text="" /> | |||||
<ContentControl | |||||
Margin="10,0,5,0" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
Foreground="{TemplateBinding Foreground}" /> | |||||
</StackPanel> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||||
</Trigger> | |||||
<Trigger Property="IsPressed" Value="true"> | |||||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
<!--#endregion--> | |||||
<!--#region 取消按钮--> | |||||
<ControlTemplate x:Key="CancelButtonTemp" TargetType="Button"> | |||||
<Border | |||||
x:Name="br" | |||||
Background="Transparent" | |||||
BorderBrush="#FF19B7EC" | |||||
BorderThickness="2"> | |||||
<StackPanel | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Orientation="Horizontal"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontFamily="../Fonts/#iconfont" | |||||
FontSize="20" | |||||
Text="" /> | |||||
<ContentControl | |||||
Margin="10,0,5,0" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
Foreground="{TemplateBinding Foreground}" /> | |||||
</StackPanel> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||||
</Trigger> | |||||
<Trigger Property="IsPressed" Value="true"> | |||||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
<!--#endregion--> | |||||
<!--#region 确认按钮--> | |||||
<ControlTemplate x:Key="ConfirmButtonTemp" TargetType="Button"> | |||||
<Border | |||||
x:Name="br" | |||||
Background="Transparent" | |||||
BorderBrush="#FF19B7EC" | |||||
BorderThickness="2"> | |||||
<StackPanel | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Orientation="Horizontal"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontFamily="../Fonts/#iconfont" | |||||
FontSize="20" | |||||
Text="" /> | |||||
<ContentControl | |||||
Margin="10,0,5,0" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
Foreground="{TemplateBinding Foreground}" /> | |||||
</StackPanel> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||||
</Trigger> | |||||
<Trigger Property="IsPressed" Value="true"> | |||||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
<!--#endregion--> | |||||
<!--#region 移除按钮样式--> | |||||
<ControlTemplate x:Key="ButtonTemplate" TargetType="Button"> | |||||
<Border | |||||
x:Name="br" | |||||
Background="Transparent" | |||||
BorderBrush="#FFDE7889" | |||||
BorderThickness="2" | |||||
CornerRadius="0"> | |||||
<StackPanel | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Orientation="Horizontal"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontFamily="../Fonts/#iconfont" | |||||
FontSize="20" | |||||
Text="" /> | |||||
<ContentControl | |||||
Margin="10,0,5,0" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
Foreground="{TemplateBinding Foreground}" /> | |||||
</StackPanel> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter TargetName="br" Property="Background" Value="#22DE7889" /> | |||||
</Trigger> | |||||
<Trigger Property="IsPressed" Value="true"> | |||||
<Setter TargetName="br" Property="Background" Value="#22DE7889" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
<!--#endregion--> | |||||
<!--#region 编辑开关 ToggleButton 样式--> | |||||
<Style x:Key="EditToggleButtonStyle" TargetType="{x:Type ToggleButton}"> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="{x:Type ToggleButton}"> | |||||
<Grid> | |||||
<Border | |||||
x:Name="border2" | |||||
Width="{TemplateBinding Width}" | |||||
Height="{TemplateBinding Height}" | |||||
Margin="{TemplateBinding Padding}" | |||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" | |||||
Background="Transparent"> | |||||
<ContentPresenter | |||||
Margin="{TemplateBinding Padding}" | |||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" | |||||
RecognizesAccessKey="True" | |||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |||||
</Border> | |||||
</Grid> | |||||
<ControlTemplate.Triggers> | |||||
<!--<Trigger Property="IsPressed" Value="true"> | |||||
<Setter Property="Background" Value="#FFd2e7f4" /> | |||||
</Trigger>--> | |||||
<!-- 控件选中 --> | |||||
<Trigger Property="IsChecked" Value="true"> | |||||
<Setter Property="Foreground" Value="#ff1002E9" /> | |||||
</Trigger> | |||||
<!-- 控件未选中 --> | |||||
<Trigger Property="IsChecked" Value="false"> | |||||
<Setter Property="Foreground" Value="#ff2AB2E7" /> | |||||
</Trigger> | |||||
<!-- 鼠标进入 --> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter TargetName="border2" Property="Background" Value="#332AB2E7" /> | |||||
</Trigger> | |||||
<!-- 控件禁用 --> | |||||
<Trigger Property="IsEnabled" Value="false"> | |||||
<Setter Property="Foreground" Value="#662AB2E7" /> | |||||
</Trigger> | |||||
<!-- 控件启用 --> | |||||
<Trigger Property="IsEnabled" Value="True"> | |||||
<Setter Property="Foreground" Value="#ff2AB2E7" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
<!--#endregion--> | |||||
<!--#region ComboBox 样式--> | |||||
<!-- ComBoBox项选中背景色 --> | |||||
<SolidColorBrush x:Key="ComboBoxSelectdBackground" Color="#AA3ba7f2" /> | |||||
<!-- ComBoBox项鼠标经过背景色 --> | |||||
<SolidColorBrush x:Key="ComboBoxMouseOverBackground" Color="#553ba7f2" /> | |||||
<!-- ComBoBox项选中前景色 --> | |||||
<SolidColorBrush x:Key="ComboBoxSelectedForeground" Color="#DDD" /> | |||||
<!-- ComBoBox项鼠标经过前景色 --> | |||||
<SolidColorBrush x:Key="ComboBoxMouseOverForegrond" Color="#DDD" /> | |||||
<ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}"> | |||||
<Grid Height="25" HorizontalAlignment="Stretch"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="*" /> | |||||
<ColumnDefinition Width="30" /> | |||||
</Grid.ColumnDefinitions> | |||||
<Border | |||||
Grid.ColumnSpan="2" | |||||
Background="White" | |||||
Opacity="0" /> | |||||
<TextBlock | |||||
Grid.Column="1" | |||||
Margin="0,0,5,0" | |||||
HorizontalAlignment="Right" | |||||
VerticalAlignment="Center" | |||||
FontFamily="../Fonts/#iconfont" | |||||
FontSize="14" | |||||
Foreground="#FF23CACA" | |||||
Text="" /> | |||||
<!--<Path | |||||
x:Name="Arrow" | |||||
Grid.Column="1" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Data="M 0 0 6 6 12 0 Z" | |||||
Fill="#aa20FDFA" | |||||
Stretch="None"> | |||||
<Path.Effect> | |||||
<DropShadowEffect | |||||
BlurRadius="10" | |||||
Direction="90" | |||||
Opacity="1" | |||||
RenderingBias="Quality" | |||||
ShadowDepth="0" | |||||
Color="#aa20FDFA" /> | |||||
</Path.Effect> | |||||
</Path>--> | |||||
</Grid> | |||||
<!--<ControlTemplate.Triggers> | |||||
<Trigger Property="IsChecked" Value="true"> | |||||
<Setter TargetName="Arrow" Property="RenderTransform"> | |||||
<Setter.Value> | |||||
<RotateTransform Angle="180" CenterX="6" CenterY="3" /> | |||||
</Setter.Value> | |||||
</Setter> | |||||
<Setter TargetName="Arrow" Property="Margin" Value="0,0,0,2" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers>--> | |||||
</ControlTemplate> | |||||
<Style x:Key="ComboBoxStyle" TargetType="{x:Type ComboBox}"> | |||||
<Setter Property="BorderThickness" Value="0" /> | |||||
<Setter Property="ItemContainerStyle"> | |||||
<Setter.Value> | |||||
<Style TargetType="ComboBoxItem"> | |||||
<Setter Property="Height" Value="25" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="{x:Type ComboBoxItem}"> | |||||
<Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"> | |||||
<Border x:Name="_borderbg" Background="Transparent" /> | |||||
<TextBlock | |||||
x:Name="_txt" | |||||
Margin="3,0,3,0" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Foreground="#DDD" | |||||
Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" /> | |||||
<Border | |||||
x:Name="_border" | |||||
Background="#103153" | |||||
Opacity="0" /> | |||||
</Grid> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsSelected" Value="true"> | |||||
<Setter TargetName="_txt" Property="Foreground" Value="{StaticResource ComboBoxSelectedForeground}" /> | |||||
<Setter TargetName="_borderbg" Property="Background" Value="{StaticResource ComboBoxSelectdBackground}" /> | |||||
</Trigger> | |||||
<MultiTrigger> | |||||
<MultiTrigger.Conditions> | |||||
<Condition Property="IsSelected" Value="false" /> | |||||
<Condition Property="IsMouseOver" Value="true" /> | |||||
</MultiTrigger.Conditions> | |||||
<Setter TargetName="_borderbg" Property="Background" Value="{StaticResource ComboBoxMouseOverBackground}" /> | |||||
<Setter TargetName="_txt" Property="Foreground" Value="{StaticResource ComboBoxMouseOverForegrond}" /> | |||||
</MultiTrigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
</Setter.Value> | |||||
</Setter> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="{x:Type ComboBox}"> | |||||
<Grid> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.3*" MaxWidth="30" /> | |||||
</Grid.ColumnDefinitions> | |||||
<Border | |||||
x:Name="_prybr" | |||||
Grid.Column="0" | |||||
Grid.ColumnSpan="2" | |||||
BorderBrush="{TemplateBinding BorderBrush}" | |||||
BorderThickness="{TemplateBinding BorderThickness}" | |||||
CornerRadius="0" /> | |||||
<ContentPresenter | |||||
x:Name="ContentSite" | |||||
Margin="3,3,0,3" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding SelectionBoxItem}" | |||||
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" | |||||
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" | |||||
IsHitTestVisible="False" /> | |||||
<!-- ToggleButton 已数据绑定到 ComboBox 本身以切换 IsDropDownOpen --> | |||||
<ToggleButton | |||||
x:Name="ToggleButton" | |||||
Grid.Column="0" | |||||
Grid.ColumnSpan="2" | |||||
ClickMode="Press" | |||||
Focusable="false" | |||||
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" | |||||
Template="{StaticResource ComboBoxToggleButton}" /> | |||||
<!-- 必须将 TextBox 命名为 PART_EditableTextBox,否则 ComboBox 将无法识别它 --> | |||||
<TextBox | |||||
x:Name="PART_EditableTextBox" | |||||
Margin="2,0,0,0" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderThickness="0" | |||||
Focusable="True" | |||||
IsReadOnly="{TemplateBinding IsReadOnly}" | |||||
Visibility="Hidden" /> | |||||
<!-- Popup 可显示 ComboBox 中的项列表。IsOpen 已数据绑定到通过 ComboBoxToggleButton 来切换的 IsDropDownOpen --> | |||||
<Popup | |||||
x:Name="Popup" | |||||
AllowsTransparency="True" | |||||
Focusable="False" | |||||
IsOpen="{TemplateBinding IsDropDownOpen}" | |||||
Placement="Bottom" | |||||
PopupAnimation="Slide"> | |||||
<Grid | |||||
x:Name="DropDown" | |||||
MinWidth="{TemplateBinding ActualWidth}" | |||||
MaxHeight="150" | |||||
SnapsToDevicePixels="True"> | |||||
<Border | |||||
x:Name="DropDownBorder" | |||||
BorderBrush="#3ba7f2" | |||||
BorderThickness="0" /> | |||||
<ScrollViewer | |||||
Margin="1" | |||||
CanContentScroll="True" | |||||
HorizontalScrollBarVisibility="Auto" | |||||
SnapsToDevicePixels="True" | |||||
VerticalScrollBarVisibility="Auto"> | |||||
<!-- StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True --> | |||||
<!-- 一下可以设置列表背景色 --> | |||||
<StackPanel | |||||
Background="#103153" | |||||
IsItemsHost="True" | |||||
KeyboardNavigation.DirectionalNavigation="Contained" /> | |||||
</ScrollViewer> | |||||
</Grid> | |||||
</Popup> | |||||
</Grid> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsEditable" Value="true"> | |||||
<Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible" /> | |||||
</Trigger> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter TargetName="_prybr" Property="BorderBrush" Value="#aa3ba7f2" /> | |||||
<!--<Setter Property="Background" Value="#553ba7f2" TargetName="_prybr"/>--> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
<!--#endregion--> | |||||
</ResourceDictionary> | </ResourceDictionary> |
@@ -178,6 +178,18 @@ | |||||
Style="{StaticResource TextBoxStyle}" | Style="{StaticResource TextBoxStyle}" | ||||
Text="{Binding NoodleLoc}" /> | Text="{Binding NoodleLoc}" /> | ||||
<CheckBox | |||||
Grid.Row="2" | |||||
Grid.Column="7" | |||||
Height="20" | |||||
VerticalAlignment="Center" | |||||
Background="#FF2AB2E7" | |||||
Content="启用随机数" | |||||
FontSize="16" | |||||
Foreground="#ddd" | |||||
IsChecked="{Binding IsEnableRandom}" | |||||
Template="{StaticResource CbTemplate}" /> | |||||
<TextBlock | <TextBlock | ||||
Margin="10,0,0,0" | Margin="10,0,0,0" | ||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
@@ -185,6 +197,7 @@ | |||||
Foreground="#00c2f4" | Foreground="#00c2f4" | ||||
Text="取碗位置:" /> | Text="取碗位置:" /> | ||||
<TextBox | <TextBox | ||||
Margin="0,0,20,0" | Margin="0,0,20,0" | ||||
Style="{StaticResource TextBoxStyle}" | Style="{StaticResource TextBoxStyle}" | ||||
@@ -194,14 +207,13 @@ | |||||
Grid.Row="2" | Grid.Row="2" | ||||
Grid.Column="7" | Grid.Column="7" | ||||
Height="20" | Height="20" | ||||
Margin="10" | |||||
HorizontalAlignment="Right" | |||||
Margin="0,0,20,0" | |||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
Background="#FF2AB2E7" | Background="#FF2AB2E7" | ||||
Content="启用随机数" | Content="启用随机数" | ||||
FontSize="16" | FontSize="16" | ||||
Foreground="#ddd" | Foreground="#ddd" | ||||
IsChecked="{Binding IsEnableRandom}" | |||||
IsChecked="{Binding BowlIsEnableRandom}" | |||||
Template="{StaticResource CbTemplate}" /> | Template="{StaticResource CbTemplate}" /> | ||||
<Button | <Button | ||||
@@ -222,6 +234,7 @@ | |||||
Margin="10,0,0,0" | Margin="10,0,0,0" | ||||
HorizontalAlignment="Center" | HorizontalAlignment="Center" | ||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
FontSize="16" | |||||
Foreground="Red" | Foreground="Red" | ||||
Text="注意:取面位置范围是:1 -- 5, 取碗位置范围是:10 -- 11" /> | Text="注意:取面位置范围是:1 -- 5, 取碗位置范围是:10 -- 11" /> | ||||
</StackPanel> | </StackPanel> | ||||
@@ -286,27 +299,6 @@ | |||||
</DataTemplate> | </DataTemplate> | ||||
</ListBox.ItemTemplate> | </ListBox.ItemTemplate> | ||||
</ListBox> | </ListBox> | ||||
<!--<ListBox | |||||
Margin="0,3,0,0" | |||||
Background="Transparent" | |||||
BorderThickness="0" | |||||
ItemsSource="{Binding Conditions}"> | |||||
<ListBox.ItemsPanel> | |||||
<ItemsPanelTemplate> | |||||
<VirtualizingStackPanel Orientation="Horizontal" /> | |||||
</ItemsPanelTemplate> | |||||
</ListBox.ItemsPanel> | |||||
<ListBox.ItemTemplate> | |||||
<DataTemplate> | |||||
<ToggleButton | |||||
Content="{Binding ConditionName}" | |||||
IsChecked="{Binding ConditionMet}" | |||||
Style="{StaticResource ToggleButStyle}" /> | |||||
</DataTemplate> | |||||
</ListBox.ItemTemplate> | |||||
</ListBox>--> | |||||
</StackPanel> | </StackPanel> | ||||
</DataTemplate> | </DataTemplate> | ||||
</ItemsControl.ItemTemplate> | </ItemsControl.ItemTemplate> | ||||
@@ -0,0 +1,489 @@ | |||||
<UserControl | |||||
x:Class="HBLConsole.View.DeviceManageView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:HBLConsole.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:pry="clr-namespace:HBLConsole.PryUserControl;assembly=HBLConsole.PryUserControl" | |||||
xmlns:vm="clr-namespace:HBLConsole.ViewModel" | |||||
d:DesignHeight="450" | |||||
d:DesignWidth="800" | |||||
mc:Ignorable="d"> | |||||
<UserControl.DataContext> | |||||
<vm:DeviceManageViewModel /> | |||||
</UserControl.DataContext> | |||||
<UserControl.Resources> | |||||
<ResourceDictionary Source="../Resources/ResourceDictionarys/BasicStyle.xaml"> | |||||
<ResourceDictionary.MergedDictionaries> | |||||
<ResourceDictionary> | |||||
<Style x:Key="TextBlockStyle" TargetType="TextBlock"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="FontSize" Value="18" /> | |||||
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||||
</Style> | |||||
<Style x:Key="TextBoxStyle" TargetType="TextBox"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="FontSize" Value="22" /> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" /> | |||||
<Setter Property="BorderBrush" Value="#FF23CACA" /> | |||||
<Setter Property="CaretBrush" Value="Aqua" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
</Style> | |||||
<Style x:Key="buttonStyle" TargetType="Button"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="FontSize" Value="20" /> | |||||
<Setter Property="Foreground" Value="#FFDE7889" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="Button"> | |||||
<Grid> | |||||
<ContentControl | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
Foreground="{TemplateBinding Foreground}" /> | |||||
<pry:Quadrilateral | |||||
x:Name="poly" | |||||
Stroke="#FFDE7889" | |||||
StrokeThickness="2" /> | |||||
</Grid> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter TargetName="poly" Property="FillColor" Value="#22DE7889" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
</ResourceDictionary> | |||||
</ResourceDictionary.MergedDictionaries> | |||||
</ResourceDictionary> | |||||
</UserControl.Resources> | |||||
<Grid Margin="10"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="35" /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||||
<Button | |||||
Width="140" | |||||
Margin="0,0,20,0" | |||||
Background="#FF19B7EC" | |||||
Command="{Binding NewConnectCommand}" | |||||
Content="新建连接" | |||||
FontFamily="楷体" | |||||
FontSize="18" | |||||
Template="{StaticResource NewButtonTemp}"> | |||||
<Button.Foreground> | |||||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | |||||
<GradientStop Color="#FFBB662A" /> | |||||
<GradientStop Offset="1" Color="White" /> | |||||
</LinearGradientBrush> | |||||
</Button.Foreground> | |||||
</Button> | |||||
<Button | |||||
Width="140" | |||||
Command="{Binding SaveConnectSetCommand}" | |||||
Content="保存" | |||||
FontFamily="楷体" | |||||
FontSize="18" | |||||
Template="{StaticResource SaveButtonTemp}"> | |||||
<Button.Foreground> | |||||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | |||||
<GradientStop Color="#FFBB662A" /> | |||||
<GradientStop Offset="1" Color="White" /> | |||||
</LinearGradientBrush> | |||||
</Button.Foreground> | |||||
</Button> | |||||
</StackPanel> | |||||
<ScrollViewer | |||||
Grid.Row="1" | |||||
Margin="0,10,0,0" | |||||
HorizontalScrollBarVisibility="Hidden" | |||||
VerticalScrollBarVisibility="Hidden"> | |||||
<ItemsControl ItemsSource="{Binding communicationSets}"> | |||||
<ItemsControl.ItemTemplate> | |||||
<DataTemplate> | |||||
<Grid Margin="0,0,0,30"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="0.1*" /> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<!--#region 标题显示及操作--> | |||||
<Grid Margin="0,0,0,20"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
<ColumnDefinition Width="0.3*" /> | |||||
<ColumnDefinition /> | |||||
</Grid.ColumnDefinitions> | |||||
<pry:TitleTextBlock /> | |||||
<TextBlock | |||||
Margin="5" | |||||
HorizontalAlignment="Left" | |||||
VerticalAlignment="Center" | |||||
FontFamily="楷体" | |||||
FontSize="20" | |||||
Foreground="Aqua" | |||||
Text="{Binding DeviceName}" /> | |||||
</Grid> | |||||
<!--#endregion--> | |||||
<!--#region 西门子设备--> | |||||
<Grid Grid.Row="1" Visibility="{Binding Path=deviceType, Converter={StaticResource VisibleConvert},ConverterParameter=Siemens}"> | |||||
<Grid> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
<ColumnDefinition Width="0.2*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition /> | |||||
<RowDefinition Height="20" /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<TextBlock | |||||
Grid.Column="0" | |||||
Style="{StaticResource TextBlockStyle}" | |||||
Text="IP地址:" /> | |||||
<TextBox | |||||
Grid.Column="1" | |||||
Margin="0,0,20,0" | |||||
Style="{StaticResource TextBoxStyle}" | |||||
Text="{Binding Path=Device.IP}" /> | |||||
<TextBlock | |||||
Grid.Column="2" | |||||
Style="{StaticResource TextBlockStyle}" | |||||
Text="端口号:" /> | |||||
<TextBox | |||||
Grid.Column="3" | |||||
Margin="0,0,20,0" | |||||
Style="{StaticResource TextBoxStyle}" | |||||
Text="{Binding Path=Device.PortNum}" /> | |||||
<TextBlock | |||||
Grid.Column="4" | |||||
Style="{StaticResource TextBlockStyle}" | |||||
Text="PLC类型:" /> | |||||
<ComboBox | |||||
Grid.Column="5" | |||||
Margin="0,0,20,0" | |||||
VerticalAlignment="Center" | |||||
BorderBrush="#FF23CACA" | |||||
BorderThickness="1" | |||||
FontFamily="楷体" | |||||
FontSize="20" | |||||
Foreground="#ff23caca" | |||||
IsEditable="False" | |||||
ItemsSource="{Binding Path=Device.PlcTypes}" | |||||
SelectedIndex="0" | |||||
Style="{StaticResource ComboBoxStyle}" | |||||
Text="{Binding Path=Device.PlcType}" /> | |||||
<Button | |||||
Grid.Column="7" | |||||
Command="{Binding RemoveCommand}" | |||||
CommandParameter="{Binding DeviceName}" | |||||
Content="删除" | |||||
FontFamily="楷体" | |||||
FontSize="20" | |||||
Foreground="#FFDE7889" | |||||
Template="{StaticResource ButtonTemplate}" /> | |||||
<TextBlock | |||||
Grid.Row="2" | |||||
Style="{StaticResource TextBlockStyle}" | |||||
Text="机架号:" /> | |||||
<TextBox | |||||
Grid.Row="2" | |||||
Grid.Column="1" | |||||
Margin="0,0,20,0" | |||||
Style="{StaticResource TextBoxStyle}" | |||||
Text="{Binding Path=Device.Rack}" /> | |||||
<TextBlock | |||||
Grid.Row="2" | |||||
Grid.Column="2" | |||||
Style="{StaticResource TextBlockStyle}" | |||||
Text="插槽号:" /> | |||||
<TextBox | |||||
Grid.Row="2" | |||||
Grid.Column="3" | |||||
Margin="0,0,20,0" | |||||
Style="{StaticResource TextBoxStyle}" | |||||
Text="{Binding Path=Device.Slot}" /> | |||||
<CheckBox | |||||
Grid.Row="2" | |||||
Grid.Column="7" | |||||
Width="100" | |||||
Height="20" | |||||
Margin="10" | |||||
HorizontalAlignment="Right" | |||||
VerticalAlignment="Center" | |||||
Background="#FF2AB2E7" | |||||
Content="IsActive" | |||||
FontSize="16" | |||||
Foreground="#ddd" | |||||
IsChecked="{Binding IsActive}" | |||||
Template="{StaticResource CbTemplate}" /> | |||||
</Grid> | |||||
</Grid> | |||||
<!--#endregion--> | |||||
<!--#region Modbus Tcp 设备--> | |||||
<Grid Grid.Row="2" Visibility="{Binding Path=deviceType, Converter={StaticResource VisibleConvert},ConverterParameter=ModbusTcp}"> | |||||
<Grid> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
<ColumnDefinition Width="0.2*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition /> | |||||
<RowDefinition Height="20" /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<TextBlock | |||||
Grid.Column="0" | |||||
Style="{StaticResource TextBlockStyle}" | |||||
Text="IP地址:" /> | |||||
<TextBox | |||||
Grid.Column="1" | |||||
Margin="0,0,20,0" | |||||
Style="{StaticResource TextBoxStyle}" | |||||
Text="{Binding Path=NotFoundString,FallbackValue=Device.IP}" /> | |||||
<TextBlock | |||||
Grid.Column="2" | |||||
Style="{StaticResource TextBlockStyle}" | |||||
Text="端口号:" /> | |||||
<TextBox | |||||
Grid.Column="3" | |||||
Margin="0,0,20,0" | |||||
Style="{StaticResource TextBoxStyle}" | |||||
Text="{Binding Path=Device.PortNum}" /> | |||||
<TextBlock | |||||
Grid.Column="4" | |||||
Style="{StaticResource TextBlockStyle}" | |||||
Text="站号:" /> | |||||
<TextBox | |||||
Grid.Column="5" | |||||
Margin="0,0,20,0" | |||||
Style="{StaticResource TextBoxStyle}" | |||||
Text="{Binding Path=Device.StationNo}" /> | |||||
<Button | |||||
Grid.Column="7" | |||||
Command="{Binding RemoveCommand}" | |||||
CommandParameter="{Binding DeviceName}" | |||||
Content="删除" | |||||
FontFamily="楷体" | |||||
FontSize="20" | |||||
Foreground="#FFDE7889" | |||||
Template="{StaticResource ButtonTemplate}" /> | |||||
<CheckBox | |||||
Grid.Row="2" | |||||
Grid.Column="7" | |||||
Width="100" | |||||
Height="20" | |||||
Margin="10" | |||||
HorizontalAlignment="Right" | |||||
VerticalAlignment="Center" | |||||
Background="#FF2AB2E7" | |||||
Content="IsActive" | |||||
FontSize="16" | |||||
Foreground="#ddd" | |||||
IsChecked="{Binding IsActive}" | |||||
Template="{StaticResource CbTemplate}" /> | |||||
</Grid> | |||||
</Grid> | |||||
<!--#endregion--> | |||||
<!--#region Modbus RTU 设备--> | |||||
<Grid Grid.Row="3" Visibility="{Binding Path=deviceType, Converter={StaticResource VisibleConvert},ConverterParameter=ModbusRtu}"> | |||||
<Grid> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
<ColumnDefinition Width="0.2*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition /> | |||||
<RowDefinition Height="20" /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="端口号:" /> | |||||
<ComboBox | |||||
Grid.Column="1" | |||||
Margin="0,0,20,0" | |||||
VerticalAlignment="Center" | |||||
BorderBrush="#FF23CACA" | |||||
BorderThickness="1" | |||||
FontFamily="楷体" | |||||
FontSize="20" | |||||
Foreground="#ff23caca" | |||||
IsEditable="False" | |||||
ItemsSource="{Binding Path=Device.Ports}" | |||||
SelectedIndex="0" | |||||
Style="{StaticResource ComboBoxStyle}" | |||||
Text="{Binding Path=Device.ComSerialPort}" /> | |||||
<TextBlock | |||||
Grid.Column="2" | |||||
Style="{StaticResource TextBlockStyle}" | |||||
Text="波特率:" /> | |||||
<ComboBox | |||||
Grid.Column="3" | |||||
Margin="0,0,20,0" | |||||
VerticalAlignment="Center" | |||||
BorderBrush="#FF23CACA" | |||||
BorderThickness="1" | |||||
FontFamily="楷体" | |||||
FontSize="20" | |||||
Foreground="#ff23caca" | |||||
IsEditable="False" | |||||
ItemsSource="{Binding Path=Device.BaudRates}" | |||||
SelectedIndex="0" | |||||
Style="{StaticResource ComboBoxStyle}" | |||||
Text="{Binding Path=Device.BaudRate}" /> | |||||
<TextBlock | |||||
Grid.Column="4" | |||||
Style="{StaticResource TextBlockStyle}" | |||||
Text="奇偶:" /> | |||||
<ComboBox | |||||
Grid.Column="5" | |||||
Margin="0,0,20,0" | |||||
VerticalAlignment="Center" | |||||
BorderBrush="#FF23CACA" | |||||
BorderThickness="1" | |||||
FontFamily="楷体" | |||||
FontSize="20" | |||||
Foreground="#ff23caca" | |||||
IsEditable="False" | |||||
ItemsSource="{Binding Path=Device.Paritys}" | |||||
SelectedIndex="0" | |||||
Style="{StaticResource ComboBoxStyle}" | |||||
Text="{Binding Path=Device.Parity}" /> | |||||
<TextBlock | |||||
Grid.Row="2" | |||||
Grid.Column="0" | |||||
Style="{StaticResource TextBlockStyle}" | |||||
Text="数据位:" /> | |||||
<TextBox | |||||
Grid.Row="2" | |||||
Grid.Column="1" | |||||
Margin="0,0,20,0" | |||||
Style="{StaticResource TextBoxStyle}" | |||||
Text="{Binding Path=Device.DataBit}" /> | |||||
<TextBlock | |||||
Grid.Row="2" | |||||
Grid.Column="2" | |||||
Style="{StaticResource TextBlockStyle}" | |||||
Text="停止位:" /> | |||||
<TextBox | |||||
Grid.Row="2" | |||||
Grid.Column="3" | |||||
Margin="0,0,20,0" | |||||
Style="{StaticResource TextBoxStyle}" | |||||
Text="{Binding Path=Device.StopBit}" /> | |||||
<TextBlock | |||||
Grid.Row="2" | |||||
Grid.Column="4" | |||||
Style="{StaticResource TextBlockStyle}" | |||||
Text="站号:" /> | |||||
<TextBox | |||||
Grid.Row="2" | |||||
Grid.Column="5" | |||||
Margin="0,0,20,0" | |||||
Style="{StaticResource TextBoxStyle}" | |||||
Text="{Binding Path=Device.StationNo}" /> | |||||
<Button | |||||
Grid.Column="7" | |||||
Command="{Binding RemoveCommand}" | |||||
CommandParameter="{Binding DeviceName}" | |||||
Content="删除" | |||||
FontFamily="楷体" | |||||
FontSize="20" | |||||
Foreground="#FFDE7889" | |||||
Template="{StaticResource ButtonTemplate}" /> | |||||
<CheckBox | |||||
Grid.Row="2" | |||||
Grid.Column="7" | |||||
Width="100" | |||||
Height="20" | |||||
Margin="10" | |||||
HorizontalAlignment="Right" | |||||
VerticalAlignment="Center" | |||||
Background="#FF2AB2E7" | |||||
Content="IsActive" | |||||
FontSize="16" | |||||
Foreground="#ddd" | |||||
IsChecked="{Binding IsActive}" | |||||
Template="{StaticResource CbTemplate}" /> | |||||
</Grid> | |||||
</Grid> | |||||
<!--#endregion--> | |||||
</Grid> | |||||
</DataTemplate> | |||||
</ItemsControl.ItemTemplate> | |||||
</ItemsControl> | |||||
</ScrollViewer> | |||||
</Grid> | |||||
</UserControl> |
@@ -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 HBLConsole.View | |||||
{ | |||||
/// <summary> | |||||
/// DeviceManageView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class DeviceManageView : UserControl | |||||
{ | |||||
public DeviceManageView() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
} | |||||
} |
@@ -215,6 +215,14 @@ | |||||
Content="流程监控" | Content="流程监控" | ||||
Style="{StaticResource ParallelogramRadioButtonStyle}" /> | Style="{StaticResource ParallelogramRadioButtonStyle}" /> | ||||
<RadioButton | |||||
Margin="-10,0,0,0" | |||||
Command="{Binding NavChangedCommand}" | |||||
CommandParameter="DeviceManageView" | |||||
Content="设备管理" | |||||
Style="{StaticResource ParallelogramRadioButtonStyle}" /> | |||||
<RadioButton | <RadioButton | ||||
Margin="-10,0,0,0" | Margin="-10,0,0,0" | ||||
Command="{Binding NavChangedCommand}" | Command="{Binding NavChangedCommand}" | ||||
@@ -260,15 +268,15 @@ | |||||
<Button | <Button | ||||
Name="ButMin" | Name="ButMin" | ||||
Width="40" | Width="40" | ||||
Content="" | |||||
Content="" | |||||
Style="{StaticResource TitleBarStyle}" /> | Style="{StaticResource TitleBarStyle}" /> | ||||
<Button | <Button | ||||
Name="ButMax" | Name="ButMax" | ||||
Content="" | |||||
Content="" | |||||
Style="{StaticResource TitleBarStyle}" /> | Style="{StaticResource TitleBarStyle}" /> | ||||
<Button | <Button | ||||
Name="ButClose" | Name="ButClose" | ||||
Content="" | |||||
Content="" | |||||
FontSize="26" | FontSize="26" | ||||
Style="{StaticResource TitleBarStyle}" /> | Style="{StaticResource TitleBarStyle}" /> | ||||
</UniformGrid> | </UniformGrid> | ||||
@@ -0,0 +1,12 @@ | |||||
<UserControl x:Class="HBLConsole.View.ProcessMonitoringView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:HBLConsole.View" | |||||
mc:Ignorable="d" | |||||
d:DesignHeight="450" d:DesignWidth="800"> | |||||
<Grid> | |||||
</Grid> | |||||
</UserControl> |
@@ -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 HBLConsole.View | |||||
{ | |||||
/// <summary> | |||||
/// ProcessMonitoringView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class ProcessMonitoringView : UserControl | |||||
{ | |||||
public ProcessMonitoringView() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
} | |||||
} |
@@ -18,6 +18,7 @@ namespace HBLConsole.ViewModel | |||||
{ | { | ||||
public class DebugViewModel : ViewModelBase | public class DebugViewModel : ViewModelBase | ||||
{ | { | ||||
static bool First = false; | |||||
public DebugViewModel() | public DebugViewModel() | ||||
{ | { | ||||
WindowName = "调试模式"; | WindowName = "调试模式"; | ||||
@@ -25,9 +26,10 @@ namespace HBLConsole.ViewModel | |||||
{ | { | ||||
ActionManagerment.GetInstance.Send("SimOrder", new SimOrderData() | ActionManagerment.GetInstance.Send("SimOrder", new SimOrderData() | ||||
{ | { | ||||
IsEnableRandom = IsEnableRandom, | |||||
NoodleIsEnableRandom = IsEnableRandom, | |||||
BowlLoc = BowlLoc, | BowlLoc = BowlLoc, | ||||
NoodleLoc = NoodleLoc, | NoodleLoc = NoodleLoc, | ||||
BowlIsEnableRandom = BowlIsEnableRandom | |||||
}, new Action(() => | }, new Action(() => | ||||
{ | { | ||||
BowlLoc = MORKS.GetInstance.BowlLoc; | BowlLoc = MORKS.GetInstance.BowlLoc; | ||||
@@ -36,17 +38,12 @@ namespace HBLConsole.ViewModel | |||||
}); | }); | ||||
InitCommand = new RelayCommand(() => { MORKS.GetInstance.DeviceInit(); }); | InitCommand = new RelayCommand(() => { MORKS.GetInstance.DeviceInit(); }); | ||||
ProcessCondition(); | |||||
//ThreadManagerment.GetInstance.StartLong(new Action(() => | |||||
//{ | |||||
// NoodleCount = MORKS.GetInstance.mORKS.RBTakeNoodleTask.Count; | |||||
// BowlCount = MORKS.GetInstance.mORKS.TakeBowlTask.Count; | |||||
// Thread.Sleep(1000); | |||||
//}), "数据监控"); | |||||
if (!First) ProcessCondition(); | |||||
} | } | ||||
private void ProcessCondition() | private void ProcessCondition() | ||||
{ | { | ||||
First = true; | |||||
Type type = MORKS.GetInstance.mORKS.GetType(); | Type type = MORKS.GetInstance.mORKS.GetType(); | ||||
//添加流程监控信息 | //添加流程监控信息 | ||||
@@ -169,15 +166,8 @@ namespace HBLConsole.ViewModel | |||||
private static bool _mIsEnableRandom = true; | private static bool _mIsEnableRandom = true; | ||||
//public static int NoodleCount { get { return _mNoodleCount; } set { _mNoodleCount = value; OnStaticPropertyChanged(); } } | |||||
//private static int _mNoodleCount; | |||||
//public static int BowlCount { get { return _mBowlCount; } set { _mBowlCount = value; OnStaticPropertyChanged(); } } | |||||
//private static int _mBowlCount; | |||||
public static bool BowlIsEnableRandom { get { return _mBowlIsEnableRandom; } set { _mBowlIsEnableRandom = value; OnStaticPropertyChanged(); } } | |||||
private static bool _mBowlIsEnableRandom = true; | |||||
} | } | ||||
} | } |
@@ -0,0 +1,132 @@ | |||||
using HBLConsole.DialogWindow.View; | |||||
using HBLConsole.Interface; | |||||
using HBLConsole.Model; | |||||
using HBLConsole.Service; | |||||
using Microsoft.Toolkit.Mvvm.Input; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Collections.ObjectModel; | |||||
using System.Linq; | |||||
using System.Reflection; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Windows; | |||||
namespace HBLConsole.ViewModel | |||||
{ | |||||
public class DeviceManageViewModel : ViewModelBase | |||||
{ | |||||
public DeviceManageViewModel() | |||||
{ | |||||
WindowName = "设备管理"; | |||||
NewConnectCommand = new RelayCommand(() => { NewConnect(); }); | |||||
SaveConnectSetCommand = new RelayCommand(() => | |||||
{ | |||||
Json<CommunicationPar>.GetInstance.Base.communicationSets.Clear(); | |||||
foreach (var item in communicationSets) | |||||
{ | |||||
item.RemoveAction = null; | |||||
//if (!item.CommModbusRtu.IsVisible) item.CommModbusRtu = null; | |||||
//if (!item.CommSiemens.IsVisible) item.CommSiemens = null; | |||||
//if (!item.CommModbusTcp.IsVisible) item.CommModbusTcp = null; | |||||
Json<CommunicationPar>.GetInstance.Base.communicationSets.Add(item); | |||||
} | |||||
Json<CommunicationPar>.GetInstance.Save(); | |||||
}); | |||||
Json<CommunicationPar>.GetInstance.Read(); | |||||
communicationSets.Clear(); | |||||
foreach (var item in Json<CommunicationPar>.GetInstance.Base.communicationSets) | |||||
{ | |||||
item.RemoveAction = RemoveDevice; | |||||
communicationSets.Add(item); | |||||
} | |||||
ActionManagerment.GetInstance.Register(new Func<object, object>((p) => | |||||
{ | |||||
if (p is DeviceManagermentResult dm) | |||||
{ | |||||
return communicationSets.FirstOrDefault(s => s.DeviceName == dm.DeviceName) == null; | |||||
} | |||||
return false; | |||||
}), "AddDeviceVerify"); | |||||
} | |||||
public static ObservableCollection<CommunicationSet> communicationSets { get; set; } = new ObservableCollection<CommunicationSet>(); | |||||
public RelayCommand NewConnectCommand { get; set; } | |||||
public RelayCommand SaveConnectSetCommand { get; set; } | |||||
/// <summary> | |||||
/// 创建新连接 | |||||
/// </summary> | |||||
private void NewConnect() | |||||
{ | |||||
DeviceManagermentSetView deviceManagermentSetView = new DeviceManagermentSetView(); | |||||
var result = deviceManagermentSetView.ShowDialog(); | |||||
var ResultTag = (DeviceManagermentResult)deviceManagermentSetView.Tag; | |||||
if (ResultTag != null) | |||||
{ | |||||
if ((bool)result) | |||||
{ | |||||
var obj = communicationSets.FirstOrDefault(p => p.DeviceName == ResultTag.DeviceName); | |||||
if (obj == null) | |||||
{ | |||||
CommunicationSet communicationObj = new CommunicationSet(); | |||||
EDeviceType eDeviceType = (EDeviceType)Enum.Parse(typeof(EDeviceType), ResultTag.DeviceType); | |||||
string NameSpace = "HBLConsole.Model";//Load 加载的是dll的名称,GetType获取的是全命名空间下的类 | |||||
Type type = Assembly.Load(NameSpace)?.GetType($"{NameSpace}.{ResultTag.DeviceType}"); | |||||
if (type != null) | |||||
{ | |||||
communicationObj.Device = (IDeviceType)Activator.CreateInstance(type); | |||||
} | |||||
communicationObj.DeviceName = ResultTag.DeviceName; | |||||
communicationObj.deviceType = eDeviceType; | |||||
communicationObj.RemoveAction = RemoveDevice; | |||||
communicationSets.Add(communicationObj); | |||||
//switch (eDeviceType) | |||||
//{ | |||||
// case EDeviceType.Siemens: | |||||
// //communicationObj.CommSiemens = new Siemens(); | |||||
// //communicationObj.CommSiemens.IsVisible = true; | |||||
// break; | |||||
// case EDeviceType.ModbusRtu: | |||||
// //communicationObj.CommModbusRtu.IsVisible = true; | |||||
// break; | |||||
// case EDeviceType.ModbusTcp: | |||||
// //communicationObj.CommModbusTcp.IsVisible = true; | |||||
// break; | |||||
// case EDeviceType.SerialPort: | |||||
// break; | |||||
// default: | |||||
// break; | |||||
//} | |||||
} | |||||
} | |||||
} | |||||
deviceManagermentSetView = null; | |||||
} | |||||
private void RemoveDevice(object o) | |||||
{ | |||||
var result = communicationSets.FirstOrDefault(p => p.DeviceName == o.ToString()); | |||||
if (result != null) | |||||
{ | |||||
communicationSets.Remove(result); | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,123 @@ | |||||
using HBLConsole.Business.Devices; | |||||
using HBLConsole.Model; | |||||
using HBLConsole.Service; | |||||
using System; | |||||
using System.Collections.Concurrent; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Reflection; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using System.Threading.Tasks; | |||||
namespace HBLConsole.ViewModel | |||||
{ | |||||
public class ProcessMonitoringViewModel : ViewModelBase | |||||
{ | |||||
public ProcessMonitoringViewModel() | |||||
{ | |||||
WindowName = "流程监控"; | |||||
ProcessCondition(); | |||||
} | |||||
private void ProcessCondition() | |||||
{ | |||||
Type type = MORKS.GetInstance.mORKS.GetType(); | |||||
//添加流程监控信息 | |||||
foreach (var item in type.GetProperties()) | |||||
{ | |||||
if (item.CustomAttributes.Count() > 0) | |||||
{ | |||||
string? propertyInfo = item.GetCustomAttribute<GVL.CircuitAttribute>()?.PropertyIllustrate; | |||||
string[]? Classifiactions = item.GetCustomAttribute<GVL.CircuitAttribute>()?.Classifiaction; | |||||
if (Classifiactions != null) | |||||
{ | |||||
foreach (var itemClassifiactions in Classifiactions) | |||||
{ | |||||
if (GVL.ProcessData.GetInstance.Conditions.ContainsKey(itemClassifiactions)) | |||||
{ | |||||
if (propertyInfo != null) | |||||
{ | |||||
int index = Array.FindIndex(GVL.ProcessData.GetInstance.Conditions[itemClassifiactions].ToArray(), p => p.propertyIllustrate == propertyInfo); | |||||
if (index >= 0) | |||||
{ | |||||
GVL.ProcessData.GetInstance.Conditions[itemClassifiactions].ElementAt(index).ToolTip = item.Name; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
var Conditions = GVL.ProcessData.GetInstance.Conditions; | |||||
if (Conditions != null) | |||||
{ | |||||
foreach (var item in Conditions) | |||||
{ | |||||
ProcessConditions process = new ProcessConditions(); | |||||
process.ProcessTitl = item.Key; | |||||
foreach (var values in item.Value) | |||||
{ | |||||
process.Conditions.Add(new Condition() { ConditionName = values.propertyIllustrate }); | |||||
} | |||||
processConditions.Add(process); | |||||
} | |||||
} | |||||
//更新流程监控图 | |||||
ThreadManagerment.GetInstance.StartLong(new Action(() => | |||||
{ | |||||
foreach (var item in type.GetProperties()) | |||||
{ | |||||
if (item.CustomAttributes.Count() > 0) | |||||
{ | |||||
string? propertyInfo = item.GetCustomAttribute<GVL.CircuitAttribute>()?.PropertyIllustrate; | |||||
string[]? Classifiactions = item.GetCustomAttribute<GVL.CircuitAttribute>()?.Classifiaction; | |||||
if (Classifiactions != null) | |||||
{ | |||||
foreach (string? Titles in Classifiactions) | |||||
{ | |||||
if (Titles != null && propertyInfo != null) | |||||
{ | |||||
bool? isNot = GVL.ProcessData.GetInstance.Conditions[Titles]?.FirstOrDefault(p => p.propertyIllustrate == propertyInfo)?.IsNot; | |||||
int index = Array.FindIndex(processConditions.ToArray(), p => p.ProcessTitl == Titles); | |||||
if (index >= 0) | |||||
{ | |||||
int PropertyIndex = Array.FindIndex(processConditions.ElementAt(index).Conditions.ToArray(), p => p.ConditionName == propertyInfo); | |||||
if (PropertyIndex >= 0) | |||||
{ | |||||
var res = type.GetProperty(item.Name)?.GetValue(MORKS.GetInstance.mORKS, null); | |||||
if (res != null) | |||||
{ | |||||
if (res is bool blen) | |||||
{ | |||||
if (isNot != null) | |||||
{ | |||||
processConditions.ElementAt(index).Conditions.ElementAt(PropertyIndex).ConditionMet = (bool)isNot ? !blen : blen; | |||||
} | |||||
} | |||||
else if (res is ConcurrentQueue<GVL.OrderLocInfo> OrderLocInfoS) | |||||
{ | |||||
processConditions.ElementAt(index).Conditions.ElementAt(PropertyIndex).ConditionMet = OrderLocInfoS.Count > 0; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
Thread.Sleep(1000); | |||||
}), "UpdateValue"); | |||||
} | |||||
} | |||||
} |