Browse Source

jaka代码优化更改

样式分支
pengliangyang 2 years ago
parent
commit
2b2787c55a
7 changed files with 604 additions and 388 deletions
  1. +18
    -10
      BPASmartClient.MorkT.Lebai.JC/Control_MORKJC2.cs
  2. +32
    -5
      BPASmartClient.MorkT.Lebai.JC/ViewModel/DebugViewModel.cs
  3. +1
    -1
      BPASmartClient.Morkt.JAKA.JC/BPASmartClient.MorkTJAKAJC.csproj
  4. +466
    -367
      BPASmartClient.Morkt.JAKA.JC/Control_MORKJC.cs
  5. +61
    -0
      BPASmartClient.Morkt.JAKA.JC/GVL_MORKJC.cs
  6. +17
    -0
      BPASmartClient.Morkt.JAKA.JC/OrderLocInfo.cs
  7. +9
    -5
      BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml

+ 18
- 10
BPASmartClient.MorkT.Lebai.JC/Control_MORKJC2.cs View File

@@ -53,6 +53,8 @@ namespace BPASmartClient.MorkTLebaiJC
IsHealth = true;
serverInit();
DataParse();
ActionManage.GetInstance.Register(new Action<object>((o) => { SimOrder(o); }), "SimOrder");//模拟订单委托注册

}

private void serverInit()
@@ -241,15 +243,6 @@ namespace BPASmartClient.MorkTLebaiJC
DoBoiledTea();
DoBoiledWater();
}
public void Main()
{
//开始心跳刷新,根据咖啡机及冰淇淋机来判断
ThreadManage.GetInstance().StartLong(new Action(() =>
{
IsHealth = true;
Thread.Sleep(100);
}), "MORK-IC心跳刷新");
}

/// <summary>
/// 订单状态改变
@@ -850,7 +843,22 @@ namespace BPASmartClient.MorkTLebaiJC

public void SimOrder<T>(T simOrder)
{
if (simOrder != null)
{

if (simOrder is List<ushort> locs)
{
List<OrderLocInfo> orders = new List<OrderLocInfo>();
string subId = Guid.NewGuid().ToString();
foreach (var item in locs)
{
if (true)
{
orders.Add(new OrderLocInfo() { Loc = item, SuborderId = subId });
}
}
}
}
}
public override void Stop()


+ 32
- 5
BPASmartClient.MorkT.Lebai.JC/ViewModel/DebugViewModel.cs View File

@@ -151,21 +151,47 @@ namespace BPASmartClient.MorkTLebaiJC.ViewModel;

public bool MCU_DO_Value { get { return _mcu_DO_Valuer; } set { _mcu_DO_Valuer = value; OnPropertyChanged(); } }
private bool _mcu_DO_Valuer = true;
private void Button_McuOutput()

