|
|
@@ -32,6 +32,7 @@ namespace BPASmartClient.MorkS |
|
|
|
bool Initing; |
|
|
|
public override void StartMain() |
|
|
|
{ |
|
|
|
ServerInit(); |
|
|
|
DataParse(); |
|
|
|
ReadPLCData(); |
|
|
|
Main(); |
|
|
@@ -43,6 +44,29 @@ namespace BPASmartClient.MorkS |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void ServerInit() |
|
|
|
{ |
|
|
|
//物料信息 |
|
|
|
EventBus.EventBus.GetInstance().Subscribe<MaterialDeliveryEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) |
|
|
|
{ |
|
|
|
if (@event == null) return; |
|
|
|
if (@event is MaterialDeliveryEvent material) |
|
|
|
{ |
|
|
|
orderMaterialDelivery = material.orderMaterialDelivery; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
//配方数据信息 |
|
|
|
EventBus.EventBus.GetInstance().Subscribe<RecipeBomEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) |
|
|
|
{ |
|
|
|
if (@event == null) return; |
|
|
|
if (@event is RecipeBomEvent recipe) |
|
|
|
{ |
|
|
|
recipeBoms = recipe.recipeBoms; |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) |
|
|
|
{ |
|
|
|
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Id = DeviceId, Status = oRDER_STATUS, SubOrderId = subid }); |
|
|
@@ -165,7 +189,6 @@ namespace BPASmartClient.MorkS |
|
|
|
MessageLog.GetInstance.Show($"接收到{OrderCount}次订单"); |
|
|
|
foreach (var item in order.MorkOrder.GoodBatchings) |
|
|
|
{ |
|
|
|
//var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); |
|
|
|
var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); |
|
|
|
if (res != null) |
|
|
|
{ |
|
|
@@ -197,47 +220,6 @@ namespace BPASmartClient.MorkS |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (order is MorkOrderPush morkOrderPush) |
|
|
|
//{ |
|
|
|
// foreach (var item in morkOrderPush.GoodBatchings) |
|
|
|
// { |
|
|
|
// //var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); |
|
|
|
// var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); |
|
|
|
// if (res != null) |
|
|
|
// { |
|
|
|
// if (ushort.TryParse(res.BatchingLoc, out ushort loc)) |
|
|
|
// { |
|
|
|
// if (loc >= 1 && loc <= 5) |
|
|
|
// { |
|
|
|
// if (mORKS.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == morkOrderPush.SuborderId) == null) |
|
|
|
// mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = ushort.Parse(res.BatchingLoc), SuborderId = morkOrderPush.SuborderId, BatchingId = res.BatchingId }); |
|
|
|
// } |
|
|
|
// else if (loc >= 10 && loc <= 11) |
|
|
|
// { |
|
|
|
// int index = 0; |
|
|
|
// if (recipeBoms != null) |
|
|
|
// { |
|
|
|
// index = Array.FindIndex(recipeBoms.RecipeIds?.ToArray(), p => p.RecipeId == morkOrderPush.RecipeId); |
|
|
|
// index++; |
|
|
|
// } |
|
|
|
// if (mORKS.TakeBowlTask.FirstOrDefault(p => p.SuborderId == morkOrderPush.SuborderId) == null) |
|
|
|
// mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() |
|
|
|
// { |
|
|
|
// Loc = ushort.Parse(res.BatchingLoc), |
|
|
|
// SuborderId = morkOrderPush.SuborderId, |
|
|
|
// RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0 |
|
|
|
// }); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
//} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -247,7 +229,6 @@ namespace BPASmartClient.MorkS |
|
|
|
{ |
|
|
|
mORKS.AllowRun = mORKS.InitComplete; |
|
|
|
IsHealth = mORKS.Error && mORKS.InitComplete; |
|
|
|
//GeneralConfig.Healthy = mORKS.Error && mORKS.InitComplete && !GeneralConfig.EnableLocalSimOrder; |
|
|
|
|
|
|
|
TakeBowlTask(); |
|
|
|
|
|
|
@@ -308,14 +289,12 @@ namespace BPASmartClient.MorkS |
|
|
|
//正常轮询 |
|
|
|
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(); |
|
|
|
var result = orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKS.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList(); |
|
|
|
if (result != null) |
|
|
|
{ |
|
|
|
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; |
|
|
@@ -465,12 +444,6 @@ namespace BPASmartClient.MorkS |
|
|
|
TakeNoodleCompleteReset(); |
|
|
|
} |
|
|
|
|
|
|
|
//转台到位检测 |
|
|
|
//if (RTrig.GetInstance("TurntableInPlace").Start(mORKS.TurntableMoveInPlace)) |
|
|
|
//{ |
|
|
|
// mORKS.TurntableInterlock = false; |
|
|
|
//} |
|
|
|
|
|
|
|
int OutMealRequstCount = mORKS.CookNoodlesComplete.Where(p => p == true).ToList().Count; |
|
|
|
int mlCount = mORKS.NoodleCookerStatus.Where(p => p == true).ToList().Count; |
|
|
|
mORKS.RobotTaskInterlock = OutMealRequstCount > 0 && mORKS.AllowFallNoodle && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0); |
|
|
@@ -513,7 +486,7 @@ namespace BPASmartClient.MorkS |
|
|
|
private void TakeNoodleCompleteReset() |
|
|
|
{ |
|
|
|
WriteData("M100.4", false); |
|
|
|
//ModbusTcpHelper.GetInstance.Write(1124, WriteType.Coils, false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -524,11 +497,7 @@ namespace BPASmartClient.MorkS |
|
|
|
{ |
|
|
|
if (num >= 1 && num <= 6) |
|
|
|
{ |
|
|
|
//ushort addRess = (ushort)(1136 + num - 1); |
|
|
|
|
|
|
|
WriteData($"102.{num - 1}", false); |
|
|
|
|
|
|
|
//ModbusTcpHelper.GetInstance.Write(addRess, WriteType.Coils, false); |
|
|
|
MessageLog.GetInstance.Show($"{num}号煮面口占用复位"); |
|
|
|
} |
|
|
|
|
|
|
@@ -541,7 +510,6 @@ namespace BPASmartClient.MorkS |
|
|
|
private void SetRecipeNumber(ushort num) |
|
|
|
{ |
|
|
|
WriteData("VW0", num); |
|
|
|
//ModbusTcpHelper.GetInstance.Write(100, WriteType.HoldingRegisters, num); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -555,8 +523,6 @@ namespace BPASmartClient.MorkS |
|
|
|
mORKS.TurntableLocLists.Add(loc); |
|
|
|
WriteData("VW0", loc); |
|
|
|
WriteData("M0.5", true); |
|
|
|
//ModbusTcpHelper.GetInstance.Write(101, WriteType.HoldingRegisters, loc); |
|
|
|
//ModbusTcpHelper.GetInstance.Write(325, WriteType.Coils, true); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -566,7 +532,6 @@ namespace BPASmartClient.MorkS |
|
|
|
private void SetFallNoodleLoc(ushort loc) |
|
|
|
{ |
|
|
|
WriteData("VW4", loc); |
|
|
|
//ModbusTcpHelper.GetInstance.Write(102, WriteType.HoldingRegisters, loc); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -576,7 +541,6 @@ namespace BPASmartClient.MorkS |
|
|
|
private void SetTakeNoodleLoc(ushort loc) |
|
|
|
{ |
|
|
|
WriteData("VW6", loc); |
|
|
|
//ModbusTcpHelper.GetInstance.Write(103, WriteType.HoldingRegisters, loc); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -588,12 +552,10 @@ namespace BPASmartClient.MorkS |
|
|
|
if (loc == 10)//小碗 |
|
|
|
{ |
|
|
|
WriteData("M0.1", true); |
|
|
|
//ModbusTcpHelper.GetInstance.Write(321, WriteType.Coils, true); |
|
|
|
} |
|
|
|
else if (loc == 11)//大碗 |
|
|
|
{ |
|
|
|
WriteData("M0.2", true); |
|
|
|
//ModbusTcpHelper.GetInstance.Write(322, WriteType.Coils, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -603,7 +565,6 @@ namespace BPASmartClient.MorkS |
|
|
|
private void RobotTakeNoodle() |
|
|
|
{ |
|
|
|
WriteData("M0.3", true); |
|
|
|
//ModbusTcpHelper.GetInstance.Write(323, WriteType.Coils, true); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -612,13 +573,6 @@ namespace BPASmartClient.MorkS |
|
|
|
private void RobotOutMeal() |
|
|
|
{ |
|
|
|
WriteData("M0.4", true); |
|
|
|
//ModbusTcpHelper.GetInstance.Write(324, WriteType.Coils, true); |
|
|
|
//var result = ModbusTcpHelper.GetInstance.Read(324, ReadType.Coils); |
|
|
|
//if (result is bool res) |
|
|
|
// while (!res) |
|
|
|
// { |
|
|
|
// ModbusTcpHelper.GetInstance.Write(324, WriteType.Coils, true); |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -627,7 +581,6 @@ namespace BPASmartClient.MorkS |
|
|
|
private void ResetCookComplete() |
|
|
|
{ |
|
|
|
WriteData("M100.6", false); |
|
|
|
//ModbusTcpHelper.GetInstance.Write(1126, WriteType.Coils, false); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -636,7 +589,6 @@ namespace BPASmartClient.MorkS |
|
|
|
private void ResetAllowFallNoodle() |
|
|
|
{ |
|
|
|
WriteData("M100.3", false); |
|
|
|
//ModbusTcpHelper.GetInstance.Write(1123, WriteType.Coils, false); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -645,11 +597,8 @@ namespace BPASmartClient.MorkS |
|
|
|
public async void DeviceInit() |
|
|
|
{ |
|
|
|
WriteData("M0.0", true); |
|
|
|
//ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, true); |
|
|
|
await Task.Delay(1000); |
|
|
|
//ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, false); |
|
|
|
WriteData("M0.0", false); |
|
|
|
|
|
|
|
} |
|
|
|
#endregion |
|
|
|
|
|
|
|