Browse Source

morkF代码更新

样式分支
pengliangyang 2 years ago
parent
commit
b65520e989
5 changed files with 151 additions and 111 deletions
  1. +2
    -7
      BPASmartClient.Lebai/LebaiRobot.cs
  2. +2
    -1
      BPASmartClient.Model/乐白机器人/LebaiRobotEvent.cs
  3. +6
    -6
      BPASmartClient.MorkF/Control_MorkF.cs
  4. +140
    -97
      BPASmartClient.MorkT.Lebai.JC/Control_MORKJC2.cs
  5. +1
    -0
      BPASmartClient.MorkT.Lebai.JC/GVL_MorkTLebeiJC.cs

+ 2
- 7
BPASmartClient.Lebai/LebaiRobot.cs View File

@@ -57,7 +57,6 @@ namespace BPASmartClient.Lebai
LebaiHelper.GetInstance().GetRobotModeStatus();
Thread.Sleep(10);
}, "获取乐白机器人数据");

}

public override void Stop()
@@ -143,9 +142,9 @@ namespace BPASmartClient.Lebai
EventBus.EventBus.GetInstance().Subscribe<LebaiRobot_SetOutPutEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (@event == null) return;
if (@event is LebaiRobot_LebaiSenceEvent lebaiSenceEvent)
if (@event is LebaiRobot_SetOutPutEvent lebaiOutputEvent)
{
LebaiHelper.GetInstance().SetOutput(lebaiOutputEvent.Value,lebaiOutputEvent.Pin);
}
});

@@ -158,10 +157,6 @@ namespace BPASmartClient.Lebai
{
}
public void SetDO(bool value, int Ch=0)
{
LebaiHelper.GetInstance().SetOutput(value,Ch);
}
}
}

+ 2
- 1
BPASmartClient.Model/乐白机器人/LebaiRobotEvent.cs View File

@@ -48,7 +48,8 @@ namespace BPASmartClient.Model.乐白机器人

public class LebaiRobot_SetOutPutEvent : BaseEvent
{
public int RobotSetOut { get; set; }
public int Pin { get; set; }
public bool Value { get; set; }
}
}


+ 6
- 6
BPASmartClient.MorkF/Control_MorkF.cs View File

@@ -95,12 +95,12 @@ namespace BPASmartClient.MorkF
//流程
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } });
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List<StirFryPotAction>() { StirFryPotAction.大火持续 }, During = 5 });
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入A料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 6 });
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.A料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 6 });
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.停止火力, StirFryPotAction.搅拌臂上位 } });//加A料
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入B料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 6 });
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.B料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 6 });
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加B料

stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入C料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 9 });
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.C料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 9 });

stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加C料
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 });
@@ -519,13 +519,13 @@ namespace BPASmartClient.MorkF
case StirFryRobotAction.清洗槽取锅:
TakePotTask();//执行取锅操作
break;
case StirFryRobotAction.加入A料:
case StirFryRobotAction.A料:
TakeBurdenATask();//执行取A料操作
break;
case StirFryRobotAction.加入B料:
case StirFryRobotAction.B料:
TakeBurdenATask();//执行取B料操作
break;
case StirFryRobotAction.加入C料:
case StirFryRobotAction.C料:
TakeBurdenCTask();//执行取C料操作
break;
case StirFryRobotAction.灶取锅:


+ 140
- 97
BPASmartClient.MorkT.Lebai.JC/Control_MORKJC2.cs View File

@@ -117,7 +117,6 @@ namespace BPASmartClient.MorkTLebaiJC
GoodName = order.MorkOrder.GoodsName,
});
}
//morkTLebaiJC.SuborderId = order.MorkOrder.SuborderId;
break;
case GOODS_TYPE.JUICE:
GuMake = order.MorkOrder.MakeID == "2";//判断果汁的冷热
@@ -165,6 +164,83 @@ namespace BPASmartClient.MorkTLebaiJC
}
});
}

