Browse Source

冲突解决

master
pry 2 years ago
parent
commit
d370350e30
8 changed files with 975 additions and 26 deletions
  1. +1
    -0
      HBLConsole.Debug/Debug_MORKJC.xaml
  2. +63
    -12
      HBLConsole.Debug/Debug_MORKJC.xaml.cs
  3. +11
    -11
      HBLConsole.MORKJC/Control_MORKJC.cs
  4. +721
    -0
      HBLConsole.MORKJC2/Control_MORKJC.cs
  5. +16
    -0
      HBLConsole.MORKJC2/HBLConsole.MORKJC2.csproj
  6. +153
    -0
      HBLConsole.MORKJC2/PolymerBatching.cs
  7. +8
    -1
      HBLConsole.sln
  8. +2
    -2
      HBLConsole/App.config

+ 1
- 0
HBLConsole.Debug/Debug_MORKJC.xaml View File

@@ -20,6 +20,7 @@
<TextBox HorizontalAlignment="Left" Margin="90,292,0,0" TextWrapping="Wrap" IsEnabled="false" Text="{Binding Path=failureCnt}" VerticalAlignment="Top" Width="68"/>
<Label Content="成功次数" HorizontalAlignment="Left" Margin="27,262,0,0" VerticalAlignment="Top" Name="success" />
<Label Content="失败次数" HorizontalAlignment="Left" Margin="27,288,0,0" VerticalAlignment="Top" Name="fail" />
<Button Click="Btn_Test_Click" Content="测试" Margin="590,244,73,145" Background="White" />
</Grid>




+ 63
- 12
HBLConsole.Debug/Debug_MORKJC.xaml.cs View File

@@ -269,19 +269,19 @@ namespace HBLConsole.Debug
Thread.Sleep(3000);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接茶_接水);
Wait(int.Parse(JaKaHelper.SENCE_接茶_接水));
MCUSerialHelper.GetInstance.OutputControl(4, false);
MCUSerialHelper.GetInstance.OutputControl(3, false);
MCUSerialHelper.GetInstance.OutputControl(2, false);
Thread.Sleep(100);
MCUSerialHelper.GetInstance.OutputControl(2, true);
MCUSerialHelper.GetInstance.OutputControl(3, true);
Thread.Sleep(3000);
MCUSerialHelper.GetInstance.OutputControl(2, false);
MCUSerialHelper.GetInstance.OutputControl(3, false);
Thread.Sleep(100);

MCUSerialHelper.GetInstance.OutputControl(3, false);
MCUSerialHelper.GetInstance.OutputControl(4, false);
Thread.Sleep(100);
MCUSerialHelper.GetInstance.OutputControl(3, true);
MCUSerialHelper.GetInstance.OutputControl(4, true);
Thread.Sleep(500);
MCUSerialHelper.GetInstance.OutputControl(3, false);
MCUSerialHelper.GetInstance.OutputControl(4, false);

Thread.Sleep(60000);

@@ -311,19 +311,19 @@ namespace HBLConsole.Debug
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接水);
Wait(int.Parse(JaKaHelper.SENCE_接水));
MCUSerialHelper.GetInstance.OutputControl(4, false);
MCUSerialHelper.GetInstance.OutputControl(3, false);
MCUSerialHelper.GetInstance.OutputControl(2, false);
Thread.Sleep(100);
MCUSerialHelper.GetInstance.OutputControl(2, true);
MCUSerialHelper.GetInstance.OutputControl(3, true);
Thread.Sleep(3000);
MCUSerialHelper.GetInstance.OutputControl(2, false);
MCUSerialHelper.GetInstance.OutputControl(3, false);
Thread.Sleep(100);

MCUSerialHelper.GetInstance.OutputControl(3, false);
MCUSerialHelper.GetInstance.OutputControl(4, false);
Thread.Sleep(100);
MCUSerialHelper.GetInstance.OutputControl(3, true);
MCUSerialHelper.GetInstance.OutputControl(4, true);
Thread.Sleep(500);
MCUSerialHelper.GetInstance.OutputControl(3, false);
MCUSerialHelper.GetInstance.OutputControl(4, false);

Thread.Sleep(60000);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放茶水杯);
@@ -486,5 +486,56 @@ namespace HBLConsole.Debug
}
return 1;
}

