Browse Source

1

煮面机(新)
ZhaoGang 1 year ago
parent
commit
25729cc792
1 changed files with 51 additions and 129 deletions
  1. +51
    -129
      BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs

+ 51
- 129
BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs View File

@@ -1,29 +1,6 @@
using System;
using System.Collections.Generic;
using BPA.Message.Enum;
using BPASmartClient.Device;

using BPASmartClient.Model;
using BPASmartClient.Peripheral;

using BPA.Helper;
using System.Threading;

using BPA.Message;
using System.Linq;
using BPASmartClient.Model.PLC;
using System.Threading.Tasks;
using System.Reflection;
using BPASmartClient.MorkSUpgradedVer.Model;
using System.Collections.ObjectModel;
using BPASmartClient.MorkSUpgradedVer.ViewModel;
using BPASmartClient.Business;
using BPASmartClient.Model.小炒机;
using BPA.Models;
using System.Windows.Forms;
using System.Media;
using BPASmartClient.CustomResource;
using BPASmartClient.CustomResource;
using static BPA.Helper.EventBus;

//using BPA.Helper;

namespace BPASmartClient.MorkSUpgradedVer
@@ -31,8 +8,8 @@ namespace BPASmartClient.MorkSUpgradedVer
public class Control_MorkSUpgradedVer : BaseDevice
{
public override DeviceClientType DeviceType => DeviceClientType.MORKS;
GVL_MorkSUpgradedVer mORKS = new GVL_MorkSUpgradedVer();
Alarm alarm = new Alarm();
private GVL_MorkSUpgradedVer mORKS = new GVL_MorkSUpgradedVer();
private Alarm alarm = new Alarm();

public override void DoMain()
{
@@ -41,7 +18,8 @@ namespace BPASmartClient.MorkSUpgradedVer
DataParse();
Json<MorksPar>.Read();
Json<OrderStatistics>.Read();
if (Json<MorksPar>.Data.parSets == null) Json<MorksPar>.Data.parSets = new ObservableCollection<ParSet>();
if (Json<MorksPar>.Data.parSets == null)
Json<MorksPar>.Data.parSets = new ObservableCollection<ParSet>();
if (Json<MorksPar>.Data.parSets.Count < 6)
{
Json<MorksPar>.Data.parSets.Clear();
@@ -82,11 +60,13 @@ namespace BPASmartClient.MorkSUpgradedVer

ActionManage.GetInstance.Register(new Action<object>((o) =>
{
if (o != null && o is WritePar writePar) WriteData(writePar.Address, writePar.Value);
if (o != null && o is WritePar writePar)
WriteData(writePar.Address, writePar.Value);
}), "WriteVW");
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
if (o != null && o is WritePar writePar) WriteData(writePar.Address, writePar.Value);
if (o != null && o is WritePar writePar)
WriteData(writePar.Address, writePar.Value);
}), "WriteBools");
ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitDevice");
}
@@ -99,7 +79,6 @@ namespace BPASmartClient.MorkSUpgradedVer

public override void Stop()
{

}

private void ServerInit()
@@ -107,7 +86,8 @@ namespace BPASmartClient.MorkSUpgradedVer
//物料信息
EventBus.GetInstance().Subscribe<MaterialDeliveryEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (@event == null) return;
if (@event == null)
return;
if (@event is MaterialDeliveryEvent material)
{
orderMaterialDelivery = material.orderMaterialDelivery;
@@ -117,14 +97,13 @@ namespace BPASmartClient.MorkSUpgradedVer
//配方数据信息
EventBus.GetInstance().Subscribe<RecipeBomEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
if (@event == null) return;
if (@event == null)
return;
if (@event is RecipeBomEvent recipe)
{
recipeBoms = recipe.recipeBoms;
}
});


}

private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
@@ -145,7 +124,9 @@ namespace BPASmartClient.MorkSUpgradedVer
if (!string.IsNullOrEmpty(goodName) && !string.IsNullOrEmpty(SortNum))
{
EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { SortNum = SortNum, GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType });

var index = DataServer.GetInstance.morkS.MakeOrder.FindIndex(p => p.SortNum == SortNum);
//如果订单信息已经存在,则修改状态,否则新增。
if (index >= 0 && index < DataServer.GetInstance.morkS.MakeOrder.Count)
{
if (oRDER_STATUS == ORDER_STATUS.COMPLETED_COOK)
@@ -162,7 +143,8 @@ namespace BPASmartClient.MorkSUpgradedVer
else if (oRDER_STATUS == ORDER_STATUS.COMPLETED_TAKE)
{
var temp = DataServer.GetInstance.morkS.MakeOrderOver.FirstOrDefault(p => p.SortNum == SortNum);
if (temp != null) DataServer.GetInstance.morkS.MakeOrderOver.Remove(temp);
if (temp != null)
DataServer.GetInstance.morkS.MakeOrderOver.Remove(temp);
}
else
{
@@ -183,8 +165,6 @@ namespace BPASmartClient.MorkSUpgradedVer
}
//}



//var res = mORKS.doOrderEvents.FirstOrDefault(p => p.MorkOrder.SuborderId == subid);
//string goodName = string.Empty;
//string SortNum = string.Empty;
@@ -366,7 +346,6 @@ namespace BPASmartClient.MorkSUpgradedVer

alarm.MachineLowTemperature = !mORKS.TemperatureReaches;
}

}));

GetStatus("VW770", new Action<object>((obj) =>
@@ -375,7 +354,6 @@ namespace BPASmartClient.MorkSUpgradedVer
{
mORKS.CurrentFeedbackLoc = ushorts[0];
}

}));

mORKS.TakeBowlTaskCount = mORKS.TakeBowlTask.Count;
@@ -386,29 +364,23 @@ namespace BPASmartClient.MorkSUpgradedVer
mORKS.nsm.ElementAt(i).IsShield = Json<MorksPar>.Data.parSets.ElementAt(i).IsShield;
mORKS.nsm.ElementAt(i).NoodleCookerStatus = mORKS.NoodleCookerStatus[i];
}

//if (Status?.status?["PLC.PLCMachine.IsConnected"] is bool connected)
//{
// mORKS.IsConnected = connected;
//}

}

/// <summary>
/// 数据解析
/// </summary>
/// <summary>数据解析</summary>
private void DataParse()
{
EventBus.GetInstance().Subscribe<DoOrderEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle)
{
if (@event == null) return;
if (@event == null)
return;
if (@event is DoOrderEvent order)
{
mORKS.doOrderEvents.Add(order);
//mORKS.doe.TryAdd(order.MorkOrder.SuborderId, order);
if (order.MorkOrder.GoodBatchings == null) return;
if (mORKS.HistorySuborderId.Contains(order.MorkOrder.SuborderId)) return;
if (order.MorkOrder.GoodBatchings == null)
return;
if (mORKS.HistorySuborderId.Contains(order.MorkOrder.SuborderId))
return;
OrderCount++;
if (DateTime.Now.Subtract(Json<OrderStatistics>.Data.StatisticsTime).Days != 0)
Json<OrderStatistics>.Data.Count = 0;
@@ -503,9 +475,7 @@ namespace BPASmartClient.MorkSUpgradedVer
}
}

/// <summary>
/// 取碗控制
/// </summary>
/// <summary>取碗控制</summary>
private void TakeBowlTask()
{
if (mORKS.AllowRun && mORKS.TakeBowlTask.Count > 0 && !mORKS.DropBowlMechanismStatus && !mORKS.TakeBowlInterlock)
@@ -514,7 +484,8 @@ namespace BPASmartClient.MorkSUpgradedVer
var res = orderMaterialDelivery?.BatchingInfo?.Where(p => p.BatchingId == mORKS.TakeBowlTask.ElementAt(0).BatchingId).ToList();
if (res == null || res?.Count == 0)
{
if (mORKS.TakeBowlTask.TryDequeue(out OrderLocInfo orderLocInfo)) BowlControl(orderLocInfo);
if (mORKS.TakeBowlTask.TryDequeue(out OrderLocInfo orderLocInfo))
BowlControl(orderLocInfo);
}
else
{
@@ -547,9 +518,7 @@ namespace BPASmartClient.MorkSUpgradedVer
}
}

