mirror of
https://github.com/OpenLogics/MewtocolNet.git
synced 2025-12-06 03:01:24 +00:00
- fix missing build methods for array registers - add reconnect injection task - add slim semaphore for async message single thread handling
351 lines
15 KiB
XML
351 lines
15 KiB
XML
<UserControl x:Class="Examples.WPF.Views.PlcDataView"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:vm="clr-namespace:Examples.WPF.ViewModels"
|
|
xmlns:local="clr-namespace:Examples.WPF.Views"
|
|
mc:Ignorable="d"
|
|
d:DataContext="{d:DesignInstance vm:PlcDataViewViewModel, IsDesignTimeCreatable=True}"
|
|
d:DesignHeight="450"
|
|
d:DesignWidth="800">
|
|
<Grid>
|
|
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="auto"/>
|
|
<RowDefinition Height="auto"/>
|
|
<RowDefinition/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<Menu>
|
|
<MenuItem Header="PLC">
|
|
<MenuItem Header="Disconnect" IsEnabled="{Binding Plc.IsConnected}"
|
|
Click="ClickedDisconnect"/>
|
|
<MenuItem Header="Connect" IsEnabled="{Binding Plc.IsConnected, Converter={StaticResource bInv}}"
|
|
Click="ClickedConnect"/>
|
|
<MenuItem Header="Set Random DT1000" IsEnabled="{Binding Plc.IsConnected}"
|
|
Click="ClickedSetRandom"/>
|
|
<MenuItem Header="Queue test" IsEnabled="{Binding Plc.IsConnected}"
|
|
Click="ClickedAddQueueTest"/>
|
|
<MenuItem Header="Toggle OP mode" IsEnabled="{Binding Plc.IsConnected}"
|
|
Click="ClickedToggleRunMode"/>
|
|
</MenuItem>
|
|
</Menu>
|
|
|
|
<StackPanel Margin="10"
|
|
Grid.Row="1">
|
|
|
|
<TextBlock IsEnabled="{Binding Plc.IsConnected}">
|
|
|
|
<Run Text="{Binding Plc.PlcInfo.TypeName, Mode=OneWay}"
|
|
FontSize="24"
|
|
BaselineAlignment="Center"
|
|
FontWeight="SemiBold"/>
|
|
|
|
<Run Text="{Binding Plc.PlcInfo.CpuVersion, StringFormat='v{0}', Mode=OneWay}"
|
|
FontSize="24"
|
|
FontWeight="Light"/>
|
|
|
|
<Ellipse Width="10"
|
|
Height="10"
|
|
Fill="Lime"
|
|
IsEnabled="{Binding Plc.IsConnected}"/>
|
|
|
|
<Run>
|
|
<Run.Style>
|
|
<Style TargetType="Run">
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding Plc.IsRunMode, Mode=OneWay}" Value="True">
|
|
<Setter Property="Text" Value="RUN MODE"/>
|
|
</DataTrigger>
|
|
<DataTrigger Binding="{Binding Plc.IsRunMode, Mode=OneWay}" Value="False">
|
|
<Setter Property="Text" Value="NO RUN MODE"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</Run.Style>
|
|
</Run>
|
|
|
|
<TextBlock.Style>
|
|
<Style TargetType="TextBlock">
|
|
<Style.Triggers>
|
|
<Trigger Property="IsEnabled" Value="False">
|
|
<Setter Property="Visibility" Value="Collapsed"/>
|
|
</Trigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</TextBlock.Style>
|
|
|
|
</TextBlock>
|
|
|
|
<TextBlock IsEnabled="{Binding Plc.IsConnected, Converter={StaticResource bInv}}">
|
|
|
|
<Run Text="Disconnected"
|
|
FontSize="24"
|
|
BaselineAlignment="Center"
|
|
FontWeight="SemiBold"/>
|
|
|
|
<Ellipse Width="10"
|
|
Height="10"
|
|
Fill="Red"
|
|
IsEnabled="{Binding Plc.IsConnected}"/>
|
|
|
|
<TextBlock.Style>
|
|
<Style TargetType="TextBlock">
|
|
<Style.Triggers>
|
|
<Trigger Property="IsEnabled" Value="False">
|
|
<Setter Property="Visibility" Value="Collapsed"/>
|
|
</Trigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</TextBlock.Style>
|
|
|
|
</TextBlock>
|
|
|
|
<TextBlock Text="{Binding Plc.PlcInfo.TypeCode, StringFormat='#{0:X}', Mode=OneWay}"
|
|
FontSize="18"/>
|
|
|
|
<ItemsControl ItemsSource="{Binding Plc.PlcInfo.OperationModeTags, Mode=OneWay}">
|
|
<ItemsControl.ItemsPanel>
|
|
<ItemsPanelTemplate>
|
|
<StackPanel Orientation="Horizontal"/>
|
|
</ItemsPanelTemplate>
|
|
</ItemsControl.ItemsPanel>
|
|
<ItemsControl.ItemTemplate>
|
|
<DataTemplate>
|
|
<Border Background="LightGray"
|
|
CornerRadius="5"
|
|
Margin="2"
|
|
Padding="5">
|
|
<TextBlock Text="{Binding}"/>
|
|
</Border>
|
|
</DataTemplate>
|
|
</ItemsControl.ItemTemplate>
|
|
</ItemsControl>
|
|
|
|
<ItemsControl ItemsSource="{Binding Plc.PlcInfo.HardwareInformationTags, Mode=OneWay}">
|
|
<ItemsControl.ItemsPanel>
|
|
<ItemsPanelTemplate>
|
|
<StackPanel Orientation="Horizontal"/>
|
|
</ItemsPanelTemplate>
|
|
</ItemsControl.ItemsPanel>
|
|
<ItemsControl.ItemTemplate>
|
|
<DataTemplate>
|
|
<Border Background="LightGray"
|
|
CornerRadius="5"
|
|
Margin="2"
|
|
Padding="5">
|
|
<TextBlock Text="{Binding}"/>
|
|
</Border>
|
|
</DataTemplate>
|
|
</ItemsControl.ItemTemplate>
|
|
</ItemsControl>
|
|
|
|
<TextBlock>
|
|
|
|
<Run Text="Reconnecting..."/>
|
|
<Run Text="{Binding PlcCurrentReconnectArgs.ReconnectTry, Mode=OneWay, StringFormat='{}{0}/'}"/>
|
|
<Run Text="{Binding PlcCurrentReconnectArgs.MaxAttempts, Mode=OneWay}"/> in
|
|
<Run Text="{Binding PlcCurrentReconnectArgs.RetryCountDownRemaining, Mode=OneWay}"/>
|
|
|
|
<TextBlock.Style>
|
|
<Style TargetType="TextBlock">
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding PlcCurrentReconnectArgs, Mode=OneWay}" Value="{x:Null}">
|
|
<Setter Property="Visibility" Value="Collapsed"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</TextBlock.Style>
|
|
|
|
</TextBlock>
|
|
|
|
</StackPanel>
|
|
|
|
<Grid Grid.Row="2">
|
|
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="1.5*"/>
|
|
<ColumnDefinition Width="auto"/>
|
|
<ColumnDefinition Width="*"/>
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="auto"/>
|
|
<RowDefinition/>
|
|
<RowDefinition Height="auto"/>
|
|
<RowDefinition/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<GridSplitter Grid.Column="1"
|
|
Grid.Row="1"
|
|
Grid.RowSpan="3"
|
|
VerticalAlignment="Stretch"
|
|
HorizontalAlignment="Stretch"
|
|
Background="Gray"
|
|
ShowsPreview="true"
|
|
Width="10">
|
|
<GridSplitter.Template>
|
|
<ControlTemplate>
|
|
<Rectangle Fill="Gray"
|
|
Width="2"
|
|
Margin="2"/>
|
|
</ControlTemplate>
|
|
</GridSplitter.Template>
|
|
</GridSplitter>
|
|
|
|
<TextBlock Text="Underlying Registers"
|
|
FontSize="18"
|
|
Margin="10"/>
|
|
|
|
<DataGrid Grid.Row="1"
|
|
Grid.RowSpan="3"
|
|
AutoGenerateColumns="False"
|
|
IsReadOnly="True"
|
|
ItemsSource="{Binding Plc.Registers, Mode=OneWay}">
|
|
<DataGrid.RowStyle>
|
|
<Style TargetType="DataGridRow">
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding IsAutoGenerated}" Value="True">
|
|
<Setter Property="IsEnabled" Value="False"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</DataGrid.RowStyle>
|
|
<DataGrid.Columns>
|
|
<DataGridTextColumn Header="FP Address" Binding="{Binding PLCAddressName}"/>
|
|
<DataGridTextColumn Header="Type" Binding="{Binding UnderlyingSystemType.Name}"/>
|
|
<DataGridTemplateColumn Header="Value" Width="*">
|
|
<DataGridTemplateColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<Border HorizontalAlignment="Left"
|
|
Padding="2,0">
|
|
<TextBlock Text="{Binding ValueStr}"/>
|
|
<Border.Style>
|
|
<Style TargetType="Border">
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding ValueStr}" Value="True">
|
|
<Setter Property="Background" Value="Blue"/>
|
|
<Setter Property="TextElement.Foreground" Value="White"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</Border.Style>
|
|
</Border>
|
|
</DataTemplate>
|
|
</DataGridTemplateColumn.CellTemplate>
|
|
</DataGridTemplateColumn>
|
|
<DataGridTextColumn Header="Poll Level" Binding="{Binding PollLevel, Mode=OneWay}"/>
|
|
<DataGridTextColumn Header="Update Frequency" Binding="{Binding UpdateFreqHz, StringFormat='{}{0} Hz',Mode=OneWay}"/>
|
|
<DataGridTemplateColumn Width="15">
|
|
<DataGridTemplateColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<Border Background="{Binding MemoryArea, Mode=OneWay, Converter={StaticResource hashColor}}"/>
|
|
</DataTemplate>
|
|
</DataGridTemplateColumn.CellTemplate>
|
|
</DataGridTemplateColumn>
|
|
</DataGrid.Columns>
|
|
</DataGrid>
|
|
|
|
<TextBlock Text="Memory Areas"
|
|
Grid.Column="2"
|
|
FontSize="18"
|
|
Margin="10"/>
|
|
|
|
<Border Grid.Column="2"
|
|
Grid.Row="1"
|
|
VerticalAlignment="Stretch"
|
|
HorizontalAlignment="Stretch"
|
|
BorderBrush="LightBlue"
|
|
BorderThickness="1.5">
|
|
|
|
<DataGrid IsReadOnly="True"
|
|
AutoGenerateColumns="False"
|
|
ItemsSource="{Binding Plc.MemoryAreas, Mode=OneWay}">
|
|
|
|
<DataGrid.Columns>
|
|
|
|
<DataGridTextColumn Header="Address Range" Binding="{Binding AddressRange, Mode=OneWay}"/>
|
|
|
|
<DataGridTemplateColumn Width="15">
|
|
<DataGridTemplateColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<Border Background="{Binding Converter={StaticResource hashColor}}"/>
|
|
</DataTemplate>
|
|
</DataGridTemplateColumn.CellTemplate>
|
|
</DataGridTemplateColumn>
|
|
|
|
<DataGridTextColumn Header="Words" Binding="{Binding UnderlyingWordsString, Mode=OneWay}"/>
|
|
|
|
</DataGrid.Columns>
|
|
|
|
</DataGrid>
|
|
|
|
</Border>
|
|
|
|
<TextBlock Text="Property Bindings"
|
|
Grid.Column="2"
|
|
Grid.Row="2"
|
|
FontSize="18"
|
|
Margin="10"/>
|
|
|
|
<Border Grid.Column="2"
|
|
Grid.Row="3"
|
|
VerticalAlignment="Stretch"
|
|
HorizontalAlignment="Stretch"
|
|
BorderBrush="LightBlue"
|
|
BorderThickness="1.5">
|
|
|
|
<ScrollViewer>
|
|
|
|
<StackPanel>
|
|
|
|
<TextBlock Text="Boolean internal relays"/>
|
|
|
|
<TextBlock>
|
|
<Run Text="R11A Nullable property: "/>
|
|
<Run Text="{Binding RegCollection.TestR11A}"
|
|
FontWeight="Bold"/>
|
|
</TextBlock>
|
|
|
|
<TextBlock>
|
|
<Run Text="R11A Duplicate non nullable property: "/>
|
|
<Run Text="{Binding RegCollection.TestR11A_Duplicate_NonNullable}"
|
|
FontWeight="Bold"/>
|
|
</TextBlock>
|
|
|
|
<TextBlock>
|
|
<Run Text="R16B"/>
|
|
<Run Text="{Binding RegCollection.TestR16B}"
|
|
FontWeight="Bold"/>
|
|
</TextBlock>
|
|
|
|
<TextBlock>
|
|
<Run Text="DT1000 Word duplicate: "/>
|
|
<Run Text="{Binding RegCollection.TestDT100_Word_Duplicate, Mode=OneWay}"
|
|
FontWeight="Bold"/>
|
|
</TextBlock>
|
|
|
|
<TextBlock>
|
|
<Run Text="DT1000 Word direct bit read (Idx 0): "/>
|
|
<Run Text="{Binding RegCollection.TestDT100_Word_Duplicate_SingleBit, Mode=OneWay}"
|
|
FontWeight="Bold"/>
|
|
</TextBlock>
|
|
|
|
<TextBlock>
|
|
<Run Text="DDT1010 DWord direct bit read (Idx 1): "/>
|
|
<Run Text="{Binding RegCollection.TestDDT1010_DWord_Duplicate_SingleBit, Mode=OneWay}"
|
|
FontWeight="Bold"/>
|
|
</TextBlock>
|
|
|
|
</StackPanel>
|
|
|
|
</ScrollViewer>
|
|
|
|
</Border>
|
|
|
|
</Grid>
|
|
|
|
</Grid>
|
|
</UserControl>
|