ソースを参照

设备类型修改

样式分支
pry 2年前
コミット
a28b81537c
17個のファイルの変更531行の追加214行の削除
  1. +1
    -1
      BPASmartClient.Business/BPASmartClient.Business.csproj
  2. +4
    -3
      BPASmartClient.Business/Plugin/OrderProxy.cs
  3. +1
    -1
      BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
  4. +34
    -0
      BPASmartClient.CustomResource/Converters/VisibleTypeConverter.cs
  5. +1
    -1
      BPASmartClient.Device/BPASmartClient.Device.csproj
  6. +0
    -38
      BPASmartClient.Modbus/ModbusTcp.cs
  7. +1
    -1
      BPASmartClient.Model/BPASmartClient.Model.csproj
  8. +6
    -1
      BPASmartClient.Model/订单/OrderStatusChangedEvent.cs
  9. +4
    -4
      BPASmartClient.MorkT/Control_MorkT.cs
  10. +81
    -21
      BPASmartClient.ViewModel/Model/DeviceConfigModel.cs
  11. +197
    -22
      BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs
  12. +17
    -18
      BPASmartClient/App.config
  13. +1
    -0
      BPASmartClient/App.xaml
  14. +117
    -101
      BPASmartClient/Control/ShopDeviceConfigView.xaml
  15. +64
    -0
      BPASmartClient/Control/ShopDeviceConfigView.xaml.cs
  16. +1
    -1
      BPASmartClient/DeviceInfo.xml
  17. +1
    -1
      HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj

+ 1
- 1
BPASmartClient.Business/BPASmartClient.Business.csproj ファイルの表示

@@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="BPA.ApolloClient" Version="1.0.12" />
<PackageReference Include="BPA.Message" Version="1.0.24" />
<PackageReference Include="BPA.Message" Version="1.0.26" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />


+ 4
- 3
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<ConfigMgr>().ClientId;
var temp = BPAPackage.Make(orderStatusChange, clientId, orderStatusChangedEvent.deviceClientType);
var q = temp.Serialize(false);
Plugin.GetInstance().GetPlugin<MQTTMgr>().Publish(TOPIC.GetInstance.GetAppTopic(clientId.ToString()), temp.Serialize(false));
#endregion
}


+ 1
- 1
BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj ファイルの表示

@@ -200,7 +200,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.24" />
<PackageReference Include="BPA.Message" Version="1.0.26" />
</ItemGroup>

<ItemGroup>


+ 34
- 0
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();
}
}
}

+ 1
- 1
BPASmartClient.Device/BPASmartClient.Device.csproj ファイルの表示

@@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.24" />
<PackageReference Include="BPA.Message" Version="1.0.26" />
</ItemGroup>

<ItemGroup>


+ 0
- 38
BPASmartClient.Modbus/ModbusTcp.cs ファイルの表示

@@ -452,44 +452,6 @@ namespace BPASmartClient.Modbus
master.WriteSingleRegister(slaveAddress, startAddress, value);
}
#endregion





}


public enum ReadType
{
/// <summary>
/// 读线圈
/// </summary>
Coils,
/// <summary>
/// 读输入线圈
/// </summary>
Inputs,
/// <summary>
/// 读保持寄存器
/// </summary>
HoldingRegisters,
/// <summary>
/// 读输入寄存器
/// </summary>
InputRegisters,
}

public enum WriteType
{
/// <summary>
/// 写线圈
/// </summary>
Coils,
/// <summary>
/// 写保持寄存器
/// </summary>
HoldingRegisters,
}

public enum CommandType


+ 1
- 1
BPASmartClient.Model/BPASmartClient.Model.csproj ファイルの表示

@@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.24" />
<PackageReference Include="BPA.Message" Version="1.0.26" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
</ItemGroup>



+ 6
- 1
BPASmartClient.Model/订单/OrderStatusChangedEvent.cs ファイルの表示

@@ -10,7 +10,7 @@ namespace BPASmartClient.Model
/// <summary>
/// 订单状态改变事件
/// </summary>
public class OrderStatusChangedEvent:BaseEvent
public class OrderStatusChangedEvent : BaseEvent
{
/// <summary>
/// 子订单ID
@@ -20,5 +20,10 @@ namespace BPASmartClient.Model
/// 状态
/// </summary>
public ORDER_STATUS Status { get; set; }

/// <summary>
/// 商品名称
/// </summary>
public string GoodName { get; set; }
}
}