public bool MCU_DI0 { get { return _mcu_DI0; }set { _mcu_DI0 = value;OnPropertyChanged(); } }
private bool _mcu_DI0 = true;
public bool MCU_DI1 { get { return _mcu_DI1; } set { _mcu_DI1 = value; OnPropertyChanged(); } }
private bool _mcu_DI1 = true;
public bool MCU_DI2 { get { return _mcu_DI2; } set { _mcu_DI2 = value; OnPropertyChanged(); } }
private bool _mcu_DI2 = true;
public bool MCU_DI3 { get { return _mcu_DI3; } set { _mcu_DI3 = value; OnPropertyChanged(); } }
private bool _mcu_DI3 = true;
public bool MCU_DI4 { get { return _mcu_DI4; } set { _mcu_DI4 = value; OnPropertyChanged(); } }
private bool _mcu_DI4 = true;
public bool MCU_DI5 { get { return _mcu_DI5; } set { _mcu_DI5 = value; OnPropertyChanged(); } }
private bool _mcu_DI5 = true;
public bool MCU_DI6 { get { return _mcu_DI6; } set { _mcu_DI6 = value; OnPropertyChanged(); } }
private bool _mcu_DI6 = true;
public bool MCU_DI7 { get { return _mcu_DI7; } set { _mcu_DI7 = value; OnPropertyChanged(); } }
private bool _mcu_DI7 = true;
/// <summary>
/// 单片机舵机输出
/// </summary>
private void Button_McuOutput()
{
string sChoosePWM =Convert.ToString(MCU_PWM_CH+1);
new WriteMcu() { TagName = "ServoControl", Address = sChoosePWM, Value = PWMInputNumber }.Publish();
}
/// <summary>
/// 单片机DO输出
/// </summary>
private void Button_McuDOutput()
{
string sChooseDO = Convert.ToString(MCU_DO_CH + 1);
new WriteMcu() { TagName = "OutputControl", Address = sChooseDO, Value = MCU_DO_Value }.Publish();
}
/// <summary>
/// 乐白的DO输出
/// </summary>
private void Button_LebaiDOutput()
{
string sChooseDO = Convert.ToString(Lebai_DO_CH + 1);
int sChooseDO = Convert.ToInt16(Lebai_DO_CH);
bool lebai_DO_Value = Convert.ToInt16(Lebai_DO_Value) == 0;
new LebaiRobot_SetOutPutEvent { DeviceId = DeviceId, Pin = sChooseDO, Value = lebai_DO_Value }.Publish();
}
#endregion

@@ -205,7 +231,7 @@ namespace BPASmartClient.MorkTLebaiJC.ViewModel;
;
});


ThreadManage.GetInstance().StartLong(new Action(() =>
{
@@ -230,6 +256,7 @@ namespace BPASmartClient.MorkTLebaiJC.ViewModel;
}
Thread.Sleep(500);
}), "MorkT-状态刷新");

}
}


+ 1
- 1
BPASmartClient.Morkt.JAKA.JC/BPASmartClient.MorkTJAKAJC.csproj View File

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

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>


+ 466
- 367
BPASmartClient.Morkt.JAKA.JC/Control_MORKJC.cs View File

@@ -22,19 +22,14 @@ namespace BPASmartClient.MorktJAKAJC
{
public class Control_MORKJC : BaseDevice
{
GVL_MORKJC mORKD = new GVL_MORKJC();
GVL_MORKJC morkTJakaJC = new GVL_MORKJC();
//物料存放位置
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;
public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKT; } }
/// <summary>
/// 果汁机做法,true:热饮,false:冷饮
/// </summary>
@@ -44,119 +39,209 @@ namespace BPASmartClient.MorktJAKAJC
{
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType });
}

//private SerialPortClient commProxy;
public void ConnectOk()
public override void DoMain()
{

if (Json<KeepDataBase>.Data.IsVerify)
{
IsHealth = true;
}
IsHealth = true;
serverInit();
DataParse();
}
ConcurrentQueue<MorkOrderPush> morkOrderPushes = new ConcurrentQueue<MorkOrderPush>();
public void Init()
private void serverInit()
{
ActionManage.GetInstance.Register(new Action<object>((s) =>
EventBus.EventBus.GetInstance().Subscribe<MaterialDeliveryEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (s is DrCoffeeDrinksCode cf)
if (@event == null) return;
if (@event is MaterialDeliveryEvent material)
{
mainMaterialLoc = ((int)cf).ToString();
DoCoffee();
orderMaterialDelivery = material.orderMaterialDelivery;
}
}), "SimCoffee");
});
}

