diff --git a/BPASmartClient.Business/BPASmartClient.Business.csproj b/BPASmartClient.Business/BPASmartClient.Business.csproj
index c6bacbd8..da5bfe70 100644
--- a/BPASmartClient.Business/BPASmartClient.Business.csproj
+++ b/BPASmartClient.Business/BPASmartClient.Business.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/BPASmartClient.Business/Plugin/ConfigMgr.cs b/BPASmartClient.Business/Plugin/ConfigMgr.cs
index 61c84ae4..6d7ea90a 100644
--- a/BPASmartClient.Business/Plugin/ConfigMgr.cs
+++ b/BPASmartClient.Business/Plugin/ConfigMgr.cs
@@ -25,6 +25,8 @@ namespace BPASmartClient.Business
//Apollo地址
private string apolloUri;
+ private string apoid;
+ private string namespa;
//设备集合
private List deviceConfigs;
public void Dispose()
@@ -35,6 +37,8 @@ namespace BPASmartClient.Business
{
ClientId = int.Parse(System.Configuration.ConfigurationManager.AppSettings["ClientId"]);
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();
InitDeviceModel();
@@ -83,60 +87,6 @@ namespace BPASmartClient.Business
deviceConfig.Peripherals.Add(peripheral);
}
}
-
-
- //if (null != device.Element("Parameters"))
- //{
- // foreach (var deviceParameter in device.Element("Parameters").Elements())
- // {
- // deviceConfig.Parameters.Add(deviceParameter.Name.LocalName, deviceParameter.Value);
- // }
- //}
-
- //var Peripheral = device.XPathSelectElements("Parameters");
- //if (null != Peripheral)
- //{
- // foreach (var deviceParameter in Peripheral)
- // {
- // deviceConfig.Parameters.Add(deviceParameter.Name.LocalName, deviceParameter.Value);
- // }
- //}
-
-
-
- //if (device.Element("Peripheral") != null)
- //{
- // foreach (var peripherals in device.Element("Peripheral").Elements())
- // {
- // BPASmartClient.Model.Peripheral peripheral = new BPASmartClient.Model.Peripheral();
- // peripheral.Module = peripherals.Attribute("Module").Value;
- // if (null != peripherals.Element("Parameters"))
- // {
- // foreach (XElement parameter in peripherals.Element("Parameters").Elements())
- // {
- // peripheral.Parameters.Add(parameter.Name.LocalName, parameter.Value);
- // }
- // }
- // deviceConfig.Peripherals.Add(peripheral);
- // }
- //}
-
-
-
-
- //foreach (var peripheralEl in device.XPathSelectElements("//Peripheral"))
- //{
- // BPASmartClient.Model.Peripheral peripheral = new BPASmartClient.Model.Peripheral();
- // peripheral.Module = peripheralEl.Attribute("Module").Value;
- // if (null != peripheralEl.Element("Parameters"))
- // {
- // foreach (XElement parameter in peripheralEl.Element("Parameters").Elements())
- // {
- // peripheral.Parameters.Add(parameter.Name.LocalName, parameter.Value);
- // }
- // }
- // deviceConfig.Peripherals.Add(peripheral);
- //}
deviceConfigs.Add(deviceConfig);
}
}
@@ -159,9 +109,9 @@ namespace BPASmartClient.Business
//正式版本
configurationBuilder.AddApolloConfiguration(p =>
{
- p.AppId = "order";
+ p.AppId = apoid;
p.MetaServer = apolloUri;
- p.Namespaces = new List() { "TEST1.Config" };
+ p.Namespaces = new List() { namespa };
});
IConfiguration config = configurationBuilder.Build();
diff --git a/BPASmartClient.Business/Plugin/DeviceMgr.cs b/BPASmartClient.Business/Plugin/DeviceMgr.cs
index a93a5e02..ec21017d 100644
--- a/BPASmartClient.Business/Plugin/DeviceMgr.cs
+++ b/BPASmartClient.Business/Plugin/DeviceMgr.cs
@@ -99,7 +99,7 @@ namespace BPASmartClient.Business
{
EventBus.EventBus.GetInstance().Publish(new RecipeBomEvent()
{
- Id = device.DeviceId,
+ DeviceId = device.DeviceId,
recipeBoms = JsonConvert.DeserializeObject(result)
});
MessageLog.GetInstance.Show("接收到辅料信息");
@@ -109,7 +109,7 @@ namespace BPASmartClient.Business
var apiData = JsonConvert.DeserializeObject(result);
EventBus.EventBus.GetInstance().Publish(new MaterialDeliveryEvent()
{
- Id = device.DeviceId,
+ DeviceId = device.DeviceId,
orderMaterialDelivery = apiData
});
MessageLog.GetInstance.Show("接收到物料信息");
diff --git a/BPASmartClient.Business/Plugin/OrderProxy.cs b/BPASmartClient.Business/Plugin/OrderProxy.cs
index c27db0b9..579cd026 100644
--- a/BPASmartClient.Business/Plugin/OrderProxy.cs
+++ b/BPASmartClient.Business/Plugin/OrderProxy.cs
@@ -1,4 +1,4 @@
-#define test
+//#define test
using BPA.Message;
using BPA.Message.Enum;
using BPASmartClient.EventBus;
@@ -109,7 +109,7 @@ namespace BPASmartClient.Business
morkOrderPushes.Enqueue(temp);
#endif
var orderEvent = DoOrderEvent.Make(temp);
- orderEvent.Id = device.DeviceId;
+ orderEvent.DeviceId = device.DeviceId;
orderEvent.Publish();
ActionManage.GetInstance.Send("AddOrder", new object[] { temp, device });
}
@@ -124,6 +124,8 @@ namespace BPASmartClient.Business
OrderStatusChangedEvent orderStatusChangedEvent = @event as OrderStatusChangedEvent;
string result = string.Empty;
OrderStatusChange orderStatusChange = new OrderStatusChange() { CookingStatus = orderStatusChangedEvent.Status, SuborderId = orderStatusChangedEvent.SubOrderId };
+
+ #region API 订单状态修改
try
{
string header = $"[{InternetInfo.OrderServer}/order/robotstatuschange]_[{DateTime.Now.Ticks}]".AESEncrypt();
@@ -137,8 +139,17 @@ namespace BPASmartClient.Business
var res = JsonConvert.DeserializeObject(result);
ActionManage.GetInstance.Send("OrderStatusChange", orderStatusChangedEvent);
MessageLog.GetInstance.Show(string.Format("订单状态改变,调用API执行结果{0}", res == null ? false : res.isSuccess));
+ #endregion
+
+
+ #region MQTT 订单状态修改
+ var clientId = Plugin.GetInstance().GetPlugin().ClientId;
+ var temp = BPAPackage.Make(orderStatusChange, clientId, orderStatusChangedEvent.deviceClientType);
+ Plugin.GetInstance().GetPlugin().Publish(TOPIC.GetInstance.GetAppTopic(clientId.ToString()), temp.Serialize(false));
+ #endregion
}
+
///
/// 资源释放
///
diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
index 5327ae72..f1590991 100644
--- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
+++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
@@ -200,7 +200,7 @@
-
+
diff --git a/BPASmartClient.DRCoffee/CoffeeMachine.cs b/BPASmartClient.DRCoffee/CoffeeMachine.cs
index 7f2f7bb6..614b24b5 100644
--- a/BPASmartClient.DRCoffee/CoffeeMachine.cs
+++ b/BPASmartClient.DRCoffee/CoffeeMachine.cs
@@ -141,7 +141,7 @@ namespace BPASmartClient.DRCoffee
{
status["Status"] = package.Status;
lastRefreshTime = DateTime.Now;
- new DRCoffee_CoffeEndCookEvent() { Id = DeviceId }.Publish();
+ new DRCoffee_CoffeEndCookEvent() { DeviceId = DeviceId }.Publish();
}
else status["Status"] = package.Status;
status["AppStatus"] = package.ApplicationStatus;
diff --git a/BPASmartClient.Device/BPASmartClient.Device.csproj b/BPASmartClient.Device/BPASmartClient.Device.csproj
index a980eeee..d6e29885 100644
--- a/BPASmartClient.Device/BPASmartClient.Device.csproj
+++ b/BPASmartClient.Device/BPASmartClient.Device.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/BPASmartClient.EventBus/EventBus.cs b/BPASmartClient.EventBus/EventBus.cs
index 2c95b099..23b6c807 100644
--- a/BPASmartClient.EventBus/EventBus.cs
+++ b/BPASmartClient.EventBus/EventBus.cs
@@ -70,12 +70,12 @@ namespace BPASmartClient.EventBus
///
public void Publish(TEvent @event) where TEvent : IEvent
{
- if (_eventHandls.ContainsKey(@event.Id))
+ if (_eventHandls.ContainsKey(@event.DeviceId))
{
- if (_eventHandls[@event.Id].ContainsKey(typeof(TEvent)))
+ if (_eventHandls[@event.DeviceId].ContainsKey(typeof(TEvent)))
{
- for (int i = _eventHandls[@event.Id][typeof(TEvent)].Count - 1; i >= 0; i--)
- _eventHandls[@event.Id][typeof(TEvent)][i](@event);
+ for (int i = _eventHandls[@event.DeviceId][typeof(TEvent)].Count - 1; i >= 0; i--)
+ _eventHandls[@event.DeviceId][typeof(TEvent)][i](@event);
//_eventHandls[typeof(TEvent)].ForEach(p =>
//{
@@ -91,9 +91,9 @@ namespace BPASmartClient.EventBus
public void Publish(TEvent @event, EventCallBackHandle eventCallBack) where TEvent : IEvent
{
List
-
+
diff --git a/BPASmartClient.Model/BaseEvent.cs b/BPASmartClient.Model/BaseEvent.cs
index f1c8b070..3ee63db2 100644
--- a/BPASmartClient.Model/BaseEvent.cs
+++ b/BPASmartClient.Model/BaseEvent.cs
@@ -1,4 +1,5 @@
-using BPASmartClient.EventBus;
+using BPA.Message.Enum;
+using BPASmartClient.EventBus;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -9,6 +10,7 @@ namespace BPASmartClient.Model
{
public class BaseEvent : IEvent
{
- public int Id { get; set; }
+ public int DeviceId { get; set; }
+ public DeviceClientType deviceClientType { get; set; }
}
}
diff --git a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj
index d65dbbbe..e39ff09d 100644
--- a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj
+++ b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj
@@ -6,6 +6,10 @@
enable
+
+
+
+
diff --git a/BPASmartClient.MorkF/Control_MorkF.cs b/BPASmartClient.MorkF/Control_MorkF.cs
index da316c00..d97a59ad 100644
--- a/BPASmartClient.MorkF/Control_MorkF.cs
+++ b/BPASmartClient.MorkF/Control_MorkF.cs
@@ -106,7 +106,7 @@ namespace BPASmartClient.MorkF
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
{
- EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Id = DeviceId, Status = oRDER_STATUS, SubOrderId = subid });
+ EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { DeviceId = DeviceId, Status = oRDER_STATUS, SubOrderId = subid });
}
///
@@ -504,7 +504,7 @@ namespace BPASmartClient.MorkF
///
private void WriteData(string address, object value)
{
- EventBus.EventBus.GetInstance().Publish(new WriteModel() { Id = DeviceId, Address = address, Value = value });
+ EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value });
}
///
/// 灶台档位调节
diff --git a/BPASmartClient.MorkS/Control.cs b/BPASmartClient.MorkS/Control.cs
index 3e2cf303..25e65e0b 100644
--- a/BPASmartClient.MorkS/Control.cs
+++ b/BPASmartClient.MorkS/Control.cs
@@ -27,6 +27,7 @@ namespace BPASmartClient.MorkS
{
ServerInit();
DataParse();
+ ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitDevice");
}
public override void ResetProgram()
@@ -66,12 +67,12 @@ namespace BPASmartClient.MorkS
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
{
- EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Id = DeviceId, Status = oRDER_STATUS, SubOrderId = subid });
+ EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { DeviceId = DeviceId, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType });
}
private void ReadData(string address, ushort len = 1, Action action = null)
{
- EventBus.EventBus.GetInstance().Publish(new ReadModel() { Id = DeviceId, Address = address, Length = len }, (o) =>
+ EventBus.EventBus.GetInstance().Publish(new ReadModel() { DeviceId = DeviceId, Address = address, Length = len }, (o) =>
{
if (o != null && o.Length > 0 && o[0] is bool[] bools)
{
@@ -159,7 +160,7 @@ namespace BPASmartClient.MorkS
}
}));
- EventBus.EventBus.GetInstance().Publish(new ReadModel() { Id = DeviceId, Address = "VW372", Length = 1 }, (o) =>
+ EventBus.EventBus.GetInstance().Publish(new ReadModel() { DeviceId = DeviceId, Address = "VW372", Length = 1 }, (o) =>
{
if (o != null && o.Length > 0 && o[0] is ushort value)
{
@@ -443,7 +444,7 @@ namespace BPASmartClient.MorkS
private void WriteData(string address, object value)
{
- EventBus.EventBus.GetInstance().Publish(new WriteModel() { Id = DeviceId, Address = address, Value = value });
+ EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value });
}
///
diff --git a/BPASmartClient.ViewModel/LogViewModel.cs b/BPASmartClient.ViewModel/LogViewModel.cs
index 24fb7ce7..ffcb3dd0 100644
--- a/BPASmartClient.ViewModel/LogViewModel.cs
+++ b/BPASmartClient.ViewModel/LogViewModel.cs
@@ -20,10 +20,10 @@ namespace BPASmartClient.ViewModel
///
/// 日志界面
///
- public class LogViewModel :ObservableObject
+ public class LogViewModel : ObservableObject
{
//public DispatcherTimer dispatcherTimer;
- public string ClientId= System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString();
+ public string ClientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString();
private ObservableCollection _LogModels;
public ObservableCollection LogDataGrid
{
@@ -43,20 +43,20 @@ namespace BPASmartClient.ViewModel
public static LogViewModel GetInstance() => _Instance ?? (_Instance = new LogViewModel());
private LogViewModel()
{
- if(LogDataGrid==null)
+ if (LogDataGrid == null)
LogDataGrid = new ObservableCollection();
MessageLog.GetInstance.InfoNotify = new Action((s) =>
{
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
{
- LogDataGrid.Insert(0,new LogModel { message = s,type = "Info" });
+ LogDataGrid.Insert(0, new LogModel { message = s, type = "Base" });//基础消息
}));
});
MessageLog.GetInstance.ExInfoNotify = new Action((s) =>
{
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
{
- LogDataGrid.Insert(0,new LogModel { message = s,type = "Error" });
+ LogDataGrid.Insert(0, new LogModel { message = s, type = "Error" });//错误消息
DataVClient.GetInstance().HttpAddLog(new LogTable
{
ClientId = ClientId,
@@ -67,6 +67,13 @@ namespace BPASmartClient.ViewModel
});
}));
});
+ MessageLog.GetInstance.DeviceProcessLogNotify = new Action((s) =>
+ {
+ Application.Current?.Dispatcher.Invoke(new Action(() =>
+ {
+ LogDataGrid.Insert(0, new LogModel { message = s, type = "Device" });//设备消息
+ }));
+ });
ExcelCommand = new RelayCommand(() =>
{
ExcellOrder();
@@ -83,7 +90,7 @@ namespace BPASmartClient.ViewModel
string text = "时间 类型 日志内容\n";
LogDataGrid?.ToList().ForEach(temp =>
{
- text = text + temp.time + " " + temp.type + " " + temp.message+ "\n";
+ text = text + temp.time + " " + temp.type + " " + temp.message + "\n";
});
SaveFileDialog openfile = new SaveFileDialog();
openfile.Filter = "Txt文件(*.txt)|*.txt";
@@ -95,7 +102,7 @@ namespace BPASmartClient.ViewModel
if (!System.IO.File.Exists(path))
{
//没有则创建这个文件
- FileStream fs1 = new FileStream(path,FileMode.Create,FileAccess.Write);//创建写入文件
+ FileStream fs1 = new FileStream(path, FileMode.Create, FileAccess.Write);//创建写入文件
StreamWriter sw = new StreamWriter(fs1);
sw.WriteLine(text);//开始写入值
sw.Close();
@@ -103,14 +110,14 @@ namespace BPASmartClient.ViewModel
}
else
{
- FileStream fs = new FileStream(path,FileMode.Open,FileAccess.Write);
+ FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Write);
StreamWriter sr = new StreamWriter(fs);
sr.WriteLine(text);//开始写入值
sr.Close();
fs.Close();
}
- string msg = string.Format("记录导出完成,共导出记录{0}条,是否打开!",LogDataGrid.Count);
- if (System.Windows.MessageBox.Show(msg,"提示",MessageBoxButton.OKCancel) == MessageBoxResult.OK)
+ string msg = string.Format("记录导出完成,共导出记录{0}条,是否打开!", LogDataGrid.Count);
+ if (System.Windows.MessageBox.Show(msg, "提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
OpenFile(openfile.FileName);
}
@@ -206,7 +213,7 @@ namespace BPASmartClient.ViewModel
}
- public class LogModel :ObservableObject
+ public class LogModel : ObservableObject
{
public string time { get; set; }
@@ -222,7 +229,7 @@ namespace BPASmartClient.ViewModel
if (_type == value)
return;
_type = value;
- if(_type== "Error") foreground = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#ed0032"));
+ if (_type == "Error") foreground = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#ed0032"));
OnPropertyChanged("type");
}
@@ -246,8 +253,8 @@ namespace BPASmartClient.ViewModel
}
public LogModel()
{
- foreground=new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#21bb2e"));
- time =DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+ foreground = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#21bb2e"));
+ time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
}
}
diff --git a/BPASmartClient/App.config b/BPASmartClient/App.config
index 7c595b55..3fa19c23 100644
--- a/BPASmartClient/App.config
+++ b/BPASmartClient/App.config
@@ -11,7 +11,7 @@
-
+
@@ -23,6 +23,8 @@
+
+