Browse Source

增加测距传感器

master
applelon 2 years ago
parent
commit
fd10d16013
6 changed files with 59 additions and 19 deletions
  1. +5
    -13
      HBLConsole.MORKIC/Control_MORKIC.cs
  2. +14
    -0
      HBLDevice.ICChip/ChipStatus.cs
  3. +10
    -0
      HBLDevice.ICChip/CommandEvent.cs
  4. +16
    -0
      HBLDevice.ICChip/CommandHandler.cs
  5. +1
    -1
      HBLDevice.ICChip/Protocal/ICChipPackage.cs
  6. +13
    -5
      HBLDevice.ICChip/Protocal/IC_CMD.cs

+ 5
- 13
HBLConsole.MORKIC/Control_MORKIC.cs View File

@@ -35,9 +35,8 @@ namespace HBLConsole.MORKIC
GVL_MORIC mORKD = new GVL_MORIC();
//咖啡机主控程序
private CoffeeMachine coffeeMachine;
//单片机主控程序
private ICChipMachine icchipMachine;
//冰淇淋主控程序
private IceCreamMachine iceCreamMachine;
//物料存放位置
private Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>();
//容器位置
@@ -98,8 +97,7 @@ namespace HBLConsole.MORKIC
}
//咖啡机创建
coffeeMachine = new CoffeeMachine(com_Coffee, (BaudRates)Enum.Parse(typeof(BaudRates), baud_Coffee));
//冰淇淋机创建
iceCreamMachine = new IceCreamMachine(com_IceCream, (BaudRates)Enum.Parse(typeof(BaudRates), baud_IceCream));
//单片机机创建
icchipMachine = new ICChipMachine(com_ICChip, (BaudRates)Enum.Parse(typeof(BaudRates), baud_ICChip));

Main();
@@ -171,23 +169,17 @@ namespace HBLConsole.MORKIC
{
//咖啡机开启主线程
coffeeMachine.Start();
//冰淇淋机开启主线程
iceCreamMachine.Start();
//单片机开启主线程
icchipMachine.Start();
new ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish();

//开始心跳刷新,根据咖啡机及冰淇淋机来判断
ThreadManage.GetInstance.StartLong(new Action(() =>
{

//GeneralConfig.Healthy = true;
//GeneralConfig.Healthy =
// LebaiHelper.GetInstance.IsConnected &&
// MorkIStatus.GetInstance().CanDo &&
// MorkCStatus.GetInstance().CanDo;
GeneralConfig.Healthy =
LebaiHelper.GetInstance.IsConnected &&
MorkCStatus.GetInstance().CanDo;
MorkCStatus.GetInstance().CanDo &&
ChipStatus.GetInstance().CanDo;
//GeneralConfig.Healthy = true;
Thread.Sleep(100);
}), "MORK-IC心跳刷新");


+ 14
- 0
HBLDevice.ICChip/ChipStatus.cs View File

@@ -47,6 +47,14 @@ namespace HBLDevice.ICChip
/// 3号舵机关闭完成
/// </summary>
public bool CompletedClose_SE_3 { get; set; }
/// <summary>
/// 是否存在物品
/// </summary>
public bool ArticleExits { get; set; }
/// <summary>
/// 物品距离
/// </summary>
public byte ArticleDist { get; set; }

public bool CanDo
{
@@ -105,6 +113,12 @@ namespace HBLDevice.ICChip
break;
}
break;
case IC_CMD.ARTICLE_EXITS:
ArticleExits = data.Value > 0;
break;
case IC_CMD.ARTICLE_DIST:
ArticleDist = data.Value;
break;
}
}
catch (Exception ex)


+ 10
- 0
HBLDevice.ICChip/CommandEvent.cs View File

@@ -30,4 +30,14 @@ namespace HBLDevice.ICChip
{
public bool TurnOn { get; set; }
}

public class ArticleExitsEvent : IEvent
{

}

public class ArticleDistEvent : IEvent
{

}
}

+ 16
- 0
HBLDevice.ICChip/CommandHandler.cs View File

@@ -30,10 +30,26 @@ namespace HBLDevice.ICChip
EventBus.GetInstance().Subscribe<MakeIceCreamEvent>(MakeIceCreamEventHandle);
EventBus.GetInstance().Subscribe<SESwitchCreamEvent>(StopMakeIceCreamEventHandle);
EventBus.GetInstance().Subscribe<RotorSwitchEvent>(RotorSwitchEventHandle);
EventBus.GetInstance().Subscribe<ArticleExitsEvent>(ArticleExitsEventHandle);
EventBus.GetInstance().Subscribe<ArticleDistEvent>(ArticleDistEventHandle);
}

private void ArticleDistEventHandle(IEvent @event, EventCallBackHandle callBack)
{
package.Cmd = IC_CMD.ARTICLE_DIST;
commProxy.SendData(StructureToByte(package));
}

private void ArticleExitsEventHandle(IEvent @event, EventCallBackHandle callBack)
{
ChipStatus.GetInstance().ArticleExits = false;
package.Cmd = IC_CMD.ARTICLE_EXITS;
commProxy.SendData(StructureToByte(package));
}

private void StopMakeIceCreamEventHandle(IEvent @event, EventCallBackHandle callBack)
{
ChipStatus.GetInstance().ArticleDist = 0;
package.Cmd = (@event as SESwitchCreamEvent).IsOpen ? IC_CMD.OPEN_SE : IC_CMD.CLOSE_SE;
package.Value = (byte)(@event as SESwitchCreamEvent).SteeringEngine;
commProxy.SendData(StructureToByte(package));


+ 1
- 1
HBLDevice.ICChip/Protocal/ICChipPackage.cs View File

@@ -26,7 +26,7 @@ namespace HBLDevice.ICChip
/// </summary>
public IC_CMD Cmd;
/// <summary>
/// 故障(咖啡机负责写,工控机负责读)
///
/// </summary>
public byte Value;
/// <summary>


+ 13
- 5
HBLDevice.ICChip/Protocal/IC_CMD.cs View File

@@ -9,20 +9,20 @@ namespace HBLDevice.ICChip
/// <summary>
/// 命令
/// </summary>
public enum IC_CMD:byte
public enum IC_CMD : byte
{
/// <summary>
/// 心跳
/// </summary>
HEART_BEAT=0x00,
HEART_BEAT = 0x00,
/// <summary>
/// 下杯(带上碗参数)
/// </summary>
TAKE_CUP=0x01,
TAKE_CUP = 0x01,
/// <summary>
/// 打开舵机(带上舵机参数)
/// </summary>
OPEN_SE=0x02,
OPEN_SE = 0x02,
/// <summary>
/// 关闭舵机(带上舵机参数)
/// </summary>
@@ -30,6 +30,14 @@ namespace HBLDevice.ICChip
/// <summary>
/// 使能冰淇淋转子(带上开关参数)
/// </summary>
ROTOR=0x04,
ROTOR = 0x04,
/// <summary>
/// 检测是否有物品
/// </summary>
ARTICLE_EXITS = 0x05,
/// <summary>
/// 检测物品距离
/// </summary>
ARTICLE_DIST = 0x06
}
}

Loading…
Cancel
Save