+ 4
- 4
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;
}


}


+ 81
- 21
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
/// </summary>
public class DeviceConfigModel : ObservableObject
{

/// <summary>
/// 店铺名称
/// </summary>
@@ -28,7 +30,7 @@ namespace BPASmartClient.ViewModel.Model
/// <summary>
/// 设备集合
/// </summary>
public ObservableCollection<DeviceModel> deviceModels = new ObservableCollection<DeviceModel>();
public ObservableCollection<DeviceModel> deviceModels { get; set; } = new ObservableCollection<DeviceModel>();
}

/// <summary>
@@ -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;


/// <summary>
/// 设备ID
/// </summary>
@@ -57,7 +64,7 @@ namespace BPASmartClient.ViewModel.Model
/// <summary>
/// 通讯模块
/// </summary>
public ObservableCollection<CommunicationModel> communicationDevcies = new ObservableCollection<CommunicationModel>();
public ObservableCollection<CommunicationModel> communicationDevcies { get; set; } = new ObservableCollection<CommunicationModel>();

}

@@ -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
/// </summary>
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;
/// <summary>
/// 通讯类型,false:串口,true:网口
/// </summary>
public bool CommunicationType { get { return _mCommunicationType; } set { _mCommunicationType = value; OnPropertyChanged(); } }
private bool _mCommunicationType;

}

public enum CommunicationParType
{
/// <summary>
/// IP地址
/// </summary>
IPAddress,
public string IPAddress { get { return _mIPAddress; } set { _mIPAddress = value; OnPropertyChanged(); } }
private string _mIPAddress;

/// <summary>
/// IP 端口号
/// </summary>
public int IPPort { get { return _mIPPort; } set { _mIPPort = value; OnPropertyChanged(); } }
private int _mIPPort;

/// <summary>
/// 端口号
/// ip 串口 站
/// </summary>
Port,
public int StationNo { get { return _mStationNo; } set { _mStationNo = value; OnPropertyChanged(); } }
private int _mStationNo;


/// <summary>
/// 串口端口号
/// 串口口号
/// </summary>
SerialPort,
public string SerialPort { get { return _mSerialPort; } set { _mSerialPort = value; OnPropertyChanged(); } }
private string _mSerialPort;

/// <summary>
/// 波特率
/// </summary>
BaudRate,
public int BaudRate { get { return _mBaudRate; } set { _mBaudRate = value; OnPropertyChanged(); } }
private int _mBaudRate;

/// <summary>
/// 数据位
/// </summary>
DataBits,
public int DataBits { get { return _mDataBits; } set { _mDataBits = value; OnPropertyChanged(); } }
private int _mDataBits;

/// <summary>
/// 停止位
/// </summary>
StopBits,
public string StopBits { get { return _mStopBits; } set { _mStopBits = value; OnPropertyChanged(); } }
private string _mStopBits;

/// <summary>
/// 校验位
/// </summary>
Parity,
public string Parity { get { return _mParity; } set { _mParity = value; OnPropertyChanged(); } }
private string _mParity;

}

//public enum CommunicationParType
//{
// /// <summary>
// /// IP地址
// /// </summary>
// IPAddress,
// /// <summary>
// /// 端口号
// /// </summary>
// Port,
// /// <summary>
// /// 串口端口号
// /// </summary>
// SerialPort,
// /// <summary>
// /// 波特率
// /// </summary>
// BaudRate,
// /// <summary>
// /// 数据位
// /// </summary>
// DataBits,
// /// <summary>
// /// 停止位
// /// </summary>
// StopBits,
// /// <summary>
// /// 校验位
// /// </summary>
// Parity,
//}
}

+ 197
- 22
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<object[]>((o) =>
@@ -21,43 +26,213 @@ namespace BPASmartClient.ViewModel
{
if (par.Length == 2)
{
ShopName = par[0];
ShopId = par[1];
configModel.ShopName = par[0];
configModel.ShopId = par[1];
deviceConfig.Add(configModel);
}
}
}), "ShopPar");