private void Btn_Test_Click(object sender, RoutedEventArgs e)
{
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(1);
Thread.Sleep(1000);
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(2);
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(1);
Thread.Sleep(1000);
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(2);
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(1);
Thread.Sleep(1000);
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(2);
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(1);
Thread.Sleep(1000);
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(2);
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(1);
Thread.Sleep(1000);
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(2);
/*
MCUSerialHelper.GetInstance.OutputControl(1, true);
Thread.Sleep(1000);
MCUSerialHelper.GetInstance.OutputControl(1, false);

MCUSerialHelper.GetInstance.OutputControl(2, true);
Thread.Sleep(1000);
MCUSerialHelper.GetInstance.OutputControl(2, false);

MCUSerialHelper.GetInstance.OutputControl(4, false);
MCUSerialHelper.GetInstance.OutputControl(3, false);
Thread.Sleep(100);
MCUSerialHelper.GetInstance.OutputControl(3, true);
Thread.Sleep(3000);
MCUSerialHelper.GetInstance.OutputControl(3, false);
Thread.Sleep(100);

MCUSerialHelper.GetInstance.OutputControl(4, false);
Thread.Sleep(100);
MCUSerialHelper.GetInstance.OutputControl(4, true);
Thread.Sleep(500);
MCUSerialHelper.GetInstance.OutputControl(4, false);*/

MCUSerialHelper.GetInstance.ServoControl(1, 105);
Thread.Sleep(1000);
MCUSerialHelper.GetInstance.ServoControl(1, 130);
Thread.Sleep(1000);
MCUSerialHelper.GetInstance.ServoControl(1, 105);

JuicerHelper.GetInstance.StartCook(1);
new MakeCoffeeEvent() { DrinkCode = DrCoffeeDrinksCode.热水 }.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水

}
}
}

+ 11
- 11
HBLConsole.MORKJC/Control_MORKJC.cs View File

@@ -282,20 +282,20 @@ namespace HBLConsole.MORKJC
Thread.Sleep(3000);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接茶_接水);
Wait(int.Parse(JaKaHelper.SENCE_接茶_接水));
MCUSerialHelper.GetInstance.OutputControl(3, false);
MCUSerialHelper.GetInstance.OutputControl(4, false);

MCUSerialHelper.GetInstance.OutputControl(2, false);
MCUSerialHelper.GetInstance.OutputControl(3, false);
Thread.Sleep(100);
MCUSerialHelper.GetInstance.OutputControl(2, true);
MCUSerialHelper.GetInstance.OutputControl(3, true);
Thread.Sleep(3000);
MCUSerialHelper.GetInstance.OutputControl(2, false);
MCUSerialHelper.GetInstance.OutputControl(3, false);
Thread.Sleep(100);

MCUSerialHelper.GetInstance.OutputControl(3, false);
MCUSerialHelper.GetInstance.OutputControl(4, false);
Thread.Sleep(100);
MCUSerialHelper.GetInstance.OutputControl(3, true);
MCUSerialHelper.GetInstance.OutputControl(4, true);
Thread.Sleep(500);
MCUSerialHelper.GetInstance.OutputControl(3, false);
MCUSerialHelper.GetInstance.OutputControl(4, false);

Thread.Sleep(60000);

@@ -334,13 +334,13 @@ namespace HBLConsole.MORKJC
Wait(int.Parse(JaKaHelper.SENCE_接水));
are.WaitOne(1000 * 180);

MCUSerialHelper.GetInstance.OutputControl(2, true);
Thread.Sleep(1000);
MCUSerialHelper.GetInstance.OutputControl(2, false);
Thread.Sleep(10000);
MCUSerialHelper.GetInstance.OutputControl(3, true);
Thread.Sleep(1000);
MCUSerialHelper.GetInstance.OutputControl(3, false);
Thread.Sleep(10000);
MCUSerialHelper.GetInstance.OutputControl(4, true);
Thread.Sleep(1000);
MCUSerialHelper.GetInstance.OutputControl(4, false);
Thread.Sleep(3000);
//添加控制接水机构程序



+ 721
- 0
HBLConsole.MORKJC2/Control_MORKJC.cs View File

@@ -0,0 +1,721 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Threading;
using BPA.Message;
using HBLConsole.Communication;
using HBLConsole.Factory;
using HBLConsole.GVL;
using HBLConsole.Interface;
using HBLConsole.Model;
using HBLConsole.Service;
using HBLDevice.Coffee;
using Robotc;
using System.Collections.Concurrent;
using System.Diagnostics;
using BPA.Message.IOT;
using System.Threading.Tasks;

