ソースを参照

JakaDO添加

样式分支
pengliangyang 2年前
コミット
c3efa98fdb
10個のファイルの変更1150行の追加7行の削除
  1. +3
    -0
      BPASmartClient.JAKA/JakaMachine.cs
  2. +2
    -0
      BPASmartClient.Model/节卡机器人/JakaModel.cs
  3. +3
    -3
      BPASmartClient.MorkT.Lebai.JC/Control_MORKJC2.cs
  4. +19
    -0
      BPASmartClient.MorkT_Show/BPASmartClient.MorkT_Show.csproj
  5. +851
    -0
      BPASmartClient.MorkT_Show/Control_MORKJC_Show.cs
  6. +76
    -0
      BPASmartClient.MorkT_Show/GVL_MorkTLebeiJC.cs
  7. +17
    -0
      BPASmartClient.MorkT_Show/OrderLocInfo.cs
  8. +152
    -0
      BPASmartClient.MorkT_Show/PolymerBatching.cs
  9. +3
    -3
      BPASmartClient.Morkt.JAKA.JC/Control_MORKJC.cs
  10. +24
    -1
      SmartClient.sln

+ 3
- 0
BPASmartClient.JAKA/JakaMachine.cs ファイルの表示

@@ -52,6 +52,9 @@ namespace BPASmartClient.JAKA
case "JaKaProgramName":
if (par?.Value is string stringvalue) jaKaHelper.JaKaProgramName(stringvalue);
break;
case "JakaDOutput":
if (par?.Value is bool DO_value && par?.DO_Index is int DO_Index) jaKaHelper.Set_RobotDO(DO_Index, DO_value);
break;
default:
break;
}


+ 2
- 0
BPASmartClient.Model/节卡机器人/JakaModel.cs ファイルの表示

@@ -39,6 +39,7 @@ namespace BPASmartClient.Model
{
public string Address { get; set; }
public object Value { get; set; }
public int DO_Index { get; set; }
}

public class ReadJaka : BaseEvent
@@ -47,5 +48,6 @@ namespace BPASmartClient.Model
public ushort Length { get; set; }
public object ReadPar { get; set; }
}

}


+ 3
- 3
BPASmartClient.MorkT.Lebai.JC/Control_MORKJC2.cs ファイルの表示

