浏览代码

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

# Conflicts:
#	Dev/OHV/OHV.Module.Interactivity/PopUp/DriveServoViewModel.cs
#	Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs
ys-hwang 6 年之前
父节点
当前提交
61b612d3d3

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

@@ -178,6 +178,7 @@ namespace OHV.Common.Events
             DriveON,
             DriveOFF,
             JOG,
+            VehicleState,
 
         }
 
@@ -195,7 +196,7 @@ namespace OHV.Common.Events
 
         
         public double CurrentPosition { get; set; }
-        public string PositionTag { get; set; }
+        public int TargetRouteID { get; set; }
 
         public eJogMoveDir JogDir { get; set; }
         public eEventDir EventDir { get; set; }

+ 4 - 3
Dev/OHV/OHV.Common/Model/VehicleState.cs

@@ -9,8 +9,9 @@ namespace OHV.Common.Model
     public class VehicleState
     {
         public string VehicleID { get; set; }
-        public int CurrentTag { get; set; }
-        public double CurrentScale { get; set; }
-
+        public string CurrentTag { get; set; }
+        public double CurrentPosition { get; set; }
+        public double CurrentSpeed { get; set; }
+        public double CurrentTorque { get; set; }
     }
 }

+ 0 - 1
Dev/OHV/OHV.Common/OHV.Common.csproj

@@ -79,7 +79,6 @@
     <Compile Include="Model\SelectionItem.cs" />
     <Compile Include="Model\SelectionList.cs" />
     <Compile Include="Model\SubCmd.cs" />
-    <Compile Include="Model\VehicleState.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Shareds\ConstString.cs" />
     <Compile Include="Shareds\SharedEnumType.cs" />

+ 4 - 0
Dev/OHV/OHV.Module.Interactivity/OHV.Module.Interactivity.csproj

@@ -241,6 +241,10 @@
       <Project>{122D81C8-9AB9-4CED-80D2-9C4F2F9DEB4C}</Project>
       <Name>OHV.SqliteDAL</Name>
     </ProjectReference>
+    <ProjectReference Include="..\VehicleControlSystem\VehicleControlSystem.csproj">
+      <Project>{73BAB40E-FC7D-4AB5-85CA-B4CF221DFBD1}</Project>
+      <Name>VehicleControlSystem</Name>
+    </ProjectReference>
   </ItemGroup>
   <ItemGroup>
     <None Include="packages.config" />

+ 65 - 2
Dev/OHV/OHV.Module.Interactivity/PopUp/ConveyorControlViewModel.cs

@@ -1,4 +1,5 @@
 using OHV.Common.Events;
+using OHV.Common.Shareds;
 using Prism.Commands;
 using Prism.Events;
 using Prism.Mvvm;
@@ -9,6 +10,8 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Input;
+using VehicleControlSystem.ControlLayer.IO;
+using static OHV.Common.Events.AxisControlEventArgs;
 
 namespace OHV.Module.Interactivity.PopUp
 {
@@ -36,24 +39,67 @@ namespace OHV.Module.Interactivity.PopUp
 
         IEventAggregator eventAggregator;
         MessageController messageController;
+
+        List<BitBlock> allIOList = new List<BitBlock>();
+
         public ConveyorControlViewModel( IEventAggregator _ea , MessageController _msg)
         {
             this.eventAggregator = _ea;
 
             /*IO Publish Event*/
-            this.eventAggregator.GetEvent<IOControlPubSubEvent>().Unsubscribe( UICallbackCommunivation );
-            this.eventAggregator.GetEvent<IOControlPubSubEvent>().Subscribe( UICallbackCommunivation , ThreadOption.UIThread );
+            //this.eventAggregator.GetEvent<IOControlPubSubEvent>().Unsubscribe( UICallbackCommunivation );
+            //this.eventAggregator.GetEvent<IOControlPubSubEvent>().Subscribe( UICallbackCommunivation , ThreadOption.UIThread );
 
             /*Lock&UnLock Publish Event*/
             this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Unsubscribe( AxisUICallbackCommunication );
             this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Subscribe( AxisUICallbackCommunication , ThreadOption.UIThread );
 
+            /*GUI Pubsub Event*/
+            this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Unsubscribe( UICallbackCommunication );
+            this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Subscribe( UICallbackCommunication, ThreadOption.UIThread );
+
             this.messageController = _msg;
 
             this.ConveyorRunCommand = new DelegateCommand<object>( ExecuteCvCommand );
             this.PosMoveCommand = new DelegateCommand<object>( ExecutePosMoveCommand );
         }
 
+        private void UICallbackCommunication( GUIMessageEventArgs _args )
+        {
+            //TODO:[20/03/20 ys-hwang] Conveyor 에서 Vehicle 상태를 쓸 항목이 있으런지? 쓴다면 State만??
+            if( _args.Kind == GUIMessageEventArgs.eGUIMessageKind.ModelPropertyChange)
+            {
+                if( _args.MessageKey.Equals(MessageKey.Vehicle))
+                {
+
+                }
+            }
+
+            switch ( _args.Kind )
+            {
+                case GUIMessageEventArgs.eGUIMessageKind.ModelPropertyChange:
+                    break;
+                case GUIMessageEventArgs.eGUIMessageKind.RspIOObject:
+                    break;
+                case GUIMessageEventArgs.eGUIMessageKind.RspIOMapList:
+                    break;
+                case GUIMessageEventArgs.eGUIMessageKind.RspCommandList:
+                    break;
+                case GUIMessageEventArgs.eGUIMessageKind.RspAutoModeChange:
+                    break;
+                case GUIMessageEventArgs.eGUIMessageKind.RspManualModeChange:
+                    break;
+                case GUIMessageEventArgs.eGUIMessageKind.RspAlarmReset:
+                    break;
+                case GUIMessageEventArgs.eGUIMessageKind.RspVehicleModeChange:
+                    break;
+                case GUIMessageEventArgs.eGUIMessageKind.RspEStop:
+                    break;
+                case GUIMessageEventArgs.eGUIMessageKind.RspVihicleState:
+                    break;
+            }
+        }
+
         private void ExecutePosMoveCommand( object obj )
         {
             this.messageController.ShowConfirmationPopupView( "Carrier Move To ?" , r =>
@@ -119,11 +165,28 @@ namespace OHV.Module.Interactivity.PopUp
                     case AxisControlEventArgs.eAxisControlKind.FaultReset:
                         break;
                     case AxisControlEventArgs.eAxisControlKind.AxisState:
+                        AxisState( _args );
                         break;
                 }
             }
         }
 