namespace HBLConsole.MORKJC
{
/*
* 冰淇淋咖啡机组合套装
* 物料位置:
* 1:冰淇料
* 2:冰淇淋杯
* 5:咖啡
* 6:咖啡杯
* 9: 茶
* 10: 茶杯
*/
public class Control_MORKJC : IControl
{
//咖啡机主控程序
private CoffeeMachine coffeeMachine;
//物料存放位置
private Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>();
//容器位置
private string holderLoc;
//主料位置
private string mainMaterialLoc;
//子订单ID
private string subOrderId;

private bool enableFunny = false;
private DateTime lastRecvdOrder = DateTime.Now;
private bool working = false;
/// <summary>
/// 果汁机做法,true:热饮,false:冷饮
/// </summary>
private bool GuMake = false;

private SerialPortClient commProxy;
public void ConnectOk()
{

}
ConcurrentQueue<MorkOrderPush> morkOrderPushes = new ConcurrentQueue<MorkOrderPush>();
public void Init()
{
ActionManage.GetInstance.Register(new Action<object>((s) =>
{
if (s is DrCoffeeDrinksCode cf)
{
DoCoffee();
}
else if (s is Dictionary<string, string> ms)
{
if (ms.ContainsKey("Button"))
{
switch (ms["Button"])
{
case "启动示教":
LebaiHelper.GetInstance.StartTeachMode();
break;
case "停止示教":
LebaiHelper.GetInstance.EndtTeachMode();
break;
case "启动机器人":
LebaiHelper.GetInstance.StartRobot();
break;
case "急停":
LebaiHelper.GetInstance.EStopRobot();
break;
default:
break;
}
}
}
}), "SimCoffee");

//构建所有商品物料信息
batchings = PolymerBatching.BuildAll();

EventBus.GetInstance().Subscribe<CoffeEndCook>(CoffeEndCookHandle);

System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
//一系列外围基础配置
var com_Coffee = config.AppSettings.Settings["COM_Coffee"].Value;
var baud_Coffee = config.AppSettings.Settings["BAUD_Coffee"].Value;
//咖啡机创建
coffeeMachine = new CoffeeMachine(com_Coffee, (BaudRates)Enum.Parse(typeof(BaudRates), baud_Coffee));

Main();
ReadData();
ThreadManage.GetInstance.StartLong(new Action(() =>
{
while (GeneralConfig.Healthy && (morkOrderPushes.Count > 0))
{
/*while (enableFunny) { Thread.Sleep(10); }
MessageLog.GetInstance.Show("当前非自嗨模式,允许开工");*/
working = true;
if (morkOrderPushes.TryDequeue(out MorkOrderPush order))
{
MessageLog.GetInstance.Show($"开始制作订单[{order.SortNum}]");

//Thread.Sleep(5000);
//SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK);

//商品类型
GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER;
//子订单ID
subOrderId = order.SuborderId;
//遍历物料
foreach (var item in order.GoodBatchings)
{
var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery.BatchingInfo.FirstOrDefault(p => p.BatchingId == item.BatchingId);
if (res != null)
{
//获取主料和容器位置
switch (batchings[res.BatchingLoc].BatchingClass)
{
case BATCHING_CLASS.HOLDER:
holderLoc = res.BatchingLoc;
break;
case BATCHING_CLASS.MAIN_MATERIAL:
// mainMaterialLoc ="1";
mainMaterialLoc = res.BatchingLoc;
//验证商品是咖啡还是冰淇淋
if (ValidateGoodsByBatching(res.BatchingLoc) != GOODS_TYPE.NEITHER)
{
//获取当前物料所属商品类型
currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc);
}
break;
}
}
}

//根据商品类型执行具体制作流程
switch (currentGoodsType)
{
case GOODS_TYPE.COFFEE:
DoCoffee();
break;
case GOODS_TYPE.JUICE:
GuMake = order.MakeID == "2";
DoJuicer();
break;
case GOODS_TYPE.TEA:
DoTea();
break;
case GOODS_TYPE.WATER:
DoWater();
break;
case GOODS_TYPE.NEITHER:
MessageLog.GetInstance.Show("未知的商品类型");
break;
}
}
working = false;
lastRecvdOrder = DateTime.Now;
}
Thread.Sleep(1000);
}), "订单制作");
}

public void Main()
{
//咖啡机开启主线程
coffeeMachine.Start();
//开始心跳刷新,根据咖啡机及冰淇淋机来判断
ThreadManage.GetInstance.StartLong(new Action(() =>
{
GeneralConfig.Healthy =
LebaiHelper.GetInstance.IsConnected &&
MorkCStatus.GetInstance().CanDo &&
JuicerHelper.GetInstance.IsOpen &&
MCUSerialHelper.GetInstance.IsOpen;
//GeneralConfig.Healthy = true;
Thread.Sleep(100);
}), "MORK-IC心跳刷新");
ThreadManage.GetInstance.Start(new Action(() =>
{
while (!LebaiHelper.GetInstance.IsConnected)
{
Thread.Sleep(10);
}
//LebaiHelper.GetInstance.Scene(LebaiHelper.SENCE_欢迎);
}), "MORK-JC欢迎");
}

public void DataParse<T>(T order)
{
if (order is MorkOrderPush morkOrderPush)
{
morkOrderPushes.Enqueue(morkOrderPush);
}
}

/// <summary>
/// 验证当前是做咖啡还是做冰淇淋
/// </summary>
/// <param name="batchingLoc">物料位置</param>
private GOODS_TYPE ValidateGoodsByBatching(string batchingLoc)
{
if (batchings.ContainsKey(batchingLoc))
return batchings[batchingLoc].GoodsType;
return GOODS_TYPE.NEITHER;
}

private AutoResetEvent are = new AutoResetEvent(false);

private void Wait(int value)
{
while (!((JaKaHelper.GetInstance.Get_RobotAO1() == value) && JaKaHelper.GetInstance.GetProgramStatus() == 0))//判断文件是否已经执行结束 且 文件末端变量值==文件名
{
Thread.Sleep(5);
}
}
int[] devStatusBy = new int[2] { 0, 0 };

/// <summary>
/// 传感器的输入信号 0:无意义 1:有信号 2:无信号 3:信号不正确
/// </summary>
int bSensorInput;
/// <summary>
/// 延迟的超时时间
/// </summary>
DateTime delayTimeOut;
/// <summary>
/// 做咖啡
/// </summary>
private void DoCoffee()
{
#region 接咖啡流程
are.Reset();
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{
MessageLog.GetInstance.Show("咖啡杯取杯完成");
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接咖啡);
Wait(int.Parse(JaKaHelper.SENCE_接咖啡));
new MakeCoffeeEvent() { DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水
are.WaitOne(1000 * 120);

JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放咖啡杯);
Wait(int.Parse(JaKaHelper.SENCE_放咖啡杯));
int resultputCup = putCup();
if (resultputCup == 1)
{
//订单状态改变:完成
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
}
else
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
}
}
else if (resultTakeCup == 2 || resultTakeCup == 3)
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
}
#endregion
}
/// <summary>
/// 做茶
/// </summary>
private void DoTea()
{
#region 接茶流程
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{
MessageLog.GetInstance.Show("取茶杯完成");
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接茶);
Wait(int.Parse(JaKaHelper.SENCE_接茶));

MCUSerialHelper.GetInstance.ServoControl(1, 105);
Thread.Sleep(1000);
MCUSerialHelper.GetInstance.ServoControl(1, 130);
Thread.Sleep(1000);
MCUSerialHelper.GetInstance.ServoControl(1, 105);

Thread.Sleep(3000);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接茶_接水);
Wait(int.Parse(JaKaHelper.SENCE_接茶_接水));
MCUSerialHelper.GetInstance.OutputControl(4, false);

