@@ -59,6 +59,21 @@ namespace BPASmartClient.Business | |||
/// 是否启用测试模式 | |||
/// </summary> | |||
public static bool IsEnableTest { get; set; } | |||
/// <summary> | |||
/// 大屏地址 | |||
/// </summary> | |||
public static string DataVApiAddress { get; set; } | |||
/// <summary> | |||
/// 大屏主题 | |||
/// </summary> | |||
public static string BroadcastPubTopic { get; set; } | |||
/// <summary> | |||
/// 物料管理地址 | |||
/// </summary> | |||
public static string WebServiceUri { get; set; } | |||
#endregion | |||
} | |||
@@ -26,6 +26,10 @@ namespace BPASmartClient.Business | |||
/// </summary> | |||
public MQTT_Entity MQTT_Config { get; set; } | |||
public MQTT_Account Mqtt_Account { get; set; } | |||
public UriConfig uriConfig { get; set; } | |||
//Apollo地址 | |||
private string apolloUri; | |||
private string apoid; | |||
@@ -42,11 +46,11 @@ namespace BPASmartClient.Business | |||
apolloUri = System.Configuration.ConfigurationManager.AppSettings["ApolloUri"].ToString(); | |||
apoid = System.Configuration.ConfigurationManager.AppSettings["AppId"].ToString(); | |||
namespa = System.Configuration.ConfigurationManager.AppSettings["Namespaces"].ToString(); | |||
InternetInfo.OrderServer = System.Configuration.ConfigurationManager.AppSettings["OrderServiceUri"].ToString(); | |||
InternetInfo.StockServer = System.Configuration.ConfigurationManager.AppSettings["StockServiceUri"].ToString(); | |||
//InternetInfo.OrderServer = System.Configuration.ConfigurationManager.AppSettings["OrderServiceUri"].ToString(); | |||
//InternetInfo.StockServer = System.Configuration.ConfigurationManager.AppSettings["StockServiceUri"].ToString(); | |||
InternetInfo.IsEnableTest = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["IsEnableTest"].ToString()); | |||
InitDeviceModel(); | |||
InitMQTT(); | |||
InitConfig(); | |||
} | |||
public List<DeviceConfig> GetDeviceConfigs() | |||
@@ -132,30 +136,45 @@ namespace BPASmartClient.Business | |||
/// <summary> | |||
/// 加载MQTT配置 | |||
/// </summary> | |||
private void InitMQTT() | |||
//private void InitMQTT() | |||
//{ | |||
// IConfigurationBuilder configurationBuilder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()); | |||
// configurationBuilder.AddApolloConfiguration(p => | |||
// { | |||
// p.AppId = apoid; | |||
// p.MetaServer = apolloUri; | |||
// p.Namespaces = new List<string>() { namespa }; | |||
// }); | |||
// IConfiguration config = configurationBuilder.Build(); | |||
// var mqttBroker = config.GetSection("BrokerHostSettings"); | |||
// MQTT_Config = mqttBroker.Value.FromJSON<MQTT_Entity>(); | |||
// if (MQTT_Config == null) MessageLog.GetInstance.Show("获取配置数据为空!"); | |||
//} | |||
public void InitConfig() | |||
{ | |||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()); | |||
//测试版本 | |||
//configurationBuilder.AddApolloConfiguration(p => | |||
// { | |||
// p.AppId = "dev1_order"; | |||
// p.MetaServer = apolloUri; | |||
// p.Namespaces = new List<string>() { "DEV.Config" }; | |||
// }); | |||
//正式版本 | |||
configurationBuilder.AddApolloConfiguration(p => | |||
{ | |||
p.AppId = apoid; | |||
p.AppId = "HostComputer"; | |||
p.MetaServer = apolloUri; | |||
p.Namespaces = new List<string>() { namespa }; | |||
p.Namespaces = new List<string>() { "application", namespa }; | |||
}); | |||
IConfiguration config = configurationBuilder.Build(); | |||
var mqttBroker = config.GetSection("BrokerHostSettings"); | |||
MQTT_Config = mqttBroker.Value.FromJSON<MQTT_Entity>(); | |||
if (MQTT_Config == null) MessageLog.GetInstance.Show("获取配置数据为空!"); | |||
MQTT_Config = config.GetSection("BrokerHostSettings").Value.FromJSON<MQTT_Entity>(); | |||
Mqtt_Account = config.GetSection("MqttAccount").Value.FromJSON<MQTT_Account>(); | |||
uriConfig = config.GetSection("URL").Value.FromJSON<UriConfig>(); | |||
if (uriConfig != null) | |||
{ | |||
InternetInfo.OrderServer = uriConfig.OrderServiceUrl; | |||
InternetInfo.StockServer = uriConfig.StockServiceUrl; | |||
InternetInfo.BroadcastPubTopic = uriConfig.BroadcastPubTopic; | |||
InternetInfo.DataVApiAddress = uriConfig.DataVServiceUrl; | |||
InternetInfo.WebServiceUri = uriConfig.WebServiceUrl; | |||
ActionManage.GetInstance.Send("配置初始化完成Iot启动"); | |||
} | |||
} | |||
public void Start() | |||
@@ -167,5 +186,20 @@ namespace BPASmartClient.Business | |||
public string Host { get; set; } | |||
public int Port { get; set; } | |||
} | |||
public class MQTT_Account | |||
{ | |||
public string UserName { get; set; } | |||
public string Password { get; set; } | |||
} | |||
public class UriConfig | |||
{ | |||
public string OrderServiceUrl { get; set; } | |||
public string StockServiceUrl { get; set; } | |||
public string DataVServiceUrl { get; set; } | |||
public string WebServiceUrl { get; set; } | |||
public string BroadcastPubTopic { get; set; } | |||
} | |||
} | |||
} |
@@ -46,6 +46,7 @@ namespace BPASmartClient.Business | |||
mqttProxy.Connected = new Action(() => | |||
{ | |||
mqttProxy.Subscrib(TopicDefine.GetInstance().SubscribTopics.ToArray()); | |||
MessageLog.GetInstance.Show("MQTT 连接成功"); | |||
}); | |||
//MQTT 连接成功 | |||
mqttProxy.LostConnect = new Action(() => | |||
@@ -57,10 +58,10 @@ namespace BPASmartClient.Business | |||
{ | |||
msg.Enqueue(message); | |||
}); | |||
MessageLog.GetInstance.Show("准备连接MQTT"); | |||
var MqttServerConfig = Plugin.GetInstance().GetPlugin<ConfigMgr>().MQTT_Config; | |||
var MqttServerAccount = Plugin.GetInstance().GetPlugin<ConfigMgr>().Mqtt_Account; | |||
//MQTT 初始化 | |||
mqttProxy.Connect(Plugin.GetInstance().GetPlugin<ConfigMgr>().MQTT_Config.Host, Plugin.GetInstance().GetPlugin<ConfigMgr>().MQTT_Config.Port, | |||
Guid.NewGuid().ToString()); | |||
mqttProxy.Connect(MqttServerAccount.UserName, MqttServerAccount.Password, MqttServerConfig.Host, MqttServerConfig.Port, Guid.NewGuid().ToString()); | |||
ThreadManage.GetInstance().Start(() => | |||
{ | |||
@@ -12,6 +12,7 @@ using System.Reflection; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using System.Collections.ObjectModel; | |||
namespace BPASmartClient.Device | |||
{ | |||
@@ -88,7 +89,7 @@ namespace BPASmartClient.Device | |||
/// <summary> | |||
/// 设备变量监控 | |||
/// </summary> | |||
public List<VariableMonitor> variableMonitors { get; set; } = new List<VariableMonitor>(); | |||
public ObservableCollection<VariableMonitor> variableMonitors { get; set; } = new ObservableCollection<VariableMonitor>(); | |||
/// <summary> | |||
/// 外设状态,硬件设备数据 | |||
@@ -105,6 +106,7 @@ namespace BPASmartClient.Device | |||
public List<Alarm> alarms { get; set; } = new List<Alarm>(); | |||
public IAlarm InterfaceAlarm { get; set; } | |||
public AlarmHelper alarmHelper { get; set; } = new AlarmHelper(); | |||
public IStatus InterfaceStatus { get; set; } | |||
#endregion | |||
@@ -205,16 +207,16 @@ namespace BPASmartClient.Device | |||
{ | |||
if (faces.Name == "IStatus") | |||
{ | |||
IStatus status = item.GetValue(this) as IStatus; | |||
GetMonitorData(status); | |||
ThreadManage.GetInstance().StopTask($"{item.Name}:{DeviceId}", new Action(() => | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
UpdateValue(status); | |||
Thread.Sleep(1000); | |||
}), $"{item.Name}:{DeviceId}"); | |||
})); | |||
InterfaceStatus = item.GetValue(this) as IStatus; | |||
GetMonitorData(InterfaceStatus); | |||
//ThreadManage.GetInstance().StopTask($"{item.Name}:{DeviceId}", new Action(() => | |||
// { | |||
//ThreadManage.GetInstance().StartLong(new Action(() => | |||
//{ | |||
// UpdateValue(InterfaceStatus); | |||
// Thread.Sleep(1000); | |||
//}), $"GvlStatusMonitor:{DeviceId}"); | |||
//})); | |||
} | |||
else if (faces.Name == "IAlarm") | |||
{ | |||
@@ -289,8 +291,11 @@ namespace BPASmartClient.Device | |||
{ | |||
ThreadManage.GetInstance().StopTask($"ReadData:{DeviceId}", new Action(() => | |||
{ | |||
ResetProgram(); | |||
InitTask(); | |||
ThreadManage.GetInstance().StopTask($"GvlStatusMonitor:{DeviceId}", new Action(() => | |||
{ | |||
ResetProgram(); | |||
InitTask(); | |||
})); | |||
})); | |||
})); | |||
} | |||
@@ -317,6 +322,13 @@ namespace BPASmartClient.Device | |||
}), $"MainTask:{DeviceId}"); | |||
#endregion | |||
#region 设备状态监控 | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
UpdateValue(InterfaceStatus); | |||
Thread.Sleep(1000); | |||
}), $"GvlStatusMonitor:{DeviceId}"); | |||
#endregion | |||
} | |||
/// <summary> | |||
@@ -8,6 +8,7 @@ using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Collections.ObjectModel; | |||
namespace BPASmartClient.Device | |||
{ | |||
@@ -54,7 +55,7 @@ namespace BPASmartClient.Device | |||
/// <summary> | |||
/// 设备变量信息 | |||
/// </summary> | |||
List<VariableMonitor> variableMonitors { get; set; } | |||
ObservableCollection<VariableMonitor> variableMonitors { get; set; } | |||
/// <summary> | |||
/// 设备报警信息集合 | |||
@@ -66,6 +67,11 @@ namespace BPASmartClient.Device | |||
/// </summary> | |||
IAlarm InterfaceAlarm { get; set; } | |||
/// <summary> | |||
/// 接口设备状态 | |||
/// </summary> | |||
IStatus InterfaceStatus { get; set; } | |||
/// <summary> | |||
/// 报警实体 | |||
/// </summary> | |||
@@ -3,46 +3,49 @@ using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
namespace BPASmartClient.Device | |||
{ | |||
public class VariableMonitor | |||
public class VariableMonitor : ObservableObject | |||
{ | |||
public int Id { get { return _mId; } set { _mId = value; } } | |||
public int Id { get { return _mId; } set { _mId = value; OnPropertyChanged(); } } | |||
private int _mId; | |||
public string VarName { get { return _mVarName; } set { _mVarName = value; } } | |||
public string VarName { get { return _mVarName; } set { _mVarName = value; OnPropertyChanged(); } } | |||
private string _mVarName; | |||
public string PLCAddress { get { return _mPLCAddress; } set { _mPLCAddress = value; } } | |||
public string PLCAddress { get { return _mPLCAddress; } set { _mPLCAddress = value; OnPropertyChanged(); } } | |||
private string _mPLCAddress; | |||
public string Notes { get { return _mNotes; } set { _mNotes = value; } } | |||
public string Notes { get { return _mNotes; } set { _mNotes = value; OnPropertyChanged(); } } | |||
private string _mNotes; | |||
public string ModbusTcpAddress { get { return _mModbusTcpAddress; } set { _mModbusTcpAddress = value; } } | |||
public string ModbusTcpAddress { get { return _mModbusTcpAddress; } set { _mModbusTcpAddress = value; OnPropertyChanged(); } } | |||
private string _mModbusTcpAddress; | |||
public string CurrentValue | |||
{ | |||
get { return _mCurrentValue; } | |||
set | |||
{ | |||
public string CurrentValue | |||
{ | |||
get { return _mCurrentValue; } | |||
set | |||
{ | |||
_mCurrentValue = value; | |||
OnPropertyChanged(); | |||
if (_mCurrentValue == "False" || _mCurrentValue == "True") | |||
{ | |||
if (_mCurrentValue == "True") | |||
StatusColor = new { r = 51, g = 232, b = 34, a = 1 }; | |||
else | |||
StatusColor = new { r = 255, g = 0, b = 0, a = 1 }; | |||
}else | |||
} | |||
else | |||
StatusColor = new { r = 51, g = 232, b = 34, a = 1 }; | |||
} | |||
} | |||
} | |||
private string _mCurrentValue; | |||
@@ -88,12 +88,6 @@ namespace BPASmartClient.GSIceCream | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
status["test"] = 0; | |||
for (int i = 0; i < 1000; i++) | |||
{ | |||
status["test"] = (int)status["test"] + 1; | |||
Thread.Sleep(1000); | |||
} | |||
ResolveMsg(); | |||
}), "冰淇淋解析线程"); | |||
} | |||
@@ -11,24 +11,12 @@ namespace BPASmartClient.Helper | |||
/// </summary> | |||
public class Json<T> where T : class, new() | |||
{ | |||
//private static string DeviceType = ActionManage.GetInstance.SendResult("GetDeviceType").ToString(); | |||
//static string path | |||
//{ | |||
// get | |||
// { | |||
// Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\{DeviceType}\\JSON")); | |||
// return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\{DeviceType}\\JSON\\{typeof(T).Name}.json"; | |||
// } | |||
//} | |||
static string path | |||
{ | |||
get | |||
{ | |||
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"JSON")); | |||
return $"{AppDomain.CurrentDomain.BaseDirectory}JSON\\{typeof(T).Name}.json"; | |||
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\JSON")); | |||
return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\JSON\\{typeof(T).Name}.json"; | |||
} | |||
} | |||
@@ -43,8 +31,6 @@ namespace BPASmartClient.Helper | |||
File.WriteAllText(path, outjson); | |||
} | |||
/// <summary> | |||
/// 获取保存的数据 | |||
/// </summary> | |||
@@ -34,13 +34,15 @@ namespace BPASmartClient.IoT | |||
/// </summary> | |||
public DataVClient() | |||
{ | |||
DataVApiAddress = System.Configuration.ConfigurationManager.AppSettings["DataVServiceUri"].ToString(); | |||
DataVApiAddress = InternetInfo.DataVApiAddress; | |||
//DataVApiAddress = System.Configuration.ConfigurationManager.AppSettings["DataVServiceUri"].ToString(); | |||
ClientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString(); | |||
DeviceName = System.Configuration.ConfigurationManager.AppSettings["DeviceName"].ToString(); | |||
ProductKey = System.Configuration.ConfigurationManager.AppSettings["ProductKey"].ToString(); | |||
DeviceSecret = System.Configuration.ConfigurationManager.AppSettings["DeviceSecret"].ToString(); | |||
StartupMode = System.Configuration.ConfigurationManager.AppSettings["StartupMode"].ToString(); | |||
BroadcastPubTopic = System.Configuration.ConfigurationManager.AppSettings["BroadcastPubTopic"].ToString(); | |||
BroadcastPubTopic = InternetInfo.BroadcastPubTopic; | |||
//BroadcastPubTopic = System.Configuration.ConfigurationManager.AppSettings["BroadcastPubTopic"].ToString(); | |||
} | |||
#endregion | |||
@@ -178,7 +180,7 @@ namespace BPASmartClient.IoT | |||
{ | |||
if (DeviceDataV != null && DeviceDataV.GetIsConnected() && DeviceDataV.deviceTable != null) | |||
{ | |||
iOTDevSXModel.Device1=String.Empty;iOTDevSXModel.Device2=String.Empty;iOTDevSXModel.Device3 = String.Empty; | |||
iOTDevSXModel.Device1 = String.Empty; iOTDevSXModel.Device2 = String.Empty; iOTDevSXModel.Device3 = String.Empty; | |||
List<object> dataVNode = new List<object>(); | |||
Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices()?.ForEach(device => | |||
{ | |||
@@ -299,7 +301,7 @@ namespace BPASmartClient.IoT | |||
string FileName = result.data?.fileName; | |||
string uploadId = result.data?.uploadId; | |||
FileUpload.FileSend(DeviceDataV, uploadId, result.data.offset); | |||
MessageLog.GetInstance.Show($"[阿里云上传]:请求上传云回执成功."); | |||
//MessageLog.GetInstance.Show($"[阿里云上传]:请求上传云回执成功."); | |||
} | |||
else | |||
MessageLog.GetInstance.Show($"[阿里云上传]:请求上传云回执失败.原因:{result.message}"); | |||
@@ -314,7 +316,7 @@ namespace BPASmartClient.IoT | |||
{ | |||
FileUploadModelResult result = Tools.JsonToObjectTools<FileUploadModelResult>(message); | |||
} | |||
} | |||
/// <summary> | |||
@@ -84,7 +84,7 @@ namespace BPASmartClient.IoT.Model | |||
//fileUpload.@params.extraParams.fileTag = new Dictionary<string, string> { {"Time", DateTime.Now.ToString("yyyy_M_d") },{"Name", "HBL.LogDir" } }; | |||
dataV.IOT_Publish(dataV.FileUpLoadTopic, Tools.JsonConvertTools(fileUpload)); | |||
MessageLog.GetInstance.Show($"[阿里云上传]:第[{i+1}]包数据,请求上传."); | |||
//MessageLog.GetInstance.Show($"[阿里云上传]:第[{i+1}]包数据,请求上传."); | |||
int count = 0; | |||
while (modelResult == null)//等待上传完成 | |||
@@ -100,8 +100,13 @@ namespace BPASmartClient.IoT.Model | |||
; | |||
if(modelResult.code==200) | |||
MessageLog.GetInstance.Show($"[阿里云上传]:第[{i + 1}]包,上传成功."); | |||
if (modelResult.code == 200) | |||
{ | |||
if (modelResult.data.complete) | |||
{ | |||
MessageLog.GetInstance.Show($"[阿里云上传]:文件上传完成,总长度[{modelResult.data.bSize}]字节."); | |||
} | |||
} | |||
else | |||
MessageLog.GetInstance.Show($"[阿里云上传]:第[{i + 1}]包,上传失败.原因:{modelResult.message}"); | |||
; | |||
@@ -12,16 +12,8 @@ namespace BPASmartClient.PLC | |||
public class PLCMachine : BasePeripheral | |||
{ | |||
ModbusTcp modbusTcp = new ModbusTcp(); | |||
//public string IpAddress { get; set; } | |||
//public int Port { get; set; } | |||
//public string PLCReadAddress { get; set; } | |||
//private List<PLCReadParameter> plcReadParameters; | |||
public override void Init() | |||
{ | |||
//plcReadParameters = PLCReadParameter.DeSerialize(PLCReadAddress); | |||
Task.Run(new Action(() => { modbusTcp.ModbusTcpConnect(communicationPar.IPAddress, communicationPar.IPPort); })); //PLC 设备连接 | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
@@ -45,61 +37,12 @@ namespace BPASmartClient.PLC | |||
status.TryAdd(par.Address, res); | |||
} | |||
} | |||
//ushort address = (ushort)modbusTcp.GetAddress(par?.Address); | |||
//object readData = new object(); | |||
//switch (par.CmdType) | |||
//{ | |||
// case CommandType.Coils: | |||
// modbusTcp.Readbool(address, par.Length, new Action<bool[]>((s) => { readData = s; })); | |||
// break; | |||
// case CommandType.HoldingRegisters: | |||
// readData = modbusTcp.Read(address, CommandType.HoldingRegisters, par.Length); | |||
// break; | |||
//} | |||
//status[par.Address] = readData; | |||
} | |||
//foreach (var par in plcReadParameters) | |||
//{ | |||
// ushort address = (ushort)modbusTcp.GetAddress(par?.Address); | |||
// object readData = new object(); | |||
// switch (par.CmdType) | |||
// { | |||
// case CommandType.Coils: | |||
// modbusTcp.Readbool(address, par.Length, new Action<bool[]>((s) => { readData = s; })); | |||
// break; | |||
// case CommandType.HoldingRegisters: | |||
// readData = modbusTcp.Read(address, CommandType.HoldingRegisters, par.Length); | |||
// break; | |||
// } | |||
// status[par.Address] = readData; | |||
//} | |||
Thread.Sleep(500); | |||
} | |||
Thread.Sleep(1000); | |||
}), $"设备[{DeviceId}]PLC读取线程", true); | |||
//读取数据 | |||
// EventBus.EventBus.GetInstance().Subscribe<ReadModel>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
//{ | |||
// if (@event == null) return; | |||
// var par = @event as ReadModel; | |||
// ushort address = (ushort)modbusTcp.GetAddress(par?.Address); | |||
// object readData = new object(); | |||
// if (par.Address.ToUpper().Contains("M")) | |||
// { | |||
// modbusTcp.Readbool(address, par.Length, new Action<bool[]>((s) => { readData = s; })); | |||
// } | |||
// else if (par.Address.ToUpper().Contains("VW")) | |||
// { | |||
// readData = modbusTcp.Read(address, CommandType.HoldingRegisters, par.Length); | |||
// } | |||
// callBack?.Invoke(readData); | |||
//}); | |||
//写入数据 | |||
EventBus.EventBus.GetInstance().Subscribe<WriteModel>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
@@ -107,15 +50,6 @@ namespace BPASmartClient.PLC | |||
var par = @event as WriteModel; | |||
modbusTcp.Write(par?.Address, par?.Value); | |||
//ushort address = (ushort)modbusTcp.GetAddress(par?.Address); | |||
//if (par.Address.ToUpper().Contains("M")) | |||
//{ | |||
// modbusTcp.Write(address, CommandType.Coils, par.Value); | |||
//} | |||
//else if (par.Address.ToUpper().Contains("VW")) | |||
//{ | |||
// modbusTcp.Write(address, CommandType.HoldingRegisters, par.Value); | |||
//} | |||
}); | |||
} | |||
@@ -22,15 +22,17 @@ namespace BPASmartClient.MQTT | |||
private IMqttClient client; | |||
public void Connect(string ip, int port, string clientId) | |||
public void Connect(string userName, string Password, string ip, int port, string clientId) | |||
{ | |||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); | |||
configurationBuilder.AddMqttClientHostedService(p => | |||
{ | |||
p.Server = ip; | |||
p.Port = port; | |||
p.UserName = "rafiul"; | |||
p.Password = "12345678"; | |||
//p.UserName = "rafiul"; | |||
//p.Password = "12345678"; | |||
p.UserName = userName; | |||
p.Password = Password; | |||
p.mqttClientConnectedHandlerDelegate = new MQTTnet.Client.Connecting.MqttClientConnectedHandlerDelegate(e => | |||
{ | |||
IsConnected = true; | |||
@@ -22,11 +22,5 @@ namespace BPASmartClient.Model | |||
/// </summary> | |||
public ObservableCollection<OrderData> orderLists { get; set; } = new ObservableCollection<OrderData>(); | |||
/// <summary> | |||
/// 参数设置 | |||
/// </summary> | |||
public ObservableCollection<ParSet> parSets { get; set; } = new ObservableCollection<ParSet>(); | |||
} | |||
} |
@@ -1,29 +1,29 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
//using System; | |||
//using System.Collections.Generic; | |||
//using System.Linq; | |||
//using System.Text; | |||
//using System.Threading.Tasks; | |||
namespace BPASmartClient.Model | |||
{ | |||
public class ParSet | |||
{ | |||
public ushort Minute { get { return _mMinute; } set { _mMinute = value; } } | |||
private ushort _mMinute; | |||
//namespace BPASmartClient.Model | |||
//{ | |||
// public class ParSet | |||
// { | |||
// public ushort Minute { get { return _mMinute; } set { _mMinute = value; } } | |||
// private ushort _mMinute; | |||
public ushort Second { get { return _mSecond; } set { _mSecond = value; } } | |||
private ushort _mSecond; | |||
// public ushort Second { get { return _mSecond; } set { _mSecond = value; } } | |||
// private ushort _mSecond; | |||
public bool IsShield { get { return _mIsShield; } set { _mIsShield = value; } } | |||
private bool _mIsShield; | |||
// public bool IsShield { get { return _mIsShield; } set { _mIsShield = value; } } | |||
// private bool _mIsShield; | |||
public string TextBlockContext { get { return _mTextBlockContext; } set { _mTextBlockContext = value; } } | |||
private string _mTextBlockContext; | |||
// public string TextBlockContext { get { return _mTextBlockContext; } set { _mTextBlockContext = value; } } | |||
// private string _mTextBlockContext; | |||
public string CheckBoxContext { get { return _mCheckBoxContext; } set { _mCheckBoxContext = value; } } | |||
private string _mCheckBoxContext; | |||
// public string CheckBoxContext { get { return _mCheckBoxContext; } set { _mCheckBoxContext = value; } } | |||
// private string _mCheckBoxContext; | |||
} | |||
} | |||
// } | |||
//} |
@@ -14,6 +14,7 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.EventBus\BPASmartClient.EventBus.csproj" /> | |||
@@ -14,6 +14,9 @@ using System.Linq; | |||
using BPASmartClient.Model.PLC; | |||
using System.Threading.Tasks; | |||
using System.Reflection; | |||
using BPASmartClient.MorkS.Model; | |||
using System.Collections.ObjectModel; | |||
using BPASmartClient.MorkS.ViewModel; | |||
namespace BPASmartClient.MorkS | |||
{ | |||
@@ -25,8 +28,36 @@ namespace BPASmartClient.MorkS | |||
public override void DoMain() | |||
{ | |||
MonitorViewModel.DeviceId = DeviceId; | |||
ServerInit(); | |||
DataParse(); | |||
Json<MorksPar>.Read(); | |||
if (Json<MorksPar>.Data.parSets == null) Json<MorksPar>.Data.parSets = new ObservableCollection<ParSet>(); | |||
if (Json<MorksPar>.Data.parSets.Count < 6) | |||
{ | |||
Json<MorksPar>.Data.parSets.Clear(); | |||
for (int i = 0; i < 6; i++) | |||
{ | |||
Json<MorksPar>.Data.parSets.Add(new ParSet() | |||
{ | |||
CheckBoxContext = $"煮面口{i + 1}屏蔽", | |||
Minute = 1, | |||
Second = 0, | |||
IsShield = false, | |||
TextBlockContext = $"煮面口{i + 1}时间设定" | |||
}); | |||
} | |||
} | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
if (o != null && o is WritePar writePar) WriteData(writePar.Address, writePar.Value); | |||
}), "WriteVW"); | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
if (o != null && o is WritePar writePar) WriteData(writePar.Address, writePar.Value); | |||
}), "WriteBools"); | |||
ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitDevice"); | |||
} | |||
@@ -189,14 +220,6 @@ namespace BPASmartClient.MorkS | |||
if (obj is ushort[] UshortValue && UshortValue.Length > 0 && UshortValue.Length <= 1) | |||
mORKS.TurntableFeedbackloc = UshortValue[0]; | |||
})); | |||
//EventBus.EventBus.GetInstance().Publish(new ReadModel() { DeviceId = DeviceId, Address = "VW372", Length = 1 }, (o) => | |||
//{ | |||
// if (o != null && o.Length > 0 && o[0] is ushort value) | |||
// { | |||
// mORKS.TurntableFeedbackloc = value; | |||
// } | |||
//}); | |||
} | |||
/// <summary> | |||
@@ -455,11 +478,10 @@ namespace BPASmartClient.MorkS | |||
OrderChange(orderLocInfo.SuborderId, ORDER_STATUS.COOKING); | |||
DeviceProcessLogShow($"订单【{orderLocInfo.SuborderId}】,机器人倒面至【{loc + 1}】号煮面栏"); | |||
//写入煮面时间 | |||
//List<ushort> values = new List<ushort>(); | |||
//values.Add(Json<KeepDataBase>.Data.parSets.ElementAt(loc).Minute); | |||
//values.Add(Json<KeepDataBase>.Data.parSets.ElementAt(loc).Second); | |||
//ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetWordAddress($"VW{116 + (loc * 6)}"), WriteType.HoldingRegisters, values.ToArray()); | |||
List<ushort> values = new List<ushort>(); | |||
values.Add(Json<MorksPar>.Data.parSets.ElementAt(loc).Minute); | |||
values.Add(Json<MorksPar>.Data.parSets.ElementAt(loc).Second); | |||
WriteData($"VW{116 + (loc * 6)}", values.ToArray()); | |||
mORKS.TakeNoodleInterlock = true; | |||
} | |||
} | |||
@@ -0,0 +1,15 @@ | |||
using BPASmartClient.Model; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.MorkS.Model | |||
{ | |||
internal class MorksPar | |||
{ | |||
public ObservableCollection<ParSet> parSets { get; set; } = new ObservableCollection<ParSet>(); | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Model | |||
{ | |||
public class ParSet | |||
{ | |||
public ushort Minute { get { return _mMinute; } set { _mMinute = value; } } | |||
private ushort _mMinute; | |||
public ushort Second { get { return _mSecond; } set { _mSecond = value; } } | |||
private ushort _mSecond; | |||
public bool IsShield { get { return _mIsShield; } set { _mIsShield = value; } } | |||
private bool _mIsShield; | |||
public string TextBlockContext { get { return _mTextBlockContext; } set { _mTextBlockContext = value; } } | |||
private string _mTextBlockContext; | |||
public string CheckBoxContext { get { return _mCheckBoxContext; } set { _mCheckBoxContext = value; } } | |||
private string _mCheckBoxContext; | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.MorkS.Model | |||
{ | |||
public class WritePar | |||
{ | |||
public string Address { get; set; } | |||
public object Value { get; set; } | |||
} | |||
} |
@@ -15,11 +15,228 @@ | |||
<vm:MonitorViewModel /> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<Label | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Content="监控画面" | |||
FontSize="40" /> | |||
<UserControl.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary> | |||
<!--<convert:TextDisplayConvert x:Key="textDisplayConvert" /> | |||
<convert:IsEnableConvert x:Key="isEnableConvert" /> | |||
<convert:AnalogAlarmConvert x:Key="analogAlarmConvert" /> | |||
<convert:DiscreteAlarmConvert x:Key="discreteAlarmConvert" /> | |||
<convert:AlarmTypeTextConvert x:Key="alarmTypeTextConvert" />--> | |||
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" /> | |||
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" /> | |||
<SolidColorBrush x:Key="TitleFontColor" Color="#ddd" /> | |||
<SolidColorBrush x:Key="CursorColor" Color="Aqua" /> | |||
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" /> | |||
<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> | |||
</ResourceDictionary> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</UserControl.Resources> | |||
<Grid Margin="10"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!--#region 表格标题栏设置--> | |||
<Grid Background="#dd2AB2E7"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.3*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="ID" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="变量名" /> | |||
<Border | |||
BorderBrush="{StaticResource TitleBorderColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="PLC 地址" /> | |||
<Grid Grid.Column="3"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="注释" /> | |||
<Border | |||
BorderBrush="{StaticResource TitleBorderColor}" | |||
BorderThickness="1,0,0,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<Grid Grid.Column="4"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="Modbus TCP 地址" /> | |||
<Border | |||
BorderBrush="{StaticResource TitleBorderColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="5" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="当前值" /> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 表格数据显示--> | |||
<ScrollViewer | |||
Grid.Row="1" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Hidden"> | |||
<ItemsControl ItemsSource="{Binding variableMonitors}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<Grid x:Name="gr" Height="30"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.3*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="14" | |||
Foreground="{StaticResource FontColor}" | |||
Text="{Binding Id}" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="14" | |||
Foreground="{StaticResource FontColor}" | |||
Text="{Binding VarName}" /> | |||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="2" | |||
Margin="5,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="14" | |||
Foreground="{StaticResource FontColor}" | |||
Text="{Binding PLCAddress}" /> | |||
<Grid Grid.Column="3"> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="14" | |||
Foreground="{StaticResource FontColor}" | |||
Text="{Binding Notes}" /> | |||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,0,0" /> | |||
</Grid> | |||
<Grid Grid.Column="4"> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="14" | |||
Foreground="{StaticResource FontColor}" | |||
Text="{Binding ModbusTcpAddress}" /> | |||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="5" | |||
Margin="5,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="14" | |||
Foreground="{StaticResource FontColor}" | |||
Text="{Binding CurrentValue}" /> | |||
<Border | |||
Grid.ColumnSpan="8" | |||
BorderBrush="{StaticResource BorderSolid}" | |||
BorderThickness="1" /> | |||
</Grid> | |||
<DataTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" /> | |||
</Trigger> | |||
</DataTemplate.Triggers> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</ScrollViewer> | |||
<!--#endregion--> | |||
</Grid> | |||
</UserControl> |
@@ -46,28 +46,11 @@ | |||
<Grid Margin="10"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition Height="35" /> | |||
<RowDefinition Height="Auto" /> | |||
</Grid.RowDefinitions> | |||
<CheckBox | |||
Grid.Row="0" | |||
Grid.Column="2" | |||
Height="20" | |||
Margin="10" | |||
VerticalAlignment="Top" | |||
Background="#FF2AB2E7" | |||
Content="开机启动" | |||
FontSize="14" | |||
Foreground="#00c2f4" | |||
IsChecked="{Binding IsSelected}" | |||
Template="{StaticResource CbTemplate}" /> | |||
<StackPanel | |||
Grid.Row="1" | |||
HorizontalAlignment="Right" | |||
Orientation="Horizontal"> | |||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="请点击按钮保存参数:" /> | |||
@@ -3,7 +3,10 @@ using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.Business; | |||
using BPASmartClient.Device; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.ObjectModel; | |||
namespace BPASmartClient.MorkS.ViewModel | |||
{ | |||
@@ -13,5 +16,10 @@ namespace BPASmartClient.MorkS.ViewModel | |||
{ | |||
} | |||
public static int DeviceId { get; set; } | |||
public ObservableCollection<VariableMonitor> variableMonitors { get; set; } = Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices()?.FirstOrDefault(p => p.DeviceId == DeviceId)?.variableMonitors; | |||
} | |||
} |
@@ -1,8 +1,12 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.MorkS.Model; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
namespace BPASmartClient.MorkS.ViewModel | |||
@@ -11,7 +15,29 @@ namespace BPASmartClient.MorkS.ViewModel | |||
{ | |||
public ParSetViewModel() | |||
{ | |||
SaveInfoCommand = new Action(() => | |||
{ | |||
List<ushort> values = new List<ushort>(); | |||
values.Clear(); | |||
List<bool> bools = new List<bool>(); | |||
bools.Clear(); | |||
for (int i = 0; i < Json<MorksPar>.Data.parSets.Count; i++) | |||
{ | |||
values.Clear(); | |||
values.Add(Json<MorksPar>.Data.parSets[i].Minute); | |||
values.Add(Json<MorksPar>.Data.parSets[i].Second); | |||
bools.Add(Json<MorksPar>.Data.parSets[i].IsShield); | |||
ActionManage.GetInstance.Send("WriteVW", new WritePar() { Address = $"VW{116 + (i * 6)}", Value = values.ToArray() }); | |||
} | |||
ActionManage.GetInstance.Send("WriteBools", new WritePar() { Address = "M260.0", Value = bools.ToArray() }); | |||
Json<MorksPar>.Save(); | |||
}); | |||
} | |||
public Action SaveInfoCommand { get; set; } | |||
public ObservableCollection<ParSet> parSets { get; set; } = Json<MorksPar>.Data.parSets; | |||
} | |||
} |
@@ -40,11 +40,7 @@ namespace BPASmartClient.MorkT | |||
morkT.MakeCoffeeOrder.OrderStatus = 1; | |||
}); | |||
int i = 0; | |||
////ThreadManage.GetInstance().StartLong(new Action(() => | |||
////{ | |||
//// i = (int)Status.status["GSIceCream.IceCreamMachine.test"]; | |||
////}),"test"); | |||
MessageLog.GetInstance.Show("MORKT 设备初始化完成"); | |||
@@ -77,10 +73,6 @@ namespace BPASmartClient.MorkT | |||
})); | |||
MakeCoffeeProcess(); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 },(o)=> | |||
{ | |||
@@ -223,7 +215,7 @@ namespace BPASmartClient.MorkT | |||
private void Wait(int value = 101) | |||
{ | |||
while (!((bool)Status.status["Lebai.LebaiRobot.OK"] && (int)Status.status["Lebai.LebaiRobot.Value"] == value)) | |||
while (!((bool)peripheralStatus["OK"] && (int)peripheralStatus["Value"] == value)) | |||
{ | |||
Thread.Sleep(5); | |||
} | |||
@@ -364,14 +356,14 @@ namespace BPASmartClient.MorkT | |||
{ | |||
if (IceCreamCanMake()) | |||
{ | |||
if(Status.status.ContainsKey("GSIceCream.IceCreamMachine.CurrentMode")) | |||
if(peripheralStatus.ContainsKey("CurrentMode")) | |||
{ | |||
if ((MORKI_MODE)Status.status["GSIceCream.IceCreamMachine.CurrentMode"] != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
if ((MORKI_MODE)peripheralStatus["CurrentMode"] != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
} | |||
if(Status.status.ContainsKey("GSIceCream.IceCreamMachine.CBX")) | |||
if(peripheralStatus.ContainsKey(".CBX")) | |||
{ | |||
if ((short)Status.status["GSIceCream.IceCreamMachine.CBX"] >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作 | |||
if ((short)peripheralStatus["CBX"] >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作 | |||
{ | |||
bool result = true; | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 }, (res) => | |||
@@ -491,7 +483,7 @@ namespace BPASmartClient.MorkT | |||
{ | |||
int count_1 = 0; | |||
while ((short)Status.status["GSIceCream.IceCreamMachine.CBX"] <= 86) | |||
while ((short)peripheralStatus["CBX"] <= 86) | |||
{ | |||
Thread.Sleep(5); | |||
count_1++; | |||
@@ -1,4 +1,5 @@ | |||
| |||
using BPASmartClient.Business; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.IoT; | |||
using DataVAPI.Tool.IOT; | |||
@@ -22,7 +23,7 @@ namespace BPASmartClient.ViewModel | |||
deviceTable = new ObservableCollection<DeviceTable>(); | |||
device = new DeviceTable(); | |||
deviceTableSelectedItem = new DeviceTable(); | |||
ApiURL = System.Configuration.ConfigurationManager.AppSettings["DataVServiceUri"].ToString(); | |||
ApiURL = InternetInfo.DataVApiAddress; | |||
Refresh(); | |||
} | |||
#endregion | |||
@@ -47,8 +47,6 @@ namespace BPASmartClient.ViewModel | |||
GetData(); | |||
} | |||
private void GetData() | |||
{ | |||
var text = TextHelper.GetInstance.ReadTextInfo("StartShop", "DeviceConfig"); | |||
@@ -68,6 +66,24 @@ namespace BPASmartClient.ViewModel | |||
} | |||
} | |||
} | |||
if (Devices.Count > 0) | |||
{ | |||
Devices.ElementAt(0).IsChecked = true; | |||
DeviceMonitors.Clear(); | |||
Assembly.Load(Devices.ElementAt(0).Namespace.Substring(0, Devices.ElementAt(0).Namespace.LastIndexOf("."))).GetTypes().ToList().ForEach((type) => | |||
{ | |||
if (type?.BaseType?.Name == "UserControl") | |||
{ | |||
var fe = type.GetConstructor(Type.EmptyTypes).Invoke(null) as FrameworkElement; | |||
DeviceMonitors.Add(new Device() { Name = fe.Name, Namespace = type?.FullName, fe = fe }); | |||
} | |||
}); | |||
if (DeviceMonitors.Count > 0) | |||
{ | |||
DeviceMonitors.ElementAt(0).IsChecked = true; | |||
if (DeviceMonitors.ElementAt(0).fe != null) MainContent = DeviceMonitors.ElementAt(0).fe; | |||
} | |||
} | |||
} | |||
public FrameworkElement MainContent { get { return _mMainContent; } set { _mMainContent = value; OnPropertyChanged(); } } | |||
@@ -93,7 +109,13 @@ namespace BPASmartClient.ViewModel | |||
public string Namespace { get { return _mNamespace; } set { _mNamespace = value; OnPropertyChanged(); } } | |||
private string _mNamespace; | |||
public bool IsChecked { get { return _mIsChecked; } set { _mIsChecked = value; OnPropertyChanged(); } } | |||
private bool _mIsChecked; | |||
public FrameworkElement fe { get; set; } | |||
} | |||
@@ -1,4 +1,5 @@ | |||
using BPASmartClient.CustomResource.UserControls; | |||
using BPASmartClient.Business; | |||
using BPASmartClient.CustomResource.UserControls; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.IoT; | |||
@@ -51,7 +52,7 @@ namespace BPASmartClient.ViewModel | |||
#region 函数 | |||
public void Init() | |||
{ | |||
DataVApiAddress = System.Configuration.ConfigurationManager.AppSettings["DataVServiceUri"].ToString(); | |||
DataVApiAddress = InternetInfo.DataVApiAddress; | |||
LogDataFile = new ObservableCollection<FileModel>(); | |||
//查询 | |||
@@ -17,29 +17,29 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
if (SaveInfoCommand == null) | |||
{ | |||
SaveInfoCommand = new Action(() => | |||
{ | |||
List<ushort> values = new List<ushort>(); | |||
values.Clear(); | |||
//SaveInfoCommand = new Action(() => | |||
//{ | |||
// List<ushort> values = new List<ushort>(); | |||
// values.Clear(); | |||
List<bool> bools = new List<bool>(); | |||
bools.Clear(); | |||
// List<bool> bools = new List<bool>(); | |||
// bools.Clear(); | |||
for (int i = 0; i < Json<KeepDataBase>.Data.parSets.Count; i++) | |||
{ | |||
values.Clear(); | |||
values.Add(Json<KeepDataBase>.Data.parSets[i].Minute); | |||
values.Add(Json<KeepDataBase>.Data.parSets[i].Second); | |||
bools.Add(Json<KeepDataBase>.Data.parSets[i].IsShield); | |||
//ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetWordAddress($"VW{116 + (i * 6)}"), WriteType.HoldingRegisters, values.ToArray()); | |||
} | |||
//ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetBoolAddress("M260.0"), WriteType.Coils, bools.ToArray()); | |||
// for (int i = 0; i < Json<KeepDataBase>.Data.parSets.Count; i++) | |||
// { | |||
// values.Clear(); | |||
// values.Add(Json<KeepDataBase>.Data.parSets[i].Minute); | |||
// values.Add(Json<KeepDataBase>.Data.parSets[i].Second); | |||
// bools.Add(Json<KeepDataBase>.Data.parSets[i].IsShield); | |||
// //ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetWordAddress($"VW{116 + (i * 6)}"), WriteType.HoldingRegisters, values.ToArray()); | |||
// } | |||
// //ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetBoolAddress("M260.0"), WriteType.Coils, bools.ToArray()); | |||
}); | |||
//}); | |||
} | |||
} | |||
public ObservableCollection<ParSet> parSets { get; set; } = Json<KeepDataBase>.Data.parSets; | |||
//public ObservableCollection<ParSet> parSets { get; set; } = Json<KeepDataBase>.Data.parSets; | |||
public Action SaveInfoCommand { get; set; } | |||
} | |||
@@ -1,48 +1,21 @@ | |||
<?xml version="1.0" encoding="utf-8" ?> | |||
<configuration> | |||
<appSettings> | |||
<!--通用配置--> | |||
<!--1:且时且多冰淇淋咖啡机,2:且时且多煮面机,3:海科煮面机测试店铺--> | |||
<add key="ClientId" value="50"/> | |||
<!--<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/"/>--> | |||
<!--<add key="ApolloUri" value="https://bpa.black-pa.com:28080"/>--> | |||
<!--<add key="ClientId" value="2"/>--> | |||
<!--通用配置--> | |||
<add key="ClientId" value="51"/> | |||
<!--开发环境--> | |||
<!--<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="apollouri" value="http://10.2.1.21:28080/"/> | |||
<add key="AppId" value="dev1_common"/> | |||
<add key ="Namespaces" value="DEV.Config"/> | |||
<add key="IsEnableTest" value="False"/>--> | |||
<!--测试环境--> | |||
<!--<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="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="apollouri" value="http://47.108.65.220:28080/"/> | |||
<add key="AppId" value="order"/> | |||
<add key ="Namespaces" value="TEST1.Config"/> | |||
<add key="IsEnableTest" value="false"/> | |||
<add key="IsEnableTest" value="False"/> | |||
<!--阿里云上报启动方式:API 或者 LOCAL--> | |||
<!--API :通过客户端ID,调用接口查询“设备连接信息”--> | |||
@@ -1,4 +1,5 @@ | |||
using System; | |||
using BPASmartClient.Business; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
@@ -18,13 +19,14 @@ namespace BPASmartClient.Control | |||
/// <summary> | |||
/// BatchingAddView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class BatchingAddView :UserControl | |||
public partial class BatchingAddView : UserControl | |||
{ | |||
public BatchingAddView() | |||
{ | |||
InitializeComponent(); | |||
webView.Source=new Uri(System.Configuration.ConfigurationManager.AppSettings["WebServiceUri"].ToString()); | |||
//webView.Source=new Uri(System.Configuration.ConfigurationManager.AppSettings["WebServiceUri"].ToString()); | |||
webView.Source = new Uri(InternetInfo.WebServiceUri); | |||
} | |||
} | |||
} |
@@ -81,6 +81,7 @@ | |||
CommandParameter="{Binding Namespace}" | |||
Content="{Binding Name}" | |||
GroupName="Devices" | |||
IsChecked="{Binding IsChecked}" | |||
Style="{StaticResource RectangleRadioButtonStyle}" /> | |||
</Grid> | |||
</DataTemplate> | |||
@@ -108,6 +109,7 @@ | |||
Content="{Binding Name}" | |||
FontSize="16" | |||
GroupName="DeviceMotion" | |||
IsChecked="{Binding IsChecked}" | |||
Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
</Grid> | |||
</DataTemplate> | |||
@@ -48,7 +48,7 @@ namespace BPASmartClient | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
myMenu.Visibility = Visibility.Visible; | |||
MenuItem_Click(new MenuItem() { Tag = "LogView", Header = "日志监视" },null); | |||
MenuItem_Click(new MenuItem() { Tag = "LogView", Header = "日志监视" }, null); | |||
}), "LoginSuccess"); | |||
Initialize(); | |||
} | |||
@@ -80,18 +80,21 @@ namespace BPASmartClient | |||
mainConsole.Start(); | |||
}), "启动主控制台", false); | |||
ThreadManage.GetInstance().Start(new Action(() => | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
try | |||
ThreadManage.GetInstance().Start(new Action(() => | |||
{ | |||
DataVClient.GetInstance().Initialize(); | |||
DataVClient.GetInstance().Start(); | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
} | |||
}), "启动主IoT", false); | |||
try | |||
{ | |||
DataVClient.GetInstance().Initialize(); | |||
DataVClient.GetInstance().Start(); | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
} | |||
}), "启动主IoT", false); | |||
}), "配置初始化完成Iot启动"); | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
@@ -102,14 +105,14 @@ namespace BPASmartClient | |||
switch (iot.CommandName) | |||
{ | |||
case 0://控制类 | |||
if (iot.CommandValue != null && iot.CommandValue.Count>0) | |||
if (iot.CommandValue != null && iot.CommandValue.Count > 0) | |||
{ | |||
switch (iot.CommandValue.Keys.ToList()[0]) | |||
{ | |||
case "程序启动": | |||
//mainConsole.Start(); | |||
break; | |||
//mainConsole.Stop(); | |||
//mainConsole.Stop(); | |||
case "程序停止": | |||
break; | |||
case "程序复位": | |||