//构建所有商品物料信息
batchings = PolymerBatching.BuildAll();
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeEndCookEvent>(DeviceId, DRCoffee_CoffeEndCookEventHandle);
Main();
ReadData();
ThreadManage.GetInstance().StartLong(new Action(() =>
{
while (morkOrderPushes.Count > 0)
{
while (enableFunny) { Thread.Sleep(10); }
DeviceProcessLogShow("当前非自嗨模式,允许开工");
working = true;
if (morkOrderPushes.TryDequeue(out MorkOrderPush order))
private void DataParse()
{
EventBus.EventBus.GetInstance().Subscribe<DoOrderEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle)
{
if (@event == null) return;
if (@event is DoOrderEvent order)
{
if (order.MorkOrder.GoodBatchings == null) return;
OrderCount++;
DeviceProcessLogShow($"接收到{OrderCount}次订单");
batchings = PolymerBatching.BuildAll();

//商品类型
GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER;

foreach (var item in order.MorkOrder.GoodBatchings)
{
DeviceProcessLogShow($"开始制作订单[{order.SortNum}]");
//商品类型
GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER;
//子订单ID
subOrderId = order.SuborderId;
//遍历物料
foreach (var item in order.GoodBatchings)
var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId);
if (res != null)
{
var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery.BatchingInfo.FirstOrDefault(p => p.BatchingId == item.BatchingId);
if (res != null)
//验证商品是做的某种饮料
if (ValidateGoodsByBatching(res.BatchingLoc) != GOODS_TYPE.NEITHER)
{
//获取当前物料所属商品类型
currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc);
}
//
switch (batchings[res.BatchingLoc].BatchingClass)
{
case BATCHING_CLASS.HOLDER:
holderLoc = res.BatchingLoc;
break;
case BATCHING_CLASS.MAIN_MATERIAL:
mainMaterialLoc = res.BatchingLoc;
break;
}
//根据商品类型执行具体制作流程
switch (currentGoodsType)
{
//获取主料和容器位置
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)
case GOODS_TYPE.COFFEE:
if (morkTJakaJC.morkOrderPushesCoffee.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
{
morkTJakaJC.morkOrderPushesCoffee.Enqueue(new OrderLocInfo()
{
SuborderId = order.MorkOrder.SuborderId,
BatchingId = res.BatchingId,
Loc = ushort.Parse(mainMaterialLoc),
GoodName = order.MorkOrder.GoodsName,
});
}
break;
case GOODS_TYPE.JUICE:
GuMake = order.MorkOrder.MakeID == "2";//判断果汁的冷热
if (morkTJakaJC.morkOrderPushesJuicer.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
{
morkTJakaJC.morkOrderPushesJuicer.Enqueue(new OrderLocInfo()
{
SuborderId = order.MorkOrder.SuborderId,
BatchingId = res.BatchingId,
Loc = ushort.Parse(mainMaterialLoc),
GoodName = order.MorkOrder.GoodsName,
});
}
break;
case GOODS_TYPE.TEA:
if (morkTJakaJC.morkOrderPushesTea.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
{
morkTJakaJC.morkOrderPushesTea.Enqueue(new OrderLocInfo()
{
SuborderId = order.MorkOrder.SuborderId,
BatchingId = res.BatchingId,
Loc = ushort.Parse(mainMaterialLoc),
GoodName = order.MorkOrder.GoodsName,
});
}
break;
case GOODS_TYPE.WATER:
if (morkTJakaJC.morkOrderPushesWater.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
{
morkTJakaJC.morkOrderPushesWater.Enqueue(new OrderLocInfo()
{
//获取当前物料所属商品类型
currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc);
}
break;
}
SuborderId = order.MorkOrder.SuborderId,
BatchingId = res.BatchingId,
Loc = ushort.Parse(mainMaterialLoc),
GoodName = order.MorkOrder.GoodsName,
});
}
break;
case GOODS_TYPE.NEITHER:
DeviceProcessLogShow("未知的商品类型");
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:
DeviceProcessLogShow("未知的商品类型");
break;
}
}
working = false;
lastRecvdOrder = DateTime.Now;
}
Thread.Sleep(1000);
}), "订单制作");
});
}