ObservableCollection<DeviceModel> deviceModels = new ObservableCollection<DeviceModel>();
ObservableCollection<CommunicationModel> communicationModels = new ObservableCollection<CommunicationModel>();
communicationModels.Add(new CommunicationModel() { CommunicationName = "通讯1", CommunicationModule = "qidong" });
deviceModels.Add(new DeviceModel() { DeviceName = "设备1", DeviceId = "10", DeviceModule = "aa", communicationDevcies = communicationModels });
deviceConfig = new DeviceConfigModel()
NewDeviceCommand = new RelayCommand<object>(NewDevice);
RemoveDeviceCommand = new RelayCommand<object>(RemoveDevice);
NewCommunicationCommand = new RelayCommand<object>(NewCommunication);
RemoveCommunicationCommand = new RelayCommand<object>(RemoveCommunication);
}

private void RemoveCommunication(object? obj)
{
if (obj != null && obj is CommunicationModel com)
{
ShopName = "且时且多",
ShopId = "10",
deviceModels = deviceModels
};
if (com != null)
{
int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.Id == com.DeviceModelId);
if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count)
{
var res = deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.FirstOrDefault(p => p.CommunicationName == com.CommunicationName);
if (res != null)
{
deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.Remove(res);
}
}
}
}
}

NewDeviceCommand = new RelayCommand<string>((o) =>
private void NewCommunication(object? obj)
{
if (obj != null && obj is DeviceModel dm)
{
if (dm != null)
{
string CommunicationName = string.Empty;
int num = 1;
while (true)
{
int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.DeviceName == dm.DeviceName);
if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count)
{
var res = deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.FirstOrDefault(p => p.CommunicationName.Contains($"Communication_{num}"));
if (res == null)
{
deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.Add(new CommunicationModel()
{
CommunicationName = $"Communication_{num}",
DeviceModelId = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == dm.DeviceName)?.Id,
communicationPar = new CommunicationPar() { CommunicationType = false }

});
});
break;
}
}
else break;
num++;
}
}
}
}

private void RemoveDevice(object? obj)
{
if (obj != null && deviceConfig.Count == 1)
{
string DeviceName = obj?.ToString();
var res = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == DeviceName);
if (res != null)
deviceConfig.ElementAt(0).deviceModels.Remove(res);
}
}

public Action NewCommand { get; set; }
private void NewDevice(object? obj)
{
if (obj != null && deviceConfig.Count == 1)
{
string DeviceName = string.Empty;
int num = 1;
while (true)
{
var res = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == $"Device_{num}");
if (res == null)
{
deviceConfig.ElementAt(0).deviceModels.Add(new DeviceModel() { DeviceId = "0", DeviceName = $"Device_{num}", Id = Guid.NewGuid().ToString() });
break;
}
num++;
}
}
}


public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
private static void OnStaticPropertyChanged([CallerMemberName] string PropName = "")
{
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName));
}


//public static string DeviceNamePar
//{
// get { return _mDeviceNamePar; }
// set
// {
// _mDeviceNamePar = value;
// if (deviceConfig.Count == 1)
// {
// int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.DeviceName == DeviceName);
// if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count)
// {
// deviceConfig.ElementAt(0).deviceModels.ElementAt(index).DeviceName = value;
// }
// }
// OnStaticPropertyChanged();
// }
//}
//private static string _mDeviceNamePar;

//public static string DeviceIdPar
//{
// get { return _mDeviceIdPar; }
// set
// {
// _mDeviceIdPar = value;
// if (deviceConfig.Count == 1)
// {
// int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.DeviceName == DeviceName);
// if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count)
// {
// deviceConfig.ElementAt(0).deviceModels.ElementAt(index).DeviceId = value;
// }
// }
// OnStaticPropertyChanged();
// }
//}
//private static string _mDeviceIdPar;

public static Visibility DeviceParVisibility { get { return _mDeviceParVisibility; } set { _mDeviceParVisibility = value; OnStaticPropertyChanged(); } }
private static Visibility _mDeviceParVisibility = Visibility.Hidden;
public static Visibility CommunicationVisibility { get { return _mCommunicationVisibility; } set { _mCommunicationVisibility = value; OnStaticPropertyChanged(); } }
private static Visibility _mCommunicationVisibility = Visibility.Hidden;




