优化内部mqtt消息

This commit is contained in:
dd 2022-01-25 22:39:59 +08:00
parent 47f869924e
commit 936b5c67f5
5 changed files with 13 additions and 3 deletions

View File

@ -125,7 +125,12 @@
"ProjectGuid": "8e2d91dc-dee4-4843-8d09-6fc06651527e",
"DisplayName": "DriverModbusMaster",
"ColorIndex": 7
},
"7752ad8c-04bf-4bd2-9272-cda4f78fa954": {
"ProjectGuid": "7752ad8c-04bf-4bd2-9272-cda4f78fa954",
"DisplayName": "PluginInterface",
"ColorIndex": 8
}
},
"NextColorIndex": 8
"NextColorIndex": 9
}

Binary file not shown.

View File

@ -104,14 +104,19 @@ namespace Plugin
//变化了才推送到mqttserver用于前端展示
if (DeviceValues[item.ID].StatusType != ret.StatusType || DeviceValues[item.ID].Value?.ToString() != ret.Value?.ToString() || DeviceValues[item.ID].CookedValue?.ToString() != ret.CookedValue?.ToString())
{
//这是设备变量列表要用的
mqttServer.PublishAsync($"internal/v1/gateway/telemetry/{Device.DeviceName}/{item.Name}", JsonConvert.SerializeObject(ret));
//这是在线组态要用的
mqttServer.PublishAsync($"v1/gateway/telemetry/{Device.DeviceName}/{item.Name}", JsonConvert.SerializeObject(ret.CookedValue));
}
DeviceValues[item.ID] = ret;
}
payLoad.TS = (long)(DateTime.Now - TsStartDt).TotalMilliseconds;
if (DeviceValues.Any(x => x.Value.StatusType != VaribaleStatusTypeEnum.Good))
if (DeviceValues.Any(x => x.Value.Value ==null))
{
payLoad.Values = null;
payLoad.DeviceStatus = DeviceStatusTypeEnum.Bad;

View File

@ -14,7 +14,7 @@ namespace PluginInterface
public object CookedValue { get; set; }
public string Message { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public VaribaleStatusTypeEnum StatusType { get; set; }
public VaribaleStatusTypeEnum StatusType { get; set; } = VaribaleStatusTypeEnum.UnKnow;
public Guid VarId { get; set; }
}
}