using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using HBLConsole.Interface; using HBLConsole.Communication; using System.Threading; using System.Collections.Concurrent; using HBLConsole.Model; using HBLConsole.Attributes; namespace HBLConsole.MORKD { public class GVL_MORKD : IGvl { #region 上位机到 --> PLC 控制 /// /// 初始化控制 /// public void InitControl() { ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, true); //await Task.Delay(1000); //ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, false); } /// /// 机器人取面启动 /// /// 煮面篮位置 /// /// 转台位置 public void RBTakeNoodleStart(ushort CookNoodleLoc, ushort TurntableLoc) { ModbusTcpHelper.GetInstance.Write(101, WriteType.HoldingRegisters, CookNoodleLoc); ModbusTcpHelper.GetInstance.Write(100, WriteType.HoldingRegisters, TurntableLoc); ModbusTcpHelper.GetInstance.Write(321, WriteType.Coils, true); } /// /// 机器人出面启动 /// /// 出面位置 /// 倒面至碗位置 public void RBOutNoodleStart(ushort OutNoodleLoc, ushort BowlLoc) { ModbusTcpHelper.GetInstance.Write(102, WriteType.HoldingRegisters, OutNoodleLoc); ModbusTcpHelper.GetInstance.Write(103, WriteType.HoldingRegisters, BowlLoc); ModbusTcpHelper.GetInstance.Write(322, WriteType.Coils, true); } /// /// 机器人取浇头启动 /// /// 浇头位置 /// 破口位置 public void RBTakeSoupStart(ushort SoupLoc, ushort CutLoc) { AllowTakeSoup = true; ModbusTcpHelper.GetInstance.Write(105, WriteType.HoldingRegisters, SoupLoc); ModbusTcpHelper.GetInstance.Write(106, WriteType.HoldingRegisters, CutLoc); ModbusTcpHelper.GetInstance.Write(323, WriteType.Coils, true); } /// /// 加热完成取浇头启动 /// /// 取浇头完成 /// 倒浇头至碗位置 /// 放面至出餐口位置 public void HeatCompleteTakeSoupStart(ushort SoupLoc, ushort BowlLoc, ushort OutMealLoc) { AllowTakeSoup = true; ModbusTcpHelper.GetInstance.Write(108, WriteType.HoldingRegisters, SoupLoc); ModbusTcpHelper.GetInstance.Write(109, WriteType.HoldingRegisters, BowlLoc); ModbusTcpHelper.GetInstance.Write(110, WriteType.HoldingRegisters, OutMealLoc); ModbusTcpHelper.GetInstance.Write(324, WriteType.Coils, true); } /// /// 转台启动 /// /// 转台位置 public void TurntableStart(ushort TurntableLoc) { this.TurntableLoc = TurntableLoc; TurntableInterlock = true; TurntableLocLists.Add(TurntableLoc); ModbusTcpHelper.GetInstance.Write(100, WriteType.HoldingRegisters, TurntableLoc); ModbusTcpHelper.GetInstance.Write(325, WriteType.Coils, true); } /// /// 下碗启动 /// /// 启动轴位置 /// 碗类型位置 public void DropBowlStart(ushort AxisLoc, ushort BowlType) { ModbusTcpHelper.GetInstance.Write(113, WriteType.HoldingRegisters, AxisLoc); ModbusTcpHelper.GetInstance.Write(114, WriteType.HoldingRegisters, BowlType); } /// /// 取面完成信号复位 /// public void TakeNoodleCompleteReset() { ModbusTcpHelper.GetInstance.Write(1122, WriteType.Coils, false); } /// /// 出面完成信号复位 /// public void PutNoodleTakeMealCompleteReset() { ModbusTcpHelper.GetInstance.Write(1148, WriteType.Coils, false); } /// /// 取浇头完成信号复位 /// public void TakeSoupCompleteReset() { ModbusTcpHelper.GetInstance.Write(1147, WriteType.Coils, false); } #endregion #region PLC --> 上位机 /// /// 初始化完成 /// PLC --> M100.0 /// ModbusTcp --> 1120 /// [Circuit(new string[] { "允许运行", "转台控制" }, "初始化完成")] public bool InitComplete { get; set; } /// /// 转台到位 /// PLC --> M100.1 /// ModbusTcp --> 1121 /// [Circuit("取面任务", "转台到位检测")] public bool TurntableInPlace { get; set; } /// /// 机器人取面完成 /// PLC --> M100.2 /// ModbusTcp --> 1122 /// public bool RBTakeNoodleComplete { get; set; } /// /// 轴空闲 /// PLC --> M100.3 -- M100.04 /// ModbusTcp --> 1123 -- 1124 /// public bool[] AxisIdle { get; set; } = new bool[2] { false, false }; /// /// 轴允许倒面 /// PLC --> M100.5 -- M100.06 /// ModbusTcp --> 1125 -- 1126 /// public bool[] AxisAllowInvertedNoodle { get; set; } = new bool[2] { false, false }; /// /// 轴允许倒浇头 /// PLC --> M100.7 -- M101.00 /// ModbusTcp --> 1127 -- 1128 /// public bool[] AxisAllowInvertedSoup { get; set; } = new bool[2] { false, false }; /// /// 浇头加热完成 /// PLC --> M101.1 -- M101.02 /// ModbusTcp --> 1129 -- 1130 /// public bool[] SoupHeatComplete { get; set; } = new bool[2] { false, false }; /// /// 煮面篮空闲 /// PLC --> M101.3 -- M102.0 /// ModbusTcp --> 1131 -- 1136 /// public bool[] CookNoodleBasketIdle { get; set; } = new bool[6] { false, false, false, false, false, false }; /// /// 煮面完成 /// PLC --> M102.1 -- M102.6 /// ModbusTcp --> 1137 -- 1142 /// public bool[] CookNoodleComplete { get; set; } = new bool[6] { false, false, false, false, false, false }; /// /// 取面机器人空闲状态 /// PLC --> M102.7 /// ModbusTcp --> 1143 /// [Circuit(new string[] { "取面任务", "出餐控制" }, "取面机器人空闲")] public bool TakeNoodleRobotIdle { get; set; } /// /// 取浇头机器人空闲状态 /// PLC --> M103.0 /// ModbusTcp --> 1144 /// [Circuit(new string[] { "取浇头控制", "出浇头控制" }, "取浇头机器人空闲状态")] public bool TakeSoupRobotIdle { get; set; } /// /// 破口机构空闲 /// PLC --> M103.1 -- M103.02 /// ModbusTcp --> 1145 -- 1146 /// public bool[] BreakMechanismIdle { get; set; } = new bool[2] { false, false }; /// /// 取浇头完成 /// PLC --> M103.3 /// ModbusTcp --> 1147 /// public bool TakeSoupComplete { get; set; } /// /// 放面至取餐口完成 /// PLC --> M103.4 /// ModbusTcp --> 1148 /// public bool PutNoodleTakeMealComplete { get; set; } /// /// 设备初始化中 /// PLC --> M103.5 /// ModbusTcp --> 1149 /// public bool Initing { get; set; } /// /// 转台位置 /// PLC -> VW372 /// ModbusTcp -> 286 /// public ushort TurntableFeedbackloc { get; set; } #endregion #region 传感器状态 /// /// 转台下限位 /// PLC --> M120.0 /// ModbusTcp --> 1200 /// public bool TurntableLowerLimit { get; set; } /// /// 转台上限位 /// PLC --> M120.1 /// ModbusTcp --> 1201 /// public bool TurntableUpLimit { get; set; } /// /// 浇头缺料 /// PLC --> M120.2 -- M120.6 /// ModbusTcp --> 1202 -- 1206 /// public bool[] SoupMaterialShortage { get; set; } = new bool[5] { false, false, false, false, false }; /// /// 出餐口检测 /// PLC --> M120.7 -- M121.1 /// ModbusTcp --> 1207 -- 1209 /// public bool[] OutMealDetect { get; set; } = new bool[3] { false, false, false }; /// /// 温度到达 /// PLC --> M121.2 /// ModbusTcp --> 1210 /// public bool TemperatureReached { get; set; } #endregion #region 内部变量 /// /// 允许倒浇头 /// [Circuit(new string[] { "出浇头控制" }, "允许倒浇头", new bool[] { true })] public bool AllowPutSoup { get; set; } /// /// 允许取浇头 /// [Circuit(new string[] { "取浇头控制", "出浇头控制" }, "允许取浇头", new bool[] { true, true })] public bool AllowTakeSoup { get; set; } /// /// 放面位置 /// public int PutNoodleLoc { get; set; } /// /// 轴空闲位置 /// public int AxisIdleIndex { get; set; } /// /// 轴空闲互锁位置 /// public int AxisIdleLockIndex { get; set; } /// /// 转台位置 /// public ushort TurntableLoc { get; set; } /// /// 机器人任务互锁信号 /// [Circuit(new string[] { "取面任务", "出餐控制" }, "机器人任务互锁", new bool[] { true, false })] public bool RobotTaskInterlock { get; set; } /// /// 取碗互锁信号 /// public bool TakeBowlInterlock { get; set; } /// /// 取面互锁信号 /// [Circuit(new string[] { "出餐控制" }, "取面互锁信号", new bool[] { true })] public bool TakeNoodleInterlock { get; set; } /// /// 出面中 /// [Circuit(new string[] { "取面任务" }, "出面中", new bool[] { true })] public bool OutNoodleing { get; set; } /// /// 允许取面 /// [Circuit(new string[] { "转台控制", "取面任务" }, "允许取面", new bool[] { true, false })] public bool AllowTakeNoodle { get; set; } /// /// 转台互锁信号 /// [Circuit(new string[] { "转台控制" }, "转台互锁信号", new bool[] { true })] public bool TurntableInterlock { get; set; } /// /// 轴空闲互锁 /// public bool[] AxisIdleLock { get; set; } = new bool[2] { false, false }; /// /// 转台位置轮询 /// public List TurntableLocLists = new List(); /// /// 允许运行 /// [Circuit(new string[] { "取面任务", "取浇头控制" }, "允许运行")] public bool AllowRun { get; set; } /// /// 取面位置队列 /// public ConcurrentQueue RBTakeNoodleTask { get; set; } = new ConcurrentQueue(); /// /// 取浇头任务队列 /// public ConcurrentQueue TakeSoupTask { get; set; } = new ConcurrentQueue(); /// ///取碗任务队列 /// public ConcurrentQueue TakeBowlTask { get; set; } = new ConcurrentQueue(); /// /// 煮面完成任务队列 /// public ConcurrentQueue CookNoodleCompleteTask { get; set; } = new ConcurrentQueue(); #endregion #region 内部变量 --> 订单ID记录 /// /// 煮面口对应的订单ID /// public string[] CookNodelId { get; set; } = new string[6] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, }; /// /// 出餐口订单ID /// public string[] OutMealId { get; set; } = new string[3] { string.Empty, string.Empty, string.Empty }; /// /// 轴允许倒面 id /// public string[] AxisAllowInvertedNoodleID { get; set; } = new string[2] { string.Empty, string.Empty }; /// /// 轴允许倒浇头 id /// public string[] AxisAllowInvertedSoupID { get; set; } = new string[2] { string.Empty, string.Empty }; /// /// 浇头加热完成 id /// public string[] SoupHeatCompleteID { get; set; } = new string[2] { string.Empty, string.Empty }; #endregion } }