@@ -190,7 +190,7 @@ namespace BPASmartClient.MorkTLebaiJC
bFirstTrig_Coffee = true;
delayTimeOut_Coffee = DateTime.Now;
}
if (DateTime.Now.Subtract(delayTimeOut_Coffee).TotalSeconds > 180 )
else if (DateTime.Now.Subtract(delayTimeOut_Coffee).TotalSeconds > 180 && bFirstTrig_Coffee == true)
{
bFirstTrig_Coffee = false;
if (morkTLebaiJC.IsHaveCoffeeCup)
@@ -219,7 +219,7 @@ namespace BPASmartClient.MorkTLebaiJC
bFirstTrig_Juice = true;
delayTimeOut_Juice = DateTime.Now;
}
if (DateTime.Now.Subtract(delayTimeOut_Juice).TotalSeconds > 30)
else if (DateTime.Now.Subtract(delayTimeOut_Juice).TotalSeconds > 30 && bFirstTrig_Juice == true)
{
bFirstTrig_Juice = false;
morkTLebaiJC.MakeJuiceEnd = true;
@@ -232,7 +232,7 @@ namespace BPASmartClient.MorkTLebaiJC
bFirstTrig_TeaWater = true;
delayTimeOut = DateTime.Now;
}
if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 50)
else if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 50 && bFirstTrig_TeaWater == true)
{
bFirstTrig_TeaWater = false;
morkTLebaiJC.MakeTeaEnd = true;


+ 19
- 0
BPASmartClient.MorkT_Show/BPASmartClient.MorkT_Show.csproj ファイルの表示

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

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

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" />
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" />
<ProjectReference Include="..\BPASmartClient.DRCoffee\BPASmartClient.DRCoffee.csproj" />
<ProjectReference Include="..\BPASmartClient.GSIceCream\BPASmartClient.GSIceCream.csproj" />
<ProjectReference Include="..\BPASmartClient.Juicer\BPASmartClient.Juicer.csproj" />
<ProjectReference Include="..\BPASmartClient.Lebai\BPASmartClient.Lebai.csproj" />
<ProjectReference Include="..\BPASmartClient.MCU\BPASmartClient.MCU.csproj" />
</ItemGroup>

</Project>

+ 851
- 0
BPASmartClient.MorkT_Show/Control_MORKJC_Show.cs ファイルの表示

@@ -0,0 +1,851 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Threading;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Threading.Tasks;
using BPASmartClient.Device;
using BPA.Message.Enum;
using BPA.Message;
using BPASmartClient.Helper;
using BPASmartClient.Model.咖啡机.Enum;
using BPASmartClient.Model;
using BPASmartClient.EventBus;
using static BPASmartClient.EventBus.EventBus;
using BPASmartClient.Message;
using BPASmartClient.Model.乐白机器人;
using BPASmartClient.Model.单片机;
using BPASmartClient.Model.PLC;

namespace BPASmartClient.MorkT_Show
{
/*
* 冰淇淋咖啡机组合套装
* 物料位置:
* 1:冰淇料
* 2:冰淇淋杯
* 5:咖啡
* 6:咖啡杯
* 9: 茶
* 10: 茶杯
*/
public class Control_MORKJC_Show : BaseDevice
{
private Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>();
//容器位置
private string holderLoc;
//主料位置
private string mainMaterialLoc;
public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKT; } }

GVL_MorkTLebaiJC morkTLebaiJC =new GVL_MorkTLebaiJC();
/// <summary>
/// 果汁机做法,true:热饮,false:冷饮
/// </summary>
private bool GuMake = false;
public override void DoMain()
{
if (Json<KeepDataBase>.Data.IsVerify)
{
IsHealth = true;
}
IsHealth = true;
serverInit();
DataParse();
ActionManage.GetInstance.Register(new Action<object>((o) => { SimOrder(o); }), "SimOrder");//模拟订单委托注册

}

private void serverInit()
{
EventBus.EventBus.GetInstance().Subscribe<MaterialDeliveryEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (@event == null) return;
if (@event is MaterialDeliveryEvent material)
{
orderMaterialDelivery = material.orderMaterialDelivery;
}
});
}
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)
{
var res = 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)
{
case GOODS_TYPE.COFFEE:
if (morkTLebaiJC.morkOrderPushesCoffee.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
{
morkTLebaiJC.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 (morkTLebaiJC.morkOrderPushesJuicer.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
{
morkTLebaiJC.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 (morkTLebaiJC.morkOrderPushesTea.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
{
morkTLebaiJC.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 (morkTLebaiJC.morkOrderPushesWater.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
{
morkTLebaiJC.morkOrderPushesWater.Enqueue(new OrderLocInfo()
{
SuborderId = order.MorkOrder.SuborderId,
BatchingId = res.BatchingId,
Loc = ushort.Parse(mainMaterialLoc),
GoodName = order.MorkOrder.GoodsName,
});
}
break;
case GOODS_TYPE.NEITHER:
DeviceProcessLogShow("未知的商品类型");
break;
}
}
}
}
});
}
/// <summary>
/// 将空杯放好到接饮料的地方的标志位
/// </summary>
private bool bFirstTrig_TeaWater = false;
private bool bFirstTrig_Coffee = false;
private bool bFirstTrig_Juice = false;
/// <summary>
/// 延迟的超时时间
/// </summary>
DateTime delayTimeOut_Water;
DateTime delayTimeOut_Coffee;
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;
}
else if (DateTime.Now.Subtract(delayTimeOut_Coffee).TotalSeconds > 180 && bFirstTrig_Coffee == true)
{
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;
}
else if (DateTime.Now.Subtract(delayTimeOut_Juice).TotalSeconds > 30 && bFirstTrig_Juice==true)
{
bFirstTrig_Juice = false;
morkTLebaiJC.MakeJuiceEnd = true;
}
}
if (morkTLebaiJC.IsHaveTeaWaterCup)
{
if (!bFirstTrig_TeaWater)
{
bFirstTrig_TeaWater = true;
delayTimeOut_Water = DateTime.Now;//开启接水信号后,记录当前时间
}
else if (DateTime.Now.Subtract(delayTimeOut_Water).TotalSeconds >= 50 && bFirstTrig_TeaWater == true)//接水超过50s后,启动接水完成标志,开启接水程序
{
bFirstTrig_TeaWater = false;
morkTLebaiJC.MakeTeaEnd = true;
}
}
DoCoffee();
DoJuice();
DoBoiledTea();
DoBoiledWater();
}