//public static string DeviceModelId
//{
// get { return _mDeviceModelId; }
// set
// {
// _mDeviceModelId = value;

// }
//}
//private static string _mDeviceModelId;


//public static string DeviceName
//{
// get { return _mDeviceName; }
// set
// {
// _mDeviceName = value;
// if (deviceConfig.Count == 1)
// {
// var res = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == value);
// if (res != null)
// {
// DeviceIdPar = res.DeviceId;
// DeviceNamePar = res.DeviceName;
// }
// }
// }
//}
//private static string _mDeviceName;


//public static string CommunicationName { get; set; }



/// <summary>
/// 新建设备
/// </summary>
public RelayCommand<object> NewDeviceCommand { get; set; }

public RelayCommand<string> NewDeviceCommand { get; set; }
/// <summary>
/// 删除设备
/// </summary>
public RelayCommand<object> RemoveDeviceCommand { get; set; }

public string ShopName { get { return _mShopName; } set { _mShopName = value; OnPropertyChanged(); } }
private string _mShopName = "店铺名称";
/// <summary>
/// 新建通讯
/// </summary>
public RelayCommand<object> NewCommunicationCommand { get; set; }

public string ShopId { get { return _mShopId; } set { _mShopId = value; OnPropertyChanged(); } }
private string _mShopId;
/// <summary>
/// 删除通讯
/// </summary>
public RelayCommand<object> RemoveCommunicationCommand { get; set; }

public ObservableCollection<DeviceConfigModel> deviceConfig = new ObservableCollection<DeviceConfigModel>();
public static ObservableCollection<DeviceConfigModel> deviceConfig { get; set; } = new ObservableCollection<DeviceConfigModel>();

//public DeviceConfigModel deviceConfig { get { return _mdeviceConfig; } set { _mdeviceConfig = value; OnPropertyChanged(); } }
//private DeviceConfigModel _mdeviceConfig;


}


+ 17
- 18
BPASmartClient/App.config ファイルの表示

@@ -3,7 +3,7 @@
<appSettings>
<!--通用配置-->
<!--1:且时且多冰淇淋咖啡机,2:且时且多煮面机,3:海科煮面机测试店铺-->
<add key="ClientId" value="43"/>
<add key="ClientId" value="46"/>
<!--<add key="ApolloUri" value="http://10.2.1.21:28080"/>
<add key="OrderServiceUri" value="http://10.2.1.26:21527/order/"/>
<add key="StockServiceUri" value="http://10.2.1.26:21527/stock/"/>-->
@@ -12,35 +12,34 @@
<!--<add key="ClientId" value="2"/>-->

<!--开发环境-->
<!--<add key="ApolloUri" value="http://10.2.1.21:28080"/>
<add key="OrderServiceUri" value="https://bpa.black-pa.com:21527/order/"/>
<add key="StockServiceUri" value="https://bpa.black-pa.com:21527/stock/"/>
<add key="DataVServiceUri" value="https://bpa.black-pa.com:21527/datav"/>
<add key="WebServiceUri" value="https://bpa.black-pa.com:21527"/>-->
<add key="apollouri" value="http://10.2.1.21:28080"/>
<add key="orderserviceuri" value="https://bpa.black-pa.com:21527/order/"/>
<add key="stockserviceuri" value="https://bpa.black-pa.com:21527/stock/"/>
<add key="datavserviceuri" value="https://bpa.black-pa.com:21527/datav"/>
<add key="webserviceuri" value="https://bpa.black-pa.com:21527"/>
<add key="broadcastpubtopic" value="/broadcast/grgpechsl7q/transit_test_setdevice"/>

<add key="BroadcastPubTopic" value="/broadcast/grgpECHSL7q/Transit_Test_SetDevice"/>
<add key="AppId" value="order"/>
<add key ="Namespaces" value="TEST1.Config"/>
<add key="IsEnableTest" value="false"/>
<add key="IsEnableTest" value="true"/>

