Browse Source

Merge branch 'master' of http://unque781.synology.me:3000/GSI/OHV

ys-hwang 6 years ago
parent
commit
4c16097f0a

+ 11 - 1
Dev/OHV/OHV.Common/Events/MessageEventArgs.cs

@@ -24,6 +24,7 @@ namespace OHV.Common.Events
             RspManualModeChange,
             RspAlarmReset,
             RspVehicleModeChange,
+            RspEStop,
         }
 
         public eGUIMessageKind Kind { get; set; }
@@ -57,6 +58,7 @@ namespace OHV.Common.Events
             ReqManualModeChange,
             ReqAlarmReset,
             ReqVehicleModeChange,
+            ReqEStop,
         }
 
         public eVCSMessageKind Kind { get; set; }
@@ -82,12 +84,12 @@ namespace OHV.Common.Events
             EStop,
             Move,
             Jog,
-            CurrentPosition,
             ServoOn,
             ServoOff,
             ReqCurrentPosition,
             ReqStopCurrentPosition,
             FaultReset,
+            AxisState,
         }
 
         public enum eJogMoveDir
@@ -123,6 +125,14 @@ namespace OHV.Common.Events
         public Dictionary<string, object> Args { get; set; }
 
         public Result Result { get; set; }
+
+        public class AxisState
+        {
+            public bool IsServoOn { get; set; }
+            public bool IsOriginReturn { get; set; }
+            public bool IsAmpFault { get; set; }
+            public double CurrentPosition { get; set; }
+        }
     }
 
     public class IOChangedMessageEventArgs: EventArgs

+ 5 - 1
Dev/OHV/OHV.Common/Shareds/SharedEnumType.cs

