@@ -0,0 +1,21 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace HBLConsole.Abstract | |||
{ | |||
public abstract class ControlAbstract | |||
{ | |||
public abstract void Init(); | |||
public Action ReadDataAction { get; set; } | |||
public Action MainAction { get; set; } | |||
public abstract void ReadData(); | |||
public abstract void Main(); | |||
public abstract void ResetProgram(); | |||
} | |||
} |
@@ -13,7 +13,7 @@ using BPA.Utility; | |||
using Newtonsoft.Json; | |||
using HBLConsole.Communication; | |||
namespace HBLConsole.Business.MessageServer | |||
namespace HBLConsole.Business.AbstractServer | |||
{ | |||
public class Base : AbstractMessageServer | |||
{ | |||
@@ -109,33 +109,8 @@ namespace HBLConsole.Business.MessageServer | |||
MessageLog.GetInstance.Show("接收到辅料信息"); | |||
ActionManage.GetInstance.Send("recipeBom"); | |||
} | |||
//WritePlcData(); | |||
} | |||
/// <summary> | |||
/// 写配方数据到PLC | |||
/// </summary> | |||
//private void WritePlcData() | |||
//{ | |||
// return; | |||
// //写配方数据到PLC | |||
// List<ushort> recipeBoms = new List<ushort>(); | |||
// foreach (var item in Json<BatchingInfoPar>.Data.recipeBoms.RecipeIds) | |||
// { | |||
// foreach (var rec in item.Recipes) | |||
// { | |||
// recipeBoms.Add((ushort)rec); | |||
// } | |||
// } | |||
// if (recipeBoms.Count > 0) | |||
// { | |||
// if (ModbusTcpHelper.GetInstance.Write(1100, WriteType.HoldingRegisters, recipeBoms.ToArray())) | |||
// { | |||
// MessageLog.GetInstance.Show("成功写入配方数据"); | |||
// } | |||
// } | |||
//} | |||
/// <summary> | |||
/// 订单状态改变 | |||
/// </summary> |
@@ -0,0 +1,61 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using HBLConsole.Abstract; | |||
using HBLConsole.Service; | |||
using HBLConsole.Factory; | |||
using HBLConsole.Model; | |||
namespace HBLConsole.Business.AbstractServer | |||
{ | |||
public class ControlBase : ControlAbstract | |||
{ | |||
public override void Init() | |||
{ | |||
Main(); | |||
ReadData(); | |||
ResetProgram(); | |||
} | |||
public override void Main() | |||
{ | |||
ThreadManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
if (MainAction != null) MainAction(); | |||
Thread.Sleep(100); | |||
}), "MainTask"); | |||
} | |||
public override void ReadData() | |||
{ | |||
ThreadManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
if (ReadDataAction != null) ReadDataAction(); | |||
Thread.Sleep(100); | |||
}), "ReadPLCData"); | |||
} | |||
public override void ResetProgram() | |||
{ | |||
ThreadManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
if (RTrig.GetInstance("ResetProgram").Start(DeviceData.Initing)) | |||
{ | |||
ThreadManage.GetInstance.StopTask("MainTask", new Action(() => | |||
{ | |||
ThreadManage.GetInstance.StopTask("ReadPLCData", new Action(() => | |||
{ | |||
SimpleFactory.GetInstance.CreateGvl(); | |||
ReadData(); | |||
Main(); | |||
})); | |||
})); | |||
} | |||
Thread.Sleep(10); | |||
}), "ResetProgram"); | |||
} | |||
} | |||
} |
@@ -15,7 +15,7 @@ namespace HBLConsole.Factory | |||
private volatile static SimpleFactory _Instance; | |||
public static SimpleFactory GetInstance => _Instance ?? (_Instance = new SimpleFactory()); | |||
private SimpleFactory() { ActionManage.GetInstance.Register(new Action(() => { GetInterfaceData(); }), "ResetProgram"); } | |||
//private SimpleFactory() { ActionManage.GetInstance.Register(new Action(() => { GetInterfaceData(); }), "ResetProgram"); } | |||
public AbstractMessageServer GetAbsMessageServer => _GetAbsMessageServer ?? (_GetAbsMessageServer = GetAbstractMessageServer()); | |||
private AbstractMessageServer _GetAbsMessageServer; | |||
@@ -23,6 +23,7 @@ namespace HBLConsole.Factory | |||
private string DeviceType => GeneralConfig.DeviceType.ToString(); | |||
private object debugControl; | |||
private string GvlName = string.Empty; | |||
public void MqttMessage(IMessage message) | |||
{ | |||
@@ -59,19 +60,43 @@ namespace HBLConsole.Factory | |||
return res; | |||
} | |||
public void CreateGvl() | |||
{ | |||
string NameSpace = $"HBLConsole.{DeviceType}"; | |||
Type type = Assembly.Load(NameSpace).GetType($"{NameSpace}.GVL_{DeviceType}"); | |||
var tempGvl = Activator.CreateInstance(type); | |||
var FieldValue = control.GetType().GetField(GvlName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public); | |||
FieldValue?.SetValue(control, null); | |||
FieldValue?.SetValue(control, tempGvl); | |||
GetInterfaceData(); | |||
} | |||
private AbstractMessageServer GetAbstractMessageServer() | |||
{ | |||
string NameSpace = "HBLConsole.Business"; | |||
Type type = Assembly.Load(NameSpace).GetType($"{NameSpace}.MessageServer.{DeviceType}"); | |||
Type type = Assembly.Load(NameSpace).GetType($"{NameSpace}.AbstractServer.{DeviceType}"); | |||
if (type == null) | |||
type = Assembly.Load(NameSpace).GetType($"{NameSpace}.MessageServer.Base"); | |||
type = Assembly.Load(NameSpace).GetType($"{NameSpace}.AbstractServer.Base"); | |||
return Activator.CreateInstance(type) as AbstractMessageServer; | |||
} | |||
private void GetControlBase() | |||
{ | |||
string NameSpace = "HBLConsole.Business"; | |||
Type type = Assembly.Load(NameSpace).GetType($"{NameSpace}.AbstractServer.ControlBase"); | |||
controlAbstract = Activator.CreateInstance(type) as ControlAbstract; | |||
if (controlAbstract != null) | |||
{ | |||
controlAbstract.MainAction = new Action(() => { control?.Main(); }); | |||
controlAbstract.ReadDataAction = new Action(() => { control?.ReadData(); }); | |||
controlAbstract.Init(); | |||
} | |||
} | |||
public IControl control { get; set; } | |||
public IGvl GVL { get; set; } | |||
public IAlarm Alarm { get; set; } | |||
public ControlAbstract controlAbstract { get; set; } | |||
/// <summary> | |||
/// 设备初始化 | |||
@@ -91,6 +116,7 @@ namespace HBLConsole.Factory | |||
ActionManage.GetInstance.Register(new Action<object>((o) => { control?.SimOrder(o); }), "SimOrder"); | |||
ActionManage.GetInstance.Register(new Action<object>((o) => { control?.IotBroadcast(o); }), "IotBroadcast"); | |||
ConnectHelper.GetInstance.Init(); | |||
GetControlBase(); | |||
} | |||
@@ -115,6 +141,8 @@ namespace HBLConsole.Factory | |||
if (inters.Name.Equals("IGvl")) | |||
{ | |||
GVL = (item.GetValue(control)) as IGvl; | |||
GvlName = item.Name; | |||
} | |||
else if (inters.Name.Equals("IAlarm")) | |||
{ | |||
@@ -9,7 +9,6 @@ namespace HBLConsole.Interface | |||
public interface IControl | |||
{ | |||
void Main(); | |||
//object GetT(); | |||
void Init(); | |||
void ReadData(); | |||
void SimOrder<T>(T simOrder); | |||
@@ -22,7 +22,7 @@ namespace HBLConsole.MORKD | |||
{ | |||
Main(); | |||
ReadData(); | |||
ResetProgram(); | |||
//ResetProgram(); | |||
} | |||
public void DataParse<T>(T order) | |||
@@ -63,119 +63,121 @@ namespace HBLConsole.MORKD | |||
}), "InitCommand"); | |||
} | |||
bool Initing = false; | |||
//bool Initing = false; | |||
//bool Initing { get; set; } | |||
/// <summary> | |||
/// 复位程序 | |||
/// </summary> | |||
private void ResetProgram() | |||
{ | |||
ThreadManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
if (RTrig.GetInstance("ResetProgram").Start(Initing)) | |||
{ | |||
ThreadManage.GetInstance.StopTask("MainTask", new Action(() => | |||
{ | |||
ThreadManage.GetInstance.StopTask("ReadPLCData", new Action(() => | |||
{ | |||
mORKD = null; | |||
mORKD = new GVL_MORKD(); | |||
ActionManage.GetInstance.Send("ResetProgram"); | |||
ReadData(); | |||
Main(); | |||
})); | |||
})); | |||
} | |||
Thread.Sleep(10); | |||
}), "ResetProgram"); | |||
} | |||
//private void ResetProgram() | |||
//{ | |||
// ThreadManage.GetInstance.StartLong(new Action(() => | |||
// { | |||
// if (RTrig.GetInstance("ResetProgram").Start(Initing)) | |||
// { | |||
// ThreadManage.GetInstance.StopTask("MainTask", new Action(() => | |||
// { | |||
// ThreadManage.GetInstance.StopTask("ReadPLCData", new Action(() => | |||
// { | |||
// mORKD = null; | |||
// mORKD = new GVL_MORKD(); | |||
// ActionManage.GetInstance.Send("ResetProgram"); | |||
// ReadData(); | |||
// Main(); | |||
// })); | |||
// })); | |||
// } | |||
// Thread.Sleep(10); | |||
// }), "ResetProgram"); | |||
//} | |||
public void Main() | |||
{ | |||
ThreadManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
mORKD.AllowRun = mORKD.InitComplete && !mORKD.TemperatureReached; | |||
//ThreadManage.GetInstance.StartLong(new Action(() => | |||
//{ | |||
mORKD.AllowRun = mORKD.InitComplete && !mORKD.TemperatureReached; | |||
TakeBowlTask(); | |||
TakeBowlTask(); | |||
TakeNoodleTask(); | |||
TakeNoodleTask(); | |||
OutNoodleTask(); | |||
OutNoodleTask(); | |||
SingleDetect(); | |||
SingleDetect(); | |||
TurntableControl(); | |||
TurntableControl(); | |||
OutSoupTask(); | |||
OutSoupTask(); | |||
TakeSoupTask(); | |||
TakeSoupTask(); | |||
Thread.Sleep(10); | |||
// Thread.Sleep(10); | |||
}), "MainTask"); | |||
//}), "MainTask"); | |||
} | |||
public void ReadData() | |||
{ | |||
ThreadManage.GetInstance.StartLong(new Action(() => | |||
//ThreadManage.GetInstance.StartLong(new Action(() => | |||
//{ | |||
ModbusTcpHelper.GetInstance.Readbool(1120, 30, new Action<bool[]>((bools) => | |||
{ | |||
ModbusTcpHelper.GetInstance.Readbool(1120, 30, new Action<bool[]>((bools) => | |||
{ | |||
mORKD.InitComplete = bools[0]; | |||
mORKD.TurntableInPlace = bools[1]; | |||
mORKD.RBTakeNoodleComplete = bools[2]; | |||
mORKD.InitComplete = bools[0]; | |||
mORKD.TurntableInPlace = bools[1]; | |||
mORKD.RBTakeNoodleComplete = bools[2]; | |||
for (int i = 0; i < 2; i++) | |||
{ | |||
mORKD.AxisIdle[i] = bools[3 + i]; | |||
mORKD.AxisAllowInvertedNoodle[i] = bools[5 + i]; | |||
mORKD.AxisAllowInvertedSoup[i] = bools[7 + i]; | |||
mORKD.SoupHeatComplete[i] = bools[9 + i]; | |||
mORKD.BreakMechanismIdle[i] = bools[25 + i]; | |||
} | |||
for (int i = 0; i < 2; i++) | |||
{ | |||
mORKD.AxisIdle[i] = bools[3 + i]; | |||
mORKD.AxisAllowInvertedNoodle[i] = bools[5 + i]; | |||
mORKD.AxisAllowInvertedSoup[i] = bools[7 + i]; | |||
mORKD.SoupHeatComplete[i] = bools[9 + i]; | |||
mORKD.BreakMechanismIdle[i] = bools[25 + i]; | |||
} | |||
for (int i = 0; i < 6; i++) | |||
{ | |||
mORKD.CookNoodleBasketIdle[i] = bools[11 + i]; | |||
mORKD.CookNoodleComplete[i] = bools[17 + i]; | |||
} | |||
for (int i = 0; i < 6; i++) | |||
{ | |||
mORKD.CookNoodleBasketIdle[i] = bools[11 + i]; | |||
mORKD.CookNoodleComplete[i] = bools[17 + i]; | |||
} | |||
mORKD.TakeNoodleRobotIdle = bools[23]; | |||
mORKD.TakeSoupRobotIdle = bools[24]; | |||
mORKD.TakeSoupComplete = bools[27]; | |||
mORKD.PutNoodleTakeMealComplete = bools[28]; | |||
Initing = bools[29]; | |||
})); | |||
mORKD.TakeNoodleRobotIdle = bools[23]; | |||
mORKD.TakeSoupRobotIdle = bools[24]; | |||
mORKD.TakeSoupComplete = bools[27]; | |||
mORKD.PutNoodleTakeMealComplete = bools[28]; | |||
DeviceData.Initing = bools[29]; | |||
})); | |||
ModbusTcpHelper.GetInstance.Readbool(1280, 11, new Action<bool[]>((bools) => | |||
ModbusTcpHelper.GetInstance.Readbool(1280, 11, new Action<bool[]>((bools) => | |||
{ | |||
mORKD.TurntableLowerLimit = bools[0]; | |||
mORKD.TurntableUpLimit = bools[1]; | |||
for (int i = 0; i < 5; i++) | |||
{ | |||
mORKD.TurntableLowerLimit = bools[0]; | |||
mORKD.TurntableUpLimit = bools[1]; | |||
for (int i = 0; i < 5; i++) | |||
{ | |||
mORKD.SoupMaterialShortage[i] = bools[2 + i]; | |||
} | |||
mORKD.SoupMaterialShortage[i] = bools[2 + i]; | |||
} | |||
for (int i = 0; i < 3; i++) | |||
{ | |||
mORKD.OutMealDetect[i] = bools[7 + i]; | |||
} | |||
for (int i = 0; i < 3; i++) | |||
{ | |||
mORKD.OutMealDetect[i] = bools[7 + i]; | |||
} | |||
mORKD.TemperatureReached = bools[10]; | |||
})); | |||
mORKD.TemperatureReached = bools[10]; | |||
})); | |||
var ResLoc = ModbusTcpHelper.GetInstance.Read(720, ReadType.HoldingRegisters); | |||
if (ResLoc != null) | |||
var ResLoc = ModbusTcpHelper.GetInstance.Read(720, ReadType.HoldingRegisters); | |||
if (ResLoc != null) | |||
{ | |||
if (ResLoc is ushort loc) | |||
{ | |||
if (ResLoc is ushort loc) | |||
{ | |||
mORKD.TurntableFeedbackloc = loc; | |||
} | |||
mORKD.TurntableFeedbackloc = loc; | |||
} | |||
Thread.Sleep(100); | |||
}), "ReadPLCData"); | |||
} | |||
// Thread.Sleep(100); | |||
//}), "ReadPLCData"); | |||
} | |||
public void SimOrder<T>(T simOrder) | |||
@@ -87,6 +87,14 @@ namespace HBLConsole.MORKIC | |||
//冰淇淋机创建 | |||
iceCreamMachine = new IceCreamMachine(com_IceCream, (BaudRates)Enum.Parse(typeof(BaudRates), baud_IceCream)); | |||
icchipMachine = new ICChipMachine(com_ICChip, (BaudRates)Enum.Parse(typeof(BaudRates), baud_ICChip)); | |||
//咖啡机开启主线程 | |||
coffeeMachine.Start(); | |||
//冰淇淋机开启主线程 | |||
iceCreamMachine.Start(); | |||
icchipMachine.Start(); | |||
new ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
Main(); | |||
ReadData(); | |||
@@ -251,40 +259,35 @@ namespace HBLConsole.MORKIC | |||
public void Main() | |||
{ | |||
//咖啡机开启主线程 | |||
coffeeMachine.Start(); | |||
//冰淇淋机开启主线程 | |||
iceCreamMachine.Start(); | |||
icchipMachine.Start(); | |||
new ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
//开始心跳刷新,根据咖啡机及冰淇淋机来判断 | |||
ThreadManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
//ThreadManage.GetInstance.StartLong(new Action(() => | |||
//{ | |||
//GeneralConfig.Healthy = true; | |||
//GeneralConfig.Healthy = | |||
// LebaiHelper.GetInstance.IsConnected && | |||
// MorkIStatus.GetInstance().CanDo && | |||
// MorkCStatus.GetInstance().CanDo; | |||
GeneralConfig.Healthy = | |||
LebaiHelper.GetInstance.IsConnected && | |||
MorkCStatus.GetInstance().CanDo; | |||
GeneralConfig.Healthy = true; | |||
Thread.Sleep(100); | |||
}), "MORK-IC心跳刷新"); | |||
//GeneralConfig.Healthy = true; | |||
//GeneralConfig.Healthy = | |||
// LebaiHelper.GetInstance.IsConnected && | |||
// MorkIStatus.GetInstance().CanDo && | |||
// MorkCStatus.GetInstance().CanDo; | |||
GeneralConfig.Healthy = | |||
LebaiHelper.GetInstance.IsConnected && | |||
MorkCStatus.GetInstance().CanDo; | |||
GeneralConfig.Healthy = true; | |||
// Thread.Sleep(100); | |||
//}), "MORK-IC心跳刷新"); | |||
} | |||
public void ReadData() | |||
{ | |||
ThreadManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
lebai = LebaiHelper.GetInstance.GetValueAsync(); | |||
LebaiHelper.GetInstance.GetRobotModeStatus(); | |||
Thread.Sleep(100); | |||
}), "乐百机器人数据读取"); | |||
//ThreadManage.GetInstance.StartLong(new Action(() => | |||
//{ | |||
lebai = LebaiHelper.GetInstance.GetValueAsync(); | |||
LebaiHelper.GetInstance.GetRobotModeStatus(); | |||
// Thread.Sleep(100); | |||
//}), "乐百机器人数据读取"); | |||
} | |||
public void SimOrder<T>(T simOrder) | |||
@@ -15,6 +15,7 @@ using BPA.Message.Enum; | |||
using HBLConsole.GVL; | |||
using BPA.Models; | |||
using BPA.Message.IOT; | |||
using HBLConsole.Abstract; | |||
namespace HBLConsole.MORKS | |||
{ | |||
@@ -29,6 +30,9 @@ namespace HBLConsole.MORKS | |||
public void ConnectOk() | |||
{ | |||
mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo()); | |||
mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo()); | |||
mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo()); | |||
//WriteRecipeBoms(); | |||
ReadData(); | |||
Main(); | |||
@@ -36,94 +40,67 @@ namespace HBLConsole.MORKS | |||
MessageLog.GetInstance.Show("MORKS 设备初始化完成"); | |||
} | |||
/// <summary> | |||
/// 复位程序 | |||
/// </summary> | |||
private void ResetProgram() | |||
{ | |||
ThreadManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
if (RTrig.GetInstance("ResetProgram").Start(mORKS.DeviceIniting)) | |||
{ | |||
ThreadManage.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"); | |||
} | |||
/// <summary> | |||
/// 数据读取 | |||
/// </summary> | |||
public void ReadData() | |||
{ | |||
ThreadManage.GetInstance.StartLong(new Action(() => | |||
//ThreadManage.GetInstance.StartLong(new Action(() => | |||
//{ | |||
ModbusTcpHelper.GetInstance.Readbool(323, 3, new Action<bool[]>((bools) => | |||
{ | |||
ModbusTcpHelper.GetInstance.Readbool(323, 3, new Action<bool[]>((bools) => | |||
{ | |||
mORKS.RobotTakeNoodle = bools[0]; | |||
mORKS.RobotOutMeal = bools[1]; | |||
mORKS.MoveTurntable = bools[2]; | |||
})); | |||
mORKS.RobotTakeNoodle = bools[0]; | |||
mORKS.RobotOutMeal = bools[1]; | |||
mORKS.MoveTurntable = bools[2]; | |||
})); | |||
ModbusTcpHelper.GetInstance.Readbool(1120, 16, new Action<bool[]>((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]; | |||
})); | |||
ModbusTcpHelper.GetInstance.Readbool(1136, 6, new Action<bool[]>((bools) => | |||
ModbusTcpHelper.GetInstance.Readbool(1120, 16, new Action<bool[]>((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]; | |||
DeviceData.Initing = bools[10]; | |||
mORKS.TurntableLowerLimit = bools[11]; | |||
mORKS.MissingBowlSignal2 = bools[12]; | |||
mORKS.TurntableUpLimit = bools[13]; | |||
mORKS.TurntableMoveInPlace = bools[15]; | |||
})); | |||
ModbusTcpHelper.GetInstance.Readbool(1136, 6, new Action<bool[]>((bools) => | |||
{ | |||
for (int i = 0; i < 6; i++) | |||
{ | |||
for (int i = 0; i < 6; i++) | |||
{ | |||
mORKS.NoodleCookerStatus[i] = bools[i]; | |||
} | |||
})); | |||
mORKS.NoodleCookerStatus[i] = bools[i]; | |||
} | |||
})); | |||
ModbusTcpHelper.GetInstance.Readbool(1144, 6, new Action<bool[]>((bools) => | |||
ModbusTcpHelper.GetInstance.Readbool(1144, 6, new Action<bool[]>((bools) => | |||
{ | |||
for (int i = 0; i < 6; i++) | |||
{ | |||
for (int i = 0; i < 6; i++) | |||
{ | |||
mORKS.CookNoodlesComplete[i] = bools[i]; | |||
} | |||
})); | |||
mORKS.CookNoodlesComplete[i] = bools[i]; | |||
} | |||
})); | |||
var ResLoc = ModbusTcpHelper.GetInstance.Read(286, ReadType.HoldingRegisters); | |||
if (ResLoc != null) | |||
{ | |||
if (ResLoc is ushort loc) | |||
{ | |||
mORKS.TurntableFeedbackloc = loc; | |||
} | |||
} | |||
//var ResLoc = ModbusTcpHelper.GetInstance.Read(286, ReadType.HoldingRegisters); | |||
//if (ResLoc != null) | |||
//{ | |||
// if (ResLoc is ushort loc) | |||
// { | |||
// mORKS.TurntableFeedbackloc = loc; | |||
// } | |||
//} | |||
Thread.Sleep(500); | |||
}), "ReadPLCData"); | |||
// Thread.Sleep(500); | |||
//}), "ReadPLCData"); | |||
} | |||
public void SimOrder<T>(T simOrder) | |||
@@ -224,37 +201,33 @@ namespace HBLConsole.MORKS | |||
int index = Array.FindIndex(Json<BatchingInfoPar>.Data.recipeBoms.RecipeIds.ToArray(), p => p.RecipeId == morkOrderPush.RecipeId); | |||
index++; | |||
mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = ushort.Parse(batching_W.BatchingLoc), SuborderId = morkOrderPush.SuborderId, RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0 }); | |||
} | |||
} | |||
} | |||
public void Main() | |||
{ | |||
ThreadManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
mORKS.AllowRun = mORKS.InitComplete; | |||
//mORKS.AllowRun = mORKS.InitComplete && mORKS.TemperatureReached; | |||
//GeneralConfig.Healthy = true; | |||
GeneralConfig.Healthy = mORKS.AllowRun; | |||
//ThreadManage.GetInstance.StartLong(new Action(() => | |||
//{ | |||
mORKS.AllowRun = mORKS.InitComplete; | |||
//mORKS.AllowRun = mORKS.InitComplete && mORKS.TemperatureReached; | |||
//GeneralConfig.Healthy = true; | |||
GeneralConfig.Healthy = mORKS.AllowRun; | |||
TakeBowlTask(); | |||
TakeBowlTask(); | |||
TakeNoodleTask(); | |||
TakeNoodleTask(); | |||
OutNoodleTask(); | |||
OutNoodleTask(); | |||
SingleDetect(); | |||
SingleDetect(); | |||
TurntableControl(); | |||
TurntableControl(); | |||
Thread.Sleep(100); | |||
//Thread.Sleep(100); | |||
}), "MainTask"); | |||
//}), "MainTask"); | |||
} | |||
/// <summary> | |||
@@ -327,9 +300,10 @@ namespace HBLConsole.MORKS | |||
#region 优化版本 | |||
//if (mORKS.TurntableMoveInPlace && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) | |||
//{ | |||
// var result = Json<BatchingInfoPar>.Data.orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKS.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList(); | |||
// if (mORKS.TurntableLowerLimit) | |||
// { | |||
// if (mORKS.TurntableFeedbackloc == mORKS.RBTakeNoodleTask.ElementAt(0).Loc) | |||
// if (mORKS.TurntableFeedbackloc == mORKS.RBTakeNoodleTask.ElementAt(0).Loc || (result?.Count > 0 && result?.Count == mORKS.TurntableLocLists.Count)) | |||
// { | |||
// mORKS.TurntableLocLists.Clear(); | |||
// mORKS.AllowTakeNoodle = true; | |||
@@ -348,20 +322,22 @@ namespace HBLConsole.MORKS | |||
// { | |||
// if (!mORKS.TurntableInterlock) | |||
// { | |||
// var result = Json<BatchingInfoPar>.Data.orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKS.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList(); | |||
// result?.ForEach(item => | |||
// if (result != null) | |||
// { | |||
// if (ushort.TryParse(item.BatchingLoc, out ushort loc)) | |||
// foreach (var item in result) | |||
// { | |||
// if (mORKS.TurntableFeedbackloc != loc && !mORKS.TurntableLocLists.Contains(loc)) | |||
// if (ushort.TryParse(item.BatchingLoc, out ushort loc)) | |||
// { | |||
// TurntableStart(loc); | |||
// MessageLog.GetInstance.Show($"没有物料检测的启动转台控制,转台位置:[{loc}]"); | |||
// return; | |||
// if (mORKS.TurntableFeedbackloc != loc && !mORKS.TurntableLocLists.Contains(loc)) | |||
// { | |||
// TurntableStart(loc); | |||
// MessageLog.GetInstance.Show($"没有物料检测的启动转台控制,转台位置:[{loc}]"); | |||
// break; | |||
// } | |||
// else if (mORKS.TurntableFeedbackloc == loc && !mORKS.TurntableLocLists.Contains(loc)) mORKS.TurntableLocLists.Add(loc); | |||
// } | |||
// else if (mORKS.TurntableFeedbackloc == loc) mORKS.TurntableLocLists.Add(loc); | |||
// } | |||
// }); | |||
// } | |||
// } | |||
// } | |||
@@ -42,41 +42,48 @@ namespace HBLConsole.MORKS | |||
/// 允许运行 | |||
/// </summary> | |||
[Circuit(new string[] { "机器人取面", "取碗控制" }, "允许运行")] | |||
[VariableMonitor("允许运行")] | |||
public bool AllowRun { get; set; } | |||
/// <summary> | |||
/// //机器人任务互锁信号 | |||
/// </summary> | |||
[Circuit(new string[] { "机器人取面", "出面控制" }, "机器人互锁", new bool[] { true, false })] | |||
[VariableMonitor("机器人任务互锁信号")] | |||
public bool RobotTaskInterlock { get; set; } | |||
/// <summary> | |||
/// 取碗互锁信号 | |||
/// </summary> | |||
[Circuit("取碗控制", "取碗互锁", true)] | |||
[VariableMonitor("取碗互锁信号")] | |||
public bool TakeBowlInterlock { get; set; } | |||
/// <summary> | |||
/// 取面互锁信号 | |||
/// </summary> | |||
[Circuit(new string[] { "机器人取面", "出面控制" }, "取面互锁信号", new bool[] { true, true })] | |||
[VariableMonitor("取面互锁信号")] | |||
public bool TakeNoodleInterlock { get; set; } | |||
/// <summary> | |||
/// 出面中 | |||
/// </summary> | |||
[Circuit("机器人取面", "出面中", true)] | |||
[VariableMonitor("出面中")] | |||
public bool OutNoodleing { get; set; } | |||
/// <summary> | |||
/// 允许取面 | |||
/// </summary> | |||
[Circuit(new string[] { "转台控制", "机器人取面" }, "允许取面", new bool[] { true, false })] | |||
[VariableMonitor("允许取面")] | |||
public bool AllowTakeNoodle { get; set; } | |||
/// <summary> | |||
/// 转台互锁信号 | |||
/// </summary> | |||
[VariableMonitor("转台互锁信号")] | |||
public bool TurntableInterlock { get; set; } | |||
#endregion | |||
@@ -87,6 +94,7 @@ namespace HBLConsole.MORKS | |||
/// ModbusTcp -> 1120 | |||
/// </summary> | |||
[Circuit(new string[] { "允许运行", "转台控制", "转台控制" }, "初始化完成")] | |||
[VariableMonitor("初始化完成", "M100.0", "1120")] | |||
public bool InitComplete { get; set; } | |||
/// <summary> | |||
@@ -95,6 +103,7 @@ namespace HBLConsole.MORKS | |||
/// ModbusTcp -> 1121 | |||
/// </summary> | |||
[Circuit("取碗控制", "取碗机构空闲", true)] | |||
[VariableMonitor("初始化完成", "M100.1", "1121")] | |||
public bool TakeBowlIdle { get; set; } | |||
/// <summary> | |||
@@ -103,6 +112,7 @@ namespace HBLConsole.MORKS | |||
/// ModbusTcp -> 1122 | |||
/// </summary> | |||
[Circuit("允许运行", "温度到达")] | |||
[VariableMonitor("温度到达", "M100.2", "1122")] | |||
public bool TemperatureReached { get; set; } | |||
/// <summary> | |||
@@ -111,6 +121,7 @@ namespace HBLConsole.MORKS | |||
/// ModbusTcp -> 1123 | |||
/// </summary> | |||
[Circuit("出面控制", "允许到面")] | |||
[VariableMonitor("允许到面", "M100.3", "1123")] | |||
public bool AllowFallNoodle { get; set; } | |||
/// <summary> | |||
@@ -118,6 +129,7 @@ namespace HBLConsole.MORKS | |||
/// PLC -> M100.4 | |||
/// ModbusTcp -> 1124 | |||
/// </summary> | |||
[VariableMonitor("机器人取面完成", "M100.4", "1124")] | |||
public bool RbTakeNoodleComplete { get; set; } | |||
/// <summary> | |||
@@ -125,6 +137,7 @@ namespace HBLConsole.MORKS | |||
/// PLC -> M100.5 | |||
/// ModbusTcp -> 1125 | |||
/// </summary> | |||
[VariableMonitor("机器人倒面完成", "M100.5", "1125")] | |||
public bool RbFallNoodleComplete { get; set; } | |||
/// <summary> | |||
@@ -132,6 +145,7 @@ namespace HBLConsole.MORKS | |||
/// PLC -> M100.6 | |||
/// ModbusTcp -> 1126 | |||
/// </summary> | |||
[VariableMonitor("机器人出餐完成", "M100.6", "1126")] | |||
public bool RbOutMealComplete { get; set; } | |||
/// <summary> | |||
@@ -140,6 +154,7 @@ namespace HBLConsole.MORKS | |||
/// ModbusTcp -> 1127 | |||
/// </summary> | |||
[Circuit(new string[] { "机器人取面", "出面控制" }, "机器人空闲")] | |||
[VariableMonitor("机器人空闲", "M100.7", "1127")] | |||
public bool RobotIdle { get; set; } | |||
/// <summary> | |||
@@ -148,6 +163,7 @@ namespace HBLConsole.MORKS | |||
/// ModbusTcp -> 1128 | |||
/// </summary> | |||
[Circuit("出面控制", "取餐口检测", true)] | |||
[VariableMonitor("取餐口检测", "M101.0", "1128")] | |||
public bool TakeMealDetect { get; set; } | |||
/// <summary> | |||
@@ -155,6 +171,7 @@ namespace HBLConsole.MORKS | |||
/// PLC -> M101.1 | |||
/// ModbusTcp -> 1129 | |||
/// </summary> | |||
[VariableMonitor("缺碗信号", "M101.1", "1129")] | |||
public bool MissingBowl { get; set; } | |||
/// <summary> | |||
@@ -162,6 +179,7 @@ namespace HBLConsole.MORKS | |||
/// PLC -> M101.2 | |||
/// ModbusTcp -> 1130 | |||
/// </summary> | |||
[VariableMonitor("设备初始化中", "M101.2", "1130")] | |||
public bool DeviceIniting { get; set; } | |||
/// <summary> | |||
@@ -170,6 +188,7 @@ namespace HBLConsole.MORKS | |||
/// ModbusTcp -> 1131 | |||
/// </summary> | |||
[Circuit("转台控制", "转台下限检测有物料")] | |||
[VariableMonitor("转台下限检测", "M101.3", "1131")] | |||
public bool TurntableLowerLimit { get; set; } | |||
/// <summary> | |||
@@ -177,6 +196,7 @@ namespace HBLConsole.MORKS | |||
/// PLC -> M101.4 | |||
/// ModbusTcp -> 1132 | |||
/// </summary> | |||
[VariableMonitor("缺碗信号 2", "M101.4", "1132")] | |||
public bool MissingBowlSignal2 { get; set; } | |||
/// <summary> | |||
@@ -184,6 +204,7 @@ namespace HBLConsole.MORKS | |||
/// PLC -> M101.5 | |||
/// ModbusTcp -> 1133 | |||
/// </summary> | |||
[VariableMonitor("转台上限检测", "M101.5", "1133")] | |||
public bool TurntableUpLimit { get; set; } | |||
/// <summary> | |||
@@ -192,6 +213,7 @@ namespace HBLConsole.MORKS | |||
/// ModbusTcp -> 1135 | |||
/// </summary> | |||
[Circuit(new string[] { "转台控制", "机器人取面" }, "转台移动到位")] | |||
[VariableMonitor("转台移动到位", "M101.7", "1135")] | |||
public bool TurntableMoveInPlace { get; set; } | |||
/// <summary> | |||
@@ -199,6 +221,7 @@ namespace HBLConsole.MORKS | |||
/// M102.0 - M102.5 | |||
/// 1136 - 1141 | |||
/// </summary> | |||
[VariableMonitor("煮面炉状态", "M102.0", "1136")] | |||
public bool[] NoodleCookerStatus { get; set; } = new bool[6] { false, false, false, false, false, false }; | |||
/// <summary> | |||
@@ -206,6 +229,7 @@ namespace HBLConsole.MORKS | |||
/// M103.0 - M103.5 | |||
/// 1144 - 1149 | |||
/// </summary> | |||
[VariableMonitor("煮面完成", "M103.0", "1144")] | |||
public bool[] CookNoodlesComplete { get; set; } = new bool[6] { false, false, false, false, false, false }; | |||
/// <summary> | |||
@@ -213,6 +237,7 @@ namespace HBLConsole.MORKS | |||
/// PLC -> VW0 | |||
/// ModbusTcp -> 100 | |||
/// </summary> | |||
[VariableMonitor("配方编号", "VW0", "100")] | |||
public ushort RecipeNumber { get; set; } | |||
/// <summary> | |||
@@ -220,6 +245,7 @@ namespace HBLConsole.MORKS | |||
/// PLC -> VW2 | |||
/// ModbusTcp -> 101 | |||
/// </summary> | |||
[VariableMonitor("转台位置", "VW2", "101")] | |||
public ushort TurntableLoc { get; set; } | |||
/// <summary> | |||
@@ -227,6 +253,7 @@ namespace HBLConsole.MORKS | |||
/// PLC -> VW4 | |||
/// ModbusTcp -> 102 | |||
/// </summary> | |||
[VariableMonitor("到面至煮面炉位置", "VW4", "102")] | |||
public ushort FallNoodleLoc { get; set; } | |||
/// <summary> | |||
@@ -234,6 +261,7 @@ namespace HBLConsole.MORKS | |||
/// PLC -> VW6 | |||
/// ModbusTcp -> 103 | |||
/// </summary> | |||
[VariableMonitor("取面位置", "VW6", "103")] | |||
public ushort TakeNoodleLoc { get; set; } | |||
/// <summary> | |||
@@ -241,6 +269,7 @@ namespace HBLConsole.MORKS | |||
/// PLC -> VW372 | |||
/// ModbusTcp -> 286 | |||
/// </summary> | |||
[VariableMonitor("转台位置", "VW372", "286")] | |||
public ushort TurntableFeedbackloc { get; set; } | |||
/// <summary> | |||
@@ -0,0 +1,14 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace HBLConsole.Model | |||
{ | |||
public class DeviceData | |||
{ | |||
public static bool Initing { get; set; } | |||
} | |||
} |
@@ -7,9 +7,11 @@ using System.Threading.Tasks; | |||
namespace HBLConsole.Service | |||
{ | |||
/// <summary> | |||
/// 上升沿操作类 | |||
/// </summary> | |||
public class RTrig | |||
{ | |||
private volatile static ConcurrentDictionary<string, RTrig> _Instance; | |||
public static RTrig GetInstance(string name) | |||
{ | |||
@@ -34,8 +36,5 @@ namespace HBLConsole.Service | |||
IN1 = IN; | |||
return Q; | |||
} | |||
} | |||
} |
@@ -0,0 +1,39 @@ | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace HBLConsole.Service | |||
{ | |||
/// <summary> | |||
/// 下降沿操作 | |||
/// </summary> | |||
public class TTrig | |||
{ | |||
private volatile static ConcurrentDictionary<string, TTrig> _Instance; | |||
public static TTrig GetInstance(string name) | |||
{ | |||
if (_Instance == null) _Instance = new ConcurrentDictionary<string, TTrig>(); | |||
if (!_Instance.ContainsKey(name)) _Instance.TryAdd(name, new TTrig()); | |||
return _Instance[name]; | |||
} | |||
private TTrig() { } | |||
private bool flag1; | |||
public bool Q { get; private set; } | |||
private bool IN1 | |||
{ | |||
set | |||
{ | |||
Q = !value && flag1; | |||
flag1 = value; | |||
} | |||
} | |||
public bool Start(bool IN) | |||
{ | |||
IN1 = IN; | |||
return Q; | |||
} | |||
} | |||
} |