/// <summary>
/// 订单状态改变
/// </summary>
/// <param name="subid"></param>
/// <param name="oRDER_STATUS"></param>
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
{
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType });
}
/// <summary>
/// 验证商品是做的某种饮料
/// </summary>
/// <param name="batchingLoc">物料位置</param>
private GOODS_TYPE ValidateGoodsByBatching(string batchingLoc)
{
if (batchings.ContainsKey(batchingLoc))
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))
{
Thread.Sleep(5);
}
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)
{
if (peripheralStatus.ContainsKey(key))
{
if (peripheralStatus[key] != null)
{
return (T)(peripheralStatus[key]);
}
}
return default;
}
int[] devStatusBy = new int[2] { 0, 0 };
bool outCupCheck = false;//放纸杯位置有无判断
/// <summary>
/// 判断接咖啡的位置是否有杯子
/// </summary>
bool pickUpCoffeeHaveCup = false;
/// <summary>
/// 判断接果汁的位置是否有杯子
/// </summary>
bool pickUpJuiceHaveCup = false;
/// <summary>
/// 判断接开水的位置是否有杯子
/// </summary>
bool pickUpHotWaterHaveCup = false;
/// <summary>
/// 传感器的输入信号 0:无意义 1:有信号 2:无信号 3:信号不正确
/// </summary>
int bSensorInput;

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;
return bMake;
}
private bool IsMakeTeaWater()
{
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>
/// 做咖啡流程
/// </summary>
private void DoCoffee()
{
if (IsMakeCoffee())
{
if (morkTLebaiJC.morkOrderPushesCoffee.TryDequeue(out OrderLocInfo orderLoc))
{
PickUpCoffee();//接咖啡
morkTLebaiJC.IsHaveCoffeeCup = true;
}
}
else if(morkTLebaiJC.MakeCoffeeEnd)
{
PutCoffeeCup();
pickUpCoffeeHaveCup = false;
morkTLebaiJC.IsHaveCoffeeCup = false;
}
}
private void DoJuice()
{
if (IsMakeJuice())
{
if (morkTLebaiJC.morkOrderPushesJuicer.TryDequeue(out OrderLocInfo orderLoc))
{
PickUpJuicer();
morkTLebaiJC.IsHaveJuiceCup = true;
}
}
else if (morkTLebaiJC.MakeJuiceEnd)
{
Thread.Sleep(5000);//延迟五秒,防止接饮料口滴饮料
putJuice();
pickUpJuiceHaveCup = false;
morkTLebaiJC.IsHaveJuiceCup = false;
morkTLebaiJC.MakeJuiceEnd = false;
}
}
private void DoBoiledTea()
{
if (IsMakeTeaWater())
{
if (morkTLebaiJC.morkOrderPushesTea.TryDequeue(out OrderLocInfo orderLoc))
{
PickUpTea();
morkTLebaiJC.IsHaveTeaWaterCup = true;
}
}
else if(morkTLebaiJC.MakeTeaEnd)
{
PutWaterCup();
pickUpHotWaterHaveCup = false;
morkTLebaiJC.IsHaveTeaWaterCup = false ;
morkTLebaiJC.MakeTeaEnd = false;
}
}
private void DoBoiledWater()
{
if (IsMakeWater())
{
if (morkTLebaiJC.morkOrderPushesWater.TryDequeue(out OrderLocInfo orderLoc))
{
PickUpWater();
}
}
else if (morkTLebaiJC.MakeTeaEnd)
{
PutWaterCup();
pickUpHotWaterHaveCup = false;
morkTLebaiJC.IsHaveTeaWaterCup = false;
morkTLebaiJC.MakeTeaEnd = false;
}
}

#region 做咖啡流程
/// <summary>
/// 接咖啡
/// </summary>
private void PickUpCoffee()
{
//while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品
//{
// if (!outCupCheck)
// DeviceProcessLogShow("成品处有纸杯存在,请取走!!");
// outCupCheck = true;
//}
if (!pickUpCoffeeHaveCup)
{
outCupCheck = false;
OrderChange(morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{
DeviceProcessLogShow("咖啡杯取杯完成");
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_接咖啡);
Wait();
pickUpCoffeeHaveCup = true;
new DRCoffee_MakeCoffeeEvent() { DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水
}
else
{
DeviceProcessLogShow("取杯失败 回到初始位,请及时处理!!");
Sence(JuicerModel.JUICE2_初始位);
}
}
}
/// <summary>
/// 咖啡杯接好,放咖啡杯
/// </summary>
private void PutCoffeeCup()
{
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品
{
if (!outCupCheck)
DeviceProcessLogShow("成品处有纸杯存在,请取走!!");
outCupCheck = true;
}
outCupCheck = false;
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_放咖啡杯);
Wait();
OrderChange(morkTLebaiJC.morkOrderPushesCoffee.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
DeviceProcessLogShow("咖啡制作完成");
}
#endregion
#region 做开水流程
/// <summary>
/// 接开水
/// </summary>
private void PickUpWater()
{
#region 接水流程
if (!pickUpHotWaterHaveCup)
{
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();
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);
}
else
{
return;
}
}
#endregion
}
#endregion
#region 做茶流程
/// <summary>
/// 做茶
/// </summary>
private void PickUpTea()
{
#region 接茶流程
if (!pickUpHotWaterHaveCup)
{
OrderChange(morkTLebaiJC.morkOrderPushesTea.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
if (resultTakeCup == 1)
{
DeviceProcessLogShow("取茶杯完成");
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_接茶叶);
Wait();

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

Thread.Sleep(3000);
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
{
return;
}
}
#endregion
}
/// <summary>
/// 放水杯流程
/// </summary>
private void PutWaterCup()
{
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品
{
if (!outCupCheck)
DeviceProcessLogShow("成品处有纸杯存在,请取走!!");
outCupCheck = true;
}
outCupCheck = false;
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_放水杯);
Wait();
OrderChange(morkTLebaiJC.morkOrderPushesWater.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
DeviceProcessLogShow("茶水制作完成");
}

#endregion
#region 做果汁流程
/// <summary>
/// 果汁机控制信号
/// </summary>
private byte JuicerNum;
private int JuiceCH;
/// <summary>
/// 接果汁
/// </summary>
private void PickUpJuicer()
{
#region 接果汁流程
if (!pickUpJuiceHaveCup)
{
OrderChange(morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
int resultTakeCup = takeCup();
JuiceCH = int.Parse(mainMaterialLoc);
if (resultTakeCup == 1)
{
switch (JuiceCH)
{
case 52:
if (GuMake)
JuicerNum = 0x00;
else
JuicerNum = 0x01;
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_接果汁1);
Wait();
break;
case 53:
if (GuMake)
JuicerNum = 0x02;
else
JuicerNum = 0x03;
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_接果汁2);
Wait();
break;
case 54:
if (GuMake)
JuicerNum = 0x04;
else
JuicerNum = 0x05;
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_接果汁3);
Wait();
break;
case 55:
if (GuMake)
JuicerNum = 0x06;
else
JuicerNum = 0x07;
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_接果汁4);
Wait();
break;
default:
JuicerNum = 0x00;
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_接果汁1);
Wait();
break;
}
new WriteJuicer() { Value = JuicerNum }.Publish();
pickUpJuiceHaveCup = true;
}
else
{
return;
}
}
#endregion
}
/// <summary>
/// 取接好果汁杯
/// </summary>
private void putJuice()
{
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品
{
if (!outCupCheck)
DeviceProcessLogShow("成品处有纸杯存在,请取走!!");
outCupCheck = true;
}
outCupCheck = false;
switch (JuiceCH)
{
case 52:
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_放果汁杯1);
Wait();
break;
case 53:
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_放果汁杯2);
Wait();
break;
case 54:
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_放果汁杯3);
Wait();
break;
case 55:
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_放果汁杯4);
Wait();
break;
default:
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_放果汁杯1);
Wait();
break;
}
OrderChange(morkTLebaiJC.morkOrderPushesJuicer.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
DeviceProcessLogShow("果汁制作完成");
}
#endregion