@@ -36,8 +36,12 @@
     #region Vehicle Status
 	public enum eVehicleState
 	{
+		None,
 		Idle,
-		Active,
+		Move,
+		Load,
+		Unload,
+		Charge,
 		Abnormal,
 		Blocked,
 		Decelerate,

+ 7 - 3
Dev/OHV/OHV.Module.Interactivity/OHV.Module.Interactivity.csproj

@@ -36,12 +36,12 @@
     <Reference Include="CommonServiceLocator, Version=2.0.4.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
       <HintPath>..\packages\CommonServiceLocator.2.0.4\lib\net45\CommonServiceLocator.dll</HintPath>
     </Reference>
+    <Reference Include="DynamicExpresso.Core, Version=2.3.1.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\DynamicExpresso.Core.2.3.1\lib\net45\DynamicExpresso.Core.dll</HintPath>
+    </Reference>
     <Reference Include="FluentResults">
       <HintPath>..\Assambly\FluentResults.dll</HintPath>
     </Reference>
-    <Reference Include="GSG.NET.WPF">
-      <HintPath>C:\Users\user\Desktop\새 폴더 (3)\OHV\Assambly\GSG.NET.WPF.dll</HintPath>
-    </Reference>
     <Reference Include="MaterialDesignColors, Version=1.2.2.920, Culture=neutral, processorArchitecture=MSIL">
       <HintPath>..\packages\MaterialDesignColors.1.2.2\lib\net45\MaterialDesignColors.dll</HintPath>
     </Reference>
@@ -217,6 +217,10 @@
     </Page>
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\..\..\..\GSG\GSG\GSG.NET.WPF\GSG.NET.WPF.csproj">
+      <Project>{6b91fca2-0a26-41d5-8959-a6f27645dacd}</Project>
+      <Name>GSG.NET.WPF</Name>
+    </ProjectReference>
     <ProjectReference Include="..\OHV.Common\OHV.Common.csproj">
       <Project>{0d1f7fbc-bfb0-4ee4-852d-e2a8d62c5708}</Project>
       <Name>OHV.Common</Name>

+ 168 - 62
Dev/OHV/OHV.Module.Interactivity/PopUp/LockServoView.xaml

@@ -3,12 +3,15 @@
              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:prism="http://prismlibrary.com/"
              xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
              xmlns:local="clr-namespace:OHV.Module.Interactivity.PopUp"
              xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+             xmlns:prism="http://prismlibrary.com/"
              prism:ViewModelLocator.AutoWireViewModel="True"
+             xmlns:CommonShareds ="clr-namespace:OHV.Common.Shareds;assembly=OHV.Common"
              mc:Ignorable="d" 
+             xmlns:c ="clr-namespace:GSG.NET.WPF.CalcBinding;assembly=GSG.NET.WPF"
+             xmlns:media ="clr-namespace:System.Windows.Media;assembly=PresentationCore"
              Width="800"
              Height="600"
              Background="#455a64">
@@ -61,7 +64,6 @@
                         <ColumnDefinition Width="*"/>
                     </Grid.ColumnDefinitions>
 
-                    <Border BorderBrush="#FF00FFD3" BorderThickness="2" Grid.RowSpan="4" Grid.Column="3" Margin="95,10,2,0"/>
 
                     <!--Column1-->
                     <Button Background="{x:Null}" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Stretch" Margin="5" Height="auto"
@@ -114,12 +116,12 @@
                             ToolTip="MaterialDesignRaisedButton with Round Corners"
                             Command="{Binding SelectAxisCommand}"
                             CommandParameter="Axis_CarrierLock_Left"
-                            BorderBrush="{Binding SelectControl}"
+                            BorderBrush="{Binding LeftAxisBrush}"
                             BorderThickness="2">
                         <StackPanel>
                             <TextBlock VerticalAlignment="Center"
                                        HorizontalAlignment="Center">
-                                <Run Text="Carrier"/>
+                                <Run Text="Clamp"/>
                             </TextBlock>
                             <TextBlock><Run Text="Axis Left"/></TextBlock>
                         </StackPanel>
@@ -156,12 +158,12 @@
                             ToolTip="MaterialDesignRaisedButton with Round Corners"
                             Command="{Binding SelectAxisCommand}"
                             CommandParameter="Axis_CarrierLock_Right"
-                            BorderBrush="{Binding SelectControl}"
+                            BorderBrush="{Binding RightAxisBrush}"
                             BorderThickness="2">
                         <StackPanel>
                             <TextBlock VerticalAlignment="Center"
                                        HorizontalAlignment="Center">
-                                <Run Text="Carrier"/>
+                                <Run Text="Clamp"/>
                             </TextBlock>
                             <TextBlock><Run Text="Axis Right"/></TextBlock>
                         </StackPanel>
@@ -191,23 +193,49 @@
                         <TextBlock><Run Text="{Binding DifferenceLockRight, StringFormat=0.000, FallbackValue=0.000}"/></TextBlock>
                     </Button>
 
-                    <Button Margin="3" HorizontalAlignment="Stretch" Grid.Column="4" Grid.Row="1" Width="Auto" Height="Auto" BorderBrush="Gray" BorderThickness="2"
-                            Command="{Binding SelectPosCommand}"
-                            CommandParameter="Teach_Postion_Lock">
+                    <!--Axis State-->
+                    <Border BorderThickness="3" BorderBrush="Aqua" Grid.Column="3" Grid.ColumnSpan="4" Grid.RowSpan="4" />
+
+                    <Button Background="{x:Null}" Grid.Column="3" Grid.Row="0" HorizontalAlignment="Stretch" Margin="5" Height="auto"
+                           Style="{StaticResource MaterialDesignRaisedButton}"
+                            materialDesign:ButtonAssist.CornerRadius="10"
+                            ToolTip="MaterialDesignRaisedButton with Round Corners">
+                        <TextBlock><Run Text="Left Axis"/></TextBlock>
+                    </Button>
+                    <Button Background="{x:Null}" Grid.Column="4" Grid.Row="0" HorizontalAlignment="Stretch" Margin="5" Height="auto"
+                           Style="{StaticResource MaterialDesignRaisedButton}"
+                            materialDesign:ButtonAssist.CornerRadius="10"
+                            ToolTip="MaterialDesignRaisedButton with Round Corners">
+                        <TextBlock><Run Text="Right Axis"/></TextBlock>
+                    </Button>
+
+                    <Button Grid.Column="3" Grid.Row="1" HorizontalAlignment="Stretch" Margin="5" Height="auto"
+                            Style="{StaticResource MaterialDesignRaisedButton}"
+                            materialDesign:ButtonAssist.CornerRadius="10"
+                            ToolTip="MaterialDesignRaisedButton with Round Corners" Background="{c:Binding 'IsLeftServoOn ? media:Brushes.DodgerBlue : media:Brushes.Transparent'}">
                         <StackPanel>
-                            <TextBlock Text="Pos" VerticalAlignment="Stretch" HorizontalAlignment="Center"/>
-                            <TextBlock Text="Lock" VerticalAlignment="Stretch" HorizontalAlignment="Center"/>
+                            <TextBlock HorizontalAlignment="Center"><Run Text="Servo On"/></TextBlock>
                         </StackPanel>
                     </Button>
-                    <Button Margin="3" HorizontalAlignment="Stretch" Grid.Column="4" Grid.Row="2" Width="Auto" Height="Auto" BorderBrush="Gray" BorderThickness="2"
-                            Command="{Binding SelectPosCommand}"
-                            CommandParameter="Teach_Postion_Unlock">
+                    <Button Grid.Column="3" Grid.Row="2" HorizontalAlignment="Stretch" Margin="5" Height="auto"
+                            Style="{StaticResource MaterialDesignRaisedButton}"
+                            materialDesign:ButtonAssist.CornerRadius="10" Background="{c:Binding 'IsLeftServoOriginReturn ? media:Brushes.DodgerBlue : media:Brushes.Transparent'}"
+                            ToolTip="MaterialDesignRaisedButton with Round Corners">
                         <StackPanel>
-                            <TextBlock Text="Pos" VerticalAlignment="Stretch" HorizontalAlignment="Center"/>
-                            <TextBlock Text="UnLock" VerticalAlignment="Stretch" HorizontalAlignment="Center"/>
+                            <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap"><Run Text="Origin Return"/></TextBlock>
                         </StackPanel>
                     </Button>
-                    <Border BorderBrush="#FF00FFD3" BorderThickness="2" Margin="7,98,101,-33" Grid.ColumnSpan="4" RenderTransformOrigin="0.5,0.5" Grid.Row="3">
+                    <Button Grid.Column="3" Grid.Row="3" HorizontalAlignment="Stretch" Margin="5" Height="auto"
+                            Style="{StaticResource MaterialDesignRaisedButton}"
+                            materialDesign:ButtonAssist.CornerRadius="10" Background="{c:Binding 'IsLeftServoFault ? media:Brushes.DodgerBlue : media:Brushes.Transparent'}"
+                            ToolTip="MaterialDesignRaisedButton with Round Corners">
+                        <StackPanel>
+                            <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap"><Run Text="Servo Fault"/></TextBlock>
+                        </StackPanel>
+                    </Button>
+
+                    <!--Right-->
+                    <Border BorderBrush="#FF00FFD3" BorderThickness="2" Margin="12,78,15,-13" Grid.ColumnSpan="5" RenderTransformOrigin="0.5,0.5" Grid.Row="3">
                         <Border.RenderTransform>
                             <TransformGroup>
                                 <ScaleTransform ScaleX="-1"/>
@@ -217,12 +245,57 @@
                             </TransformGroup>
                         </Border.RenderTransform>
                     </Border>
+                    <Button Grid.Column="4" Grid.Row="1" HorizontalAlignment="Stretch" Margin="5" Height="auto"
+                            Style="{StaticResource MaterialDesignRaisedButton}"
+                            materialDesign:ButtonAssist.CornerRadius="10" Background="{c:Binding 'IsRightServoOn ? media:Brushes.DodgerBlue : media:Brushes.Transparent'}"
+                            ToolTip="MaterialDesignRaisedButton with Round Corners">
+                        <StackPanel>
+                            <TextBlock HorizontalAlignment="Center"><Run Text="Servo On"/></TextBlock>
+                        </StackPanel>
+                    </Button>
+                    <Button Grid.Column="4" Grid.Row="2" HorizontalAlignment="Stretch" Margin="5" Height="auto"
+                            Style="{StaticResource MaterialDesignRaisedButton}"
+                            materialDesign:ButtonAssist.CornerRadius="10" Background="{c:Binding 'IsLeftServoOriginReturn ? media:Brushes.DodgerBlue : media:Brushes.Transparent'}"
+                            ToolTip="MaterialDesignRaisedButton with Round Corners">
+                        <StackPanel>
+                            <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap"><Run Text="Origin Return"/></TextBlock>
+                        </StackPanel>
+                    </Button>
+                    <Button Grid.Column="4" Grid.Row="3" HorizontalAlignment="Stretch" Margin="5" Height="auto"
+                            Style="{StaticResource MaterialDesignRaisedButton}"
+                            materialDesign:ButtonAssist.CornerRadius="10" Background="{c:Binding 'IsLeftServoFault ? media:Brushes.DodgerBlue : media:Brushes.Transparent'}"
+                            ToolTip="MaterialDesignRaisedButton with Round Corners">
+                        <StackPanel>
+                            <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap"><Run Text="Servo Fault"/></TextBlock>
+                        </StackPanel>
+                    </Button>
+
+                    <Border BorderBrush="#FF00FFD3" BorderThickness="2" Grid.Column="1" Margin="78,102,18,-269" Grid.Row="3"/>
 
                 </Grid>
 
                 <Grid Grid.Row="1">
-                    <StackPanel Margin="50,0,0,90" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left">
-                        <Button
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="*"/>
+                        <ColumnDefinition Width="2*"/>
+                    </Grid.ColumnDefinitions>
+                    <StackPanel Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center">
+                        <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center" >
+                            <Button
+                            Style="{StaticResource MaterialDesignRaisedButton}"
+                            materialDesign:ButtonAssist.CornerRadius="10"
+                            ToolTip="MaterialDesignRaisedButton with Round Corners"
+                            Margin="15"
+                            Height="auto"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center"
+                            >
+                                <StackPanel>
+                                    <TextBlock><Run Text="Limit(-)"/></TextBlock>
+                                </StackPanel>
+                            </Button>
+
+                            <Button
                             Style="{StaticResource MaterialDesignRaisedButton}"
                             materialDesign:ButtonAssist.CornerRadius="10"
                             ToolTip="MaterialDesignRaisedButton with Round Corners"
@@ -231,12 +304,12 @@
                             HorizontalAlignment="Center"
                             VerticalAlignment="Center"
                             >
-                            <StackPanel>
-                                <TextBlock><Run Text="Limit(-)"/></TextBlock>
-                            </StackPanel>
-                        </Button>
+                                <StackPanel>
+                                    <TextBlock><Run Text="Origin"/></TextBlock>
+                                </StackPanel>
+                            </Button>
 
-                        <Button
+                            <Button
                             Style="{StaticResource MaterialDesignRaisedButton}"
                             materialDesign:ButtonAssist.CornerRadius="10"
                             ToolTip="MaterialDesignRaisedButton with Round Corners"
@@ -244,28 +317,28 @@
                             Height="auto"
                             HorizontalAlignment="Center"
                             VerticalAlignment="Center">
-                            <StackPanel>
-                                <TextBlock><Run Text="Limit(+)"/></TextBlock>
-                            </StackPanel>
-                        </Button>
-                    </StackPanel>
+                                <StackPanel>
+                                    <TextBlock><Run Text="Limit(+)"/></TextBlock>
+                                </StackPanel>
+                            </Button>
+                        </StackPanel>
 
-                    <StackPanel Margin="30,0,0,50" Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Left"
+                        <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center"
                                 Width="Auto" Height="120">
-                        <RepeatButton
+                            <RepeatButton
                             Margin="5"
                             Grid.Row="2" 
                             Grid.Column="1"
                             HorizontalAlignment="Stretch"
                             Height="auto"
                             Command="{Binding JogCommand}" CommandParameter="-">
-                            <StackPanel>
-                                <materialDesign:PackIcon Kind="ArrowLeftBoldCircleOutline" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="30" Width="auto"/>
-                                <TextBlock><Run Text="Jog(-)"/></TextBlock>
-                            </StackPanel>
-                        </RepeatButton>
+                                <StackPanel>
+                                    <materialDesign:PackIcon Kind="ArrowLeftBoldCircleOutline" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="30" Width="auto"/>
+                                    <TextBlock><Run Text="Jog(-)"/></TextBlock>
+                                </StackPanel>
+                            </RepeatButton>
 
-                        <materialDesign:Badged
+                            <materialDesign:Badged
                             Grid.Row="2"
                             Grid.Column="2"
                             Badge="Jog Velocity"
@@ -274,33 +347,62 @@
                             BadgeForeground="Aqua"
                             VerticalAlignment="Center"
                             HorizontalAlignment="Center">
-                            <Button Margin="15" VerticalAlignment="Center" HorizontalAlignment="Center" Height="60" Width="Auto" >
-                                <StackPanel>
-                                    <TextBlock Text="0.000"/>
-                                </StackPanel>
-                            </Button>
-                        </materialDesign:Badged>
-
-                        <RepeatButton
+                                <Button Margin="15" VerticalAlignment="Center" HorizontalAlignment="Center" Height="60" Width="Auto" >
+                                    <StackPanel>
+                                        <TextBlock Text="0.000"/>
+                                    </StackPanel>
+                                </Button>
+                            </materialDesign:Badged>
+
+                            <RepeatButton
                             Margin="5"
                             Grid.Row="2" 
                             Grid.Column="3"
                             HorizontalAlignment="Stretch"
                             Height="auto"
                             Command="{Binding JogCommand}" CommandParameter="+">
-                            <StackPanel>
-                                <materialDesign:PackIcon Kind="ArrowRightBoldCircleOutline" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="30" Width="auto"/>
-                                <TextBlock><Run Text="Jog(+)"/></TextBlock>
-                            </StackPanel>
-                        </RepeatButton>
+                                <StackPanel>
+                                    <materialDesign:PackIcon Kind="ArrowRightBoldCircleOutline" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="30" Width="auto"/>
+                                    <TextBlock><Run Text="Jog(+)"/></TextBlock>
+                                </StackPanel>
+                            </RepeatButton>
+                        </StackPanel>
+
                     </StackPanel>
+
+                    <Grid Grid.Column="0" Margin="5,20,0,0">
+                        <Grid>
+                            <Grid.RowDefinitions>
+                                <RowDefinition Height="*"/>
+                                <RowDefinition Height="*"/>
+                                <RowDefinition Height="*"/>
+                                <RowDefinition Height="*"/>
+                            </Grid.RowDefinitions>
+                            <Button Margin="3" HorizontalAlignment="Stretch" Grid.Column="4" Grid.Row="0" Width="Auto" Height="Auto" BorderBrush="{Binding PosLockBrush}" BorderThickness="2"
+                            Command="{Binding SelectPosCommand}"
+                            CommandParameter="Teach_Postion_Lock">
+                                <StackPanel>
+                                    <TextBlock Text="Clamp" VerticalAlignment="Stretch" HorizontalAlignment="Center"/>
+                                    <TextBlock Text="Lock" VerticalAlignment="Stretch" HorizontalAlignment="Center"/>
+                                </StackPanel>
+                            </Button>
+                            <Button Margin="3" HorizontalAlignment="Stretch" Grid.Column="4" Grid.Row="1" Width="Auto" Height="Auto" BorderBrush="{Binding PosUnlockBrush}" BorderThickness="2"
+                            Command="{Binding SelectPosCommand}"
+                            CommandParameter="Teach_Postion_Unlock">
+                                <StackPanel>
+                                    <TextBlock Text="Clamp" VerticalAlignment="Stretch" HorizontalAlignment="Center"/>
+                                    <TextBlock Text="UnLock" VerticalAlignment="Stretch" HorizontalAlignment="Center"/>
+                                </StackPanel>
+                            </Button>
+                        </Grid>
+                    </Grid>
                 </Grid>
             </Grid>
         </Grid>
 
         <Grid Grid.Column="1" Background="#37474f">
             <StackPanel>
-                <Button Margin="7,20" HorizontalAlignment="Stretch" Height="90" BorderBrush="Gray" BorderThickness="2" Command="{Binding AxisSelectCommand}"
+                <Button Margin="7,5" HorizontalAlignment="Stretch" Height="90" BorderBrush="Gray" BorderThickness="2" Command="{Binding MoveToCommand}"
                         Style="{DynamicResource MaterialDesignRaisedButton}"
                         materialDesign:ShadowAssist.ShadowDepth="Depth5">
                     <StackPanel>
@@ -310,7 +412,7 @@
                 </Button>
 
 
-                <Button Margin="7,20" HorizontalAlignment="Stretch" Height="90" BorderBrush="Gray" BorderThickness="2" Command="{Binding AxisSelectCommand}"
+                <Button Margin="7,5" HorizontalAlignment="Stretch" Height="90" BorderBrush="Gray" BorderThickness="2" Command="{Binding CurrentToTargetCommand}"
                         Style="{DynamicResource MaterialDesignRaisedButton}"
                         materialDesign:ShadowAssist.ShadowDepth="Depth5">
                     <StackPanel>
@@ -321,15 +423,6 @@
                 </Button>
 
 
-                <Button Margin="7,20" HorizontalAlignment="Stretch" Height="90" BorderBrush="Orange" BorderThickness="2"
-                        Style="{DynamicResource MaterialDesignRaisedButton}"
-                        materialDesign:ShadowAssist.ShadowDepth="Depth5"
-                        Command="{Binding SelectedPosDataSave}">
-                    <StackPanel>
-                        <materialDesign:PackIcon Kind="CalendarExport" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="42" Width="auto"/>
-                        <TextBlock Text="SAVE" VerticalAlignment="Stretch" HorizontalAlignment="Center"/>
-                    </StackPanel>
-                </Button>
             </StackPanel>
         </Grid>
 
@@ -364,7 +457,20 @@
                     </StackPanel>
                 </Button>
 
-                <Button Margin="5" HorizontalAlignment="Stretch" Height="Auto" BorderBrush="Gray" BorderThickness="2" Command="{Binding CloseDialogCommand}" CommandParameter="true">
+            </StackPanel>
+
+            <StackPanel Orientation="Vertical" VerticalAlignment="Bottom">
+                <Button Margin="7,5" HorizontalAlignment="Stretch" Height="90" BorderBrush="Gray" BorderThickness="2"
+                        Style="{DynamicResource MaterialDesignRaisedButton}"
+                        materialDesign:ShadowAssist.ShadowDepth="Depth5"
+                        Command="{Binding SelectedPosDataSave}">
+                    <StackPanel>
+                        <materialDesign:PackIcon Kind="CalendarExport" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="42" Width="auto"/>
+                        <TextBlock Text="SAVE" VerticalAlignment="Stretch" HorizontalAlignment="Center"/>
+                    </StackPanel>
+                </Button>
+                
+                <Button Margin="7,0,7,7" HorizontalAlignment="Stretch" Height="90" BorderBrush="Gray" BorderThickness="2" Command="{Binding CloseDialogCommand}" CommandParameter="true">
                     <StackPanel>
                         <materialDesign:PackIcon Kind="ExitToApp" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="42" Width="auto"/>
                         <TextBlock Text="Close" VerticalAlignment="Stretch" HorizontalAlignment="Center" />

+ 297 - 162
Dev/OHV/OHV.Module.Interactivity/PopUp/LockServoViewModel.cs

@@ -1,4 +1,5 @@
 using OHV.Common.Events;
+using OHV.Common.Model;
 using OHV.Common.Shareds;
 using OHV.SqliteDAL;
 using Prism.Commands;
@@ -7,11 +8,11 @@ using Prism.Mvvm;
 using Prism.Services.Dialogs;
 using System;
 using System.Collections.Generic;
-using System.Drawing;
 using System.Linq;
-using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Input;
+using System.Windows.Media;
+using static OHV.Common.Events.AxisControlEventArgs;
 
 namespace OHV.Module.Interactivity.PopUp
 {
@@ -19,7 +20,7 @@ namespace OHV.Module.Interactivity.PopUp
     {
         private DelegateCommand<string> _closeDialogCommand;
         public DelegateCommand<string> CloseDialogCommand =>
-            _closeDialogCommand ?? ( _closeDialogCommand = new DelegateCommand<string>( CloseDialog ) );
+            _closeDialogCommand ?? (_closeDialogCommand = new DelegateCommand<string>(CloseDialog));
 
         private string _title = "LockServoView";
         public string Title
@@ -27,7 +28,7 @@ namespace OHV.Module.Interactivity.PopUp
             get { return this._title; }
             set
             {
-                this.SetProperty( ref this._title , value );
+                this.SetProperty(ref this._title, value);
             }
         }
 
@@ -35,7 +36,7 @@ namespace OHV.Module.Interactivity.PopUp
         public string SelectAxis
         {
             get => this._selectAxis;
-            set { this.SetProperty( ref this._selectAxis , value ); }
+            set { this.SetProperty(ref this._selectAxis, value); }
         }
 
         private string _selectedPosition = string.Empty;
@@ -44,7 +45,7 @@ namespace OHV.Module.Interactivity.PopUp
             get => this._selectedPosition;
             set
             {
-                this.SetProperty( ref this._selectedPosition , value );
+                this.SetProperty(ref this._selectedPosition, value);
             }
         }
 
@@ -53,21 +54,60 @@ namespace OHV.Module.Interactivity.PopUp
         public double TargetPosLockLeft
         {
             get { return this._targetPosLockLeft; }
-            set { this.SetProperty( ref this._targetPosLockLeft , value ); }
+            set { this.SetProperty(ref this._targetPosLockLeft, value); }
         }
 
         private double _currentLockLeft;
         public double CurrentLockLeft
         {
             get { return this._currentLockLeft; }
-            set { this.SetProperty( ref this._currentLockLeft , value ); }
+            set { this.SetProperty(ref this._currentLockLeft, value); }
         }
 
         private double _differenceLockLeft;
         public double DifferenceLockLeft
         {
             get { return this._differenceLockLeft; }
-            set { this.SetProperty( ref this._differenceLockLeft , value ); }
+            set { this.SetProperty(ref this._differenceLockLeft, value); }
+        }
+
+        Brush _leftAxisBrush = Brushes.Gray;
+        public Brush LeftAxisBrush
+        {
+            get { return this._leftAxisBrush; }
+            set { SetProperty(ref this._leftAxisBrush, value); }
+        }
+
+        private Brush posLockBrush = Brushes.Gray;
+
+        public Brush PosLockBrush
+        {
+            get { return posLockBrush; }
+            set { SetProperty(ref this.posLockBrush, value); }
+        }
+
+        private bool isLeftServoOn;
+
+        public bool IsLeftServoOn
+        {
+            get { return isLeftServoOn; }
+            set { SetProperty(ref isLeftServoOn, value); }
+        }
+
+        private bool isLeftServoOriginReturn;
+
+        public bool IsLeftServoOriginReturn
+        {
+            get { return isLeftServoOriginReturn; }
+            set { SetProperty(ref isLeftServoOriginReturn, value); }
+        }
+
+        private bool isLeftServoFalut;
+
+        public bool IsLeftServoFault
+        {
+            get { return isLeftServoFalut; }
+            set { SetProperty(ref isLeftServoFalut, value); }
         }
         #endregion
 
@@ -76,31 +116,63 @@ namespace OHV.Module.Interactivity.PopUp
         public double TargetPosLockRight
         {
             get { return this._targetPosLockRight; }
-            set { this.SetProperty( ref this._targetPosLockRight , value ); }
+            set { this.SetProperty(ref this._targetPosLockRight, value); }
         }
 
         private double _currentLockRight;
         public double CurrentLockRight
         {
             get { return this._currentLockRight; }
-            set { this.SetProperty( ref this._currentLockRight , value ); }
+            set { this.SetProperty(ref this._currentLockRight, value); }
         }
 
         private double _differenceLockRight;
         public double DifferenceLockRight
         {
             get { return this._differenceLockRight; }
-            set { this.SetProperty( ref this._differenceLockRight , value ); }
+            set { this.SetProperty(ref this._differenceLockRight, value); }
         }
-        #endregion
 
-        Brush _selectControl = Brushes.Gray;
-        public Brush SelectControl
+        Brush _rightAxisBrush = Brushes.Gray;
+        public Brush RightAxisBrush
+        {
+            get { return this._rightAxisBrush; }
+            set { SetProperty(ref this._rightAxisBrush, value); }
+        }
+
+        private Brush posUnlockBursh = Brushes.Gray;
+
+        public Brush PosUnlockBrush
+        {
+            get { return posUnlockBursh; }
+            set { SetProperty(ref this.posUnlockBursh, value); }
+        }
+
+        private bool isRightServoOn;
+        public bool IsRightServoOn
+        {
+            get { return isRightServoOn; }
+            set { SetProperty(ref isRightServoOn, value); }
+        }
+
+        private bool isRightServoOriginReturn;
+
+        public bool IsRightServoOriginReturn
+        {
+            get { return isRightServoOriginReturn; }
+            set { SetProperty(ref isRightServoOriginReturn, value); }
+        }
+
+        private bool isRightServoFalut;
+
+        public bool IsRightServoFault
         {
-            get { return this._selectControl; }
-            set { SetProperty( ref this._selectControl , value ); }
+            get { return isRightServoFalut; }
+            set { SetProperty(ref isRightServoFalut, value); }
         }
 
+        #endregion
+
         public ICommand SelectAxisCommand { get; set; }
         public ICommand KeyInTargetPosCommand { get; set; }
         public ICommand SelectPosCommand { get; set; }
@@ -119,279 +191,342 @@ namespace OHV.Module.Interactivity.PopUp
         MessageController messageController;
         SqliteManager sql;
 
-        public LockServoViewModel( IEventAggregator ea , MessageController _messageController , SqliteManager _sql )
+        public LockServoViewModel(IEventAggregator ea, MessageController _messageController, SqliteManager _sql)
         {
-            this.SelectAxisCommand = new DelegateCommand<object>( ExecuteSelectAxisCommand );
-            this.SelectPosCommand = new DelegateCommand<object>( ExecuteSelectPosCommand );
-            this.MoveToCommand = new DelegateCommand( ExecuteMoveToCommand );
-            this.CurrentToTargetCommand = new DelegateCommand( ExecuteCurrentToTargetCommand );
-            this.KeyInTargetPosCommand = new DelegateCommand<object>( ExecuteKeyInCommand );
+            this.SelectAxisCommand = new DelegateCommand<object>(ExecuteSelectAxisCommand);
+            this.SelectPosCommand = new DelegateCommand<object>(ExecuteSelectPosCommand);
+            this.MoveToCommand = new DelegateCommand(ExecuteMoveToCommand);
+            this.CurrentToTargetCommand = new DelegateCommand(ExecuteCurrentToTargetCommand);
+            this.KeyInTargetPosCommand = new DelegateCommand<object>(ExecuteKeyInCommand);
 
-            this.ServoOnCommand = new DelegateCommand<object>( ExecuteServoOnCommand );
-            this.ServoOffCommand = new DelegateCommand<object>( ExecuteServoOffCommand );
-            this.FaultResetCommand = new DelegateCommand<object>( ExecuteFaultResetCommand );
-            this.OriginCommand = new DelegateCommand<object>( ExecuteOriginCommand );
-            this.SelectedPosDataSave = new DelegateCommand<object>( ExecuteSelectedPosDataSave );
+            this.ServoOnCommand = new DelegateCommand<object>(ExecuteServoOnCommand);
+            this.ServoOffCommand = new DelegateCommand<object>(ExecuteServoOffCommand);
+            this.FaultResetCommand = new DelegateCommand<object>(ExecuteFaultResetCommand);
+            this.OriginCommand = new DelegateCommand<object>(ExecuteOriginCommand);
 
-            this.JogCommand = new DelegateCommand<object>( ExecuteJogCommand );
+            this.SelectedPosDataSave = new DelegateCommand<object>(ExecuteSelectedPosDataSave);
+            this.JogCommand = new DelegateCommand<object>(ExecuteJogCommand);
 
             this.eventAggregator = ea;
-            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Unsubscribe( UICallbackCommunication );
-            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Subscribe( UICallbackCommunication , ThreadOption.UIThread );
+            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Unsubscribe(UICallbackCommunication);
+            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Subscribe(UICallbackCommunication, ThreadOption.UIThread);
 
             this.messageController = _messageController;
 
             this.sql = _sql;
+
+            //초기 선택 축
+            this.SelectAxis = ConstString.AXIS_CARRIER_LOCK_LEFT;
+            this.LeftAxisBrush = Brushes.Orange;
+
+            //초기 Pos 선택
+            this.SelectedPosition = ConstString.TEACH_POSITION_LOCK;
+            this.PosLockBrush = Brushes.Orange;
         }
 
-        private void ExecuteSelectedPosDataSave( object obj )
+        private void ExecuteSelectedPosDataSave(object obj)
         {
             List<Common.Model.AxisPositionData> dataList = null;
 
-            this.messageController.ShowConfirmationPopupView( "Position Data Save ?" , r =>
-            {
-                if ( r.Result == ButtonResult.OK )
-                {
-                    if ( this.SelectAxis == ConstString.AXIS_CARRIER_LOCK_LEFT )
-                    {
-                        switch ( this.SelectedPosition )
-                        {
-                            case ConstString.TEACH_POSITION_LOCK:
-                                dataList = sql.AxisPositionDataDAL.GetKFromPostion( ConstString.TEACH_POSITION_LOCK );
-                                break;
-                            case ConstString.TEACH_POSITION_UNLOCK:
-                                dataList = sql.AxisPositionDataDAL.GetKFromPostion( ConstString.TEACH_POSITION_UNLOCK );
-                                break;
-                        }
-
-                        var sqlAxisLeft = dataList.Where( x => x.AxisName.Equals( ConstString.AXIS_CARRIER_LOCK_LEFT ) ).Single();
-                        sqlAxisLeft.Value = this.CurrentLockLeft;
-                        sql.AxisPositionDataDAL.Update( sqlAxisLeft );
-                    }
-                    else if ( this.SelectAxis == ConstString.AXIS_CARRIER_LOCK_RIGHT )
-                    {
-                        switch ( this.SelectedPosition )
-                        {
-                            case ConstString.TEACH_POSITION_LOCK:
-                                dataList = sql.AxisPositionDataDAL.GetKFromPostion( ConstString.TEACH_POSITION_LOCK );
-                                break;
-                            case ConstString.TEACH_POSITION_UNLOCK:
-                                dataList = sql.AxisPositionDataDAL.GetKFromPostion( ConstString.TEACH_POSITION_UNLOCK );
-                                break;
-                        }
-                        var sqlAxisRight = dataList.Where( x => x.AxisName.Equals( ConstString.AXIS_CARRIER_LOCK_RIGHT ) ).Single();
-                        sqlAxisRight.Value = this.CurrentLockLeft;
-                        sql.AxisPositionDataDAL.Update( sqlAxisRight );
-                    }
-                    else
-                    { }
-                }
-            } );
+            this.messageController.ShowConfirmationPopupView("Position Data Save ?", r =>
+          {
+              if (r.Result == ButtonResult.OK)
+              {
+                  if (this.SelectAxis == ConstString.AXIS_CARRIER_LOCK_LEFT)
+                  {
+                      switch (this.SelectedPosition)
+                      {
+                          case ConstString.TEACH_POSITION_LOCK:
+                              dataList = sql.AxisPositionDataDAL.GetKFromPostion(ConstString.TEACH_POSITION_LOCK);
+                              break;
+                          case ConstString.TEACH_POSITION_UNLOCK:
+                              dataList = sql.AxisPositionDataDAL.GetKFromPostion(ConstString.TEACH_POSITION_UNLOCK);
+                              break;
+                      }
+
+                      var sqlAxisLeft = dataList.Where(x => x.AxisName.Equals(ConstString.AXIS_CARRIER_LOCK_LEFT)).Single();
+                      sqlAxisLeft.Value = this.CurrentLockLeft;
+                      sql.AxisPositionDataDAL.Update(sqlAxisLeft);
+                  }
+                  else if (this.SelectAxis == ConstString.AXIS_CARRIER_LOCK_RIGHT)
+                  {
+                      switch (this.SelectedPosition)
+                      {
+                          case ConstString.TEACH_POSITION_LOCK:
+                              dataList = sql.AxisPositionDataDAL.GetKFromPostion(ConstString.TEACH_POSITION_LOCK);
+                              break;
+                          case ConstString.TEACH_POSITION_UNLOCK:
+                              dataList = sql.AxisPositionDataDAL.GetKFromPostion(ConstString.TEACH_POSITION_UNLOCK);
+                              break;
+                      }
+                      var sqlAxisRight = dataList.Where(x => x.AxisName.Equals(ConstString.AXIS_CARRIER_LOCK_RIGHT)).Single();
+                      sqlAxisRight.Value = this.CurrentLockLeft;
+                      sql.AxisPositionDataDAL.Update(sqlAxisRight);
+                  }
+                  else
+                  { }
+              }
+          });
         }
 
-        private void ExecuteJogCommand( object obj )
+        private void ExecuteJogCommand(object obj)
         {
             var msg = new AxisControlEventArgs
             {
-                Dir = AxisControlEventArgs.eEventDir.ToBack ,
-                Kind = AxisControlEventArgs.eAxisControlKind.Jog ,
-                AxisName = this.SelectAxis ,
+                Dir = AxisControlEventArgs.eEventDir.ToBack,
+                Kind = AxisControlEventArgs.eAxisControlKind.Jog,
+                AxisName = this.SelectAxis,
             };
 
-            if ( obj.ToString().Equals( "+" ) )
+            if (obj.ToString().Equals("+"))
                 msg.JogDir = AxisControlEventArgs.eJogMoveDir.Positive;
             else
                 msg.JogDir = AxisControlEventArgs.eJogMoveDir.Negative;
 
-            this.PublishEvent( msg );
+            this.PublishEvent(msg);
         }
 
-        void PublishEvent( AxisControlEventArgs args )
+        void PublishEvent(AxisControlEventArgs args)
         {
-            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish( args );
+            args.Dir = AxisControlEventArgs.eEventDir.ToBack;
+            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish(args);
         }
 
-        void UICallbackCommunication( AxisControlEventArgs args )
+        void UICallbackCommunication(AxisControlEventArgs args)
         {
-            if ( args.Dir == AxisControlEventArgs.eEventDir.ToFront )
+            if (args.Dir == AxisControlEventArgs.eEventDir.ToFront)
             {
-                switch ( args.Kind )
+                switch (args.Kind)
                 {
                     case AxisControlEventArgs.eAxisControlKind.Stop:
                         break;
                     case AxisControlEventArgs.eAxisControlKind.EStop:
                         break;
                     case AxisControlEventArgs.eAxisControlKind.Move:
+                        RspMove(args);
                         break;
                     case AxisControlEventArgs.eAxisControlKind.Jog:
                         break;
-                    case AxisControlEventArgs.eAxisControlKind.CurrentPosition:
-                        if ( args.AxisName.Equals( ConstString.AXIS_CARRIER_LOCK_LEFT ) )
-                            this.CurrentLockLeft = args.CurrentPosition;
-                        else
-                            this.CurrentLockRight = args.CurrentPosition;
-                        break;
                     case AxisControlEventArgs.eAxisControlKind.ServoOn:
                         break;
                     case AxisControlEventArgs.eAxisControlKind.ServoOff:
                         break;
+                    case AxisControlEventArgs.eAxisControlKind.NONE:
+                        break;
+                    case AxisControlEventArgs.eAxisControlKind.OriginReturn:
+                        break;
+                    case AxisControlEventArgs.eAxisControlKind.ReqCurrentPosition:
+                        break;
+                    case AxisControlEventArgs.eAxisControlKind.ReqStopCurrentPosition:
+                        break;
+                    case AxisControlEventArgs.eAxisControlKind.FaultReset:
+                        break;
+                    case AxisControlEventArgs.eAxisControlKind.AxisState:
+                        AxisState(args);
+                        break;
                     default:
                         break;
                 }
             }
         }
 
-        private void ExecuteOriginCommand( object obj )
+        private void AxisState(AxisControlEventArgs args)
         {
-            var msg = new AxisControlEventArgs
-            {
-                Dir = AxisControlEventArgs.eEventDir.ToBack ,
-                Kind = AxisControlEventArgs.eAxisControlKind.OriginReturn ,
-                AxisName = this.SelectAxis ,
-            };
+            var left = args.Args["Left"] as AxisState;
+            var right = args.Args["Right"] as AxisState;
+
+            this.IsLeftServoOn = left.IsServoOn;
+            this.IsLeftServoOriginReturn = left.IsOriginReturn;
+            this.IsLeftServoFault = left.IsAmpFault;
+            this.CurrentLockLeft = left.CurrentPosition;
+
+            this.IsRightServoOn = right.IsServoOn;
+            this.IsRightServoOriginReturn = right.IsOriginReturn;
+            this.IsRightServoFault = right.IsAmpFault;
+            this.CurrentLockRight = right.CurrentPosition;
+        }
+
+        private void RspMove(AxisControlEventArgs args)
+        {
+            string msg = string.Empty;
 
-            if ( obj.ToString().Equals( "Left" ) )
-                msg.Axis = AxisControlEventArgs.eAxises.LEFT;
+            if (args.Result.IsSuccess)
+            {
+                if (args.PosDir == AxisControlEventArgs.ePosDir.Lock)
+                    msg = "Clamp Lock Success";
+                else
+                    msg = "Clamp Unlock Success";
+            }
             else
-                msg.Axis = AxisControlEventArgs.eAxises.RIGHT;
+            {
+                var error = args.Result.Errors.FirstOrDefault();
+                var alarm = error.Metadata["Alarm"] as Alarm;
+                msg = alarm.Name + " " + alarm.Text;
+            }
 
-            this.PublishEvent( msg );
-        }   
+            this.messageController.ShowNotificationView(msg);
+        }
 