<!--测试环境-->
<!--<add key="ApolloUri" value="http://10.2.1.21:28070"/>
<add key="OrderServiceUri" value="https://bpa.black-pa.com:21528/order/"/>
<add key="StockServiceUri" value="https://bpa.black-pa.com:21528/stock/"/>
<add key="DataVServiceUri" value="https://bpa.black-pa.com:21527/datav"/>
<add key="WebServiceUri" value="https://bpa.black-pa.com:21528/stock/"/>
<add key="BroadcastPubTopic" value="/broadcast/grgpECHSL7q/Transit_Test_SetDevice"/>
<add key="AppId" value="dev1_common"/>
<add key ="Namespaces" value="DEV.test1.Config"/>-->
<add key="OrderServiceUri" value="https://bpa.black-pa.com:21528/order/"/>
<add key="StockServiceUri" value="https://bpa.black-pa.com:21528/stock/"/>
<add key="DataVServiceUri" value="https://bpa.black-pa.com:21527/datav"/>
<add key="WebServiceUri" value="https://bpa.black-pa.com:21528/stock/"/>
<add key="BroadcastPubTopic" value="/broadcast/grgpECHSL7q/Transit_Test_SetDevice"/>
<add key="AppId" value="dev1_common"/>
<add key ="Namespaces" value="DEV.test1.Config"/>-->

<!--正式环境-->
<add key="ApolloUri" value="http://47.108.65.220:28080"/>
<!--<add key="ApolloUri" value="http://47.108.65.220:28080"/>
<add key="OrderServiceUri" value="https://witt.black-pa.com/order/"/>
<add key="StockServiceUri" value="https://witt.black-pa.com/stock/"/>
<add key="DataVServiceUri" value="https://witt.black-pa.com/datav"/>
<add key="WebServiceUri" value="https://witt.black-pa.com"/>
<add key="BroadcastPubTopic" value="/broadcast/grgpECHSL7q/Transit_SetDevice"/>
<add key="BroadcastPubTopic" value="/broadcast/grgpECHSL7q/Transit_SetDevice"/>-->

<!--阿里云上报启动方式:API 或者 LOCAL-->
<!--API :通过客户端ID,调用接口查询“设备连接信息”-->


+ 1
- 0
BPASmartClient/App.xaml ファイルの表示

@@ -21,6 +21,7 @@
<ResourceDictionary>
<con:ColorConverter x:Key="ColorConverter" />
<con:TextConverter x:Key="TextConverter" />
<con:VisibleTypeConverter x:Key="VisibleTypeConverter" />
</ResourceDictionary>

<ResourceDictionary>


+ 117
- 101
BPASmartClient/Control/ShopDeviceConfigView.xaml ファイルの表示

@@ -12,15 +12,13 @@
d:DesignWidth="1200"
mc:Ignorable="d">

<UserControl.DataContext>
<vm:ShopDeviceConfigViewModel />
</UserControl.DataContext>

<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>

<vm:ShopDeviceConfigViewModel x:Key="sdv" />

<Style x:Key="TextBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="楷体" />
<Setter Property="FontSize" Value="18" />
@@ -322,6 +320,10 @@
</ResourceDictionary>
</UserControl.Resources>

<UserControl.DataContext>
<Binding Source="{StaticResource sdv}" />
</UserControl.DataContext>

<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="55" />
@@ -395,99 +397,99 @@

<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="250" />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<Grid>

<TreeView ItemsSource="{Binding deviceConfig}" Background="Transparent" BorderThickness="0">
<TreeView
Name="tv"
Background="Transparent"
BorderThickness="1"
ItemsSource="{Binding deviceConfig}"
MouseRightButtonDown="tv_MouseRightButtonDown"
PreviewMouseRightButtonDown="tv_PreviewMouseRightButtonDown"
SelectedItemChanged="TreeView_SelectedItemChanged">
<TreeView.Resources>

<!-- 店铺信息 -->
<HierarchicalDataTemplate DataType="{x:Type vmm:DeviceConfigModel}" ItemsSource="{Binding deviceModels}">
<StackPanel>
<TextBlock Text="{Binding DeviceName}" />
<TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding ShopName}">
<TextBlock.ContextMenu>
<ContextMenu>
<MenuItem
Command="{Binding NewDeviceCommand, Source={StaticResource sdv}}"
CommandParameter="{Binding}"
Header="新建设备" />
</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>
</StackPanel>
</HierarchicalDataTemplate>

