using BPA.Message;
using BPA.Message.Enum;
using BPASmartClient.Device;
using BPASmartClient.EventBus;
using BPASmartClient.Helper;
using BPASmartClient.Message;
using BPASmartClient.Model;
using BPASmartClient.Model.PLC;
using BPA.Models;
using static BPASmartClient.EventBus.EventBus;
using BPASmartClient.Model.小炒机;
using BPASmartClient.MorkF.Model;
using System.Text;
using System.Collections.Concurrent;
namespace BPASmartClient.MorkF
{
public class Control_MorkF : BaseDevice
{
///
/// while循环最大sleep次数
///
private const int sleepCount = 20;
///
/// while循环每次sleep时间
///
private const int sleepTime = 500;
///
/// 初始化炒锅数量
///
private int count = 2;
//当前炒锅,默认为1号炒锅
private int fryIndex = 0;
public override DeviceClientType DeviceType => DeviceClientType.MORKCS;
public AutoResetEvent minorReset = new AutoResetEvent(false);
public AutoResetEvent mainReset = new AutoResetEvent(false);
Dictionary morkFs = new Dictionary();//全局对象声明
///
/// 小炒菜单集合
///
public static List LocalstirFryGoods = new List();
///
/// 待炒小炒队列
///
private ConcurrentQueue StirFryGoodsQuenes = new ConcurrentQueue();
private const String striConst = "炒锅{0}炒制{1}线程";
///
/// 当前炒制菜品
///
private OrderLocInfo nowStirFryGood = null;
List resultorder = new List();//调试变量
///
/// 入口
///
public override void DoMain()
{
WriteControl("VD836", 0);
WriteControl("VD840", 0);
Thread.Sleep(400);
WriteControl("M0.0", true);
for (int i = 0;i< count;i++)
{
morkFs.Add(i, new GVL_MorkF());
DataParse(i);//数据解析
}
CommandRegist();//调试
ServerInit();
DeviceProcessLogShow("MORKF 设备初始化完成");
ReadData();
}
#region 调试代码
public void CommandRegist()
{
#region 设备控制
ActionManage.GetInstance.Register(PLCInite, "InitCommand");
ActionManage.GetInstance.Register(StartOrder, "StartOrder");
ActionManage.GetInstance.Register(StartLocalOrder, "StartLocalOrder");
ActionManage.GetInstance.Register(StopLocalOrder, "StopLocalOrder");
#endregion
#region 菜品库
ActionManage.GetInstance.Register(FoodLibInit, "FoodLibInit");
ActionManage.GetInstance.Register(Electromagnetism, "Electromagnetism");
ActionManage.GetInstance.Register(GetDistance_1, "GetDistance_1");
ActionManage.GetInstance.Register(GetDistance_2, "GetDistance_2");
ActionManage.GetInstance.Register(GetDistance_3, "GetDistance_3");
ActionManage.GetInstance.Register(PawTurnFront, "PawTurnFront");
ActionManage.GetInstance.Register(PawTurnBack, "PawTurnBack");
ActionManage.GetInstance.Register(SetArmPosition, "SetArmPosition");
#endregion
//ActionManage.GetInstance.Register(PLCInite, "InitCommand");
#region 配料控制
ActionManage.GetInstance.Register(new Action