基本完成MQTT消息的发送
This commit is contained in:
@@ -22,5 +22,8 @@ public class MqttServerDto
|
||||
public DateTime? ConnectedAt { get; set; }
|
||||
public long ConnectionDuration { get; set; }
|
||||
public string MessageFormat { get; set; }
|
||||
public string MessageHeader { get; set; }
|
||||
public string MessageContent { get; set; }
|
||||
public string MessageFooter { get; set; }
|
||||
public List<VariableMqttAliasDto> VariableAliases { get; set; } = new();
|
||||
}
|
||||
@@ -34,18 +34,12 @@ public class MqttPublishProcessor : IVariableProcessor
|
||||
}
|
||||
|
||||
// 遍历所有关联的MQTT配置,并将其推入发送队列
|
||||
foreach (var variableMqttAlias in variable.MqttAliases)
|
||||
foreach (var variableMqttAliasDto in variable.MqttAliases)
|
||||
{
|
||||
// 创建VariableMqtt对象
|
||||
var variableMqtt = new VariableMqtt
|
||||
{
|
||||
Variable = _mapper.Map<Variable>(variable),
|
||||
Mqtt = variableMqttAlias.MqttServer,
|
||||
MqttId = variableMqttAlias.MqttServerId
|
||||
};
|
||||
|
||||
// 发布变量数据到MQTT服务器
|
||||
await _mqttServiceManager.PublishVariableDataAsync(variableMqtt);
|
||||
var variableMqttAlias = _mapper.Map<VariableMqttAlias>(variableMqttAliasDto);
|
||||
variableMqttAlias.Variable.DataValue=variable.DataValue;
|
||||
await _mqttServiceManager.PublishVariableDataAsync(variableMqttAlias);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user