@@ -0,0 +1,21 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace HBLConsole.Abstract | |||||
{ | |||||
public abstract class ControlAbstract | |||||
{ | |||||
public abstract void Init(); | |||||
public Action ReadDataAction { get; set; } | |||||
public Action MainAction { get; set; } | |||||
public abstract void ReadData(); | |||||
public abstract void Main(); | |||||
public abstract void ResetProgram(); | |||||
} | |||||
} |
@@ -13,7 +13,7 @@ using BPA.Utility; | |||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
using HBLConsole.Communication; | using HBLConsole.Communication; | ||||
namespace HBLConsole.Business.MessageServer | |||||
namespace HBLConsole.Business.AbstractServer | |||||
{ | { | ||||
public class Base : AbstractMessageServer | public class Base : AbstractMessageServer | ||||
{ | { | ||||
@@ -22,10 +22,24 @@ namespace HBLConsole.Business.MessageServer | |||||
if (orderInfo == null) return; | if (orderInfo == null) return; | ||||
if (orderInfo is MorkOrderPush morkOrderpush) | if (orderInfo is MorkOrderPush morkOrderpush) | ||||
{ | { | ||||
OrderData order = Json<MorkOrderPushPar>.Data.morkOrderPushes.Find(par => par.OrderPush?.SuborderId == morkOrderpush.SuborderId); | |||||
//OrderData order = Json<MorkOrderPushPar>.Data.morkOrderPushes.Find(par => par.OrderPush?.SuborderId == morkOrderpush.SuborderId); | |||||
//if (order == null)//防止重复订单 | |||||
//{ | |||||
// Json<MorkOrderPushPar>.Data.morkOrderPushes.Add(new OrderData() | |||||
// { | |||||
// OrderStatus = ORDER_STATUS.WAIT, | |||||
// IsSelected = true, | |||||
// OrderPush = morkOrderpush | |||||
// }); | |||||
// ActionManage.GetInstance.Send("AddOrder", morkOrderpush); | |||||
// ActionManage.GetInstance.Send("DataParse", morkOrderpush); | |||||
//} | |||||
OrderData order = Json<KeepDataBase>.Data.orderLists.FirstOrDefault(par => par.OrderPush?.SuborderId == morkOrderpush.SuborderId); | |||||
if (order == null)//防止重复订单 | if (order == null)//防止重复订单 | ||||
{ | { | ||||
Json<MorkOrderPushPar>.Data.morkOrderPushes.Add(new OrderData() | |||||
Json<KeepDataBase>.Data.orderLists.Add(new OrderData() | |||||
{ | { | ||||
OrderStatus = ORDER_STATUS.WAIT, | OrderStatus = ORDER_STATUS.WAIT, | ||||
IsSelected = true, | IsSelected = true, | ||||
@@ -74,12 +88,11 @@ namespace HBLConsole.Business.MessageServer | |||||
{ | { | ||||
Json<BatchingInfoPar>.Data.recipeBoms = JsonConvert.DeserializeObject<RecipeBoms>(result); | Json<BatchingInfoPar>.Data.recipeBoms = JsonConvert.DeserializeObject<RecipeBoms>(result); | ||||
ActionManage.GetInstance.Send("recipeBom"); | ActionManage.GetInstance.Send("recipeBom"); | ||||
//WritePlcData(); | |||||
MessageLog.GetInstance.Show("接收到辅料信息"); | |||||
} | } | ||||
else if (PushType == 0) | else if (PushType == 0) | ||||
{ | { | ||||
Json<BatchingInfoPar>.Data.orderMaterialDelivery = JsonConvert.DeserializeObject<OrderMaterialDelivery>(result); | Json<BatchingInfoPar>.Data.orderMaterialDelivery = JsonConvert.DeserializeObject<OrderMaterialDelivery>(result); | ||||
} | } | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
@@ -109,33 +122,8 @@ namespace HBLConsole.Business.MessageServer | |||||
MessageLog.GetInstance.Show("接收到辅料信息"); | MessageLog.GetInstance.Show("接收到辅料信息"); | ||||
ActionManage.GetInstance.Send("recipeBom"); | ActionManage.GetInstance.Send("recipeBom"); | ||||
} | } | ||||
//WritePlcData(); | |||||
} | } | ||||
/// <summary> | |||||
/// 写配方数据到PLC | |||||
/// </summary> | |||||
//private void WritePlcData() | |||||
//{ | |||||
// return; | |||||
// //写配方数据到PLC | |||||
// List<ushort> recipeBoms = new List<ushort>(); | |||||
// foreach (var item in Json<BatchingInfoPar>.Data.recipeBoms.RecipeIds) | |||||
// { | |||||
// foreach (var rec in item.Recipes) | |||||
// { | |||||
// recipeBoms.Add((ushort)rec); | |||||
// } | |||||
// } | |||||
// if (recipeBoms.Count > 0) | |||||
// { | |||||
// if (ModbusTcpHelper.GetInstance.Write(1100, WriteType.HoldingRegisters, recipeBoms.ToArray())) | |||||
// { | |||||
// MessageLog.GetInstance.Show("成功写入配方数据"); | |||||
// } | |||||
// } | |||||
//} | |||||
/// <summary> | /// <summary> | ||||
/// 订单状态改变 | /// 订单状态改变 | ||||
/// </summary> | /// </summary> |
@@ -0,0 +1,61 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading; | |||||
using System.Threading.Tasks; | |||||
using HBLConsole.Abstract; | |||||
using HBLConsole.Service; | |||||
using HBLConsole.Factory; | |||||
using HBLConsole.Model; | |||||
namespace HBLConsole.Business.AbstractServer | |||||
{ | |||||
public class ControlBase : ControlAbstract | |||||
{ | |||||
public override void Init() | |||||
{ | |||||
Main(); | |||||
ReadData(); | |||||
ResetProgram(); | |||||
} | |||||
public override void Main() | |||||
{ | |||||
ThreadManage.GetInstance.StartLong(new Action(() => | |||||
{ | |||||
if (MainAction != null) MainAction(); | |||||
Thread.Sleep(100); | |||||
}), "MainTask"); | |||||
} | |||||
public override void ReadData() | |||||
{ | |||||
ThreadManage.GetInstance.StartLong(new Action(() => | |||||
{ | |||||
if (ReadDataAction != null) ReadDataAction(); | |||||
Thread.Sleep(100); | |||||
}), "ReadPLCData"); | |||||
} | |||||
public override 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(() => | |||||
{ | |||||
SimpleFactory.GetInstance.CreateGvl(); | |||||
ReadData(); | |||||
Main(); | |||||
})); | |||||
})); | |||||
} | |||||
Thread.Sleep(10); | |||||
}), "ResetProgram"); | |||||
} | |||||
} | |||||
} |
@@ -8,6 +8,7 @@ using System.Drawing; | |||||
using HBLConsole.Service; | using HBLConsole.Service; | ||||
using HBLConsole.Model; | using HBLConsole.Model; | ||||
using System.Collections.ObjectModel; | using System.Collections.ObjectModel; | ||||
using HBLConsole.GVL; | |||||
namespace HBLConsole.Business | namespace HBLConsole.Business | ||||
{ | { | ||||
@@ -64,6 +65,15 @@ namespace HBLConsole.Business | |||||
}; | }; | ||||
Sqlite<Alarm>.GetInstance.Base.Add(tempAlarm); | Sqlite<Alarm>.GetInstance.Base.Add(tempAlarm); | ||||
IotReport.GetInstance.SendAlarmMessage(new BPA.Message.API请求.AlarmTable | |||||
{ | |||||
AlarmTime=DateTime.Now, | |||||
AlarmType= tempAlarm.Grade, | |||||
AlarmMessage= tempAlarm.Info, | |||||
AlarmVla= tempAlarm.Value, | |||||
ClientId= InternetInfo.ClientId.ToString() | |||||
}); | |||||
if (Alarms.FirstOrDefault(p => p.Info == AlarmInfo) == null) | if (Alarms.FirstOrDefault(p => p.Info == AlarmInfo) == null) | ||||
{ | { | ||||
Alarms.Add(tempAlarm); | Alarms.Add(tempAlarm); | ||||
@@ -46,6 +46,7 @@ namespace HBLConsole.Business | |||||
MessagePackage.Timestamp = DateTime.Now; | MessagePackage.Timestamp = DateTime.Now; | ||||
MessagePackage.Message = deviceStatus;//GetMessage == null ? deviceStatus : GetMessage(); | MessagePackage.Message = deviceStatus;//GetMessage == null ? deviceStatus : GetMessage(); | ||||
MqttHelper.GetInstance.MqttPublishAsync(Topic, MessagePackage.Serialize()); | MqttHelper.GetInstance.MqttPublishAsync(Topic, MessagePackage.Serialize()); | ||||
IotReport.GetInstance.SendTargetMessage(); | |||||
Thread.Sleep(1000); | Thread.Sleep(1000); | ||||
}), "设备心跳上报"); | }), "设备心跳上报"); | ||||
@@ -11,6 +11,7 @@ using System.Text; | |||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using HBLConsole.Factory; | using HBLConsole.Factory; | ||||
using BPA.Message.API请求; | |||||
namespace HBLConsole.Business | namespace HBLConsole.Business | ||||
{ | { | ||||
@@ -19,163 +20,209 @@ namespace HBLConsole.Business | |||||
#region 单例模式 | #region 单例模式 | ||||
private volatile static IotReport _Instance; | private volatile static IotReport _Instance; | ||||
public static IotReport GetInstance => _Instance ?? (_Instance = new IotReport()); | public static IotReport GetInstance => _Instance ?? (_Instance = new IotReport()); | ||||
private IotReport() | |||||
{ | |||||
IOTDev.GetInstance().Set(InternetInfo.ProductKey, InternetInfo.DeviceName, InternetInfo.DeviceSecret); | |||||
IOTDev.GetInstance().CreateLinks(); | |||||
IOTDev.GetInstance().IOT_Subscribe(IOTDev.BroadcastTopic);//订阅广播主题 | |||||
IOTDev.actionIOT += actionIOTHandler;//消息数据回调 | |||||
IOTDev.UNConnectMqtt += new Action<string>((o) => { MessageLog.GetInstance.Show(o); }); | |||||
if (IOTDev.client.IsConnected) MessageLog.GetInstance.Show($"设备{InternetInfo.DeviceName}阿里云连接成功."); | |||||
else MessageLog.GetInstance.Show($"设备{InternetInfo.DeviceName}阿里云连接失败.不能上报业务信息"); | |||||
//string NameSpace = $"HBLConsole.{GeneralConfig.DeviceType}"; | |||||
//control = (IControl)(Assembly.Load(NameSpace).GetType($"{NameSpace}.Control_{GeneralConfig.DeviceType}"))?.GetProperty("Instance").GetValue(null); | |||||
} | |||||
#endregion | #endregion | ||||
#region 变量 | #region 变量 | ||||
/// <summary> | /// <summary> | ||||
/// 大屏上报Model | |||||
/// 查询出当前设备信息 | |||||
/// </summary> | /// </summary> | ||||
public IOTDevSXModel iOTDevSXModel = new IOTDevSXModel() { SBMC = InternetInfo.DeviceName, SBMS = InternetInfo.DeviceMS }; | |||||
public DeviceTable device; | |||||
/// <summary> | /// <summary> | ||||
/// 当前控制的设备控件 | |||||
/// 大屏上报Model | |||||
/// </summary> | /// </summary> | ||||
//public IControl control; | |||||
public IOTDevSXModel iOTDevSXModel = new IOTDevSXModel() { }; | |||||
#endregion | #endregion | ||||
#region 事件 | |||||
#region IOT上报公共调用 | |||||
/// <summary> | /// <summary> | ||||
/// 关闭IOT连接 | |||||
/// 上报告警消息 | |||||
/// 调用示例: SendAlarmMessage(new AlarmTable { AlarmTime = DateTime.Now,AlarmType = "1",AlarmMessage = "煮面机异常",AlarmVla = "煮面机" }); | |||||
/// </summary> | /// </summary> | ||||
public static void Close() | |||||
/// <param name="alarmTable"></param> | |||||
public void SendAlarmMessage(AlarmTable alarmTable) | |||||
{ | { | ||||
if (IOTDev.client != null) | |||||
IOTDev.GetInstance().Disconnect(); | |||||
if (IOTDevServer.client != null && IOTDevServer.client.IsConnected && device!=null) | |||||
{ | |||||
alarmTable.ClientId = InternetInfo.ClientId.ToString(); | |||||
alarmTable.devicename = device.devicename; | |||||
string json = Tools.JsonConvertTools<IotModel<AlarmIOT>>(new IotModel<AlarmIOT> { @params = new AlarmIOT { GJXX = Tools.JsonConvertTools(alarmTable) } }); | |||||
IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic,json); | |||||
} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 获取属性状态 | |||||
/// 上报日志消息 | |||||
/// 调用示例:SendLogMessage(new LogTable { LogTime = DateTime.Now,LogType = "1",LogMessage = "程序异常",LogVla = "程序" }); | |||||
/// </summary> | /// </summary> | ||||
public T GetTypeValue<T>(string str) | |||||
/// <param name="logTable"></param> | |||||
public void SendLogMessage(LogTable logTable) | |||||
{ | { | ||||
if (IOTDevServer.client != null && IOTDevServer.client.IsConnected && device != null) | |||||
{ | |||||
logTable.devicename = device.devicename; | |||||
logTable.ClientId = InternetInfo.ClientId.ToString(); | |||||
string json = Tools.JsonConvertTools<IotModel<LogIOT>>(new IotModel<LogIOT> { @params = new LogIOT { SZXX = Tools.JsonConvertTools(logTable) } }); | |||||
IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic,json); | |||||
} | |||||
} | |||||
return (T)SimpleFactory.GetInstance.GVL.GetType().GetProperty(str).GetValue(SimpleFactory.GetInstance.GVL, null); | |||||
//return (T)control.GetT().GetType().GetProperty(str).GetValue(control.GetT(),null); | |||||
/// <summary> | |||||
/// 上报节点状态消息 | |||||
/// 调用示例:SendNodeStatusMessage("json字符串"); | |||||
/// </summary> | |||||
/// <param name="json"></param> | |||||
public void SendNodeStatusMessage(string json) | |||||
{ | |||||
if (IOTDevServer.client!=null && IOTDevServer.client.IsConnected && device != null) | |||||
{ | |||||
string jsonstr = Tools.JsonConvertTools<IotModel<NodeStatusIOT>>(new IotModel<NodeStatusIOT> { @params = new NodeStatusIOT { NodeStatus = Tools.JsonConvertTools(json) } }); | |||||
IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic,jsonstr); | |||||
} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 设置上报数据 | |||||
/// 上报属性状态 | |||||
/// 调用示例:SendTargetMessage(); | |||||
/// </summary> | /// </summary> | ||||
public void SetData() | |||||
/// <param name="json"></param> | |||||
public void SendTargetMessage() | |||||
{ | { | ||||
#region 上报数据整理 | |||||
#region 基本数据 | |||||
//设置基本属性与状态 | |||||
iOTDevSXModel.SetJBSX(new DevSX | |||||
if (IOTDevServer.client != null && IOTDevServer.client.IsConnected && device != null) | |||||
{ | { | ||||
data = new List<DevSXBase> | |||||
string kzsx = string.Empty; | |||||
string jbsx = Tools.JsonConvertTools<DevSX>(new DevSX | |||||
{ | |||||
data = new List<DevSXBase> | |||||
{ | { | ||||
new DevSXBase { SXMC="设备硬件",SXLX="机器人",SXStatus=ModbusTcpHelper.GetInstance.Connected | new DevSXBase { SXMC="设备硬件",SXLX="机器人",SXStatus=ModbusTcpHelper.GetInstance.Connected | ||||
,SXYCMS=ModbusTcpHelper.GetInstance.Connected?"":DateTime.Now+" 异常,机器人未连接,疑似未连接网络...."}, | ,SXYCMS=ModbusTcpHelper.GetInstance.Connected?"":DateTime.Now+" 异常,机器人未连接,疑似未连接网络...."}, | ||||
new DevSXBase { SXMC="设备软件",SXLX="上位机",SXStatus=true } | new DevSXBase { SXMC="设备软件",SXLX="上位机",SXStatus=true } | ||||
} | } | ||||
}); | |||||
#endregion | |||||
#region 扩展数据 | |||||
bool IsAllowRun = GetTypeValue<bool>("AllowRun"); | |||||
bool TemperatureReached = GetTypeValue<bool>("TemperatureReached"); | |||||
bool MissingBowl = GetTypeValue<bool>("MissingBowl"); | |||||
bool MissingBowlSignal2 = GetTypeValue<bool>("MissingBowlSignal2"); | |||||
bool IsNoodles = GetTypeValue<bool>("IsNoodles");//转台 | |||||
bool AllowFallNoodle = GetTypeValue<bool>("AllowFallNoodle");//是否允许到面 | |||||
bool[] CookNoodlesComplete = GetTypeValue<bool[]>("CookNoodlesComplete");//煮面完成上升信号 | |||||
bool isCookNoodles = CookNoodlesComplete.ToList().Find(o => o); | |||||
//设置扩展属性与状态,连接上机器人后才会处罚 | |||||
if (IsAllowRun) | |||||
{ | |||||
iOTDevSXModel.SetKZSX(new DevSX | |||||
}); | |||||
bool IsAllowRun = GetTypeValue<bool>("AllowRun"); | |||||
bool TemperatureReached = GetTypeValue<bool>("TemperatureReached"); | |||||
bool MissingBowl = GetTypeValue<bool>("MissingBowl"); | |||||
bool MissingBowlSignal2 = GetTypeValue<bool>("MissingBowlSignal2"); | |||||
bool IsNoodles = GetTypeValue<bool>("IsNoodles");//转台 | |||||
bool AllowFallNoodle = GetTypeValue<bool>("AllowFallNoodle");//是否允许到面 | |||||
bool[] CookNoodlesComplete = GetTypeValue<bool[]>("CookNoodlesComplete");//煮面完成上升信号 | |||||
bool isCookNoodles = CookNoodlesComplete.ToList().Find(o => o); | |||||
//设置扩展属性与状态,连接上机器人后才会处罚 | |||||
if (IsAllowRun) | |||||
{ | { | ||||
data = new List<DevSXBase> | |||||
kzsx = Tools.JsonConvertTools<DevSX>(new DevSX | |||||
{ | { | ||||
new DevSXBase { SXMC="设备硬件",SXLX="煮面炉",SXStatus= !TemperatureReached , | |||||
SXYCMS=!TemperatureReached?"":DateTime.Now+" 异常,煮面炉温度不够,疑似正在加热或者未工作...."}, | |||||
new DevSXBase { SXMC="设备硬件",SXLX="装小碗结构",SXStatus=MissingBowl , | |||||
SXYCMS=MissingBowl?"":DateTime.Now+" 异常,缺小碗...."}, | |||||
new DevSXBase { SXMC="设备硬件",SXLX="装大碗结构",SXStatus=MissingBowlSignal2 , | |||||
SXYCMS=MissingBowlSignal2?"":DateTime.Now+" 异常,缺大碗...."}, | |||||
new DevSXBase { SXMC="设备硬件",SXLX="取面转台",SXStatus=IsNoodles , | |||||
SXYCMS=IsNoodles?"":DateTime.Now+" 异常,转台位置缺少物料...."}, | |||||
new DevSXBase { SXMC="设备硬件",SXLX="配料机",SXStatus=!(!AllowFallNoodle && isCookNoodles) , | |||||
SXYCMS=!((!AllowFallNoodle && isCookNoodles))?"":DateTime.Now+" 异常,配料机未配完料,疑似碗未到配料机下方或者配料机未工作...."} | |||||
} | |||||
}); | |||||
} | |||||
else | |||||
{ | |||||
iOTDevSXModel.SetKZSX(new DevSX { data = new List<DevSXBase> { new DevSXBase { SXMC = "", SXLX = "" } } }); | |||||
data = new List<DevSXBase> | |||||
{ | |||||
new DevSXBase { SXMC="设备硬件",SXLX="煮面炉",SXStatus= !TemperatureReached , | |||||
SXYCMS=!TemperatureReached?"":DateTime.Now+" 异常,煮面炉温度不够,疑似正在加热或者未工作...."}, | |||||
new DevSXBase { SXMC="设备硬件",SXLX="装小碗结构",SXStatus=MissingBowl , | |||||
SXYCMS=MissingBowl?"":DateTime.Now+" 异常,缺小碗...."}, | |||||
new DevSXBase { SXMC="设备硬件",SXLX="装大碗结构",SXStatus=MissingBowlSignal2 , | |||||
SXYCMS=MissingBowlSignal2?"":DateTime.Now+" 异常,缺大碗...."}, | |||||
new DevSXBase { SXMC="设备硬件",SXLX="取面转台",SXStatus=IsNoodles , | |||||
SXYCMS=IsNoodles?"":DateTime.Now+" 异常,转台位置缺少物料...."}, | |||||
new DevSXBase { SXMC="设备硬件",SXLX="配料机",SXStatus=!(!AllowFallNoodle && isCookNoodles) , | |||||
SXYCMS=!((!AllowFallNoodle && isCookNoodles))?"":DateTime.Now+" 异常,配料机未配完料,疑似碗未到配料机下方或者配料机未工作...."} | |||||
} | |||||
}); | |||||
} | |||||
string jsonstr = Tools.JsonConvertTools<IotModel<TargetIOT>>(new IotModel<TargetIOT> { @params = new TargetIOT { JBSX = jbsx,KZSX = kzsx } }); | |||||
IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic,jsonstr); | |||||
} | } | ||||
#endregion | |||||
//设置告警消息 | |||||
#region 告警消息 | |||||
List<DevSXBase> bases = Tools.JsonToObjectTools<DevSX>(iOTDevSXModel.JBSX)?.data?.ToList().FindAll(par => par.SXStatus == false); | |||||
if (bases != null) bases.AddRange(Tools.JsonToObjectTools<DevSX>(iOTDevSXModel.KZSX)?.data?.ToList().FindAll(par => par.SXStatus == false)); | |||||
List<AlarmModel> alarms = new List<AlarmModel>(); | |||||
bases?.ForEach(par => alarms.Add(new AlarmModel { DeviceMC = iOTDevSXModel.SBMC, DeviceSJ = DateTime.Now.ToString(), AlarmCD = "一般", DeviceZT = "未处理", DeviceMS = par.SXYCMS })); | |||||
iOTDevSXModel.SetGJXX(new AlarmMessage { data = alarms }); | |||||
#endregion | |||||
} | |||||
#endregion | |||||
bool InitComplete = GetTypeValue<bool>("InitComplete"); | |||||
bool RobotTakeNoodle = GetTypeValue<bool>("RobotTakeNoodle"); | |||||
bool RobotOutMeal = GetTypeValue<bool>("RobotOutMeal"); | |||||
iOTDevSXModel.SetLCSB(new ProcessMessage | |||||
#region 外部关闭或初始化IOT调用 | |||||
/// <summary> | |||||
/// 初始化IOT连接 | |||||
/// </summary> | |||||
public bool Initialize() | |||||
{ | |||||
if (!IOTDevServer.GetInstance().CreateLinks(InternetInfo.ClientId,out device)) | |||||
{ | { | ||||
data = new List<ProcessModel> | |||||
{ | |||||
new ProcessModel { ProcessName="开机",IsMark=IsAllowRun,ProcessMS=IsAllowRun?"机器人开机成功":"" }, | |||||
new ProcessModel { ProcessName="初始化",IsMark=InitComplete,ProcessMS=InitComplete?"机器人正在初始化成功":"" }, | |||||
new ProcessModel { ProcessName="取面",IsMark=RobotTakeNoodle,ProcessMS=RobotTakeNoodle?"机器人正在取面过程中....":""}, | |||||
new ProcessModel { ProcessName="出餐",IsMark=AllowFallNoodle,ProcessMS=AllowFallNoodle?"机器人正在出餐过程中....":"" } | |||||
} | |||||
}); | |||||
#endregion | |||||
MessageLog.GetInstance.Show($"设备{InternetInfo.ClientId}阿里云上没有该设备。"); | |||||
return false; | |||||
} | |||||
IOTDevServer.GetInstance().IOT_Subscribe(IOTDevServer.BroadcastTopic);//订阅广播主题 | |||||
IOTDevServer.DevIOTAction += DevIOTActionHandler; | |||||
IOTDevServer.UNConnectMqtt += new Action<string>((o) => { MessageLog.GetInstance.Show(o); });//断网自动重连接与打印 | |||||
if (IOTDevServer.client.IsConnected) MessageLog.GetInstance.Show($"设备{device.devicename} {device.remark}阿里云连接成功."); | |||||
else MessageLog.GetInstance.Show($"设备{device.devicename} {device.remark}阿里云连接失败.不能上报业务信息"); | |||||
return IOTDevServer.client.IsConnected; | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 初始化上报流程 | |||||
/// 关闭IOT连接 | |||||
/// </summary> | /// </summary> | ||||
public void Init() | |||||
public static void Close() | |||||
{ | { | ||||
ThreadManage.GetInstance.StartLong(new Action(() => | |||||
{ | |||||
if (IOTDev.client.IsConnected && GeneralConfig.DeviceType.ToString() == "MORKS") | |||||
{ | |||||
//SetData(); | |||||
IOTDev.GetInstance().IOT_Publish(IOTDev.PubTopic, iOTDevSXModel.Tojson()); | |||||
} | |||||
Thread.Sleep(5000); | |||||
}), "设备IOT上报云端"); | |||||
if (IOTDevServer.client != null) | |||||
IOTDevServer.GetInstance().Disconnect(); | |||||
} | } | ||||
#endregion | |||||
#region 云端订阅主题消息接收 | |||||
/// <summary> | /// <summary> | ||||
/// 接收云端消息 | /// 接收云端消息 | ||||
/// </summary> | /// </summary> | ||||
/// <param name="topic"></param> | /// <param name="topic"></param> | ||||
/// <param name="message"></param> | /// <param name="message"></param> | ||||
private void actionIOTHandler(string topic, string message) | |||||
private void DevIOTActionHandler(string topic, string message) | |||||
{ | { | ||||
if (IOTDev.BroadcastTopic == topic && !string.IsNullOrEmpty(message))//广播主题消息,将广播消息发送到相应客户端 | |||||
if (IOTDevServer.BroadcastTopic == topic && !string.IsNullOrEmpty(message))//广播主题消息,将广播消息发送到相应客户端 | |||||
{ | { | ||||
IOTCommandModel iOTCommand = Tools.JsonToObjectTools<IOTCommandModel>(message); | IOTCommandModel iOTCommand = Tools.JsonToObjectTools<IOTCommandModel>(message); | ||||
if (iOTCommand.deviceName == InternetInfo.DeviceName) | |||||
if (iOTCommand.deviceName == device.devicename) | |||||
ActionManage.GetInstance.Send("IotBroadcast", iOTCommand); | ActionManage.GetInstance.Send("IotBroadcast", iOTCommand); | ||||
} | } | ||||
} | } | ||||
#endregion | #endregion | ||||
#region 私有函数 | |||||
/// <summary> | |||||
/// 获取属性状态 | |||||
/// </summary> | |||||
private T GetTypeValue<T>(string str) | |||||
{ | |||||
return (T)SimpleFactory.GetInstance.GVL?.GetType().GetProperty(str).GetValue(SimpleFactory.GetInstance.GVL,null); | |||||
} | |||||
#endregion | |||||
} | |||||
/// <summary> | |||||
/// 日志上报 | |||||
/// </summary> | |||||
public class LogIOT | |||||
{ | |||||
public string SZXX { get; set; } | |||||
} | |||||
/// <summary> | |||||
/// 告警上报 | |||||
/// </summary> | |||||
public class AlarmIOT | |||||
{ | |||||
public string GJXX { get; set; } | |||||
} | |||||
/// <summary> | |||||
/// 节点状态上报 | |||||
/// </summary> | |||||
public class NodeStatusIOT | |||||
{ | |||||
public string NodeStatus { get; set; } | |||||
} | |||||
/// <summary> | |||||
/// 基本属性与扩展属性 | |||||
/// </summary> | |||||
public class TargetIOT | |||||
{ | |||||
/// <summary> | |||||
/// 基本属性 | |||||
/// </summary> | |||||
public string JBSX { get; set; } | |||||
/// <summary> | |||||
/// 扩展属性 | |||||
/// </summary> | |||||
public string KZSX { get; set; } | |||||
} | } | ||||
} | } |
@@ -68,8 +68,7 @@ namespace HBLConsole.Business | |||||
MqttM2.GetInstance.PublishInfo(PublishContent); | MqttM2.GetInstance.PublishInfo(PublishContent); | ||||
//mqttClient.Publish($"/sys/grgp0rFA2uu/{deviceName}/thing/event/property/post", Encoding.UTF8.GetBytes(PublishContent), 0, false); | //mqttClient.Publish($"/sys/grgp0rFA2uu/{deviceName}/thing/event/property/post", Encoding.UTF8.GetBytes(PublishContent), 0, false); | ||||
Thread.Sleep(1000); | |||||
}), "阿里云数据上报", new Action(() => { MqttM2.GetInstance.DisConnect(); })); | |||||
}), "阿里云数据上报", false, new Action(() => { MqttM2.GetInstance.DisConnect(); })); | |||||
} | } | ||||
} | } | ||||
@@ -41,7 +41,7 @@ namespace HBLConsole.Business | |||||
} | } | ||||
} | } | ||||
Thread.Sleep(100); | Thread.Sleep(100); | ||||
}), "mqtt消息处理"); | |||||
}), "mqtt消息处理", true); | |||||
} | } | ||||
@@ -77,6 +77,38 @@ namespace HBLConsole.Communication | |||||
MessageLog.GetInstance.Show("ModbusTcp 连接成功!"); | MessageLog.GetInstance.Show("ModbusTcp 连接成功!"); | ||||
} | } | ||||
public int GetBoolAddress(string address) | |||||
{ | |||||
if (address != null && address.Length >= 4) | |||||
{ | |||||
var res = address.Substring(1).Split('.'); | |||||
if (res != null && res.Length == 2) | |||||
{ | |||||
if (int.TryParse(res[0], out int firstAddress) && int.TryParse(res[1], out int ExitAddress)) | |||||
{ | |||||
if (ExitAddress >= 0 && ExitAddress <= 7) | |||||
{ | |||||
return (firstAddress * 8) + 320 + ExitAddress; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
return -1; | |||||
} | |||||
public int GetWordAddress(string address) | |||||
{ | |||||
if (address != null && address.Length > 3) | |||||
{ | |||||
var res = address.Substring(2); | |||||
if (res != null && int.TryParse(res, out int tempAddress)) | |||||
{ | |||||
return (tempAddress / 2) + 100; | |||||
} | |||||
} | |||||
return -1; | |||||
} | |||||
public void Readbool(ushort startAddress, ushort len, Action<bool[]> action) | public void Readbool(ushort startAddress, ushort len, Action<bool[]> action) | ||||
{ | { | ||||
object result; | object result; | ||||
@@ -23,6 +23,7 @@ namespace HBLConsole.Factory | |||||
private string DeviceType => GeneralConfig.DeviceType.ToString(); | private string DeviceType => GeneralConfig.DeviceType.ToString(); | ||||
private object debugControl; | private object debugControl; | ||||
private string GvlName = string.Empty; | |||||
public void MqttMessage(IMessage message) | public void MqttMessage(IMessage message) | ||||
{ | { | ||||
@@ -59,19 +60,43 @@ namespace HBLConsole.Factory | |||||
return res; | return res; | ||||
} | } | ||||
public void CreateGvl() | |||||
{ | |||||
string NameSpace = $"HBLConsole.{DeviceType}"; | |||||
Type type = Assembly.Load(NameSpace).GetType($"{NameSpace}.GVL_{DeviceType}"); | |||||
var tempGvl = Activator.CreateInstance(type); | |||||
var FieldValue = control.GetType().GetField(GvlName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public); | |||||
FieldValue?.SetValue(control, null); | |||||
FieldValue?.SetValue(control, tempGvl); | |||||
GetInterfaceData(); | |||||
} | |||||
private AbstractMessageServer GetAbstractMessageServer() | private AbstractMessageServer GetAbstractMessageServer() | ||||
{ | { | ||||
string NameSpace = "HBLConsole.Business"; | string NameSpace = "HBLConsole.Business"; | ||||
Type type = Assembly.Load(NameSpace).GetType($"{NameSpace}.MessageServer.{DeviceType}"); | |||||
Type type = Assembly.Load(NameSpace).GetType($"{NameSpace}.AbstractServer.{DeviceType}"); | |||||
if (type == null) | if (type == null) | ||||
type = Assembly.Load(NameSpace).GetType($"{NameSpace}.MessageServer.Base"); | |||||
type = Assembly.Load(NameSpace).GetType($"{NameSpace}.AbstractServer.Base"); | |||||
return Activator.CreateInstance(type) as AbstractMessageServer; | return Activator.CreateInstance(type) as AbstractMessageServer; | ||||
} | } | ||||
private void GetControlBase() | |||||
{ | |||||
string NameSpace = "HBLConsole.Business"; | |||||
Type type = Assembly.Load(NameSpace).GetType($"{NameSpace}.AbstractServer.ControlBase"); | |||||
controlAbstract = Activator.CreateInstance(type) as ControlAbstract; | |||||
if (controlAbstract != null) | |||||
{ | |||||
controlAbstract.MainAction = new Action(() => { control?.Main(); }); | |||||
controlAbstract.ReadDataAction = new Action(() => { control?.ReadData(); }); | |||||
controlAbstract.Init(); | |||||
} | |||||
} | |||||
public IControl control { get; set; } | public IControl control { get; set; } | ||||
public IGvl GVL { get; set; } | public IGvl GVL { get; set; } | ||||
public IAlarm Alarm { get; set; } | public IAlarm Alarm { get; set; } | ||||
public ControlAbstract controlAbstract { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 设备初始化 | /// 设备初始化 | ||||
@@ -91,6 +116,7 @@ namespace HBLConsole.Factory | |||||
ActionManage.GetInstance.Register(new Action<object>((o) => { control?.SimOrder(o); }), "SimOrder"); | ActionManage.GetInstance.Register(new Action<object>((o) => { control?.SimOrder(o); }), "SimOrder"); | ||||
ActionManage.GetInstance.Register(new Action<object>((o) => { control?.IotBroadcast(o); }), "IotBroadcast"); | ActionManage.GetInstance.Register(new Action<object>((o) => { control?.IotBroadcast(o); }), "IotBroadcast"); | ||||
ConnectHelper.GetInstance.Init(); | ConnectHelper.GetInstance.Init(); | ||||
//GetControlBase(); | |||||
} | } | ||||
@@ -115,6 +141,8 @@ namespace HBLConsole.Factory | |||||
if (inters.Name.Equals("IGvl")) | if (inters.Name.Equals("IGvl")) | ||||
{ | { | ||||
GVL = (item.GetValue(control)) as IGvl; | GVL = (item.GetValue(control)) as IGvl; | ||||
GvlName = item.Name; | |||||
} | } | ||||
else if (inters.Name.Equals("IAlarm")) | else if (inters.Name.Equals("IAlarm")) | ||||
{ | { | ||||
@@ -36,10 +36,6 @@ namespace HBLConsole.GVL | |||||
ConsulAddress = System.Configuration.ConfigurationManager.AppSettings["ConsulAddress"]; | ConsulAddress = System.Configuration.ConfigurationManager.AppSettings["ConsulAddress"]; | ||||
ClientId = int.Parse(System.Configuration.ConfigurationManager.AppSettings["ClientId"]); | ClientId = int.Parse(System.Configuration.ConfigurationManager.AppSettings["ClientId"]); | ||||
ProductKey = System.Configuration.ConfigurationManager.AppSettings["ProductKey"]; | |||||
DeviceName = System.Configuration.ConfigurationManager.AppSettings["DeviceName"]; | |||||
DeviceSecret = System.Configuration.ConfigurationManager.AppSettings["DeviceSecret"]; | |||||
DeviceMS= System.Configuration.ConfigurationManager.AppSettings["DeviceMS"]; | |||||
while (StockServer == null) | while (StockServer == null) | ||||
{ | { | ||||
try | try | ||||
@@ -124,24 +120,5 @@ namespace HBLConsole.GVL | |||||
public static string StockServer { get; set; } | public static string StockServer { get; set; } | ||||
#endregion | #endregion | ||||
#region IOT设备地址 | |||||
/// <summary> | |||||
/// IOT ProductKey | |||||
/// </summary> | |||||
public static string ProductKey { get; set; } | |||||
/// <summary> | |||||
/// IOT DeviceName | |||||
/// </summary> | |||||
public static string DeviceName { get; set; } | |||||
/// <summary> | |||||
/// IOT DeviceSecret | |||||
/// </summary> | |||||
public static string DeviceSecret { get; set; } | |||||
/// <summary> | |||||
/// IOT DeviceMS | |||||
/// </summary> | |||||
public static string DeviceMS { get; set; } | |||||
#endregion | |||||
} | } | ||||
} | } |
@@ -9,7 +9,6 @@ namespace HBLConsole.Interface | |||||
public interface IControl | public interface IControl | ||||
{ | { | ||||
void Main(); | void Main(); | ||||
//object GetT(); | |||||
void Init(); | void Init(); | ||||
void ReadData(); | void ReadData(); | ||||
void SimOrder<T>(T simOrder); | void SimOrder<T>(T simOrder); | ||||
@@ -9,10 +9,142 @@ using HBLConsole.Attributes; | |||||
namespace HBLConsole.MORKD | namespace HBLConsole.MORKD | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 报警实体类 | |||||
/// 报警实体信息 | |||||
/// </summary> | /// </summary> | ||||
public class Alarm_MORKD : IAlarm | public class Alarm_MORKD : IAlarm | ||||
{ | { | ||||
#region PLC-->上位机 | |||||
/** | |||||
* Modbus地址数值,如何配置 | |||||
*/ | |||||
/// <summary> | |||||
/// 煮面机左侧低温报警 | |||||
/// PLC ---> M550.0 | |||||
/// ModbusTcp --> 1570 | |||||
/// </summary> | |||||
[VariableMonitor("煮面机左侧低温报警", "550.0", "1570")] | |||||
public bool MachineLeftLowTemperature { get; set; } | |||||
/// <summary> | |||||
/// 煮面机左侧低温报警 | |||||
/// PLC ---> M550.1 | |||||
/// ModbusTcp --> 1571 | |||||
/// </summary> | |||||
[VariableMonitor("煮面机右侧低温报警", "550.1", "1571")] | |||||
public bool MachineRightLowTemperature { get; set; } | |||||
/// <summary> | |||||
/// 供碗1缺碗 | |||||
/// PLC ---> M550.2 | |||||
/// ModbusTcp --> 1572 | |||||
/// </summary> | |||||
[VariableMonitor("供碗1缺碗", "550.2", "1572")] | |||||
public bool Supply1_LossBowl { get; set; } | |||||
/// <summary> | |||||
/// 供碗2缺碗 | |||||
/// PLC ---> M550.3 | |||||
/// ModbusTcp --> 1573 | |||||
/// </summary> | |||||
[VariableMonitor("供碗2缺碗", "550.3", "1573")] | |||||
public bool Supply2_LossBowl { get; set; } | |||||
/// <summary> | |||||
/// 供碗1出碗检测异常 | |||||
/// PLC ---> M550.4 | |||||
/// ModbusTcp --> 1574 | |||||
/// </summary> | |||||
[VariableMonitor("供碗1出碗检测异常", "550.4", "1574")] | |||||
public bool Supply1_ErrorOutBowl { get; set; } | |||||
/// <summary> | |||||
/// 供碗2出碗检测异常 | |||||
/// PLC ---> M550.5 | |||||
/// ModbusTcp --> 1575 | |||||
/// </summary> | |||||
[VariableMonitor("供碗2出碗检测异常", "550.5", "1575")] | |||||
public bool Supply2_ErrorOutBowl { get; set; } | |||||
/// <summary> | |||||
/// 推碗气缸故障 | |||||
/// PLC ---> M550.6 | |||||
/// ModbusTcp --> 1576 | |||||
/// </summary> | |||||
[VariableMonitor("推碗气缸故障", "550.6", "1576")] | |||||
public bool PushBowlCylinderError { get; set; } | |||||
/// <summary> | |||||
/// 煮面机通讯异常 | |||||
/// PLC ---> M550.7 | |||||
/// ModbusTcp --> 1577 | |||||
/// </summary> | |||||
[VariableMonitor("煮面机通讯异常", "550.7", "1577")] | |||||
public bool NoodleMacCommunicateError { get; set; } | |||||
/// <summary> | |||||
/// 煮面机通讯异常 | |||||
/// PLC ---> M551.0 | |||||
/// ModbusTcp --> 1580 | |||||
/// </summary> | |||||
[VariableMonitor("配料机通讯异常", "551.0", "1580")] | |||||
public bool DosingMacCommunicateError { get; set; } | |||||
/// <summary> | |||||
/// 机器人通讯异常 | |||||
/// PLC ---> M551.1 | |||||
/// ModbusTcp --> 1581 | |||||
/// </summary> | |||||
[VariableMonitor("机器人通讯异常", "551.1", "1581")] | |||||
public bool RobotMacCommunicateError { get; set; } | |||||
/// <summary> | |||||
/// 机器人初始化失败 | |||||
/// PLC ---> M551.3 | |||||
/// ModbusTcp --> 1583 | |||||
/// </summary> | |||||
[VariableMonitor("机器人初始化失败", "551.3", "1583")] | |||||
public bool RobotInitError { get; set; } | |||||
/// <summary> | |||||
/// 机器人急停 | |||||
/// PLC ---> M551.4 | |||||
/// ModbusTcp --> 1584 | |||||
/// </summary> | |||||
[VariableMonitor("机器人急停", "551.4", "1584")] | |||||
public bool RobotUrgentStop { get; set; } | |||||
/// <summary> | |||||
/// 机器人不在远程模式 | |||||
/// PLC ---> M551.5 | |||||
/// ModbusTcp --> 1585 | |||||
/// </summary> | |||||
[VariableMonitor("机器人不在远程模式", "551.5", "1585")] | |||||
public bool RobotNotInRemoteMode { get; set; } | |||||
/// <summary> | |||||
/// 机器人伺服未就绪 | |||||
/// PLC ---> M551.6 | |||||
/// ModbusTcp --> 1586 | |||||
/// </summary> | |||||
[VariableMonitor("机器人伺服未就绪", "551.6", "1586")] | |||||
public bool RobotNotInReady { get; set; } | |||||
/// <summary> | |||||
/// 机器人本体异常 | |||||
/// PLC ---> M551.7 | |||||
/// ModbusTcp --> 1587 | |||||
/// </summary> | |||||
[VariableMonitor("机器人本体异常", "551.7", "1587")] | |||||
public bool RobotSelfInException { get; set; } | |||||
#endregion | |||||
} | } | ||||
} | } |
@@ -63,8 +63,6 @@ namespace HBLConsole.MORKD | |||||
}), "InitCommand"); | }), "InitCommand"); | ||||
} | } | ||||
bool Initing = false; | |||||
/// <summary> | /// <summary> | ||||
/// 复位程序 | /// 复位程序 | ||||
/// </summary> | /// </summary> | ||||
@@ -72,7 +70,7 @@ namespace HBLConsole.MORKD | |||||
{ | { | ||||
ThreadManage.GetInstance.StartLong(new Action(() => | ThreadManage.GetInstance.StartLong(new Action(() => | ||||
{ | { | ||||
if (RTrig.GetInstance("ResetProgram").Start(Initing)) | |||||
if (RTrig.GetInstance("ResetProgram").Start(DeviceData.Initing)) | |||||
{ | { | ||||
ThreadManage.GetInstance.StopTask("MainTask", new Action(() => | ThreadManage.GetInstance.StopTask("MainTask", new Action(() => | ||||
{ | { | ||||
@@ -145,10 +143,9 @@ namespace HBLConsole.MORKD | |||||
mORKD.TakeSoupRobotIdle = bools[24]; | mORKD.TakeSoupRobotIdle = bools[24]; | ||||
mORKD.TakeSoupComplete = bools[27]; | mORKD.TakeSoupComplete = bools[27]; | ||||
mORKD.PutNoodleTakeMealComplete = bools[28]; | mORKD.PutNoodleTakeMealComplete = bools[28]; | ||||
Initing = bools[29]; | |||||
DeviceData.Initing = bools[29]; | |||||
})); | })); | ||||
ModbusTcpHelper.GetInstance.Readbool(1280, 11, new Action<bool[]>((bools) => | ModbusTcpHelper.GetInstance.Readbool(1280, 11, new Action<bool[]>((bools) => | ||||
{ | { | ||||
mORKD.TurntableLowerLimit = bools[0]; | mORKD.TurntableLowerLimit = bools[0]; | ||||
@@ -174,6 +171,34 @@ namespace HBLConsole.MORKD | |||||
mORKD.TurntableFeedbackloc = loc; | mORKD.TurntableFeedbackloc = loc; | ||||
} | } | ||||
} | } | ||||
/** 读取Alarm 报警信息 2022.4.2 | |||||
*/ | |||||
ModbusTcpHelper.GetInstance.Readbool(1570, 20, new Action<bool[]>((bools) => | |||||
{ | |||||
// 0 -- 1570 | |||||
//10 -- 1580 | |||||
int bit1570 = 1570; | |||||
alarm.MachineLeftLowTemperature = bools[bit1570]; | |||||
alarm.MachineRightLowTemperature = bools[bit1570 + 1]; | |||||
alarm.Supply1_LossBowl = bools[bit1570 + 2]; | |||||
alarm.Supply2_LossBowl = bools[bit1570 + 3]; | |||||
alarm.Supply1_ErrorOutBowl = bools[bit1570 + 4]; | |||||
alarm.Supply2_ErrorOutBowl = bools[bit1570 + 5]; | |||||
alarm.PushBowlCylinderError = bools[bit1570 + 6]; | |||||
alarm.NoodleMacCommunicateError = bools[bit1570 + 7]; | |||||
// | |||||
int bit1580 = 1580; | |||||
alarm.DosingMacCommunicateError = bools[bit1580]; | |||||
alarm.RobotMacCommunicateError = bools[bit1580 + 1]; | |||||
alarm.RobotInitError = bools[bit1580 + 3]; | |||||
alarm.RobotUrgentStop = bools[bit1580 + 4]; | |||||
alarm.RobotNotInRemoteMode = bools[bit1580 + 5]; | |||||
alarm.RobotNotInReady = bools[bit1580 + 6]; | |||||
alarm.RobotSelfInException = bools[bit1580 + 7]; | |||||
})); | |||||
Thread.Sleep(100); | Thread.Sleep(100); | ||||
}), "ReadPLCData"); | }), "ReadPLCData"); | ||||
} | } | ||||
@@ -350,6 +375,8 @@ namespace HBLConsole.MORKD | |||||
} | } | ||||
} | } | ||||
bool isNotTakeNoodle = false; //true-无法取面,false-可以取面 | |||||
/// <summary> | /// <summary> | ||||
/// 取面任务 | /// 取面任务 | ||||
/// </summary> | /// </summary> | ||||
@@ -361,9 +388,13 @@ namespace HBLConsole.MORKD | |||||
if (mORKD.TurntableInPlace && !mORKD.OutNoodleing && mORKD.RBTakeNoodleTask.Count > 0) | if (mORKD.TurntableInPlace && !mORKD.OutNoodleing && mORKD.RBTakeNoodleTask.Count > 0) | ||||
{ | { | ||||
int loc = mORKD.CookNoodleBasketIdle.GetIndex(false);//查找煮面炉空闲位置 | int loc = mORKD.CookNoodleBasketIdle.GetIndex(false);//查找煮面炉空闲位置 | ||||
int IdleLoc = mORKD.CookNodeState.GetIndex(false);//获取煮面炉空闲状态互锁位置 | |||||
int IdleLoc = mORKD.CookNodeState.GetIndex(false);//获取煮面炉空闲状态互锁位置 | |||||
if (loc >= 0 && loc <= 5) | if (loc >= 0 && loc <= 5) | ||||
{ | { | ||||
if (isNotTakeNoodle) | |||||
{ | |||||
return; | |||||
} | |||||
if (mORKD.RBTakeNoodleTask.TryDequeue(out OrderLocInfo orderLocInfo)) | if (mORKD.RBTakeNoodleTask.TryDequeue(out OrderLocInfo orderLocInfo)) | ||||
{ | { | ||||
mORKD.RBTakeNoodleStart((ushort)(loc + 1), orderLocInfo.Loc); | mORKD.RBTakeNoodleStart((ushort)(loc + 1), orderLocInfo.Loc); | ||||
@@ -373,6 +404,8 @@ namespace HBLConsole.MORKD | |||||
//MessageLog.GetInstance.Show($"订单【{orderLocInfo.SuborderId}】,煮面栏:[{loc + 1}]"); | //MessageLog.GetInstance.Show($"订单【{orderLocInfo.SuborderId}】,煮面栏:[{loc + 1}]"); | ||||
mORKD.TakeNoodleInterlock = true; | mORKD.TakeNoodleInterlock = true; | ||||
MessageLog.GetInstance.Show($"{loc + 1}号煮面篮订单ID:[{orderLocInfo.SuborderId}]"); | MessageLog.GetInstance.Show($"{loc + 1}号煮面篮订单ID:[{orderLocInfo.SuborderId}]"); | ||||
Trace.WriteLine($"%%%开始下面。。。" + $"{loc + 1}号煮面篮订单ID:[{orderLocInfo.SuborderId}]"); | |||||
isNotTakeNoodle = true; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -385,6 +418,7 @@ namespace HBLConsole.MORKD | |||||
mORKD.AllowTakeNoodle = false; | mORKD.AllowTakeNoodle = false; | ||||
MessageLog.GetInstance.Show("转台取面完成"); | MessageLog.GetInstance.Show("转台取面完成"); | ||||
mORKD.TakeNoodleCompleteReset(); | mORKD.TakeNoodleCompleteReset(); | ||||
isNotTakeNoodle = false; | |||||
} | } | ||||
} | } | ||||
@@ -405,6 +439,7 @@ namespace HBLConsole.MORKD | |||||
{ | { | ||||
if (mORKD.CookNoodleCompleteTask.Count > 0) | if (mORKD.CookNoodleCompleteTask.Count > 0) | ||||
{ | { | ||||
RevertOutNoodleQueue(); //交换出面台位顺序 2022.3.30 | |||||
string id = mORKD.CookNodelId[mORKD.CookNoodleCompleteTask.ElementAt(0)]; | string id = mORKD.CookNodelId[mORKD.CookNoodleCompleteTask.ElementAt(0)]; | ||||
int index = mORKD.AxisAllowInvertedNoodleID.GetIndex(id); | int index = mORKD.AxisAllowInvertedNoodleID.GetIndex(id); | ||||
if (index >= 0 && index <= 1) | if (index >= 0 && index <= 1) | ||||
@@ -422,6 +457,7 @@ namespace HBLConsole.MORKD | |||||
MessageLog.GetInstance.Show($"从{loc + 1}号位置取面"); | MessageLog.GetInstance.Show($"从{loc + 1}号位置取面"); | ||||
MessageLog.GetInstance.Show($"倒入{index + 1}号碗位置"); | MessageLog.GetInstance.Show($"倒入{index + 1}号碗位置"); | ||||
MessageLog.GetInstance.Show($"{index + 1}号轴允许倒浇头ID:[{ mORKD.AxisAllowInvertedSoupID[index]}]"); | MessageLog.GetInstance.Show($"{index + 1}号轴允许倒浇头ID:[{ mORKD.AxisAllowInvertedSoupID[index]}]"); | ||||
//Trace.WriteLine($"###出面控制。。。"); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -431,6 +467,33 @@ namespace HBLConsole.MORKD | |||||
mORKD.RobotTaskInterlock = mORKD.CookNoodleCompleteTask.Count > 0 && (mlCount >= 2 || mORKD.RBTakeNoodleTask.Count == 0); | mORKD.RobotTaskInterlock = mORKD.CookNoodleCompleteTask.Count > 0 && (mlCount >= 2 || mORKD.RBTakeNoodleTask.Count == 0); | ||||
} | } | ||||
public int tCount = 0; | |||||
/// <summary> | |||||
/// 交换出面台位优先级 | |||||
/// </summary> | |||||
void RevertOutNoodleQueue() | |||||
{ | |||||
string id = mORKD.CookNodelId[mORKD.CookNoodleCompleteTask.ElementAt(0)]; | |||||
int index = mORKD.AxisAllowInvertedNoodleID.GetIndex(id); | |||||
if (index == -1) | |||||
{ | |||||
tCount++; | |||||
if (tCount == 100) | |||||
{ | |||||
//交换取面位置 | |||||
mORKD.CookNoodleCompleteTask.TryDequeue(out ushort result2); | |||||
mORKD.CookNoodleCompleteTask.Enqueue(result2); | |||||
tCount = 0; | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
tCount = 0; | |||||
} | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 取浇头控制 | /// 取浇头控制 | ||||
/// </summary> | /// </summary> | ||||
@@ -9,6 +9,7 @@ using System.Threading; | |||||
using System.Collections.Concurrent; | using System.Collections.Concurrent; | ||||
using HBLConsole.Model; | using HBLConsole.Model; | ||||
using HBLConsole.Attributes; | using HBLConsole.Attributes; | ||||
using System.Diagnostics; | |||||
namespace HBLConsole.MORKD | namespace HBLConsole.MORKD | ||||
{ | { | ||||
@@ -47,6 +48,7 @@ namespace HBLConsole.MORKD | |||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Write(102, WriteType.HoldingRegisters, OutNoodleLoc); | ModbusTcpHelper.GetInstance.Write(102, WriteType.HoldingRegisters, OutNoodleLoc); | ||||
ModbusTcpHelper.GetInstance.Write(103, WriteType.HoldingRegisters, BowlLoc); | ModbusTcpHelper.GetInstance.Write(103, WriteType.HoldingRegisters, BowlLoc); | ||||
Trace.WriteLine($"#######出面位置:{OutNoodleLoc},碗位置:{BowlLoc}"); | |||||
ModbusTcpHelper.GetInstance.Write(322, WriteType.Coils, true); | ModbusTcpHelper.GetInstance.Write(322, WriteType.Coils, true); | ||||
} | } | ||||
@@ -101,8 +101,10 @@ namespace HBLConsole.MORKIC | |||||
//冰淇淋机创建 | //冰淇淋机创建 | ||||
iceCreamMachine = new IceCreamMachine(com_IceCream, (BaudRates)Enum.Parse(typeof(BaudRates), baud_IceCream)); | iceCreamMachine = new IceCreamMachine(com_IceCream, (BaudRates)Enum.Parse(typeof(BaudRates), baud_IceCream)); | ||||
icchipMachine = new ICChipMachine(com_ICChip, (BaudRates)Enum.Parse(typeof(BaudRates), baud_ICChip)); | icchipMachine = new ICChipMachine(com_ICChip, (BaudRates)Enum.Parse(typeof(BaudRates), baud_ICChip)); | ||||
ReadData(); | |||||
Main(); | Main(); | ||||
ReadData(); | |||||
ThreadManage.GetInstance.StartLong(new Action(() => | ThreadManage.GetInstance.StartLong(new Action(() => | ||||
{ | { | ||||
@@ -191,7 +193,8 @@ namespace HBLConsole.MORKIC | |||||
}), "MORK-IC心跳刷新"); | }), "MORK-IC心跳刷新"); | ||||
ThreadManage.GetInstance.Start(new Action(() => | ThreadManage.GetInstance.Start(new Action(() => | ||||
{ | { | ||||
while (!LebaiHelper.GetInstance.IsConnected) { | |||||
while (!LebaiHelper.GetInstance.IsConnected) | |||||
{ | |||||
Thread.Sleep(10); | Thread.Sleep(10); | ||||
} | } | ||||
LebaiHelper.GetInstance.Scene(LebaiHelper.SENCE_欢迎); | LebaiHelper.GetInstance.Scene(LebaiHelper.SENCE_欢迎); | ||||
@@ -344,17 +347,41 @@ namespace HBLConsole.MORKIC | |||||
are.Set(); | 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 ReadData() | public void ReadData() | ||||
{ | { | ||||
ThreadManage.GetInstance.StartLong(new Action(() => | |||||
{ | |||||
lebai = LebaiHelper.GetInstance.GetValueAsync(); | |||||
LebaiHelper.GetInstance.GetRobotModeStatus(); | |||||
Thread.Sleep(100); | |||||
}), "乐百机器人数据读取"); | |||||
//ThreadManage.GetInstance.StartLong(new Action(() => | |||||
//{ | |||||
lebai = LebaiHelper.GetInstance.GetValueAsync(); | |||||
LebaiHelper.GetInstance.GetRobotModeStatus(); | |||||
// Thread.Sleep(100); | |||||
//}), "乐百机器人数据读取"); | |||||
} | } | ||||
public void SimOrder<T>(T simOrder) | public void SimOrder<T>(T simOrder) | ||||
@@ -15,6 +15,7 @@ using BPA.Message.Enum; | |||||
using HBLConsole.GVL; | using HBLConsole.GVL; | ||||
using BPA.Models; | using BPA.Models; | ||||
using BPA.Message.IOT; | using BPA.Message.IOT; | ||||
using HBLConsole.Abstract; | |||||
namespace HBLConsole.MORKS | namespace HBLConsole.MORKS | ||||
{ | { | ||||
@@ -26,39 +27,60 @@ namespace HBLConsole.MORKS | |||||
ActionManage.GetInstance.Register(new Action(() => { WriteRecipeBoms(); }), "recipeBom"); | ActionManage.GetInstance.Register(new Action(() => { WriteRecipeBoms(); }), "recipeBom"); | ||||
ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitCommand"); | ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitCommand"); | ||||
} | } | ||||
public void ConnectOk() | public void ConnectOk() | ||||
{ | { | ||||
//WriteRecipeBoms(); | |||||
ReadData(); | ReadData(); | ||||
Main(); | Main(); | ||||
//ResetProgram(); | |||||
ResetProgram(); | |||||
ActionManage.GetInstance.Register(new Action(() => | |||||
{ | |||||
Random rd = new Random(); | |||||
ThreadManage.GetInstance.StartLong(new Action(() => | |||||
{ | |||||
int NoodleLoc = rd.Next(1, 6); | |||||
int BowlLoc = rd.Next(10, 11); | |||||
string guid = new Guid().ToString(); | |||||
mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = (ushort)NoodleLoc, SuborderId = guid }); | |||||
MessageLog.GetInstance.Show($"添加订单:面条位置【{NoodleLoc}】"); | |||||
mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = (ushort)BowlLoc, SuborderId = guid }); | |||||
MessageLog.GetInstance.Show($"添加订单:碗位置【{BowlLoc}】"); | |||||
Thread.Sleep(60000); | |||||
}), "ForOrder"); | |||||
}), "EnableForOrder"); | |||||
ActionManage.GetInstance.Register(new Action(() => | |||||
{ | |||||
ThreadManage.GetInstance.StopTask("ForOrder", new Action(() => | |||||
{ | |||||
mORKS.RBTakeNoodleTask.Clear(); | |||||
mORKS.TakeBowlTask.Clear(); | |||||
})); | |||||
}), "StopForOrder"); | |||||
MessageLog.GetInstance.Show("MORKS 设备初始化完成"); | MessageLog.GetInstance.Show("MORKS 设备初始化完成"); | ||||
} | } | ||||
/// <summary> | |||||
/// 复位程序 | |||||
/// </summary> | |||||
private void ResetProgram() | private void ResetProgram() | ||||
{ | { | ||||
ThreadManage.GetInstance.StartLong(new Action(() => | ThreadManage.GetInstance.StartLong(new Action(() => | ||||
{ | { | ||||
if (RTrig.GetInstance("ResetProgram").Start(mORKS.DeviceIniting)) | |||||
if (RTrig.GetInstance("ResetProgram").Start(DeviceData.Initing)) | |||||
{ | { | ||||
ThreadManage.GetInstance.StopTask("MainTask", new Action(() => | ThreadManage.GetInstance.StopTask("MainTask", new Action(() => | ||||
{ | |||||
//mORKS.AllowRun = false; | |||||
//TakeBowlId = string.Empty; | |||||
//IngredientsCompleteId = string.Empty; | |||||
//CookNodelId = new string[6] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, }; | |||||
//mORKS.RobotTaskInterlock = false; | |||||
//OutMealId = string.Empty; | |||||
//mORKS.TakeBowlInterlock = false; | |||||
//mORKS.TakeNoodleInterlock = false; | |||||
//mORKS.OutNoodleing = false; | |||||
Main(); | |||||
})); | |||||
{ | |||||
ThreadManage.GetInstance.StopTask("ReadPLCData", new Action(() => | |||||
{ | |||||
mORKS = null; | |||||
mORKS = new GVL_MORKS(); | |||||
ActionManage.GetInstance.Send("ResetProgram"); | |||||
ReadData(); | |||||
Main(); | |||||
})); | |||||
})); | |||||
} | } | ||||
Thread.Sleep(10); | Thread.Sleep(10); | ||||
}), "ResetProgram"); | }), "ResetProgram"); | ||||
} | } | ||||
@@ -71,11 +93,11 @@ namespace HBLConsole.MORKS | |||||
ThreadManage.GetInstance.StartLong(new Action(() => | ThreadManage.GetInstance.StartLong(new Action(() => | ||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Readbool(323, 3, new Action<bool[]>((bools) => | ModbusTcpHelper.GetInstance.Readbool(323, 3, new Action<bool[]>((bools) => | ||||
{ | |||||
mORKS.RobotTakeNoodle = bools[0]; | |||||
mORKS.RobotOutMeal = bools[1]; | |||||
mORKS.MoveTurntable = bools[2]; | |||||
})); | |||||
{ | |||||
mORKS.RobotTakeNoodle = bools[0]; | |||||
mORKS.RobotOutMeal = bools[1]; | |||||
mORKS.MoveTurntable = bools[2]; | |||||
})); | |||||
ModbusTcpHelper.GetInstance.Readbool(1120, 16, new Action<bool[]>((bools) => | ModbusTcpHelper.GetInstance.Readbool(1120, 16, new Action<bool[]>((bools) => | ||||
{ | { | ||||
@@ -89,7 +111,7 @@ namespace HBLConsole.MORKS | |||||
mORKS.RobotIdle = bools[7]; | mORKS.RobotIdle = bools[7]; | ||||
mORKS.TakeMealDetect = bools[8]; | mORKS.TakeMealDetect = bools[8]; | ||||
mORKS.MissingBowl = bools[9]; | mORKS.MissingBowl = bools[9]; | ||||
mORKS.DeviceIniting = bools[10]; | |||||
DeviceData.Initing = bools[10]; | |||||
mORKS.TurntableLowerLimit = bools[11]; | mORKS.TurntableLowerLimit = bools[11]; | ||||
mORKS.MissingBowlSignal2 = bools[12]; | mORKS.MissingBowlSignal2 = bools[12]; | ||||
mORKS.TurntableUpLimit = bools[13]; | mORKS.TurntableUpLimit = bools[13]; | ||||
@@ -194,53 +216,58 @@ namespace HBLConsole.MORKS | |||||
} | } | ||||
} | } | ||||
int OrderCount = 0; | |||||
/// <summary> | /// <summary> | ||||
/// 数据解析 | /// 数据解析 | ||||
/// </summary> | /// </summary> | ||||
public void DataParse<T>(T order) | public void DataParse<T>(T order) | ||||
{ | { | ||||
OrderCount++; | |||||
MessageLog.GetInstance.Show($"接收到{OrderCount}次订单"); | |||||
if (order is MorkOrderPush morkOrderPush) | if (order is MorkOrderPush morkOrderPush) | ||||
{ | { | ||||
BatchingInfo batching_M = null;//面条 | |||||
BatchingInfo batching_W = null;//碗 | |||||
foreach (var item in morkOrderPush.GoodBatchings) | foreach (var item in morkOrderPush.GoodBatchings) | ||||
{ | { | ||||
var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery.BatchingInfo.FirstOrDefault(p => p.BatchingId == item.BatchingId); | |||||
var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); | |||||
if (res != null) | if (res != null) | ||||
{ | { | ||||
if (ushort.TryParse(res.BatchingLoc, out ushort loc)) | if (ushort.TryParse(res.BatchingLoc, out ushort loc)) | ||||
{ | { | ||||
if (loc >= 1 && loc <= 5) { batching_M = res; } | |||||
else if (loc >= 10 && loc <= 11) { batching_W = res; } | |||||
if (loc >= 1 && loc <= 5) | |||||
{ | |||||
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 (Json<BatchingInfoPar>.Data.recipeBoms != null) | |||||
{ | |||||
index = Array.FindIndex(Json<BatchingInfoPar>.Data.recipeBoms?.RecipeIds.ToArray(), p => p.RecipeId == morkOrderPush.RecipeId); | |||||
index++; | |||||
} | |||||
mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() | |||||
{ | |||||
Loc = ushort.Parse(res.BatchingLoc), | |||||
SuborderId = morkOrderPush.SuborderId, | |||||
RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0 | |||||
}); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
if (batching_M != null && batching_W != null) | |||||
{ | |||||
batching_W.BatchingLoc = "10"; | |||||
mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = ushort.Parse(batching_M.BatchingLoc), SuborderId = morkOrderPush.SuborderId, BatchingId = batching_M.BatchingId }); | |||||
int index = Array.FindIndex(Json<BatchingInfoPar>.Data.recipeBoms.RecipeIds.ToArray(), p => p.RecipeId == morkOrderPush.RecipeId); | |||||
index++; | |||||
mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = ushort.Parse(batching_W.BatchingLoc), SuborderId = morkOrderPush.SuborderId, RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0 }); | |||||
} | |||||
} | } | ||||
} | } | ||||
public void Main() | public void Main() | ||||
{ | { | ||||
ThreadManage.GetInstance.StartLong(new Action(() => | ThreadManage.GetInstance.StartLong(new Action(() => | ||||
{ | { | ||||
mORKS.AllowRun = mORKS.InitComplete; | mORKS.AllowRun = mORKS.InitComplete; | ||||
//mORKS.AllowRun = mORKS.InitComplete && mORKS.TemperatureReached; | //mORKS.AllowRun = mORKS.InitComplete && mORKS.TemperatureReached; | ||||
//GeneralConfig.Healthy = true; | |||||
GeneralConfig.Healthy = mORKS.AllowRun; | |||||
GeneralConfig.Healthy = true; | |||||
//GeneralConfig.Healthy = mORKS.AllowRun; | |||||
TakeBowlTask(); | TakeBowlTask(); | ||||
@@ -309,6 +336,7 @@ namespace HBLConsole.MORKS | |||||
if (!mORKS.TurntableLocLists.Contains(loc)) | if (!mORKS.TurntableLocLists.Contains(loc)) | ||||
{ | { | ||||
TurntableStart(loc); | TurntableStart(loc); | ||||
MessageLog.GetInstance.Show("未检测到物料,启动转台查找"); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
@@ -327,9 +355,10 @@ namespace HBLConsole.MORKS | |||||
#region 优化版本 | #region 优化版本 | ||||
//if (mORKS.TurntableMoveInPlace && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) | //if (mORKS.TurntableMoveInPlace && 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 (mORKS.TurntableLowerLimit) | // if (mORKS.TurntableLowerLimit) | ||||
// { | // { | ||||
// if (mORKS.TurntableFeedbackloc == mORKS.RBTakeNoodleTask.ElementAt(0).Loc) | |||||
// if (mORKS.TurntableFeedbackloc == mORKS.RBTakeNoodleTask.ElementAt(0).Loc || (result?.Count > 0 && result?.Count == mORKS.TurntableLocLists.Count)) | |||||
// { | // { | ||||
// mORKS.TurntableLocLists.Clear(); | // mORKS.TurntableLocLists.Clear(); | ||||
// mORKS.AllowTakeNoodle = true; | // mORKS.AllowTakeNoodle = true; | ||||
@@ -348,20 +377,22 @@ namespace HBLConsole.MORKS | |||||
// { | // { | ||||
// if (!mORKS.TurntableInterlock) | // if (!mORKS.TurntableInterlock) | ||||
// { | // { | ||||
// var result = Json<BatchingInfoPar>.Data.orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKS.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList(); | |||||
// result?.ForEach(item => | |||||
// if (result != null) | |||||
// { | // { | ||||
// if (ushort.TryParse(item.BatchingLoc, out ushort loc)) | |||||
// foreach (var item in result) | |||||
// { | // { | ||||
// if (mORKS.TurntableFeedbackloc != loc && !mORKS.TurntableLocLists.Contains(loc)) | |||||
// if (ushort.TryParse(item.BatchingLoc, out ushort loc)) | |||||
// { | // { | ||||
// TurntableStart(loc); | |||||
// MessageLog.GetInstance.Show($"没有物料检测的启动转台控制,转台位置:[{loc}]"); | |||||
// return; | |||||
// if (mORKS.TurntableFeedbackloc != loc && !mORKS.TurntableLocLists.Contains(loc)) | |||||
// { | |||||
// TurntableStart(loc); | |||||
// MessageLog.GetInstance.Show($"没有物料检测的启动转台控制,转台位置:[{loc}]"); | |||||
// break; | |||||
// } | |||||
// else if (mORKS.TurntableFeedbackloc == loc && !mORKS.TurntableLocLists.Contains(loc)) mORKS.TurntableLocLists.Add(loc); | |||||
// } | // } | ||||
// else if (mORKS.TurntableFeedbackloc == loc) mORKS.TurntableLocLists.Add(loc); | |||||
// } | // } | ||||
// }); | |||||
// } | |||||
// } | // } | ||||
// } | // } | ||||
@@ -462,10 +493,15 @@ namespace HBLConsole.MORKS | |||||
{ | { | ||||
SimpleFactory.GetInstance.OrderChanged(mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE); | SimpleFactory.GetInstance.OrderChanged(mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE); | ||||
MessageLog.GetInstance.Show($"订单【{mORKS.OutMealId}】取餐完成"); | MessageLog.GetInstance.Show($"订单【{mORKS.OutMealId}】取餐完成"); | ||||
var RemoveItem = Json<MorkOrderPushPar>.Data.morkOrderPushes.FirstOrDefault(p => p.OrderPush.SuborderId == mORKS.OutMealId); | |||||
//var RemoveItem = Json<MorkOrderPushPar>.Data.morkOrderPushes.FirstOrDefault(p => p.OrderPush.SuborderId == mORKS.OutMealId); | |||||
//if (RemoveItem != null) | |||||
//{ | |||||
// Json<MorkOrderPushPar>.Data.morkOrderPushes.Remove(RemoveItem); | |||||
//} | |||||
var RemoveItem = Json<KeepDataBase>.Data.orderLists.FirstOrDefault(p => p.OrderPush.SuborderId == mORKS.OutMealId); | |||||
if (RemoveItem != null) | if (RemoveItem != null) | ||||
{ | { | ||||
Json<MorkOrderPushPar>.Data.morkOrderPushes.Remove(RemoveItem); | |||||
Json<KeepDataBase>.Data.orderLists.Remove(RemoveItem); | |||||
} | } | ||||
ResetCookComplete(); | ResetCookComplete(); | ||||
mORKS.OutMealId = string.Empty; | mORKS.OutMealId = string.Empty; | ||||
@@ -476,6 +512,7 @@ namespace HBLConsole.MORKS | |||||
{ | { | ||||
mORKS.TakeNoodleInterlock = false; | mORKS.TakeNoodleInterlock = false; | ||||
mORKS.AllowTakeNoodle = false; | mORKS.AllowTakeNoodle = false; | ||||
mORKS.TurntableInterlock = false; | |||||
MessageLog.GetInstance.Show("取面完成"); | MessageLog.GetInstance.Show("取面完成"); | ||||
TakeNoodleCompleteReset(); | TakeNoodleCompleteReset(); | ||||
} | } | ||||
@@ -514,6 +551,7 @@ namespace HBLConsole.MORKS | |||||
MessageLog.GetInstance.Show("成功写入配方数据"); | MessageLog.GetInstance.Show("成功写入配方数据"); | ||||
} | } | ||||
} | } | ||||
else { MessageLog.GetInstance.Show("配方数据为空"); } | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -592,11 +630,11 @@ namespace HBLConsole.MORKS | |||||
/// <param name="loc"></param> | /// <param name="loc"></param> | ||||
private void TakeBowlControl(ushort loc) | private void TakeBowlControl(ushort loc) | ||||
{ | { | ||||
if (loc == 10) | |||||
if (loc == 10)//小碗 | |||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Write(321, WriteType.Coils, true); | ModbusTcpHelper.GetInstance.Write(321, WriteType.Coils, true); | ||||
} | } | ||||
else if (loc == 11) | |||||
else if (loc == 11)//大碗 | |||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Write(322, WriteType.Coils, true); | ModbusTcpHelper.GetInstance.Write(322, WriteType.Coils, true); | ||||
} | } | ||||
@@ -42,41 +42,48 @@ namespace HBLConsole.MORKS | |||||
/// 允许运行 | /// 允许运行 | ||||
/// </summary> | /// </summary> | ||||
[Circuit(new string[] { "机器人取面", "取碗控制" }, "允许运行")] | [Circuit(new string[] { "机器人取面", "取碗控制" }, "允许运行")] | ||||
[VariableMonitor("允许运行")] | |||||
public bool AllowRun { get; set; } | public bool AllowRun { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// //机器人任务互锁信号 | /// //机器人任务互锁信号 | ||||
/// </summary> | /// </summary> | ||||
[Circuit(new string[] { "机器人取面", "出面控制" }, "机器人互锁", new bool[] { true, false })] | [Circuit(new string[] { "机器人取面", "出面控制" }, "机器人互锁", new bool[] { true, false })] | ||||
[VariableMonitor("机器人任务互锁信号")] | |||||
public bool RobotTaskInterlock { get; set; } | public bool RobotTaskInterlock { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 取碗互锁信号 | /// 取碗互锁信号 | ||||
/// </summary> | /// </summary> | ||||
[Circuit("取碗控制", "取碗互锁", true)] | [Circuit("取碗控制", "取碗互锁", true)] | ||||
[VariableMonitor("取碗互锁信号")] | |||||
public bool TakeBowlInterlock { get; set; } | public bool TakeBowlInterlock { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 取面互锁信号 | /// 取面互锁信号 | ||||
/// </summary> | /// </summary> | ||||
[Circuit(new string[] { "机器人取面", "出面控制" }, "取面互锁信号", new bool[] { true, true })] | [Circuit(new string[] { "机器人取面", "出面控制" }, "取面互锁信号", new bool[] { true, true })] | ||||
[VariableMonitor("取面互锁信号")] | |||||
public bool TakeNoodleInterlock { get; set; } | public bool TakeNoodleInterlock { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 出面中 | /// 出面中 | ||||
/// </summary> | /// </summary> | ||||
[Circuit("机器人取面", "出面中", true)] | [Circuit("机器人取面", "出面中", true)] | ||||
[VariableMonitor("出面中")] | |||||
public bool OutNoodleing { get; set; } | public bool OutNoodleing { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 允许取面 | /// 允许取面 | ||||
/// </summary> | /// </summary> | ||||
[Circuit(new string[] { "转台控制", "机器人取面" }, "允许取面", new bool[] { true, false })] | [Circuit(new string[] { "转台控制", "机器人取面" }, "允许取面", new bool[] { true, false })] | ||||
[VariableMonitor("允许取面")] | |||||
public bool AllowTakeNoodle { get; set; } | public bool AllowTakeNoodle { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 转台互锁信号 | /// 转台互锁信号 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("转台互锁信号")] | |||||
public bool TurntableInterlock { get; set; } | public bool TurntableInterlock { get; set; } | ||||
#endregion | #endregion | ||||
@@ -87,6 +94,7 @@ namespace HBLConsole.MORKS | |||||
/// ModbusTcp -> 1120 | /// ModbusTcp -> 1120 | ||||
/// </summary> | /// </summary> | ||||
[Circuit(new string[] { "允许运行", "转台控制", "转台控制" }, "初始化完成")] | [Circuit(new string[] { "允许运行", "转台控制", "转台控制" }, "初始化完成")] | ||||
[VariableMonitor("初始化完成", "M100.0", "1120")] | |||||
public bool InitComplete { get; set; } | public bool InitComplete { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -95,6 +103,7 @@ namespace HBLConsole.MORKS | |||||
/// ModbusTcp -> 1121 | /// ModbusTcp -> 1121 | ||||
/// </summary> | /// </summary> | ||||
[Circuit("取碗控制", "取碗机构空闲", true)] | [Circuit("取碗控制", "取碗机构空闲", true)] | ||||
[VariableMonitor("初始化完成", "M100.1", "1121")] | |||||
public bool TakeBowlIdle { get; set; } | public bool TakeBowlIdle { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -103,6 +112,7 @@ namespace HBLConsole.MORKS | |||||
/// ModbusTcp -> 1122 | /// ModbusTcp -> 1122 | ||||
/// </summary> | /// </summary> | ||||
[Circuit("允许运行", "温度到达")] | [Circuit("允许运行", "温度到达")] | ||||
[VariableMonitor("温度到达", "M100.2", "1122")] | |||||
public bool TemperatureReached { get; set; } | public bool TemperatureReached { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -111,6 +121,7 @@ namespace HBLConsole.MORKS | |||||
/// ModbusTcp -> 1123 | /// ModbusTcp -> 1123 | ||||
/// </summary> | /// </summary> | ||||
[Circuit("出面控制", "允许到面")] | [Circuit("出面控制", "允许到面")] | ||||
[VariableMonitor("允许到面", "M100.3", "1123")] | |||||
public bool AllowFallNoodle { get; set; } | public bool AllowFallNoodle { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -118,6 +129,7 @@ namespace HBLConsole.MORKS | |||||
/// PLC -> M100.4 | /// PLC -> M100.4 | ||||
/// ModbusTcp -> 1124 | /// ModbusTcp -> 1124 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("机器人取面完成", "M100.4", "1124")] | |||||
public bool RbTakeNoodleComplete { get; set; } | public bool RbTakeNoodleComplete { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -125,6 +137,7 @@ namespace HBLConsole.MORKS | |||||
/// PLC -> M100.5 | /// PLC -> M100.5 | ||||
/// ModbusTcp -> 1125 | /// ModbusTcp -> 1125 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("机器人倒面完成", "M100.5", "1125")] | |||||
public bool RbFallNoodleComplete { get; set; } | public bool RbFallNoodleComplete { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -132,6 +145,7 @@ namespace HBLConsole.MORKS | |||||
/// PLC -> M100.6 | /// PLC -> M100.6 | ||||
/// ModbusTcp -> 1126 | /// ModbusTcp -> 1126 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("机器人出餐完成", "M100.6", "1126")] | |||||
public bool RbOutMealComplete { get; set; } | public bool RbOutMealComplete { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -140,6 +154,7 @@ namespace HBLConsole.MORKS | |||||
/// ModbusTcp -> 1127 | /// ModbusTcp -> 1127 | ||||
/// </summary> | /// </summary> | ||||
[Circuit(new string[] { "机器人取面", "出面控制" }, "机器人空闲")] | [Circuit(new string[] { "机器人取面", "出面控制" }, "机器人空闲")] | ||||
[VariableMonitor("机器人空闲", "M100.7", "1127")] | |||||
public bool RobotIdle { get; set; } | public bool RobotIdle { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -148,6 +163,7 @@ namespace HBLConsole.MORKS | |||||
/// ModbusTcp -> 1128 | /// ModbusTcp -> 1128 | ||||
/// </summary> | /// </summary> | ||||
[Circuit("出面控制", "取餐口检测", true)] | [Circuit("出面控制", "取餐口检测", true)] | ||||
[VariableMonitor("取餐口检测", "M101.0", "1128")] | |||||
public bool TakeMealDetect { get; set; } | public bool TakeMealDetect { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -155,6 +171,7 @@ namespace HBLConsole.MORKS | |||||
/// PLC -> M101.1 | /// PLC -> M101.1 | ||||
/// ModbusTcp -> 1129 | /// ModbusTcp -> 1129 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("缺碗信号", "M101.1", "1129")] | |||||
public bool MissingBowl { get; set; } | public bool MissingBowl { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -162,6 +179,7 @@ namespace HBLConsole.MORKS | |||||
/// PLC -> M101.2 | /// PLC -> M101.2 | ||||
/// ModbusTcp -> 1130 | /// ModbusTcp -> 1130 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("设备初始化中", "M101.2", "1130")] | |||||
public bool DeviceIniting { get; set; } | public bool DeviceIniting { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -170,6 +188,7 @@ namespace HBLConsole.MORKS | |||||
/// ModbusTcp -> 1131 | /// ModbusTcp -> 1131 | ||||
/// </summary> | /// </summary> | ||||
[Circuit("转台控制", "转台下限检测有物料")] | [Circuit("转台控制", "转台下限检测有物料")] | ||||
[VariableMonitor("转台下限检测", "M101.3", "1131")] | |||||
public bool TurntableLowerLimit { get; set; } | public bool TurntableLowerLimit { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -177,6 +196,7 @@ namespace HBLConsole.MORKS | |||||
/// PLC -> M101.4 | /// PLC -> M101.4 | ||||
/// ModbusTcp -> 1132 | /// ModbusTcp -> 1132 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("缺碗信号 2", "M101.4", "1132")] | |||||
public bool MissingBowlSignal2 { get; set; } | public bool MissingBowlSignal2 { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -184,6 +204,7 @@ namespace HBLConsole.MORKS | |||||
/// PLC -> M101.5 | /// PLC -> M101.5 | ||||
/// ModbusTcp -> 1133 | /// ModbusTcp -> 1133 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("转台上限检测", "M101.5", "1133")] | |||||
public bool TurntableUpLimit { get; set; } | public bool TurntableUpLimit { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -192,6 +213,7 @@ namespace HBLConsole.MORKS | |||||
/// ModbusTcp -> 1135 | /// ModbusTcp -> 1135 | ||||
/// </summary> | /// </summary> | ||||
[Circuit(new string[] { "转台控制", "机器人取面" }, "转台移动到位")] | [Circuit(new string[] { "转台控制", "机器人取面" }, "转台移动到位")] | ||||
[VariableMonitor("转台移动到位", "M101.7", "1135")] | |||||
public bool TurntableMoveInPlace { get; set; } | public bool TurntableMoveInPlace { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -199,6 +221,7 @@ namespace HBLConsole.MORKS | |||||
/// M102.0 - M102.5 | /// M102.0 - M102.5 | ||||
/// 1136 - 1141 | /// 1136 - 1141 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("煮面炉状态", "M102.0", "1136")] | |||||
public bool[] NoodleCookerStatus { get; set; } = new bool[6] { false, false, false, false, false, false }; | public bool[] NoodleCookerStatus { get; set; } = new bool[6] { false, false, false, false, false, false }; | ||||
/// <summary> | /// <summary> | ||||
@@ -206,6 +229,7 @@ namespace HBLConsole.MORKS | |||||
/// M103.0 - M103.5 | /// M103.0 - M103.5 | ||||
/// 1144 - 1149 | /// 1144 - 1149 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("煮面完成", "M103.0", "1144")] | |||||
public bool[] CookNoodlesComplete { get; set; } = new bool[6] { false, false, false, false, false, false }; | public bool[] CookNoodlesComplete { get; set; } = new bool[6] { false, false, false, false, false, false }; | ||||
/// <summary> | /// <summary> | ||||
@@ -213,6 +237,7 @@ namespace HBLConsole.MORKS | |||||
/// PLC -> VW0 | /// PLC -> VW0 | ||||
/// ModbusTcp -> 100 | /// ModbusTcp -> 100 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("配方编号", "VW0", "100")] | |||||
public ushort RecipeNumber { get; set; } | public ushort RecipeNumber { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -220,6 +245,7 @@ namespace HBLConsole.MORKS | |||||
/// PLC -> VW2 | /// PLC -> VW2 | ||||
/// ModbusTcp -> 101 | /// ModbusTcp -> 101 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("转台位置", "VW2", "101")] | |||||
public ushort TurntableLoc { get; set; } | public ushort TurntableLoc { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -227,6 +253,7 @@ namespace HBLConsole.MORKS | |||||
/// PLC -> VW4 | /// PLC -> VW4 | ||||
/// ModbusTcp -> 102 | /// ModbusTcp -> 102 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("到面至煮面炉位置", "VW4", "102")] | |||||
public ushort FallNoodleLoc { get; set; } | public ushort FallNoodleLoc { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -234,6 +261,7 @@ namespace HBLConsole.MORKS | |||||
/// PLC -> VW6 | /// PLC -> VW6 | ||||
/// ModbusTcp -> 103 | /// ModbusTcp -> 103 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("取面位置", "VW6", "103")] | |||||
public ushort TakeNoodleLoc { get; set; } | public ushort TakeNoodleLoc { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -241,6 +269,7 @@ namespace HBLConsole.MORKS | |||||
/// PLC -> VW372 | /// PLC -> VW372 | ||||
/// ModbusTcp -> 286 | /// ModbusTcp -> 286 | ||||
/// </summary> | /// </summary> | ||||
[VariableMonitor("转台位置", "VW372", "286")] | |||||
public ushort TurntableFeedbackloc { get; set; } | public ushort TurntableFeedbackloc { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -30,7 +30,7 @@ namespace HBLConsole.MainConsole | |||||
if (Enum.TryParse(deviceType, out DeviceClientType dct)) GeneralConfig.DeviceType = dct; | if (Enum.TryParse(deviceType, out DeviceClientType dct)) GeneralConfig.DeviceType = dct; | ||||
LocaPath.GetInstance.FilePath = $"AccessFile\\{GeneralConfig.DeviceType.ToString()}\\"; | LocaPath.GetInstance.FilePath = $"AccessFile\\{GeneralConfig.DeviceType.ToString()}\\"; | ||||
ThreadManage.GetInstance.Start(new Action(() => { Sqlite<Alarm>.GetInstance.GetData(); }), "GetAlarm"); | ThreadManage.GetInstance.Start(new Action(() => { Sqlite<Alarm>.GetInstance.GetData(); }), "GetAlarm"); | ||||
Json<MorkOrderPushPar>.Read(); | |||||
//Json<MorkOrderPushPar>.Read(); | |||||
Json<BatchingInfoPar>.Read(); | Json<BatchingInfoPar>.Read(); | ||||
Json<SimOrderConfig>.Read(); | Json<SimOrderConfig>.Read(); | ||||
Json<KeepDataBase>.Read(); | Json<KeepDataBase>.Read(); | ||||
@@ -40,7 +40,7 @@ namespace HBLConsole.MainConsole | |||||
public void DataSave() | public void DataSave() | ||||
{ | { | ||||
Json<MorkOrderPushPar>.Save(); | |||||
//Json<MorkOrderPushPar>.Save(); | |||||
Json<BatchingInfoPar>.Save(); | Json<BatchingInfoPar>.Save(); | ||||
Json<SimOrderConfig>.Save(); | Json<SimOrderConfig>.Save(); | ||||
Json<KeepDataBase>.Save(); | Json<KeepDataBase>.Save(); | ||||
@@ -53,53 +53,8 @@ namespace HBLConsole.MainConsole | |||||
{ | { | ||||
ThreadManage.GetInstance.Start(new Action(() => | ThreadManage.GetInstance.Start(new Action(() => | ||||
{ | { | ||||
//SimpleFactory.GetInstance.DeviceInit();//设备初始化 | |||||
InternetInfo.ConfigInit();//从 consul 获取配置数据 | |||||
Topics.Clear(); | |||||
Topics.Add(TOPIC.GetInstance.GetOrderPushTopic(GeneralConfig.DeviceType, InternetInfo.ClientId)); | |||||
Topics.Add(TOPIC.GetInstance.GetBusinessTopic(GeneralConfig.DeviceType, InternetInfo.ClientId)); | |||||
//MQTT 连接成功 | |||||
MqttHelper.GetInstance.ConnectOk = new Action(() => | |||||
{ | |||||
SimpleFactory.GetInstance.DeviceInit();//设备初始化 | |||||
MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray());//主题订阅 | |||||
IotReport.GetInstance.Init();//IOT 上报 | |||||
HeartbeatReport.GetInstance.Init();//心跳上报 | |||||
ServerData.GetInstance.Init();//数据处理初始化 | |||||
//接收MQTT消息 | |||||
MqttHelper.GetInstance.MqttReceive = new Action<MQTTnet.MqttApplicationMessageReceivedEventArgs>((receivce) => | |||||
{ | |||||
ServerData.GetInstance.ReceiveData(Encoding.UTF8.GetString(receivce.ApplicationMessage.Payload)); | |||||
}); | |||||
}); | |||||
//MQTT 重连成功 | |||||
MqttHelper.GetInstance.Reconnection = new Action(() => { MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray()); }); | |||||
//MQTT 连接 | |||||
MqttHelper.GetInstance.MqttInitAsync(InternetInfo.MqttUserName, InternetInfo.MqttPassword, | |||||
InternetInfo.MqttAddress, InternetInfo.MqttPort, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")); | |||||
}), "业务逻辑初始化"); | |||||
} | |||||
[Obsolete("测试使用,服务正常后切换到函数 BusinessInit()")] | |||||
public void BusinessSimTest() | |||||
{ | |||||
ThreadManage.GetInstance.Start(new Action(() => | |||||
{ | |||||
InternetInfo.ConfigInit();//从 consul 获取配置数据 | InternetInfo.ConfigInit();//从 consul 获取配置数据 | ||||
IotReport.GetInstance.Initialize(); | |||||
Topics.Clear(); | Topics.Clear(); | ||||
Topics.Add(TOPIC.GetInstance.GetOrderPushTopic(GeneralConfig.DeviceType, InternetInfo.ClientId)); | Topics.Add(TOPIC.GetInstance.GetOrderPushTopic(GeneralConfig.DeviceType, InternetInfo.ClientId)); | ||||
Topics.Add(TOPIC.GetInstance.GetBusinessTopic(GeneralConfig.DeviceType, InternetInfo.ClientId)); | Topics.Add(TOPIC.GetInstance.GetBusinessTopic(GeneralConfig.DeviceType, InternetInfo.ClientId)); | ||||
@@ -111,8 +66,6 @@ namespace HBLConsole.MainConsole | |||||
MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray());//主题订阅 | MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray());//主题订阅 | ||||
IotReport.GetInstance.Init();//IOT 上报 | |||||
HeartbeatReport.GetInstance.Init();//心跳上报 | HeartbeatReport.GetInstance.Init();//心跳上报 | ||||
ServerData.GetInstance.Init();//数据处理初始化 | ServerData.GetInstance.Init();//数据处理初始化 | ||||
@@ -0,0 +1,43 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace HBLConsole.Model | |||||
{ | |||||
/// <summary> | |||||
/// 下发至Plc设备参数实体 | |||||
/// </summary> | |||||
public class DistributePlcPar | |||||
{ | |||||
/***屏蔽煮面口**/ | |||||
public bool HideNoodleNo1 { get; set; } | |||||
public bool HideNoodleNo2 { get; set; } | |||||
public bool HideNoodleNo3 { get; set; } | |||||
public bool HideNoodleNo4 { get; set; } | |||||
public bool HideNoodleNo5 { get; set; } | |||||
public bool HideNoodleNo6 { get; set; } | |||||
/***冷库转盘当前位置***/ | |||||
public int CurrentTurnPosition { get; set; } | |||||
/***煮面口时间设定**/ | |||||
public int No1_Minute { get; set; } | |||||
public int No1_Second { get; set; } | |||||
public int No2_Minute { get; set; } | |||||
public int No2_Second { get; set; } | |||||
public int No3_Minute { get; set; } | |||||
public int No3_Second { get; set; } | |||||
public int No4_Minute { get; set; } | |||||
public int No4_Second { get; set; } | |||||
public int No5_Minute { get; set; } | |||||
public int No5_Second { get; set; } | |||||
public int No6_Minute { get; set; } | |||||
public int No6_Second { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,14 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace HBLConsole.Model | |||||
{ | |||||
public class DeviceData | |||||
{ | |||||
public static bool Initing { get; set; } | |||||
} | |||||
} |
@@ -9,6 +9,6 @@ namespace HBLConsole.Model | |||||
{ | { | ||||
public class MorkOrderPushPar | public class MorkOrderPushPar | ||||
{ | { | ||||
public List<OrderData> morkOrderPushes = new List<OrderData>(); | |||||
public List<OrderData> morkOrderPushes { get; set; } = new List<OrderData>(); | |||||
} | } | ||||
} | } |
@@ -0,0 +1,17 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
namespace HBLConsole.Model | |||||
{ | |||||
public class ParSet : ObservableObject | |||||
{ | |||||
public bool IsAutoStart { get { return _mIsAutoStart; } set { _mIsAutoStart = value; OnPropertyChanged(); } } | |||||
private bool _mIsAutoStart; | |||||
} | |||||
} |
@@ -7,9 +7,11 @@ using System.Threading.Tasks; | |||||
namespace HBLConsole.Service | namespace HBLConsole.Service | ||||
{ | { | ||||
/// <summary> | |||||
/// 上升沿操作类 | |||||
/// </summary> | |||||
public class RTrig | public class RTrig | ||||
{ | { | ||||
private volatile static ConcurrentDictionary<string, RTrig> _Instance; | private volatile static ConcurrentDictionary<string, RTrig> _Instance; | ||||
public static RTrig GetInstance(string name) | public static RTrig GetInstance(string name) | ||||
{ | { | ||||
@@ -34,8 +36,5 @@ namespace HBLConsole.Service | |||||
IN1 = IN; | IN1 = IN; | ||||
return Q; | return Q; | ||||
} | } | ||||
} | } | ||||
} | } |
@@ -95,9 +95,12 @@ namespace HBLConsole.Service | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public bool IsAutoStart() | public bool IsAutoStart() | ||||
{ | { | ||||
//RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run\"); | |||||
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run\"); | |||||
return registryKey.GetValueNames().Contains(GetApplicationName); | |||||
RegistryKey R_local = Registry.CurrentUser; | |||||
RegistryKey R_run = R_local.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); | |||||
bool res = R_run.GetValueNames().Contains(GetApplicationName); | |||||
R_run.Close(); | |||||
R_local.Close(); | |||||
return res; | |||||
} | } | ||||
@@ -0,0 +1,39 @@ | |||||
using System; | |||||
using System.Collections.Concurrent; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace HBLConsole.Service | |||||
{ | |||||
/// <summary> | |||||
/// 下降沿操作 | |||||
/// </summary> | |||||
public class TTrig | |||||
{ | |||||
private volatile static ConcurrentDictionary<string, TTrig> _Instance; | |||||
public static TTrig GetInstance(string name) | |||||
{ | |||||
if (_Instance == null) _Instance = new ConcurrentDictionary<string, TTrig>(); | |||||
if (!_Instance.ContainsKey(name)) _Instance.TryAdd(name, new TTrig()); | |||||
return _Instance[name]; | |||||
} | |||||
private TTrig() { } | |||||
private bool flag1; | |||||
public bool Q { get; private set; } | |||||
private bool IN1 | |||||
{ | |||||
set | |||||
{ | |||||
Q = !value && flag1; | |||||
flag1 = value; | |||||
} | |||||
} | |||||
public bool Start(bool IN) | |||||
{ | |||||
IN1 = IN; | |||||
return Q; | |||||
} | |||||
} | |||||
} |
@@ -36,47 +36,39 @@ namespace HBLConsole.Service | |||||
ActionManage.GetInstance.Register(ExitCallback, guid + key); | ActionManage.GetInstance.Register(ExitCallback, guid + key); | ||||
} | } | ||||
//public void StopTask(string[] keys, Action ExitCallback = null) | |||||
//{ | |||||
// lock (_lock) | |||||
// if (keys != null) | |||||
// { | |||||
// for (int i = 0; i < keys.Length; i++) | |||||
// { | |||||
// this.keys.Add(keys[i]); | |||||
// callbackKey.Append(keys[i]); | |||||
// if (CancellationTokenSources.ContainsKey(guid + keys[i])) | |||||
// CancellationTokenSources[guid + keys[i]]?.Cancel(); | |||||
// } | |||||
// callbackKey.Append(guid); | |||||
// ActionManage.GetInstance.Register(ExitCallback, callbackKey.ToString()); | |||||
// } | |||||
//} | |||||
/// <summary> | /// <summary> | ||||
/// 长任务,带 while true 的循环 | /// 长任务,带 while true 的循环 | ||||
/// </summary> | /// </summary> | ||||
/// <param name="action"></param> | /// <param name="action"></param> | ||||
/// <param name="key"></param> | /// <param name="key"></param> | ||||
public void StartLong(Action action, string key, Action RunComplete = null) | |||||
public void StartLong(Action action, string key, bool IsRestart = false, Action RunComplete = null) | |||||
{ | { | ||||
CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource()); | CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource()); | ||||
bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() => | bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() => | ||||
{ | { | ||||
ccc: | |||||
try | try | ||||
{ | { | ||||
while (!CancellationTokenSources[guid + key].IsCancellationRequested) | while (!CancellationTokenSources[guid + key].IsCancellationRequested) | ||||
{ | { | ||||
if (action != null) action(); | |||||
if (action != null) | |||||
{ | |||||
action(); | |||||
} | |||||
} | } | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已重启"); | |||||
CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource temp); | |||||
Threads.TryRemove(guid + key, out Task temp1); | |||||
MessageLog.GetInstance.Show(ex.ToString()); | |||||
if (IsRestart) goto ccc; | |||||
else | |||||
{ | |||||
CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource temp); | |||||
Threads.TryRemove(guid + key, out Task temp1); | |||||
MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已重启"); | |||||
} | |||||
} | } | ||||
}), CancellationTokenSources[guid + key].Token).ContinueWith(new Action<Task, object>((t, o) => | }), CancellationTokenSources[guid + key].Token).ContinueWith(new Action<Task, object>((t, o) => | ||||
{ | { | ||||
@@ -35,7 +35,7 @@ namespace HBLConsole | |||||
protected override void OnStartup(StartupEventArgs e) | protected override void OnStartup(StartupEventArgs e) | ||||
{ | { | ||||
base.OnStartup(e); | base.OnStartup(e); | ||||
SystemHelper.GetInstance.AutoStart(false); | |||||
//SystemHelper.GetInstance.AutoStart(true); | |||||
SystemHelper.GetInstance.CreateDesktopShortcut(); | SystemHelper.GetInstance.CreateDesktopShortcut(); | ||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | ||||
MainConsole.Main.GetInstance.DataInit(); | MainConsole.Main.GetInstance.DataInit(); | ||||
@@ -44,7 +44,7 @@ namespace HBLConsole | |||||
mainView.Show(); | mainView.Show(); | ||||
SplitScreenDisplay(); | SplitScreenDisplay(); | ||||
NoCompleteOrderInit(); | NoCompleteOrderInit(); | ||||
MainConsole.Main.GetInstance.BusinessSimTest(); | |||||
MainConsole.Main.GetInstance.BusinessInit(); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -94,6 +94,7 @@ namespace HBLConsole | |||||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) | private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) | ||||
{ | { | ||||
var ErroLog = e.ExceptionObject.ToString(); | var ErroLog = e.ExceptionObject.ToString(); | ||||
MessageLog.GetInstance.Show(ErroLog); | |||||
TextHelper.GetInstance.WriteTextInfo(ErroLog, "ErroLog"); | TextHelper.GetInstance.WriteTextInfo(ErroLog, "ErroLog"); | ||||
SqlHelper.GetInstance.Save(); | SqlHelper.GetInstance.Save(); | ||||
MainConsole.Main.GetInstance.DataSave(); | MainConsole.Main.GetInstance.DataSave(); | ||||
@@ -20,51 +20,6 @@ namespace HBLConsole.DialogWindow.ViewModel | |||||
public static bool IsAutoClose = false; | public static bool IsAutoClose = false; | ||||
public ListDialogViewModel() | public ListDialogViewModel() | ||||
{ | { | ||||
//CloseCommand = new RelayCommand(() => | |||||
//{ | |||||
// Json<MorkOrderPushPar>.Data.morkOrderPushes.Clear(); | |||||
// orderStatusLists.Clear(); | |||||
// WeakReferenceMessenger.Default.Send("false", "Close"); | |||||
//}); | |||||
//CancelCommand = new RelayCommand(() => | |||||
//{ | |||||
// Json<MorkOrderPushPar>.Data.morkOrderPushes.Clear(); | |||||
// orderStatusLists.Clear(); | |||||
// WeakReferenceMessenger.Default.Send("false", "Close"); | |||||
//}); | |||||
//ConfirmCommand = new RelayCommand(() => | |||||
//{ | |||||
// foreach (var item in orderStatusLists) | |||||
// { | |||||
// if (!item.IsSelected) | |||||
// { | |||||
// var reslut = Json<MorkOrderPushPar>.Data.morkOrderPushes.FirstOrDefault(p => p.OrderPush.SuborderId == item.OrderPush.SuborderId); | |||||
// if (reslut != null) Json<MorkOrderPushPar>.Data.morkOrderPushes.Remove(reslut); | |||||
// } | |||||
// } | |||||
// foreach (var item in Json<MorkOrderPushPar>.Data.morkOrderPushes) | |||||
// { | |||||
// orderStatusLists.Add(new OrderData() { IsSelected = true, OrderPush = item.OrderPush, OrderStatus = item.OrderStatus }); | |||||
// } | |||||
// WeakReferenceMessenger.Default.Send("true", "Close"); | |||||
//}); | |||||
//foreach (var item in Json<MorkOrderPushPar>.Data.morkOrderPushes) | |||||
//{ | |||||
// orderStatusLists.Add(new OrderData() { IsSelected = true, OrderPush = item.OrderPush, OrderStatus = item.OrderStatus }); | |||||
//} | |||||
//if (Json<MorkOrderPushPar>.Data.morkOrderPushes.Count > 0) | |||||
//{ | |||||
// ThreadManage.GetInstance.Start(new Action(() => | |||||
// { | |||||
// Thread.Sleep(10000); | |||||
// if (!IsAutoClose) WeakReferenceMessenger.Default.Send("false", "Close"); | |||||
// }), "延时退出"); | |||||
//} | |||||
//AllSelected = true; | |||||
Init(); | Init(); | ||||
} | } | ||||
@@ -86,8 +41,6 @@ namespace HBLConsole.DialogWindow.ViewModel | |||||
ConfirmCommand = new RelayCommand(() => | ConfirmCommand = new RelayCommand(() => | ||||
{ | { | ||||
//if (Json<KeepDataBase>.Data.orderLists.ContainsKey(GVL.GeneralConfig.DeviceType.ToString())) | |||||
//{ | |||||
var res = orderStatusLists.Where(p => p.IsSelected == true).ToList(); | var res = orderStatusLists.Where(p => p.IsSelected == true).ToList(); | ||||
if (res != null) | if (res != null) | ||||
{ | { | ||||
@@ -99,11 +52,11 @@ namespace HBLConsole.DialogWindow.ViewModel | |||||
ActionManage.GetInstance.Send("DataParse", item.OrderPush); | ActionManage.GetInstance.Send("DataParse", item.OrderPush); | ||||
} | } | ||||
} | } | ||||
//} | |||||
WeakReferenceMessenger.Default.Send("true", "Close"); | WeakReferenceMessenger.Default.Send("true", "Close"); | ||||
}); | }); | ||||
if (Json<MorkOrderPushPar>.Data.morkOrderPushes.Count > 0) | |||||
//if (Json<MorkOrderPushPar>.Data.morkOrderPushes.Count > 0) | |||||
if (Json<KeepDataBase>.Data.orderLists.Count > 0) | |||||
{ | { | ||||
ThreadManage.GetInstance.Start(new Action(() => | ThreadManage.GetInstance.Start(new Action(() => | ||||
{ | { | ||||
@@ -264,10 +264,8 @@ | |||||
<Button | <Button | ||||
x:Name="button_loop" | x:Name="button_loop" | ||||
Margin="0,0,10,0" | Margin="0,0,10,0" | ||||
Command="{Binding LoopSimOrderCommand}" | |||||
CommandParameter="{Binding ElementName=button_loop, Path=Content}" | |||||
Content="{Binding LoopButton, Mode=TwoWay, NotifyOnTargetUpdated=True}" | |||||
Foreground="{Binding LoopColor, Mode=TwoWay, NotifyOnTargetUpdated=True}" | |||||
Command="{Binding LoopSimOrderCommand}" | |||||
Content="{Binding LoopOrderButtonContent}" | |||||
Style="{StaticResource ButtonStyle}" /> | Style="{StaticResource ButtonStyle}" /> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
@@ -266,6 +266,8 @@ | |||||
<RadioButton | <RadioButton | ||||
Margin="-10,0,0,0" | Margin="-10,0,0,0" | ||||
Command="{Binding NavChangedCommand}" | |||||
CommandParameter="ParSetView" | |||||
Content="参数设置" | Content="参数设置" | ||||
Style="{StaticResource ParallelogramRadioButtonStyle}" /> | Style="{StaticResource ParallelogramRadioButtonStyle}" /> | ||||
@@ -0,0 +1,416 @@ | |||||
<UserControl | |||||
x:Class="HBLConsole.View.ParSetView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:HBLConsole.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:vm="clr-namespace:HBLConsole.ViewModel" | |||||
xmlns:pry="clr-namespace:HBLConsole.PryUserControl;assembly=HBLConsole.PryUserControl" | |||||
d:DesignHeight="450" | |||||
d:DesignWidth="1000" | |||||
mc:Ignorable="d"> | |||||
<UserControl.DataContext> | |||||
<vm:ParSetViewModel /> | |||||
</UserControl.DataContext> | |||||
<UserControl.Resources> | |||||
<ResourceDictionary Source="../Resources/ResourceDictionarys/BasicStyle.xaml"> | |||||
<ResourceDictionary.MergedDictionaries> | |||||
<ResourceDictionary> | |||||
<Style x:Key="TextBlockStyle" TargetType="TextBlock"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="FontSize" Value="18" /> | |||||
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||||
</Style> | |||||
<Style x:Key="TextBoxStyle" TargetType="TextBox"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="FontSize" Value="22" /> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" /> | |||||
<Setter Property="BorderBrush" Value="#FF23CACA" /> | |||||
<Setter Property="CaretBrush" Value="Aqua" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
</Style> | |||||
<Style x:Key="buttonStyle" TargetType="Button"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="FontSize" Value="20" /> | |||||
<Setter Property="Foreground" Value="#FFDE7889" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="Button"> | |||||
<Grid> | |||||
<ContentControl | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
Foreground="{TemplateBinding Foreground}" /> | |||||
<pry:Quadrilateral | |||||
x:Name="poly" | |||||
Stroke="#FFDE7889" | |||||
StrokeThickness="2" /> | |||||
</Grid> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter TargetName="poly" Property="FillColor" Value="#22DE7889" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
</ResourceDictionary> | |||||
</ResourceDictionary.MergedDictionaries> | |||||
</ResourceDictionary> | |||||
</UserControl.Resources> | |||||
<Grid Margin="10"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="40" /> | |||||
<RowDefinition Height="35"/> | |||||
<RowDefinition Height="Auto"/> | |||||
</Grid.RowDefinitions> | |||||
<CheckBox | |||||
Grid.Row="0" | |||||
Grid.Column="2" | |||||
Height="20" | |||||
Margin="10" | |||||
VerticalAlignment="Top" | |||||
Background="#FF2AB2E7" | |||||
Content="开机启动" | |||||
FontSize="14" | |||||
Foreground="#00c2f4" | |||||
IsChecked="{Binding IsSelected}" | |||||
Template="{StaticResource CbTemplate}" /> | |||||
<StackPanel | |||||
Grid.Row="1" | |||||
HorizontalAlignment="Right" Orientation="Horizontal"> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="请点击按钮保存参数:" /> | |||||
<Button | |||||
Width="140" | |||||
Command="{Binding SaveInfoCommand}" | |||||
Content="保存" | |||||
FontFamily="楷体" | |||||
FontSize="18" | |||||
Template="{StaticResource SaveButtonTemp}"> | |||||
<Button.Foreground> | |||||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | |||||
<GradientStop Color="#FFBB662A" /> | |||||
<GradientStop Offset="1" Color="White" /> | |||||
</LinearGradientBrush> | |||||
</Button.Foreground> | |||||
</Button> | |||||
</StackPanel> | |||||
<!--参数放置面板--> | |||||
<Grid Grid.Row="2"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition/> | |||||
<RowDefinition/> | |||||
<RowDefinition/> | |||||
<RowDefinition/> | |||||
<RowDefinition/> | |||||
<RowDefinition/> | |||||
<RowDefinition/> | |||||
<RowDefinition/> | |||||
<RowDefinition/> | |||||
</Grid.RowDefinitions> | |||||
<!--屏蔽煮面口--> | |||||
<StackPanel Grid.Row="0" | |||||
Margin="10,0,0,0" | |||||
HorizontalAlignment="Left" Orientation="Horizontal"> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="屏蔽煮面口:" /> | |||||
<CheckBox | |||||
Height="20" | |||||
Margin="10" | |||||
VerticalAlignment="Top" | |||||
Background="#FF2AB2E7" | |||||
Content="煮面口1" | |||||
FontSize="14" | |||||
Foreground="#00c2f4" | |||||
IsChecked="{Binding HideNoodleNo1}" | |||||
Template="{StaticResource CbTemplate}"></CheckBox> | |||||
<CheckBox | |||||
Height="20" | |||||
Margin="10" | |||||
VerticalAlignment="Top" | |||||
Background="#FF2AB2E7" | |||||
Content="煮面口2" | |||||
FontSize="14" | |||||
Foreground="#00c2f4" | |||||
IsChecked="{Binding HideNoodleNo2}" | |||||
Template="{StaticResource CbTemplate}"></CheckBox> | |||||
<CheckBox | |||||
Height="20" | |||||
Margin="10" | |||||
VerticalAlignment="Top" | |||||
Background="#FF2AB2E7" | |||||
Content="煮面口3" | |||||
FontSize="14" | |||||
Foreground="#00c2f4" | |||||
IsChecked="{Binding HideNoodleNo3}" | |||||
Template="{StaticResource CbTemplate}"></CheckBox> | |||||
<CheckBox | |||||
Height="20" | |||||
Margin="10" | |||||
VerticalAlignment="Top" | |||||
Background="#FF2AB2E7" | |||||
Content="煮面口4" | |||||
FontSize="14" | |||||
Foreground="#00c2f4" | |||||
IsChecked="{Binding HideNoodleNo4}" | |||||
Template="{StaticResource CbTemplate}"></CheckBox> | |||||
<CheckBox | |||||
Height="20" | |||||
Margin="10" | |||||
VerticalAlignment="Top" | |||||
Background="#FF2AB2E7" | |||||
Content="煮面口5" | |||||
FontSize="14" | |||||
Foreground="#00c2f4" | |||||
IsChecked="{Binding HideNoodleNo5}" | |||||
Template="{StaticResource CbTemplate}"></CheckBox> | |||||
<CheckBox | |||||
Height="20" | |||||
Margin="10" | |||||
VerticalAlignment="Top" | |||||
Background="#FF2AB2E7" | |||||
Content="煮面口6" | |||||
FontSize="14" | |||||
Foreground="#00c2f4" | |||||
IsChecked="{Binding HideNoodleNo6}" | |||||
Template="{StaticResource CbTemplate}"></CheckBox> | |||||
</StackPanel> | |||||
<StackPanel Grid.Row="1" | |||||
Margin="10,0,0,0" | |||||
HorizontalAlignment="Left" Orientation="Horizontal"> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="冷库转盘当前位置(1——5):" /> | |||||
<TextBox | |||||
Grid.Row="1" | |||||
Grid.Column="1" | |||||
Margin="0,10" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Width="100" | |||||
Text="{Binding CurrentTurnPosition}" /> | |||||
</StackPanel> | |||||
<!--煮面口时间设定--> | |||||
<StackPanel Grid.Row="2" | |||||
Margin="10,0,0,0" | |||||
HorizontalAlignment="Left" Orientation="Horizontal"> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="煮面口1时间设定" /> | |||||
<TextBox | |||||
Grid.Column="1" | |||||
Margin="10,0,0,0" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Width="100" | |||||
Text="{Binding No1_Minute}" /> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="(分)" /> | |||||
<TextBox | |||||
Grid.Column="1" | |||||
Margin="0,10" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Width="100" | |||||
Text="{Binding No1_Second}" /> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="(秒)" /> | |||||
</StackPanel> | |||||
<StackPanel Grid.Row="3" | |||||
Margin="10,0,0,0" | |||||
HorizontalAlignment="Left" Orientation="Horizontal"> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="煮面口2时间设定" /> | |||||
<TextBox | |||||
Grid.Column="1" | |||||
Margin="10,0,0,0" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Width="100" | |||||
Text="{Binding No2_Minute}" /> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="(分)" /> | |||||
<TextBox | |||||
Grid.Column="1" | |||||
Margin="0,10" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Width="100" | |||||
Text="{Binding No2_Second}" /> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="(秒)" /> | |||||
</StackPanel> | |||||
<StackPanel Grid.Row="4" | |||||
Margin="10,0,0,0" | |||||
HorizontalAlignment="Left" Orientation="Horizontal"> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="煮面口3时间设定" /> | |||||
<TextBox | |||||
Grid.Column="1" | |||||
Margin="10,0,0,0" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Width="100" | |||||
Text="{Binding No3_Minute}" /> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="(分)" /> | |||||
<TextBox | |||||
Grid.Column="1" | |||||
Margin="0,10" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Width="100" | |||||
Text="{Binding No3_Second}" /> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="(秒)" /> | |||||
</StackPanel> | |||||
<StackPanel Grid.Row="5" | |||||
Margin="10,0,0,0" | |||||
HorizontalAlignment="Left" Orientation="Horizontal"> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="煮面口4时间设定" /> | |||||
<TextBox | |||||
Grid.Column="1" | |||||
Margin="10,0,0,0" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Width="100" | |||||
Text="{Binding No4_Minute}" /> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="(分)" /> | |||||
<TextBox | |||||
Grid.Column="1" | |||||
Margin="0,10" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Width="100" | |||||
Text="{Binding No4_Second}" /> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="(秒)" /> | |||||
</StackPanel> | |||||
<StackPanel Grid.Row="6" | |||||
Margin="10,0,0,0" | |||||
HorizontalAlignment="Left" Orientation="Horizontal"> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="煮面口5时间设定" /> | |||||
<TextBox | |||||
Grid.Column="1" | |||||
Margin="10,0,0,0" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Width="100" | |||||
Text="{Binding No5_Minute}" /> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="(分)" /> | |||||
<TextBox | |||||
Grid.Column="1" | |||||
Margin="0,10" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Width="100" | |||||
Text="{Binding No5_Second}" /> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="(秒)" /> | |||||
</StackPanel> | |||||
<StackPanel Grid.Row="7" | |||||
Margin="10,0,0,0" | |||||
HorizontalAlignment="Left" Orientation="Horizontal"> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="煮面口6时间设定" /> | |||||
<TextBox | |||||
Grid.Column="1" | |||||
Margin="10,0,0,0" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Width="100" | |||||
Text="{Binding No6_Minute}" /> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="(分)" /> | |||||
<TextBox | |||||
Grid.Column="1" | |||||
Margin="0,10" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Width="100" | |||||
Text="{Binding No6_Second}" /> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="(秒)" /> | |||||
</StackPanel> | |||||
</Grid> | |||||
</Grid> | |||||
</UserControl> |
@@ -0,0 +1,28 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Windows; | |||||
using System.Windows.Controls; | |||||
using System.Windows.Data; | |||||
using System.Windows.Documents; | |||||
using System.Windows.Input; | |||||
using System.Windows.Media; | |||||
using System.Windows.Media.Imaging; | |||||
using System.Windows.Navigation; | |||||
using System.Windows.Shapes; | |||||
namespace HBLConsole.View | |||||
{ | |||||
/// <summary> | |||||
/// ParSetView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class ParSetView : UserControl | |||||
{ | |||||
public ParSetView() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
} | |||||
} |
@@ -46,7 +46,6 @@ namespace HBLConsole.ViewModel | |||||
{ | { | ||||
locs.Add((ushort)(new Random().Next(1, 5))); | locs.Add((ushort)(new Random().Next(1, 5))); | ||||
locs.Add(10); | locs.Add(10); | ||||
} | } | ||||
ActionManage.GetInstance.Send("SimOrder", locs); | ActionManage.GetInstance.Send("SimOrder", locs); | ||||
@@ -63,46 +62,17 @@ namespace HBLConsole.ViewModel | |||||
LoopSimOrderCommand = new RelayCommand(() => | LoopSimOrderCommand = new RelayCommand(() => | ||||
{ | { | ||||
LoopButton = LoopButton == "循环跑单" ? "停止跑单" : "循环跑单"; | |||||
if (LoopOrderButtonContent == "循环跑单") ActionManage.GetInstance.Send("EnableForOrder"); | |||||
if (LoopOrderButtonContent == "停止跑单") ActionManage.GetInstance.Send("StopForOrder"); | |||||
LoopOrderButtonContent = LoopOrderButtonContent == "循环跑单" ? "停止跑单" : "循环跑单"; | |||||
}); | }); | ||||
//ThreadManage.GetInstance.StartLong(new Action(() => | |||||
//{ | |||||
// //try | |||||
// //{ | |||||
// // System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)async delegate | |||||
// // { | |||||
// // if (IsLoop && !IsLoopzc) | |||||
// // { | |||||
// // IsLoopzc = true; | |||||
// // if (simOrderVisibleDatas.ElementAt(0).IsSelected) | |||||
// // simOrderVisibleDatas.ElementAt(0).Loc = (ushort)(new Random().Next(1,6)); | |||||
// // ActionManage.GetInstance.Send("SimOrder",new SimOrderData() | |||||
// // { | |||||
// // NoodleLoc = simOrderVisibleDatas.ElementAt(0).Loc, | |||||
// // SoupLoc = simOrderVisibleDatas.ElementAt(1).Loc, | |||||
// // BowlLoc = 10, | |||||
// // }); | |||||
// // await Task.Delay(50000); | |||||
// // IsLoopzc = false; | |||||
// // } | |||||
// // }); | |||||
// //} | |||||
// //catch (Exception ex) | |||||
// //{ | |||||
// //} | |||||
// Thread.Sleep(1000); | |||||
//}), "循环订单"); | |||||
EditCommand = new RelayCommand<object>((o) => | EditCommand = new RelayCommand<object>((o) => | ||||
{ | { | ||||
if (o != null) | if (o != null) | ||||
{ | { | ||||
//if (Json<KeepDataBase>.Data.simOrderConfig.ContainsKey(GVL.GeneralConfig.DeviceType.ToString())) | |||||
//{ | |||||
var res = Json<KeepDataBase>.Data.simOrderConfig.FirstOrDefault(p => p.Text == o.ToString()); | var res = Json<KeepDataBase>.Data.simOrderConfig.FirstOrDefault(p => p.Text == o.ToString()); | ||||
if (res != null) | if (res != null) | ||||
{ | { | ||||
@@ -110,7 +80,6 @@ namespace HBLConsole.ViewModel | |||||
simOrderConfitView.Show(); | simOrderConfitView.Show(); | ||||
ActionManage.GetInstance.Send("SendSimData", res); | ActionManage.GetInstance.Send("SendSimData", res); | ||||
} | } | ||||
//} | |||||
} | } | ||||
}); | }); | ||||
@@ -119,11 +88,8 @@ namespace HBLConsole.ViewModel | |||||
{ | { | ||||
if (o != null) | if (o != null) | ||||
{ | { | ||||
//if (Json<KeepDataBase>.Data.simOrderConfig.ContainsKey(GVL.GeneralConfig.DeviceType.ToString())) | |||||
//{ | |||||
var res = Json<KeepDataBase>.Data.simOrderConfig.FirstOrDefault(p => p.Text == o.ToString()); | var res = Json<KeepDataBase>.Data.simOrderConfig.FirstOrDefault(p => p.Text == o.ToString()); | ||||
if (res != null) Json<KeepDataBase>.Data.simOrderConfig.Remove(res); | if (res != null) Json<KeepDataBase>.Data.simOrderConfig.Remove(res); | ||||
//} | |||||
} | } | ||||
}); | }); | ||||
} | } | ||||
@@ -132,18 +98,10 @@ namespace HBLConsole.ViewModel | |||||
{ | { | ||||
get | get | ||||
{ | { | ||||
//if (!Json<KeepDataBase>.Data.simOrderConfig.ContainsKey(GVL.GeneralConfig.DeviceType.ToString())) | |||||
//{ | |||||
// Json<KeepDataBase>.Data.simOrderConfig.TryAdd(GVL.GeneralConfig.DeviceType.ToString(), new ObservableCollection<SimOrderVisibleData>()); | |||||
//} | |||||
return Json<KeepDataBase>.Data.simOrderConfig; | return Json<KeepDataBase>.Data.simOrderConfig; | ||||
} | } | ||||
set | set | ||||
{ | { | ||||
//if (!Json<KeepDataBase>.Data.simOrderConfig.ContainsKey(GVL.GeneralConfig.DeviceType.ToString())) | |||||
//{ | |||||
// Json<KeepDataBase>.Data.simOrderConfig.TryAdd(GVL.GeneralConfig.DeviceType.ToString(), new ObservableCollection<SimOrderVisibleData>()); | |||||
//} | |||||
Json<KeepDataBase>.Data.simOrderConfig = value; | Json<KeepDataBase>.Data.simOrderConfig = value; | ||||
} | } | ||||
} | } | ||||
@@ -160,23 +118,18 @@ namespace HBLConsole.ViewModel | |||||
public RelayCommand<object> RemoveCommand { get; set; } | public RelayCommand<object> RemoveCommand { get; set; } | ||||
public static bool IsLoop = false; | |||||
public static bool IsLoopzc = false; | |||||
public static string LoopButton | |||||
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged; | |||||
public static void OnStaticPropertyChanged([CallerMemberName] string PropName = "") | |||||
{ | { | ||||
get { return _LoopButton; } | |||||
set | |||||
{ | |||||
_LoopButton = value; | |||||
if (value != "循环跑单") { IsLoop = true; LoopColor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("Red")); } | |||||
else { IsLoop = false; LoopColor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#00c2f4")); } | |||||
OnStaticPropertyChanged(); | |||||
} | |||||
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName)); | |||||
} | } | ||||
private static string _LoopButton = "循环跑单"; | |||||
public static Brush LoopColor { get { return _LoopColor; } set { _LoopColor = value; OnStaticPropertyChanged(); } } | |||||
private static Brush _LoopColor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#00c2f4")); | |||||
public static string LoopOrderButtonContent { get { return _mLoopOrderButtonContent; } set { _mLoopOrderButtonContent = value; OnStaticPropertyChanged(); } } | |||||
private static string _mLoopOrderButtonContent = "循环跑单"; | |||||
} | } | ||||
@@ -60,7 +60,7 @@ namespace HBLConsole.ViewModel | |||||
} | } | ||||
private string _mClientDeviceType = string.Empty; | private string _mClientDeviceType = string.Empty; | ||||
public static ObservableCollection<CommunicationSet> communicationSets { get; set; } = new ObservableCollection<CommunicationSet>(); | |||||
public static ObservableCollection<CommunicationSet> communicationSets { get; set;} = new ObservableCollection<CommunicationSet>(); | |||||
public ObservableCollection<string> ClientDevices { get; set; } = new ObservableCollection<string>(); | public ObservableCollection<string> ClientDevices { get; set; } = new ObservableCollection<string>(); | ||||
@@ -0,0 +1,257 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Collections.ObjectModel; | |||||
using System.Diagnostics; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using BPA.Message.Enum; | |||||
using HBLConsole.Model; | |||||
using HBLConsole.Service; | |||||
using Microsoft.Toolkit.Mvvm.Input; | |||||
namespace HBLConsole.ViewModel | |||||
{ | |||||
public class ParSetViewModel : ViewModelBase | |||||
{ | |||||
public ParSetViewModel() | |||||
{ | |||||
WindowName = "参数设置"; | |||||
// | |||||
if (SaveInfoCommand == null) | |||||
{ | |||||
SaveInfoCommand = new RelayCommand(SaveInfoHandler); | |||||
} | |||||
LoadInfoHandler(); | |||||
} | |||||
private const string ParSetJsonFilePath = "DistributePlc.json"; | |||||
private const string RootJsonPath = "AccessFile\\"; | |||||
//开机启动 | |||||
public bool IsSelected | |||||
{ | |||||
get { return SystemHelper.GetInstance.IsAutoStart(); } | |||||
set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } | |||||
} | |||||
//下拉框绑定设备类型 | |||||
public ObservableCollection<string> ClientDevices { get; set; } | |||||
= new ObservableCollection<string>(); | |||||
//选中类型名称 | |||||
public string ClientDeviceType | |||||
{ | |||||
get { return _mClientDeviceType; } | |||||
set | |||||
{ | |||||
_mClientDeviceType = value; | |||||
OnPropertyChanged(); | |||||
} | |||||
} | |||||
private string _mClientDeviceType = string.Empty; | |||||
/******煮面口********/ | |||||
private bool _hideNoodleNo1 = false; | |||||
public bool HideNoodleNo1 | |||||
{ | |||||
get { return _hideNoodleNo1; } | |||||
set { _hideNoodleNo1 = value; OnPropertyChanged(); } | |||||
} | |||||
private bool _hideNoodleNo2 = false; | |||||
public bool HideNoodleNo2 | |||||
{ | |||||
get { return _hideNoodleNo2; } | |||||
set { _hideNoodleNo2 = value; OnPropertyChanged(); } | |||||
} | |||||
private bool _hideNoodleNo3 = false; | |||||
public bool HideNoodleNo3 | |||||
{ | |||||
get { return _hideNoodleNo3; } | |||||
set { _hideNoodleNo3 = value; OnPropertyChanged(); } | |||||
} | |||||
private bool _hideNoodleNo4 = false; | |||||
public bool HideNoodleNo4 | |||||
{ | |||||
get { return _hideNoodleNo4; } | |||||
set { _hideNoodleNo4 = value; OnPropertyChanged(); } | |||||
} | |||||
private bool _hideNoodleNo5 = false; | |||||
public bool HideNoodleNo5 | |||||
{ | |||||
get { return _hideNoodleNo5; } | |||||
set { _hideNoodleNo5 = value; OnPropertyChanged(); } | |||||
} | |||||
private bool _hideNoodleNo6 = false; | |||||
public bool HideNoodleNo6 | |||||
{ | |||||
get { return _hideNoodleNo6; } | |||||
set { _hideNoodleNo6 = value; OnPropertyChanged(); } | |||||
} | |||||
/******冷库转盘当前位置********/ | |||||
private int _currentTurnPosition = 1; | |||||
public int CurrentTurnPosition | |||||
{ | |||||
get { return _currentTurnPosition; } | |||||
set { _currentTurnPosition = value; OnPropertyChanged(); } | |||||
} | |||||
/******煮面口时间设定********/ | |||||
private int _noFirstMin = 0; | |||||
private int _noFirstSec = 0; | |||||
public int No1_Minute | |||||
{ | |||||
get { return _noFirstMin; } | |||||
set { _noFirstMin = value; OnPropertyChanged(); } | |||||
} | |||||
public int No1_Second | |||||
{ | |||||
get { return _noFirstSec; } | |||||
set { _noFirstSec = value; OnPropertyChanged(); } | |||||
} | |||||
private int _noSecondMin = 0; | |||||
private int _noSecondSec = 0; | |||||
public int No2_Minute | |||||
{ | |||||
get { return _noSecondMin; } | |||||
set { _noSecondMin = value; OnPropertyChanged(); } | |||||
} | |||||
public int No2_Second | |||||
{ | |||||
get { return _noSecondSec; } | |||||
set { _noSecondSec = value; OnPropertyChanged(); } | |||||
} | |||||
// | |||||
private int _noThirdMin = 0; | |||||
private int _noThirdSec = 0; | |||||
public int No3_Minute | |||||
{ | |||||
get { return _noThirdMin; } | |||||
set { _noThirdMin = value; OnPropertyChanged(); } | |||||
} | |||||
public int No3_Second | |||||
{ | |||||
get { return _noThirdSec; } | |||||
set { _noThirdSec = value; OnPropertyChanged(); } | |||||
} | |||||
private int _noForthMin = 0; | |||||
private int _noForthSec = 0; | |||||
public int No4_Minute | |||||
{ | |||||
get { return _noForthMin; } | |||||
set { _noForthMin = value; OnPropertyChanged(); } | |||||
} | |||||
public int No4_Second | |||||
{ | |||||
get { return _noForthSec; } | |||||
set { _noForthSec = value; OnPropertyChanged(); } | |||||
} | |||||
private int _noFifthMin = 0; | |||||
private int _noFifthSec = 0; | |||||
public int No5_Minute | |||||
{ | |||||
get { return _noFifthMin; } | |||||
set { _noFifthMin = value; OnPropertyChanged(); } | |||||
} | |||||
public int No5_Second | |||||
{ | |||||
get { return _noFifthSec; } | |||||
set { _noFifthSec = value; OnPropertyChanged(); } | |||||
} | |||||
private int _noSixthMin = 0; | |||||
private int _noSixthSec = 0; | |||||
public int No6_Minute | |||||
{ | |||||
get { return _noSixthMin; } | |||||
set { _noSixthMin = value; OnPropertyChanged(); } | |||||
} | |||||
public int No6_Second | |||||
{ | |||||
get { return _noSixthSec; } | |||||
set { _noSixthSec = value; OnPropertyChanged(); } | |||||
} | |||||
//保存输入命令 | |||||
public RelayCommand SaveInfoCommand { get; set; } | |||||
//保存界面输入功能 | |||||
private void SaveInfoHandler() | |||||
{ | |||||
DistributePlcPar distributePlcPar = GetDistributeParUserInput(); | |||||
Json<DistributePlcPar>.Data = distributePlcPar; | |||||
LocaPath.GetInstance.FilePath = RootJsonPath; | |||||
Json<DistributePlcPar>.Save(); | |||||
Trace.WriteLine($"{nameof(DistributePlcPar)},json文件已成功保存。"); | |||||
} | |||||
//载入界面数据 | |||||
private void LoadInfoHandler() | |||||
{ | |||||
LocaPath.GetInstance.FilePath = RootJsonPath; | |||||
Json<DistributePlcPar>.Read(); | |||||
DistributePlcPar data = Json<DistributePlcPar>.Data; | |||||
DistributePlcPar distributePlcPar = data; | |||||
if (distributePlcPar != null) | |||||
{ | |||||
this.HideNoodleNo1 = distributePlcPar.HideNoodleNo1; | |||||
this.HideNoodleNo2 = distributePlcPar.HideNoodleNo2; | |||||
this.HideNoodleNo3 = distributePlcPar.HideNoodleNo3; | |||||
this.HideNoodleNo4 = distributePlcPar.HideNoodleNo4; | |||||
this.HideNoodleNo5 = distributePlcPar.HideNoodleNo5; | |||||
this.HideNoodleNo6 = distributePlcPar.HideNoodleNo6; | |||||
this.CurrentTurnPosition = distributePlcPar.CurrentTurnPosition; | |||||
this.No1_Minute = distributePlcPar.No1_Minute; | |||||
this.No1_Second = distributePlcPar.No1_Second; | |||||
this.No2_Minute = distributePlcPar.No2_Minute; | |||||
this.No2_Second = distributePlcPar.No2_Second; | |||||
this.No3_Minute = distributePlcPar.No3_Minute; | |||||
this.No3_Second = distributePlcPar.No3_Second; | |||||
this.No4_Minute = distributePlcPar.No4_Minute; | |||||
this.No4_Second = distributePlcPar.No4_Second; | |||||
this.No5_Minute = distributePlcPar.No5_Minute; | |||||
this.No5_Second = distributePlcPar.No5_Second; | |||||
this.No6_Minute = distributePlcPar.No6_Minute; | |||||
this.No6_Second = distributePlcPar.No6_Second; | |||||
} | |||||
Trace.WriteLine($"已成功载入{nameof(DistributePlcPar)}json文件"); | |||||
return; | |||||
} | |||||
//获取界面用户输入 | |||||
private DistributePlcPar GetDistributeParUserInput() | |||||
{ | |||||
DistributePlcPar distributePlcPar = new DistributePlcPar() | |||||
{ | |||||
HideNoodleNo1 = this.HideNoodleNo1, | |||||
HideNoodleNo2 = this.HideNoodleNo2, | |||||
HideNoodleNo3 = this.HideNoodleNo3, | |||||
HideNoodleNo4 = this.HideNoodleNo4, | |||||
HideNoodleNo5 = this.HideNoodleNo5, | |||||
HideNoodleNo6 = this.HideNoodleNo6, | |||||
// | |||||
CurrentTurnPosition = this.CurrentTurnPosition, | |||||
// | |||||
No1_Minute = this.No1_Minute, | |||||
No1_Second = this.No1_Second, | |||||
No2_Minute = this.No2_Minute, | |||||
No2_Second = this.No2_Second, | |||||
No3_Minute = this.No3_Minute, | |||||
No3_Second = this.No3_Second, | |||||
No4_Minute = this.No4_Minute, | |||||
No4_Second = this.No4_Second, | |||||
No5_Minute = this.No5_Minute, | |||||
No5_Second = this.No5_Second, | |||||
No6_Minute = this.No6_Minute, | |||||
No6_Second = this.No6_Second, | |||||
}; | |||||
return distributePlcPar; | |||||
} | |||||
} | |||||
} |
@@ -16,6 +16,8 @@ using BPA.Message.Enum; | |||||
using System.Collections.Concurrent; | using System.Collections.Concurrent; | ||||
using HBLConsole.Factory; | using HBLConsole.Factory; | ||||
using System.Threading; | using System.Threading; | ||||
using HBLConsole.Business; | |||||
using HBLConsole.GVL; | |||||
namespace HBLConsole.ViewModel | namespace HBLConsole.ViewModel | ||||
{ | { | ||||
@@ -27,6 +29,15 @@ namespace HBLConsole.ViewModel | |||||
MessageLog.GetInstance.InfoNotify = new Action<string>((s) => | MessageLog.GetInstance.InfoNotify = new Action<string>((s) => | ||||
{ | { | ||||
LogMessage = MessageLog.GetInstance.LogInfo; | LogMessage = MessageLog.GetInstance.LogInfo; | ||||
IotReport.GetInstance.SendLogMessage(new BPA.Message.API请求.LogTable | |||||
{ | |||||
ClientId = InternetInfo.ClientId.ToString(), | |||||
LogTime = DateTime.Now, | |||||
LogType = "1", | |||||
LogMessage = s, | |||||
LogVla = "正常", | |||||
}); | |||||
}); | }); | ||||
} | } | ||||
@@ -107,7 +118,7 @@ namespace HBLConsole.ViewModel | |||||
private void Test() | private void Test() | ||||
{ | { | ||||
#if test | #if test | ||||
ThreadOperate.GetInstance.StartLong(new Action(() => | |||||
ThreadManage.GetInstance.StartLong(new Action(() => | |||||
{ | { | ||||
while (morkOrderPushes.Count > 0) | while (morkOrderPushes.Count > 0) | ||||
{ | { | ||||
@@ -188,7 +199,13 @@ namespace HBLConsole.ViewModel | |||||
break; | break; | ||||
case ORDER_STATUS.COMPLETED_TAKE: | case ORDER_STATUS.COMPLETED_TAKE: | ||||
var re = WaitTakeMeal.FirstOrDefault(p => p.OrderPush.SuborderId == orderStatusChange.SuborderId); | var re = WaitTakeMeal.FirstOrDefault(p => p.OrderPush.SuborderId == orderStatusChange.SuborderId); | ||||
if (re != null) WaitTakeMeal.Remove(re); | |||||
if (re != null) | |||||
{ | |||||
WaitTakeMeal.Remove(re); | |||||
//Json<MorkOrderPushPar>.Data.morkOrderPushes.Remove(re); | |||||
Json<KeepDataBase>.Data.orderLists.Remove(re); | |||||
} | |||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||