<!-- 设备信息 -->
<HierarchicalDataTemplate DataType="{x:Type vmm:DeviceModel}" ItemsSource="{Binding communicationDevcies}">
<StackPanel>
<TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding DeviceName}">
<TextBlock.ContextMenu>
<ContextMenu>
<MenuItem
Command="{Binding NewCommunicationCommand, Source={StaticResource sdv}}"
CommandParameter="{Binding}"
Header="新建通讯" />
<MenuItem
Command="{Binding RemoveDeviceCommand, Source={StaticResource sdv}}"
CommandParameter="{Binding}"
Header="删除设备" />
</ContextMenu>
</TextBlock.ContextMenu>

<!--<TextBlock.Style>
<Style TargetType="{x:Type 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" />
<EventSetter Event="MouseRightButtonDown" Handler="DeviceInfo" />
</Style>
</TextBlock.Style>-->

</TextBlock>
</StackPanel>
</HierarchicalDataTemplate>

<!-- 通讯模块信息 -->
<DataTemplate DataType="{x:Type vmm:CommunicationModel}">
<StackPanel>
<TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding CommunicationName}">
<TextBlock.ContextMenu>
<ContextMenu>
<MenuItem
Command="{Binding RemoveCommunicationCommand, Source={StaticResource sdv}}"
CommandParameter="{Binding}"
Header="删除通讯" />
</ContextMenu>
</TextBlock.ContextMenu>

<!--<TextBlock.Style>
<Style TargetType="{x:Type 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" />
<EventSetter Event="MouseRightButtonDown" Handler="CommunicationInfo" />
</Style>
</TextBlock.Style>-->

</TextBlock>
</StackPanel>
</DataTemplate>
</TreeView.Resources>
</TreeView>

<!--<TreeView
Background="Transparent"
BorderThickness="1"
ItemsSource="{Binding deviceConfig}">
-->
<!-- 设置店铺 -->
<!--
<TreeViewItem Header="{Binding ShopName}" Style="{StaticResource TreeviewItemStyle}">
<TreeViewItem.ContextMenu>
<ContextMenu>
<MenuItem
Command="{Binding DataContent.NewDeviceCommand}"
CommandParameter="{Binding ShopName}"
Header="新建设备" />
</ContextMenu>
</TreeViewItem.ContextMenu>
-->
<!-- 设置多个设备 -->
<!--
<TreeView
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding deviceConfig.deviceModels}">
<TreeViewItem Header="{Binding DeviceName}" Style="{StaticResource TreeviewItemStyle}">
<TreeViewItem.ContextMenu>
<ContextMenu>
<MenuItem Header="新建通讯" />
<MenuItem Header="删除设备" />
</ContextMenu>
</TreeViewItem.ContextMenu>

-->
<!-- 设置通讯 -->
<!--
<TreeView
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding communicationDevcies}">
<TreeViewItem Header="{Binding CommunicationName}" Style="{StaticResource TreeviewItemStyle}">
<TreeViewItem.ContextMenu>
<ContextMenu>
<MenuItem Header="删除" />
</ContextMenu>
</TreeViewItem.ContextMenu>
</TreeViewItem>
</TreeView>

</TreeViewItem>


</TreeView>
-->
<!--<TreeViewItem Header="冰淇淋机设备" Style="{StaticResource TreeviewItemStyle}">
<TreeViewItem.ContextMenu>
<ContextMenu>
<MenuItem Header="新建通讯" />
<MenuItem Header="删除设备" />
</ContextMenu>
</TreeViewItem.ContextMenu>
<TreeViewItem Header="单片机通讯" Style="{StaticResource TreeviewItemStyle}">
<TreeViewItem.ContextMenu>
<ContextMenu>
<MenuItem Header="删除" />
</ContextMenu>
</TreeViewItem.ContextMenu>
</TreeViewItem>
<TreeViewItem Header="乐百机器人通讯" Style="{StaticResource TreeviewItemStyle}">
<TreeViewItem.ContextMenu>
<ContextMenu>
<MenuItem Header="删除" />
</ContextMenu>
</TreeViewItem.ContextMenu>
</TreeViewItem>
</TreeViewItem>-->
<!--
</TreeViewItem>
</TreeView>-->
</Grid>

<Grid Grid.Column="1" Margin="10">
@@ -511,6 +513,20 @@
<ColumnDefinition />
</Grid.ColumnDefinitions>