public void Main()
private bool bFirstTrig_TeaWater = false;
private bool bFirstTrig_Coffee = false;
DateTime delayTimeOut_Coffee;
private bool bFirstTrig_Juice = false;
DateTime delayTimeOut_Juice;
/// <summary>
/// 判断接咖啡的位置是否有杯子
/// </summary>
bool pickUpCoffeeHaveCup = false;
/// <summary>
/// 判断接果汁的位置是否有杯子
/// </summary>
bool pickUpJuiceHaveCup = false;
/// <summary>
/// 判断接开水的位置是否有杯子
/// </summary>
bool pickUpHotWaterHaveCup = false;
public override void MainTask()
{
//开始心跳刷新,根据咖啡机及冰淇淋机来判断
ThreadManage.GetInstance().StartLong(new Action(() =>
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeEndCookEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
//IsHealth =
// Write.IsConnected &&
// MorkCStatus.GetInstance().CanDo &&
// JuicerHelper.GetInstance.IsOpen &&
// MCUSerialHelper.GetInstance.IsOpen;
//GeneralConfig.Healthy = true;
Thread.Sleep(100);
}), "MORK-IC心跳刷新");
}

public void DataParse<T>(T order)
{
if (order is MorkOrderPush morkOrderPush)
if (morkTJakaJC.IsHaveCoffeeCup)
morkTJakaJC.MakeCoffeeEnd = true;
});
if (pickUpCoffeeHaveCup)
{
morkOrderPushes.Enqueue(morkOrderPush);
if (!bFirstTrig_Coffee)
{
bFirstTrig_Coffee = true;
delayTimeOut_Coffee = DateTime.Now;
}
if (DateTime.Now.Subtract(delayTimeOut_Coffee).TotalSeconds > 180)
{
bFirstTrig_Coffee = false;
if (morkTJakaJC.IsHaveCoffeeCup)
morkTJakaJC.MakeCoffeeEnd = true;
}
}
if (morkTJakaJC.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)
{
morkTJakaJC.MakeJuiceEnd = true;
}
}
}
//若无状态返回 则加延迟
if (!bFirstTrig_Juice)
{
bFirstTrig_Juice = true;
delayTimeOut_Juice = DateTime.Now;
}
if (DateTime.Now.Subtract(delayTimeOut_Juice).TotalSeconds > 30)
{
bFirstTrig_Juice = false;
morkTJakaJC.MakeJuiceEnd = true;
}
}
if (morkTJakaJC.IsHaveTeaWaterCup)
{
if (!bFirstTrig_TeaWater)
{
bFirstTrig_TeaWater = true;
delayTimeOut = DateTime.Now;
}
if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 50)
{
bFirstTrig_TeaWater = false;
morkTJakaJC.MakeTeaEnd = true;
}
}
DoCoffee();
DoJuice();
DoBoiledTea();
DoBoiledWater();
}

/// <summary>
/// 验证当前是做咖啡还是做冰淇淋
/// </summary>
@@ -190,7 +275,26 @@ namespace BPASmartClient.MorktJAKAJC
}
}
int[] devStatusBy = new int[2] { 0, 0 };

