A:增加Float格式支持
This commit is contained in:
1 parent
de1a29c522
commit
ea6103a596
5 files changed
+20
-16
No files matched your search
@@ -73,7 +73,7 @@
|
||||
<GroupBox Header="实时监控 (Add Watch)" Grid.Row="2" Margin="0,0,0,15">
|
||||
<StackPanel Orientation="Horizontal" Margin="10">
|
||||
<TextBox hc:InfoElement.Placeholder="地址 (如 DB1.DBW0)" Text="{Binding MonitorAddress}" Width="200" Margin="0,0,10,0"/>
|
||||
<ComboBox ItemsSource="{Binding SupportedMonitorTypes}" SelectedItem="{Binding SelectedMonitorType}" Width="120" Margin="0,0,10,0" DisplayMemberPath="Name"/>
|
||||
<ComboBox ItemsSource="{Binding SupportedMonitorTypes}" SelectedValue="{Binding SelectedMonitorType}" SelectedValuePath="Type" DisplayMemberPath="Name" Width="120" Margin="0,0,10,0"/>
|
||||
<Button Content="添加监控" Command="{Binding AddMonitorCommand}"/>
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
@@ -83,7 +83,7 @@
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="100"/>
|
||||
<DataGridTextColumn Header="地址" Binding="{Binding Address}" Width="150"/>
|
||||
<DataGridTextColumn Header="类型" Binding="{Binding DataType.Name}" Width="80"/>
|
||||
<DataGridTextColumn Header="类型" Binding="{Binding DataTypeName}" Width="80"/>
|
||||
<DataGridTextColumn Header="当前值" Binding="{Binding Value}" Width="*"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
@@ -19,6 +19,8 @@ public class PlcTagViewModel : ViewModelBase
|
||||
|
||||
public Type DataType => _tag.DataType;
|
||||
|
||||
public string DataTypeName => _tag.DataType == typeof(float) ? "Float" : _tag.DataType.Name;
|
||||
|
||||
public object? Value => _tag.Value;
|
||||
|
||||
public PlcTag Tag => _tag;
|
||||
|
||||
@@ -127,19 +127,19 @@ public class PlcViewModel : ViewModelBase
|
||||
// 数据源
|
||||
public ObservableCollection<PlcBrand> Brands { get; } = new(Enum.GetValues<PlcBrand>());
|
||||
public ObservableCollection<CpuType> CpuTypes { get; } = new(Enum.GetValues<CpuType>());
|
||||
public ObservableCollection<Type> SupportedMonitorTypes { get; } = new()
|
||||
public ObservableCollection<DataTypeOption> SupportedMonitorTypes { get; } = new()
|
||||
{
|
||||
typeof(bool),
|
||||
typeof(byte),
|
||||
typeof(short),
|
||||
typeof(ushort),
|
||||
typeof(int),
|
||||
typeof(uint),
|
||||
typeof(long),
|
||||
typeof(ulong),
|
||||
typeof(float),
|
||||
typeof(double),
|
||||
typeof(string)
|
||||
new("Bool", typeof(bool)),
|
||||
new("Byte", typeof(byte)),
|
||||
new("Short (Int16)", typeof(short)),
|
||||
new("UShort (UInt16)", typeof(ushort)),
|
||||
new("Int (Int32)", typeof(int)),
|
||||
new("UInt (UInt32)", typeof(uint)),
|
||||
new("Long (Int64)", typeof(long)),
|
||||
new("ULong (UInt64)", typeof(ulong)),
|
||||
new("Float (Real)", typeof(float)),
|
||||
new("Double (LReal)", typeof(double)),
|
||||
new("String", typeof(string))
|
||||
};
|
||||
public ObservableCollection<PlcTagViewModel> MonitoredTags { get; } = new();
|
||||
|
||||
@@ -264,3 +264,5 @@ public class PlcViewModel : ViewModelBase
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public record DataTypeOption(string Name, Type Type);
|
||||
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Client")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bc09280d4ea03ae8d0db7cd8c25ddd02d63abd84")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+de1a29c522c231e011e0b795cb1494b1dd7282bf")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Client")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Client")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
8b7343fa73644682ba621a0a8c61df82ebb0d6cdd1d8d63cf26b3522a08f12ee
|
||||
b775c782e822e9da489917907ac5dc67ababf8e2b94747f6176fcf3d21ac9454
|
||||
Reference in new issue
Block a user