+        private void AxisState( AxisControlEventArgs args )
+        {
+            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 UICallbackCommunivation( IOControlEventArgs _args )
         {
             if ( _args.EventDir == IOControlEventArgs.eEventDir.ToBack )

+ 2 - 2
Dev/OHV/OHV.Module.Interactivity/PopUp/DriveServoView.xaml

@@ -197,8 +197,8 @@
                     <TextBlock><Run Text="{Binding DifferenceDrive, StringFormat=0.000, FallbackValue=0.000}"/></TextBlock>
                 </Button>
                     
-                <StackPanel Grid.Column="2" Grid.Row="1" Grid.ColumnSpan="3" Grid.RowSpan="3"  Orientation="Horizontal" HorizontalAlignment="Center" Margin="102,52,102,31" >
-                    <Button Margin="0,30" Width="150"
+                <StackPanel Grid.Column="2" Grid.Row="1" Grid.ColumnSpan="3" Grid.RowSpan="3"  Orientation="Horizontal" HorizontalAlignment="Center" Margin="82,52,43,31" Width="379"  >
+                    <Button Margin="20,30" Width="150"
                         HorizontalAlignment="Stretch" 
                         Height="Auto" 
                         BorderBrush="{Binding SteeringLeftBrushProperty}" 

+ 19 - 4
Dev/OHV/OHV.Module.Interactivity/PopUp/DriveServoViewModel.cs

@@ -285,12 +285,21 @@ namespace OHV.Module.Interactivity.PopUp
                         break;
                     case DriveControlEventArgs.eControlKind.JOG:
                         break;
+                    case DriveControlEventArgs.eControlKind.VehicleState:
+                        ResponseVehicleState(args);
+                        break;
                     default:
                         break;
                 }
             }
         }
 
