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">
|
<GroupBox Header="实时监控 (Add Watch)" Grid.Row="2" Margin="0,0,0,15">
|
||||||
<StackPanel Orientation="Horizontal" Margin="10">
|
<StackPanel Orientation="Horizontal" Margin="10">
|
||||||
<TextBox hc:InfoElement.Placeholder="地址 (如 DB1.DBW0)" Text="{Binding MonitorAddress}" Width="200" Margin="0,0,10,0"/>
|
<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}"/>
|
<Button Content="添加监控" Command="{Binding AddMonitorCommand}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="100"/>
|
<DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="100"/>
|
||||||
<DataGridTextColumn Header="地址" Binding="{Binding Address}" Width="150"/>
|
<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="*"/>
|
<DataGridTextColumn Header="当前值" Binding="{Binding Value}" Width="*"/>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ public class PlcTagViewModel : ViewModelBase
|
|||||||
|
|
||||||
public Type DataType => _tag.DataType;
|
public Type DataType => _tag.DataType;
|
||||||
|
|
||||||
|
public string DataTypeName => _tag.DataType == typeof(float) ? "Float" : _tag.DataType.Name;
|
||||||
|
|
||||||
public object? Value => _tag.Value;
|
public object? Value => _tag.Value;
|
||||||
|
|
||||||
public PlcTag Tag => _tag;
|
public PlcTag Tag => _tag;
|
||||||
|
|||||||
@@ -127,19 +127,19 @@ public class PlcViewModel : ViewModelBase
|
|||||||
// 数据源
|
// 数据源
|
||||||
public ObservableCollection<PlcBrand> Brands { get; } = new(Enum.GetValues<PlcBrand>());
|
public ObservableCollection<PlcBrand> Brands { get; } = new(Enum.GetValues<PlcBrand>());
|
||||||
public ObservableCollection<CpuType> CpuTypes { get; } = new(Enum.GetValues<CpuType>());
|
public ObservableCollection<CpuType> CpuTypes { get; } = new(Enum.GetValues<CpuType>());
|
||||||
public ObservableCollection<Type> SupportedMonitorTypes { get; } = new()
|
public ObservableCollection<DataTypeOption> SupportedMonitorTypes { get; } = new()
|
||||||
{
|
{
|
||||||
typeof(bool),
|
new("Bool", typeof(bool)),
|
||||||
typeof(byte),
|
new("Byte", typeof(byte)),
|
||||||
typeof(short),
|
new("Short (Int16)", typeof(short)),
|
||||||
typeof(ushort),
|
new("UShort (UInt16)", typeof(ushort)),
|
||||||
typeof(int),
|
new("Int (Int32)", typeof(int)),
|
||||||
typeof(uint),
|
new("UInt (UInt32)", typeof(uint)),
|
||||||
typeof(long),
|
new("Long (Int64)", typeof(long)),
|
||||||
typeof(ulong),
|
new("ULong (UInt64)", typeof(ulong)),
|
||||||
typeof(float),
|
new("Float (Real)", typeof(float)),
|
||||||
typeof(double),
|
new("Double (LReal)", typeof(double)),
|
||||||
typeof(string)
|
new("String", typeof(string))
|
||||||
};
|
};
|
||||||
public ObservableCollection<PlcTagViewModel> MonitoredTags { get; } = new();
|
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.AssemblyCompanyAttribute("Client")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[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.AssemblyProductAttribute("Client")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("Client")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("Client")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
8b7343fa73644682ba621a0a8c61df82ebb0d6cdd1d8d63cf26b3522a08f12ee
|
b775c782e822e9da489917907ac5dc67ababf8e2b94747f6176fcf3d21ac9454
|
||||||
Reference in new issue
Block a user