-        private void ExecuteFaultResetCommand( object obj )
+        private void ExecuteOriginCommand(object obj)
         {
             var msg = new AxisControlEventArgs
             {
-                Dir = AxisControlEventArgs.eEventDir.ToBack ,
-                Kind = AxisControlEventArgs.eAxisControlKind.FaultReset ,
-                AxisName = this.SelectAxis ,
+                Dir = AxisControlEventArgs.eEventDir.ToBack,
+                Kind = AxisControlEventArgs.eAxisControlKind.OriginReturn,
+                AxisName = this.SelectAxis,
             };
 
-            if ( obj.ToString().Equals( "Left" ) )
-                msg.Axis = AxisControlEventArgs.eAxises.LEFT;
-            else
-                msg.Axis = AxisControlEventArgs.eAxises.RIGHT;
-
-            this.PublishEvent( msg );
+            this.PublishEvent(msg);
         }
 
-        private void ExecuteServoOffCommand( object obj )
+        private void ExecuteFaultResetCommand(object obj)
         {
             var msg = new AxisControlEventArgs
             {
-                Dir = AxisControlEventArgs.eEventDir.ToBack ,
-                Kind = AxisControlEventArgs.eAxisControlKind.ServoOff ,
-                AxisName = this.SelectAxis ,
+                Dir = AxisControlEventArgs.eEventDir.ToBack,
+                Kind = AxisControlEventArgs.eAxisControlKind.FaultReset,
+                AxisName = this.SelectAxis,
             };
 
-            if ( obj.ToString().Equals( "Left" ) )
-                msg.Axis = AxisControlEventArgs.eAxises.LEFT;
-            else
-                msg.Axis = AxisControlEventArgs.eAxises.RIGHT;
-
-            this.PublishEvent( msg );
+            this.PublishEvent(msg);
         }
 