+        private void ResponseVehicleState(DriveControlEventArgs args)
+        {
+            var state = CastTo<VehicleState>.From<object>(args.Args);
+            this.CurrentDrive = state.CurrentPosition;
+        }
+
         private void ResponseMove( DriveControlEventArgs args )
         {
             var msg = string.Empty;
@@ -500,15 +509,17 @@ namespace OHV.Module.Interactivity.PopUp
 
         private void ExecuteMoveToCommand()
         {
-            this.messageController.ShowConfirmationPopupView( "Move To Pos ?" , r =>
+            this.messageController.ShowConfirmationPopupView( "Move To Selected Position ?" , r =>
             {
                 if ( r.Result == ButtonResult.OK )
                 {
+                    var ll = this.RouteList.Where(x => x.IsSelected).FirstOrDefault();
+
                     var msg = new DriveControlEventArgs
                     {
-                        EventDir = DriveControlEventArgs.eEventDir.ToBack ,
-                        ControlKind = DriveControlEventArgs.eControlKind.MOVE ,
-                        //PositionTag = 
+                        EventDir = DriveControlEventArgs.eEventDir.ToBack,
+                        ControlKind = DriveControlEventArgs.eControlKind.MOVE,
+                        TargetRouteID = ll.Id,
                     };
 
                     this.PublishEvent( msg );
@@ -544,7 +555,11 @@ namespace OHV.Module.Interactivity.PopUp
             };
             this.PublishEvent(msg);
 
+<<<<<<< HEAD
          //   this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Publish( new DriveControlEventArgs { EventDir = DriveControlEventArgs.eEventDir.ToBack , ControlKind = DriveControlEventArgs.eControlKind.ReqCurrentPos } );
+=======
+            this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Publish( new DriveControlEventArgs { EventDir = DriveControlEventArgs.eEventDir.ToBack , ControlKind = DriveControlEventArgs.eControlKind.VehicleState } );
+>>>>>>> c46c4387a8ef1f5ab1ba5e83769ae8f84c3891dc
         }
 
         private void CloseDialog(string parameter)

+ 554 - 0
Dev/OHV/OHV.Module.Interactivity/PopUp/DriveServoViewModel.cs.orig

@@ -0,0 +1,554 @@
+using GSG.NET.Extensions;
+using OHV.Common.Events;
+using OHV.Common.Model;
+using OHV.Common.Shareds;
+using OHV.SqliteDAL;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace OHV.Module.Interactivity.PopUp
+{
+    public class DriveServoViewModel : BindableBase, IDialogAware
+    {
+        private DelegateCommand<string> _closeDialogCommand;
+        public DelegateCommand<string> CloseDialogCommand =>
+            _closeDialogCommand ?? (_closeDialogCommand = new DelegateCommand<string>(CloseDialog));
+
+        private string _title = "DriveServoView";
+        public string Title
+        {
+            get { return this._title; }
+            set
+            {
+                this.SetProperty(ref this._title, value);
+            }
+        }
+
+        private string _selectedPosition = string.Empty;
+        public string SelectedPosition
+        {
+            get => this._selectedPosition;
+            set
+            {
+                this.SetProperty(ref this._selectedPosition, value);
+            }
+        }
+
+        private string _selectDirection = string.Empty;
+        public string SelectDirection
+        {
+            get => this._selectDirection;
+            set { this.SetProperty(ref this._selectDirection, value); }
+        }
+
+        #region Motor Left Binding Value
+        private double _driveTargetPos;
+        public double DriveTargetPos
+        {
+            get { return this._driveTargetPos; }
+            set { this.SetProperty(ref this._driveTargetPos , value); }
+        }
+
+        private double _currentDrive;
+        public double CurrentDrive
+        {
+            get { return this._currentDrive; }
+            set { this.SetProperty(ref this._currentDrive, value); }
+        }
+
+        private double _differenceDrive;
+        public double DifferenceDrive
+        {
+            get { return this._differenceDrive; }
+            set { this.SetProperty(ref this._differenceDrive, value); }
+        }
+
+        private double _jogVelocity;
+        public double JogVelocity
+        {
+            get { return this._jogVelocity; }
+            set { this.SetProperty(ref this._jogVelocity, value); }
+        }
+        #endregion
+
+        public event Action<IDialogResult> RequestClose;
+
+        public ICommand SelectAxisCommand { get; set; }
+        public ICommand KeyInTargetPosCommand { get; set; }
+        public ICommand SelectPosCommand { get; set; }
+        public ICommand MoveToCommand { get; set; }
+        public ICommand CurrentToTargetCommand { get; set; }
+        public ICommand ServoOnCommand { get; set; }
+        public ICommand ServoOffCommand { get; set; }
+        public ICommand FaultResetCommand { get; set; }
+        public ICommand OriginCommand { get; set; }
+
+        public IEventAggregator eventAggregator;
+        public ICommand PositionAddCommand { get; set; }
+        public ICommand PositionDeleteCommand { get; set; }
+        public ICommand PositionSaveCommand { get; set; }
+        public ICommand SteeringCWCommand { get; set; }
+        public ICommand SteeringCCWCommand { get; set; }
+        public ICommand SelectedDirection { get; set; }
+        public ICommand JogVelPopupCommand { get; set; }
+        public ICommand JogCommand { get; set; }
+
+        #region Brushes
+        private Brush steeringLeftBrush = Brushes.Gray;
+        public Brush SteeringLeftBrushProperty
+        {
+            get { return steeringLeftBrush; }
+            set { SetProperty(ref this.steeringLeftBrush, value); }
+        }
+
+        private Brush steeringRightBrush = Brushes.Gray;
+        public Brush SteeringRightBrushProperty
+        {
+            get { return steeringRightBrush; }
+            set { SetProperty(ref this.steeringRightBrush, value); }
+        }
+        #endregion
+
+        private ObservableCollection<Route> _routeList;
+        public ObservableCollection<Route> RouteList
+        {
+            get { return this._routeList; }
+            set { SetProperty(ref this._routeList, value); }
+        }
+
+        public SqliteDAL.DAL.AxisPositionDataDAL axisPositionDataDal;
+        SqliteManager sql;
+        MessageController messageController;
+
+        public DriveServoViewModel(IEventAggregator _ea, SqliteManager _sql, MessageController _messageController)
+        {
+            this.eventAggregator = _ea;
+            this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Unsubscribe( DriveControlCallBack );
+            this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Subscribe( DriveControlCallBack , ThreadOption.UIThread );
+
+            /*상태 회신을 받기 위함*/
+            this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Unsubscribe( UICallBackCommunication );
+            this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Subscribe( UICallBackCommunication , ThreadOption.UIThread );
+
+            this.sql = _sql;
+            this.RouteList = new ObservableCollection<Route>(sql.RouteDal.All);
+
+            this.messageController = _messageController;
+
+            this.SelectPosCommand = new DelegateCommand<object>(ExecuteSelectPosCommand);
+            this.MoveToCommand = new DelegateCommand(ExecuteMoveToCommand);
+            this.CurrentToTargetCommand = new DelegateCommand(ExecuteCurrentToTargetCommand);
+            this.KeyInTargetPosCommand = new DelegateCommand<object>(ExecuteKeyInCommadn);
+
+            this.ServoOnCommand = new DelegateCommand(ExecuteServoOnCommand);
+            this.ServoOffCommand = new DelegateCommand(ExecuteServoOffCommand);
+            this.FaultResetCommand = new DelegateCommand(ExecuteFaultResetCommand);
+            this.OriginCommand = new DelegateCommand(ExecuteOriginCommand);
+
+            this.PositionAddCommand = new DelegateCommand(ExecutePositionAddCommand);
+            this.PositionDeleteCommand = new DelegateCommand(ExecutePositionDeleteCommand);
+            this.PositionSaveCommand = new DelegateCommand(ExecutePositionSaveCommand);
+
+            this.SelectedDirection = new DelegateCommand<object>(ExecuteSelectedDirection);
+            this.SteeringCWCommand = new DelegateCommand<object>(ExecuteSteeringCWCommand);
+            this.SteeringCCWCommand = new DelegateCommand<object>(ExecuteSteeringCCWCommand);
+
+            this.JogVelPopupCommand = new DelegateCommand(ExecuteJogVelPopupCommand);
+            this.JogCommand = new DelegateCommand<object>(ExecuteJogCommand);
+        }
+
+        private void UICallBackCommunication( GUIMessageEventArgs obj )
+        {
+            //Property 상태가 바뀔때 마다 표현만 하면 된다?
+            if ( obj.Kind == GUIMessageEventArgs.eGUIMessageKind.ModelPropertyChange )
+            {
+                if ( obj.MessageKey.Equals( MessageKey.Vehicle ) )
+                {
+                    switch ( obj.ModelPropertyName )
+                    {
+                        case "SteeringState":
+                            {
+                                var dir = CastTo<eSteeringState>.From<object>( obj.Args );
+                                this.ChangeSteeringDirection( dir );
+                            }
+                            break;
+<<<<<<< HEAD
+                        case "VehicleStateProperty":
+                            {
+                                var v = CastTo<eVehicleState>.From<object>( obj.Args );
+                                this.ChagneVehicleState( v );
+                            }
+                            break;
+                        case "ObstacleStateProperty":
+                            break;
+=======
+                        case "CurrentPosition":
+                            {
+                                var v = CastTo<double>.From<object>(obj.Args);
+                            }
+                            break;
+>>>>>>> 944428eda961c69237f00f4b0ce920edb41b0a2e
+                        default:
+                            break;
+                    }
+                }
+            }
+        }
+
+        private void ChagneVehicleState( eVehicleState v )
+        {
+            //TODO:[20/03/20 ys-hwang] Vehicle Manual Move 할때? 상태를 보고 해야?, 아니면 Manual 이니까???? 
+            // 아니면 busy 상태 확인만 ?
+            switch ( v )
+            {
+                case eVehicleState.None:
+                    break;
+                case eVehicleState.Idle:
+                    break;
+                case eVehicleState.Move:
+                    break;
+                case eVehicleState.Load:
+                    break;
+                case eVehicleState.Unload:
+                    break;
+                case eVehicleState.Charge:
+                    break;
+                case eVehicleState.Abnormal:
+                    break;
+                case eVehicleState.Blocked:
+                    break;
+                case eVehicleState.Decelerate:
+                    break;
+            }
+        }
+
+        private void DriveControlCallBack( DriveControlEventArgs args)
+        {
+            //TODO:[20/03/19 ys-hwang] Drive UI return msg popup
+
+            if (args.EventDir == DriveControlEventArgs.eEventDir.ToFront)
+            {
+                switch ( args.ControlKind )
+                {
+                    case DriveControlEventArgs.eControlKind.MOVE:
+                        ResponseMove(args);
+                        break;
+                    case DriveControlEventArgs.eControlKind.STOP:
+                        break;
+                    case DriveControlEventArgs.eControlKind.Steering:
+                        //if ( args.Result.IsSuccess )
+                        //{
+                        //    var dir = args.Result.ToResult<DriveControlEventArgs.eMoveDir>().Value;
+                        //    this.ChangeSteeringDirection( dir == DriveControlEventArgs.eMoveDir.LEFT ? true : false );
+                        //}
+                        break;
+                    case DriveControlEventArgs.eControlKind.SteeringState:
+                        //if ( args.Result.IsSuccess )
+                        //{
+                        //    var dir = args.Result.ToResult<DriveControlEventArgs.eMoveDir>().Value;
+                        //    this.ChangeSteeringDirection( dir == DriveControlEventArgs.eMoveDir.LEFT ? true : false );
+                        //}
+                        break;
+                    case DriveControlEventArgs.eControlKind.ReqCurrentPos:
+                        this.CurrentDrive = args.CurrentPosition;
+                        break;
+                    case DriveControlEventArgs.eControlKind.ReqStopCurrentPos:
+                        break;
+                    case DriveControlEventArgs.eControlKind.FaultReset:
+                        break;
+                    case DriveControlEventArgs.eControlKind.DriveON:
+                        break;
+                    case DriveControlEventArgs.eControlKind.DriveOFF:
+                        break;
+                    case DriveControlEventArgs.eControlKind.JOG:
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        private void ResponseMove( DriveControlEventArgs args )
+        {
+            var msg = string.Empty;
+            if(args.Result.IsSuccess)
+            {
+                msg = "Move Successs";
+            }
+            else
+            {
+                var error = args.Result.Errors.FirstOrDefault();
+                var alarm = error.Metadata[ "Alarm" ] as Alarm;
+                msg = alarm.Name + " " + alarm.Text;
+            }
+
+            this.messageController.ShowNotificationView( msg );
+        }
+
+        void PublishEvent(DriveControlEventArgs args)
+        {
+            this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Publish(args);
+        }
+
+        void ChangeSteeringDirection(eSteeringState state)
+        {
+            if ( state == eSteeringState.Left )
+            {
+                this.SteeringLeftBrushProperty = ( System.Windows.Media.Brush )new System.Windows.Media.BrushConverter().ConvertFromString( "#FF00FFD3" );
+                this.SteeringRightBrushProperty = Brushes.Gray;
+            }
+            else if ( state == eSteeringState.Right )
+            {
+                this.SteeringLeftBrushProperty = Brushes.Gray;
+                this.SteeringRightBrushProperty = ( System.Windows.Media.Brush )new System.Windows.Media.BrushConverter().ConvertFromString( "#FF00FFD3" );
+            }
+            else
+            {
+                this.SteeringLeftBrushProperty = Brushes.Gray;
+                this.SteeringRightBrushProperty = Brushes.Gray;
+            }
+        }
+
+        #region Execute Method
+        private void ExecuteJogCommand(object obj)
+        {
+            var msg = new DriveControlEventArgs
+            {
+                EventDir = DriveControlEventArgs.eEventDir.ToBack,
+                ControlKind = DriveControlEventArgs.eControlKind.JOG,
+            };
+
+            if ( obj.ToString().Equals( "+" ) )
+                msg.JogDir = DriveControlEventArgs.eJogMoveDir.Positive;
+            else
+                msg.JogDir = DriveControlEventArgs.eJogMoveDir.Negative;
+
+            this.PublishEvent( msg );
+        }
+
+        private void ExecuteJogVelPopupCommand()
+        {
+            var numPad = new CalcuratorView();
+            var result = numPad.ShowDialog(this.JogVelocity);
+
+            this.JogVelocity = result;
+        }
+
+        private void ExecuteSelectedDirection(object obj)
+        {
+            this.SelectDirection = obj.ToString();
+        }
+
+        private void ExecuteSteeringCCWCommand(object obj)
+        {
+            var msg = new DriveControlEventArgs
+            {
+                EventDir = DriveControlEventArgs.eEventDir.ToBack,
+                ControlKind = DriveControlEventArgs.eControlKind.Steering,
+            };
+
+            if (obj.ToString().Equals("CCW"))
+                msg.MoveDir = DriveControlEventArgs.eMoveDir.RIGHT;
+            else
+                msg.MoveDir = DriveControlEventArgs.eMoveDir.LEFT;
+
+            this.PublishEvent(msg);
+        }
+
+        private void ExecuteSteeringCWCommand(object obj)
+        {
+            var msg = new DriveControlEventArgs
+            {
+                EventDir = DriveControlEventArgs.eEventDir.ToBack,
+                ControlKind = DriveControlEventArgs.eControlKind.Steering,
+            };
+
+            if (obj.ToString().Equals("CW"))
+                msg.MoveDir = DriveControlEventArgs.eMoveDir.LEFT;
+            else
+                msg.MoveDir = DriveControlEventArgs.eMoveDir.RIGHT;
+
+            this.PublishEvent(msg);
+        }
+
+        private void ExecutePositionSaveCommand()
+        { 
+            this.messageController.ShowConfirmationPopupView("Save To Data ?", r =>
+            {
+              if (r.Result == ButtonResult.OK)
+              {
+                    //TODO:[20/03/18 ys-hwang] DB Table Update
+              }
+            });
+        }
+
+        private void ExecutePositionDeleteCommand()
+        {
+            this.messageController.ShowConfirmationPopupView( "Select To Delete ?" , r =>
+            {
+                if ( r.Result == ButtonResult.OK )
+                {
+                    var deleteList = new List<Route>();
+
+                    foreach ( var item in this.RouteList )
+                    {
+                        if ( item.IsSelected )
+                            deleteList.Add( item );
+                    }
+                    deleteList.ForEach( x => { this.RouteList.Remove( x ); } );
+                }
+            } );
+        }
+
+        private void ExecutePositionAddCommand()
+        {
+            this.messageController.ShowConfirmationPopupView( "Position Add ?" , r =>
+            {
+                if ( r.Result == ButtonResult.OK )
+                {
+                    this.RouteList.Add( new Route() );
+
+                    this.messageController.ShowNotificationView( "Create Success" );
+                }
+            } );
+        }
+
+        private void ExecuteKeyInCommadn(object obj)
+        {
+            var numPad = new CalcuratorView();
+            var result = numPad.ShowDialog(this.DriveTargetPos );
+            this.DriveTargetPos = result;
+        }
+
+        private void ExecuteOriginCommand()
+        {
+            this.messageController.ShowConfirmationPopupView( "Origin ?" , r =>
+            {
+                if ( r.Result == ButtonResult.OK )
+                {
+                    //TODO: How to use
+                }
+            } );
+        }
+
+        private void ExecuteFaultResetCommand()
+        {
+            var msg = new DriveControlEventArgs
+            {
+                EventDir = DriveControlEventArgs.eEventDir.ToBack ,
+                ControlKind = DriveControlEventArgs.eControlKind.FaultReset ,
+            };
+
+            this.PublishEvent( msg );
+        }
+
+        private void ExecuteServoOffCommand()
+        {
+            var msg = new DriveControlEventArgs
+            {
+                EventDir = DriveControlEventArgs.eEventDir.ToBack ,
+                ControlKind = DriveControlEventArgs.eControlKind.DriveOFF ,
+            };
+
+            this.PublishEvent( msg );
+        }
+
+        private void ExecuteServoOnCommand()
+        {
+            var msg = new DriveControlEventArgs
+            {
+                EventDir = DriveControlEventArgs.eEventDir.ToBack ,
+                ControlKind = DriveControlEventArgs.eControlKind.DriveON ,
+            };
+
+            this.PublishEvent( msg );
+        }
+
+        private void ExecuteCurrentToTargetCommand()
+        {
+            this.messageController.ShowConfirmationPopupView( "Current To Target ?" , r =>
+            {
+                if ( r.Result == ButtonResult.OK )
+                {
+                    this.DriveTargetPos = this.CurrentDrive;
+                }
+            } );
+        }
+
+        private void ExecuteMoveToCommand()
+        {
+            this.messageController.ShowConfirmationPopupView( "Move To Pos ?" , r =>
+            {
+                if ( r.Result == ButtonResult.OK )
+                {
+                    var msg = new DriveControlEventArgs
+                    {
+                        EventDir = DriveControlEventArgs.eEventDir.ToBack ,
+                        ControlKind = DriveControlEventArgs.eControlKind.MOVE ,
+                        //PositionTag = 
+                    };
+
+                    this.PublishEvent( msg );
+                }
+            } );
+        }
+
+        private void ExecuteSelectPosCommand(object obj)
+        {
+            this.SelectedPosition = obj.ToString();
+        }
+
+        #endregion
+
+        #region Dialog Function
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+            this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Publish( new DriveControlEventArgs { EventDir = DriveControlEventArgs.eEventDir.ToBack , ControlKind = DriveControlEventArgs.eControlKind.ReqStopCurrentPos } );
+            this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Unsubscribe( DriveControlCallBack );
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+            var msg = new DriveControlEventArgs
+            {
+                EventDir = DriveControlEventArgs.eEventDir.ToBack,
+                ControlKind = DriveControlEventArgs.eControlKind.SteeringState,
+            };
+            this.PublishEvent(msg);
+
+            this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Publish( new DriveControlEventArgs { EventDir = DriveControlEventArgs.eEventDir.ToBack , ControlKind = DriveControlEventArgs.eControlKind.ReqCurrentPos } );
+        }
+
+        private void CloseDialog(string parameter)
+        {
+            ButtonResult result = ButtonResult.None;
+
+            if (parameter?.ToLower() == "true")
+                result = ButtonResult.OK;
+            else if (parameter?.ToLower() == "false")
+                result = ButtonResult.Cancel;
+
+            RaiseRequestClose(new DialogResult(result));
+        }
+
+        public virtual void RaiseRequestClose(IDialogResult dialogResult)
+        {
+            RequestClose?.Invoke(dialogResult);
+        }
+        #endregion
+    }
+}

+ 189 - 165
Dev/OHV/OHV.Module.Interactivity/PopUp/LockServoViewModel.cs

@@ -20,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
@@ -28,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 );
             }
         }
 
@@ -36,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;
@@ -45,7 +45,7 @@ namespace OHV.Module.Interactivity.PopUp
             get => this._selectedPosition;
             set
             {
-                this.SetProperty(ref this._selectedPosition, value);
+                this.SetProperty( ref this._selectedPosition , value );
             }
         }
 
@@ -54,28 +54,28 @@ 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); }
+            set { SetProperty( ref this._leftAxisBrush , value ); }
         }
 
         private Brush posLockBrush = Brushes.Gray;
