|
@@ -77,6 +77,58 @@ namespace HBLConsole.Business |
|
|
IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic,jsonstr); |
|
|
IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic,jsonstr); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 上报属性状态 |
|
|
|
|
|
/// 调用示例:SendTargetMessage(); |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
/// <param name="json"></param> |
|
|
|
|
|
public void SendTargetMessage() |
|
|
|
|
|
{ |
|
|
|
|
|
if (IOTDevServer.client != null && IOTDevServer.client.IsConnected) |
|
|
|
|
|
{ |
|
|
|
|
|
string kzsx = string.Empty; |
|
|
|
|
|
string jbsx = Tools.JsonConvertTools<DevSX>(new DevSX |
|
|
|
|
|
{ |
|
|
|
|
|
data = new List<DevSXBase> |
|
|
|
|
|
{ |
|
|
|
|
|
new DevSXBase { SXMC="设备硬件",SXLX="机器人",SXStatus=ModbusTcpHelper.GetInstance.Connected |
|
|
|
|
|
,SXYCMS=ModbusTcpHelper.GetInstance.Connected?"":DateTime.Now+" 异常,机器人未连接,疑似未连接网络...."}, |
|
|
|
|
|
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) |
|
|
|
|
|
{ |
|
|
|
|
|
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+" 异常,配料机未配完料,疑似碗未到配料机下方或者配料机未工作...."} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
string jsonstr = Tools.JsonConvertTools<IotModel<TargetIOT>>(new IotModel<TargetIOT> { @params = new TargetIOT { JBSX = jbsx,KZSX = kzsx } }); |
|
|
|
|
|
IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic,jsonstr); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
#endregion |
|
|
#endregion |
|
|
|
|
|
|
|
|
#region 外部关闭或初始化IOT调用 |
|
|
#region 外部关闭或初始化IOT调用 |
|
@@ -125,64 +177,6 @@ namespace HBLConsole.Business |
|
|
} |
|
|
} |
|
|
#endregion |
|
|
#endregion |
|
|
|
|
|
|
|
|
#region 废弃代码 |
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 设置上报基本与扩展数据 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
public void SetData() |
|
|
|
|
|
{ |
|
|
|
|
|
#region 基本数据 |
|
|
|
|
|
//设置基本属性与状态 |
|
|
|
|
|
iOTDevSXModel.SetJBSX(new DevSX |
|
|
|
|
|
{ |
|
|
|
|
|
data = new List<DevSXBase> |
|
|
|
|
|
{ |
|
|
|
|
|
new DevSXBase { SXMC="设备硬件",SXLX="机器人",SXStatus=ModbusTcpHelper.GetInstance.Connected |
|
|
|
|
|
,SXYCMS=ModbusTcpHelper.GetInstance.Connected?"":DateTime.Now+" 异常,机器人未连接,疑似未连接网络...."}, |
|
|
|
|
|
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 |
|
|
|
|
|
{ |
|
|
|
|
|
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+" 异常,配料机未配完料,疑似碗未到配料机下方或者配料机未工作...."} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
iOTDevSXModel.SetKZSX(new DevSX { data = new List<DevSXBase> { new DevSXBase { SXMC = "",SXLX = "" } } }); |
|
|
|
|
|
} |
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.PubTopic,iOTDevSXModel.Tojson()); |
|
|
|
|
|
} |
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
#region 私有函数 |
|
|
#region 私有函数 |
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// 获取属性状态 |
|
|
/// 获取属性状态 |
|
@@ -215,4 +209,18 @@ namespace HBLConsole.Business |
|
|
{ |
|
|
{ |
|
|
public string NodeStatus { get; set; } |
|
|
public string NodeStatus { get; set; } |
|
|
} |
|
|
} |
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 基本属性与扩展属性 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
public class TargetIOT |
|
|
|
|
|
{ |
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 基本属性 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
public string JBSX { get; set; } |
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 扩展属性 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
public string KZSX { get; set; } |
|
|
|
|
|
} |
|
|
} |
|
|
} |