<UniformGrid
Grid.Column="1"
VerticalAlignment="Center"
Columns="2">
<RadioButton
Content="网口"
FontSize="16"
Foreground="{StaticResource TextBlockForeground}" />
<RadioButton
Content="串口"
FontSize="16"
Foreground="{StaticResource TextBlockForeground}" />
</UniformGrid>

<TextBlock
Grid.Column="2"
HorizontalAlignment="Right"
@@ -522,7 +538,7 @@
Width="170"
HorizontalAlignment="Left"
Style="{StaticResource TextBoxStyle}"
Text="{Binding ShopName}" />
Text="{Binding deviceConfig[0].ShopName}" />

<TextBlock
Grid.Column="4"
@@ -535,13 +551,13 @@
Width="170"
HorizontalAlignment="Left"
Style="{StaticResource TextBoxStyle}"
Text="{Binding ShopId}" />
Text="{Binding deviceConfig[0].ShopId}" />

</Grid>


<!-- 设备参数 -->
<Grid Grid.Row="1">
<Grid Grid.Row="1" Visibility="{Binding DeviceParVisibility}">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
@@ -584,7 +600,7 @@
Margin="0"
HorizontalAlignment="Left"
Style="{StaticResource TextBoxStyle}"
Text="255.255.255.255" />
Text="{Binding SelectedValue.DeviceName, ElementName=tv, Mode=TwoWay}" />

<TextBlock
Grid.Column="4"
@@ -598,12 +614,12 @@
Margin="0"
HorizontalAlignment="Left"
Style="{StaticResource TextBoxStyle}"
Text="" />
Text="{Binding SelectedValue.DeviceId, ElementName=tv, Mode=TwoWay}" />

</Grid>

<!--#region TCP 通讯参数-->
<Grid Grid.Row="2">
<Grid Grid.Row="1" Visibility="{Binding SelectedValue.communicationPar.CommunicationType, ElementName=tv, Mode=TwoWay, Converter={StaticResource VisibleTypeConverter}, ConverterParameter=NetworkPort}">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
@@ -623,7 +639,7 @@
Width="170"
HorizontalAlignment="Left"
Style="{StaticResource TextBoxStyle}"
Text="{Binding Path=Device.IP}" />
Text="{Binding SelectedValue.communicationPar.IPAddress, ElementName=tv, Mode=TwoWay}" />

<TextBlock
Grid.Column="2"
@@ -635,7 +651,7 @@
Width="170"
HorizontalAlignment="Left"
Style="{StaticResource TextBoxStyle}"
Text="{Binding Path=Device.PortNum}" />
Text="{Binding SelectedValue.communicationPar.IPPort, ElementName=tv, Mode=TwoWay}" />

<TextBlock
Grid.Column="4"
@@ -647,7 +663,7 @@
Width="170"
HorizontalAlignment="Left"
Style="{StaticResource TextBoxStyle}"
Text="{Binding Path=Device.StationNo}" />
Text="{Binding SelectedValue.communicationPar.StationNo, ElementName=tv, Mode=TwoWay}" />

</Grid>

@@ -657,7 +673,7 @@
<Grid
Grid.Row="2"
Grid.RowSpan="2"
Visibility="Hidden">
Visibility="{Binding SelectedValue.communicationPar.CommunicationType, ElementName=tv, Mode=TwoWay, Converter={StaticResource VisibleTypeConverter}, ConverterParameter=SerialPort}">

<Grid.RowDefinitions>
<RowDefinition />
@@ -694,7 +710,7 @@
ItemsSource="{Binding Path=Device.Ports}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding Path=Device.ComSerialPort}" />
Text="{Binding SelectedValue.communicationPar.SerialPort, ElementName=tv, Mode=TwoWay}" />

<TextBlock
Grid.Row="0"
@@ -717,7 +733,7 @@
ItemsSource="{Binding Path=Device.BaudRates}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding Path=Device.BaudRate}" />
Text="{Binding SelectedValue.communicationPar.BaudRate, ElementName=tv, Mode=TwoWay}" />

<TextBlock
Grid.Row="0"
@@ -740,7 +756,7 @@
ItemsSource="{Binding Path=Device.Paritys}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding Path=Device.Parity}" />
Text="{Binding SelectedValue.communicationPar.Parity, ElementName=tv, Mode=TwoWay}" />