@@ -83,7 +83,7 @@ namespace OHV.Module.Interactivity.PopUp
         public Brush PosLockBrush
         {
             get { return posLockBrush; }
-            set { SetProperty(ref this.posLockBrush, value); }
+            set { SetProperty( ref this.posLockBrush , value ); }
         }
 
         private bool isLeftServoOn;
@@ -91,7 +91,7 @@ namespace OHV.Module.Interactivity.PopUp
         public bool IsLeftServoOn
         {
             get { return isLeftServoOn; }
-            set { SetProperty(ref isLeftServoOn, value); }
+            set { SetProperty( ref isLeftServoOn , value ); }
         }
 
         private bool isLeftServoOriginReturn;
@@ -99,7 +99,7 @@ namespace OHV.Module.Interactivity.PopUp
         public bool IsLeftServoOriginReturn
         {
             get { return isLeftServoOriginReturn; }
-            set { SetProperty(ref isLeftServoOriginReturn, value); }
+            set { SetProperty( ref isLeftServoOriginReturn , value ); }
         }
 
         private bool isLeftServoFalut;
@@ -107,7 +107,7 @@ namespace OHV.Module.Interactivity.PopUp
         public bool IsLeftServoFault
         {
             get { return isLeftServoFalut; }
-            set { SetProperty(ref isLeftServoFalut, value); }
+            set { SetProperty( ref isLeftServoFalut , value ); }
         }
         #endregion
 
