@@ -20,41 +20,41 @@ namespace HBLConsole.Communication | |||
Json<CommunicationPar>.Read(); | |||
foreach (var item in Json<CommunicationPar>.Data.communicationSets) | |||
{ | |||
if (item.ClientDeviceType == GVL.GeneralConfig.DeviceType.ToString()) | |||
//if (item.ClientDeviceType == GVL.GeneralConfig.DeviceType.ToString()) | |||
//{ | |||
if (item.IsActive) | |||
{ | |||
if (item.IsActive) | |||
switch (item.deviceType) | |||
{ | |||
switch (item.deviceType) | |||
{ | |||
case EDeviceType.Siemens: | |||
break; | |||
case EDeviceType.ModbusRtu: | |||
if (item.Device is ModbusRtu rtu) | |||
{ | |||
//咖啡机主控程序 | |||
//private CoffeeMachine coffeeMachine; | |||
////冰淇淋主控程序 | |||
//private IceCreamMachine iceCreamMachine; | |||
} | |||
break; | |||
case EDeviceType.ModbusTcp: | |||
if (item.Device is ModbusTcp modbus) | |||
{ | |||
ModbusTcpHelper.GetInstance.ModbusTcpConnect(modbus.IP, modbus.PortNum); | |||
} | |||
break; | |||
case EDeviceType.SerialPort: | |||
break; | |||
case EDeviceType.Lebai: | |||
if (item.Device is ModbusTcp tcp) | |||
{ | |||
LebaiHelper.GetInstance.Connect(tcp.IP); | |||
} | |||
break; | |||
default: | |||
break; | |||
} | |||
case EDeviceType.Siemens: | |||
break; | |||
case EDeviceType.ModbusRtu: | |||
if (item.Device is ModbusRtu rtu) | |||
{ | |||
//咖啡机主控程序 | |||
//private CoffeeMachine coffeeMachine; | |||
////冰淇淋主控程序 | |||
//private IceCreamMachine iceCreamMachine; | |||
} | |||
break; | |||
case EDeviceType.ModbusTcp: | |||
if (item.Device is ModbusTcp modbus) | |||
{ | |||
ModbusTcpHelper.GetInstance.ModbusTcpConnect(modbus.IP, modbus.PortNum); | |||
} | |||
break; | |||
case EDeviceType.SerialPort: | |||
break; | |||
case EDeviceType.Lebai: | |||
if (item.Device is ModbusTcp tcp) | |||
{ | |||
LebaiHelper.GetInstance.Connect(tcp.IP); | |||
} | |||
break; | |||
default: | |||
break; | |||
} | |||
//} | |||
} | |||
} | |||
ActionOperate.GetInstance.Send($"{GVL.GeneralConfig.DeviceType.ToString()}/ConnectOk"); | |||
@@ -115,6 +115,7 @@ namespace HBLConsole.MORKD | |||
public void PutNoodleTakeMealCompleteReset() | |||
{ | |||
ModbusTcpHelper.GetInstance.Write(1148, WriteType.Coils, false); | |||
OutNoodleing = false; | |||
} | |||
/// <summary> | |||
@@ -19,10 +19,7 @@ namespace HBLConsole.MainConsole | |||
private volatile static Main _Instance; | |||
public static Main GetInstance => _Instance ?? (_Instance = new Main()); | |||
private Main() | |||
{ | |||
//ActionOperate.GetInstance.Register(new Func<object>(() => { return GeneralConfig.DeviceType.ToString(); }), "GetDeviceType"); | |||
} | |||
private Main() { } | |||
List<string> Topics = new List<string>(); | |||
@@ -32,15 +29,7 @@ namespace HBLConsole.MainConsole | |||
GeneralConfig.DeviceType = DeviceClientType.MORKS; | |||
if (Enum.TryParse(deviceType, out DeviceClientType dct)) GeneralConfig.DeviceType = dct; | |||
LocaPath.GetInstance.FilePath = $"AccessFile\\{GeneralConfig.DeviceType.ToString()}\\"; | |||
ThreadOperate.GetInstance.Start(new Action(() => { Sqlite<Alarm>.GetInstance.GetData(); }), "GetAlarm"); | |||
//Json<SetPar>.Read(); | |||
//if (Enum.TryParse(Json<SetPar>.Data.ClientDeviceType, out DeviceClientType dct)) | |||
//{ | |||
// GeneralConfig.DeviceType = dct; | |||
//} | |||
//else { GeneralConfig.DeviceType = DeviceClientType.MORKS; } | |||
Json<MorkOrderPushPar>.Read(); | |||
Json<BatchingInfoPar>.Read(); | |||
Json<SimOrderConfig>.Read(); | |||
@@ -53,7 +42,6 @@ namespace HBLConsole.MainConsole | |||
{ | |||
Json<MorkOrderPushPar>.Save(); | |||
Json<BatchingInfoPar>.Save(); | |||
//Json<SetPar>.Save(); | |||
Json<SimOrderConfig>.Save(); | |||
Json<KeepDataBase>.Save(); | |||
Sqlite<Alarm>.GetInstance.Save(); | |||
@@ -1,5 +1,6 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
@@ -11,6 +12,6 @@ namespace HBLConsole.Model | |||
/// </summary> | |||
public class CommunicationPar | |||
{ | |||
public List<CommunicationSet> communicationSets = new List<CommunicationSet>(); | |||
public ObservableCollection<CommunicationSet> communicationSets { get; set; } = new ObservableCollection<CommunicationSet>(); | |||
} | |||
} |
@@ -12,12 +12,6 @@ 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; } | |||
/// <summary> | |||
/// 使用特性对接口反序列化 | |||
@@ -44,11 +38,5 @@ namespace HBLConsole.Model | |||
public EDeviceType deviceType { get { return _mdeviceType; } set { _mdeviceType = value; OnPropertyChanged(); } } | |||
private EDeviceType _mdeviceType; | |||
/// <summary> | |||
/// 客户端启动设备类型 | |||
/// </summary> | |||
public string ClientDeviceType { get; set; } | |||
public RelayCommand<object> RemoveCommand { get; set; } | |||
} | |||
} |
@@ -13,18 +13,6 @@ namespace HBLConsole.Model | |||
{ | |||
public class KeepDataBase | |||
{ | |||
/// <summary> | |||
/// 模拟订单数据的配置 | |||
/// </summary> | |||
//public ConcurrentDictionary<string, ObservableCollection<SimOrderVisibleData>> simOrderConfig { get; set; } = new ConcurrentDictionary<string, ObservableCollection<SimOrderVisibleData>>(); | |||
/// <summary> | |||
/// 需要保存的订单数据 | |||
/// </summary> | |||
//public ConcurrentDictionary<string, ObservableCollection<OrderData>> orderLists { get; set; } = new ConcurrentDictionary<string, ObservableCollection<OrderData>>(); | |||
//public static ObservableCollection<OrderData> orderStatusLists { get; set; } = new ObservableCollection<OrderData>(); | |||
//public ObservableCollection<SimOrderVisibleData> simOrderConfig { get; set; } = new ObservableCollection<SimOrderVisibleData>(); | |||
/// <summary> | |||
/// 模拟订单数据的配置 | |||
/// </summary> | |||
@@ -35,6 +23,5 @@ namespace HBLConsole.Model | |||
/// </summary> | |||
public ObservableCollection<OrderData> orderLists { get; set; } = new ObservableCollection<OrderData>(); | |||
} | |||
} |
@@ -1,16 +0,0 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace HBLConsole.Model | |||
{ | |||
/// <summary> | |||
/// 设置参数 | |||
/// </summary> | |||
public class SetPar | |||
{ | |||
public string ClientDeviceType { get; set; } | |||
} | |||
} |
@@ -1,5 +1,7 @@ | |||
using System; | |||
using Newtonsoft.Json; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.IO; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
@@ -19,5 +21,37 @@ namespace HBLConsole.Service | |||
if (obj == null || value == null) return -1; | |||
return Array.FindIndex(obj, p => p == value && p.Length > 0); | |||
} | |||
/// <summary> | |||
/// 保存数据 | |||
/// </summary> | |||
public static void Save<T>(this T ot) | |||
{ | |||
string outjson = JsonConvert.SerializeObject(ot); | |||
var str = ot.GetType().GenericTypeArguments; | |||
if (str != null && str.Length > 0) | |||
{ | |||
File.WriteAllText(LocaPath.GetInstance.Getpath(str[0].Name), outjson); | |||
} | |||
} | |||
/// <summary> | |||
/// 获取保存的数据 | |||
/// </summary> | |||
public static void Read(this object ot) | |||
{ | |||
var str = ot.GetType().GenericTypeArguments; | |||
if (str != null && str.Length > 0) | |||
{ | |||
string pa = LocaPath.GetInstance.Getpath(str[0].Name); | |||
if (File.Exists(pa)) | |||
{ | |||
string JsonString = File.ReadAllText(pa); | |||
var result = JsonConvert.DeserializeObject<object>(JsonString); | |||
if (result != null) { Json<object>.Data = result; } | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -43,6 +43,8 @@ namespace HBLConsole.Service | |||
File.WriteAllText(path, outjson); | |||
} | |||
/// <summary> | |||
/// 获取保存的数据 | |||
/// </summary> | |||
@@ -1,5 +1,6 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.IO; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
@@ -15,5 +16,11 @@ namespace HBLConsole.Service | |||
public string FilePath { get; set; } = string.Empty; | |||
public string Getpath(string name) | |||
{ | |||
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{FilePath}\\JSON")); | |||
return $"{AppDomain.CurrentDomain.BaseDirectory}{FilePath}JSON\\{name}.json"; | |||
} | |||
} | |||
} |
@@ -30,14 +30,14 @@ namespace HBLConsole.DialogWindow.View | |||
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.ButClose.Click += (o, e) => { this.Close(); }; | |||
this.MaxWidth = SystemParameters.WorkArea.Width; | |||
this.MaxHeight = SystemParameters.WorkArea.Height; | |||
ActionOperate.GetInstance.Register(new Action<object>((s) => | |||
{ | |||
this.Tag = s; | |||
this.DialogResult = false; | |||
//this.Tag = s; | |||
//this.DialogResult = false; | |||
ActionOperate.GetInstance.CancelRegister("Cancel"); | |||
this.Close(); | |||
@@ -45,40 +45,16 @@ namespace HBLConsole.DialogWindow.View | |||
ActionOperate.GetInstance.Register(new Action<object>((s) => | |||
{ | |||
this.Tag = s; | |||
this.DialogResult = true; | |||
//this.Tag = s; | |||
//this.DialogResult = true; | |||
ActionOperate.GetInstance.CancelRegister("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(); | |||
//} | |||
} | |||
} |
@@ -11,6 +11,9 @@ using Microsoft.Toolkit.Mvvm.Messaging; | |||
using System.Diagnostics; | |||
using HBLConsole.Model; | |||
using HBLConsole.Service; | |||
using System.Reflection; | |||
using HBLConsole.Interface; | |||
using HBLConsole.ViewModel; | |||
namespace HBLConsole.DialogWindow.ViewModel | |||
{ | |||
@@ -25,21 +28,47 @@ namespace HBLConsole.DialogWindow.ViewModel | |||
}); | |||
ConfirmCommand = new RelayCommand(() => | |||
{ | |||
var res = ActionOperate.GetInstance.SendResult("AddDeviceVerify", devcieManagerResult); | |||
if (res != null) | |||
var obj = DeviceManageViewModel.communicationSets.FirstOrDefault(P => P.DeviceName.ToUpper() == devcieManagerResult.DeviceName.ToUpper()); | |||
if (obj == null) | |||
{ | |||
if (res is bool blen) | |||
CommunicationSet communicationObj = new CommunicationSet(); | |||
EDeviceType eDeviceType = (EDeviceType)Enum.Parse(typeof(EDeviceType), devcieManagerResult.DeviceType); | |||
foreach (var item in Enum.GetNames(typeof(EDeviceTypeSort))) | |||
{ | |||
if (blen) | |||
var res = DeviceTypeSort.GetInstance.DevceTypes[item].FirstOrDefault(p => p == devcieManagerResult.DeviceType); | |||
if (res != null) | |||
{ | |||
ActionOperate.GetInstance.Send("Confirm", devcieManagerResult); | |||
} | |||
else | |||
{ | |||
LogInfo = $"警告:设备【{devcieManagerResult.DeviceName}】已存在,请重试"; | |||
string device = string.Empty; | |||
switch ((EDeviceTypeSort)Enum.Parse(typeof(EDeviceTypeSort), item)) | |||
{ | |||
case EDeviceTypeSort.Siemens: | |||
device = EDeviceType.Siemens.ToString(); | |||
break; | |||
case EDeviceTypeSort.TCP: | |||
device = EDeviceType.ModbusTcp.ToString(); | |||
break; | |||
case EDeviceTypeSort.Serial: | |||
device = EDeviceType.ModbusRtu.ToString(); | |||
break; | |||
default: | |||
break; | |||
} | |||
string NameSpace = "HBLConsole.Model";//Load 加载的是dll的名称,GetType获取的是全命名空间下的类 | |||
var type = Assembly.Load(NameSpace)?.GetType($"{NameSpace}.{device}"); | |||
if (type != null) communicationObj.Device = Activator.CreateInstance(type) as IDeviceType; | |||
communicationObj.DeviceName = $"{devcieManagerResult.DeviceName}【{eDeviceType}】"; | |||
communicationObj.deviceType = eDeviceType; | |||
DeviceManageViewModel.communicationSets.Add(communicationObj); | |||
break; | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
LogInfo = $"警告:设备【{devcieManagerResult.DeviceName}】已存在,请重试"; | |||
} | |||
ActionOperate.GetInstance.Send("Confirm", devcieManagerResult); | |||
}); | |||
} | |||
@@ -112,7 +112,7 @@ | |||
</Button.Foreground> | |||
</Button> | |||
<!--<Button | |||
<Button | |||
Width="140" | |||
Command="{Binding SaveConnectSetCommand}" | |||
Content="保存" | |||
@@ -125,7 +125,7 @@ | |||
<GradientStop Offset="1" Color="White" /> | |||
</LinearGradientBrush> | |||
</Button.Foreground> | |||
</Button>--> | |||
</Button> | |||
</StackPanel> | |||
<ScrollViewer | |||
@@ -226,7 +226,7 @@ | |||
<Button | |||
Grid.Column="7" | |||
Command="{Binding RemoveCommand}" | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}" | |||
CommandParameter="{Binding DeviceName}" | |||
Content="删除" | |||
FontFamily="楷体" | |||
@@ -329,7 +329,7 @@ | |||
<Button | |||
Grid.Column="7" | |||
Command="{Binding RemoveCommand}" | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}" | |||
CommandParameter="{Binding DeviceName}" | |||
Content="删除" | |||
FontFamily="楷体" | |||
@@ -470,7 +470,7 @@ | |||
<Button | |||
Grid.Column="7" | |||
Command="{Binding RemoveCommand}" | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}" | |||
CommandParameter="{Binding DeviceName}" | |||
Content="删除" | |||
FontFamily="楷体" | |||
@@ -28,83 +28,38 @@ namespace HBLConsole.ViewModel | |||
NewConnectCommand = new RelayCommand(() => { NewConnect(); }); | |||
SaveDeviceData(); | |||
RemoveCommand = new RelayCommand<object>((o) => { RemoveDevice(o); }); | |||
ActionOperate.GetInstance.Register(new Func<object, object>((p) => | |||
SaveConnectSetCommand = new RelayCommand(() => | |||
{ | |||
if (p is DeviceManagermentResult dm) | |||
{ | |||
return Json<CommunicationPar>.Data.communicationSets.FirstOrDefault(s => s.DeviceName.ToUpper() == dm.DeviceName.ToUpper()) == null; | |||
} | |||
return false; | |||
}), "AddDeviceVerify"); | |||
ClientDeviceType = GVL.GeneralConfig.DeviceType.ToString(); | |||
} | |||
static DeviceManageViewModel() | |||
{ | |||
VisibleDeviceData(); | |||
} | |||
private void SaveDeviceData() | |||
{ | |||
ActionOperate.GetInstance.Register(new Action(() => | |||
{ | |||
var rr = Json<CommunicationPar>.Data.communicationSets.Where(p => p.ClientDeviceType != GVL.GeneralConfig.DeviceType.ToString()).ToList(); | |||
if (rr != null) | |||
{ | |||
Json<CommunicationPar>.Data.communicationSets.Clear(); | |||
rr.ForEach((o) => | |||
{ | |||
Json<CommunicationPar>.Data.communicationSets.Add(o); | |||
}); | |||
} | |||
foreach (var item in communicationSets) | |||
{ | |||
item.RemoveAction = null; | |||
Json<CommunicationPar>.Data.communicationSets.Add(item); | |||
} | |||
TextHelper.GetInstance.WriteTextInfo(ClientDeviceType); | |||
LocaPath.GetInstance.FilePath = $"AccessFile\\{ClientDeviceType}\\"; | |||
Json<CommunicationPar>.Data.communicationSets.Clear(); | |||
foreach (var item in communicationSets) { Json<CommunicationPar>.Data.communicationSets.Add(item); } | |||
Json<CommunicationPar>.Save(); | |||
LocaPath.GetInstance.FilePath = $"AccessFile\\{GVL.GeneralConfig.DeviceType.ToString()}\\"; | |||
}); | |||
}), "DataSave"); | |||
} | |||
private static void VisibleDeviceData() | |||
{ | |||
if (communicationSets.Count <= 0) | |||
{ | |||
Json<CommunicationPar>.Read(); | |||
foreach (var item in Json<CommunicationPar>.Data.communicationSets) | |||
{ | |||
if (item.ClientDeviceType == GVL.GeneralConfig.DeviceType.ToString()) | |||
{ | |||
item.RemoveAction = RemoveDevice; | |||
communicationSets.Add(item); | |||
} | |||
} | |||
} | |||
ClientDeviceType = GVL.GeneralConfig.DeviceType.ToString(); | |||
} | |||
public string ClientDeviceType | |||
{ | |||
get { return _mClientDeviceType; } | |||
set | |||
{ | |||
_mClientDeviceType = value; | |||
LocaPath.GetInstance.FilePath = $"AccessFile\\{value}\\"; | |||
communicationSets.Clear(); | |||
Json<CommunicationPar>.Read(); | |||
foreach (var item in Json<CommunicationPar>.Data.communicationSets) { communicationSets.Add(item); } | |||
LocaPath.GetInstance.FilePath = $"AccessFile\\{GVL.GeneralConfig.DeviceType.ToString()}\\"; | |||
OnPropertyChanged(); | |||
TextHelper.GetInstance.WriteTextInfo(value); | |||
//Json<SetPar>.Data.ClientDeviceType = value; | |||
} | |||
} | |||
private string _mClientDeviceType = string.Empty; | |||
public static ObservableCollection<CommunicationSet> communicationSets { get; set; } = new ObservableCollection<CommunicationSet>(); | |||
public ObservableCollection<string> ClientDevices { get; set; } = new ObservableCollection<string>(); | |||
@@ -113,80 +68,22 @@ namespace HBLConsole.ViewModel | |||
public RelayCommand SaveConnectSetCommand { get; set; } | |||
public RelayCommand<object> RemoveCommand { get; set; } | |||
/// <summary> | |||
/// 创建新连接 | |||
/// </summary> | |||
private void NewConnect() | |||
{ | |||
DeviceManagermentSetView deviceManagermentSetView = new DeviceManagermentSetView(); | |||
var result = deviceManagermentSetView.ShowDialog(); | |||
var ResultTag = deviceManagermentSetView.Tag as DeviceManagermentResult; | |||
if (ResultTag != null && result != 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); | |||
foreach (var item in Enum.GetNames(typeof(EDeviceTypeSort))) | |||
{ | |||
var res = DeviceTypeSort.GetInstance.DevceTypes[item].FirstOrDefault(p => p == ResultTag.DeviceType); | |||
if (res != null) | |||
{ | |||
string device = string.Empty; | |||
switch ((EDeviceTypeSort)Enum.Parse(typeof(EDeviceTypeSort), item)) | |||
{ | |||
case EDeviceTypeSort.Siemens: | |||
device = EDeviceType.Siemens.ToString(); | |||
break; | |||
case EDeviceTypeSort.TCP: | |||
device = EDeviceType.ModbusTcp.ToString(); | |||
break; | |||
case EDeviceTypeSort.Serial: | |||
device = EDeviceType.ModbusRtu.ToString(); | |||
break; | |||
default: | |||
break; | |||
} | |||
string NameSpace = "HBLConsole.Model";//Load 加载的是dll的名称,GetType获取的是全命名空间下的类 | |||
var type = Assembly.Load(NameSpace)?.GetType($"{NameSpace}.{device}"); | |||
if (type != null) | |||
{ | |||
communicationObj.Device = Activator.CreateInstance(type) as IDeviceType; | |||
} | |||
communicationObj.DeviceName = $"{ResultTag.DeviceName}【{eDeviceType}】"; | |||
communicationObj.deviceType = eDeviceType; | |||
communicationObj.RemoveAction = RemoveDevice; | |||
communicationObj.ClientDeviceType = GVL.GeneralConfig.DeviceType.ToString(); | |||
communicationSets.Add(communicationObj); | |||
return; | |||
} | |||
} | |||
//} | |||
} | |||
} | |||
} | |||
deviceManagermentSetView = null; | |||
deviceManagermentSetView.Show(); | |||
} | |||
private static void RemoveDevice(object o) | |||
private void RemoveDevice(object o) | |||
{ | |||
if (o == null) return; | |||
int index = Array.FindIndex(communicationSets.ToArray(), p => p.DeviceName == o.ToString()); | |||
if (index >= 0 && index < communicationSets.Count) | |||
{ | |||
communicationSets.RemoveAt(index); | |||
} | |||
//var result = communicationSets.FirstOrDefault(p => p.DeviceName == o.ToString()); | |||
//if (result != null) | |||
//{ | |||
// communicationSets.Remove(result); | |||
//} | |||
if (index >= 0 && index < communicationSets.Count) communicationSets.RemoveAt(index); | |||
} | |||
@@ -65,26 +65,10 @@ namespace HBLConsole.ViewModel | |||
/// <summary> | |||
/// 订单状态列表 | |||
/// </summary> | |||
//public static ObservableCollection<OrderData> orderStatusLists { get; set; } = new ObservableCollection<OrderData>(); | |||
public static ObservableCollection<OrderData> orderStatusLists | |||
{ | |||
get | |||
{ | |||
//if (!Json<KeepDataBase>.Data.orderLists.ContainsKey(GVL.GeneralConfig.DeviceType.ToString())) | |||
//{ | |||
// Json<KeepDataBase>.Data.orderLists.TryAdd(GVL.GeneralConfig.DeviceType.ToString(), new ObservableCollection<OrderData>()); | |||
//} | |||
return Json<KeepDataBase>.Data.orderLists; | |||
} | |||
set | |||
{ | |||
//if (!Json<KeepDataBase>.Data.orderLists.ContainsKey(GVL.GeneralConfig.DeviceType.ToString())) | |||
//{ | |||
// Json<KeepDataBase>.Data.orderLists.TryAdd(GVL.GeneralConfig.DeviceType.ToString(), new ObservableCollection<OrderData>()); | |||
//} | |||
Json<KeepDataBase>.Data.orderLists = value; | |||
} | |||
get { return Json<KeepDataBase>.Data.orderLists; } | |||
set { Json<KeepDataBase>.Data.orderLists = value; } | |||
} | |||
/// <summary> | |||