/// <summary>
/// 转台控制
/// </summary>
/// <summary>转台控制</summary>
private void TurntableControl()
{
if (Global.EnableLocalSimOrder)
@@ -573,7 +542,6 @@ namespace BPASmartClient.MorkSUpgradedVer
{
if (mORKS.SiloInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0)
{

var result = orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKS.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList();
if (result != null)
{
@@ -603,13 +571,15 @@ namespace BPASmartClient.MorkSUpgradedVer
DeviceProcessLogShow($"没有物料检测的启动转台控制,转台位置:[{loc}]");
break;
}
else if (mORKS.CurrentFeedbackLoc == loc && !mORKS.TurntableLocLists.Contains(loc)) mORKS.TurntableLocLists.Add(loc);
else if (mORKS.CurrentFeedbackLoc == loc && !mORKS.TurntableLocLists.Contains(loc))
mORKS.TurntableLocLists.Add(loc);
}
}
}
}
}
else DeviceProcessLogShow("未找到可用的物料信息");
else
DeviceProcessLogShow("未找到可用的物料信息");
}
}
}
@@ -624,7 +594,6 @@ namespace BPASmartClient.MorkSUpgradedVer
//转台到位检测
if (RTrig.GetInstance("TurntableInPlace").Start(mORKS.SiloInPlace && mORKS.CurrentLoc == mORKS.CurrentFeedbackLoc))
{

mORKS.TurntableInterlock = false;
DeviceProcessLogShow("转台到位检测");
}
@@ -639,12 +608,9 @@ namespace BPASmartClient.MorkSUpgradedVer
DeviceProcessLogShow("补料完成检测");
}
}

}

/// <summary>
/// 取面任务
/// </summary>
/// <summary>取面任务</summary>
private void TakeNoodleTask()
{
//取面控制
@@ -692,14 +658,13 @@ namespace BPASmartClient.MorkSUpgradedVer
}
}

/// <summary>
/// 出餐控制
/// </summary>
/// <summary>出餐控制</summary>
private void OutNoodleTask()
{
if (mORKS.AllowInvertedFace && mORKS.RobotTaskInterlock && !mORKS.RobotOutDinnigLock && !mORKS.TakeNoodleInterlock && mORKS.RobotStatus)
{
#region 修改之前的代码

//int loc = Array.FindIndex(mORKS.CookNodelId, p => p == mORKS.IngredientsCompleteId && p.Length > 0);
//if (loc >= 0 && loc <= 5)
//{
@@ -719,12 +684,12 @@ namespace BPASmartClient.MorkSUpgradedVer
// DeviceProcessLogShow($"{loc + 1} 号位置出餐控制,订单ID:{mORKS.OutMealId}");
// mORKS.CookNoodleCom[loc] = false;
// }
//}
#endregion
//}

#endregion 修改之前的代码

for (int loc = 0; loc < mORKS.CookNodelId.Length; loc++)
{

if (mORKS.CookNoodleCom[loc] && !mORKS.RobotOutDinnigLock)
{
SetTakeNoodleLoc((ushort)(loc + 1));
@@ -746,9 +711,7 @@ namespace BPASmartClient.MorkSUpgradedVer
}
}

/// <summary>
/// 信号检测
/// </summary>
/// <summary>信号检测</summary>
private void SingleDetect()
{
//允许倒面信号检测
@@ -766,21 +729,6 @@ namespace BPASmartClient.MorkSUpgradedVer
mORKS.RobotOutDinnigLock = false;
}

//2023-8-7:检测上升沿修改为延时。
//if (DelayRTrig.GetInstance("AllowFallNoodle").Start(mORKS.AllowInvertedFace, 500))
//{
// //mORKS.IngredientsCompleteId = mORKS.TakeBowlId;
// mORKS.IngredientsCompleteName = mORKS.TakeBowName;
// mORKS.IngredientsCompleteSortNum = mORKS.TakeBowSortNum;
// mORKS.TakeBowSortNum = 0;
// mORKS.TakeBowlId = string.Empty;
// mORKS.TakeBowName = string.Empty;
// //DeviceProcessLogShow($"碗到位,允许到面,{mORKS.IngredientsCompleteId}");
// DeviceProcessLogShow($"碗到位,允许倒面。");
// mORKS.TakeBowlInterlock = false;
// mORKS.RobotOutDinnigLock = false;
//}

//取餐完成逻辑处理
if (RTrig.GetInstance("CompleteChange1").Start(mORKS.DiningComplete) && mORKS.CookCompleteFlatBit == true)
{
@@ -820,25 +768,13 @@ namespace BPASmartClient.MorkSUpgradedVer
mORKS.PriorityJudgment = Delay.GetInstance("取餐优先级判断").Start(mORKS.TurntableLocLists.Count > 0 && !mORKS.TurntableLowPosition, 4);
//mORKS.RobotTaskInterlock = OutMealRequstCount > 0 && mORKS.AllowInvertedFace && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0 || mORKS.PriorityJudgment);
//mORKS.RobotTaskInterlock = isok && mORKS.AllowInvertedFace && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0 || mORKS.PriorityJudgment);
//2023-8-5注释修改,并联出餐请求,出餐优先。
//mORKS.RobotTaskInterlock = mORKS.AllowInvertedFace && (mlCount >= 6 || mORKS.RBTakeNoodleTask.Count == 0 || mORKS.PriorityJudgment);
mORKS.RobotTaskInterlock = mORKS.AllowInvertedFace && (OutMealRequstCount>=1 /*|| mlCount >= 6*/ || mORKS.RBTakeNoodleTask.Count == 0 || mORKS.PriorityJudgment);

//2023-8-7 添加PLC连接状态指示。
//if (RTrig.GetInstance("IsConnected").Start(mORKS.IsConnected))
//{
// DeviceProcessLogShow("设备已连接。");
//}

//if (TTrig.GetInstance("IsConnected").Start(mORKS.IsConnected))
//{
// DeviceProcessLogShow("设备已断开连接。");
//}
mORKS.RobotTaskInterlock = mORKS.AllowInvertedFace && (OutMealRequstCount >= 1 /*|| mlCount >= 6*/ || mORKS.RBTakeNoodleTask.Count == 0 || mORKS.PriorityJudgment);
}
/// <summary>
/// 语音提醒取餐
/// </summary>

/// <summary>语音提醒取餐</summary>
/// <param name="meal"></param>
private void WaitMeaLSpeak(string meal)
{
@@ -855,9 +791,7 @@ namespace BPASmartClient.MorkSUpgradedVer
EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value });
}