@@ -116,28 +116,28 @@ 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 ); }
         }
 
         Brush _rightAxisBrush = Brushes.Gray;
         public Brush RightAxisBrush
         {
             get { return this._rightAxisBrush; }
-            set { SetProperty(ref this._rightAxisBrush, value); }
+            set { SetProperty( ref this._rightAxisBrush , value ); }
         }
 
         private Brush posUnlockBursh = Brushes.Gray;
@@ -145,14 +145,14 @@ namespace OHV.Module.Interactivity.PopUp
         public Brush PosUnlockBrush
         {
             get { return posUnlockBursh; }
-            set { SetProperty(ref this.posUnlockBursh, value); }
+            set { SetProperty( ref this.posUnlockBursh , value ); }
         }
 
         private bool isRightServoOn;
         public bool IsRightServoOn
         {
             get { return isRightServoOn; }
-            set { SetProperty(ref isRightServoOn, value); }
+            set { SetProperty( ref isRightServoOn , value ); }
         }
 
         private bool isRightServoOriginReturn;
@@ -160,7 +160,7 @@ namespace OHV.Module.Interactivity.PopUp
         public bool IsRightServoOriginReturn
         {
             get { return isRightServoOriginReturn; }
-            set { SetProperty(ref isRightServoOriginReturn, value); }
+            set { SetProperty( ref isRightServoOriginReturn , value ); }
         }
 
         private bool isRightServoFalut;
