itachilee 2 years ago
parent
commit
e3bc24a658
5 changed files with 45 additions and 11 deletions
  1. +1
    -1
      HBLConsole.Factory/SimpleFactory.cs
  2. +20
    -6
      HBLConsole.MORKS/Control_MORKS.cs
  3. +8
    -0
      HBLConsole.MORKS/GVL_MORKS.cs
  4. +0
    -1
      HBLConsole.MainConsole/Main.cs
  5. +16
    -3
      HBLConsole/ViewModel/ViewModelBase.cs

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

@@ -11,7 +11,7 @@ using System.Threading;
using System.Collections.Generic;
using HBLConsole.Model;
using System.Linq;
using BPA.Message;
//using BPA.Message;


namespace HBLConsole.Factory


+ 20
- 6
HBLConsole.MORKS/Control_MORKS.cs View File

@@ -76,10 +76,10 @@ namespace HBLConsole.MORKS
{
ThreadManage.GetInstance.StopTask("ReadPLCData", new Action(() =>
{
//Json<KeepDataBase>.Data.orderLists.Clear();
mORKS = null;
mORKS = new GVL_MORKS();
ActionManage.GetInstance.Send("ResetProgram");
ActionManage.GetInstance.Send("ClearOrders");
ReadData();
Main();
}));
@@ -130,12 +130,13 @@ namespace HBLConsole.MORKS
var errorStatus = ModbusTcpHelper.GetInstance.Read((ushort)ModbusTcpHelper.GetInstance.GetBoolAddress("M235.0"), ReadType.Coils, 1);
if (errorStatus != null && errorStatus is bool error) mORKS.Error = error;

ModbusTcpHelper.GetInstance.Readbool(1136, 6, new Action<bool[]>((bools) =>
ModbusTcpHelper.GetInstance.Readbool(1136, 7, new Action<bool[]>((bools) =>
{
for (int i = 0; i < 6; i++)
{
mORKS.NoodleCookerStatus[i] = bools[i];
}
mORKS.Feeding = bools[6];
}));

ModbusTcpHelper.GetInstance.Readbool(1144, 6, new Action<bool[]>((bools) =>
@@ -339,7 +340,7 @@ namespace HBLConsole.MORKS
/// </summary>
private void TurntableControl()
{
if (mORKS.TurntableMoveInPlace && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0)
if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && 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 (result != null)
@@ -347,6 +348,7 @@ namespace HBLConsole.MORKS
var res = result.FirstOrDefault(P => P.BatchingLoc == mORKS.TurntableFeedbackloc.ToString());
if (mORKS.TurntableLowerLimit && res != null)
{
//if (mORKS.RBTakeNoodleTask.ElementAt(0).Loc != mORKS.TurntableFeedbackloc)
TurntableStart(mORKS.TurntableFeedbackloc);
mORKS.TurntableLocLists.Clear();
mORKS.AllowTakeNoodle = true;
@@ -386,12 +388,18 @@ namespace HBLConsole.MORKS
//补料完成检测
if (RTrig.GetInstance("FeedComplete").Start(mORKS.FeedComplete))
{
if (!mORKS.TurntableLowerLimit && mORKS.TurntableLocLists.Count > 0 && !mORKS.AllowTakeNoodle)
if (!mORKS.AllowTakeNoodle && mORKS.TurntableLocLists.Count > 0)
{
mORKS.TurntableLocLists.Clear();
mORKS.TurntableInterlock = false;
MessageLog.GetInstance.Show("补料完成检测");
}
//if (!mORKS.TurntableLowerLimit && mORKS.TurntableLocLists.Count > 0 && !mORKS.AllowTakeNoodle)
//{
// mORKS.TurntableLocLists.Clear();
// mORKS.TurntableInterlock = false;
// MessageLog.GetInstance.Show("补料完成检测");
//}
}
}

@@ -401,7 +409,7 @@ namespace HBLConsole.MORKS
private void TakeNoodleTask()
{
//取面控制
if (mORKS.AllowRun && mORKS.RobotIdle && !mORKS.RobotTaskInterlock && mORKS.AllowTakeNoodle && mORKS.TurntableMoveInPlace && !mORKS.TakeNoodleInterlock && !mORKS.OutNoodleing && mORKS.RBTakeNoodleTask.Count > 0)
if (mORKS.AllowRun && mORKS.RobotIdle && !mORKS.Feeding && !mORKS.RobotTaskInterlock && mORKS.AllowTakeNoodle && mORKS.TurntableMoveInPlace && !mORKS.TakeNoodleInterlock && !mORKS.OutNoodleing && mORKS.RBTakeNoodleTask.Count > 0)
{
int loc = Array.FindIndex(mORKS.NoodleCookerStatus, p => p == false);//查找煮面炉空闲位置
if (loc >= 0 && loc <= 5)
@@ -414,6 +422,12 @@ namespace HBLConsole.MORKS
RobotTakeNoodle();
SimpleFactory.GetInstance.OrderChanged(orderLocInfo.SuborderId, ORDER_STATUS.COOKING);
MessageLog.GetInstance.Show($"订单【{orderLocInfo.SuborderId}】,机器人倒面至【{loc + 1}】号煮面栏");
//写入煮面时间
//List<ushort> values = new List<ushort>();
//values.Add(Json<KeepDataBase>.Data.parSets.ElementAt(loc).Minute);
//values.Add(Json<KeepDataBase>.Data.parSets.ElementAt(loc).Second);
//ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetWordAddress($"VW{116 + (loc * 6)}"), WriteType.HoldingRegisters, values.ToArray());

mORKS.TakeNoodleInterlock = true;
}
}
@@ -457,7 +471,7 @@ namespace HBLConsole.MORKS
{
mORKS.IngredientsCompleteId = mORKS.TakeBowlId;
mORKS.TakeBowlId = string.Empty;
MessageLog.GetInstance.Show($"允许到面,{mORKS.IngredientsCompleteId}");
MessageLog.GetInstance.Show($"碗到位,允许到面,{mORKS.IngredientsCompleteId}");
mORKS.TakeBowlInterlock = false;
}



+ 8
- 0
HBLConsole.MORKS/GVL_MORKS.cs View File

@@ -233,6 +233,14 @@ namespace HBLConsole.MORKS
[VariableMonitor("煮面炉状态", "M102.0", "1136")]
public bool[] NoodleCookerStatus { get; set; } = new bool[6] { false, false, false, false, false, false };

/// <summary>
/// 补料中
/// M102.6
/// 1142
/// </summary>
[VariableMonitor("补料中", "M102.6", "1142")]
public bool Feeding { get; set; }

/// <summary>
/// 煮面完成,上升后给信号
/// M103.0 - M103.5


+ 0
- 1
HBLConsole.MainConsole/Main.cs View File

@@ -69,7 +69,6 @@ namespace HBLConsole.MainConsole
{
ThreadManage.GetInstance.Start(new Action(() =>
{
//SimpleFactory.GetInstance.DeviceInit();//设备初始化
InternetInfo.ConfigInit();//从 consul 获取配置数据
IotReport.GetInstance.Initialize();
Topics.Clear();


+ 16
- 3
HBLConsole/ViewModel/ViewModelBase.cs View File

@@ -162,6 +162,17 @@ namespace HBLConsole.ViewModel
public void MqttReceive()
{
Test();

//清除订单数据
ActionManage.GetInstance.Register(new Action(() =>
{
Application.Current.Dispatcher.Invoke(() =>
{
orderStatusLists.Clear();
WaitTakeMeal.Clear();
});
}), "ClearOrders");

ActionManage.GetInstance.Register(new Action<object>((o) =>
{
if (o is MorkOrderPush morkOrderpush)
@@ -218,17 +229,19 @@ namespace HBLConsole.ViewModel
{
int index = Array.FindIndex(orderStatusLists.ToArray(), p => p.OrderPush.SuborderId == orderStatusChange.SuborderId);

if (index >= 0) orderStatusLists.ElementAt(index).OrderStatus = orderStatusChange.CookingStatus;
//if (index >= 0) orderStatusLists.ElementAt(index).OrderStatus = orderStatusChange.CookingStatus;
switch (orderStatusChange.CookingStatus)
{
case ORDER_STATUS.COOKING:

if (index >= 0 && index < orderStatusLists.Count)
orderStatusLists.ElementAt(index).OrderStatus = orderStatusChange.CookingStatus;
break;
case ORDER_STATUS.COMPLETED_COOK:
if (index >= 0)
if (index >= 0 && index < orderStatusLists.Count)
{
App.Current.Dispatcher.BeginInvoke((Action)delegate
{
orderStatusLists.ElementAt(index).OrderStatus = orderStatusChange.CookingStatus;
orderStatusLists.ElementAt(index).EndDate = DateTime.Now.ToString("HH:mm:ss");
TimeSpan timeSpan = DateTime.Now.Subtract(Convert.ToDateTime(orderStatusLists.ElementAt(index).StartDate));
orderStatusLists.ElementAt(index).CompleteDate = $"{timeSpan.TotalSeconds.ToString("0.00")} S";


Loading…
Cancel
Save