基本完成MQTT消息的发送

This commit is contained in:
2025-09-10 18:15:31 +08:00
parent a9ca89b44a
commit a43b978097
13 changed files with 127 additions and 23 deletions

View File

@@ -18,6 +18,7 @@ namespace DMS.WPF.Profiles
.ReverseMap();
CreateMap<VariableItemViewModel, VariableItemViewModel>();
CreateMap<VariableMqttAliasDto, VariableMqttAliasItemViewModel>().ReverseMap();
CreateMap<VariableMqttAlias, VariableMqttAliasItemViewModel>().ReverseMap();
CreateMap<MenuBeanDto, MenuItemViewModel>()

View File

@@ -37,7 +37,10 @@ public partial class MqttDialogViewModel : DialogViewModelBase<MqttServerItemVie
CreatedAt = mqttServer.CreatedAt,
ConnectedAt = mqttServer.ConnectedAt,
ConnectionDuration = mqttServer.ConnectionDuration,
MessageFormat = mqttServer.MessageFormat
MessageFormat = mqttServer.MessageFormat,
MessageHeader = mqttServer.MessageHeader,
MessageContent = mqttServer.MessageContent,
MessageFooter = mqttServer.MessageFooter
};
}

View File

@@ -52,6 +52,15 @@ public partial class MqttServerItemViewModel : ObservableObject
[ObservableProperty]
private string _messageFormat;
[ObservableProperty]
private string _messageHeader;
[ObservableProperty]
private string _messageContent;
[ObservableProperty]
private string _messageFooter;
[ObservableProperty]
private ObservableCollection<VariableMqttAliasItemViewModel> _variableAliases = new();

View File

@@ -44,6 +44,9 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Row 0 -->
@@ -102,10 +105,46 @@
Margin="0,15,0,0"
hc:InfoElement.Title="订阅主题:"
Text="{Binding MqttServer.SubscribeTopic, UpdateSourceTrigger=PropertyChanged}" />
<!-- Row 5 -->
<hc:TextBox
Grid.Row="4"
Grid.Column="0"
Grid.ColumnSpan="3"
Margin="0,15,0,0"
hc:InfoElement.Title="消息头:"
Text="{Binding MqttServer.MessageHeader, UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap"
AcceptsReturn="True"
VerticalContentAlignment="Top" />
<hc:TextBox
Grid.Row="5"
Grid.Column="0"
Grid.ColumnSpan="3"
Margin="0,15,0,0"
hc:InfoElement.Title="消息内容:"
Text="{Binding MqttServer.MessageContent, UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap"
AcceptsReturn="True"
VerticalContentAlignment="Top" />
<!-- Row 6 -->
<hc:TextBox
Grid.Row="6"
Grid.Column="0"
Grid.ColumnSpan="3"
Margin="0,15,0,0"
hc:InfoElement.Title="消息尾:"
Text="{Binding MqttServer.MessageFooter, UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap"
AcceptsReturn="True"
VerticalContentAlignment="Top" />
<!-- Row 4 -->
<CheckBox
Grid.Row="4"
Grid.Row="7"
Grid.Column="0"
Margin="0,20,0,0"
Content="是否启用"

View File

@@ -69,6 +69,15 @@
<!-- ItemsSource="{Binding Source={extensions:EnumBindingSourceExtension {x:Type enums:MqttPlatform}}}" -->
<!-- DisplayMemberPath="Description" -->
<!-- SelectedValuePath="Value"/> -->
<TextBlock Grid.Row="5" Grid.Column="0" Text="消息头:" Margin="0,0,5,0" VerticalAlignment="Center"/>
<TextBox Grid.Row="5" Grid.Column="1" Text="{Binding CurrentMqtt.MessageHeader, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,10,0"/>
<TextBlock Grid.Row="5" Grid.Column="2" Text="消息内容:" Margin="0,0,5,0" VerticalAlignment="Center"/>
<TextBox Grid.Row="5" Grid.Column="3" Text="{Binding CurrentMqtt.MessageContent, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Grid.Row="6" Grid.Column="0" Text="消息尾:" Margin="0,0,5,0" VerticalAlignment="Center"/>
<TextBox Grid.Row="6" Grid.Column="1" Text="{Binding CurrentMqtt.MessageFooter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,10,0"/>
</Grid>
<Button Content="保存更改" Command="{Binding SaveChangesCommand}" HorizontalAlignment="Right" Margin="0,10,0,0"/>
</StackPanel>