添加MQTT发送消息的功能

This commit is contained in:
2025-07-18 19:15:29 +08:00
parent 1c14fbd3d6
commit b26fcafee8
5 changed files with 215 additions and 158 deletions

View File

@@ -16,9 +16,13 @@ public partial class VariableMqtt : ObservableObject
public VariableMqtt(Variable variable, Mqtt mqtt)
{
Variable = variable;
Mqtt = mqtt;
MqttAlias = MqttAlias != String.Empty ? MqttAlias : variable.Name;
if (mqtt != null && variable != null)
{
Variable = variable;
Mqtt = mqtt;
MqttAlias = MqttAlias != String.Empty ? MqttAlias : variable.Name;
}
}
/// <summary>
@@ -49,6 +53,10 @@ public partial class VariableMqtt : ObservableObject
{
get
{
if (Variable!=null)
{
if (Variable.ProtocolType == ProtocolType.S7)
{
return Variable.S7Address;
@@ -57,7 +65,7 @@ public partial class VariableMqtt : ObservableObject
{
return Variable.OpcUaNodeId;
}
}
return string.Empty;
}
}