private bool IsMakeCoffee()
{
bool bMake = (IsHealth && morkTJakaJC.morkOrderPushesCoffee.Count > 0 && !morkTJakaJC.IsHaveCoffeeCup) ? true : false;
return bMake;
}
private bool IsMakeJuice()
{
bool bMake = (IsHealth && morkTJakaJC.morkOrderPushesJuicer.Count > 0 && !morkTJakaJC.IsHaveJuiceCup) ? true : false;
return bMake;
}
private bool IsMakeTeaWater()
{
bool bMake = (IsHealth && morkTJakaJC.morkOrderPushesTea.Count > 0 && !morkTJakaJC.IsHaveTeaWaterCup) ? true : false;
return bMake;
}
private bool IsMakeWater()
{
bool bMake = (IsHealth && morkTJakaJC.morkOrderPushesWater.Count > 0 && !morkTJakaJC.IsHaveTeaWaterCup) ? true : false;
return bMake;
}
/// <summary>
/// 传感器的输入信号 0:无意义 1:有信号 2:无信号 3:信号不正确
/// </summary>
@@ -204,26 +308,88 @@ namespace BPASmartClient.MorktJAKAJC
/// </summary>
private void DoCoffee()
{
#region 接咖啡流程
are.Reset();
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{
DeviceProcessLogShow("咖啡杯取杯完成");
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接咖啡 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接咖啡));
new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水
are.WaitOne(1000 * 180);
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放咖啡杯 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放咖啡杯));
int resultputCup = putCup();
if (resultputCup == 1)
{
//订单状态改变:完成
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
if (IsMakeCoffee())
{
if (morkTJakaJC.morkOrderPushesCoffee.TryDequeue(out OrderLocInfo orderLoc))
{
PickUpCoffee();//接咖啡
morkTJakaJC.IsHaveCoffeeCup = true;
}
}
else if (morkTJakaJC.MakeCoffeeEnd)
{
PutCoffeeCup();
pickUpCoffeeHaveCup = false;
morkTJakaJC.IsHaveCoffeeCup = false;
}
}
private void DoJuice()
{
if (IsMakeJuice())
{
if (morkTJakaJC.morkOrderPushesJuicer.TryDequeue(out OrderLocInfo orderLoc))
{
PickUpJuicer();
morkTJakaJC.IsHaveJuiceCup = true;
}
}
else if (morkTJakaJC.MakeJuiceEnd)
{
Thread.Sleep(5000);//延迟五秒,防止接饮料口滴饮料
putJuice();
pickUpJuiceHaveCup = false;
morkTJakaJC.IsHaveJuiceCup = false;
morkTJakaJC.MakeJuiceEnd = false;
}
}
private void DoBoiledTea()
{
if (IsMakeTeaWater())
{
if (morkTJakaJC.morkOrderPushesTea.TryDequeue(out OrderLocInfo orderLoc))
{
PickUpTea();
morkTJakaJC.IsHaveTeaWaterCup = true;
}
}
else if (morkTJakaJC.MakeTeaEnd)
{
PutWaterCup();
pickUpHotWaterHaveCup = false;
morkTJakaJC.IsHaveTeaWaterCup = false;
morkTJakaJC.MakeTeaEnd = false;
}
}
private void DoBoiledWater()
{
if (IsMakeWater())
{
if (morkTJakaJC.morkOrderPushesWater.TryDequeue(out OrderLocInfo orderLoc))
{
PickUpWater();
}
}
else if (morkTJakaJC.MakeTeaEnd)
{
PutWaterCup();
pickUpHotWaterHaveCup = false;
morkTJakaJC.IsHaveTeaWaterCup = false;
morkTJakaJC.MakeTeaEnd = false;
}
}
private void PickUpCoffee()
{
if (!pickUpCoffeeHaveCup)
{
OrderChange(morkTJakaJC.morkOrderPushesCoffee.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{
DeviceProcessLogShow("咖啡杯取杯完成");
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接咖啡 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接咖啡));
new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水
are.WaitOne(1000 * 180);
}
else
{
@@ -231,309 +397,253 @@ namespace BPASmartClient.MorktJAKAJC
Wait(int.Parse(JakaModel.SENCE_初始位));
}
}
else if (resultTakeCup == 2 || resultTakeCup == 3)
}
private void PutCoffeeCup()
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放咖啡杯 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放咖啡杯));
int resultputCup = putCup();
if (resultputCup == 1)
{
//订单状态改变:完成
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
OrderChange(morkTJakaJC.morkOrderPushesCoffee.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
}
else
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
}
#endregion
}
/// <summary>
/// 做茶
/// 接开水
/// </summary>
private void DoTea()
private void PickUpWater()
{
#region 接茶流程
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
#region 接水流程
if (!pickUpHotWaterHaveCup)
{
DeviceProcessLogShow("取茶杯完成");
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接茶 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接茶));

new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 105 }.Publish();
Thread.Sleep(1000);
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 130 }.Publish();
Thread.Sleep(1000);
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 105 }.Publish();

