Browse Source

单流程优化

master
itachilee 2 years ago
parent
commit
18eb794c61
6 changed files with 314 additions and 181 deletions
  1. +0
    -1
      HBLConsole.Communication/ConnectHelper.cs
  2. +25
    -5
      HBLConsole.Communication/MCUSerialHelper.cs
  3. +179
    -97
      HBLConsole.Debug/Debug_MORKJC.xaml.cs
  4. +75
    -44
      HBLConsole.MORKJC/Control_MORKJC.cs
  5. +25
    -26
      HBLConsole.MainConsole/Main.cs
  6. +10
    -8
      HBLConsole/App.config

+ 0
- 1
HBLConsole.Communication/ConnectHelper.cs View File

@@ -8,7 +8,6 @@ using HBLConsole.Model;
using System.Threading;
using HBLConsole.GVL;


namespace HBLConsole.Communication
{
public class ConnectHelper


+ 25
- 5
HBLConsole.Communication/MCUSerialHelper.cs View File

@@ -81,10 +81,10 @@ namespace HBLConsole.Communication
/// 获取单片机输入端口状态
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public bool GetInputStatus(byte index)
/// <returns>0:无意义 1:有信号 2:无信号 3:信号不正确</returns>
public int GetInputStatus(byte index)
{
if (index <= 0 || index > 8) return false;
if (index <= 0 || index > 8) return 0;
byte[] buffers = new byte[6] { 0xCC, 0x01, 0x03, index, 0x00, 0xDD };
if (IsOpen)
{
@@ -107,11 +107,31 @@ namespace HBLConsole.Communication
if (Reindex < receive.Count && Reindex >= 0)
{
var res = receive.GetRange(Array.FindIndex(receive.ToArray(), p => p == 0xcc), 6);
return res != null && res.Count() == 6 && res.ElementAt(4) == 0x01;
if (res.ElementAt(2) == 0x03)
{
if (res != null && res.Count() == 6 && res.ElementAt(4) == 0x01)
{
return 1;
}
else if (res != null && res.Count() == 6 && res.ElementAt(4) == 0x00)
{
return 2;
}

}
else
{
return 3;
}

}
else
{
return 0;
}
}
}
return false;
return 0;
}
}
}

+ 179
- 97
HBLConsole.Debug/Debug_MORKJC.xaml.cs View File

@@ -15,6 +15,8 @@ using HBLConsole.Communication;
using System.Threading;
using HBLConsole.Model;
using HBLConsole.Service;
using HBLDevice.Coffee;
using BPA.Message;
namespace HBLConsole.Debug
{
/// <summary>
@@ -22,148 +24,221 @@ namespace HBLConsole.Debug
/// </summary>
public partial class Debug_MORKJC : UserControl
{
public Debug_MORKJC()
{
InitializeComponent();
}
DateTime dt;
private void Wait(int value)
{
dt = DateTime.Now;
while (!((JaKaHelper.GetInstance.Get_RobotAO1() == value) && JaKaHelper.GetInstance.GetProgramStatus() == 0))//判断文件是否已经执行结束 且 文件末端变量值==文件名
{
Thread.Sleep(5);
if (DateTime.Now.Subtract(dt).TotalSeconds >= 600) break;
}
}
private AutoResetEvent are = new AutoResetEvent(false);
private CoffeeMachine coffeeMachine1;

private void CoffeEndCookHandle(IEvent @event, EventBus.EventCallBackHandle callBack)
{
are.Set();
}
private void Btn_Coffee_Click(object sender, RoutedEventArgs e)
{
/*EventBus.GetInstance().Subscribe<CoffeEndCook>(CoffeEndCookHandle);
are.Reset();
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;
coffeeMachine1 = new CoffeeMachine(com_Coffee, (BaudRates)Enum.Parse(typeof(BaudRates), baud_Coffee));
coffeeMachine1.Start();*/

int a1=MCUSerialHelper.GetInstance.GetInputStatus(1);

JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
MCUSerialHelper.GetInstance.OutputControl(1, false);
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_取杯检测));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接咖啡);
Wait(int.Parse(JaKaHelper.SENCE_接咖啡));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放咖啡杯);
Wait(int.Parse(JaKaHelper.SENCE_放咖啡杯));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测);
Wait(int.Parse(JaKaHelper.SENCE_放杯检测));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
int a2 = MCUSerialHelper.GetInstance.GetInputStatus(1);
while (a2 == 3)
{
Thread.Sleep(100);
a2 = MCUSerialHelper.GetInstance.GetInputStatus(1);
}
if (a2==1)
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接咖啡);
Wait(int.Parse(JaKaHelper.SENCE_接咖啡));
new MakeCoffeeEvent() { DrinkCode = DrCoffeeDrinksCode.热水 }.Publish(); //接咖啡控制
are.WaitOne(1000 * 60);

JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放咖啡杯);
Wait(int.Parse(JaKaHelper.SENCE_放咖啡杯));
MCUSerialHelper.GetInstance.OutputControl(1, false);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测);
Wait(int.Parse(JaKaHelper.SENCE_放杯检测));
}
int a3 = MCUSerialHelper.GetInstance.GetInputStatus(1);
while (a3 == 1)
{
Thread.Sleep(100);
a3 = MCUSerialHelper.GetInstance.GetInputStatus(1);
}
if (a3 == 2)
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
}
}

int[] devStatusBy=new int[2] { 0,0};
private void Btn_Juicer_Click(object sender, RoutedEventArgs e)
{

JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
MCUSerialHelper.GetInstance.OutputControl(1, false);
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_取杯检测));
byte JuicerNum = byte.Parse(txtJuicerNum.Text.Trim().ToString());
int JuicerNum1 = int.Parse(txtJuicerNum.Text.Trim().ToString());
switch (JuicerNum1)
int a2 = MCUSerialHelper.GetInstance.GetInputStatus(1);
while (a2 == 3 || a2 == 2)
{
case 0:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁1);
Wait(int.Parse(JaKaHelper.SENCE_接果汁1));
break;
case 1:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁1);
Wait(int.Parse(JaKaHelper.SENCE_接果汁1));
break;
case 2:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁2);
Wait(int.Parse(JaKaHelper.SENCE_接果汁2));
break;
case 3:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁2);
Wait(int.Parse(JaKaHelper.SENCE_接果汁2));
break;
case 4:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁3);
Wait(int.Parse(JaKaHelper.SENCE_接果汁3));
break;
case 5:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁3);
Wait(int.Parse(JaKaHelper.SENCE_接果汁3));
break;
case 6:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁4);
Wait(int.Parse(JaKaHelper.SENCE_接果汁4));
break;
case 7:
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;
Thread.Sleep(100);
a2 = MCUSerialHelper.GetInstance.GetInputStatus(1);
}
var devStatus = JuicerHelper.GetInstance.GetDeviceStatus();
var devStatus1 = Convert.ToString(devStatus[0], 2);
var devStatus2 = devStatus[1];
if (devStatus1.IndexOf("0") == 1&& devStatus2==0)
if (a2 == 1)
{
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(1000);
byte JuicerNum = byte.Parse(txtJuicerNum.Text.Trim().ToString());
int JuicerNum1 = int.Parse(txtJuicerNum.Text.Trim().ToString());
switch (JuicerNum1)
{
case 0:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯1);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯1));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁1);
Wait(int.Parse(JaKaHelper.SENCE_接果汁1));
break;
case 1:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯1);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯1));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁1);
Wait(int.Parse(JaKaHelper.SENCE_接果汁1));
break;
case 2:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯2);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯2));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁2);
Wait(int.Parse(JaKaHelper.SENCE_接果汁2));
break;
case 3:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯2);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯2));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁2);
Wait(int.Parse(JaKaHelper.SENCE_接果汁2));
break;
case 4:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯3);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯3));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁3);
Wait(int.Parse(JaKaHelper.SENCE_接果汁3));
break;
case 5:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯3);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯3));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁3);
Wait(int.Parse(JaKaHelper.SENCE_接果汁3));
break;
case 6:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯4);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯4));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接果汁4);
Wait(int.Parse(JaKaHelper.SENCE_接果汁4));
break;
case 7:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯4);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯4));
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));
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];

JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测);
Wait(int.Parse(JaKaHelper.SENCE_放杯检测));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
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(1000);
switch (JuicerNum1)
{
case 0:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯1);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯1));
break;
case 1:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯1);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯1));
break;
case 2:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯2);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯2));
break;
case 3:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯2);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯2));
break;
case 4:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯3);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯3));
break;
case 5:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯3);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯3));
break;
case 6:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放果汁杯4);
Wait(int.Parse(JaKaHelper.SENCE_放果汁杯4));
break;
case 7:
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;
}
MCUSerialHelper.GetInstance.OutputControl(1, false);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测);
Wait(int.Parse(JaKaHelper.SENCE_放杯检测));
int a3 = MCUSerialHelper.GetInstance.GetInputStatus(1);
while (a3 == 1)
{
Thread.Sleep(100);
a3 = MCUSerialHelper.GetInstance.GetInputStatus(1);
}
if (a3 == 2)
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
}
}
}
MessageLog.GetInstance.Show("测试流程执行完成");
}
@@ -178,7 +253,7 @@ namespace HBLConsole.Debug
Thread.Sleep(1000);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测);
Wait(int.Parse(JaKaHelper.SENCE_取杯检测));
while (!MCUSerialHelper.GetInstance.GetInputStatus(1))
while (!(MCUSerialHelper.GetInstance.GetInputStatus(1)==1))
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯);
Wait(int.Parse(JaKaHelper.SENCE_取杯));
@@ -199,15 +274,22 @@ namespace HBLConsole.Debug
Wait(int.Parse(JaKaHelper.SENCE_接茶_接水));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接水);
Wait(int.Parse(JaKaHelper.SENCE_接水));

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

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

Thread.Sleep(60000);

JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放水杯);
Wait(int.Parse(JaKaHelper.SENCE_放水杯));
MCUSerialHelper.GetInstance.OutputControl(1, false);
@@ -224,11 +306,11 @@ namespace HBLConsole.Debug
Wait(0);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯);
Wait(int.Parse(JaKaHelper.SENCE_取杯));
MCUSerialHelper.GetInstance.OutputControl(1, true);
Thread.Sleep(1000);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测);
Wait(int.Parse(JaKaHelper.SENCE_取杯检测));
while (!MCUSerialHelper.GetInstance.GetInputStatus(1))
while (!(MCUSerialHelper.GetInstance.GetInputStatus(1)==1))
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯);
Wait(int.Parse(JaKaHelper.SENCE_取杯));


+ 75
- 44
HBLConsole.MORKJC/Control_MORKJC.cs View File

@@ -178,8 +178,11 @@ namespace HBLConsole.MORKJC
{
GeneralConfig.Healthy =
JaKaHelper.GetInstance.IsConnected &&
MorkCStatus.GetInstance().CanDo;
//GeneralConfig.Healthy = true;
/* MorkCStatus.GetInstance().CanDo &&
JuicerHelper.GetInstance.IsOpen &&*/
MCUSerialHelper.GetInstance.IsOpen;
// GeneralConfig.Healthy = true;
Thread.Sleep(100);
}), "MORK-IC心跳刷新");
ThreadManage.GetInstance.Start(new Action(() =>
@@ -231,38 +234,51 @@ namespace HBLConsole.MORKJC
int checkeNum = 0;
are.Reset();
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING);

JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
MCUSerialHelper.GetInstance.OutputControl(1, false);
JaKaHelper.GetInstance.Set_RobotAO1(0);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯);
Wait(int.Parse(JaKaHelper.SENCE_取杯));

MCUSerialHelper.GetInstance.OutputControl(1, true);
Thread.Sleep(500);
MessageLog.GetInstance.Show("咖啡杯取杯完成");
p:
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测);
Wait(int.Parse(JaKaHelper.SENCE_取杯检测));
if (!LebaiHelper.GetInstance.GetTcpInput())
int a2 = MCUSerialHelper.GetInstance.GetInputStatus(1);
while (MCUSerialHelper.GetInstance.GetInputStatus(1) == 3)
{
MessageLog.GetInstance.Show("执行二次取咖啡杯");
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯);
Wait(int.Parse(JaKaHelper.SENCE_取杯));
goto p;
Thread.Sleep(100);
a2 = MCUSerialHelper.GetInstance.GetInputStatus(1);
}
if (a2 == 1)
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接咖啡);
Wait(int.Parse(JaKaHelper.SENCE_接咖啡));
new MakeCoffeeEvent() { DrinkCode = DrCoffeeDrinksCode.热水 }.Publish(); //接咖啡控制
are.WaitOne(1000 * 60);

JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放咖啡杯);
Wait(int.Parse(JaKaHelper.SENCE_放咖啡杯));
MCUSerialHelper.GetInstance.OutputControl(1, false);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测);
Wait(int.Parse(JaKaHelper.SENCE_放杯检测));
int a3 = MCUSerialHelper.GetInstance.GetInputStatus(1);
while (a3 == 1)
{
Thread.Sleep(100);
a3 = MCUSerialHelper.GetInstance.GetInputStatus(1);
}
if (a3 == 2)
{
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
}
//订单状态改变:完成
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
}
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接咖啡);
Wait(int.Parse(JaKaHelper.SENCE_接咖啡));

new MakeCoffeeEvent() { DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); //接咖啡控制
are.WaitOne(1000 * 180);

Thread.Sleep(3000);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放咖啡杯);
Wait(int.Parse(JaKaHelper.SENCE_放咖啡杯));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测);
Wait(int.Parse(JaKaHelper.SENCE_放杯检测));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
//订单状态改变:完成
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
#endregion
}
/// <summary>
@@ -270,26 +286,30 @@ namespace HBLConsole.MORKJC
/// </summary>
private void DoTea()
{
if (JaKaHelper.GetInstance.Get_RobotDI(1))
return;
#region 流程
are.Reset();
JaKaHelper.GetInstance.Set_RobotAO1(0);
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
JaKaHelper.GetInstance.Set_RobotAO1(0);
Wait(0);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
MCUSerialHelper.GetInstance.OutputControl(1, false);

JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯);
Wait(int.Parse(JaKaHelper.SENCE_取杯));

Thread.Sleep(500);
MessageLog.GetInstance.Show("茶水杯取杯完成");
p:
MCUSerialHelper.GetInstance.OutputControl(1, true);
Thread.Sleep(1000);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测);
Wait(int.Parse(JaKaHelper.SENCE_取杯检测));
if (!LebaiHelper.GetInstance.GetTcpInput())
while (MCUSerialHelper.GetInstance.GetInputStatus(1) == 3)
{
Thread.Sleep(100);
}
while ((MCUSerialHelper.GetInstance.GetInputStatus(1) == 2))
{
MessageLog.GetInstance.Show("执行二次取茶水杯");
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯);
Wait(int.Parse(JaKaHelper.SENCE_取杯));
goto p;
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_取杯检测);
Wait(int.Parse(JaKaHelper.SENCE_取杯检测));
}
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接茶);
Wait(int.Parse(JaKaHelper.SENCE_接茶));
@@ -299,28 +319,39 @@ namespace HBLConsole.MORKJC
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_接茶_接水));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_接水);
Wait(int.Parse(JaKaHelper.SENCE_接水));
MCUSerialHelper.GetInstance.OutputControl(3, false);

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

MCUSerialHelper.GetInstance.OutputControl(3, false);
Thread.Sleep(100);
MCUSerialHelper.GetInstance.OutputControl(3, true);
Thread.Sleep(1000);
Thread.Sleep(500);
MCUSerialHelper.GetInstance.OutputControl(3, false);
Thread.Sleep(3000);
are.WaitOne(1000 * 180);
//添加控制接水机构程序
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放茶水杯);
Wait(int.Parse(JaKaHelper.SENCE_放茶水杯));

Thread.Sleep(60000);

JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放水杯);
Wait(int.Parse(JaKaHelper.SENCE_放水杯));
MCUSerialHelper.GetInstance.OutputControl(1, false);
Thread.Sleep(1000);
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_放杯检测);
Wait(int.Parse(JaKaHelper.SENCE_放杯检测));
JaKaHelper.GetInstance.JaKaProgramName(JaKaHelper.SENCE_初始位);
Wait(int.Parse(JaKaHelper.SENCE_初始位));
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);

#endregion
}



+ 25
- 26
HBLConsole.MainConsole/Main.cs View File