private bool bFirstTrig_TeaWater = false;
/// <summary>
/// 延迟的超时时间
/// </summary>
DateTime delayTimeOut;
private bool bFirstTrig_Coffee = false;
DateTime delayTimeOut_Coffee;
private bool bFirstTrig_Juice = false;
DateTime delayTimeOut_Juice;
public override void MainTask()
{
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeEndCookEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (morkTLebaiJC.IsHaveCoffeeCup)
morkTLebaiJC.MakeCoffeeEnd = true;
});
if (pickUpCoffeeHaveCup)
{
if (!bFirstTrig_Coffee)
{
bFirstTrig_Coffee = true;
delayTimeOut_Coffee = DateTime.Now;
}
if (DateTime.Now.Subtract(delayTimeOut_Coffee).TotalSeconds > 180 )
{
bFirstTrig_Coffee = false;
if (morkTLebaiJC.IsHaveCoffeeCup)
morkTLebaiJC.MakeCoffeeEnd = true;
}
}

if (morkTLebaiJC.IsHaveJuiceCup)
{
var Juicestate = GetStatus<int[]>("GetDeviceStatus");
if (Juicestate != null)
{
if (Juicestate.Length > 0)
{
var Juicestate1 = Convert.ToString(Juicestate[0], 2);
var Juicestate2 = Juicestate[1];
if (Juicestate1.IndexOf("0") == 1 && Juicestate2 == 0)
{
morkTLebaiJC.MakeJuiceEnd = true;
}
}
}
//若无状态返回 则加延迟
if (!bFirstTrig_Juice)
{
bFirstTrig_Juice = true;
delayTimeOut_Juice = DateTime.Now;
}
if (DateTime.Now.Subtract(delayTimeOut_Juice).TotalSeconds > 30)
{
bFirstTrig_Juice = false;
morkTLebaiJC.MakeJuiceEnd = true;
}
}
if (morkTLebaiJC.IsHaveTeaWaterCup)
{
if (!bFirstTrig_TeaWater)
{
bFirstTrig_TeaWater = true;
delayTimeOut = DateTime.Now;
}
if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 50)
{
bFirstTrig_TeaWater = false;
morkTLebaiJC.MakeTeaEnd = true;
}
}
DoCoffee();
DoJuice();
DoBoiledTea();
DoBoiledWater();
}
public void Main()
{
//开始心跳刷新,根据咖啡机及冰淇淋机来判断
@@ -194,6 +270,10 @@ namespace BPASmartClient.MorkTLebaiJC
return batchings[batchingLoc].GoodsType;
return GOODS_TYPE.NEITHER;
}
/// <summary>
/// 乐白的场景结束等待
/// </summary>
/// <param name="value"></param>
private void Wait(int value = 101)
{
while (!((bool)peripheralStatus["RobotOK"] && (int)peripheralStatus["RobotValue"] == value))
@@ -202,11 +282,23 @@ namespace BPASmartClient.MorkTLebaiJC
}
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
}

/// <summary>
/// 乐白的场景
/// </summary>
/// <param name="sen"></param>
private void Sence(int sen)
{
new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = sen }.Publish();
}
/// <summary>
/// 乐白的数字量输出
/// </summary>
/// <param name="value"></param>
/// <param name="pin"></param>
private void Output(bool value,int pin)
{
new LebaiRobot_SetOutPutEvent { DeviceId = DeviceId, Pin = pin,Value=value }.Publish();
}

