@@ -13,6 +13,8 @@ using BPASmartClient.EventBus;
using static BPASmartClient.EventBus.EventBus;
using BPASmartClient.MorkS.ViewModel;
using BPASmartClient.MorkM.Model;
using System.Collections.ObjectModel;
using BPASmartClient.Model.PLC;
namespace BPASmartClient.MorkM
{
@@ -44,10 +46,10 @@ namespace BPASmartClient.MorkM
// string guid = new Guid().ToString();
// mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = (ushort)NoodleLoc, SuborderId = guid });
// MessageLog.GetInstance. Show($"添加订单:面条位置【{NoodleLoc}】");
// DeviceProcessLog Show($"添加订单:面条位置【{NoodleLoc}】");
// mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = (ushort)BowlLoc, SuborderId = guid });
// MessageLog.GetInstance. Show($"添加订单:碗位置【{BowlLoc}】");
// DeviceProcessLog Show($"添加订单:碗位置【{BowlLoc}】");
// Thread.Sleep(60000);
// }), "ForOrder");
// }), "EnableForOrder");
@@ -61,7 +63,7 @@ namespace BPASmartClient.MorkM
// }));
// }), "StopForOrder");
// MessageLog.GetInstance. Show("MORKM 设备初始化完成");
// DeviceProcessLog Show("MORKM 设备初始化完成");
//}
//private void ResetProgram()
@@ -192,12 +194,12 @@ namespace BPASmartClient.MorkM
// {
// orders.Add(new OrderLocInfo() { Loc = item, SuborderId = subId, MakeType = false });
// //mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = item, SuborderId = subId });
// //MessageLog.GetInstance. Show($"添加订单:面条位置【{item}】");
// //DeviceProcessLog Show($"添加订单:面条位置【{item}】");
// }
// if (item >= 10 && item <= 11)
// {
// mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = item, SuborderId = subId, MakeType = false });
// MessageLog.GetInstance. Show($"添加订单:碗位置【{item}】");
// DeviceProcessLog Show($"添加订单:碗位置【{item}】");
// }
// }
// mORKS.DishNumber = orders.Count;//订单中配菜的数量
@@ -242,7 +244,7 @@ namespace BPASmartClient.MorkM
//{
// if (broadcast != null && broadcast is IOTCommandModel iOTCommand)
// {
// MessageLog.GetInstance. Show($"IOT 广播消息命令 {iOTCommand.deviceName} 设备命令 {iOTCommand.CommandName} 控制变量{iOTCommand.CommandValue.Keys.First()}{iOTCommand.CommandValue[iOTCommand.CommandValue.Keys.First()]}");
// DeviceProcessLog Show($"IOT 广播消息命令 {iOTCommand.deviceName} 设备命令 {iOTCommand.CommandName} 控制变量{iOTCommand.CommandValue.Keys.First()}{iOTCommand.CommandValue[iOTCommand.CommandValue.Keys.First()]}");
// switch (iOTCommand.CommandName)
// {
// case 0://控制类
@@ -286,85 +288,95 @@ namespace BPASmartClient.MorkM
///// <summary>
///// 数据解析
///// </summary>
//public void DataParse<T>(T order)
//{
// OrderCount++;
// MessageLog.GetInstance.Show($"接收到{OrderCount}次订单");
// if (order is MorkOrderPush morkOrderPush)
// {
// OrderInformation newOrder = new OrderInformation();//2022.4.30 修改
// List<OrderLocInfo> locs = new List<OrderLocInfo>();
// foreach (var item in morkOrderPush.GoodBatchings)
// {
// var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId);
// if (res != null)
// {
// if (ushort.TryParse(res.BatchingLoc, out ushort loc))
// {
// if (loc >= 1 && loc <= 5)
// {
// locs.Add(new OrderLocInfo() { Loc = ushort.Parse(res.BatchingLoc), SuborderId = morkOrderPush.SuborderId, BatchingId = res.BatchingId, MakeType = morkOrderPush.MakeID == "2" }); //新增冒菜干拌or加汤
// }
// else if (loc >= 10 && loc <= 11)
// {
// int index = 0;
// if (Json<BatchingInfoPar>.Data.recipeBoms != null)
// {
// index = Array.FindIndex(Json<BatchingInfoPar>.Data.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 = 11,
// SuborderId = morkOrderPush.SuborderId,
// RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0
// });
// }
// }
// }
// }
// //手动供碗 调试用
// mORKS.TakeBowlTask.Enqueue(new OrderLocInfo()
// {
// Loc = 11,
// SuborderId = morkOrderPush.SuborderId,
// MakeType = morkOrderPush.MakeID == "2"
// });
// mORKS.DishNumber = locs.Count;//订单中配菜的数量 2022.4.30 修改
// while (locs.Count > 0)
// {
// for (int i = 0; i < locs.Count; i++)
// {
// var res = locs.FirstOrDefault(p => p.Loc % 2 != 0);
// if (res != null)
// {
// //if (mORKS.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == res.SuborderId) == null)
// mORKS.RBTakeNoodleTask.Enqueue(res);
// locs.Remove(res);
public void DataParse()
{
EventBus.EventBus.GetInstance().Subscribe<DoOrderEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle)
{
if (@event == null) return;
if (@event is DoOrderEvent order)
{
mORKS.doOrderEvents.Add(order);
if (order.MorkOrder.GoodBatchings == null) return;
OrderCount++;
OrderChange(order.MorkOrder.SuborderId, ORDER_STATUS.WAIT);
DeviceProcessLogShow($"接收到{OrderCount}次订单");
//if (order is MorkOrderPush morkOrderPush)
//{
OrderInformation newOrder = new OrderInformation();//2022.4.30 修改
List<OrderLocInfo> locs = new List<OrderLocInfo>();
foreach (var item in order.MorkOrder.GoodBatchings)
{
var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId);
if (res != null)
{
if (ushort.TryParse(res.BatchingLoc, out ushort loc))
{
if (loc >= 1 && loc <= 5)
{
locs.Add(new OrderLocInfo() { Loc = ushort.Parse(res.BatchingLoc), SuborderId = order.MorkOrder.SuborderId, BatchingId = res.BatchingId, MakeType = order.MorkOrder.MakeID == "2" }); //新增冒菜干拌or加汤
}
else if (loc >= 10 && loc <= 11)
{
int index = 0;
if (Json<BatchingInfoPar>.Data.recipeBoms != null)
{
index = Array.FindIndex(Json<BatchingInfoPar>.Data.recipeBoms?.RecipeIds.ToArray(), p => p.RecipeId == order.MorkOrder.RecipeId);
index++;
}
if (mORKS.TakeBowlTask.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
mORKS.TakeBowlTask.Enqueue(new OrderLocInfo()
{
Loc = 11,
SuborderId = order.MorkOrder.SuborderId,
RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0
});
}
}
}
}
//手动供碗 调试用
mORKS.TakeBowlTask.Enqueue(new OrderLocInfo()
{
Loc = 11,
SuborderId = order.MorkOrder.SuborderId,
MakeType = order.MorkOrder.MakeID == "2"
});
mORKS.DishNumber = locs.Count;//订单中配菜的数量 2022.4.30 修改
while (locs.Count > 0)
{
for (int i = 0; i < locs.Count; i++)
{
var res = locs.FirstOrDefault(p => p.Loc % 2 != 0);
if (res != null)
{
//if (mORKS.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == res.SuborderId) == null)
mORKS.RBTakeNoodleTask.Enqueue(res);
locs.Remove(res);
// }
// else
// {
// //if (mORKS.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == locs[i].SuborderId) == null)
// mORKS.RBTakeNoodleTask.Enqueue(locs[i]);
// mORKS.VegtabNum++;
// locs.RemoveAt(i);
}
else
{
//if (mORKS.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == locs[i].SuborderId) == null)
mORKS.RBTakeNoodleTask.Enqueue(locs[i]);
mORKS.VegtabNum++;
locs.RemoveAt(i);
// }
// }
// }
}
}
}
// Dictionary<string, OrderInformation> dic = new Dictionary<string, OrderInformation>();
// newOrder.DishNum = mORKS.DishNumber;
// newOrder.VegatableNumber = mORKS.VegtabNum;
// //newOrder.MakeType = morkOrderPush.MakeType;
// dic.Add(morkOrderPush.SuborderId, newOrder);
// mORKS.Conqueue.Enqueue(dic);
// mORKS.VegtabNum = 0;
// mORKS.DishNumber = 0;
// }
//}
Dictionary<string, OrderInformation> dic = new Dictionary<string, OrderInformation>();
newOrder.DishNum = mORKS.DishNumber;
newOrder.VegatableNumber = mORKS.VegtabNum;
//newOrder.MakeType = morkOrderPush.MakeType;
dic.Add(order.MorkOrder.SuborderId, newOrder);
mORKS.Conqueue.Enqueue(dic);
mORKS.VegtabNum = 0;
mORKS.DishNumber = 0;
//}
}
});
}
public void Main()
{
@@ -401,8 +413,8 @@ namespace BPASmartClient.MorkM
mORKS.OutMealType = orderLocInfo.MakeType;//新增冒菜干拌or加汤
TakeBowlControl(orderLocInfo.Loc);
SetRecipeNumber(orderLocInfo.RecipeNumber);
SimpleFactory.GetInstance. OrderChanged (mORKS.TakeBowlId, ORDER_STATUS.COOKING);
MessageLog.GetInstance. Show($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]");
OrderChange(mORKS.TakeBowlId, ORDER_STATUS.COOKING);
DeviceProcessLog Show($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]");
}
mORKS.TakeBowlInterlock = true;
}
@@ -413,24 +425,24 @@ namespace BPASmartClient.MorkM
/// </summary>
private void TurntableControl()
{
if (GeneralConfig.EnableLocalSimOrder)
{
//不做轮询,直接取面,模拟订单使用
if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0)
{
if (mORKS.TurntableLowerLimit)
{
TurntableStart(mORKS.RBTakeNoodleTask.ElementAt(0).Loc);
if (mORKS.RBTakeNoodleTask.ElementAt(0).Loc == mORKS.TurntableFeedbackloc)
{
mORKS.TurntableLocLists.Clear();
mORKS.AllowTakeNoodle = true;
MessageLog.GetInstance. Show($"控制机器人去转台【{mORKS.RBTakeNoodleTask.ElementAt(0).Loc}】号位置取面");
}
}
}
}
else
// if (GeneralConfig.EnableLocalSimOrder)
// {
// //不做轮询,直接取面,模拟订单使用
// if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0)
// {
// if (mORKS.TurntableLowerLimit)
// {
// TurntableStart(mORKS.RBTakeNoodleTask.ElementAt(0).Loc);
// if (mORKS.RBTakeNoodleTask.ElementAt(0).Loc == mORKS.TurntableFeedbackloc)
// {
// mORKS.TurntableLocLists.Clear();
// mORKS.AllowTakeNoodle = true;
// DeviceProcessLog Show($"控制机器人去转台【{mORKS.RBTakeNoodleTask.ElementAt(0).Loc}】号位置取面");
// }
// }
// }
// }
// else
{
//正常轮询
if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0)
@@ -445,7 +457,7 @@ namespace BPASmartClient.MorkM
TurntableStart(mORKS.TurntableFeedbackloc);
mORKS.TurntableLocLists.Clear();
mORKS.AllowTakeNoodle = true;
MessageLog.GetInstance. Show($"控制机器人去转台【{mORKS.TurntableFeedbackloc}】号位置取面");
DeviceProcessLog Show($"控制机器人去转台【{mORKS.TurntableFeedbackloc}】号位置取面");
}
else
{
@@ -458,7 +470,7 @@ namespace BPASmartClient.MorkM
if (mORKS.TurntableFeedbackloc != loc && !mORKS.TurntableLocLists.Contains(loc))
{
TurntableStart(loc);
MessageLog.GetInstance. Show($"没有物料检测的启动转台控制,转台位置:[{loc}]");
DeviceProcessLog Show($"没有物料检测的启动转台控制,转台位置:[{loc}]");
break;
}
else if (mORKS.TurntableFeedbackloc == loc && !mORKS.TurntableLocLists.Contains(loc)) mORKS.TurntableLocLists.Add(loc);
@@ -467,7 +479,7 @@ namespace BPASmartClient.MorkM
}
}
}
else MessageLog.GetInstance. Show("未找到可用的物料信息");
else DeviceProcessLog Show("未找到可用的物料信息");
}
}
@@ -476,7 +488,7 @@ namespace BPASmartClient.MorkM
{
mORKS.CurrentLoc = 0;
mORKS.TurntableInterlock = false;
MessageLog.GetInstance. Show("转台到位检测");
DeviceProcessLog Show("转台到位检测");
}
//补料完成检测
@@ -486,7 +498,7 @@ namespace BPASmartClient.MorkM
{
mORKS.TurntableLocLists.Clear();
mORKS.TurntableInterlock = false;
MessageLog.GetInstance. Show("补料完成检测");
DeviceProcessLog Show("补料完成检测");
}
}
}
@@ -512,7 +524,7 @@ namespace BPASmartClient.MorkM
//机器人开始取面
RobotTakeNoodle();
// SimpleFactory.GetInstance.OrderChanged(orderLocInfo.SuborderId, ORDER_STATUS.COOKING);
MessageLog.GetInstance. Show($"订单【{orderLocInfo.SuborderId}】,机器人倒面至【{loc + 1}】号煮面栏");
DeviceProcessLog Show($"订单【{orderLocInfo.SuborderId}】,机器人倒面至【{loc + 1}】号煮面栏");
//写入煮菜时间
List<ushort> values = new List<ushort>();
@@ -520,13 +532,14 @@ namespace BPASmartClient.MorkM
{
values.Add(2);//分
values.Add(0);//秒
ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetWordAddress($"VW{116 + (loc * 6)}"), WriteType.HoldingRegisters, values.ToArray());
// //ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetWordAddress($"VW{116 + (loc * 6)}"), WriteType.HoldingRegisters, values.ToArray());
EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address =$"VW{ 116 + (loc * 6) }" , Value = values.ToArray() });
}
else //荤菜
{
values.Add(4);//分
values.Add(0);//秒
ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetWordAddress($"VW{116 + (loc * 6)}"), WriteType.HoldingRegisters, values.ToArray() );
EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = $"VW{ 116 + (loc * 6) }", Value = values.ToArray() } );
}
@@ -588,7 +601,7 @@ namespace BPASmartClient.MorkM
// mORKS.CookNodelId[loc] = string.Empty;
mORKS.orderLocInfos[location] = null;
MessageLog.GetInstance. Show($"{location + 1}号位置出餐控制");
DeviceProcessLog Show($"{location + 1}号位置出餐控制");
mORKS.OutNoodleing = true;
mORKS.Count++;
CheckLastDish();
@@ -613,7 +626,7 @@ namespace BPASmartClient.MorkM
// mORKS.CookNodelId[loc] = string.Empty;
mORKS.orderLocInfos[location] = null;
// mORKS.Count++;
MessageLog.GetInstance. Show($"{location + 1}号位置出餐控制");
DeviceProcessLog Show($"{location + 1}号位置出餐控制");
mORKS.OutNoodleing = true;
mORKS.CountMeat++;
CheckLastDish();
@@ -649,7 +662,7 @@ namespace BPASmartClient.MorkM
if (mORKS.OutMealType)
{
AddSoup();//加汤
MessageLog.GetInstance. Show("正在加汤");
DeviceProcessLog Show("正在加汤");
}
else
{
@@ -690,8 +703,8 @@ namespace BPASmartClient.MorkM
mORKS.IngredientsCompleteId = mORKS.TakeBowlId;
// mORKS.TakeBowlId = string.Empty;
// MessageLog.GetInstance. Show("碗到位,允许到面");
MessageLog.GetInstance. Show($"碗到位,允许到面,{mORKS.IngredientsCompleteId}");
// DeviceProcessLog Show("碗到位,允许到面");
DeviceProcessLog Show($"碗到位,允许到面,{mORKS.IngredientsCompleteId}");
// mORKS.TakeBowlInterlock = false;
}
@@ -699,16 +712,16 @@ namespace BPASmartClient.MorkM
if (RTrig.GetInstance("CompleteChange").Start(mORKS.RbOutMealComplete))
{
SimpleFactory.GetInstance. OrderChanged (mORKS.OutMealId, ORDER_STATUS.COMPLETED_COOK);
MessageLog.GetInstance. Show($"订单【{mORKS.OutMealId}】制作完成");
OrderChange(mORKS.OutMealId, ORDER_STATUS.COMPLETED_COOK);
DeviceProcessLog Show($"订单【{mORKS.OutMealId}】制作完成");
mORKS.OutNoodleing = false;
}
//取餐完成逻辑处理
if (DelayRTrig.GetInstance("CompleteChange1").Start(mORKS.RbOutMealComplete && !mORKS.TakeMealDetect, 2))
{
SimpleFactory.GetInstance. OrderChanged (mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE);
MessageLog.GetInstance. Show($"订单【{mORKS.OutMealId}】取餐完成");
OrderChange(mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE);
DeviceProcessLog Show($"订单【{mORKS.OutMealId}】取餐完成");
ResetCookComplete();
mORKS.OutMealId = string.Empty;
}
@@ -719,7 +732,7 @@ namespace BPASmartClient.MorkM
mORKS.TakeNoodleInterlock = false;
mORKS.AllowTakeNoodle = false;
mORKS.TurntableInterlock = false;
MessageLog.GetInstance. Show("机器人取面完成信号检测");
DeviceProcessLog Show("机器人取面完成信号检测");
TakeNoodleCompleteReset();
}
@@ -777,12 +790,12 @@ namespace BPASmartClient.MorkM
}
if (recipeBoms.Count > 0)
{
if (ModbusTcpHelper.GetInstance.Write(1100, WriteType.HoldingRegisters, recipeBoms.ToArray()))
{
MessageLog.GetInstance. Show("成功写入配方数据");
}
// if (// ModbusTcpHelper.GetInstance.Write(1100, WriteType.HoldingRegisters, recipeBoms.ToArray()))
// {
// DeviceProcessLog Show("成功写入配方数据");
// }
}
else { MessageLog.GetInstance. Show("配方数据为空"); }
else { DeviceProcessLog Show("配方数据为空"); }
}
/// <summary>
@@ -790,7 +803,7 @@ namespace BPASmartClient.MorkM
/// </summary>
private void TakeNoodleCompleteReset()
{
ModbusTcpHelper.GetInstance.Write(1124, WriteType.Coils, false);
//// ModbusTcpHelper.GetInstance.Write(1124, WriteType.Coils, false);
}
/// <summary>
@@ -802,8 +815,8 @@ namespace BPASmartClient.MorkM
if (num >= 1 && num <= 6)
{
ushort addRess = (ushort)(1136 + num - 1);
ModbusTcpHelper.GetInstance.Write(addRess, WriteType.Coils, false);
MessageLog.GetInstance. Show($"{num}号煮面口占用复位");
// ModbusTcpHelper.GetInstance.Write(addRess, WriteType.Coils, false);
DeviceProcessLog Show($"{num}号煮面口占用复位");
}
}
@@ -814,7 +827,7 @@ namespace BPASmartClient.MorkM
/// <param name="num"></param>
private void SetRecipeNumber(ushort num)
{
ModbusTcpHelper.GetInstance.Write(100, WriteType.HoldingRegisters, num);
// ModbusTcpHelper.GetInstance.Write(100, WriteType.HoldingRegisters, num);
}
/// <summary>
@@ -826,8 +839,8 @@ namespace BPASmartClient.MorkM
mORKS.CurrentLoc = loc;
mORKS.TurntableInterlock = true;
mORKS.TurntableLocLists.Add(loc);
ModbusTcpHelper.GetInstance.Write(101, WriteType.HoldingRegisters, loc);
ModbusTcpHelper.GetInstance.Write(325, WriteType.Coils, true);
// ModbusTcpHelper.GetInstance.Write(101, WriteType.HoldingRegisters, loc);
// ModbusTcpHelper.GetInstance.Write(325, WriteType.Coils, true);
}
/// <summary>
@@ -836,7 +849,7 @@ namespace BPASmartClient.MorkM
/// <param name="loc"></param>
private void SetFallNoodleLoc(ushort loc)
{
ModbusTcpHelper.GetInstance.Write(102, WriteType.HoldingRegisters, loc);
// ModbusTcpHelper.GetInstance.Write(102, WriteType.HoldingRegisters, loc);
}
/// <summary>
@@ -845,7 +858,7 @@ namespace BPASmartClient.MorkM
/// <param name="loc"></param>
private void SetTakeNoodleLoc(ushort loc)
{
ModbusTcpHelper.GetInstance.Write(103, WriteType.HoldingRegisters, loc);
// ModbusTcpHelper.GetInstance.Write(103, WriteType.HoldingRegisters, loc);
}
/// <summary>
@@ -856,11 +869,11 @@ namespace BPASmartClient.MorkM
{
if (loc == 10)//小碗
{
ModbusTcpHelper.GetInstance.Write(321, WriteType.Coils, true);
// ModbusTcpHelper.GetInstance.Write(321, WriteType.Coils, true);
}
else if (loc == 11)//大碗
{
ModbusTcpHelper.GetInstance.Write(322, WriteType.Coils, true);
// ModbusTcpHelper.GetInstance.Write(322, WriteType.Coils, true);
}
}
@@ -869,7 +882,7 @@ namespace BPASmartClient.MorkM
/// </summary>
private void RobotTakeNoodle()
{
ModbusTcpHelper.GetInstance.Write(323, WriteType.Coils, true);
// ModbusTcpHelper.GetInstance.Write(323, WriteType.Coils, true);
}
/// <summary>
@@ -877,13 +890,13 @@ namespace BPASmartClient.MorkM
/// </summary>
private void RobotOutMeal()
{
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);
}
// 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>
@@ -891,7 +904,7 @@ namespace BPASmartClient.MorkM
/// </summary>
private void ResetCookComplete()
{
ModbusTcpHelper.GetInstance.Write(1126, WriteType.Coils, false);
// ModbusTcpHelper.GetInstance.Write(1126, WriteType.Coils, false);
}
/// <summary>
@@ -899,7 +912,7 @@ namespace BPASmartClient.MorkM
/// </summary>
private void ResetAllowFallNoodle()
{
ModbusTcpHelper.GetInstance.Write(1123, WriteType.Coils, false);
// ModbusTcpHelper.GetInstance.Write(1123, WriteType.Coils, false);
}
/// <summary>
@@ -907,9 +920,9 @@ namespace BPASmartClient.MorkM
/// </summary>
public async void DeviceInit()
{
ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, true);
// ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, true);
await Task.Delay(1000);
ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, false);
// ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, false);
}
@@ -918,7 +931,8 @@ namespace BPASmartClient.MorkM
/// </summary>
public void CookComplete()
{
ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetBoolAddress("M0.6"), WriteType.Coils, true);
////ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetBoolAddress("M0.6"), WriteType.Coils, true);
EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = "M0.6", Value = true });
}
/// <summary>
@@ -926,7 +940,8 @@ namespace BPASmartClient.MorkM
/// </summary>
public void AddSoup()
{
ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetBoolAddress("M0.7"), WriteType.Coils, true);
////ModbusTcpHelper.GetInstance.Write((ushort)ModbusTcpHelper.GetInstance.GetBoolAddress("M0.7"), WriteType.Coils, true);
EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = "M0.7", Value = true });
}
private void ServerInit()
@@ -987,7 +1002,10 @@ namespace BPASmartClient.MorkM
}), "WriteBools");
ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitDevice");
}
private void WriteData(string address, object value)
{
EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value });
}
public override void ResetProgram()
{
mORKS = null;