<UserControl
    x:Class="SicUI.Models.PMs.PMServoView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cal="http://www.caliburn.org"
    xmlns:controls="http://OpenSEMI.Ctrlib.com/presentation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:deviceControl="clr-namespace:Aitex.Core.UI.DeviceControl;assembly=MECF.Framework.UI.Core"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:local="clr-namespace:SicUI.Models.PMs"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    d:DesignHeight="650"
    d:DesignWidth="1920"
    d:Background="#91b0cd"
    mc:Ignorable="d">
    <Grid>
        <Canvas Margin="150,0" IsEnabled="{Binding IsPermission}">

            <Grid Canvas.Left="380" Canvas.Top="10">
                <Grid.RowDefinitions>
                    <RowDefinition Height="35" />
                    <RowDefinition Height="35" />
                    <RowDefinition Height="35" />
                    <RowDefinition Height="0" />
                    <RowDefinition Height="0" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="190" />
                    <ColumnDefinition Width="120" />
                    <ColumnDefinition Width="120" />
                    <ColumnDefinition Width="100" />
                </Grid.ColumnDefinitions>

                <Label
                    Grid.Row="0"
                    Grid.ColumnSpan="4"
                    HorizontalContentAlignment="Center"
                    VerticalContentAlignment="Center"
                    Content="Rotation Speed Set"
                    Style="{DynamicResource Table_TitleStyle}" />

                <Border
                    Grid.Row="1"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Title_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,1,1,1">
                    <Label
                        HorizontalContentAlignment="Right"
                        Content="Actual Speed (rpm)"
                        FontSize="14" />
                </Border>
                <Border
                    Grid.Row="1"
                    Grid.Column="1"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,1,1,1">
                    <Label HorizontalContentAlignment="Center" FontSize="14">
                        <TextBlock Text="{Binding ActualSpeedFeedback, StringFormat=0.00}" />
                    </Label>
                </Border>
                <Border
                    Grid.Row="1"
                    Grid.Column="2"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,1,1,1">
                    <controls:TextBoxEx
                        x:Name="ActualSpeed"
                        EditBoxMode="UnSignInteger"
                        FontFamily="Arial"
                        FontSize="14"
                        IsEnabled="{Binding IsServoReady}"
                        MaxValue="1000"
                        MinValue="0"
                        Text="0.0"
                        Validation.ErrorTemplate="{x:Null}" />
                </Border>
                <Border
                    Grid.Row="1"
                    Grid.Column="3"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,1,1,1">
                    <Button Content="Set" IsEnabled="{Binding IsServoReady}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="SetActualSpeed">
                                    <cal:Parameter Value="{Binding Path=Text, ElementName=ActualSpeed}" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </Border>

                <Border
                    Grid.Row="2"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Title_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,0,1,1">
                    <Label
                        HorizontalContentAlignment="Right"
                        Content="Actual Current (A)"
                        FontSize="14" />
                </Border>
                <Border
                    Grid.Row="2"
                    Grid.Column="1"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,0,1,1">
                    <Label HorizontalContentAlignment="Center" FontSize="14">
                        <TextBlock Text="{Binding ActualCurrentFeedback, StringFormat=0.00}" />
                    </Label>
                </Border>
                <Border
                    Grid.Row="2"
                    Grid.Column="2"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,1,1,1" />

                <Border
                    Grid.Row="2"
                    Grid.Column="3"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,1,1,1" />

                <Border
                    Grid.Row="3"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Title_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,0,1,1">
                    <Label
                        HorizontalContentAlignment="Right"
                        Content="Acc. Speed (rpm/s)"
                        FontSize="14" />
                </Border>
                <Border
                    Grid.Row="3"
                    Grid.Column="1"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,0,1,1">
                    <Label HorizontalContentAlignment="Center" FontSize="14">
                        <TextBlock Text="{Binding AccSpeedFeedback, StringFormat=0.00}" />
                    </Label>
                </Border>
                <Border
                    Grid.Row="3"
                    Grid.Column="2"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,1,1,1">
                    <controls:TextBoxEx
                        x:Name="AccSpeed"
                        FontFamily="Arial"
                        FontSize="14"
                        IsEnabled="{Binding IsServoReady}"
                        Text="0.00" />
                </Border>
                <Border
                    Grid.Row="3"
                    Grid.Column="3"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,1,1,1">
                    <Button Content="Set" IsEnabled="{Binding IsServoReady}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="SetAccSpeed">
                                    <cal:Parameter Value="{Binding Path=Text, ElementName=AccSpeed}" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </Border>

                <Border
                    Grid.Row="4"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Title_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,0,1,1">
                    <Label
                        HorizontalContentAlignment="Right"
                        Content="Dec. Speed (rpm/s)"
                        FontSize="14" />
                </Border>
                <Border
                    Grid.Row="4"
                    Grid.Column="1"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,0,1,1">
                    <Label HorizontalContentAlignment="Center" FontSize="14">
                        <TextBlock Text="{Binding DecSpeedFeedback, StringFormat=0.00}" />
                    </Label>
                </Border>
                <Border
                    Grid.Row="4"
                    Grid.Column="2"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,1,1,1">
                    <controls:TextBoxEx
                        x:Name="DecSpeed"
                        FontFamily="Arial"
                        FontSize="14"
                        IsEnabled="{Binding IsServoReady}"
                        Text="0.00" />
                </Border>
                <Border
                    Grid.Row="4"
                    Grid.Column="3"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,1,1,1">
                    <Button Content="Set" IsEnabled="{Binding IsServoReady}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="SetDecSpeed">
                                    <cal:Parameter Value="{Binding Path=Text, ElementName=DecSpeed}" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </Border>
            </Grid>

            <Grid
                Canvas.Left="33"
                Canvas.Top="300"
                Margin="0,5,0,0"
                Visibility="Hidden">
                <Grid.RowDefinitions>
                    <RowDefinition Height="35" />
                    <RowDefinition Height="35" />
                    <RowDefinition Height="35" />
                    <RowDefinition Height="35" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="120" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Label
                    Grid.Row="0"
                    Grid.ColumnSpan="3"
                    HorizontalContentAlignment="Center"
                    VerticalContentAlignment="Center"
                    Content="Confinement Ring Control"
                    Style="{DynamicResource Table_TitleStyle}" />

                <Border
                    Grid.Row="1"
                    Padding="5,1,0,1"
                    Background="{DynamicResource Table_BG_Title}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,0,1,1">
                    <TextBlock
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="12"
                        Foreground="{DynamicResource FG_Black}"
                        Text="Servo"
                        TextWrapping="Wrap" />
                </Border>
                <Border
                    Grid.Row="1"
                    Grid.Column="1"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,0,0,1">
                    <TextBlock
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="12"
                        Foreground="{DynamicResource FG_Black}"
                        Text="{Binding TMStatus}"
                        TextAlignment="Center"
                        TextWrapping="Wrap" />
                </Border>

                <Border
                    Grid.Row="1"
                    Grid.Column="2"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,0,1,1">

                    <StackPanel Orientation="Horizontal">
                        <Button
                            Width="80"
                            Height="25"
                            Margin="10,0"
                            Content="SetOn">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cal:ActionMessage MethodName="ServoOn">
                                        <!--<cal:Parameter Value="TM"></cal:Parameter>-->
                                    </cal:ActionMessage>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>
                    </StackPanel>
                </Border>

                <Border
                    Grid.Row="2"
                    Padding="5,1,0,1"
                    Background="{DynamicResource Table_BG_Title}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,0,1,1">
                    <TextBlock
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="12"
                        Foreground="{DynamicResource FG_Black}"
                        Text="Block No"
                        TextWrapping="Wrap" />
                </Border>
                <Border
                    Grid.Row="2"
                    Grid.Column="1"
                    Padding="5,1,0,1"
                    Background="{DynamicResource Table_BG_Content}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,0,0,1">
                    <TextBlock
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="12"
                        Foreground="{DynamicResource FG_Black}"
                        Text="{Binding TMOnlineMode}"
                        TextAlignment="Center"
                        TextWrapping="Wrap" />
                </Border>
                <Border
                    Grid.Row="2"
                    Grid.Column="2"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,0,1,1">
                    <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                        <Button
                            Width="80"
                            Height="25"
                            Margin="10,0"
                            Content="UpLimit"
                            IsEnabled="{Binding IsTMOnlineButtonEnable}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cal:ActionMessage MethodName="BlockUp">
                                        <!--<cal:Parameter Value="TM"></cal:Parameter>-->
                                    </cal:ActionMessage>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>

                        <Button
                            Width="80"
                            Height="25"
                            Margin="10,0"
                            Content="LowLimit"
                            IsEnabled="{Binding IsTMOfflineButtonEnable}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cal:ActionMessage MethodName="BlockLow">
                                        <!--<cal:Parameter Value="TM"></cal:Parameter>-->
                                    </cal:ActionMessage>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>
                    </StackPanel>

                </Border>

                <Border
                    Grid.Row="3"
                    Padding="5,1,0,1"
                    Background="{DynamicResource Table_BG_Title}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,0,1,1">
                    <TextBlock
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="12"
                        Foreground="{DynamicResource FG_Black}"
                        Text="Stb "
                        TextWrapping="Wrap" />
                </Border>
                <Border
                    Grid.Row="3"
                    Grid.Column="1"
                    Padding="5,1,0,1"
                    Background="{DynamicResource Table_BG_Content}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,0,0,1">
                    <TextBlock
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="12"
                        Foreground="{DynamicResource FG_Black}"
                        Text="{Binding TMOnlineMode}"
                        TextAlignment="Center"
                        TextWrapping="Wrap" />
                </Border>
                <Border
                    Grid.Row="3"
                    Grid.Column="2"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,0,1,1">
                    <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                        <Button
                            Width="80"
                            Height="25"
                            Margin="10,0"
                            Content="SetOn"
                            IsEnabled="{Binding IsTMOnlineButtonEnable}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cal:ActionMessage MethodName="StbOn">
                                        <!--<cal:Parameter Value="TM"></cal:Parameter>-->
                                    </cal:ActionMessage>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>

                        <Button
                            Width="80"
                            Height="25"
                            Margin="10,0"
                            Content="SetOff"
                            IsEnabled="{Binding IsTMOfflineButtonEnable}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cal:ActionMessage MethodName="StbOff">
                                        <!--<cal:Parameter Value="TM"></cal:Parameter>-->
                                    </cal:ActionMessage>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>
                    </StackPanel>

                </Border>
            </Grid>

            <Grid Canvas.Left="33" Canvas.Top="12">
                <Grid.RowDefinitions>
                    <RowDefinition Height="35" />
                    <RowDefinition Height="35" />
                    <RowDefinition Height="35" />
                    <RowDefinition Height="35" />
                    <RowDefinition Height="35" />
                    <RowDefinition Height="35" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="120" />
                    <ColumnDefinition Width="120" />
                </Grid.ColumnDefinitions>

                <Label
                    Grid.Row="0"
                    Grid.ColumnSpan="3"
                    HorizontalContentAlignment="Center"
                    VerticalContentAlignment="Center"
                    Content="Rotation Status "
                    Style="{DynamicResource Table_TitleStyle}" />

                <Border
                    Grid.Row="1"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Title_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,1,1,1">
                    <Label
                        HorizontalContentAlignment="Right"
                        Content="Servo Ready"
                        FontSize="14" />
                </Border>
                <Border
                    Grid.Row="1"
                    Grid.Column="1"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,1,1,1">
                    <deviceControl:AITSensor
                        EnableToolTip="False"
                        GreenColor="True"
                        LightOnValue="{Binding IsServoReady}" />
                </Border>

                <Border
                    Grid.Row="2"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Title_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,0,1,1">
                    <Label
                        HorizontalContentAlignment="Right"
                        Content="Servo Error"
                        FontSize="14" />
                </Border>
                <Border
                    Grid.Row="2"
                    Grid.Column="1"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,0,1,1">
                    <deviceControl:AITSensor
                        EnableToolTip="False"
                        GreenColor="False"
                        LightOnValue="{Binding IsServoError}" />
                </Border>

                <Border
                    Grid.Row="3"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Title_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,0,1,1">
                    <Label
                        HorizontalContentAlignment="Right"
                        Content="Servo Enable"
                        FontSize="14" />
                </Border>
                <Border
                    Grid.Row="3"
                    Grid.Column="1"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,0,1,1">
                    <deviceControl:AITSensor
                        EnableToolTip="False"
                        GreenColor="True"
                        LightOnValue="{Binding IsServoEnable}" />
                </Border>



                <Border
                    Grid.Row="4"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Title_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,0,0,1" />
                <Border
                    Grid.Row="4"
                    Grid.Column="1"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,0,1,1">
                    <Button
                        Margin="10,1"
                        Content="Enable"
                        IsEnabled="{Binding IsActionEnable}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="SetServoEnable">
                                    <!--<cal:Parameter Value="{Binding Path=Text, ElementName=DecSpeed}"></cal:Parameter>-->
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </Border>

                <Border
                    Grid.Row="5"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Title_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1,0,0,1">
                    <Button
                        Margin="10,1"
                        Content="Inital"
                        IsEnabled="{Binding IsActionEnable}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="SetServoInital">
                                    <!--<cal:Parameter Value="{Binding Path=Text, ElementName=DecSpeed}"></cal:Parameter>-->
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </Border>
                <Border
                    Grid.Row="5"
                    Grid.Column="1"
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Content_Inner}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0,0,1,1">
                    <Button
                        Margin="10,1"
                        Content="Reset"
                        IsEnabled="{Binding IsActionEnable}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="SetServoReset">
                                    <!--<cal:Parameter Value="{Binding Path=Text, ElementName=DecSpeed}"></cal:Parameter>-->
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </Border>


            </Grid>


        </Canvas>

    </Grid>
</UserControl>