@@ -168,7 +168,7 @@ namespace OHV.Module.Interactivity.PopUp
         public bool IsRightServoFault
         {
             get { return isRightServoFalut; }
-            set { SetProperty(ref isRightServoFalut, value); }
+            set { SetProperty( ref isRightServoFalut , value ); }
         }
 
         #endregion
@@ -191,25 +191,28 @@ 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.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.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( AxisUICallbackCommunication );
+            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Subscribe( AxisUICallbackCommunication , ThreadOption.UIThread );
+
+            this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Unsubscribe( UICallbackCommunication );
+            this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Subscribe( UICallbackCommunication , ThreadOption.UIThread );
 
             this.messageController = _messageController;
 
@@ -224,86 +227,97 @@ namespace OHV.Module.Interactivity.PopUp
             this.PosLockBrush = Brushes.Orange;
         }
 
-        private void ExecuteSelectedPosDataSave(object obj)
+        private void UICallbackCommunication( GUIMessageEventArgs obj )
         {
-            List<Common.Model.AxisPositionData> dataList = null;
+            if ( obj.Kind == GUIMessageEventArgs.eGUIMessageKind.ModelPropertyChange )
+            {
+                if ( obj.MessageKey.Equals( MessageKey.Vehicle ) )
+                {
 
-            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 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
+                    { }
+                }
+            } );
         }
 
-        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 )
         {
             args.Dir = AxisControlEventArgs.eEventDir.ToBack;
-            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish(args);
+            this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish( args );
         }
 
-        void UICallbackCommunication(AxisControlEventArgs args)
+        void AxisUICallbackCommunication( 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);
+                        RspMove( args );
                         break;
                     case AxisControlEventArgs.eAxisControlKind.Jog:
                         break;
@@ -314,15 +328,25 @@ namespace OHV.Module.Interactivity.PopUp
                     case AxisControlEventArgs.eAxisControlKind.NONE:
                         break;
                     case AxisControlEventArgs.eAxisControlKind.OriginReturn:
+                        //TODO:[20/03/20 sy-hwang] Origin 시작 시 UI Lock 여부 ?
                         break;
                     case AxisControlEventArgs.eAxisControlKind.ReqCurrentPosition:
                         break;
                     case AxisControlEventArgs.eAxisControlKind.ReqStopCurrentPosition:
                         break;
                     case AxisControlEventArgs.eAxisControlKind.FaultReset:
+                        {
+                            var msg = string.Empty;
+                            if ( args.Result.IsSuccess )
+                                msg = $" {this.SelectAxis} Reset Success ";
+                            else
+                                msg = $" {this.SelectAxis} Reset Failed ";
+
+                            this.messageController.ShowNotificationView( msg );
+                        }
                         break;
                     case AxisControlEventArgs.eAxisControlKind.AxisState:
-                        AxisState(args);
+                        AxisState( args );
                         break;
                     default:
                         break;
@@ -330,10 +354,10 @@ namespace OHV.Module.Interactivity.PopUp
             }
         }
 