Thread.Sleep(3000);
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接茶_接水 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接茶_接水));


new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish();
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish();
OrderChange(morkTJakaJC.morkOrderPushesWater.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接水 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接水));

Thread.Sleep(100);
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "3" }.Publish();
Thread.Sleep(3000);
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish();
Thread.Sleep(100);
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish();

new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish();
Thread.Sleep(100);
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "4" }.Publish();
Thread.Sleep(500);
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish();

Thread.Sleep(50000);
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish();
Thread.Sleep(100);
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "3" }.Publish();
Thread.Sleep(3000);
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish();
Thread.Sleep(100);

new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放茶水杯 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放茶水杯));
int resultputCup = putCup();
if (resultputCup == 1)
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish();
Thread.Sleep(100);
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "4" }.Publish();
Thread.Sleep(500);
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish();
}
else
else if (resultTakeCup == 2 || resultTakeCup == 3)
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
}
}
else if (resultTakeCup == 2 || resultTakeCup == 3)
#endregion
}
/// <summary>
/// 放水杯
/// </summary>
private void PutWaterCup()
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放茶水杯 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放茶水杯));
int resultputCup = putCup();
if (resultputCup == 1)
{
//订单状态改变:完成
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
OrderChange(morkTJakaJC.morkOrderPushesCoffee.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
}
else
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
}
#endregion
}

/// <summary>
/// 接开水
/// 做茶
/// </summary>
private void DoWater()
private void PickUpTea()
{
#region 接水流程
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
#region 接茶流程
if (!pickUpHotWaterHaveCup)
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接水 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接水));
OrderChange(morkTJakaJC.morkOrderPushesTea.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{
DeviceProcessLogShow("取茶杯完成");
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接茶 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接茶));

new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish();
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 105 }.Publish();
Thread.Sleep(1000);
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 130 }.Publish();
Thread.Sleep(1000);
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 105 }.Publish();

Thread.Sleep(3000);
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接茶_接水 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接茶_接水));

new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish();
Thread.Sleep(100);
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "3" }.Publish();
Thread.Sleep(3000);
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish();
Thread.Sleep(100);

new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish();
Thread.Sleep(100);
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "4" }.Publish();
Thread.Sleep(500);
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish();
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish();
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish();

Thread.Sleep(50000);
//添加控制接水机构程序
Thread.Sleep(100);
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "3" }.Publish();
Thread.Sleep(3000);
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish();
Thread.Sleep(100);

new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放茶水杯 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放茶水杯));
int resultputCup = putCup();
if (resultputCup == 1)
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish();
Thread.Sleep(100);
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "4" }.Publish();
Thread.Sleep(500);
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish();
}
else
else if (resultTakeCup == 2 || resultTakeCup == 3)
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
}
}
else if (resultTakeCup == 2 || resultTakeCup == 3)
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
}
#endregion
}
/// <summary>
/// 果汁机控制信号
/// </summary>
private byte JuicerNum;
/// <summary>
/// 做果汁
/// </summary>
private void DoJuicer()
private int JuiceCH;
private void PickUpJuicer()
{
#region 接果汁流程
are.Reset();
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
if (!pickUpJuiceHaveCup)
{
int JuicerNum1 = int.Parse(mainMaterialLoc);
switch (JuicerNum1)
OrderChange(morkTJakaJC.morkOrderPushesWater.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
JuiceCH = int.Parse(mainMaterialLoc);
if (resultTakeCup == 1)
{
case 52:
if (GuMake)
{
JuicerNum = 0x00;
}
else
{
JuicerNum = 0x01;
}
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁1 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接果汁1));
break;
case 53:
if (GuMake)
{
JuicerNum = 0x02;
}
else
{
JuicerNum = 0x03;
}
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁2 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接果汁2));
break;
case 54:
if (GuMake)
{
JuicerNum = 0x04;
}
else
{
JuicerNum = 0x05;
}
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁3 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接果汁3));
break;
case 55:
if (GuMake)
{
JuicerNum = 0x06;
}
else
{
JuicerNum = 0x07;
}
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁4 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接果汁4));
break;
default:
JuicerNum = 0x00;
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁1 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接果汁1));
break;
}
var devStatus = GetStatus<int[]>("GetDeviceStatus");
var devStatus1 = Convert.ToString(devStatus[0], 2);
var devStatus2 = devStatus[1];

