From 0285b1707cf7ee90cdc48541d7f588e781923a85 Mon Sep 17 00:00:00 2001 From: fyf Date: Fri, 18 Mar 2022 16:18:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HBLConsole.Business/IotReport.cs | 80 +++++++++++++++++++++---------- HBLConsole.MORKS/Control_MORKS.cs | 2 + HBLConsole.MORKS/GVL_MORKS.cs | 4 ++ 3 files changed, 60 insertions(+), 26 deletions(-) diff --git a/HBLConsole.Business/IotReport.cs b/HBLConsole.Business/IotReport.cs index da42812..d4f21c2 100644 --- a/HBLConsole.Business/IotReport.cs +++ b/HBLConsole.Business/IotReport.cs @@ -15,22 +15,22 @@ namespace HBLConsole.Business { public class IotReport { + #region 单例模式 private volatile static IotReport _Instance; public static IotReport GetInstance => _Instance ?? (_Instance = new IotReport()); private IotReport() { - iOTDevSXModel = new IOTDevSXModel(); - iOTDevSXModel.SBMC = InternetInfo.DeviceName; - iOTDevSXModel.SBMS = InternetInfo.DeviceMS; - iOTDevSXModel.SetKZSX(new DevSX { data = new List { new DevSXBase { SXMC = "", SXLX = "" } } }); IOTDev.GetInstance().Set(InternetInfo.ProductKey, InternetInfo.DeviceName, InternetInfo.DeviceSecret); iSLinks = IOTDev.GetInstance().CreateLinks(); if (iSLinks) MessageLog.GetInstance.Show($"设备{InternetInfo.DeviceName}阿里云连接成功."); else MessageLog.GetInstance.Show($"设备{InternetInfo.DeviceName}阿里云连接失败.不能上报业务信息"); - string NameSpace = $"HBLConsole.{GeneralConfig.DeviceType}";//Load 加载的是dll的名称,GetType获取的是全命名空间下的类 - Type type = Assembly.Load(NameSpace).GetType($"{NameSpace}.Control_{GeneralConfig.DeviceType}"); - control = (IControl)type?.GetProperty("Instance").GetValue(null); + + string NameSpace = $"HBLConsole.{GeneralConfig.DeviceType}"; + control = (IControl)(Assembly.Load(NameSpace).GetType($"{NameSpace}.Control_{GeneralConfig.DeviceType}"))?.GetProperty("Instance").GetValue(null); } + #endregion + + #region 变量 /// /// 是否连接成功 /// @@ -38,25 +38,36 @@ namespace HBLConsole.Business /// /// 大屏上报Model /// - public IOTDevSXModel iOTDevSXModel = new IOTDevSXModel(); + public IOTDevSXModel iOTDevSXModel = new IOTDevSXModel() { SBMC = InternetInfo.DeviceName, SBMS = InternetInfo.DeviceMS }; /// - /// + /// 当前控制的设备控件 /// - IControl control; + public IControl control; + + #endregion + /// + /// 关闭IOT连接 + /// public void Close() { IOTDev.GetInstance().Disconnect(); } - + /// + /// 获取属性状态 + /// public T GetTypeValue(string str) { return (T)control.GetT().GetType().GetProperty(str).GetValue(control.GetT(), null); } + /// + /// 设置上报数据 + /// public void SetData() { - #region 上报 + #region 上报数据整理 + #region 基本数据 //设置基本属性与状态 iOTDevSXModel.SetJBSX(new DevSX { @@ -67,35 +78,50 @@ namespace HBLConsole.Business new DevSXBase { SXMC="设备软件",SXLX="上位机",SXStatus=true } } }); - + #endregion + + #region 扩展数据 bool IsAllowRun = GetTypeValue("AllowRun"); bool TemperatureReached = GetTypeValue("TemperatureReached"); bool MissingBowl = GetTypeValue("MissingBowl"); - bool TurntableLowerLimit = GetTypeValue("TurntableLowerLimit"); - + bool MissingBowlSignal2 = GetTypeValue("MissingBowlSignal2"); + bool IsNoodles = GetTypeValue("IsNoodles");//转台 + bool AllowFallNoodle = GetTypeValue("AllowFallNoodle");//是否允许到面 + bool[] CookNoodlesComplete = GetTypeValue("CookNoodlesComplete");//煮面完成上升信号 + bool isCookNoodles= CookNoodlesComplete.ToList().Find(o=>o); //设置扩展属性与状态,连接上机器人后才会处罚 - if (GeneralConfig.Healthy) + if (IsAllowRun) { iOTDevSXModel.SetKZSX(new DevSX { data = new List { - 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=TurntableLowerLimit , - SXYCMS=TurntableLowerLimit?"":DateTime.Now+" 异常,转台缺面...."} + 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 { new DevSXBase { SXMC = "", SXLX = "" } } }); + } + #endregion //设置告警消息 + #region 告警消息 List bases = Tools.JsonToObjectTools(iOTDevSXModel.JBSX)?.data?.ToList().FindAll(par => par.SXStatus == false); if (bases != null) bases.AddRange(Tools.JsonToObjectTools(iOTDevSXModel.KZSX)?.data?.ToList().FindAll(par => par.SXStatus == false)); List alarms = new List(); 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 bool InitComplete = GetTypeValue("InitComplete"); bool RobotTakeNoodle = GetTypeValue("RobotTakeNoodle"); @@ -104,16 +130,19 @@ namespace HBLConsole.Business { data = new List { - new ProcessModel { ProcessName="开机",IsMark=!IsAllowRun }, - new ProcessModel { ProcessName="初始化",IsMark=!InitComplete }, + 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=RobotOutMeal,ProcessMS=RobotOutMeal?"机器人正在出餐过程中....":"" } + new ProcessModel { ProcessName="出餐",IsMark=AllowFallNoodle,ProcessMS=AllowFallNoodle?"机器人正在出餐过程中....":"" } } }); #endregion } + /// + /// 初始化上报流程 + /// public void Init() { ThreadOperate.GetInstance.StartLong(new Action(() => @@ -125,7 +154,6 @@ namespace HBLConsole.Business } Thread.Sleep(5000); }), "设备IOT上报云端"); - } } } diff --git a/HBLConsole.MORKS/Control_MORKS.cs b/HBLConsole.MORKS/Control_MORKS.cs index 4b963bc..9c375c1 100644 --- a/HBLConsole.MORKS/Control_MORKS.cs +++ b/HBLConsole.MORKS/Control_MORKS.cs @@ -302,6 +302,7 @@ namespace HBLConsole.MORKS mORKS.AllowTakeNoodle = true; TurntableLoc.Clear(); MessageLog.GetInstance.Show("转台位置OK"); + mORKS.IsNoodles = true; } else { @@ -324,6 +325,7 @@ namespace HBLConsole.MORKS } } } + mORKS.IsNoodles = false; MessageLog.GetInstance.Show("转台位置缺少物料"); } } diff --git a/HBLConsole.MORKS/GVL_MORKS.cs b/HBLConsole.MORKS/GVL_MORKS.cs index 583f86e..400553e 100644 --- a/HBLConsole.MORKS/GVL_MORKS.cs +++ b/HBLConsole.MORKS/GVL_MORKS.cs @@ -248,5 +248,9 @@ namespace HBLConsole.MORKS [Circuit("取碗控制", "有取碗队列数量")] public ConcurrentQueue TakeBowlTask { get; set; } = new ConcurrentQueue(); + /// + /// 是否有面条 + /// + public bool IsNoodles { get; set; } = true; } } From f25b8c6815d1c0080638597dc1092f78e3596185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8E=9F=E5=B7=9D=20=E5=BC=A0?= Date: Fri, 18 Mar 2022 16:56:29 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B0=83=E8=AF=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HBLConsole.Communication/LebaiHelper.cs | 8 ++++++++ HBLConsole.MORKIC/Control_MORKIC.cs | 4 ++-- HBLDevice.Coffee/CoffeeMachine.cs | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/HBLConsole.Communication/LebaiHelper.cs b/HBLConsole.Communication/LebaiHelper.cs index e99c982..017221d 100644 --- a/HBLConsole.Communication/LebaiHelper.cs +++ b/HBLConsole.Communication/LebaiHelper.cs @@ -40,10 +40,18 @@ namespace HBLConsole.Communication } } MessageLog.GetInstance.Show("乐百机器人连接成功!"); + GetSpeed(); //ActionOperate.GetInstance.Send($"{GVL.GeneralConfig.DeviceType.ToString()}/ConnectOk"); } + public void GetSpeed() + { + //client.StartSys().GetAwaiter(); + var aa = client.GetActualTcpSpeed().GetAwaiter(); + } + + /// /// 获取信号量 /// diff --git a/HBLConsole.MORKIC/Control_MORKIC.cs b/HBLConsole.MORKIC/Control_MORKIC.cs index faac7bb..f4afc42 100644 --- a/HBLConsole.MORKIC/Control_MORKIC.cs +++ b/HBLConsole.MORKIC/Control_MORKIC.cs @@ -60,7 +60,7 @@ namespace HBLConsole.MORKIC /// /// 获取乐百机器人的数据 /// - SignalResult lebai; + SignalResult lebai=new SignalResult(); public void ConnectOk() { @@ -263,7 +263,7 @@ namespace HBLConsole.MORKIC { ThreadOperate.GetInstance.StartLong(new Action(() => { - //lebai = LebaiHelper.GetInstance.GetValueAsync(); + lebai = LebaiHelper.GetInstance.GetValueAsync(); Thread.Sleep(100); }), "乐百机器人数据读取"); } diff --git a/HBLDevice.Coffee/CoffeeMachine.cs b/HBLDevice.Coffee/CoffeeMachine.cs index 635f218..bfabd42 100644 --- a/HBLDevice.Coffee/CoffeeMachine.cs +++ b/HBLDevice.Coffee/CoffeeMachine.cs @@ -14,7 +14,7 @@ namespace HBLDevice.Coffee /// /// 咖啡机 /// - public class CoffeeMachine + public class CoffeeMachine { //通讯代理 SerialPortClient commProxy = null; @@ -224,6 +224,6 @@ namespace HBLDevice.Coffee //}, "咖啡机解析线程"); } - + } }