@@ -0,0 +1,16 @@ | |||||
[*.cs] | |||||
# CS8600: 将 null 字面量或可能为 null 的值转换为非 null 类型。 | |||||
dotnet_diagnostic.CS8600.severity = none | |||||
# CS8604: 引用类型参数可能为 null。 | |||||
dotnet_diagnostic.CS8604.severity = none | |||||
# CS8603: 可能返回 null 引用。 | |||||
dotnet_diagnostic.CS8603.severity = none | |||||
# Default severity for all analyzer diagnostics | |||||
dotnet_analyzer_diagnostic.severity = none | |||||
# CS8602: 解引用可能出现空引用。 | |||||
dotnet_diagnostic.CS8602.severity = none |
@@ -1,4 +1,4 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | <PropertyGroup> | ||||
<TargetFramework>net6.0</TargetFramework> | <TargetFramework>net6.0</TargetFramework> | ||||
@@ -6,4 +6,10 @@ | |||||
<Nullable>enable</Nullable> | <Nullable>enable</Nullable> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | |||||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.Helper\BPASmartClient.Helper.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" /> | |||||
</ItemGroup> | |||||
</Project> | </Project> |
@@ -1,7 +0,0 @@ | |||||
namespace BPASmartClient.Business | |||||
{ | |||||
public class Class1 | |||||
{ | |||||
} | |||||
} |
@@ -0,0 +1,54 @@ | |||||
using BPASmartClient.Model; | |||||
using System.Xml.Linq; | |||||
using System.Xml.XPath; | |||||
namespace BPASmartClient.Business | |||||
{ | |||||
public class ConfigMgr : IPlugin | |||||
{ | |||||
private List<DeviceConfig> deviceConfigs; | |||||
public void Dispose() | |||||
{ | |||||
} | |||||
public void Initialize() | |||||
{ | |||||
InitDeviceModel(); | |||||
} | |||||
public List<DeviceConfig> GetDeviceConfigs() | |||||
{ | |||||
if (null == deviceConfigs) | |||||
InitDeviceModel(); | |||||
return deviceConfigs; | |||||
} | |||||
private void InitDeviceModel() | |||||
{ | |||||
deviceConfigs = new List<DeviceConfig>(); | |||||
var devicePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DeviceInfo.xml"); | |||||
var xdoc = XDocument.Load(devicePath); | |||||
var devices = xdoc.XPathSelectElements("//Device"); | |||||
foreach (var device in devices) | |||||
{ | |||||
DeviceConfig deviceConfig = new DeviceConfig(); | |||||
deviceConfig.Name = device.Attribute("Name").Value; | |||||
deviceConfig.Module = device.Attribute("Module").Value; | |||||
deviceConfig.DeviceId = device.Attribute("DeviceId").Value; | |||||
foreach (var peripheralEl in device.XPathSelectElements("//Peripheral")) | |||||
{ | |||||
BPASmartClient.Model.Peripheral peripheral = new BPASmartClient.Model.Peripheral(); | |||||
peripheral.Module = peripheralEl.Attribute("Module").Value; | |||||
foreach (XElement parameter in peripheralEl.Element("Parameters").Elements()) | |||||
{ | |||||
peripheral.Parameters.Add(parameter.Name.LocalName, parameter.Value); | |||||
} | |||||
deviceConfig.Peripherals.Add(peripheral); | |||||
} | |||||
deviceConfigs.Add(deviceConfig); | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,67 @@ | |||||
using BPASmartClient.Device; | |||||
using BPASmartClient.Helper; | |||||
using BPASmartClient.Peripheral; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Reflection; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.Business | |||||
{ | |||||
/// <summary> | |||||
/// 设备管理器,统一管理所有设备资源 | |||||
/// </summary> | |||||
public class DeviceMgr : IPlugin | |||||
{ | |||||
//设备集合 | |||||
private List<IDevice> devices = new List<IDevice>(); | |||||
public void Dispose() | |||||
{ | |||||
} | |||||
public void Initialize() | |||||
{ | |||||
LoadDevice(); | |||||
} | |||||
/// <summary> | |||||
/// 设备加载 | |||||
/// </summary> | |||||
private void LoadDevice() | |||||
{ | |||||
var devices = Plugin.GetInstance().GetPlugin<ConfigMgr>().GetDeviceConfigs(); | |||||
foreach (var device in devices) | |||||
{ | |||||
var deviceTemp = Assembly.Load(device.Module.Substring(0, device.Module.LastIndexOf('.'))).CreateInstance(device.Module) as IDevice; | |||||
deviceTemp.Name = device.Name; | |||||
deviceTemp.DeviceId = device.DeviceId; | |||||
List<IPeripheral> peripherals = new List<IPeripheral>(); | |||||
foreach (var peripheral in device.Peripherals) | |||||
{ | |||||
var peripheralTemp = Assembly.Load(peripheral.Module.Substring(0, peripheral.Module.LastIndexOf('.'))).CreateInstance(peripheral.Module) as IPeripheral; | |||||
foreach (var pars in peripheral.Parameters) | |||||
{ | |||||
peripheralTemp.GetType().GetProperty(pars.Key).SetValue(peripheralTemp, Convert.ChangeType(pars.Value, peripheralTemp.GetType().GetProperty(pars.Key).PropertyType)); | |||||
} | |||||
peripherals.Add(peripheralTemp); | |||||
} | |||||
deviceTemp.Initliaze(peripherals); | |||||
this.devices.Add(deviceTemp); | |||||
} | |||||
} | |||||
public void StartService() | |||||
{ | |||||
this.devices.ForEach(device => device.StartMain()); | |||||
} | |||||
public void StopService() | |||||
{ | |||||
this.devices.ForEach(device => device.Stop()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,16 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.Business | |||||
{ | |||||
/// <summary> | |||||
/// 业务插件 | |||||
/// </summary> | |||||
public interface IPlugin:IDisposable | |||||
{ | |||||
void Initialize(); | |||||
} | |||||
} |
@@ -0,0 +1,37 @@ | |||||
using BPASmartClient.Helper; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.Business | |||||
{ | |||||
public class Plugin : Singleton<Plugin>, IDisposable | |||||
{ | |||||
private List<IPlugin> plugins = new List<IPlugin>(); | |||||
public void Dispose() | |||||
{ | |||||
plugins.ForEach(p => p.Dispose()); | |||||
} | |||||
public void Init() | |||||
{ | |||||
this.GetType().Assembly.GetTypes().ToList().ForEach(plugin => | |||||
{ | |||||
if (plugin.GetInterfaces().Contains(typeof(IPlugin))) | |||||
{ | |||||
plugins.Add((IPlugin)Activator.CreateInstance(plugin)); | |||||
} | |||||
}); | |||||
plugins.ForEach(p => p.Initialize()); | |||||
} | |||||
public T GetPlugin<T>() where T : IPlugin | |||||
{ | |||||
return (T)plugins.FirstOrDefault(p => p.GetType().Equals(typeof(T))); | |||||
} | |||||
} | |||||
} |
@@ -4,8 +4,13 @@ | |||||
<TargetFramework>net6.0</TargetFramework> | <TargetFramework>net6.0</TargetFramework> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | |||||
<None Include="..\.editorconfig" Link=".editorconfig" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" /> | <ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.Peripheral\BPASmartClient.Peripheral.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.SerialPort\BPASmartClient.SerialPort.csproj" /> | <ProjectReference Include="..\BPASmartClient.SerialPort\BPASmartClient.SerialPort.csproj" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -1,16 +1,17 @@ | |||||
using BPASmartClient.DRCoffee; | using BPASmartClient.DRCoffee; | ||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using BPASmartClient.Peripheral; | |||||
using BPASmartClient.SerialPort; | using BPASmartClient.SerialPort; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Threading; | using System.Threading; | ||||
namespace HBLDevice.Coffee | |||||
namespace BPASmartClient.DRCoffee | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 咖啡机 | /// 咖啡机 | ||||
/// </summary> | /// </summary> | ||||
public class CoffeeMachine | |||||
public class CoffeeMachine: BasePeripheral | |||||
{ | { | ||||
//通讯代理 | //通讯代理 | ||||
@@ -69,21 +70,21 @@ namespace HBLDevice.Coffee | |||||
/// </summary> | /// </summary> | ||||
public Action<DrCoffeeAppStatus> CoffeeAppStatusChanged; | public Action<DrCoffeeAppStatus> CoffeeAppStatusChanged; | ||||
public CoffeeMachine(string portName, BaudRates baud) | |||||
public CoffeeMachine() | |||||
{ | { | ||||
commProxy = new SerialPortClient(portName, baud); | |||||
commProxy.SetDataStorage(dataStorage); | |||||
commandHandler.Init(commProxy); | |||||
commandHandler.PauseAsk = delegate (bool pause) | |||||
{ | |||||
free = !pause; | |||||
}; | |||||
//commProxy = new SerialPortClient(portName, baud); | |||||
//commProxy.SetDataStorage(dataStorage); | |||||
//commandHandler.Init(commProxy); | |||||
//commandHandler.PauseAsk = delegate (bool pause) | |||||
//{ | |||||
// free = !pause; | |||||
//}; | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 主线程开始运行 | /// 主线程开始运行 | ||||
/// </summary> | /// </summary> | ||||
public void Start() | |||||
public override void Start() | |||||
{ | { | ||||
commProxy.Start(); | commProxy.Start(); | ||||
running = true; | running = true; | ||||
@@ -93,7 +94,7 @@ namespace HBLDevice.Coffee | |||||
/// <summary> | /// <summary> | ||||
/// 停止运行 | /// 停止运行 | ||||
/// </summary> | /// </summary> | ||||
public void Stop() | |||||
public override void Stop() | |||||
{ | { | ||||
commProxy.Stop(); | commProxy.Stop(); | ||||
running = false; | running = false; | ||||
@@ -151,5 +152,15 @@ namespace HBLDevice.Coffee | |||||
Thread.Sleep(5); | Thread.Sleep(5); | ||||
}), "咖啡机解析线程"); | }), "咖啡机解析线程"); | ||||
} | } | ||||
protected override void InitStatus() | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
public override void Init() | |||||
{ | |||||
} | |||||
} | } | ||||
} | } |
@@ -11,7 +11,7 @@ using System.Text; | |||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace HBLDevice.Coffee | |||||
namespace BPASmartClient.DRCoffee | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 指令封装 | /// 指令封装 | ||||
@@ -6,7 +6,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace HBLDevice.Coffee | |||||
namespace BPASmartClient.DRCoffee | |||||
{ | { | ||||
public class MorkCStatus | public class MorkCStatus | ||||
{ | { | ||||
@@ -4,4 +4,8 @@ | |||||
<TargetFramework>net6.0</TargetFramework> | <TargetFramework>net6.0</TargetFramework> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | |||||
<ProjectReference Include="..\BPASmartClient.Peripheral\BPASmartClient.Peripheral.csproj" /> | |||||
</ItemGroup> | |||||
</Project> | </Project> |
@@ -0,0 +1,41 @@ | |||||
using BPASmartClient.Peripheral; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.Device | |||||
{ | |||||
/// <summary> | |||||
/// 设备基类 | |||||
/// </summary> | |||||
public abstract class BaseDevice : IDevice | |||||
{ | |||||
/// <summary> | |||||
/// 设备ID | |||||
/// </summary> | |||||
public string DeviceId { get; set; } | |||||
/// <summary> | |||||
/// 设备所有状态 | |||||
/// </summary> | |||||
public DeviceStatus Status { get; set; } | |||||
public string Name { get; set; } | |||||
public void Initliaze() | |||||
{ | |||||
} | |||||
public void Initliaze(List<IPeripheral> peripherals) | |||||
{ | |||||
peripherals.ForEach(p => { | |||||
p.DeviceId = this.DeviceId; | |||||
p.Init(); | |||||
}); | |||||
} | |||||
public abstract void StartMain(); | |||||
public abstract void Stop(); | |||||
} | |||||
} |
@@ -1,4 +1,5 @@ | |||||
using System; | |||||
using BPASmartClient.Peripheral; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
@@ -11,11 +12,19 @@ namespace BPASmartClient.Device | |||||
/// </summary> | /// </summary> | ||||
public interface IDevice | public interface IDevice | ||||
{ | { | ||||
/// <summary> | |||||
/// 设备ID | |||||
/// </summary> | |||||
string DeviceId { get; set; } | |||||
string Name { get; set; } | |||||
/// <summary> | |||||
/// 设备所有状态 | |||||
/// </summary> | |||||
DeviceStatus Status { get; set; } | DeviceStatus Status { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 初始化设备加载 | /// 初始化设备加载 | ||||
/// </summary> | /// </summary> | ||||
void Initliaze(); | |||||
void Initliaze(List<IPeripheral> peripherals); | |||||
/// <summary> | /// <summary> | ||||
/// 开启设备主任务 | /// 开启设备主任务 | ||||
/// </summary> | /// </summary> | ||||
@@ -0,0 +1,13 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFramework>net6.0</TargetFramework> | |||||
<ImplicitUsings>enable</ImplicitUsings> | |||||
<Nullable>enable</Nullable> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\BPASmartClient.Helper\BPASmartClient.Helper.csproj" /> | |||||
</ItemGroup> | |||||
</Project> |
@@ -0,0 +1,128 @@ | |||||
using BPASmartClient.Helper; | |||||
using System; | |||||
using System.Collections.Concurrent; | |||||
using System.Collections.Generic; | |||||
/* *********************************************** | |||||
* subject 事件总线,总线入口,后续按类型分发 | |||||
* author 张原川 | |||||
* date 2019/6/3 15:49:03 | |||||
* ***********************************************/ | |||||
namespace BPASmartClient.EventBus | |||||
{ | |||||
/// <summary> | |||||
/// 事件总线 | |||||
/// </summary> | |||||
public class EventBus : Singleton<EventBus> | |||||
{ | |||||
/// <summary> | |||||
/// 事件处理委托 | |||||
/// </summary> | |||||
/// <param name="args"></param> | |||||
public delegate void EventCallBackHandle(params object[] args); | |||||
/// <summary> | |||||
/// 事件处理委托 | |||||
/// </summary> | |||||
/// <param name="event"></param> | |||||
/// <param name="callBack"></param> | |||||
public delegate void EventHandle(IEvent @event, EventCallBackHandle callBack = null); | |||||
/// <summary> | |||||
/// 事件订阅者集合 | |||||
/// </summary> | |||||
private ConcurrentDictionary<string, ConcurrentDictionary<Type, List<EventHandle>>> _eventHandls = new ConcurrentDictionary<string, ConcurrentDictionary<Type, List<EventHandle>>>(); | |||||
/// <summary> | |||||
/// 事件订阅 | |||||
/// </summary> | |||||
public void Subscribe<TEvent>(string id,EventHandle handle) | |||||
{ | |||||
if (!_eventHandls.ContainsKey(id)) | |||||
_eventHandls.TryAdd(id, new ConcurrentDictionary<Type, List<EventHandle>>()); | |||||
if (!_eventHandls[id].ContainsKey(typeof(TEvent))) | |||||
_eventHandls[id].TryAdd(typeof(TEvent), new List<EventHandle>()); | |||||
lock (_eventHandls) | |||||
_eventHandls[id][typeof(TEvent)].Add(handle); | |||||
} | |||||
/// <summary> | |||||
/// 事件退订 | |||||
/// </summary> | |||||
public void UnSubscribe<TEvent>(string id,EventHandle handle) | |||||
{ | |||||
if (_eventHandls.ContainsKey(id)) | |||||
{ | |||||
if (_eventHandls[id].ContainsKey(typeof(TEvent))) | |||||
{ | |||||
if (_eventHandls[id][typeof(TEvent)].Contains(handle)) | |||||
{ | |||||
lock (_eventHandls) | |||||
_eventHandls[id][typeof(TEvent)].Remove(handle); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 事件发布,不带返回 | |||||
/// </summary> | |||||
public void Publish<TEvent>(TEvent @event) where TEvent : IEvent | |||||
{ | |||||
if (_eventHandls.ContainsKey(@event.Id)) | |||||
{ | |||||
if (_eventHandls[@event.Id].ContainsKey(typeof(TEvent))) | |||||
{ | |||||
for (int i = _eventHandls[@event.Id][typeof(TEvent)].Count - 1; i >= 0; i--) | |||||
_eventHandls[@event.Id][typeof(TEvent)][i](@event); | |||||
//_eventHandls[typeof(TEvent)].ForEach(p => | |||||
//{ | |||||
// p(@event); | |||||
//}); | |||||
} | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 事件发布,带返回 | |||||
/// </summary> | |||||
public void Publish<TEvent>(TEvent @event, EventCallBackHandle eventCallBack) where TEvent : IEvent | |||||
{ | |||||
List<object> result = new List<object>(); | |||||
if (_eventHandls.ContainsKey(@event.Id)) | |||||
{ | |||||
if (_eventHandls[@event.Id].ContainsKey(typeof(TEvent))) | |||||
{ | |||||
//_eventHandls[typeof(TEvent)].ForEach(p => | |||||
//{ | |||||
// p(@event, delegate (object[] args) | |||||
// { | |||||
// result.AddRange(args); | |||||
// }); | |||||
//}); | |||||
for (int i = _eventHandls[@event.Id][typeof(TEvent)].Count - 1; i >= 0; i--) | |||||
{ | |||||
_eventHandls[@event.Id][typeof(TEvent)][i](@event, delegate (object[] args) | |||||
{ | |||||
result.AddRange(args); | |||||
}); | |||||
} | |||||
} | |||||
} | |||||
eventCallBack.Invoke(result.ToArray()); | |||||
} | |||||
/// <summary> | |||||
/// 事件总线释放 | |||||
/// </summary> | |||||
public void Dispose() | |||||
{ | |||||
_eventHandls.Clear(); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,10 @@ | |||||
namespace BPASmartClient.EventBus | |||||
{ | |||||
/// <summary> | |||||
/// 事件接口 | |||||
/// </summary> | |||||
public interface IEvent | |||||
{ | |||||
string Id { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,38 @@ | |||||
/* ============================================================================== | |||||
* 功能描述: | |||||
* 创 建 者:张原川 | |||||
* 创建日期:2016/10/10 16:50:12 | |||||
* ==============================================================================*/ | |||||
namespace BPASmartClient.EventBus | |||||
{ | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
public static class IEventExtends | |||||
{ | |||||
#region Methods - Public | |||||
/// <summary> | |||||
/// 发布 | |||||
/// </summary> | |||||
/// <typeparam name="TEvent"></typeparam> | |||||
/// <param name="message"></param> | |||||
public static void Publish<TEvent>(this TEvent message) where TEvent : class, IEvent | |||||
{ | |||||
EventBus.GetInstance().Publish<TEvent>(message); | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <typeparam name="TEvent"></typeparam> | |||||
/// <param name="message"></param> | |||||
/// <param name="eventCallBack"></param> | |||||
public static void Publish<TEvent>(this TEvent message, EventBus.EventCallBackHandle eventCallBack) where TEvent : class, IEvent | |||||
{ | |||||
EventBus.GetInstance().Publish<TEvent>(message, eventCallBack); | |||||
} | |||||
#endregion | |||||
} | |||||
} |
@@ -27,8 +27,8 @@ namespace BPASmartClient.Helper | |||||
{ | { | ||||
get | get | ||||
{ | { | ||||
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{LocaPath.GetInstance.FilePath}\\JSON")); | |||||
return $"{AppDomain.CurrentDomain.BaseDirectory}{LocaPath.GetInstance.FilePath}JSON\\{typeof(T).Name}.json"; | |||||
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{LocaPath.GetInstance().FilePath}\\JSON")); | |||||
return $"{AppDomain.CurrentDomain.BaseDirectory}{LocaPath.GetInstance().FilePath}JSON\\{typeof(T).Name}.json"; | |||||
} | } | ||||
} | } | ||||
@@ -7,12 +7,9 @@ using System.Threading.Tasks; | |||||
namespace BPASmartClient.Helper | namespace BPASmartClient.Helper | ||||
{ | { | ||||
public class LocaPath | |||||
public class LocaPath:Singleton<LocaPath> | |||||
{ | { | ||||
private volatile static LocaPath _Instance; | |||||
public static LocaPath GetInstance => _Instance ?? (_Instance = new LocaPath()); | |||||
private LocaPath() { } | |||||
public string FilePath { get; set; } = string.Empty; | public string FilePath { get; set; } = string.Empty; | ||||
@@ -22,8 +22,8 @@ namespace BPASmartClient.Helper | |||||
{ | { | ||||
if (info?.Length > 0) | if (info?.Length > 0) | ||||
{ | { | ||||
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{LocaPath.GetInstance.FilePath}\\{DicrectoryName}")); | |||||
string path = $"{AppDomain.CurrentDomain.BaseDirectory}{LocaPath.GetInstance.FilePath}\\{DicrectoryName}\\{DateTime.Now.ToString("yyyy-MM-dd") + " " + name}.txt"; | |||||
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{LocaPath.GetInstance().FilePath}\\{DicrectoryName}")); | |||||
string path = $"{AppDomain.CurrentDomain.BaseDirectory}{LocaPath.GetInstance().FilePath}\\{DicrectoryName}\\{DateTime.Now.ToString("yyyy-MM-dd") + " " + name}.txt"; | |||||
StringBuilder sb = new StringBuilder(); | StringBuilder sb = new StringBuilder(); | ||||
sb.Append($"****************************************** {DateTime.Now} ******************************************" + "\n"); | sb.Append($"****************************************** {DateTime.Now} ******************************************" + "\n"); | ||||
sb.Append(info); | sb.Append(info); | ||||
@@ -0,0 +1,85 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.IO; | |||||
using System.Data; | |||||
using System.Xml; | |||||
using System.Xml.Serialization; | |||||
namespace BPASmartClient.Helper | |||||
{ | |||||
/// <summary> | |||||
/// Xml序列化与反序列化 | |||||
/// </summary> | |||||
public class XmlUtil | |||||
{ | |||||
#region 反序列化 | |||||
/// <summary> | |||||
/// 反序列化 | |||||
/// </summary> | |||||
/// <param name="type">类型</param> | |||||
/// <param name="xml">XML字符串</param> | |||||
/// <returns></returns> | |||||
public static object Deserialize(Type type, string xml) | |||||
{ | |||||
try | |||||
{ | |||||
using (StringReader sr = new StringReader(xml)) | |||||
{ | |||||
XmlSerializer xmldes = new XmlSerializer(type); | |||||
return xmldes.Deserialize(sr); | |||||
} | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
return null; | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 反序列化 | |||||
/// </summary> | |||||
/// <param name="type"></param> | |||||
/// <param name="xml"></param> | |||||
/// <returns></returns> | |||||
public static object Deserialize(Type type, Stream stream) | |||||
{ | |||||
XmlSerializer xmldes = new XmlSerializer(type); | |||||
return xmldes.Deserialize(stream); | |||||
} | |||||
#endregion | |||||
#region 序列化 | |||||
/// <summary> | |||||
/// 序列化 | |||||
/// </summary> | |||||
/// <param name="type">类型</param> | |||||
/// <param name="obj">对象</param> | |||||
/// <returns></returns> | |||||
public static string Serializer(Type type, object obj) | |||||
{ | |||||
MemoryStream Stream = new MemoryStream(); | |||||
XmlSerializer xml = new XmlSerializer(type); | |||||
try | |||||
{ | |||||
//序列化对象 | |||||
xml.Serialize(Stream, obj); | |||||
} | |||||
catch (InvalidOperationException) | |||||
{ | |||||
throw; | |||||
} | |||||
Stream.Position = 0; | |||||
StreamReader sr = new StreamReader(Stream); | |||||
string str = sr.ReadToEnd(); | |||||
sr.Dispose(); | |||||
Stream.Dispose(); | |||||
return str; | |||||
} | |||||
#endregion | |||||
} | |||||
} |
@@ -1,7 +1,12 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | <PropertyGroup> | ||||
<TargetFramework>net6.0</TargetFramework> | <TargetFramework>net6.0</TargetFramework> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | |||||
<ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.SerialPort\BPASmartClient.SerialPort.csproj" /> | |||||
</ItemGroup> | |||||
</Project> | </Project> |
@@ -0,0 +1,44 @@ | |||||
using BPASmartClient.KLMCoffee.Protocal; | |||||
namespace BPASmartClient.KLMCoffee | |||||
{ | |||||
/// <summary> | |||||
/// 制作咖啡 | |||||
/// </summary> | |||||
public class MakeCoffeeEvent | |||||
{ | |||||
public DrinkType DrinkCode { get; set; } | |||||
} | |||||
/// <summary> | |||||
/// 取消制作 | |||||
/// </summary> | |||||
public class CancelMakeCoffeeEvent | |||||
{ | |||||
} | |||||
/// <summary> | |||||
/// 模式设置 | |||||
/// </summary> | |||||
public class CoffeeCommCmdEvent | |||||
{ | |||||
//public DrCoffeeCommCmd CommCmd { get; set; } | |||||
} | |||||
/// <summary> | |||||
/// 开始制作 | |||||
/// </summary> | |||||
public class CoffeBeginCook | |||||
{ | |||||
} | |||||
/// <summary> | |||||
/// 结束制作 | |||||
/// </summary> | |||||
public class CoffeEndCook | |||||
{ | |||||
} | |||||
} |
@@ -0,0 +1,111 @@ | |||||
using BPASmartClient.KLMCoffee.Protocal; | |||||
using BPASmartClient.MessageCommunication; | |||||
using BPASmartClient.MessageCommunication.MsgControl; | |||||
using BPASmartClient.SerialPort; | |||||
using System; | |||||
using System.Threading; | |||||
namespace BPASmartClient.KLMCoffee | |||||
{ | |||||
/// <summary> | |||||
/// 指令封装 | |||||
/// </summary> | |||||
internal class CommandHandler | |||||
{ | |||||
byte[] cmdAsk; | |||||
private SerialPortClient commProxy; | |||||
private K95Command drinksOrder = new K95Command(); | |||||
public Action<bool> PauseAsk { get; set; } | |||||
/// <summary> | |||||
/// 初始化 | |||||
/// </summary> | |||||
internal void Init(SerialPortClient commProxy) | |||||
{ | |||||
this.commProxy = commProxy; | |||||
Class_InnerMessageBus.GetInstance().ListenMessage(this,Class_MessageName.KLMCoffee_MakeCoffee,"MakeCoffeeHandler"); | |||||
Class_InnerMessageBus.GetInstance().ListenMessage(this,Class_MessageName.KLMCoffee_CancelMakeCoffee,"CancelMakeCoffeeHandler"); | |||||
Class_InnerMessageBus.GetInstance().ListenMessage(this,Class_MessageName.KLMCoffee_CoffeeCommCmd,"CoffeeCommCmdHandler"); | |||||
} | |||||
///// <summary> | |||||
///// 制作咖啡 | |||||
///// </summary> | |||||
//public void MakeCoffeeHandler(object sender,InnerMessageEventArgs e) | |||||
//{ | |||||
// try | |||||
// { | |||||
// if (e.obj_MessageObj is MakeCoffeeEvent) | |||||
// { | |||||
// PauseAsk?.Invoke(true); | |||||
// Thread.Sleep(200); | |||||
// drinksOrder.ReturnsCommandData(K95CommandEnum.配方咖啡制作.GetString(),new new RecipeModel().Packe | |||||
// ); | |||||
// drinksOrder.CommCmd = DrCoffeeCommCmd.饮品制作指令; | |||||
// drinksOrder.DrinksCode = (DrCoffeeDrinksCode)int.Parse(e.obj_MessageObj.ToString()); | |||||
// commProxy.SendData(DrCoffee.Packe(drinksOrder)); | |||||
// Thread.Sleep(200); | |||||
// PauseAsk?.Invoke(false); | |||||
// } | |||||
// } | |||||
// catch (Exception ex) | |||||
// { | |||||
// MessageLog.GetInstance.Show($"BPASmartClient.DRCoffee 中引发错误,CancelMakeCoffeeHandler 类,描述:[{ex.Message}]"); | |||||
// } | |||||
//} | |||||
///// <summary> | |||||
///// 取消制作 | |||||
///// </summary> | |||||
//public void CancelMakeCoffeeHandler(object sender,InnerMessageEventArgs e) | |||||
//{ | |||||
// try | |||||
// { | |||||
// PauseAsk?.Invoke(true); | |||||
// Thread.Sleep(200); | |||||
// drinksOrder.CommCmd = DrCoffeeCommCmd.取消应用指令; | |||||
// drinksOrder.DrinksCode = 0; | |||||
// commProxy.SendData(DrCoffee.Packe(drinksOrder)); | |||||
// Thread.Sleep(200); | |||||
// PauseAsk?.Invoke(false); | |||||
// } | |||||
// catch (Exception ex) | |||||
// { | |||||
// MessageLog.GetInstance.Show($"BPASmartClient.DRCoffee 中引发错误,CancelMakeCoffeeHandler 类,描述:[{ex.Message}]"); | |||||
// } | |||||
//} | |||||
///// <summary> | |||||
///// 模式设置 | |||||
///// </summary> | |||||
///// <param name="sender"></param> | |||||
///// <param name="e"></param> | |||||
//public void CoffeeCommCmdHandler(object sender,InnerMessageEventArgs e) | |||||
//{ | |||||
// try | |||||
// { | |||||
// if (e.obj_MessageObj is string) | |||||
// { | |||||
// PauseAsk?.Invoke(true); | |||||
// Thread.Sleep(200); | |||||
// drinksOrder.CommCmd = (DrCoffeeCommCmd)int.Parse(e.obj_MessageObj.ToString()); | |||||
// commProxy.SendData(DrCoffee.Packe(drinksOrder)); | |||||
// Thread.Sleep(200); | |||||
// PauseAsk?.Invoke(false); | |||||
// } | |||||
// } | |||||
// catch (Exception ex) | |||||
// { | |||||
// MessageLog.GetInstance.Show($"BPASmartClient.DRCoffee 中引发错误,CoffeeCommCmdHandler 类,描述:[{ex.Message}]"); | |||||
// } | |||||
//} | |||||
/// <summary> | |||||
/// 发送状态询问 | |||||
/// </summary> | |||||
internal byte[] GetStatusAsk() | |||||
{ | |||||
return cmdAsk; | |||||
} | |||||
} | |||||
} |
@@ -113,15 +113,49 @@ namespace BPASmartClient.KLMCoffee.Protocal | |||||
#endregion | #endregion | ||||
#region 8种配方测试示例 | #region 8种配方测试示例 | ||||
//RecipeModel recipeModel = new RecipeModel(); | |||||
//string sd = recipeModel.GetItalian(60); | |||||
//sd = recipeModel.GetAmerican(60,450); | |||||
//sd = recipeModel.GetHotWater(194); | |||||
//sd = recipeModel.GetCabo(60,17); | |||||
//sd = recipeModel.GetMacChiato(60,8,17); | |||||
//sd = recipeModel.GetLatte(60,8,17); | |||||
//sd = recipeModel.GetHotMilk(8); | |||||
//sd = recipeModel.GetHotMilkFoam(17); | |||||
/// <summary> | |||||
/// 获取8中配方 | |||||
/// </summary> | |||||
/// <param name="drink"></param> | |||||
/// <returns></returns> | |||||
public string Packe(DrinkType drink) | |||||
{ | |||||
try | |||||
{ | |||||
switch (drink) | |||||
{ | |||||
case DrinkType.意式: | |||||
return GetItalian(60); | |||||
break; | |||||
case DrinkType.美式: | |||||
return GetAmerican(60,450); | |||||
break; | |||||
case DrinkType.热水: | |||||
return GetHotWater(194); | |||||
break; | |||||
case DrinkType.卡布: | |||||
return GetCabo(60,17); | |||||
break; | |||||
case DrinkType.玛奇朵: | |||||
return GetMacChiato(60,8,17); | |||||
break; | |||||
case DrinkType.拿铁: | |||||
return GetLatte(60,8,17); | |||||
break; | |||||
case DrinkType.热牛奶: | |||||
return GetHotMilk(8); | |||||
break; | |||||
case DrinkType.热奶沫: | |||||
return GetHotMilkFoam(17); | |||||
break; | |||||
} | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
return GetItalian(60); | |||||
} | |||||
return GetItalian(60); | |||||
} | |||||
#endregion | #endregion | ||||
#region 8种默认配方 | #region 8种默认配方 | ||||
@@ -1,4 +1,4 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | <PropertyGroup> | ||||
<TargetFramework>net6.0</TargetFramework> | <TargetFramework>net6.0</TargetFramework> | ||||
@@ -7,8 +7,10 @@ | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\BPASmartClient.EventBus\BPASmartClient.EventBus.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.Helper\BPASmartClient.Helper.csproj" /> | <ProjectReference Include="..\BPASmartClient.Helper\BPASmartClient.Helper.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.Message\BPASmartClient.Message.csproj" /> | <ProjectReference Include="..\BPASmartClient.Message\BPASmartClient.Message.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.Peripheral\BPASmartClient.Peripheral.csproj" /> | <ProjectReference Include="..\BPASmartClient.Peripheral\BPASmartClient.Peripheral.csproj" /> | ||||
<ProjectReference Include="..\Lebai.SDK\Lebai.SDK.csproj" /> | <ProjectReference Include="..\Lebai.SDK\Lebai.SDK.csproj" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -11,6 +11,9 @@ using BPASmartClient.Message; | |||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using TaskStatus = Lebai.SDK.Dtos.TaskStatus; | using TaskStatus = Lebai.SDK.Dtos.TaskStatus; | ||||
using BPASmartClient.Peripheral; | using BPASmartClient.Peripheral; | ||||
using BPASmartClient.EventBus; | |||||
using static BPASmartClient.EventBus.EventBus; | |||||
using BPASmartClient.Model; | |||||
namespace BPASmartClient.Lebai | namespace BPASmartClient.Lebai | ||||
{ | { | ||||
@@ -240,5 +243,13 @@ namespace BPASmartClient.Lebai | |||||
public override void Stop() | public override void Stop() | ||||
{ | { | ||||
} | } | ||||
public override void Init() | |||||
{ | |||||
EventBus.EventBus.GetInstance().Subscribe<Demo_MakeCoffeeEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack ) | |||||
{ | |||||
}); | |||||
} | |||||
} | } | ||||
} | } |
@@ -63,5 +63,24 @@ namespace BPASmartClient.MessageCommunication | |||||
/// </summary> | /// </summary> | ||||
public static string SCChip_RotorSwitch = "SCChip_RotorSwitch"; | public static string SCChip_RotorSwitch = "SCChip_RotorSwitch"; | ||||
#endregion | #endregion | ||||
#region 伽乐美咖啡机消息名称 | |||||
/// <summary> | |||||
/// 伽乐美咖啡机制作 | |||||
/// </summary> | |||||
public static string KLMCoffee_MakeCoffee = "KLMCoffee_MakeCoffee"; | |||||
/// <summary> | |||||
/// 伽乐美咖啡机取消制作咖啡 | |||||
/// </summary> | |||||
public static string KLMCoffee_CancelMakeCoffee = "KLMCoffee_CancelMakeCoffee"; | |||||
/// <summary> | |||||
/// 伽乐美咖啡机模式设置 | |||||
/// </summary> | |||||
public static string KLMCoffee_CoffeeCommCmd = "KLMCoffee_CoffeeCommCmd"; | |||||
/// <summary> | |||||
/// 伽乐美咖啡机结束制作 | |||||
/// </summary> | |||||
public static string KLMCoffee_CoffeEndCook = "KLMCoffee_CoffeEndCook"; | |||||
#endregion | |||||
} | } | ||||
} | } |
@@ -0,0 +1,13 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFramework>net6.0</TargetFramework> | |||||
<ImplicitUsings>enable</ImplicitUsings> | |||||
<Nullable>enable</Nullable> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\BPASmartClient.EventBus\BPASmartClient.EventBus.csproj" /> | |||||
</ItemGroup> | |||||
</Project> |
@@ -0,0 +1,14 @@ | |||||
using BPASmartClient.EventBus; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.Model | |||||
{ | |||||
public class BaseEvent : IEvent | |||||
{ | |||||
public string Id { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,14 @@ | |||||
using BPASmartClient.EventBus; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.Model | |||||
{ | |||||
public class Demo_MakeCoffeeEvent : BaseEvent | |||||
{ | |||||
} | |||||
} |
@@ -0,0 +1,27 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.Model | |||||
{ | |||||
public class DeviceConfigModel | |||||
{ | |||||
public List<DeviceConfig> Devices { get; set; } = new List<DeviceConfig>(); | |||||
} | |||||
public class DeviceConfig | |||||
{ | |||||
public string Name { get; set; } | |||||
public string Module { get; set; } | |||||
public string DeviceId { get; set; } | |||||
public List<Peripheral> Peripherals { get; set; } = new List<Peripheral>(); | |||||
} | |||||
public class Peripheral | |||||
{ | |||||
public string Module { get; set; } | |||||
public Dictionary<string, string> Parameters { get; set; } = new Dictionary<string, string>(); | |||||
} | |||||
} |
@@ -4,4 +4,8 @@ | |||||
<TargetFramework>net6.0</TargetFramework> | <TargetFramework>net6.0</TargetFramework> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | |||||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | |||||
</ItemGroup> | |||||
</Project> | </Project> |
@@ -1,4 +1,6 @@ | |||||
using System; | |||||
using BPASmartClient.Device; | |||||
using BPASmartClient.Peripheral; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
@@ -6,9 +8,14 @@ using System.Threading.Tasks; | |||||
namespace BPASmartClient.MorkT | namespace BPASmartClient.MorkT | ||||
{ | { | ||||
public class Device_MorkT | |||||
public class Device_MorkT : BaseDevice | |||||
{ | { | ||||
} | |||||
public override void StartMain() | |||||
{ | |||||
} | |||||
public override void Stop() | |||||
{ | |||||
} | |||||
} | |||||
} | } |
@@ -9,7 +9,7 @@ namespace BPASmartClient.Peripheral | |||||
/// <summary> | /// <summary> | ||||
/// 外设基类 | /// 外设基类 | ||||
/// </summary> | /// </summary> | ||||
public abstract class BasePeripheral : IBasePeripheral | |||||
public abstract class BasePeripheral : IPeripheral | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 是否已连接 | /// 是否已连接 | ||||
@@ -19,6 +19,11 @@ namespace BPASmartClient.Peripheral | |||||
/// 是否工作正常 | /// 是否工作正常 | ||||
/// </summary> | /// </summary> | ||||
public bool IsWork { get; protected set; } | public bool IsWork { get; protected set; } | ||||
/// <summary> | |||||
/// 归属设备Id | |||||
/// </summary> | |||||
public string DeviceId { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 外设状态集合 | /// 外设状态集合 | ||||
/// </summary> | /// </summary> | ||||
@@ -41,6 +46,6 @@ namespace BPASmartClient.Peripheral | |||||
public abstract void Stop(); | public abstract void Stop(); | ||||
public abstract void Init(); | |||||
} | } | ||||
} | } |
@@ -9,8 +9,12 @@ namespace BPASmartClient.Peripheral | |||||
/// <summary> | /// <summary> | ||||
/// 外设接口 | /// 外设接口 | ||||
/// </summary> | /// </summary> | ||||
public interface IBasePeripheral | |||||
public interface IPeripheral | |||||
{ | { | ||||
/// <summary> | |||||
/// 设备ID | |||||
/// </summary> | |||||
string DeviceId { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 获取指定状态值 | /// 获取指定状态值 | ||||
/// </summary> | /// </summary> | ||||
@@ -18,6 +22,10 @@ namespace BPASmartClient.Peripheral | |||||
/// <returns>状态值</returns> | /// <returns>状态值</returns> | ||||
object? GetStatus(string statusName); | object? GetStatus(string statusName); | ||||
/// <summary> | /// <summary> | ||||
/// 初始化 | |||||
/// </summary> | |||||
void Init(); | |||||
/// <summary> | |||||
/// 驱动开启 | /// 驱动开启 | ||||
/// </summary> | /// </summary> | ||||
void Start(); | void Start(); |
@@ -6,6 +6,7 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" /> | <ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.Peripheral\BPASmartClient.Peripheral.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.SerialPort\BPASmartClient.SerialPort.csproj" /> | <ProjectReference Include="..\BPASmartClient.SerialPort\BPASmartClient.SerialPort.csproj" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -1,4 +1,5 @@ | |||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using BPASmartClient.Peripheral; | |||||
using BPASmartClient.SerialPort; | using BPASmartClient.SerialPort; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -7,7 +8,7 @@ using System.Threading; | |||||
namespace BPASmartClient.SCChip | namespace BPASmartClient.SCChip | ||||
{ | { | ||||
public class ICChipMachine | |||||
public class ICChipMachine: BasePeripheral | |||||
{ | { | ||||
//指令组装 | //指令组装 | ||||
private CommandHandler commandHandler = new CommandHandler(); | private CommandHandler commandHandler = new CommandHandler(); | ||||
@@ -23,23 +24,21 @@ namespace BPASmartClient.SCChip | |||||
public ICChipMachine(string portName, BaudRates baud) | |||||
public ICChipMachine() | |||||
{ | { | ||||
commProxy = new SerialPortClient(portName, baud); | |||||
commProxy.SetDataStorage(dataStorage); | |||||
commandHandler.Init(commProxy); | |||||
//commProxy = new SerialPortClient(portName, baud); | |||||
//commProxy.SetDataStorage(dataStorage); | |||||
//commandHandler.Init(commProxy); | |||||
} | } | ||||
public void Start() | |||||
public override void Start() | |||||
{ | { | ||||
commProxy.Start(); | commProxy.Start(); | ||||
running = true; | running = true; | ||||
MainLoop(); | MainLoop(); | ||||
} | } | ||||
public void Stop() | |||||
{ | |||||
} | |||||
private void MainLoop() | private void MainLoop() | ||||
{ | { | ||||
@@ -96,6 +95,18 @@ namespace BPASmartClient.SCChip | |||||
} | } | ||||
return structure; | return structure; | ||||
} | } | ||||
protected override void InitStatus() | |||||
{ | |||||
} | |||||
public override void Stop() | |||||
{ | |||||
} | |||||
public override void Init() | |||||
{ | |||||
} | |||||
} | } | ||||
} | } |
@@ -11,4 +11,22 @@ | |||||
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" /> | <ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | |||||
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.DRCoffee\BPASmartClient.DRCoffee.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.GSIceCream\BPASmartClient.GSIceCream.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.KLMCoffee\BPASmartClient.KLMCoffee.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.Lebai\BPASmartClient.Lebai.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.MorkD\BPASmartClient.MorkD.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.MorkS\BPASmartClient.MorkS.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.MorkT\BPASmartClient.MorkT.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.SCChip\BPASmartClient.SCChip.csproj" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<None Update="DeviceInfo.xml"> | |||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | |||||
</None> | |||||
</ItemGroup> | |||||
</Project> | </Project> |
@@ -1,6 +1,6 @@ | |||||
<?xml version="1.0" encoding="utf-8" ?> | <?xml version="1.0" encoding="utf-8" ?> | ||||
<BPADevices> | <BPADevices> | ||||
<Device Name="MorkT" Module="Device_MorkT" ClientId=""> | |||||
<Device Name="MorkT" Module="BPASmartClient.MorkT.Device_MorkT" DeviceId="1"> | |||||
<Peripherals> | <Peripherals> | ||||
<Peripheral Module="BPASmartClient.Lebai.LebaiRobot"> | <Peripheral Module="BPASmartClient.Lebai.LebaiRobot"> | ||||
<Parameters> | <Parameters> | ||||
@@ -9,16 +9,12 @@ | |||||
<OutputSingalValue>0</OutputSingalValue> | <OutputSingalValue>0</OutputSingalValue> | ||||
</Parameters> | </Parameters> | ||||
</Peripheral> | </Peripheral> | ||||
<Peripheral Module="BPASmartClient.DRCoffee"> | |||||
<Peripheral Module="BPASmartClient.DRCoffee.CoffeeMachine"> | |||||
<Parameters> | <Parameters> | ||||
<COM>COM5</COM> | |||||
<BaudRate>9600</BaudRate> | |||||
</Parameters> | </Parameters> | ||||
</Peripheral> | </Peripheral> | ||||
<Peripheral Module="BPASmartClient.BPASmartClient.SCChip"> | |||||
<Peripheral Module="BPASmartClient.SCChip.ICChipMachine"> | |||||
<Parameters> | <Parameters> | ||||
<COM>COM6</COM> | |||||
<BaudRate>115200</BaudRate> | |||||
</Parameters> | </Parameters> | ||||
</Peripheral> | </Peripheral> | ||||
</Peripherals> | </Peripherals> | ||||
@@ -8,6 +8,8 @@ | |||||
mc:Ignorable="d" | mc:Ignorable="d" | ||||
Title="MainWindow" Height="450" Width="800"> | Title="MainWindow" Height="450" Width="800"> | ||||
<Grid> | <Grid> | ||||
<Button Content="Button" HorizontalAlignment="Left" Margin="153,123,0,0" VerticalAlignment="Top" Click="Button_Click"/> | |||||
<pry:IcoButton IcoText=""/> | <pry:IcoButton IcoText=""/> | ||||
</Grid> | </Grid> | ||||
</Window> | </Window> |
@@ -1,4 +1,7 @@ | |||||
using System; | |||||
using BPASmartClient.Business; | |||||
using BPASmartClient.EventBus; | |||||
using BPASmartClient.Model; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
@@ -22,7 +25,13 @@ namespace BPASmartClient | |||||
{ | { | ||||
public MainWindow() | public MainWindow() | ||||
{ | { | ||||
Plugin.GetInstance().Init(); | |||||
InitializeComponent(); | InitializeComponent(); | ||||
} | } | ||||
private void Button_Click(object sender, RoutedEventArgs e) | |||||
{ | |||||
new Demo_MakeCoffeeEvent() { Id = "1" }.Publish(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -63,6 +63,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.OrderProxy", | |||||
EndProject | EndProject | ||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MessageCommunication", "BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj", "{DCC07B39-E342-4841-B9E4-4D44DA2978FD}" | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MessageCommunication", "BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj", "{DCC07B39-E342-4841-B9E4-4D44DA2978FD}" | ||||
EndProject | EndProject | ||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.EventBus", "BPASmartClient.EventBus\BPASmartClient.EventBus.csproj", "{C7FC5FC8-4C72-4CD3-973E-327BDA880DF5}" | |||||
EndProject | |||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.Model", "BPASmartClient.Model\BPASmartClient.Model.csproj", "{268012B6-C4FC-4C40-802C-74D5FAD3CA45}" | |||||
EndProject | |||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.Business", "BPASmartClient.Business\BPASmartClient.Business.csproj", "{EF5EF8EF-4A44-4E44-9594-D878CABC4182}" | |||||
EndProject | |||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1E1191EB-9EA8-460E-A0A3-15DF0BC2EDAB}" | |||||
ProjectSection(SolutionItems) = preProject | |||||
.editorconfig = .editorconfig | |||||
EndProjectSection | |||||
EndProject | |||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.CustomResource", "BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj", "{CB1BC55F-D267-4724-89BE-96E3A5E432A6}" | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.CustomResource", "BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj", "{CB1BC55F-D267-4724-89BE-96E3A5E432A6}" | ||||
EndProject | EndProject | ||||
Global | Global | ||||
@@ -171,6 +182,18 @@ Global | |||||
{CB1BC55F-D267-4724-89BE-96E3A5E432A6}.Debug|Any CPU.Build.0 = Debug|Any CPU | {CB1BC55F-D267-4724-89BE-96E3A5E432A6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||
{CB1BC55F-D267-4724-89BE-96E3A5E432A6}.Release|Any CPU.ActiveCfg = Release|Any CPU | {CB1BC55F-D267-4724-89BE-96E3A5E432A6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||
{CB1BC55F-D267-4724-89BE-96E3A5E432A6}.Release|Any CPU.Build.0 = Release|Any CPU | {CB1BC55F-D267-4724-89BE-96E3A5E432A6}.Release|Any CPU.Build.0 = Release|Any CPU | ||||
{C7FC5FC8-4C72-4CD3-973E-327BDA880DF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{C7FC5FC8-4C72-4CD3-973E-327BDA880DF5}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{C7FC5FC8-4C72-4CD3-973E-327BDA880DF5}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{C7FC5FC8-4C72-4CD3-973E-327BDA880DF5}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{268012B6-C4FC-4C40-802C-74D5FAD3CA45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{268012B6-C4FC-4C40-802C-74D5FAD3CA45}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{268012B6-C4FC-4C40-802C-74D5FAD3CA45}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{268012B6-C4FC-4C40-802C-74D5FAD3CA45}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{EF5EF8EF-4A44-4E44-9594-D878CABC4182}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{EF5EF8EF-4A44-4E44-9594-D878CABC4182}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{EF5EF8EF-4A44-4E44-9594-D878CABC4182}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{EF5EF8EF-4A44-4E44-9594-D878CABC4182}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
EndGlobalSection | EndGlobalSection | ||||
GlobalSection(SolutionProperties) = preSolution | GlobalSection(SolutionProperties) = preSolution | ||||
HideSolutionNode = FALSE | HideSolutionNode = FALSE | ||||
@@ -201,6 +224,9 @@ Global | |||||
{EBDFF87C-0B98-4BB5-8760-D86964E38A88} = {6CEA3385-6F62-452A-8275-033A6037235D} | {EBDFF87C-0B98-4BB5-8760-D86964E38A88} = {6CEA3385-6F62-452A-8275-033A6037235D} | ||||
{DCC07B39-E342-4841-B9E4-4D44DA2978FD} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} | {DCC07B39-E342-4841-B9E4-4D44DA2978FD} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} | ||||
{CB1BC55F-D267-4724-89BE-96E3A5E432A6} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} | {CB1BC55F-D267-4724-89BE-96E3A5E432A6} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} | ||||
{C7FC5FC8-4C72-4CD3-973E-327BDA880DF5} = {1A9920BA-7C8D-4BDC-8D7D-6544A71AF3CF} | |||||
{268012B6-C4FC-4C40-802C-74D5FAD3CA45} = {1A9920BA-7C8D-4BDC-8D7D-6544A71AF3CF} | |||||
{EF5EF8EF-4A44-4E44-9594-D878CABC4182} = {6CEA3385-6F62-452A-8275-033A6037235D} | |||||
EndGlobalSection | EndGlobalSection | ||||
GlobalSection(ExtensibilityGlobals) = postSolution | GlobalSection(ExtensibilityGlobals) = postSolution | ||||
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC} | SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC} | ||||