if (devStatus1.IndexOf("0") == 1 && devStatus2 == 0)
{
if (sensor_Sign(1) == 1)
{
new WriteJuicer() { Value = JuicerNum }.Publish();
}
Thread.Sleep(100);
devStatusBy = GetStatus<int[]>("GetDeviceStatus");
while (!(devStatusBy[1] == 0))
{
Thread.Sleep(100);
devStatusBy = GetStatus<int[]>("GetDeviceStatus");
while (devStatusBy.Length != 2)
{
Thread.Sleep(100);
devStatusBy = GetStatus<int[]>("GetDeviceStatus");
}
}
devStatusBy = GetStatus<int[]>("GetDeviceStatus");
Thread.Sleep(5000);
switch (JuicerNum1)
switch (JuiceCH)
{
case 52:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯1 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯1));
if (GuMake)
{
JuicerNum = 0x00;
}
else
{
JuicerNum = 0x01;
}
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁1 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接果汁1));
break;
case 53:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯2 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯2));
if (GuMake)
{
JuicerNum = 0x02;
}
else
{
JuicerNum = 0x03;
}
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁2 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接果汁2));
break;
case 54:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯3 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯3));
if (GuMake)
{
JuicerNum = 0x04;
}
else
{
JuicerNum = 0x05;
}
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁3 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接果汁3));
break;
case 55:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯4 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯4));
if (GuMake)
{
JuicerNum = 0x06;
}
else
{
JuicerNum = 0x07;
}
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁4 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接果汁4));
break;
default:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯1 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯1));
JuicerNum = 0x00;
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁1 }.Publish();
Wait(int.Parse(JakaModel.SENCE_接果汁1));
break;
}
int resultputCup = putCup();
if (resultputCup == 1)
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
}
else
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
}
new WriteJuicer() { Value = JuicerNum }.Publish();
pickUpJuiceHaveCup = true;
}
else
{
switch (JuicerNum1)
{
case 52:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯1 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯1));
break;
case 53:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯2 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯2));
break;
case 54:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯3 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯3));
break;
case 55:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯4 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯4));
break;
default:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯1 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯1));
break;
}
int resultputCup = putCup();
if (resultputCup == 1)
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
}
else
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
}
return;
}
}
else if (resultTakeCup == 2 || resultTakeCup == 3)
#endregion
}
private void putJuice()
{
switch (JuiceCH)
{
case 52:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯1 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯1));
break;
case 53:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯2 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯2));
break;
case 54:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯3 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯3));
break;
case 55:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯4 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯4));
break;
default:
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯1 }.Publish();
Wait(int.Parse(JakaModel.SENCE_放果汁杯1));
break;
}
int resultputCup = putCup();
if (resultputCup == 1)
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
OrderChange(morkTJakaJC.morkOrderPushesWater.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
}
else
{
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish();
Wait(int.Parse(JakaModel.SENCE_初始位));
}
#endregion
}
private int getCup_cnt;
/// <summary>
@@ -656,9 +766,6 @@ namespace BPASmartClient.MorktJAKAJC
}
}
private int cnt_Check;

public override DeviceClientType DeviceType => throw new NotImplementedException();