/// <summary>
/// 设备初始化
/// </summary>
/// <summary>设备初始化</summary>
public async void DeviceInit()
{
WriteData("M0.0", true);
@@ -865,9 +799,7 @@ namespace BPASmartClient.MorkSUpgradedVer
WriteData("M0.0", false);
}

/// <summary>
/// 取碗控制
/// </summary>
/// <summary>取碗控制</summary>
/// <param name="loc"></param>
private void TakeBowlControl(ushort loc)
{
@@ -881,9 +813,7 @@ namespace BPASmartClient.MorkSUpgradedVer
}
}

/// <summary>
/// 启动转台
/// </summary>
/// <summary>启动转台</summary>
/// <param name="loc"></param>
private void TurntableStart(ushort loc)
{
@@ -896,9 +826,7 @@ namespace BPASmartClient.MorkSUpgradedVer
}
}

/// <summary>
/// 设置倒面位置
/// </summary>
/// <summary>设置倒面位置</summary>
/// <param name="loc"></param>
private void SetFallNoodleLoc(ushort loc)
{
@@ -906,9 +834,7 @@ namespace BPASmartClient.MorkSUpgradedVer
WriteData($"M14.{loc - 1}", true);
}

/// <summary>
/// 设置出餐位置
/// </summary>
/// <summary>设置出餐位置</summary>
/// <param name="loc"></param>
private void SetTakeNoodleLoc(ushort loc)
{
@@ -916,8 +842,6 @@ namespace BPASmartClient.MorkSUpgradedVer
WriteData($"M15.{loc - 1}", true);
}



public override void SimOrder()
{
EventBus.GetInstance().Subscribe<MorksSimorderModel>(0, delegate (IEvent @event, EventCallBackHandle callBackHandle)
@@ -936,12 +860,10 @@ namespace BPASmartClient.MorkSUpgradedVer
mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = (ushort)msm.Bowloc, SuborderId = guid });
MessageLog.GetInstance.Show($"添加订单:碗位置【{(ushort)msm.Bowloc}】");
}

}
});
}
#endregion


#endregion PLC 控制函数
}
}
}

Loading…
Cancel
Save