-        private void AxisState(AxisControlEventArgs args)
+        private void AxisState( AxisControlEventArgs args )
         {
-            var left = args.Args["Left"] as AxisState;
-            var right = args.Args["Right"] as AxisState;
+            var left = args.Args[ "Left" ] as AxisState;
+            var right = args.Args[ "Right" ] as AxisState;
 
             this.IsLeftServoOn = left.IsServoOn;
             this.IsLeftServoOriginReturn = left.IsOriginReturn;
@@ -346,13 +370,13 @@ namespace OHV.Module.Interactivity.PopUp
             this.CurrentLockRight = right.CurrentPosition;
         }
 
-        private void RspMove(AxisControlEventArgs args)
+        private void RspMove( AxisControlEventArgs args )
         {
             string msg = string.Empty;
 
-            if (args.Result.IsSuccess)
+            if ( args.Result.IsSuccess )
             {
-                if (args.PosDir == AxisControlEventArgs.ePosDir.Lock)
+                if ( args.PosDir == AxisControlEventArgs.ePosDir.Lock )
                     msg = "Clamp Lock Success";
                 else
                     msg = "Clamp Unlock Success";
@@ -360,120 +384,120 @@ namespace OHV.Module.Interactivity.PopUp
             else
             {
                 var error = args.Result.Errors.FirstOrDefault();
-                var alarm = error.Metadata["Alarm"] as Alarm;
+                var alarm = error.Metadata[ "Alarm" ] as Alarm;
                 msg = alarm.Name + " " + alarm.Text;
             }
 
-            this.messageController.ShowNotificationView(msg);
+            this.messageController.ShowNotificationView( msg );
         }
 
-        private void ExecuteOriginCommand(object obj)
+        private void ExecuteOriginCommand( object obj )
         {
             var msg = new AxisControlEventArgs
             {
-                Dir = AxisControlEventArgs.eEventDir.ToBack,
-                Kind = AxisControlEventArgs.eAxisControlKind.OriginReturn,
-                AxisName = this.SelectAxis,
+                Dir = AxisControlEventArgs.eEventDir.ToBack ,
+                Kind = AxisControlEventArgs.eAxisControlKind.OriginReturn ,
+                AxisName = this.SelectAxis ,
             };
 
-            this.PublishEvent(msg);
+            this.PublishEvent( msg );
         }
 
-        private void ExecuteFaultResetCommand(object obj)
+        private void ExecuteFaultResetCommand( object obj )
         {
             var msg = new AxisControlEventArgs
             {
-                Dir = AxisControlEventArgs.eEventDir.ToBack,
-                Kind = AxisControlEventArgs.eAxisControlKind.FaultReset,
-                AxisName = this.SelectAxis,
+                Dir = AxisControlEventArgs.eEventDir.ToBack ,
+                Kind = AxisControlEventArgs.eAxisControlKind.FaultReset ,
+                AxisName = this.SelectAxis ,
             };
 
-            this.PublishEvent(msg);
+            this.PublishEvent( msg );
         }
 
-        private void ExecuteServoOffCommand(object obj)
+        private void ExecuteServoOffCommand( object obj )
         {
             var msg = new AxisControlEventArgs
             {
-                Dir = AxisControlEventArgs.eEventDir.ToBack,
-                Kind = AxisControlEventArgs.eAxisControlKind.ServoOff,
-                AxisName = this.SelectAxis,
+                Dir = AxisControlEventArgs.eEventDir.ToBack ,
+                Kind = AxisControlEventArgs.eAxisControlKind.ServoOff ,
+                AxisName = this.SelectAxis ,
             };
 
-            this.PublishEvent(msg);
+            this.PublishEvent( msg );
         }
 
-        private void ExecuteServoOnCommand(object obj)
+        private void ExecuteServoOnCommand( object obj )
         {
             var msg = new AxisControlEventArgs
             {
-                Dir = AxisControlEventArgs.eEventDir.ToBack,
-                Kind = AxisControlEventArgs.eAxisControlKind.ServoOn,
-                AxisName = this.SelectAxis,
+                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.messageController.ShowConfirmationPopupView("Current Position To Target Position ?", r =>
-            {
-                if (r.Result == ButtonResult.OK)
-                {
-                    switch(this.SelectAxis)
-                    {
-                        case ConstString.AXIS_CARRIER_LOCK_LEFT:
-                            this.TargetPosLockLeft = this.CurrentLockLeft;
-                            break;
-                        case ConstString.AXIS_CARRIER_LOCK_RIGHT:
-                            this.TargetPosLockRight = this.CurrentLockRight;
-                            break;
-                    }
-                }
-            });
+            this.messageController.ShowConfirmationPopupView( "Current Position To Target Position ?" , r =>
+              {
+                  if ( r.Result == ButtonResult.OK )
+                  {
+                      switch ( this.SelectAxis )
+                      {
+                          case ConstString.AXIS_CARRIER_LOCK_LEFT:
+                              this.TargetPosLockLeft = this.CurrentLockLeft;
+                              break;
+                          case ConstString.AXIS_CARRIER_LOCK_RIGHT:
+                              this.TargetPosLockRight = this.CurrentLockRight;
+                              break;
+                      }
+                  }
+              } );
         }
 
-        private void ExecuteMoveToCommand()
+        private void ExecuteMoveToCommand( )
         {
-            this.messageController.ShowConfirmationPopupView($"Clamp Move To {this.SelectedPosition}", r =>
-            {
-                if (r.Result == ButtonResult.OK)
-                {
-                    var msg = new AxisControlEventArgs();
-                    msg.Kind = AxisControlEventArgs.eAxisControlKind.Move;
+            this.messageController.ShowConfirmationPopupView( $"Clamp Move To {this.SelectedPosition}" , r =>
+              {
+                  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;
+                      if ( SelectedPosition.Equals( ConstString.TEACH_POSITION_LOCK ) )
+                          msg.PosDir = AxisControlEventArgs.ePosDir.Lock;
+                      else
+                          msg.PosDir = AxisControlEventArgs.ePosDir.UnLock;
 
-                    this.PublishEvent(msg);
-                }
-            });
+                      this.PublishEvent( msg );
+                  }
+              } );
         }
 
-        private void ExecuteSelectPosCommand(object obj)
+        private void ExecuteSelectPosCommand( object obj )
         {
             this.SelectedPosition = obj.ToString();
 
-            if (obj.Equals(ConstString.TEACH_POSITION_LOCK))
+            if ( obj.Equals( ConstString.TEACH_POSITION_LOCK ) )
             {
                 this.PosLockBrush = Brushes.Orange;
                 this.PosUnlockBrush = Brushes.Gray;
@@ -485,9 +509,9 @@ namespace OHV.Module.Interactivity.PopUp
             }
         }
 
-        private void ExecuteSelectAxisCommand(object obj)
+        private void ExecuteSelectAxisCommand( object obj )
         {
-            if (obj.ToString().Equals(ConstString.AXIS_CARRIER_LOCK_LEFT))
+            if ( obj.ToString().Equals( ConstString.AXIS_CARRIER_LOCK_LEFT ) )
             {
                 this.LeftAxisBrush = Brushes.Orange;
                 this.RightAxisBrush = System.Windows.Media.Brushes.Gray;
@@ -502,38 +526,38 @@ namespace OHV.Module.Interactivity.PopUp
         }
 
         #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( AxisUICallbackCommunication );
         }
 
-        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
     }