/// <summary>
/// 取杯的次数
/// </summary>
private int nCnt;
/// <summary>
/// 传感器的检测次数
/// </summary>
private int checkCnt;
/// <summary>
/// 取杯流程
/// </summary>
/// <returns>0:无意义,1:取杯成功 2:取杯失败</returns>
private int takeCup()
{
try
{
nCnt = 0;
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_初始位);
Wait();

new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_取纸杯);
Wait();
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_取纸杯检测);
Wait();
nCnt++;
Thread.Sleep(2000);
while (checkCnt < 3)
{
if (!GetStatus<bool>("GetInput"))
{
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_再检测);
Wait();
}
else
{
break;
}
checkCnt++;
}
checkCnt = 0;
while (!GetStatus<bool>("GetInput")) //读取传感器的值
{
if (nCnt > 3)
{
nCnt = 0;
DeviceProcessLogShow("三次取杯失败,回原点");
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_检测位回原点);
Wait();
return 2;
}
else
{
nCnt++;
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_二次取杯);
Wait();
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_取纸杯检测);
Wait();
checkCnt = 0;
while (checkCnt < 3)
{
if (!GetStatus<bool>("GetInput"))
{
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish();
Sence(JuicerModel.JUICE2_再检测);
Wait();
}
else
{
checkCnt = 0;
return 1;
}
checkCnt++;
}
}
Thread.Sleep(1000);
}
}
catch (Exception ex)
{
DeviceProcessLogShow(ex.ToString());
}
return 2;
}
/// <summary>
/// 放杯
/// </summary>
/// <returns>0:无意义 1:放杯成功 2:执行失败(传感器还有信号) 3:放杯异常</returns>
private int putCup()
{
try
{
if (GetStatus<bool>("RobotValue1")) return 2;
Sence(JuicerModel.JUICE_放杯);
Wait();
new LebaiRobot_SetValueEvent() { RobotSetValue = 1 }.Publish();
Sence(JuicerModel.JUICE_放杯检测);
Wait();
new LebaiRobot_SetValueEvent() { RobotSetValue = 1 }.Publish();
if (GetStatus<bool>("GetInput2"))
{
return 1;
}
else
{
return 3;
}
}
catch (Exception ex)
{
DeviceProcessLogShow(ex.ToString());
return 0;
}
}
public void SimOrder<T>(T simOrder)
{
}
#region PLC 控制函数

