applelon 2 лет назад
Родитель
Сommit
3be8bdcdf6
3 измененных файлов: 49 добавлений и 34 удалений
  1. +1
    -1
      HBLConsole.Business/HeartbeatReport.cs
  2. +40
    -25
      HBLConsole.Business/IotReport.cs
  3. +8
    -8
      HBLConsole/ViewModel/ViewModelBase.cs

+ 1
- 1
HBLConsole.Business/HeartbeatReport.cs Просмотреть файл

@@ -46,7 +46,7 @@ namespace HBLConsole.Business
MessagePackage.Timestamp = DateTime.Now;
MessagePackage.Message = deviceStatus;//GetMessage == null ? deviceStatus : GetMessage();
MqttHelper.GetInstance.MqttPublishAsync(Topic, MessagePackage.Serialize());
IotReport.GetInstance.SendTargetMessage();
//IotReport.GetInstance.SendTargetMessage();
Thread.Sleep(1000);
}), "设备心跳上报", true);



+ 40
- 25
HBLConsole.Business/IotReport.cs Просмотреть файл

@@ -99,33 +99,48 @@ namespace HBLConsole.Business
new DevSXBase { SXMC="设备软件",SXLX="上位机",SXStatus=true }
}
});
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)
switch (GeneralConfig.DeviceType)
{
kzsx = Tools.JsonConvertTools<DevSX>(new DevSX
{
data = new List<DevSXBase>
case BPA.Message.Enum.DeviceClientType.MORKD:
break;
case BPA.Message.Enum.DeviceClientType.MORKS:
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)
{
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+" 异常,配料机未配完料,疑似碗未到配料机下方或者配料机未工作...."}
kzsx = Tools.JsonConvertTools<DevSX>(new DevSX
{
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+" 异常,配料机未配完料,疑似碗未到配料机下方或者配料机未工作...."}
}
});
}
});
break;
case BPA.Message.Enum.DeviceClientType.MORKI:
break;
case BPA.Message.Enum.DeviceClientType.MORKC:
break;
case BPA.Message.Enum.DeviceClientType.MORKIC:
break;
default:
break;
}
string jsonstr = Tools.JsonConvertTools<IotModel<TargetIOT>>(new IotModel<TargetIOT> { @params = new TargetIOT { JBSX = jbsx,KZSX = kzsx } });
IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic,jsonstr);
@@ -185,7 +200,7 @@ namespace HBLConsole.Business
/// </summary>
private T GetTypeValue<T>(string str)
{
return (T)SimpleFactory.GetInstance.GVL?.GetType().GetProperty(str).GetValue(SimpleFactory.GetInstance.GVL,null);
return (T)SimpleFactory.GetInstance.GVL?.GetType().GetProperty(str)?.GetValue(SimpleFactory.GetInstance.GVL,null);
}
#endregion
}


+ 8
- 8
HBLConsole/ViewModel/ViewModelBase.cs Просмотреть файл

@@ -30,14 +30,14 @@ namespace HBLConsole.ViewModel
{
LogMessage = MessageLog.GetInstance.LogInfo;

IotReport.GetInstance.SendLogMessage(new BPA.Message.API请求.LogTable
{
ClientId = InternetInfo.ClientId.ToString(),
LogTime = DateTime.Now,
LogType = "1",
LogMessage = s,
LogVla = "正常",
});
//IotReport.GetInstance.SendLogMessage(new BPA.Message.API请求.LogTable
//{
// ClientId = InternetInfo.ClientId.ToString(),
// LogTime = DateTime.Now,
// LogType = "1",
// LogMessage = s,
// LogVla = "正常",
//});
});
}



Загрузка…
Отмена
Сохранить