MCUSerialHelper.GetInstance.OutputControl(3, false);
Thread.Sleep(100);
MCUSerialHelper.GetInstance.OutputControl(3, true);
Thread.Sleep(3000);
MCUSerialHelper.GetInstance.OutputControl(3, false);
Thread.Sleep(100);

MCUSerialHelper.GetInstance.OutputControl(4, false);
Thread.Sleep(100);
MCUSerialHelper.GetInstance.OutputControl(4, true);
Thread.Sleep(500);
MCUSerialHelper.GetInstance.OutputControl(4, false);

Thread.Sleep(60000);

JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放茶水杯);
Wait(int.Parse(JaKaHelper.SENCE_放茶水杯));
int resultputCup = putCup();
if (resultputCup == 1)
{
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
}
else
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
}
}
else if (resultTakeCup == 2 || resultTakeCup == 3)
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
}
#endregion
}

/// <summary>
/// 接开水
/// </summary>
private void DoWater()
{
#region 接水流程
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接水);
Wait(int.Parse(JaKaHelper.SENCE_接水));
are.WaitOne(1000 * 180);

MCUSerialHelper.GetInstance.OutputControl(3, true);
Thread.Sleep(1000);
MCUSerialHelper.GetInstance.OutputControl(3, false);
Thread.Sleep(10000);
MCUSerialHelper.GetInstance.OutputControl(4, true);
Thread.Sleep(1000);
MCUSerialHelper.GetInstance.OutputControl(4, false);
Thread.Sleep(3000);
//添加控制接水机构程序

JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放茶水杯);
Wait(int.Parse(JaKaHelper.SENCE_放茶水杯));
int resultputCup = putCup();
if (resultputCup == 1)
{
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
}
else
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
}
}
else if (resultTakeCup == 2 || resultTakeCup == 3)
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
}
#endregion
}
/// <summary>
/// 果汁机控制信号
/// </summary>
private byte JuicerNum;
/// <summary>
/// 做果汁
/// </summary>
private void DoJuicer()
{
#region 接果汁流程
are.Reset();
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{
int JuicerNum1 = int.Parse(mainMaterialLoc);
switch (JuicerNum1)
{
case 52:
if(GuMake)
{
JuicerNum = 0x00;
}
else
{
JuicerNum = 0x01;
}
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁1);
Wait(int.Parse(JaKaHelper.SENCE_接果汁1));
break;
case 53:
if (GuMake)
{
JuicerNum = 0x02;
}
else
{
JuicerNum = 0x03;
}
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁2);
Wait(int.Parse(JaKaHelper.SENCE_接果汁2));
break;
case 54:
if (GuMake)
{
JuicerNum = 0x04;
}
else
{
JuicerNum = 0x05;
}
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁3);
Wait(int.Parse(JaKaHelper.SENCE_接果汁3));
break;
case 55:
if (GuMake)
{
JuicerNum = 0x06;
}
else
{
JuicerNum = 0x07;
}
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁4);
Wait(int.Parse(JaKaHelper.SENCE_接果汁4));
break;
default:
JuicerNum = 0x00;
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁1);
Wait(int.Parse(JaKaHelper.SENCE_接果汁1));
break;
}
var devStatus = JuicerHelper.GetInstance.GetDeviceStatus();
var devStatus1 = Convert.ToString(devStatus[0], 2);
var devStatus2 = devStatus[1];

