////#define test
//using BPA.Message;
//using HBLConsole.Communication;
//using HBLConsole.Factory;
//using HBLConsole.Interface;
//using HBLConsole.Model;
//using HBLConsole.Service;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading;
//using System.Threading.Tasks;
//using BPA.Message.Enum;
//using BPA.Models;
//namespace HBLConsole.Business.Devices
//{
// public class MORKS : IControl
// {
// private volatile static MORKS _Instance;
// public static MORKS GetInstance => _Instance ?? (_Instance = new MORKS());
// private MORKS() { }
// public GVL.MORKS mORKS { get; set; } = new GVL.MORKS();
// public void Init()
// {
// //模拟订单
// SimOrder();
// Test();
// }
// public void ConnectOk()
// {
// WriteRecipeBoms();
// ReadData();
// Main();
// //ResetProgram();
// MessageLog.GetInstance.Show("MORKS 设备初始化完成");
// }
// ///
// /// 测试程序
// ///
// private void Test()
// {
//#if test
// ThreadManagerment.GetInstance.StartLong(new Action(() =>
// {
// while (Json.GetInstance.Base.morkOrderPushes.Count > 0)
// {
// var result = Json.GetInstance.Base.morkOrderPushes.ElementAt(0);
// SimpleFactory.GetInstance.OrderChanged(result.OrderPush.SuborderId, ORDER_STATUS.COOKING);
// MessageLog.GetInstance.Show($"{result.OrderPush.GoodsName},{ORDER_STATUS.COOKING}");
// Thread.Sleep(5000);
// SimpleFactory.GetInstance.OrderChanged(result.OrderPush.SuborderId, ORDER_STATUS.COMPLETED_COOK);
// MessageLog.GetInstance.Show($"{result.OrderPush.GoodsName},{ORDER_STATUS.COMPLETED_COOK}");
// Thread.Sleep(5000);
// SimpleFactory.GetInstance.OrderChanged(result.OrderPush.SuborderId, ORDER_STATUS.COMPLETED_TAKE);
// MessageLog.GetInstance.Show($"{result.OrderPush.GoodsName},{ORDER_STATUS.COMPLETED_TAKE}");
// Thread.Sleep(5000);
// Json.GetInstance.Base.morkOrderPushes.RemoveAt(0);
// }
// Thread.Sleep(500);
// }), "test");
//#endif
// }
// private void Readbool(ushort startAddress, ushort len, Action action)
// {
// object result;
// result = ModbusTcpHelper.GetInstance.Read(startAddress, ReadType.Coils, len);
// if (result != null)
// {
// if (result is bool[] bools)
// {
// if (bools.Length == len)
// {
// action(bools);
// }
// }
// }
// }
// ///
// /// 复位程序
// ///
// private void ResetProgram()
// {
// ThreadManagerment.GetInstance.StartLong(new Action(() =>
// {
// if (RTrig.GetInstance("ResetProgram").Start(mORKS.DeviceIniting))
// {
// ThreadManagerment.GetInstance.StopTask("MainTask", new Action(() =>
// {
// mORKS.AllowRun = false;
// TakeBowlId = string.Empty;
// IngredientsCompleteId = string.Empty;
// CookNodelId = new string[6] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, };
// mORKS.RobotTaskInterlock = false;
// OutMealId = string.Empty;
// mORKS.TakeBowlInterlock = false;
// mORKS.TakeNoodleInterlock = false;
// mORKS.OutNoodleing = false;
// Main();
// }));
// }
// Thread.Sleep(10);
// }), "ResetProgram");
// }
// ///
// /// 数据读取
// ///
// public void ReadData()
// {
// ThreadManagerment.GetInstance.StartLong(new Action(() =>
// {
// Readbool(323, 3, new Action((bools) =>
// {
// mORKS.RobotTakeNoodle = bools[0];
// mORKS.RobotOutMeal = bools[1];
// mORKS.MoveTurntable = bools[2];
// }));
// Readbool(1120, 16, new Action((bools) =>
// {
// mORKS.InitComplete = bools[0];
// mORKS.TakeBowlIdle = bools[1];
// mORKS.TemperatureReached = bools[2];
// mORKS.AllowFallNoodle = bools[3];
// mORKS.RbTakeNoodleComplete = bools[4];
// mORKS.RbFallNoodleComplete = bools[5];
// mORKS.RbOutMealComplete = bools[6];
// mORKS.RobotIdle = bools[7];
// mORKS.TakeMealDetect = bools[8];
// mORKS.MissingBowl = bools[9];
// mORKS.DeviceIniting = bools[10];
// mORKS.TurntableLowerLimit = bools[11];
// mORKS.MissingBowlSignal2 = bools[12];
// mORKS.TurntableUpLimit = bools[13];
// mORKS.TurntableMoveInPlace = bools[15];
// }));
// Readbool(1136, 6, new Action((bools) =>
// {
// for (int i = 0; i < 6; i++)
// {
// mORKS.NoodleCookerStatus[i] = bools[i];
// }
// }));
// Readbool(1144, 6, new Action((bools) =>
// {
// for (int i = 0; i < 6; i++)
// {
// mORKS.CookNoodlesComplete[i] = bools[i];
// }
// }));
// Thread.Sleep(500);
// }), "ReadPLCData");
// }
// public ushort NoodleLoc { get; set; }
// public ushort BowlLoc { get; set; }
// public void SimOrder()
// {
// ActionManagerment.GetInstance.Register(new Action