<TextBlock
Grid.Row="1"
@@ -754,7 +770,7 @@
Width="170"
HorizontalAlignment="Left"
Style="{StaticResource TextBoxStyle}"
Text="{Binding Path=Device.DataBit}" />
Text="{Binding SelectedValue.communicationPar.DataBits, ElementName=tv, Mode=TwoWay}" />

<TextBlock
Grid.Row="1"
@@ -768,7 +784,7 @@
Width="170"
HorizontalAlignment="Left"
Style="{StaticResource TextBoxStyle}"
Text="{Binding Path=Device.StopBit}" />
Text="{Binding SelectedValue.communicationPar.StopBits, ElementName=tv, Mode=TwoWay}" />

<TextBlock
Grid.Row="1"
@@ -782,7 +798,7 @@
Width="170"
HorizontalAlignment="Left"
Style="{StaticResource TextBoxStyle}"
Text="{Binding Path=Device.StationNo}" />
Text="{Binding SelectedValue.communicationPar.StationNo, ElementName=tv, Mode=TwoWay}" />
</Grid>
<!--#endregion-->



+ 64
- 0
BPASmartClient/Control/ShopDeviceConfigView.xaml.cs ファイルの表示

@@ -13,6 +13,8 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BPASmartClient.DialogWindow;
using BPASmartClient.ViewModel;
using BPASmartClient.ViewModel.Model;

namespace BPASmartClient.Control
{
@@ -31,5 +33,67 @@ namespace BPASmartClient.Control
NewShopWindow newShopWindow = new NewShopWindow();
newShopWindow.ShowDialog();
}

private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{

Refresh();
}

private void tv_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
//if (e.ButtonState == MouseButtonState.Pressed)
//{
// Refresh();
//}
}

private void Refresh()
{
if (this.tv.SelectedValue is DeviceConfigModel deviceConfigModel)
{
//ShopDeviceConfigViewModel.ShopName = deviceConfigModel.ShopName;
}
else if (this.tv.SelectedValue is DeviceModel deviceModel)
{
ShopDeviceConfigViewModel.DeviceParVisibility = Visibility.Visible;
ShopDeviceConfigViewModel.CommunicationVisibility = Visibility.Hidden;
//ShopDeviceConfigViewModel.DeviceName = deviceModel.DeviceName;
}
else if (this.tv.SelectedValue is CommunicationModel communicationModel)
{
ShopDeviceConfigViewModel.CommunicationVisibility = Visibility.Visible;
ShopDeviceConfigViewModel.DeviceParVisibility = Visibility.Hidden;
//ShopDeviceConfigViewModel.CommunicationName = communicationModel.CommunicationName;
//ShopDeviceConfigViewModel.DeviceModelId = communicationModel.DeviceModelId;
}
}

private void tv_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{

}

private void DeviceInfo(object sender, MouseButtonEventArgs e)
{
var tb = sender as TextBlock;
if (tb != null)
{
//ShopDeviceConfigViewModel.DeviceName = tb.Text.Trim();
//tb.Background = Brushes.Blue;
}
}
private void CommunicationInfo(object sender, MouseButtonEventArgs e)
{
//var tb = sender as TextBlock;
//if (tb != null)
//{
// ShopDeviceConfigViewModel.CommunicationName = tb.Text.Trim();
// ShopDeviceConfigViewModel.DeviceModelId = tb.Tag.ToString();
// tb.Focus();
// //tb.Background = Brushes.Blue;

//}
}
}
}

+ 1
- 1
BPASmartClient/DeviceInfo.xml ファイルの表示

@@ -38,7 +38,7 @@
</Peripherals>
</Device>-->

<Device Name="Morks" Module="BPASmartClient.MorkS.Control" DeviceId="26">
<Device Name="Morks" Module="BPASmartClient.MorkS.Control" DeviceId="28">
<Peripherals>
<Peripheral Module="BPASmartClient.PLC.MorksMachine">
<Parameters>


+ 1
- 1
HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj ファイルの表示

@@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.24" />
<PackageReference Include="BPA.Message" Version="1.0.26" />
<PackageReference Include="BPA.Models" Version="1.0.10" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
</ItemGroup>


読み込み中…
キャンセル
保存