private void WritePLCData(string address, object value)
{
EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value });
}

public override void Stop()
{
}

public override void ReadData()
{

}

public override void ResetProgram()
{
}
public override void SimOrder()
{
}
}
}

+ 76
- 0
BPASmartClient.MorkT_Show/GVL_MorkTLebeiJC.cs ファイルの表示

@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.Device;
using System.Collections.Concurrent;

namespace BPASmartClient.MorkT_Show
{
public class GVL_MorkTLebaiJC : 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_Show/OrderLocInfo.cs ファイルの表示

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

namespace BPASmartClient.MorkT_Show
{
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; }
}
}

+ 152
- 0
BPASmartClient.MorkT_Show/PolymerBatching.cs ファイルの表示

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

namespace BPASmartClient.MorkT_Show
{
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 },
{"61",GOODS_TYPE.WATER },
{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;
// }
//}
}
}

+ 3
- 3
BPASmartClient.Morkt.JAKA.JC/Control_MORKJC.cs ファイルの表示

@@ -190,7 +190,7 @@ namespace BPASmartClient.MorktJAKAJC
bFirstTrig_Coffee = true;
delayTimeOut_Coffee = DateTime.Now;
}
if (DateTime.Now.Subtract(delayTimeOut_Coffee).TotalSeconds > 180)
else if (DateTime.Now.Subtract(delayTimeOut_Coffee).TotalSeconds > 180 && bFirstTrig_Coffee == true)
{
bFirstTrig_Coffee = false;
if (morkTJakaJC.IsHaveCoffeeCup)
@@ -218,7 +218,7 @@ namespace BPASmartClient.MorktJAKAJC
bFirstTrig_Juice = true;
delayTimeOut_Juice = DateTime.Now;
}
if (DateTime.Now.Subtract(delayTimeOut_Juice).TotalSeconds > 30)
else if (DateTime.Now.Subtract(delayTimeOut_Juice).TotalSeconds > 30 && bFirstTrig_Juice == true)
{
bFirstTrig_Juice = false;
morkTJakaJC.MakeJuiceEnd = true;
@@ -231,7 +231,7 @@ namespace BPASmartClient.MorktJAKAJC
bFirstTrig_TeaWater = true;
delayTimeOut = DateTime.Now;
}
if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 50)
else if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 50 && bFirstTrig_TeaWater == true)
{
bFirstTrig_TeaWater = false;
morkTJakaJC.MakeTeaEnd = true;


+ 24
- 1
SmartClient.sln ファイルの表示

@@ -98,7 +98,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DosingSystem", "DosingSyste
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTJuicer", "BPASmartClient.MorkTJuicer\BPASmartClient.MorkTJuicer.csproj", "{724087A3-E7E7-4494-B844-414FF5CD1D40}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.AGV", "BPASmartClient.AGV\BPASmartClient.AGV.csproj", "{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.AGV", "BPASmartClient.AGV\BPASmartClient.AGV.csproj", "{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MorkT_Show", "BPASmartClient.MorkT_Show\BPASmartClient.MorkT_Show.csproj", "{3653724D-3683-4722-B978-EB88DD4AE5DB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -914,6 +916,26 @@ Global
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}.Release|x64.Build.0 = Release|Any CPU
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}.Release|x86.ActiveCfg = Release|Any CPU
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}.Release|x86.Build.0 = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|ARM.ActiveCfg = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|ARM.Build.0 = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|ARM64.Build.0 = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|x64.ActiveCfg = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|x64.Build.0 = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|x86.ActiveCfg = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Debug|x86.Build.0 = Debug|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|Any CPU.Build.0 = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|ARM.ActiveCfg = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|ARM.Build.0 = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|ARM64.ActiveCfg = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|ARM64.Build.0 = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x64.ActiveCfg = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x64.Build.0 = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x86.ActiveCfg = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -959,6 +981,7 @@ Global
{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
{724087A3-E7E7-4494-B844-414FF5CD1D40} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625}
{3653724D-3683-4722-B978-EB88DD4AE5DB} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC}


読み込み中…
キャンセル
保存