if (devStatus1.IndexOf("0") == 1 && devStatus2 == 0)
{
JuicerHelper.GetInstance.StartCook(JuicerNum);
Thread.Sleep(100);
devStatusBy = JuicerHelper.GetInstance.GetDeviceStatus();
while (!(devStatusBy[1] == 0))
{
Thread.Sleep(100);
devStatusBy = JuicerHelper.GetInstance.GetDeviceStatus();
while (devStatusBy.Length != 2)
{
Thread.Sleep(100);
devStatusBy = JuicerHelper.GetInstance.GetDeviceStatus();
}
}
devStatusBy = JuicerHelper.GetInstance.GetDeviceStatus();
Thread.Sleep(5000);
switch (JuicerNum1)
{
case 52:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯1);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯1));
break;
case 53:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯2);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯2));
break;
case 54:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯3);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯3));
break;
case 55:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯4);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯4));
break;
default:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯1);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯1));
break;
}
int resultputCup = putCup();
if (resultputCup == 1)
{
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
}
else
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
}
}
}
else if (resultTakeCup == 2 || resultTakeCup == 3)
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
}
#endregion
}
/// <summary>
/// 取杯流程
/// </summary>
/// <returns>0:无意义,1:取杯成功 2:机构有杯子,但夹爪未取到杯子 3:机构没有杯子</returns>
private int takeCup()
{
try
{
/* int resultCheck = checkCup();
if (resultCheck != 1) return 2;*/
JaKaHelper.GetInstance.Set_RobotAO1(0);
Wait(0);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
MCUSerialHelper.GetInstance.OutputControl(1, true);
JaKaHelper.GetInstance.Set_RobotAO1(0);
Wait(0);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯);
Wait(int.Parse(JaKaHelper.SENCE_取杯));
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(1);
while (bSensorInput == 3 || bSensorInput == 2)
{
Thread.Sleep(100);
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(1);
if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 2)
{
MessageLog.GetInstance.Show("取杯机构,没有杯子");
break;
}
}
if (bSensorInput == 1)
{
MCUSerialHelper.GetInstance.OutputControl(1, false);
Thread.Sleep(500);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测);
Wait(int.Parse(JaKaHelper.SENCE_取杯检测));
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(1);
delayTimeOut = DateTime.Now;
while (bSensorInput == 3 || bSensorInput == 2)
{
Thread.Sleep(100);
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(1);
if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 2)
{
MessageLog.GetInstance.Show("取杯子失败");
return 2;
}
}
return bSensorInput;
}
else
{
MCUSerialHelper.GetInstance.OutputControl(1, false);
Thread.Sleep(500);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测);
Wait(int.Parse(JaKaHelper.SENCE_取杯检测));
return 3;
}
}
catch (Exception ex)
{
MessageLog.GetInstance.Show(ex.ToString());
return 0;
}
}
/// <summary>
/// 放杯
/// </summary>
/// <returns>0:无意义 1:执行成功 2:执行失败(传感器还有信号)</returns>
private int putCup()
{
try
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯);
Wait(int.Parse(JaKaHelper.SENCE_放杯));
MCUSerialHelper.GetInstance.OutputControl(1, true);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测);
Wait(int.Parse(JaKaHelper.SENCE_放杯检测));
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(1);
delayTimeOut = DateTime.Now;
while (bSensorInput != 2)
{
Thread.Sleep(100);
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(1);
if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 2) return 2;
}
if (bSensorInput == 2)
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
return 1;
}
}
catch (Exception ex)
{
MessageLog.GetInstance.Show(ex.ToString());
return 0;
}
return 1;
}

/// <summary>
/// 检测放杯位,是否有杯子
/// </summary>
/// <returns>0:无意义 1:没有杯子 2:有杯子 </returns>
private int checkCup()
{
try
{/*
JaKaHelper.GetInstance.Set_RobotAO1(0);
Wait(0);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
MCUSerialHelper.GetInstance.OutputControl(1, true);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯位检测);
Wait(int.Parse(JaKaHelper.SENCE_放杯位检测));*/
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(2);
delayTimeOut = DateTime.Now;
while (bSensorInput == 1)
{
Thread.Sleep(100);
bSensorInput = MCUSerialHelper.GetInstance.GetInputStatus(1);
MessageLog.GetInstance.Show("放杯位有杯子未取走,等待取走,最多等待60s,即跳出流程");
if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 1) return 2;
}
return 1;
}
catch (Exception ex)
{
MessageLog.GetInstance.Show(ex.ToString());
return 0;
}
}

private void CoffeEndCookHandle(IEvent @event, EventBus.EventCallBackHandle callBack)
{
are.Set();
}


public void ReadData()
{
//ThreadManage.GetInstance.StartLong(new Action(() =>
//{

// Thread.Sleep(100);
//}), "机器人数据读取", true);
}

public void SimOrder<T>(T simOrder)
{

}



/// <summary>
/// IOT 广播消息命令
/// </summary>
public void IotBroadcast<T>(T broadcast)
{
if (broadcast != null && broadcast is IOTCommandModel iOTCommand)
{
switch (iOTCommand.CommandName)
{
case 0://控制类
if (iOTCommand.CommandValue != null)
{
if (iOTCommand.CommandValue.ContainsKey("SimOrder"))
{
//SimOrder(new SimOrderData { NoodleLoc = 1, BowlLoc = 10 });
}
}
break;
case 1://设置属性

break;
case 2://通知消息

break;
default:
break;
}
}
}
public class SimOrderData
{
public string id { get; set; }

public int OrderStatus { get; set; }

public string Loc { get; set; }

public MorkOrderPush morkOrder { get; set; }

public SimOrderData()
{
id = Guid.NewGuid().ToString();
OrderStatus = 0;
}
}
}
}

+ 16
- 0
HBLConsole.MORKJC2/HBLConsole.MORKJC2.csproj View File