-        private void ExecuteServoOnCommand( object obj )
+        private void ExecuteServoOffCommand(object obj)
         {
             var msg = new AxisControlEventArgs
             {
-                Dir = AxisControlEventArgs.eEventDir.ToBack ,
-                Kind = AxisControlEventArgs.eAxisControlKind.ServoOn ,
-                AxisName = this.SelectAxis ,
+                Dir = AxisControlEventArgs.eEventDir.ToBack,
+                Kind = AxisControlEventArgs.eAxisControlKind.ServoOff,
+                AxisName = this.SelectAxis,
             };
 
-            if ( obj.ToString().Equals( "Left" ) )
-                msg.Axis = AxisControlEventArgs.eAxises.LEFT;
-            else
-                msg.Axis = AxisControlEventArgs.eAxises.RIGHT;
+            this.PublishEvent(msg);
+        }
+
+        private void ExecuteServoOnCommand(object obj)
+        {
+            var msg = new AxisControlEventArgs
+            {
+                Dir = AxisControlEventArgs.eEventDir.ToBack,
+                Kind = AxisControlEventArgs.eAxisControlKind.ServoOn,
+                AxisName = this.SelectAxis,
+            };
 
-            this.PublishEvent( msg );
+            this.PublishEvent(msg);
         }
 
