Kaynağa Gözat

123

样式分支
fyf 2 yıl önce
ebeveyn
işleme
60dac32056
5 değiştirilmiş dosya ile 189 ekleme ve 155 silme
  1. +122
    -0
      .editorconfig
  2. +0
    -4
      BPASmartClient.DRCoffee/BPASmartClient.DRCoffee.csproj
  3. +59
    -30
      BPASmartClient.DRCoffee/CoffeeMachine.cs
  4. +0
    -120
      BPASmartClient.DRCoffee/CommandHandler.cs
  5. +8
    -1
      BPASmartClient.SCChip/ICChipMachine.cs

+ 122
- 0
.editorconfig Dosyayı Görüntüle

@@ -14,3 +14,125 @@ dotnet_analyzer_diagnostic.severity = none

# CS8602: 解引用可能出现空引用。
dotnet_diagnostic.CS8602.severity = none

[*.cs]
#### 命名样式 ####

# 命名规则

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# 符号规范

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# 命名样式

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
csharp_using_directive_placement = outside_namespace:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_conditional_delegate_call = true:suggestion
csharp_style_var_for_built_in_types = false:silent
csharp_style_var_when_type_is_apparent = false:silent
csharp_style_var_elsewhere = false:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_prefer_static_local_function = true:suggestion

[*.vb]
#### 命名样式 ####

# 命名规则

dotnet_naming_rule.interface_should_be_以_i_开始.severity = suggestion
dotnet_naming_rule.interface_should_be_以_i_开始.symbols = interface
dotnet_naming_rule.interface_should_be_以_i_开始.style = 以_i_开始

dotnet_naming_rule.类型_should_be_帕斯卡拼写法.severity = suggestion
dotnet_naming_rule.类型_should_be_帕斯卡拼写法.symbols = 类型
dotnet_naming_rule.类型_should_be_帕斯卡拼写法.style = 帕斯卡拼写法

dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.severity = suggestion
dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.symbols = 非字段成员
dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.style = 帕斯卡拼写法

# 符号规范

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.类型.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.类型.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
dotnet_naming_symbols.类型.required_modifiers =

dotnet_naming_symbols.非字段成员.applicable_kinds = property, event, method
dotnet_naming_symbols.非字段成员.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
dotnet_naming_symbols.非字段成员.required_modifiers =

# 命名样式

dotnet_naming_style.以_i_开始.required_prefix = I
dotnet_naming_style.以_i_开始.required_suffix =
dotnet_naming_style.以_i_开始.word_separator =
dotnet_naming_style.以_i_开始.capitalization = pascal_case

dotnet_naming_style.帕斯卡拼写法.required_prefix =
dotnet_naming_style.帕斯卡拼写法.required_suffix =
dotnet_naming_style.帕斯卡拼写法.word_separator =
dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case

dotnet_naming_style.帕斯卡拼写法.required_prefix =
dotnet_naming_style.帕斯卡拼写法.required_suffix =
dotnet_naming_style.帕斯卡拼写法.word_separator =
dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case

[*.{cs,vb}]
end_of_line = crlf
dotnet_style_qualification_for_field = false:silent
dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
dotnet_code_quality_unused_parameters = all:suggestion

+ 0
- 4
BPASmartClient.DRCoffee/BPASmartClient.DRCoffee.csproj Dosyayı Görüntüle

@@ -4,10 +4,6 @@
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" />
<ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" />


+ 59
- 30
BPASmartClient.DRCoffee/CoffeeMachine.cs Dosyayı Görüntüle

