Browse Source

冲突解决

master
pry 2 years ago
parent
commit
8d47194ee4
4 changed files with 171 additions and 158 deletions
  1. +2
    -2
      HBLConsole.Factory/SimpleFactory.cs
  2. +59
    -63
      HBLConsole.MORKD/Control_MORKD.cs
  3. +29
    -35
      HBLConsole.MORKIC/Control_MORKIC.cs
  4. +81
    -58
      HBLConsole.MORKS/Control_MORKS.cs

+ 2
- 2
HBLConsole.Factory/SimpleFactory.cs View File

@@ -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;
@@ -116,7 +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();
//GetControlBase();

}



+ 59
- 63
HBLConsole.MORKD/Control_MORKD.cs View File

@@ -22,7 +22,7 @@ namespace HBLConsole.MORKD
{
Main();
ReadData();
//ResetProgram();
ResetProgram();
}

public void DataParse<T>(T order)
@@ -63,66 +63,62 @@ namespace HBLConsole.MORKD
}), "InitCommand");
}

//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(DeviceData.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(() =>
//{
ModbusTcpHelper.GetInstance.Readbool(1120, 30, new Action<bool[]>((bools) =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
ModbusTcpHelper.GetInstance.Readbool(1120, 30, new Action<bool[]>((bools) =>
{
mORKD.InitComplete = bools[0];
mORKD.TurntableInPlace = bools[1];
@@ -151,33 +147,33 @@ namespace HBLConsole.MORKD
}));


ModbusTcpHelper.GetInstance.Readbool(1280, 11, new Action<bool[]>((bools) =>
{
mORKD.TurntableLowerLimit = bools[0];
mORKD.TurntableUpLimit = bools[1];
for (int i = 0; i < 5; i++)
ModbusTcpHelper.GetInstance.Readbool(1280, 11, new Action<bool[]>((bools) =>
{
mORKD.SoupMaterialShortage[i] = bools[2 + i];
}
mORKD.TurntableLowerLimit = bools[0];
mORKD.TurntableUpLimit = bools[1];
for (int i = 0; i < 5; 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)
{
if (ResLoc is ushort loc)
var ResLoc = ModbusTcpHelper.GetInstance.Read(720, ReadType.HoldingRegisters);
if (ResLoc != null)
{
mORKD.TurntableFeedbackloc = loc;
if (ResLoc is ushort loc)
{
mORKD.TurntableFeedbackloc = loc;
}
}
}
// Thread.Sleep(100);
//}), "ReadPLCData");
Thread.Sleep(100);
}), "ReadPLCData");
}

public void SimOrder<T>(T simOrder)


+ 29
- 35
HBLConsole.MORKIC/Control_MORKIC.cs View File

@@ -102,16 +102,9 @@ 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();
Main();


ThreadManage.GetInstance.StartLong(new Action(() =>
{
@@ -200,7 +193,8 @@ namespace HBLConsole.MORKIC
}), "MORK-IC心跳刷新");
ThreadManage.GetInstance.Start(new Action(() =>
{
while (!LebaiHelper.GetInstance.IsConnected) {
while (!LebaiHelper.GetInstance.IsConnected)
{
Thread.Sleep(10);
}
LebaiHelper.GetInstance.Scene(LebaiHelper.SENCE_欢迎);
@@ -353,32 +347,32 @@ namespace HBLConsole.MORKIC
are.Set();
}

public void Main()
{
//咖啡机开启主线程
coffeeMachine.Start();
//冰淇淋机开启主线程
iceCreamMachine.Start();
icchipMachine.Start();
new ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish();
//开始心跳刷新,根据咖啡机及冰淇淋机来判断
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心跳刷新");
//public void Main()
//{
// //咖啡机开启主线程
// coffeeMachine.Start();
// //冰淇淋机开启主线程
// iceCreamMachine.Start();
// icchipMachine.Start();
// new ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish();
// //开始心跳刷新,根据咖啡机及冰淇淋机来判断
// 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心跳刷新");
//}

public void ReadData()
{


+ 81
- 58
HBLConsole.MORKS/Control_MORKS.cs View File

@@ -36,71 +36,94 @@ namespace HBLConsole.MORKS
//WriteRecipeBoms();
ReadData();
Main();
//ResetProgram();
ResetProgram();
MessageLog.GetInstance.Show("MORKS 设备初始化完成");
}

private 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(() =>
{
mORKS = null;
mORKS = new GVL_MORKS();
ActionManage.GetInstance.Send("ResetProgram");
ReadData();
Main();
}));
}));
}

Thread.Sleep(10);
}), "ResetProgram");
}

/// <summary>
/// 数据读取
/// </summary>
public void ReadData()
{
//ThreadManage.GetInstance.StartLong(new Action(() =>
//{
ModbusTcpHelper.GetInstance.Readbool(323, 3, new Action<bool[]>((bools) =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
ModbusTcpHelper.GetInstance.Readbool(323, 3, new Action<bool[]>((bools) =>
{
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];
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++)
ModbusTcpHelper.GetInstance.Readbool(1120, 16, new Action<bool[]>((bools) =>
{
mORKS.NoodleCookerStatus[i] = bools[i];
}
}));
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++)
{
mORKS.NoodleCookerStatus[i] = bools[i];
}
}));

ModbusTcpHelper.GetInstance.Readbool(1144, 6, new Action<bool[]>((bools) =>
{
for (int i = 0; i < 6; i++)
ModbusTcpHelper.GetInstance.Readbool(1144, 6, new Action<bool[]>((bools) =>
{
mORKS.CookNoodlesComplete[i] = bools[i];
}
}));
for (int i = 0; i < 6; 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)
@@ -208,26 +231,26 @@ namespace HBLConsole.MORKS

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>


Loading…
Cancel
Save