From a28b81537c6dc2831698025e20d6c4e98fe99118 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com>
Date: Tue, 17 May 2022 18:31:55 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=B1=BB=E5=9E=8B=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../BPASmartClient.Business.csproj | 2 +-
BPASmartClient.Business/Plugin/OrderProxy.cs | 7 +-
.../BPASmartClient.CustomResource.csproj | 2 +-
.../Converters/VisibleTypeConverter.cs | 34 +++
.../BPASmartClient.Device.csproj | 2 +-
BPASmartClient.Modbus/ModbusTcp.cs | 38 ---
.../BPASmartClient.Model.csproj | 2 +-
.../订单/OrderStatusChangedEvent.cs | 7 +-
BPASmartClient.MorkT/Control_MorkT.cs | 8 +-
.../Model/DeviceConfigModel.cs | 102 ++++++--
.../ShopDeviceConfigViewModel.cs | 219 ++++++++++++++++--
BPASmartClient/App.config | 35 ++-
BPASmartClient/App.xaml | 1 +
.../Control/ShopDeviceConfigView.xaml | 218 +++++++++--------
.../Control/ShopDeviceConfigView.xaml.cs | 64 +++++
BPASmartClient/DeviceInfo.xml | 2 +-
.../BPASmartClient.MORKIC.csproj | 2 +-
17 files changed, 531 insertions(+), 214 deletions(-)
create mode 100644 BPASmartClient.CustomResource/Converters/VisibleTypeConverter.cs
diff --git a/BPASmartClient.Business/BPASmartClient.Business.csproj b/BPASmartClient.Business/BPASmartClient.Business.csproj
index da5bfe70..e150ff8b 100644
--- a/BPASmartClient.Business/BPASmartClient.Business.csproj
+++ b/BPASmartClient.Business/BPASmartClient.Business.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/BPASmartClient.Business/Plugin/OrderProxy.cs b/BPASmartClient.Business/Plugin/OrderProxy.cs
index 2f0a2b36..5f8969ef 100644
--- a/BPASmartClient.Business/Plugin/OrderProxy.cs
+++ b/BPASmartClient.Business/Plugin/OrderProxy.cs
@@ -45,11 +45,11 @@ namespace BPASmartClient.Business
if (morkOrderPushes.TryDequeue(out MorkOrderPush mork))
{
Thread.Sleep(3000);
- new OrderStatusChangedEvent() { Status = ORDER_STATUS.COOKING, SubOrderId = mork.SuborderId }.Publish();
+ new OrderStatusChangedEvent() { Status = ORDER_STATUS.COOKING, SubOrderId = mork.SuborderId, GoodName = mork.GoodsName }.Publish();
Thread.Sleep(5000);
- new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_COOK, SubOrderId = mork.SuborderId }.Publish();
+ new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_COOK, SubOrderId = mork.SuborderId, GoodName = mork.GoodsName }.Publish();
Thread.Sleep(5000);
- new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_TAKE, SubOrderId = mork.SuborderId }.Publish();
+ new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_TAKE, SubOrderId = mork.SuborderId, GoodName = mork.GoodsName }.Publish();
Thread.Sleep(2000);
}
}
@@ -144,6 +144,7 @@ namespace BPASmartClient.Business
#region MQTT 订单状态修改
var clientId = Plugin.GetInstance().GetPlugin().ClientId;
var temp = BPAPackage.Make(orderStatusChange, clientId, orderStatusChangedEvent.deviceClientType);
+ var q = temp.Serialize(false);
Plugin.GetInstance().GetPlugin().Publish(TOPIC.GetInstance.GetAppTopic(clientId.ToString()), temp.Serialize(false));
#endregion
}
diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
index f1590991..822d0320 100644
--- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
+++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
@@ -200,7 +200,7 @@
-
+
diff --git a/BPASmartClient.CustomResource/Converters/VisibleTypeConverter.cs b/BPASmartClient.CustomResource/Converters/VisibleTypeConverter.cs
new file mode 100644
index 00000000..1225ef80
--- /dev/null
+++ b/BPASmartClient.CustomResource/Converters/VisibleTypeConverter.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+
+namespace BPASmartClient.CustomResource.Converters
+{
+ public class VisibleTypeConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value != null && parameter != null && parameter is string p && value is bool type)
+ {
+ if (p != null)
+ {
+ if (p == "NetworkPort")
+ return type ? Visibility.Visible : Visibility.Collapsed;
+ else if (p == "SerialPort")
+ return !type ? Visibility.Visible : Visibility.Collapsed;
+ }
+ }
+ return Visibility.Collapsed;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/BPASmartClient.Device/BPASmartClient.Device.csproj b/BPASmartClient.Device/BPASmartClient.Device.csproj
index d6e29885..3164a1d8 100644
--- a/BPASmartClient.Device/BPASmartClient.Device.csproj
+++ b/BPASmartClient.Device/BPASmartClient.Device.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/BPASmartClient.Modbus/ModbusTcp.cs b/BPASmartClient.Modbus/ModbusTcp.cs
index e9d21e05..3db68648 100644
--- a/BPASmartClient.Modbus/ModbusTcp.cs
+++ b/BPASmartClient.Modbus/ModbusTcp.cs
@@ -452,44 +452,6 @@ namespace BPASmartClient.Modbus
master.WriteSingleRegister(slaveAddress, startAddress, value);
}
#endregion
-
-
-
-
-
- }
-
-
- public enum ReadType
- {
- ///
- /// 读线圈
- ///
- Coils,
- ///
- /// 读输入线圈
- ///
- Inputs,
- ///
- /// 读保持寄存器
- ///
- HoldingRegisters,
- ///
- /// 读输入寄存器
- ///
- InputRegisters,
- }
-
- public enum WriteType
- {
- ///
- /// 写线圈
- ///
- Coils,
- ///
- /// 写保持寄存器
- ///
- HoldingRegisters,
}
public enum CommandType
diff --git a/BPASmartClient.Model/BPASmartClient.Model.csproj b/BPASmartClient.Model/BPASmartClient.Model.csproj
index b30929ab..f10dc37c 100644
--- a/BPASmartClient.Model/BPASmartClient.Model.csproj
+++ b/BPASmartClient.Model/BPASmartClient.Model.csproj
@@ -15,7 +15,7 @@
-
+
diff --git a/BPASmartClient.Model/订单/OrderStatusChangedEvent.cs b/BPASmartClient.Model/订单/OrderStatusChangedEvent.cs
index f5c25182..7f9045ce 100644
--- a/BPASmartClient.Model/订单/OrderStatusChangedEvent.cs
+++ b/BPASmartClient.Model/订单/OrderStatusChangedEvent.cs
@@ -10,7 +10,7 @@ namespace BPASmartClient.Model
///
/// 订单状态改变事件
///
- public class OrderStatusChangedEvent:BaseEvent
+ public class OrderStatusChangedEvent : BaseEvent
{
///
/// 子订单ID
@@ -20,5 +20,10 @@ namespace BPASmartClient.Model
/// 状态
///
public ORDER_STATUS Status { get; set; }
+
+ ///
+ /// 商品名称
+ ///
+ public string GoodName { get; set; }
}
}
diff --git a/BPASmartClient.MorkT/Control_MorkT.cs b/BPASmartClient.MorkT/Control_MorkT.cs
index cfacd727..dcdacc67 100644
--- a/BPASmartClient.MorkT/Control_MorkT.cs
+++ b/BPASmartClient.MorkT/Control_MorkT.cs
@@ -15,7 +15,7 @@ namespace BPASmartClient.MorkT
{
public class Control_MorkT : BaseDevice
{
- public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKIC; } }
+ public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKT; } }
GLV_MorkT morkT = new GLV_MorkT();
@@ -49,7 +49,7 @@ namespace BPASmartClient.MorkT
LebaiRobot.GetInstance.GetRobotModeStatus();
}
-
+
public override void Stop()
{
@@ -108,7 +108,7 @@ namespace BPASmartClient.MorkT
//获取当前物料所属商品类型
currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc);
}
-
+
//获取主料和容器位置
if (morkT.batchings[res.BatchingLoc].BatchingClass == BATCHING_CLASS.MAIN_MATERIAL) loc_Goods = res.BatchingLoc;
@@ -157,7 +157,7 @@ namespace BPASmartClient.MorkT
return morkT.batchings[batchingLoc].GoodsType;
return GOODS_TYPE.NEITHER;
}
-
+
}
diff --git a/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs b/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs
index 49e9d013..f6f699f3 100644
--- a/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs
+++ b/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs
@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
+using Microsoft.Toolkit.Mvvm.Input;
namespace BPASmartClient.ViewModel.Model
{
@@ -13,6 +14,7 @@ namespace BPASmartClient.ViewModel.Model
///
public class DeviceConfigModel : ObservableObject
{
+
///
/// 店铺名称
///
@@ -28,7 +30,7 @@ namespace BPASmartClient.ViewModel.Model
///
/// 设备集合
///
- public ObservableCollection deviceModels = new ObservableCollection();
+ public ObservableCollection deviceModels { get; set; } = new ObservableCollection();
}
///
@@ -48,6 +50,11 @@ namespace BPASmartClient.ViewModel.Model
public string DeviceModule { get { return _mDeviceModule; } set { _mDeviceModule = value; OnPropertyChanged(); } }
private string _mDeviceModule = string.Empty;
+
+ public string Id { get { return _mId; } set { _mId = value; OnPropertyChanged(); } }
+ private string _mId = string.Empty;
+
+
///
/// 设备ID
///
@@ -57,7 +64,7 @@ namespace BPASmartClient.ViewModel.Model
///
/// 通讯模块
///
- public ObservableCollection communicationDevcies = new ObservableCollection();
+ public ObservableCollection communicationDevcies { get; set; } = new ObservableCollection();
}
@@ -72,10 +79,14 @@ namespace BPASmartClient.ViewModel.Model
public string CommunicationModule { get { return _mCommunicationModule; } set { _mCommunicationModule = value; OnPropertyChanged(); } }
private string _mCommunicationModule = string.Empty;
-
public string CommunicationName { get { return _mCommunicationName; } set { _mCommunicationName = value; OnPropertyChanged(); } }
private string _mCommunicationName = string.Empty;
+ public string DeviceModelId { get { return _mDeviceModelId; } set { _mDeviceModelId = value; OnPropertyChanged(); } }
+ private string _mDeviceModelId = string.Empty;
+
+ public CommunicationPar communicationPar { get { return _mcommunicationPar; } set { _mcommunicationPar = value; OnPropertyChanged(); } }
+ private CommunicationPar _mcommunicationPar = new CommunicationPar();
}
@@ -85,44 +96,93 @@ namespace BPASmartClient.ViewModel.Model
///
public class CommunicationPar : ObservableObject
{
- public CommunicationParType communicationType { get { return _mcommunicationType; } set { _mcommunicationType = value; OnPropertyChanged(); } }
- private CommunicationParType _mcommunicationType;
-
-
- public string CommunicationValue { get { return _mCommunicationValue; } set { _mCommunicationValue = value; OnPropertyChanged(); } }
- private string _mCommunicationValue = string.Empty;
+ ///
+ /// 通讯类型,false:串口,true:网口
+ ///
+ public bool CommunicationType { get { return _mCommunicationType; } set { _mCommunicationType = value; OnPropertyChanged(); } }
+ private bool _mCommunicationType;
- }
- public enum CommunicationParType
- {
///
/// IP地址
///
- IPAddress,
+ public string IPAddress { get { return _mIPAddress; } set { _mIPAddress = value; OnPropertyChanged(); } }
+ private string _mIPAddress;
+
+ ///
+ /// IP 端口号
+ ///
+ public int IPPort { get { return _mIPPort; } set { _mIPPort = value; OnPropertyChanged(); } }
+ private int _mIPPort;
+
///
- /// 端口号
+ /// ip 串口 站号
///
- Port,
+ public int StationNo { get { return _mStationNo; } set { _mStationNo = value; OnPropertyChanged(); } }
+ private int _mStationNo;
+
+
///
- /// 串口端口号
+ /// 串口单口号
///
- SerialPort,
+ public string SerialPort { get { return _mSerialPort; } set { _mSerialPort = value; OnPropertyChanged(); } }
+ private string _mSerialPort;
+
///
/// 波特率
///
- BaudRate,
+ public int BaudRate { get { return _mBaudRate; } set { _mBaudRate = value; OnPropertyChanged(); } }
+ private int _mBaudRate;
+
///
/// 数据位
///
- DataBits,
+ public int DataBits { get { return _mDataBits; } set { _mDataBits = value; OnPropertyChanged(); } }
+ private int _mDataBits;
+
///
/// 停止位
///
- StopBits,
+ public string StopBits { get { return _mStopBits; } set { _mStopBits = value; OnPropertyChanged(); } }
+ private string _mStopBits;
+
///
/// 校验位
///
- Parity,
+ public string Parity { get { return _mParity; } set { _mParity = value; OnPropertyChanged(); } }
+ private string _mParity;
+
}
+
+ //public enum CommunicationParType
+ //{
+ // ///
+ // /// IP地址
+ // ///
+ // IPAddress,
+ // ///
+ // /// 端口号
+ // ///
+ // Port,
+ // ///
+ // /// 串口端口号
+ // ///
+ // SerialPort,
+ // ///
+ // /// 波特率
+ // ///
+ // BaudRate,
+ // ///
+ // /// 数据位
+ // ///
+ // DataBits,
+ // ///
+ // /// 停止位
+ // ///
+ // StopBits,
+ // ///
+ // /// 校验位
+ // ///
+ // Parity,
+ //}
}
diff --git a/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs b/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs
index e7e0de7c..a919b862 100644
--- a/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs
+++ b/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs
@@ -8,11 +8,16 @@ using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using BPASmartClient.ViewModel.Model;
using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using System.Windows;
namespace BPASmartClient.ViewModel
{
public class ShopDeviceConfigViewModel : ObservableObject
{
+ private DeviceConfigModel configModel = new DeviceConfigModel();
+
public ShopDeviceConfigViewModel()
{
ActionManage.GetInstance.Register(new Action