@@ -1,6 +1,7 @@
using BPASmartClient.DRCoffee;
using BPASmartClient.EventBus;
using BPASmartClient.Helper;
using BPASmartClient.Message;
using BPASmartClient.Model;
using BPASmartClient.Peripheral;
using BPASmartClient.SerialPort;
@@ -16,13 +17,10 @@ namespace BPASmartClient.DRCoffee
/// </summary>
public class CoffeeMachine: BasePeripheral
{
public Action<bool> PauseAsk { get; set; }
//通讯代理
SerialPortClient commProxy = null;
//数据仓库
private DataStorage<byte> dataStorage = new DataStorage<byte>();
//指令组装
private CommandHandler commandHandler = new CommandHandler();
//主线程运行标识
private bool running = false;
//是否下发指令,主线程等待
@@ -72,7 +70,9 @@ namespace BPASmartClient.DRCoffee
/// 应用状态改变回调
/// </summary>
public Action<DrCoffeeAppStatus> CoffeeAppStatusChanged;

/// <summary>
/// Dr咖啡机基础协议
/// </summary>
private DrCoffeePackage drinksOrder = new DrCoffeePackage();

/// <summary>
@@ -86,13 +86,7 @@ namespace BPASmartClient.DRCoffee

public CoffeeMachine()
{
//
//commProxy.SetDataStorage(dataStorage);
//commandHandler.Init(commProxy);
//commandHandler.PauseAsk = delegate (bool pause)
//{
// free = !pause;
//};
}

/// <summary>
@@ -100,7 +94,7 @@ namespace BPASmartClient.DRCoffee
/// </summary>
public override void Start()
{
commProxy = new SerialPortClient(PortName,(BaudRates)Enum.Parse(typeof(BaudRates),BaudRate));
commProxy.Start();
running = true;
MainLoop();
@@ -120,15 +114,15 @@ namespace BPASmartClient.DRCoffee
/// </summary>
private void MainLoop()
{
ThreadManage.GetInstance.StartLong(new Action(() =>
{
if (free)
{
commProxy.SendData(commandHandler.GetStatusAsk());
SendCallback?.Invoke(BitConverter.ToString(commandHandler.GetStatusAsk()));
}
Thread.Sleep(200);
}),"咖啡机询问线程");
//ThreadManage.GetInstance.StartLong(new Action(() =>
//{
// if (free)
// {
// commProxy.SendData(commandHandler.GetStatusAsk());
// SendCallback?.Invoke(BitConverter.ToString(commandHandler.GetStatusAsk()));
// }
// Thread.Sleep(200);
//}),"咖啡机询问线程");

ThreadManage.GetInstance.StartLong(new Action(() =>
{
@@ -176,28 +170,63 @@ namespace BPASmartClient.DRCoffee

public override void Init()
{
commProxy = new SerialPortClient(PortName,(BaudRates)Enum.Parse(typeof(BaudRates),BaudRate));
commProxy.SetDataStorage(dataStorage);

//咖博士咖啡机制作
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_MakeCoffeeEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
{
PauseAsk?.Invoke(true);
Thread.Sleep(200);
drinksOrder.CommCmd = DrCoffeeCommCmd.饮品制作指令;
//drinksOrder.DrinksCode = ((DRCoffee_MakeCoffeeEvent)@event).CommCmd;
commProxy.SendData(DrCoffee.Packe(drinksOrder));
Thread.Sleep(200);
PauseAsk?.Invoke(false);
try
{
free = true;
Thread.Sleep(200);
drinksOrder.CommCmd = DrCoffeeCommCmd.饮品制作指令;
//drinksOrder.DrinksCode = ((DRCoffee_MakeCoffeeEvent)@event).CommCmd;
commProxy.SendData(DrCoffee.Packe(drinksOrder));
Thread.Sleep(200);
free = false;
}
catch (Exception ex)
{
MessageLog.GetInstance.Show($"BPASmartClient.DRCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
}
});

//咖博士咖啡机取消制作咖啡
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CancelMakeCoffeeEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
{

try
{
free = true;
Thread.Sleep(200);
drinksOrder.CommCmd = DrCoffeeCommCmd.取消应用指令;
drinksOrder.DrinksCode = 0;
commProxy.SendData(DrCoffee.Packe(drinksOrder));
Thread.Sleep(200);
free = false;
}
catch (Exception ex)
{
MessageLog.GetInstance.Show($"BPASmartClient.DRCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]");
}
});

//咖博士咖啡机模式设置
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeeCommCmdEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack)
{

try
{
free = true;
Thread.Sleep(200);
//drinksOrder.CommCmd = (DrCoffeeCommCmd)int.Parse(e.obj_MessageObj.ToString());
commProxy.SendData(DrCoffee.Packe(drinksOrder));
Thread.Sleep(200);
free = false;
}
catch (Exception ex)
{
MessageLog.GetInstance.Show($"BPASmartClient.DRCoffee 中引发错误,CoffeeCommCmdHandler 类,描述:[{ex.Message}]");
}
});
}
}


+ 0
- 120
BPASmartClient.DRCoffee/CommandHandler.cs Dosyayı Görüntüle

@@ -1,120 +0,0 @@

using BPASmartClient.DRCoffee;
using BPASmartClient.Message;
using BPASmartClient.MessageCommunication;
using BPASmartClient.MessageCommunication.MsgControl;
using BPASmartClient.SerialPort;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace BPASmartClient.DRCoffee
{
/// <summary>
/// 指令封装
/// </summary>
internal class CommandHandler
{
byte[] cmdAsk;
private SerialPortClient commProxy;
private DrCoffeePackage drinksOrder = new DrCoffeePackage();
public Action<bool> PauseAsk { get; set; }

/// <summary>
/// 初始化
/// </summary>
internal void Init(SerialPortClient commProxy)
{
//DoCoffee
this.commProxy = commProxy;
DrCoffeePackage package = new DrCoffeePackage();
package.CommCmd = DrCoffeeCommCmd.饮品制作指令;
cmdAsk = DrCoffee.Packe(package);
drinksOrder.CommCmd = DrCoffeeCommCmd.饮品制作指令;
Class_InnerMessageBus.GetInstance().ListenMessage(this, Class_MessageName.DRCoffee_MakeCoffee, "MakeCoffeeHandler");
Class_InnerMessageBus.GetInstance().ListenMessage(this, Class_MessageName.DRCoffee_CancelMakeCoffee, "CancelMakeCoffeeHandler");
Class_InnerMessageBus.GetInstance().ListenMessage(this, Class_MessageName.DRCoffee_CoffeeCommCmd, "CoffeeCommCmdHandler");
}

/// <summary>
/// 制作咖啡
/// </summary>
public void MakeCoffeeHandler(object sender, InnerMessageEventArgs e)
{
try
{
if (e.obj_MessageObj is string)
{
PauseAsk?.Invoke(true);
Thread.Sleep(200);
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;
}
}
}

+ 8
- 1
BPASmartClient.SCChip/ICChipMachine.cs Dosyayı Görüntüle

@@ -22,7 +22,14 @@ namespace BPASmartClient.SCChip
public Action<string> SendCallback;
public Action<string> ReciveCallback;


/// <summary>
/// 串口COM口
/// </summary>
public string PortName { get; set; }
/// <summary>
/// 串口波特率
/// </summary>
public string BaudRate { get; set; }

public ICChipMachine()
{


Yükleniyor…
İptal
Kaydet