@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\HBLConsole.Factory\HBLConsole.Factory.csproj" />
<ProjectReference Include="..\HBLConsole.Model\HBLConsole.Model.csproj" />
<ProjectReference Include="..\HBLConsole.Service\HBLConsole.Service.csproj" />
<ProjectReference Include="..\HBLDevice.Coffee\HBLDevice.Coffee.csproj" />
</ItemGroup>

</Project>

+ 153
- 0
HBLConsole.MORKJC2/PolymerBatching.cs View File

@@ -0,0 +1,153 @@
using HBLConsole.Communication;
//using HBLDevice.ICChip;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HBLConsole.MORKJC
{
internal enum GOODS_TYPE
{
/// <summary>
/// 未知
/// </summary>
NEITHER,
/// <summary>
/// 咖啡
/// </summary>
COFFEE,
/// <summary>
/// 果汁
/// </summary>
JUICE,
/// <summary>
/// 茶水
/// </summary>
TEA,
/// <summary>
/// 水
/// </summary>
WATER,
/// <summary>
/// 杯子
/// </summary>
CUP
}

internal enum BATCHING_CLASS
{
HOLDER,
MAIN_MATERIAL,
}

internal class PolymerBatching
{
internal const string Juicer_MAIN_BATCHIN1_LOC = "52";
internal const string Juicer_MAIN_BATCHIN2_LOC = "53";
internal const string Juicer_MAIN_BATCHIN3_LOC = "54";
internal const string Juicer_MAIN_BATCHIN4_LOC = "55";
//internal const string Juicer_MAIN_BATCHIN5_LOC = "56";
//internal const string Juicer_MAIN_BATCHIN6_LOC = "57";
//internal const string Juicer_MAIN_BATCHIN7_LOC = "58";
//internal const string Juicer_MAIN_BATCHIN8_LOC = "59";

internal const string COFFEE_HOLDER_LOC = "30";
internal const string TEA_HOLDER_LOC = "51";
public static Dictionary<string, GOODS_TYPE> GOODS_TYPES = new Dictionary<string, GOODS_TYPE>() {
{"1", GOODS_TYPE.COFFEE},
{"2", GOODS_TYPE.COFFEE},
{"3", GOODS_TYPE.COFFEE},
{"4", GOODS_TYPE.COFFEE},
{"5", GOODS_TYPE.COFFEE},
{"6", GOODS_TYPE.COFFEE},
{"7", GOODS_TYPE.COFFEE},
{"8", GOODS_TYPE.COFFEE},
{"9", GOODS_TYPE.COFFEE},
{"10",GOODS_TYPE.COFFEE},
{"11",GOODS_TYPE.COFFEE},
{"12",GOODS_TYPE.COFFEE},
{"13",GOODS_TYPE.COFFEE},
{"14",GOODS_TYPE.COFFEE},
{"15",GOODS_TYPE.COFFEE},
{"16",GOODS_TYPE.COFFEE},
{"17",GOODS_TYPE.COFFEE},
{"18",GOODS_TYPE.COFFEE},
{"19",GOODS_TYPE.COFFEE},
{"20",GOODS_TYPE.COFFEE},
{"21",GOODS_TYPE.COFFEE},
{"22",GOODS_TYPE.COFFEE},
{"23",GOODS_TYPE.COFFEE},
{"24",GOODS_TYPE.COFFEE},
{"25",GOODS_TYPE.COFFEE},
{ COFFEE_HOLDER_LOC,GOODS_TYPE.CUP},
{"56",GOODS_TYPE.TEA },
{Juicer_MAIN_BATCHIN1_LOC,GOODS_TYPE.JUICE},
{Juicer_MAIN_BATCHIN2_LOC,GOODS_TYPE.JUICE},
{Juicer_MAIN_BATCHIN3_LOC,GOODS_TYPE.JUICE},
{Juicer_MAIN_BATCHIN4_LOC,GOODS_TYPE.JUICE},
//{Juicer_MAIN_BATCHIN5_LOC,GOODS_TYPE.JUICE},
//{Juicer_MAIN_BATCHIN6_LOC,GOODS_TYPE.JUICE},
//{Juicer_MAIN_BATCHIN7_LOC,GOODS_TYPE.JUICE},
//{Juicer_MAIN_BATCHIN8_LOC,GOODS_TYPE.JUICE},
};

public GOODS_TYPE GoodsType { get; set; }
public BATCHING_CLASS BatchingClass { get; set; }
private string loc;

public string Loc
{
get { return loc; }
set
{
loc = value;
if (GOODS_TYPES.ContainsKey(loc))
GoodsType = GOODS_TYPES[loc];
switch (loc)
{
case COFFEE_HOLDER_LOC:
case TEA_HOLDER_LOC:
BatchingClass = BATCHING_CLASS.HOLDER;
break;
default:
BatchingClass = BATCHING_CLASS.MAIN_MATERIAL;
break;
}
}
}

internal static Dictionary<string, PolymerBatching> BuildAll()
{
Dictionary<string, PolymerBatching> temp = new Dictionary<string, PolymerBatching>();
foreach (var item in GOODS_TYPES)
{
temp.Add(item.Key, new PolymerBatching() { Loc = item.Key });
}
return temp;
}

//internal static IC_SE GetIceCreamSE(string loc, out string sence)
//{
// switch (loc)
// {
// case Juicer_MAIN_BATCHIN1_LOC:
// sence = JaKaHelper.SENCE_接果汁1;
// return IC_SE.SE_1;

// case Juicer_MAIN_BATCHIN2_LOC:
// sence = JaKaHelper.SENCE_接果汁2;
// return IC_SE.SE_2;

// case Juicer_MAIN_BATCHIN3_LOC:
// sence = JaKaHelper.SENCE_接果汁3;
// return IC_SE.SE_3;

// default:
// sence = JaKaHelper.SENCE_接果汁1;
// return IC_SE.SE_1;
// }
//}
}
}