private T GetStatus<T>(string key)
{
@@ -237,25 +329,26 @@ namespace BPASmartClient.MorkTLebaiJC
/// 传感器的输入信号 0:无意义 1:有信号 2:无信号 3:信号不正确
/// </summary>
int bSensorInput;
/// <summary>
/// 延迟的超时时间
/// </summary>
DateTime delayTimeOut;

private bool IsMakeCoffee()
{
bool bMake = (IsHealth && morkTLebaiJC.morkOrderPushesCoffee.Count > 0 && !morkTLebaiJC.IsHaveCoffeeCup) ? true : false;
return bMake;
}

private bool IsMakeJuice()
{
bool bMake = (IsHealth && morkTLebaiJC.morkOrderPushesJuicer.Count > 0 && !morkTLebaiJC.IsHaveJuiceCup) ? true : false;
bool bMake = (IsHealth && morkTLebaiJC.morkOrderPushesJuicer.Count > 0 && !morkTLebaiJC.IsHaveJuiceCup) ? true : false;
return bMake;
}
private bool IsMakeTeaWater()
{
bool bMake = (IsHealth && morkTLebaiJC.morkOrderPushesTea.Count > 0 && morkTLebaiJC.morkOrderPushesWater.Count > 0 && !morkTLebaiJC.IsHaveTeaWaterCup) ? true : false;
bool bMake = (IsHealth && morkTLebaiJC.morkOrderPushesTea.Count > 0 && !morkTLebaiJC.IsHaveTeaWaterCup) ? true : false;
return bMake;
}
private bool IsMakeWater()
{
bool bMake = (IsHealth && morkTLebaiJC.morkOrderPushesWater.Count > 0 && !morkTLebaiJC.IsHaveTeaWaterCup) ? true : false;
return bMake;
}
/// <summary>
@@ -265,10 +358,10 @@ namespace BPASmartClient.MorkTLebaiJC
{
if (IsMakeCoffee())
{
if (morkTLebaiJC.morkOrderPushesCoffee.TryDequeue(out OrderLocInfo orderLoc))
if (morkTLebaiJC.morkOrderPushesCoffee.TryDequeue(out OrderLocInfo orderLoc))
{
morkTLebaiJC.IsHaveCoffeeCup = true;
PickUpCoffee();//接咖啡
morkTLebaiJC.IsHaveCoffeeCup = true;
}
}
else if(morkTLebaiJC.MakeCoffeeEnd)
@@ -284,15 +377,16 @@ namespace BPASmartClient.MorkTLebaiJC
{
if (morkTLebaiJC.morkOrderPushesJuicer.TryDequeue(out OrderLocInfo orderLoc))
{
morkTLebaiJC.IsHaveCoffeeCup = true;
PickUpJuicer();
morkTLebaiJC.IsHaveJuiceCup = true;
}
} else if (morkTLebaiJC.MakeJuiceEnd)
}
else if (morkTLebaiJC.MakeJuiceEnd)
{
Thread.Sleep(5000);//延迟五秒,防止接饮料口滴饮料
putJuice();
pickUpJuiceHaveCup = false;
morkTLebaiJC.IsHaveCoffeeCup = false;
morkTLebaiJC.IsHaveJuiceCup = false;
morkTLebaiJC.MakeJuiceEnd = false;
}
}
@@ -302,8 +396,8 @@ namespace BPASmartClient.MorkTLebaiJC
{
if (morkTLebaiJC.morkOrderPushesTea.TryDequeue(out OrderLocInfo orderLoc))
{
morkTLebaiJC.IsHaveTeaWaterCup = true;
PickUpTea();
morkTLebaiJC.IsHaveTeaWaterCup = true;
}
}
else if(morkTLebaiJC.MakeTeaEnd)
@@ -316,11 +410,10 @@ namespace BPASmartClient.MorkTLebaiJC
}
private void DoBoiledWater()
{
if (IsMakeTeaWater())
if (IsMakeWater())
{
if (morkTLebaiJC.morkOrderPushesWater.TryDequeue(out OrderLocInfo orderLoc))
{
morkTLebaiJC.IsHaveTeaWaterCup = true;
PickUpWater();
}
}
@@ -348,11 +441,7 @@ namespace BPASmartClient.MorkTLebaiJC
if (!pickUpCoffeeHaveCup)
{
outCupCheck = false;

if (morkTLebaiJC.morkOrderPushesCoffee.Count > 0)
{
OrderChange(morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
}
OrderChange(morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{
@@ -361,8 +450,7 @@ namespace BPASmartClient.MorkTLebaiJC
Sence(JuicerModel.JUICE2_接咖啡);
Wait();
pickUpCoffeeHaveCup = true;
//new DRCoffee_MakeCoffeeEvent() { DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水 //coffeEndCook.Publish();//模拟咖啡制作完成
//are.WaitOne(1000 * 360);
new DRCoffee_MakeCoffeeEvent() { DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水
}
else
{
@@ -386,10 +474,7 @@ namespace BPASmartClient.MorkTLebaiJC
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_放咖啡杯);
Wait();
if (morkTLebaiJC.morkOrderPushesCoffee.Count > 0)
{
OrderChange(morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
}
OrderChange(morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
DeviceProcessLogShow("咖啡制作完成");
}
#endregion
@@ -402,30 +487,26 @@ namespace BPASmartClient.MorkTLebaiJC
#region 接水流程
if (!pickUpHotWaterHaveCup)
{
if (morkTLebaiJC.morkOrderPushesCoffee.Count > 0)
{
OrderChange(morkTLebaiJC.morkOrderPushesWater.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
}
OrderChange(morkTLebaiJC.morkOrderPushesWater.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_接开水);
Wait();
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish();
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = false }.Publish();
Output(false, 1);
Output(false, 0);
Thread.Sleep(100);
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = true }.Publish();
Output(true, 0);
Thread.Sleep(3000);
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = false }.Publish();
Output(false, 0);
Thread.Sleep(100);

new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish();
Output(false, 1);
Thread.Sleep(100);
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish();
Output(true, 1);
Thread.Sleep(500);
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish();
Thread.Sleep(46000);
Output(false, 1);
}
else
{
@@ -444,10 +525,7 @@ namespace BPASmartClient.MorkTLebaiJC
#region 接茶流程
if (!pickUpHotWaterHaveCup)
{
if (morkTLebaiJC.morkOrderPushesCoffee.Count > 0)
{
OrderChange(morkTLebaiJC.morkOrderPushesTea.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
}
OrderChange(morkTLebaiJC.morkOrderPushesTea.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{
@@ -466,6 +544,19 @@ namespace BPASmartClient.MorkTLebaiJC
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_接茶水);
Wait();
Output(false, 1);
Output(false, 0);
Thread.Sleep(100);
Output(true, 0);
Thread.Sleep(3000);
Output(false, 0);
Thread.Sleep(100);

Output(false, 1);
Thread.Sleep(100);
Output(true, 1);
Thread.Sleep(500);
Output(false, 1);
pickUpHotWaterHaveCup = true;
}
else
@@ -490,10 +581,7 @@ namespace BPASmartClient.MorkTLebaiJC
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_放水杯);
Wait();
if (morkTLebaiJC.morkOrderPushesCoffee.Count > 0)
{
OrderChange(morkTLebaiJC.morkOrderPushesWater.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
}
OrderChange(morkTLebaiJC.morkOrderPushesWater.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
DeviceProcessLogShow("茶水制作完成");
}

@@ -512,10 +600,7 @@ namespace BPASmartClient.MorkTLebaiJC
#region 接果汁流程
if (!pickUpJuiceHaveCup)
{
if (morkTLebaiJC.morkOrderPushesCoffee.Count > 0)
{
OrderChange(morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
}
OrderChange(morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
JuiceCH = int.Parse(mainMaterialLoc);
if (resultTakeCup == 1)
@@ -565,6 +650,7 @@ namespace BPASmartClient.MorkTLebaiJC
Wait();
break;
}
new WriteJuicer() { Value = JuicerNum }.Publish();
pickUpJuiceHaveCup = true;
}
else
@@ -614,10 +700,7 @@ namespace BPASmartClient.MorkTLebaiJC
Wait();
break;
}
if (morkTLebaiJC.morkOrderPushesCoffee.Count > 0)
{
OrderChange(morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
}
OrderChange(morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
DeviceProcessLogShow("果汁制作完成");
}
#endregion
@@ -682,7 +765,6 @@ namespace BPASmartClient.MorkTLebaiJC
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_二次取杯);
Wait();

new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_取纸杯检测);
Wait();
@@ -780,45 +862,6 @@ namespace BPASmartClient.MorkTLebaiJC

}

private bool bFirstTrig = false;
public override void MainTask()
{
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeEndCookEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (morkTLebaiJC.IsHaveCoffeeCup)
morkTLebaiJC.MakeCoffeeEnd = true;
});
var Juicestate = GetStatus<int[]>("GetDeviceStatus");
if (Juicestate != null)
{
if (Juicestate.Length > 0)
{
var Juicestate1 = Convert.ToString(Juicestate[0], 2);
var Juicestate2 = Juicestate[1];
if (Juicestate1.IndexOf("0") == 1 && Juicestate2 == 0)
{
morkTLebaiJC.MakeJuiceEnd= true;
}
}
}
if (morkTLebaiJC.IsHaveTeaWaterCup)
{
if (!bFirstTrig)
{
bFirstTrig = true;
delayTimeOut = DateTime.Now;
}
if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 50)
{
bFirstTrig = false;
morkTLebaiJC.MakeTeaEnd = true;
}
}
DoCoffee();
DoJuice();
DoBoiledTea();
DoBoiledTea();
}
public override void ResetProgram()
{
}


+ 1
- 0
BPASmartClient.MorkT.Lebai.JC/GVL_MorkTLebeiJC.cs View File

@@ -70,6 +70,7 @@ namespace BPASmartClient.MorkTLebaiJC
/// 订单ID
/// </summary>
public string SuborderId = null;

}
}

Loading…
Cancel
Save