-        private void ExecuteKeyInCommand( object obj )
+        private void ExecuteKeyInCommand(object obj)
         {
-            if ( obj.ToString().Equals( "Left" ) )
+            if (obj.ToString().Equals("Left"))
             {
                 var numPad = new CalcuratorView();
-                var result = numPad.ShowDialog( this.TargetPosLockLeft );
+                var result = numPad.ShowDialog(this.TargetPosLockLeft);
                 this.TargetPosLockLeft = result;
             }
             else
             {
                 var numPad = new CalcuratorView();
-                var result = numPad.ShowDialog( this.TargetPosLockRight );
+                var result = numPad.ShowDialog(this.TargetPosLockRight);
                 this.TargetPosLockRight = result;
             }
         }
 
-        private void ExecuteCurrentToTargetCommand( )
+        private void ExecuteCurrentToTargetCommand()
         {
-            this.TargetPosLockLeft = this.CurrentLockLeft;
-            this.TargetPosLockRight = this.CurrentLockRight;
+            this.messageController.ShowConfirmationPopupView("Current Position To Target Position ?", r =>
+            {
+                if (r.Result == ButtonResult.OK)
+                {
+                    this.TargetPosLockLeft = this.CurrentLockLeft;
+                    this.TargetPosLockRight = this.CurrentLockRight;
+                }
+            });
         }
 