+ 14 - 14
Dev/OHV/VehicleControlSystem/ControlLayer/Motion/GSIMotion.cs

@@ -21,10 +21,10 @@ namespace VehicleControlSystem.ControlLayer.Motion
         private string currentTag;
         public string CurrentTag { get { return currentTag; } set { SetField(ref this.currentTag, value); } }
 
-        private double currentSpeed;
+        private double currentSpeed = 0;
         public double CurrentSpeed { get { return currentSpeed; } set { SetField(ref this.currentSpeed, value); } }
 
-        private double currentTorque;
+        private double currentTorque = 0;
         public double CurrentTorque { get { return currentTorque; } set { SetField(ref this.currentTorque, value); } }
 
         public bool IsErrorOn { get; set; }
@@ -43,18 +43,18 @@ namespace VehicleControlSystem.ControlLayer.Motion
 
         public bool MoveToPoint(string point, double velocity)
         {
-            var task = Task.Factory.StartNew(() =>
-            {
-                int index = 0;
-                while (true)
-                {
-                    LockUtils.Wait(500);
-                    this.CurrentPos = index++;
-
-                    if (CurrentPos > 20)
-                        break;
-                }
-            });
+            //var task = Task.Factory.StartNew(() =>
+            //{
+            //    int index = 0;
+            //    while (true)
+            //    {
+            //        LockUtils.Wait(500);
+            //        this.CurrentPos = index++;
+
+            //        if (CurrentPos > 20)
+            //            break;
+            //    }
+            //});
 
             return true;
         }

+ 36 - 8
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -261,11 +261,11 @@ namespace VehicleControlSystem.ControlLayer
                         }
                         break;
                     case DriveControlEventArgs.eControlKind.ReqCurrentPos:
-                        this.ReqCurrentPos();
+                        //this.ReqCurrentPos();
                         break;
                     case DriveControlEventArgs.eControlKind.ReqStopCurrentPos:
-                        this.taskCancel.Cancel();
-                        this.taskCancel.WaitAll();
+                        //this.taskCancel.Cancel();
+                        //this.taskCancel.WaitAll();
                         break;
                     case DriveControlEventArgs.eControlKind.FaultReset:
                         this.ReqFaultReset(_args);
@@ -279,6 +279,9 @@ namespace VehicleControlSystem.ControlLayer
                     case DriveControlEventArgs.eControlKind.JOG:
                         this.ReqJog(_args);
                         break;
+                    case DriveControlEventArgs.eControlKind.VehicleState:
+                        ReqVehicleState(_args);
+                        break;
                     default:
                         break;
                 }
@@ -326,18 +329,43 @@ namespace VehicleControlSystem.ControlLayer
 
         #region Request Method
 
+        private void ReqVehicleState(DriveControlEventArgs args)
+        {
+            VehicleState state = new VehicleState();
+            state.CurrentPosition = this.CurrentPosition;
+            state.CurrentSpeed = this.CurrentSpeed;
+            state.CurrentTag = this.CurrentTag;
+            state.CurrentTorque = this.CurrentTorque;
+
+            var msg = new DriveControlEventArgs();
+            msg.ControlKind = args.ControlKind;
+            msg.Args = state;
+
+            DriveControlEventPublish(msg);
+        }
+
         private void ReqMoveToPos( DriveControlEventArgs args )
         {
-            var drive = 0;
             //var result = drive.Move( args.PositionTag );
+<<<<<<< HEAD
             this.MoveTo( "1111" );
             var msg = new DriveControlEventArgs
+=======
+            var reply = new DriveControlEventArgs();
+
+            int targetTag = args.TargetRouteID;
+            var route = sql.RouteDal.GetK(targetTag);
+            if ( route == null)
+>>>>>>> c46c4387a8ef1f5ab1ba5e83769ae8f84c3891dc
             {
-                ControlKind = DriveControlEventArgs.eControlKind.FaultReset
-            };
+                reply.Result = Results.Fail("Not Found Route");
+                this.DriveControlEventPublish(reply);
+                return;
+            }
 
-            msg.Result = Results.Ok( "Position Move" );
-            this.DriveControlEventPublish( msg );
+            this.MoveTo(route.Name);
+            reply.Result = Results.Ok( "Position Move" );
+            this.DriveControlEventPublish(reply);
         }
 
         void ReqFaultReset(DriveControlEventArgs _args)

+ 1 - 1
Dev/OHV/VehicleControlSystem/VehicleControlSystem.csproj

@@ -18,7 +18,7 @@
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>TRACE;DEBUG;SIMULATION</DefineConstants>
+    <DefineConstants>TRACE;DEBUG</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>