@@ -71,39 +71,38 @@ namespace HBLConsole.MainConsole
ThreadManage.GetInstance.Start(new Action(() =>
{
SimpleFactory.GetInstance.DeviceInit();//设备初始化
//InternetInfo.ConfigInit();//从 consul 获取配置数据
//IotReport.GetInstance.Initialize();
//Topics.Clear();
//Topics.Add(TOPIC.GetInstance.GetOrderPushTopic(GeneralConfig.DeviceType, InternetInfo.deviceId));
//Topics.Add(TOPIC.GetInstance.GetBusinessTopic(GeneralConfig.DeviceType, InternetInfo.deviceId));
//Topics.Add(TOPIC.GetInstance.GetChargebackTopic(GeneralConfig.DeviceType, InternetInfo.deviceId));

////MQTT 连接成功
//MqttHelper.GetInstance.ConnectOk = new Action(() =>
//{
// SimpleFactory.GetInstance.DeviceInit();//设备初始化
InternetInfo.ConfigInit();//从 consul 获取配置数据
IotReport.GetInstance.Initialize();
Topics.Clear();
Topics.Add(TOPIC.GetInstance.GetOrderPushTopic(GeneralConfig.DeviceType, InternetInfo.deviceId));
Topics.Add(TOPIC.GetInstance.GetBusinessTopic(GeneralConfig.DeviceType, InternetInfo.deviceId));
Topics.Add(TOPIC.GetInstance.GetChargebackTopic(GeneralConfig.DeviceType, InternetInfo.deviceId));

//MQTT 连接成功
MqttHelper.GetInstance.ConnectOk = new Action(() =>
{
SimpleFactory.GetInstance.DeviceInit();//设备初始化

// MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray());//主题订阅
MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray());//主题订阅

// HeartbeatReport.GetInstance.Init();//心跳上报
HeartbeatReport.GetInstance.Init();//心跳上报

// ServerData.GetInstance.Init();//数据处理初始化
ServerData.GetInstance.Init();//数据处理初始化

// //接收MQTT消息
// MqttHelper.GetInstance.MqttReceive = new Action<MQTTnet.MqttApplicationMessageReceivedEventArgs>((receivce) =>
// {
// ServerData.GetInstance.ReceiveData(Encoding.UTF8.GetString(receivce.ApplicationMessage.Payload));
// });
//接收MQTT消息
MqttHelper.GetInstance.MqttReceive = new Action<MQTTnet.MqttApplicationMessageReceivedEventArgs>((receivce) =>
{
ServerData.GetInstance.ReceiveData(Encoding.UTF8.GetString(receivce.ApplicationMessage.Payload));
});

//});
});

////MQTT 重连成功
//MqttHelper.GetInstance.Reconnection = new Action(() => { MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray()); });
//MQTT 重连成功
MqttHelper.GetInstance.Reconnection = new Action(() => { MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray()); });

////MQTT 连接
//MqttHelper.GetInstance.MqttInitAsync(InternetInfo.MqttUserName, InternetInfo.MqttPassword,
// InternetInfo.MqttAddress, InternetInfo.MqttPort, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
//MQTT 连接
MqttHelper.GetInstance.MqttInitAsync(InternetInfo.MqttUserName, InternetInfo.MqttPassword,
InternetInfo.MqttAddress, InternetInfo.MqttPort, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));

}), "业务逻辑初始化");
}


+ 10
- 8
HBLConsole/App.config View File

@@ -11,20 +11,22 @@

<!--客户端ID-->
<!--1:且时且多冰淇淋咖啡机,2:且时且多煮面机,3:海科煮面机测试店铺-->
<add key="ClientId" value="11"/>
<add key="ClientId" value="1"/>

<add key="deviceId" value="13"/>
<add key="deviceId" value="10013"/>


<add key="ApolloUri" value="http://111.9.47.105:28080/"/>
<add key="OrderServiceUri" value="http://111.9.47.105:21527/order/"/>
<add key="StockServiceUri" value="http://111.9.47.105:21527/stock/"/>
<!--http://111.9.47.105:21528/kitchen/-->
<add key="COM_Coffee" value="COM8"/>
<add key="ApolloUri" value="https://bpa.black-pa.com:28080/"/>
<add key="OrderServiceUri" value="https://bpa.black-pa.com:21527/order/"/>
<add key="StockServiceUri" value="https://bpa.black-pa.com:21527/stock/"/>
<!--http://111.9.47.105:21528/kitchen/-->
<add key="COM_Coffee" value="COM10"/>
<add key="BAUD_Coffee" value="115200"/>
<add key="COM_IceCream" value="COM5"/>
<add key="BAUD_IceCream" value="9600"/>
<add key="IceCream_CXB_Threshold" value="90"/>
<add key="COM_ICChip" value="COM6"/>
<add key="BAUD_IChip" value="9600"/>



Loading…
Cancel
Save