-        private async void ExecuteMoveToCommand( )
+        private void ExecuteMoveToCommand()
         {
-            await Task.Run( ( ) =>
+            this.messageController.ShowConfirmationPopupView($"Clamp Move To {this.SelectedPosition}", r =>
             {
-               //Axis.Move(this.SelectPosition);
-           } );
+                if (r.Result == ButtonResult.OK)
+                {
+                    var msg = new AxisControlEventArgs();
+                    msg.Kind = AxisControlEventArgs.eAxisControlKind.Move;
+
+                    if (SelectedPosition.Equals(ConstString.TEACH_POSITION_LOCK))
+                        msg.PosDir = AxisControlEventArgs.ePosDir.Lock;
+                    else
+                        msg.PosDir = AxisControlEventArgs.ePosDir.UnLock;
+
+                    this.PublishEvent(msg);
+                }
+            });
         }
 
-        private void ExecuteSelectPosCommand( object obj )
+        private void ExecuteSelectPosCommand(object obj)
         {
             this.SelectedPosition = obj.ToString();
 
-            switch ( this.SelectedPosition )
+            if (obj.Equals(ConstString.TEACH_POSITION_LOCK))
+            {
+                this.PosLockBrush = Brushes.Orange;
+                this.PosUnlockBrush = Brushes.Gray;
+            }
+            else
             {
-                case "Lock":
-                    break;
-                case "UnLock":
-                    break;
-                default:
-                    break;
+                this.PosLockBrush = Brushes.Gray;
+                this.PosUnlockBrush = Brushes.Orange;
             }
         }
 
-        private void ExecuteSelectAxisCommand( object obj )
+        private void ExecuteSelectAxisCommand(object obj)
         {
-            this.SelectAxis = obj.ToString();
+            if (obj.ToString().Equals(ConstString.AXIS_CARRIER_LOCK_LEFT))
+            {
+                this.LeftAxisBrush = Brushes.Orange;
+                this.RightAxisBrush = System.Windows.Media.Brushes.Gray;
+                this.SelectAxis = ConstString.AXIS_CARRIER_LOCK_LEFT;
+            }
+            else
+            {
+                this.RightAxisBrush = Brushes.Orange;
+                this.LeftAxisBrush = System.Windows.Media.Brushes.Gray;
+                this.SelectAxis = ConstString.AXIS_CARRIER_LOCK_RIGHT;
+            }
         }
 
         #region Dialog 
-        public bool CanCloseDialog( )
+        public bool CanCloseDialog()
         {
             //throw new NotImplementedException();
             return true;
         }
 
-        public void OnDialogClosed( )
+        public void OnDialogClosed()
         {
-            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish( new AxisControlEventArgs { Dir = AxisControlEventArgs.eEventDir.ToBack , Kind = AxisControlEventArgs.eAxisControlKind.ReqStopCurrentPosition } );
-            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Unsubscribe( UICallbackCommunication );
+            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish(new AxisControlEventArgs { Dir = AxisControlEventArgs.eEventDir.ToBack, Kind = AxisControlEventArgs.eAxisControlKind.ReqStopCurrentPosition });
+            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Unsubscribe(UICallbackCommunication);
         }
 
-        public void OnDialogOpened( IDialogParameters parameters )
+        public void OnDialogOpened(IDialogParameters parameters)
         {
-            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish( new AxisControlEventArgs { Dir = AxisControlEventArgs.eEventDir.ToBack , Kind = AxisControlEventArgs.eAxisControlKind.ReqCurrentPosition } );
+            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish(new AxisControlEventArgs { Dir = AxisControlEventArgs.eEventDir.ToBack, Kind = AxisControlEventArgs.eAxisControlKind.ReqCurrentPosition });
         }
 
-        public virtual void RaiseRequestClose( IDialogResult dialogResult )
+        public virtual void RaiseRequestClose(IDialogResult dialogResult)
         {
-            RequestClose?.Invoke( dialogResult );
+            RequestClose?.Invoke(dialogResult);
         }
 
-        private void CloseDialog( string parameter )
+        private void CloseDialog(string parameter)
         {
             ButtonResult result = ButtonResult.None;
 
-            if ( parameter?.ToLower() == "true" )
+            if (parameter?.ToLower() == "true")
                 result = ButtonResult.OK;
-            else if ( parameter?.ToLower() == "false" )
+            else if (parameter?.ToLower() == "false")
                 result = ButtonResult.Cancel;
 
-            RaiseRequestClose( new DialogResult( result ) );
+            RaiseRequestClose(new DialogResult(result));
         }
         #endregion
     }

+ 1 - 0
Dev/OHV/OHV.Module.Interactivity/packages.config

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
   <package id="CommonServiceLocator" version="2.0.4" targetFramework="net45" />
+  <package id="DynamicExpresso.Core" version="2.3.1" targetFramework="net45" />
   <package id="MaterialDesignColors" version="1.2.2" targetFramework="net45" />
   <package id="MaterialDesignThemes" version="3.0.1" targetFramework="net45" />
   <package id="Prism.Core" version="7.2.0.1422" targetFramework="net45" />