/// <summary>
/// 检测放杯位,是否有杯子
/// </summary>
@@ -730,7 +837,6 @@ namespace BPASmartClient.MorktJAKAJC
{
break;
}

}
if (cnt_Check >= 0)
{
@@ -750,14 +856,11 @@ namespace BPASmartClient.MorktJAKAJC

public void SimOrder<T>(T simOrder)
{

}

public override void DoMain()
{

}

public override void Stop()
{

@@ -765,13 +868,9 @@ namespace BPASmartClient.MorktJAKAJC

public override void ReadData()
{
}

public override void MainTask()
{

}

public override void ResetProgram()
{


+ 61
- 0
BPASmartClient.Morkt.JAKA.JC/GVL_MORKJC.cs View File

@@ -1,8 +1,69 @@
using BPASmartClient.Device;
using System.Collections.Concurrent;

namespace BPASmartClient.MorktJAKAJC
{
public class GVL_MORKJC : IStatus
{
/// <summary>
/// <summary>
/// 咖啡订单队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesCoffee = new ConcurrentQueue<OrderLocInfo>();
/// <summary>
/// 是否有咖啡杯
/// </summary>
public bool IsHaveCoffeeCup = false;

/// <summary>
/// 咖啡是否制作完成
/// </summary>
public bool MakeCoffeeEnd = false;

/// <summary>
/// 果汁订单队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesJuicer = new ConcurrentQueue<OrderLocInfo>();
/// <summary>
/// 果汁是否在制作中
/// </summary>
public bool IsHaveJuiceCup = false;
/// <summary>
/// 咖啡是否制作完成
/// </summary>
public bool MakeJuiceEnd = false;

/// <summary>
/// 做茶订单队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesTea = new ConcurrentQueue<OrderLocInfo>();
/// <summary>
/// 茶或水是否在制作中
/// </summary>
public bool IsHaveTeaWaterCup = false;
/// <summary>
/// 咖啡是否制作完成
/// </summary>
public bool MakeTeaEnd = false;

/// <summary>
/// 做开水订单队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> morkOrderPushesWater = new ConcurrentQueue<OrderLocInfo>();

/// <summary>
/// 等待取餐订单
/// </summary>
public OrderLocInfo waitMorkOrder = new OrderLocInfo();

/// <summary>
/// 当前正在制作咖啡
/// </summary>
public OrderLocInfo MakeCoffeeOrder = new OrderLocInfo();

/// <summary>
/// 订单ID
/// </summary>
public string SuborderId = null;
}
}

+ 17
- 0
BPASmartClient.Morkt.JAKA.JC/OrderLocInfo.cs View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorktJAKAJC
{
public class OrderLocInfo
{
public string SuborderId { get; set; }
public ushort Loc { get; set; }
public ushort RecipeNumber { get; set; }
public int BatchingId { get; set; }
public string GoodName { get; set; }
}
}

+ 9
- 5
BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml View File

@@ -18,7 +18,7 @@
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="10*"/>
@@ -26,7 +26,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="20*"/>
<RowDefinition Height="15*"/>
</Grid.RowDefinitions>

<GroupBox Grid.ColumnSpan="2"
@@ -50,7 +50,7 @@
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding RobotConnected}"
Margin="120,0,0,0"/>
<ListBox Grid.Row="2" Background="Transparent" Margin="0,0,0,-9">
<ListBox.Template>
<ControlTemplate TargetType="{x:Type ListBox}">
@@ -119,6 +119,10 @@
FontSize="20"
Header=" 果汁机 ">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="47*"/>
<ColumnDefinition Width="75*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
@@ -127,7 +131,7 @@
<TextBlock Text="连接状态" />
<TextBlock Text="{Binding JuicerConnected}"
Margin="120,0,0,0"/>
<Grid Grid.Row="1">
<Grid Grid.ColumnSpan="2" Margin="0,71,0,71" Grid.RowSpan="3">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
@@ -157,7 +161,7 @@
</Grid>


<StackPanel Grid.Row="2" Orientation="Vertical">
<StackPanel Grid.Row="2" Orientation="Vertical" Grid.ColumnSpan="2">
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock>果汁</TextBlock>
<ComboBox Margin="100,0,0,0"


Loading…
Cancel
Save