@@ -183,6 +183,8 @@ namespace HBLConsole.MORKIC | |||
Thread.Sleep(5); | |||
} | |||
//todo:咖啡杯下杯 | |||
new TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish(); | |||
while (!ChipStatus.GetInstance().CompletedTake_CPU_CUP_COFFEE) { Thread.Sleep(5); } | |||
MessageLog.GetInstance.Show("咖啡杯取杯完成"); | |||
LebaiHelper.GetInstance.SetValue(100); | |||
@@ -210,10 +212,14 @@ namespace HBLConsole.MORKIC | |||
/// </summary> | |||
private void DoIceCream() | |||
{ | |||
new RotorSwitchEvent() { TurnOn = true }.Publish(); | |||
int scene = 10009; | |||
var se = IC_SE.SE_2; | |||
se = PolymerBatching.GetIceCreamSE(mainMaterialLoc, out scene); | |||
//订单状态改变:开始制作 | |||
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
//todo:先调用机器人 | |||
ThreadOperate.GetInstance.Start(new Action(() => { LebaiHelper.GetInstance.Scene(10001); }), "调用乐百机器人做冰淇淋场景"); | |||
ThreadOperate.GetInstance.Start(new Action(() => { LebaiHelper.GetInstance.Scene(scene); }), "调用乐百机器人做冰淇淋场景"); | |||
while (!(lebai.Ok && lebai.Value == 1)) | |||
{ | |||
@@ -221,10 +227,20 @@ namespace HBLConsole.MORKIC | |||
} | |||
new TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish(); | |||
while (!ChipStatus.GetInstance().CompletedTake_CPU_CUP_ICECREAM) { Thread.Sleep(5); } | |||
new MakeIceCreamEvent() { SteeringEngine = IC_SE.SE_1 }.Publish(); | |||
LebaiHelper.GetInstance.SetValue(100); | |||
//are.WaitOne(100 * 90); | |||
//订单状态改变:完成 | |||
while (!(lebai.Ok && lebai.Value == 2)) | |||
{ | |||
Thread.Sleep(5); | |||
} | |||
new MakeIceCreamEvent() { SteeringEngine = se }.Publish(); | |||
LebaiHelper.GetInstance.SetValue(101); | |||
new RotorSwitchEvent() { TurnOn = false }.Publish(); | |||
while (!(lebai.Ok && lebai.Value ==3)) | |||
{ | |||
Thread.Sleep(5); | |||
} | |||
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK); | |||
} | |||
@@ -239,6 +255,7 @@ namespace HBLConsole.MORKIC | |||
coffeeMachine.Start(); | |||
//冰淇淋机开启主线程 | |||
iceCreamMachine.Start(); | |||
icchipMachine.Start(); | |||
new ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
//开始心跳刷新,根据咖啡机及冰淇淋机来判断 | |||
@@ -253,6 +270,7 @@ namespace HBLConsole.MORKIC | |||
GeneralConfig.Healthy = | |||
LebaiHelper.GetInstance.IsConnected && | |||
MorkCStatus.GetInstance().CanDo; | |||
GeneralConfig.Healthy = true; | |||
Thread.Sleep(100); | |||
}), "MORK-IC心跳刷新"); | |||
@@ -1,4 +1,5 @@ | |||
using System; | |||
using HBLDevice.ICChip; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
@@ -21,6 +22,9 @@ namespace HBLConsole.MORKIC | |||
internal class PolymerBatching | |||
{ | |||
internal const string ICE_MAIN_BATCHIN1_LOC = "52"; | |||
internal const string ICE_MAIN_BATCHIN2_LOC = "53"; | |||
internal const string ICE_MAIN_BATCHIN3_LOC = "54"; | |||
public static Dictionary<string, GOODS_TYPE> GOODS_TYPES = new Dictionary<string, GOODS_TYPE>() { | |||
{"1", GOODS_TYPE.COFFEE}, | |||
{"2", GOODS_TYPE.COFFEE}, | |||
@@ -49,8 +53,9 @@ namespace HBLConsole.MORKIC | |||
{"25",GOODS_TYPE.COFFEE}, | |||
{"30",GOODS_TYPE.COFFEE}, | |||
{"51",GOODS_TYPE.ICECREAM}, | |||
{"52",GOODS_TYPE.ICECREAM}, | |||
{"53",GOODS_TYPE.ICECREAM}, | |||
{ICE_MAIN_BATCHIN1_LOC,GOODS_TYPE.ICECREAM}, | |||
{ICE_MAIN_BATCHIN2_LOC,GOODS_TYPE.ICECREAM}, | |||
{ICE_MAIN_BATCHIN3_LOC,GOODS_TYPE.ICECREAM}, | |||
}; | |||
public GOODS_TYPE GoodsType { get; set; } | |||
@@ -88,5 +93,24 @@ namespace HBLConsole.MORKIC | |||
} | |||
return temp; | |||
} | |||
internal static IC_SE GetIceCreamSE(string loc,out int sence) | |||
{ | |||
switch (loc) | |||
{ | |||
case ICE_MAIN_BATCHIN1_LOC: | |||
sence = 10008; | |||
return IC_SE.SE_1; | |||
case ICE_MAIN_BATCHIN2_LOC: | |||
sence = 10013; | |||
return IC_SE.SE_3; | |||
case ICE_MAIN_BATCHIN3_LOC: | |||
sence = 10009; | |||
return IC_SE.SE_2; | |||
default: | |||
sence = 10011; | |||
return IC_SE.SE_2; | |||
} | |||
} | |||
} | |||
} |
@@ -24,7 +24,7 @@ | |||
<add key="COM_IceCream" value="COM5"/> | |||
<add key="BAUD_IceCream" value="9600"/> | |||
<add key="IceCream_CXB_Threshold" value="90"/> | |||
<add key="COM_ICChip" value="COM5"/> | |||
<add key="COM_ICChip" value="COM10"/> | |||
<add key="BAUD_IChip" value="9600"/> | |||
</appSettings> |
@@ -19,4 +19,9 @@ namespace HBLDevice.ICChip | |||
{ | |||
public IC_SE SteeringEngine { get; set; } | |||
} | |||
public class RotorSwitchEvent : IEvent | |||
{ | |||
public bool TurnOn { get; set; } | |||
} | |||
} |
@@ -28,83 +28,27 @@ namespace HBLDevice.ICChip | |||
this.commProxy = commProxy; | |||
EventBus.GetInstance().Subscribe<TakeCupEvent>(TakeCupEventHandle); | |||
EventBus.GetInstance().Subscribe<MakeIceCreamEvent>(MakeIceCreamEventHandle); | |||
EventBus.GetInstance().Subscribe<RotorSwitchEvent>(RotorSwitchEventHandle); | |||
} | |||
private void RotorSwitchEventHandle(IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
package.Cmd = IC_CMD.ROTOR; | |||
package.Value = (@event as RotorSwitchEvent).TurnOn ? (byte)IC_ROTOR.OPEN_ROTOR : (byte)IC_ROTOR.OPEN_ROTOR; | |||
commProxy.SendData(StructureToByte(package)); | |||
} | |||
private void MakeIceCreamEventHandle(IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
switch ((@event as MakeIceCreamEvent).SteeringEngine) | |||
{ | |||
case IC_SE.SE_1: | |||
ChipStatus.GetInstance().CompletedOpen_SE_1 = false; | |||
break; | |||
case IC_SE.SE_2: | |||
ChipStatus.GetInstance().CompletedOpen_SE_2 = false; | |||
break; | |||
case IC_SE.SE_3: | |||
ChipStatus.GetInstance().CompletedOpen_SE_3 = false; | |||
break; | |||
} | |||
package.Cmd = IC_CMD.OPEN_SE; | |||
package.Value = (byte)(@event as MakeIceCreamEvent).SteeringEngine; | |||
commProxy.SendData(StructureToByte(package)); | |||
Thread.Sleep(500); | |||
DateTime timeOut = DateTime.Now.AddSeconds(3); | |||
bool loop = true; | |||
while (loop) | |||
{ | |||
loop = DateTime.Now < timeOut; | |||
switch ((@event as MakeIceCreamEvent).SteeringEngine) | |||
{ | |||
case IC_SE.SE_1: | |||
loop = !ChipStatus.GetInstance().CompletedOpen_SE_1; | |||
break; | |||
case IC_SE.SE_2: | |||
loop = !ChipStatus.GetInstance().CompletedOpen_SE_2; | |||
break; | |||
case IC_SE.SE_3: | |||
loop = !ChipStatus.GetInstance().CompletedOpen_SE_3; | |||
break; | |||
} | |||
} | |||
Thread.Sleep(3000); | |||
switch ((@event as MakeIceCreamEvent).SteeringEngine) | |||
{ | |||
case IC_SE.SE_1: | |||
ChipStatus.GetInstance().CompletedClose_SE_1 = false; | |||
break; | |||
case IC_SE.SE_2: | |||
ChipStatus.GetInstance().CompletedClose_SE_2 = false; | |||
break; | |||
case IC_SE.SE_3: | |||
ChipStatus.GetInstance().CompletedClose_SE_3 = false; | |||
break; | |||
} | |||
package.Cmd = IC_CMD.CLOSE_SE; | |||
package.Value = (byte)(@event as MakeIceCreamEvent).SteeringEngine; | |||
commProxy.SendData(StructureToByte(package)); | |||
Thread.Sleep(500); | |||
timeOut = DateTime.Now.AddSeconds(3); | |||
loop = true; | |||
while (loop) | |||
{ | |||
loop = DateTime.Now < timeOut; | |||
switch ((@event as MakeIceCreamEvent).SteeringEngine) | |||
{ | |||
case IC_SE.SE_1: | |||
loop = !ChipStatus.GetInstance().CompletedClose_SE_1; | |||
break; | |||
case IC_SE.SE_2: | |||
loop = !ChipStatus.GetInstance().CompletedClose_SE_2; | |||
break; | |||
case IC_SE.SE_3: | |||
loop = !ChipStatus.GetInstance().CompletedClose_SE_3; | |||
break; | |||
} | |||
} | |||
} | |||
private void TakeCupEventHandle(IEvent @event, EventCallBackHandle callBack) | |||
@@ -127,6 +71,7 @@ namespace HBLDevice.ICChip | |||
private byte[] StructureToByte(ICChipPackage structure) | |||
{ | |||
structure.Header = 0xAA; | |||
structure.Sender = IC_SENDER.CONSOLE; | |||
structure.End = 0xBB; | |||
int size = Marshal.SizeOf(typeof(ICChipPackage)); | |||
@@ -61,6 +61,7 @@ namespace HBLDevice.ICChip | |||
byte item = dataStorage.GetData(); | |||
if (item == 0xAA) | |||
{ | |||
temp.Add(item); | |||
while (dataStorage.GetSize() < 4) { Thread.Sleep(5); } | |||
while (temp.Count < 5) | |||
{ | |||
@@ -70,8 +71,8 @@ namespace HBLDevice.ICChip | |||
{ | |||
var package = ByteToStructure(temp.ToArray()); | |||
ChipStatus.GetInstance().ProcessMsg(package); | |||
temp.Clear(); | |||
} | |||
temp.Clear(); | |||
} | |||
continue; | |||
} | |||
@@ -0,0 +1,23 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace HBLDevice.ICChip | |||
{ | |||
/// <summary> | |||
/// 搅拌器 | |||
/// </summary> | |||
public enum IC_ROTOR | |||
{ | |||
/// <summary> | |||
/// 开始搅拌 | |||
/// </summary> | |||
OPEN_ROTOR = 0x01, | |||
/// <summary> | |||
/// 停止搅拌 | |||
/// </summary> | |||
CLOSE_ROTOR = 0x00 | |||
} | |||
} |