+ 1 - 0
Dev/OHV/OHV.SqliteDAL/OHVDbInitializer.cs

@@ -168,6 +168,7 @@ namespace OHV.SqliteDAL
                 new Alarm { AlarmId = 20, Kind = eAlarmKind.Axis, Name = "Conveyor",       Text="Loading Position Wrong",                  Solution="", Description="", Level = eAlarmLevel.Falut, },
                 new Alarm { AlarmId = 21, Kind = eAlarmKind.Axis, Name = "Conveyor",       Text="Unloading Position Wrong",                Solution="", Description="", Level = eAlarmLevel.Falut, },
                 new Alarm { AlarmId = 22, Kind = eAlarmKind.Axis, Name = "Init",           Text="Vehicle Drive Error",                     Solution="", Description="", Level = eAlarmLevel.Falut, },
+                new Alarm { AlarmId = 23, Kind = eAlarmKind.Axis, Name = "EStop",          Text="EStop",                                   Solution="", Description="", Level = eAlarmLevel.Falut, },
             });
 
             //context.Set<HisAlarm>().Add(new HisAlarm { AlarmId = 1, OccurTime = DateTime.Now.AddDays(-10) });

+ 10 - 0
Dev/OHV/OHV.Vehicle/Concept/D_MainWindowViewModel.cs

@@ -210,6 +210,7 @@ namespace OHV.Vehicle.Concept
             this.StartCommand = new DelegateCommand(ExecuteStartCommand);
             this.StopCommand = new DelegateCommand(ExecuteStopCommand);
             this.AlarmResetCommand = new DelegateCommand( ExecuteAlarmResetCommand);
+            this.EmergencyStopCommand = new DelegateCommand(ExecuteEStop);
 
             DispatcherTimer dateTimer = new DispatcherTimer();
             dateTimer.Tick += (object sender, EventArgs e) =>
@@ -238,6 +239,15 @@ namespace OHV.Vehicle.Concept
             GSG.NET.Quartz.QuartzUtils.Invoke("RESOURCE_CHECK", GSG.NET.Quartz.QuartzUtils.GetExpnSecond(1), QuzOnResourceUsage);
         }
 