+ 8
- 1
HBLConsole.sln View File

@@ -49,7 +49,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HBLConsole.MORKM", "HBLCons
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Devices", "Devices", "{D6D3D62A-F72B-4940-8579-B2DBF35D3059}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HBLConsole.MORKJC", "HBLConsole.MORKJC\HBLConsole.MORKJC.csproj", "{07DB7E09-6899-4B9F-8BA3-72D5D93E8881}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HBLConsole.MORKJC", "HBLConsole.MORKJC\HBLConsole.MORKJC.csproj", "{07DB7E09-6899-4B9F-8BA3-72D5D93E8881}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HBLConsole.MORKJC2", "HBLConsole.MORKJC2\HBLConsole.MORKJC2.csproj", "{28F93257-7F44-4B96-B0C7-EFC6EDAD89F9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -145,6 +147,10 @@ Global
{07DB7E09-6899-4B9F-8BA3-72D5D93E8881}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07DB7E09-6899-4B9F-8BA3-72D5D93E8881}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07DB7E09-6899-4B9F-8BA3-72D5D93E8881}.Release|Any CPU.Build.0 = Release|Any CPU
{28F93257-7F44-4B96-B0C7-EFC6EDAD89F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28F93257-7F44-4B96-B0C7-EFC6EDAD89F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28F93257-7F44-4B96-B0C7-EFC6EDAD89F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28F93257-7F44-4B96-B0C7-EFC6EDAD89F9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -158,6 +164,7 @@ Global
{4A451647-FB80-4D19-85CF-C04A9548A17E} = {CFF94828-163A-4907-B951-081B18F3CBBD}
{77F458A8-2550-490C-9DEF-CE220663E6FE} = {D6D3D62A-F72B-4940-8579-B2DBF35D3059}
{07DB7E09-6899-4B9F-8BA3-72D5D93E8881} = {D6D3D62A-F72B-4940-8579-B2DBF35D3059}
{28F93257-7F44-4B96-B0C7-EFC6EDAD89F9} = {D6D3D62A-F72B-4940-8579-B2DBF35D3059}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1968105D-1913-4F0B-A03E-7C18AFA58912}


+ 2
- 2
HBLConsole/App.config View File

@@ -14,7 +14,7 @@
<!--<add key="ClientId" value="11"/>
<add key="deviceId" value="13"/>-->

<add key="ClientId" value="49"/>
<add key="ClientId" value="50"/>
<add key="deviceId" value="31"/>

<!--<add key="ApolloUri" value="http://111.9.47.105:28080/"/>
@@ -43,7 +43,7 @@
<add key="IsEnableTest" value="false"/>

<!--http://111.9.47.105:21528/kitchen/-->
<add key="COM_Coffee" value="COM10"/>
<add key="COM_Coffee" value="COM5"/>
<add key="BAUD_Coffee" value="115200"/>

<add key="COM_IceCream" value="COM5"/>


Loading…
Cancel
Save