+        private void ExecuteEStop()
+        {
+            var msg = new VCSMessageEventArgs
+            {
+                Kind = VCSMessageEventArgs.eVCSMessageKind.ReqEStop,
+            };
+            vcsMessagePublisher.Publish(msg);
+        }
+
         void QuzOnResourceUsage()
         {
             this.CPU = GSG.NET.OSView.Mgnt.CpuUseRate();

+ 4 - 0
Dev/OHV/VehicleControlSystem/ControlLayer/Axis/EzAxis.cs

@@ -383,6 +383,10 @@ namespace VehicleControlSystem.ControlLayer.Axis
 
         public override int ServoOn()
         {
+            int result = EziMOTIONPlusELib.FAS_IsSlaveExist(Config.AxisNo);
+            if (result != EziMOTIONPlusELib.FMM_OK)
+                return result;
+
             return EziMOTIONPlusELib.FAS_ServoEnable( Config.AxisNo, 1 );
         }
 

+ 96 - 30
Dev/OHV/VehicleControlSystem/ControlLayer/Clamp.cs

@@ -7,11 +7,13 @@ using FluentResults;
 using GSG.NET.Concurrent;
 using GSG.NET.Logging;
 using OHV.Common.Events;
+using OHV.Common.Model;
 using OHV.Common.Shareds;
 using OHV.SqliteDAL;
 using Prism.Events;
 using VehicleControlSystem.ControlLayer.Axis;
 using VehicleControlSystem.ControlLayer.Lib.EziPlusE;
+using static OHV.Common.Events.AxisControlEventArgs;
 
 namespace VehicleControlSystem.ControlLayer
 {
@@ -42,38 +44,36 @@ namespace VehicleControlSystem.ControlLayer
         {
             if (args.Dir == AxisControlEventArgs.eEventDir.ToBack)
             {
-                switch ( args.Kind )
+                switch (args.Kind)
                 {
                     case AxisControlEventArgs.eAxisControlKind.Stop:
                         break;
                     case AxisControlEventArgs.eAxisControlKind.EStop:
                         break;
                     case AxisControlEventArgs.eAxisControlKind.Move:
-                        this.ReqOrderByMove( args );
+                        this.ReqOrderByMove(args);
                         break;
                     case AxisControlEventArgs.eAxisControlKind.Jog:
-                        this.ReqJog( args );
-                        break;
-                    case AxisControlEventArgs.eAxisControlKind.CurrentPosition:
+                        this.ReqJog(args);
                         break;
                     case AxisControlEventArgs.eAxisControlKind.ServoOn:
-                        this.ReqServoOn( args );
+                        this.ReqServoOn(args);
                         break;
                     case AxisControlEventArgs.eAxisControlKind.ServoOff:
-                        this.ReqServoOff( args );
+                        this.ReqServoOff(args);
                         break;
                     case AxisControlEventArgs.eAxisControlKind.ReqCurrentPosition:
-                        this.ReqStartCurrentPosition();
+                        this.ReqStartAxisState();
                         break;
                     case AxisControlEventArgs.eAxisControlKind.ReqStopCurrentPosition:
                         this.taskCancel.Cancel();
                         this.taskCancel.WaitAll();
                         break;
                     case AxisControlEventArgs.eAxisControlKind.OriginReturn:
-                        this.ReqOriginReturn( args );
+                        this.ReqOriginReturn(args);
                         break;
                     case AxisControlEventArgs.eAxisControlKind.FaultReset:
-                        this.ReqFaultReset( args );
+                        this.ReqFaultReset(args);
                         break;
                     default:
                         break;
@@ -83,10 +83,11 @@ namespace VehicleControlSystem.ControlLayer
 
         void PublishEvent(AxisControlEventArgs args)
         {
+            args.Dir = AxisControlEventArgs.eEventDir.ToFront;
             this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish(args);
         }
 
-        #region Requst Method
+        #region Request Method
         private void ReqFaultReset(AxisControlEventArgs args)
         {
             var axis = this.axes.Where(x => x.Config.AxisName.Equals(args.AxisName)).FirstOrDefault();
@@ -95,9 +96,10 @@ namespace VehicleControlSystem.ControlLayer
             var msg = new AxisControlEventArgs
             {
                 AxisName = args.AxisName,
+                Dir = AxisControlEventArgs.eEventDir.ToFront,
                 Kind = AxisControlEventArgs.eAxisControlKind.FaultReset,
             };
-            msg.Result = Results.Ok("Servo On");
+            msg.Result = Results.Ok("Servo Fault Reset");
             this.PublishEvent(msg);
         }
 
@@ -109,6 +111,7 @@ namespace VehicleControlSystem.ControlLayer
             var msg = new AxisControlEventArgs
             {
                 AxisName = args.AxisName,
+                Dir = AxisControlEventArgs.eEventDir.ToFront,
                 Kind = AxisControlEventArgs.eAxisControlKind.ServoOn,
             };
             msg.Result = Results.Ok("Servo On");
@@ -123,13 +126,14 @@ namespace VehicleControlSystem.ControlLayer
             var msg = new AxisControlEventArgs
             {
                 AxisName = args.AxisName,
+                Dir = AxisControlEventArgs.eEventDir.ToFront,
                 Kind = AxisControlEventArgs.eAxisControlKind.ServoOff,
             };
             msg.Result = Results.Ok("Servo Off");
             this.PublishEvent(msg);
         }
 
-        void ReqStartCurrentPosition()
+        void ReqStartAxisState()
         {
             var task = Task.Factory.StartNew(() =>
             {
@@ -141,23 +145,40 @@ namespace VehicleControlSystem.ControlLayer
                     LockUtils.Wait(500);
 
                     int index = 0;
-                    this.axes.ForEach(a =>
+                    //this.axes.ForEach(a =>
+                    //{
+                    //    if (beforePosition[index] != a.CurrentPosition)
+                    //    {
+                    //        beforePosition[index] = a.CurrentPosition;
+
+                    //        var msg = new AxisControlEventArgs
+                    //        {
+                    //            AxisName = a.Config.AxisName,
+                    //            Dir = AxisControlEventArgs.eEventDir.ToFront,
+                    //            Kind = AxisControlEventArgs.eAxisControlKind.CurrentPosition,
+                    //            CurrentPosition = a.CurrentPosition,
+                    //        };
+                    //        this.PublishEvent(msg);
+                    //    }
+                    //    index++;
+                    //});
+                    var msg = new AxisControlEventArgs();
+                    msg.Kind = AxisControlEventArgs.eAxisControlKind.AxisState;
+                    msg.Args = new Dictionary<string, object>();
+                    this.axes.ForEach(a => 
                     {
-                        if (beforePosition[index] != a.CurrentPosition)
-                        {
-                            beforePosition[index] = a.CurrentPosition;
-
-                            var msg = new AxisControlEventArgs
-                            {
-                                AxisName = a.Config.AxisName,
-                                Dir = AxisControlEventArgs.eEventDir.ToFront,
-                                Kind = AxisControlEventArgs.eAxisControlKind.CurrentPosition,
-                                CurrentPosition = a.CurrentPosition,
-                            };
-                            this.PublishEvent(msg);
-                        }
-                        index++;
+                        var state = new AxisState();
+                        state.IsServoOn = a.IsServoOn();
+                        state.IsOriginReturn = a.IsOriginReturn();
+                        state.IsAmpFault = a.IsAmpFault();
+                        state.CurrentPosition = GSG.NET.Utils.NumUtils.Random(0, 3000);
+
+                        if (a.Config.AxisName.Equals(ConstString.AXIS_CARRIER_LOCK_LEFT))
+                            msg.Args.Add("Left", state);
+                        else
+                            msg.Args.Add("Right", state);
                     });
+                    this.PublishEvent(msg);
                 }
             });
 
@@ -193,13 +214,58 @@ namespace VehicleControlSystem.ControlLayer
             this.PublishEvent(msg);
         }
 
-        void ReqOrderByMove( AxisControlEventArgs arg )
+        void ReqOrderByMove(AxisControlEventArgs arg)
         {
-            /*Lock & UnLock Manual 동시에 Move 사용*/
+            var msg = new AxisControlEventArgs();
+            msg.Kind = AxisControlEventArgs.eAxisControlKind.Move;
+            msg.PosDir = arg.PosDir;
+            int result = 0;
+
+            if (arg.PosDir == AxisControlEventArgs.ePosDir.Lock)
+            {
+                result = Lock_Sync();
+                if (result != 0)
+                {
+                    var alarm = this.sql.AlarmDAL.GetK(result);
+                    if (alarm == null)
+                        alarm = new Alarm() { Name = "Unknown Alarm", Text = "Not define" };
+
+                    var error = new Error().WithMetadata("Alarm", alarm);
+                    msg.Result = Results.Fail(error);
+                }
+                else
+                {
+                    msg.Result = Results.Ok();
+                }
+            }
+            else
+            {
+                result = Unlock_Sync();
+                if (result != 0)
+                {
+                    var alarm = this.sql.AlarmDAL.GetK(result);
+                    if (alarm == null)
+                        alarm = new Alarm() { Name = "Unknown Alarm", Text = "Not define" };
+
+                    var error = new Error().WithMetadata("Alarm", alarm);
+                    msg.Result = Results.Fail(error);
+                }
+                else
+                {
+                    msg.Result = Results.Ok();
+                }
+            }
+
+            this.PublishEvent(msg);
         }
 
         #endregion
 
+        public void ClampEStop()
+        {
+            this.axes.ForEach(x => { x.EmergencyStop(); });
+        }
+
         void CreateAxis()
         {
             sql.AxisConfigDAL.All.ForEach(config =>

+ 80 - 1
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -435,6 +435,14 @@ namespace VehicleControlSystem.ControlLayer
         #endregion
 
         #region Control Action Method
+        public void EStop()
+        {
+            //Clamp EStop
+            this.clamp.ClampEStop();
+            this.motion.EStop();
+
+            this.autoManager.ProcessAlarm(23);
+        }
 
         void Move( SubCmd sub )
         {
@@ -574,12 +582,83 @@ namespace VehicleControlSystem.ControlLayer
 
         /// <summary>
         /// Battery Charge
-        /// 
+        /// 충전 시 PIO 를 해야 함.
         /// </summary>
         /// <param name="sub"></param>
         /// <returns></returns>
         public bool BatteryCharge( SubCmd sub )
         {
+            var route = sql.RouteDal.GetRoute(sub.TargetID);
+
+            if (!CorrectPosition(route, this.CurrentPosition))
+            {
+                this.autoManager.ProcessAlarm(21);
+                return false; //Alarm
+            }
+
+            var pioTimeout = sql.ConfigDal.GetValueToInt(ConstString.PIOTimeOut);
+
+            PIOClear();
+            loggerPIO.I($"Start Unload PIO - [{sub.TargetID}]");
+            this.OnPIOStart?.Invoke(false);
+
+            if (!this.iO.IsOn("IN_PIO_READY"))
+            {
+                loggerPIO.E("[Port] - 1 Ready not On");
+                this.OnFailReport?.Invoke(eFailCode.UnlaodPIOInterlockTimeout);
+                //return 0;
+            }
+
+            this.iO.WriteOutputIO("OUT_PIO_READY", true);
+            loggerPIO.I("[Vehicle] - 1 Ready On");
+
+            if (!this.iO.WaitChangeInputIO(true, pioTimeout, "IN_PIO_RECEIVE_RUN"))
+            {
+                PIOClear();
+                loggerPIO.E("[Port] - 2 Receive CV Run Timeout");
+                this.OnFailReport?.Invoke(eFailCode.UnlaodPIOInterlockTimeout);
+                //return 0;
+            }
+
+            this.iO.WriteOutputIO("OUT_PIO_SENDING_RUN", true);
+            loggerPIO.I("[Vehicle] - 2 Send Run On");
+
+            this.SetConveyorSpeed(true);
+            this.OnOffConveyor(true);
+            this.OnConveyorStart?.Invoke(false);
+
+            var sTime = SwUtils.CurrentTimeMillis;
+            while (true)
+            {
+                if (SwUtils.Gt(sTime, 20 * ConstUtils.ONE_SECOND))
+                {
+                    PIOClear();
+                    this.OnOffConveyor(false, true);
+                    loggerPIO.E("[Port] Conveyor Wait Time Out");
+                    this.OnFailReport?.Invoke(eFailCode.UnlaodPIOInterlockTimeout);
+
+                    //if (IsDetectedLoadStart() || IsDetectedCenter()) //중간에 걸려 있다고 생각해서 알람 처리.
+                    //    return 12; //Conveyor Moving Timeout
+                    //else
+                    //    return 0;
+                }
+
+                if (this.iO.IsOn("IN_PIO_RECEIVE_COMPLITE"))
+                    break;
+            }
+
+            if (!IsDetectedCenter())
+                this.OnCarrierDetected?.Invoke(false);
+
+            this.OnOffConveyor(false); //Stop
+            this.OnConveyorStop?.Invoke(false);
+            PIOClear();
+
+            this.iO.WriteOutputIO("OUT_PIO_SEND_COMPLITE", true);
+            this.iO.WriteOutputIO("OUT_PIO_SEND_COMPLITE", false, 1000);
+
+            this.OnUnloadComplete?.Invoke();
+
 
             return true;
         }

+ 1 - 2
Dev/OHV/VehicleControlSystem/Managers/AutoManager.cs

@@ -23,7 +23,7 @@ namespace VehicleControlSystem.Managers
         bool isThreadAlive = false;
 
         IIO iO = null;
-        bool IsErrorProcessing = false;
+        public bool IsErrorProcessing { get; set; } = false;
         IEventAggregator eventAggregator = null;
         SqliteManager sql = null;
 
@@ -206,7 +206,6 @@ namespace VehicleControlSystem.Managers
                     switch (this.AutoModeStateProperty)
                     {
                         case eAutoModeState.ErrorStop:
-                            if ( !IsErrorProcessing )
                                 this.AutoModeStateProperty = eAutoModeState.WaitStop;
                             break;
                         case eAutoModeState.WaitStop:

+ 15 - 0
Dev/OHV/VehicleControlSystem/VCSystem.cs

@@ -108,15 +108,30 @@ namespace VehicleControlSystem
                 case VCSMessageEventArgs.eVCSMessageKind.ModelPropertyChange:
                     break;
                 case VCSMessageEventArgs.eVCSMessageKind.ReqAlarmReset:
+                    ReqAlarmReset();
                     break;
                 case VCSMessageEventArgs.eVCSMessageKind.ReqVehicleModeChange:
                     this.ReqVehicleModeChange(msg);
                     break;
+                case VCSMessageEventArgs.eVCSMessageKind.ReqEStop:
+                    ReqEStop();
+                    break;
                 default:
                     break;
             }
         }
 
+        private void ReqAlarmReset()
+        {
+            if (this.autoManager.IsErrorProcessing)
+                this.autoManager.IsErrorProcessing = false;
+        }
+
+        private void ReqEStop()
+        {
+            this.vehicle.EStop();
+        }
+
         private void ReqVehicleModeChange(VCSMessageEventArgs msg)
         {
             GUIMessageEventArgs reply;