unque781 5 anni fa
parent
commit
12dc560c54

+ 1 - 0
Dev/OHV/OHV.Common/Model/Command.cs

@@ -11,6 +11,7 @@ namespace OHV.Common.Model
     {
         public string CommandID { get; set; }
         public string TargetID { get; set; }
+        public string TargetName { get; set; }
         public DateTime CreateTime { get; set; }
         public eCommandType Type { get; set; }
         public eCommandState State { get; set; }

+ 5 - 3
Dev/OHV/OHV.Module.ListViews/Views/CommandListView.xaml

@@ -60,12 +60,13 @@
                             </Trigger>
                         </Style.Triggers>
                         <Setter Property="TextBlock.TextAlignment" Value="Center" />
-                        <Setter Property="FontSize" Value="15"/>
+                        <Setter Property="FontSize" Value="20"/>
                     </Style>
                     <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
                         <Setter Property="VerticalContentAlignment" Value="Center"/>
                         <Setter Property="HorizontalContentAlignment" Value="Center"/>
                         <Setter Property="Foreground" Value="White"/>
+                        <Setter Property="FontSize" Value="20"/>
                     </Style>
                 </DataGrid.Resources>
 
@@ -78,11 +79,12 @@
                         </DataGridTemplateColumn.CellTemplate>
                     </DataGridTemplateColumn>
 
-                    <materialDesign:DataGridTextColumn FontSize="20" Header="Target" Binding="{Binding TargetID}" EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}"></materialDesign:DataGridTextColumn>
+                    <materialDesign:DataGridTextColumn Header="PointID" Binding="{Binding TargetID}" EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}"></materialDesign:DataGridTextColumn>
+                    <materialDesign:DataGridTextColumn Header="EQ" Binding="{Binding TargetName}" EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}"></materialDesign:DataGridTextColumn>
                     <materialDesign:DataGridTextColumn Header="Type" Binding="{Binding Type}" EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}"></materialDesign:DataGridTextColumn>
                     <materialDesign:DataGridTextColumn Header="State" Binding="{Binding State}" EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}"></materialDesign:DataGridTextColumn>
                     <materialDesign:DataGridTextColumn Header="CreateTime" Binding="{Binding CreateTime}" EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}"></materialDesign:DataGridTextColumn>
-                    <materialDesign:DataGridTextColumn Header="CommandID" Binding="{Binding Co}" EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}"></materialDesign:DataGridTextColumn>
+                    <materialDesign:DataGridTextColumn Header="CommandID" Binding="{Binding CommandID}" EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}"></materialDesign:DataGridTextColumn>
 
                 </DataGrid.Columns>
             </DataGrid>

+ 22 - 25
Dev/OHV/OHV.Module.ListViews/Views/CommandListViewModel.cs

@@ -25,21 +25,21 @@ namespace OHV.Module.ListViews.Views
         public ObservableCollection<Command> CommandList
         {
             get { return this._commandList; }
-            set { SetProperty(ref this._commandList, value); }
+            set { SetProperty( ref this._commandList, value ); }
         }
 
         private string targetID;
         public string TargetID
         {
             get { return targetID; }
-            set { SetProperty(ref this.targetID, value); }
+            set { SetProperty( ref this.targetID, value ); }
         }
 
         private eCommandType selectedCommandType;
         public eCommandType SelectedCommandType
         {
             get { return selectedCommandType; }
-            set { SetProperty(ref this.selectedCommandType, value); }
+            set { SetProperty( ref this.selectedCommandType, value ); }
         }
 
         private List<string> targetIDList;
@@ -47,7 +47,7 @@ namespace OHV.Module.ListViews.Views
         public List<string> TargetIDList
         {
             get { return targetIDList; }
-            set { SetProperty(ref this.targetIDList, value); }
+            set { SetProperty( ref this.targetIDList, value ); }
         }
 
         #endregion
@@ -61,57 +61,57 @@ namespace OHV.Module.ListViews.Views
 
         VehicleControlSystem.VCSystem vCSystem = null;
 
-        public CommandListViewModel(IEventAggregator ea, SqliteManager sql, MessageController msgController, VehicleControlSystem.VCSystem vcSystem )
+        public CommandListViewModel( IEventAggregator ea, SqliteManager sql, MessageController msgController, VehicleControlSystem.VCSystem vcSystem )
         {
             this.vCSystem = vcSystem;
 
             this.eventAggregator = ea;
             this.messageController = msgController;
             this.sql = sql;
-            this.sql.CommandDAL.OnChangeTable += this.RefreshCommandLIst;
+            //this.sql.CommandDAL.OnChangeTable += this.RefreshCommandLIst;
 
-            this.CommandList = new ObservableCollection<Command>(sql.CommandDAL.GetAll());
+            this.CommandList = new ObservableCollection<Command>( sql.CommandDAL.GetAll() );
 
             //this.TargetIDList = sql.RouteDal.All.Select(x => x.Name).ToList();
             this.TargetIDList = vCSystem.RouteManager.Equipments.Select( e => e.Name ).ToList();
-            this.TargetIDList.Add("None");
+            this.TargetIDList.Add( "None" );
 
-            this.SaveCommand = new DelegateCommand(ExecuteSaveCommand);
-            this.DeleteCommand = new DelegateCommand(ExecuteDeleteCommand);
+            this.SaveCommand = new DelegateCommand( ExecuteSaveCommand );
+            this.DeleteCommand = new DelegateCommand( ExecuteDeleteCommand );
 
-            this.eventAggregator.GetEvent<VehicleCommandListChanged>().Unsubscribe(UICallbackCommunication);
-            this.eventAggregator.GetEvent<VehicleCommandListChanged>().Subscribe(UICallbackCommunication, ThreadOption.UIThread);
+            this.eventAggregator.GetEvent<VehicleCommandListChanged>().Unsubscribe( UICallbackCommunication );
+            this.eventAggregator.GetEvent<VehicleCommandListChanged>().Subscribe( UICallbackCommunication, ThreadOption.UIThread );
         }
 
-        private void UICallbackCommunication(string obj)
+        private void UICallbackCommunication( string obj )
         {
-            //RefreshCommandLIst(null, null);
+            this.RefreshCommandLIst();
         }
 
         private void ExecuteDeleteCommand()
         {
             List<string> deleteList = new List<string>();
-            foreach (var item in this.CommandList)
+            foreach ( var item in this.CommandList )
             {
-                if (item.IsSelected)
+                if ( item.IsSelected )
                 {
-                    deleteList.Add(item.CommandID);
+                    deleteList.Add( item.CommandID );
                 }
             }
 
-            deleteList.ForEach(x => { this.sql.CommandDAL.Delete(x); });
+            deleteList.ForEach( x => { this.sql.CommandDAL.Delete( x ); } );
             //RefreshCommandLIst();
         }
 
         private void ExecuteSaveCommand()
         {
             var route = this.vCSystem.RouteManager.Equipments.Any( e => e.Name.Equals( TargetID ) );
-            if (!route )
+            if ( !route )
                 messageController.ShowNotificationView( "Not Found TargetID" );
             else
             {
                 var targetPoint = this.vCSystem.RouteManager.Equipments.Where( e => e.Name.Equals( TargetID ) ).Single().pointID.ToString();
-                Command cmd = new Command() { TargetID = targetPoint, Type = SelectedCommandType };
+                Command cmd = new Command() { TargetID = targetPoint, Type = SelectedCommandType, TargetName = TargetID };
                 cmd.ByWho = eCommandByWho.LocalSystem;
 
                 var msg = new VCSMessageEventArgs();
@@ -136,11 +136,8 @@ namespace OHV.Module.ListViews.Views
             //if (Application.Current == null)
             //    return;
 
-            Application.Current.Dispatcher.Invoke(() =>
-            {
-                this.CommandList.Clear();
-                this.CommandList.AddRange(sql.CommandDAL.GetAll());
-            });
+            this.CommandList.Clear();
+            this.CommandList.AddRange( sql.CommandDAL.GetAll() );
         }
 
     }

+ 6 - 1
Dev/OHV/OHV.Module.ListViews/Views/SubCommandListView.xaml

@@ -10,7 +10,7 @@
              xmlns:prism="http://prismlibrary.com/"
              prism:ViewModelLocator.AutoWireViewModel="True"
              xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
-             d:DesignHeight="450" d:DesignWidth="800" Foreground="White">
+             d:DesignHeight="450" d:DesignWidth="800" Foreground="White" MinHeight="100" MinWidth="500" >
 
     <UserControl.Resources>
         <ResourceDictionary>
@@ -58,11 +58,16 @@
                                 <Setter Property="Background" Value="{x:Null}"></Setter>
                             </Trigger>
                         </Style.Triggers>
+
+                        <Setter Property="TextBlock.TextAlignment" Value="Center" />
+                        <Setter Property="FontSize" Value="20"/>
                     </Style>
+
                     <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
                         <Setter Property="VerticalContentAlignment" Value="Center"/>
                         <Setter Property="HorizontalContentAlignment" Value="Center"/>
                         <Setter Property="Foreground" Value="White"/>
+                        <Setter Property="FontSize" Value="20"/>
                     </Style>
                 </DataGrid.Resources>
 

+ 10 - 7
Dev/OHV/OHV.Module.ListViews/Views/SubCommandListViewModel.cs

@@ -60,7 +60,7 @@ namespace OHV.Module.ListViews.Views
         {
             this.eventAggregator = ea;
             this.sql = sql;
-            this.sql.SubCmdDAL.OnChangeTable += SubCmdDAL_ChangedProperty;
+            //this.sql.SubCmdDAL.OnChangeTable += SubCmdDAL_ChangedProperty;
 
             this.SubCmdList = new ObservableCollection<SubCmd>(sql.SubCmdDAL.GetAll());
 
@@ -71,7 +71,7 @@ namespace OHV.Module.ListViews.Views
             this.TargetIDList.Add( "None" );
 
             this.eventAggregator.GetEvent<VehicleSubCmdListChanged>().Unsubscribe(UICallbackCommunication);
-            this.eventAggregator.GetEvent<VehicleSubCmdListChanged>().Subscribe(UICallbackCommunication);
+            this.eventAggregator.GetEvent<VehicleSubCmdListChanged>().Subscribe(UICallbackCommunication, ThreadOption.UIThread);
         }
 
         internal void Dispose()
@@ -129,11 +129,14 @@ namespace OHV.Module.ListViews.Views
             //TODO: Null Exception Check 
             //TODO: Application 종료 시 TaskCancledException 발생됨 -> 또 발생됨 06/29/20:02
 
-            Application.Current.Dispatcher.Invoke(() =>
-            {
-                this.SubCmdList.Clear();
-                this.SubCmdList.AddRange(sql.SubCmdDAL.GetAll());
-            });
+            this.SubCmdList.Clear();
+            this.SubCmdList.AddRange( sql.SubCmdDAL.GetAll() );
+
+            //Application.Current.Dispatcher.Invoke(() =>
+            //{
+            //    this.SubCmdList.Clear();
+            //    this.SubCmdList.AddRange(sql.SubCmdDAL.GetAll());
+            //});
         }
     }
 }

+ 12 - 3
Dev/OHV/OHV.SqliteDAL/DAL/AbstractDAL.cs

@@ -134,6 +134,7 @@ namespace OHV.SqliteDAL.DAL
         void Delete( Expression<Func<T, bool>> filter = null );
         void Clean();
         void Save();
+        void Dispose();
     }
 
     class GenericRepository<T> : IGenericRepository<T> where T : class
@@ -202,6 +203,8 @@ namespace OHV.SqliteDAL.DAL
                 table.Add( obj );
                 this.Save();
             }
+
+            this.OnChangeTable?.Invoke();
         }
 
         public void Update( T obj )
@@ -219,6 +222,7 @@ namespace OHV.SqliteDAL.DAL
                 this.Save();
             }
 
+            this.OnChangeTable?.Invoke();
         }
 
         public void Delete( object id )
@@ -227,7 +231,6 @@ namespace OHV.SqliteDAL.DAL
             if ( existing == null )
                 return;
 
-
             lock ( lockObj )
             {
                 if ( _context.Entry( existing ).State == EntityState.Detached )
@@ -238,7 +241,7 @@ namespace OHV.SqliteDAL.DAL
                 table.Remove( existing );
                 this.Save();
             }
-
+            this.OnChangeTable?.Invoke();
         }
 
         public void Delete( Expression<Func<T, bool>> filter )
@@ -252,6 +255,7 @@ namespace OHV.SqliteDAL.DAL
                     Save();
                 }
             }
+            this.OnChangeTable?.Invoke();
         }
 
         public void Clean()
@@ -266,6 +270,8 @@ namespace OHV.SqliteDAL.DAL
                     this.Save();
                 }
             }
+
+            this.OnChangeTable?.Invoke();
         }
 
         public void Save()
@@ -292,8 +298,11 @@ namespace OHV.SqliteDAL.DAL
                 logger.E( $"[DataBase] - DbUpdateConcurrencyException {this.table.GetType().Name}" );
                 return;
             }
+        }
 
-            this.OnChangeTable?.Invoke();
+        public void Dispose()
+        {
+            this._context.Dispose();
         }
     }
 

+ 20 - 1
Dev/OHV/OHV.SqliteDAL/SqliteManager.cs

@@ -3,9 +3,11 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using OHV.Common.Events;
 using OHV.Common.Interfaces;
 using OHV.Common.Model;
 using OHV.SqliteDAL.DAL;
+using Prism.Events;
 using Prism.Ioc;
 using Prism.Modularity;
 
@@ -26,7 +28,9 @@ namespace OHV.SqliteDAL
         public IGenericRepository<HisAlarm> HisAlarmDAL { get; set; }
         public IGenericRepository<Route> RouteDal { get; set; }
 
-        public SqliteManager()
+        IEventAggregator eventAggregator;
+
+        public SqliteManager(IEventAggregator eventAggregator)
         {
             this.ConfigDal = new GenericRepository<Config>();
             this.SubCmdDAL = new GenericRepository<SubCmd>();
@@ -39,6 +43,21 @@ namespace OHV.SqliteDAL
             this.VehicleInfoDAL = new GenericRepository<VehicleInfo>();
             this.HisAlarmDAL = new GenericRepository<HisAlarm>();
             this.RouteDal = new GenericRepository<Route>();
+
+            this.eventAggregator = eventAggregator;
+
+            this.CommandDAL.OnChangeTable += CommandDAL_OnChangeTable;
+            this.SubCmdDAL.OnChangeTable += SubCmdDAL_OnChangeTable;
+        }
+
+        private void SubCmdDAL_OnChangeTable()
+        {
+            this.eventAggregator.GetEvent<VehicleSubCmdListChanged>().Publish( "" );
+        }
+
+        private void CommandDAL_OnChangeTable()
+        {
+            this.eventAggregator.GetEvent<VehicleCommandListChanged>().Publish( "" );
         }
 
         public void RegisterTypes(IContainerRegistry containerRegistry)

+ 211 - 3
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -3,6 +3,7 @@ using System.Collections;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
+using System.Runtime.Remoting.Messaging;
 using System.Threading;
 using System.Threading.Tasks;
 using FluentResults;
@@ -1549,6 +1550,7 @@ namespace VehicleControlSystem.ControlLayer
         /// Out Put 을 Off 이면 Sensor On
         /// </summary>
         public void PIOSensorOff() => this.refObjects.IO.OutputOn( "OUT_PIO_SENSOR_ONOFF" );
+        public bool IsChargeCylinderForword() => this.refObjects.IO.IsOn( "IN_CHARGE_CYL_FWD_DETECT" );
 
         /// <summary>
         /// 충전 중일때 MTL PIO Bit 가 살아 있다 
@@ -1581,6 +1583,12 @@ namespace VehicleControlSystem.ControlLayer
         public int ConveyorLoad() => this.refObjects.Conveyor.ConveyorLoad();
         public int ConveyorUnload() => this.refObjects.Conveyor.ConveyorUnload();
 
+        void PIOClear()
+        {
+            string[] pio = { "OUT_PIO_READY", "OUT_PIO_SENDING_RUN", "OUT_PIO_SEND_COMPLITE", "OUT_PIO_RECEIVABLE", "OUT_PIO_RECEIVE_RUN", "OUT_PIO_RECIVE_COMPLITE", "OUT_PIO_INTERLOCK" };
+            pio.FwEach( x => { this.refObjects.IO.OutputOff( x ); } );
+        }
+
         public int PIOAndLoad( string targetName )
         {
 #if SIMULATION
@@ -1914,10 +1922,210 @@ namespace VehicleControlSystem.ControlLayer
             return 0;
         }
 
-        void PIOClear()
+        public int ManualPIOAndLoad( )
         {
-            string[] pio = { "OUT_PIO_READY", "OUT_PIO_SENDING_RUN", "OUT_PIO_SEND_COMPLITE", "OUT_PIO_RECEIVABLE", "OUT_PIO_RECEIVE_RUN", "OUT_PIO_RECIVE_COMPLITE", "OUT_PIO_INTERLOCK" };
-            pio.FwEach( x => { this.refObjects.IO.OutputOff( x ); } );
+            loggerPIO.I( $"Start Load PIO - [{this.CurrentTag}]" );
+
+            PIOClear();
+
+            this.PIOSensorOn();
+            LockUtils.Wait( 500 );
+
+            int result = ConstInt.EXECUTE_SUCCESS;
+
+            var pioTimeout = Convert.ToInt32( this.refObjects.Sqlite.ConfigDal.GetById( ConstString.PIOTimeOut ).Value );
+
+            result = this.refObjects.Clamp.Unlock_Sync();
+            if ( result != 0 )
+            {
+                this.OccurVehicleAlarm( result );
+                return result;
+            }
+
+            if ( this.refObjects.Conveyor.IsInverterError() )
+                return 16;
+
+            if ( this.refObjects.Conveyor.IsDetectedCenter() )
+                return 9;
+
+            if ( !this.refObjects.Conveyor.IsLifterPositinCheck() )
+            {
+                loggerPIO.E( "[Port] - Lift Position Check Error" );
+                return 14;
+            }
+
+            this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECEIVABLE", true );
+            loggerPIO.I( "[Vehicle] - 4 Receivable" );
+
+            if ( !this.refObjects.IO.WaitChangeInputIO( true, 1 * ConstUtils.ONE_SECOND, "IN_PIO_SENDABLE" ) )
+            {
+                PIOClear();
+                loggerPIO.E( "[Port] - 4 Ready Time Out" );
+                TimerUtils.Once( 1000, this.OnFailReport, eFailCode.LoadPIOInterlockTimeout );
+                //this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
+                return 18;
+            }
+            loggerPIO.I( "[Port] - 4 Ready On" );
+
+            //this.conveyor.SetConveyorSpeed( true );
+            this.refObjects.Conveyor.OnOffConveyor( true, true );
+            this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECEIVE_RUN", true, 1000 ); //1Sec 이후 On
+            loggerPIO.I( "[Vehicle] - Conveyor Run" );
+            this.OnConveyorStart?.Invoke( true );
+
+            if ( !this.refObjects.IO.WaitChangeInputIO( true, pioTimeout, "IN_PIO_SEND_RUN" ) )
+            {
+                this.refObjects.Conveyor.OnOffConveyor( false, true );
+                PIOClear();
+                loggerPIO.E( "[Port] - 5 Sending Run Time Out" );
+                return 18;
+            }
+            loggerPIO.I( "[Port] - 5 Sending Run On" );
+
+            bool isStartDetected = false;
+            var sTime = SwUtils.CurrentTimeMillis;
+            while ( true )
+            {
+                LockUtils.Wait( 10 );
+
+                if ( SwUtils.Gt( sTime, 20 * ConstUtils.ONE_SECOND ) )
+                {
+                    PIOClear();
+                    this.refObjects.Conveyor.OnOffConveyor( false, true );
+                    loggerPIO.E( "[Vehicle] Conveyor Wait Time Out" );
+                    return 10; //Conveyor Time Out
+                }
+
+                if ( this.refObjects.Conveyor.IsDetectedLoadStart() && !isStartDetected )
+                    isStartDetected = true;
+
+                if ( !this.refObjects.Conveyor.IsDetectedLoadStart() && isStartDetected ) { }
+
+                if ( this.refObjects.Conveyor.IsDetectedLoadStop() ) break;
+
+                if ( this.refObjects.Conveyor.IsPIOInterLockOn() )
+                {
+                    PIOClear();
+                    this.refObjects.Conveyor.OnOffConveyor( false ); //Stop
+                    loggerPIO.E( "[Port] PIO InterLock On " );
+                    return 19; //
+                }
+            }
+
+            this.refObjects.Conveyor.OnOffConveyor( false ); //Stop
+            PIOClear();
+            loggerPIO.I( "[Vehicle] Conveyor Stop" );
+
+            this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECIVE_COMPLITE", true );
+            loggerPIO.I( "[Vehicle] Receive Complete On" );
+
+            if ( !this.refObjects.IO.WaitChangeInputIO( true, pioTimeout, "IN_PIO_SEND_COMPLITE" ) )
+            {
+                this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECIVE_COMPLITE", false );
+                loggerPIO.E( "[Port]  IN_PIO_SEND_COMPLITE On Time Out" );
+            }
+            loggerPIO.I( "[Port] Send Complete On" );
+
+            this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECIVE_COMPLITE", false, 1000 );
+
+            loggerPIO.I( $"End Load PIO - [{this.CurrentTag}]" );
+
+            result = this.refObjects.Clamp.Lock_Sync();
+            if ( result != 0 )
+            {
+                this.OccurVehicleAlarm( result );
+                return result;
+            }
+
+            return result;
+        }
+
+        public int ManualPIOAndUnlaod( )
+        {
+            loggerPIO.I( $"Start Unload PIO -[{this.CurrentTag}]" );
+
+            PIOClear();
+            this.PIOSensorOn();
+            LockUtils.Wait( 500 );
+
+            int result = 0;
+
+            var pioTimeout = Convert.ToInt32( this.refObjects.Sqlite.ConfigDal.GetById( ConstString.PIOTimeOut ).Value );
+
+            if ( this.refObjects.Conveyor.IsInverterError() )
+                return 16;
+
+            if ( !this.refObjects.Conveyor.IsDetectedCenter() )
+            {
+                return 11;
+            }
+
+            if ( !this.refObjects.Conveyor.IsLifterPositinCheck() )
+            {
+                loggerPIO.E( "[Port] - Lift Position Check Error" );
+                return 13; 
+            }
+
+            if ( !this.refObjects.IO.WaitChangeInputIO( true, 1 * ConstUtils.ONE_SECOND, "IN_PIO_READY" ) )
+            {
+                loggerPIO.E( "[Port] - 1 Ready not On" );
+                return 17;
+            }
+
+            this.refObjects.IO.WriteOutputIO( "OUT_PIO_READY", true );
+            loggerPIO.I( "[Vehicle] - 1 Ready On" );
+
+            if ( !this.refObjects.IO.WaitChangeInputIO( true, 1 * ConstUtils.ONE_SECOND, "IN_PIO_RECEIVE_RUN" ) )
+            {
+                PIOClear();
+                loggerPIO.E( "[Port] - 2 Receive CV Run Timeout" );
+                return 0;
+            }
+            loggerPIO.I( "[Port] - 2 Receive CV Run On" );
+
+            result = this.refObjects.Clamp.Unlock_Sync();
+            if ( result != 0 )
+            {
+                this.OccurVehicleAlarm( result );
+                return result;
+            }
+
+            this.refObjects.IO.WriteOutputIO( "OUT_PIO_SENDING_RUN", true );
+            loggerPIO.I( "[Vehicle] - 2 Send Run On" );
+
+            this.refObjects.Conveyor.OnOffConveyor( true );
+
+            var sTime = SwUtils.CurrentTimeMillis;
+            while ( true )
+            {
+                if ( SwUtils.Gt( sTime, 20 * ConstUtils.ONE_SECOND ) )
+                {
+                    PIOClear();
+                    this.refObjects.Conveyor.OnOffConveyor( false, true );
+                    loggerPIO.E( "[Port] Conveyor Wait Time Out" );
+                    return 12; //Conveyor Moving Timeout
+                }
+
+                if ( !this.refObjects.Conveyor.IsDetectedLoadStart() && !this.refObjects.Conveyor.IsDetectedCenter() )
+                {
+                    if ( this.refObjects.IO.IsOn( "IN_PIO_RECEIVE_COMPLITE" ) )
+                    {
+                        loggerPIO.I( "[Port] - 3 Receive Complete On" );
+                        break;
+                    }
+                }
+            }
+
+            this.refObjects.Conveyor.OnOffConveyor( false ); //Stop
+            PIOClear();
+
+            this.refObjects.IO.WriteOutputIO( "OUT_PIO_SEND_COMPLITE", true );
+            LockUtils.Wait( 1000 );
+            this.refObjects.IO.WriteOutputIO( "OUT_PIO_SEND_COMPLITE", false );
+            loggerPIO.I( "[Vehicle] - 3 Send Complete OnOff" );
+            loggerPIO.I( $"End Unload PIO - [{CurrentTag}]" );
+
+            return result;
         }
 
         #endregion

+ 7 - 24
Dev/OHV/VehicleControlSystem/Managers/HostManager.cs

@@ -27,6 +27,7 @@ namespace VehicleControlSystem.Managers
         Vehicle vehicle = null;
         SqliteManager sql = null;
         AutoManager autoManager;
+        Scheduler scheduler = null;
 
         public bool IsConnected { get { return this.manager.Connected; } }
 
@@ -43,7 +44,8 @@ namespace VehicleControlSystem.Managers
             this.autoManager.OnOccurAlarm += AutoManager_OnOccurAlarm;
             this.autoManager.OnClearAlarm += AutoManager_OnClearAlarm;
 
-            scheduler.OnMaualAddedCommand += Scheduler_OnMaualAddedCommand;
+            this.scheduler = scheduler;
+            this.scheduler.OnMaualAddedCommand += Scheduler_OnMaualAddedCommand;
         }
 
         private void Scheduler_OnMaualAddedCommand( Command obj )
@@ -313,26 +315,6 @@ namespace VehicleControlSystem.Managers
             this.manager.Send( msg );
         }
 
-        //private void Vehicle_OnManualCharging()
-        //{
-        //    this.Send_ManualCharging();
-        //}
-
-        //private void Vehicle_OnManualUnload()
-        //{
-        //    this.Send_ManualUnlaod();
-        //}
-
-        //private void Vehicle_OnManualMove()
-        //{
-        //    this.Send_ManualMove();
-        //}
-
-        //private void Vehicle_OnManualLoad()
-        //{
-        //    this.Send_ManualLoad();
-        //}
-
         private void Vehicle_OnCurrentTagChanged( int point )
         {
             this.Send_Tcmd( point );
@@ -529,10 +511,11 @@ namespace VehicleControlSystem.Managers
 
                     cmd.TargetID = msg.Tag;
 
-                    this.sql.CommandDAL.Insert( cmd );
+                    this.scheduler.AddCommand( cmd );
+                    //this.sql.CommandDAL.Insert( cmd );
                     logger.I( $"[Command] - Add HostOverWrite : Target {cmd.TargetID} / Type {cmd.Type}" );
-
-                    sql.CommandDAL.Delete( hasCommand.CommandID );
+                    this.scheduler.RemoveCommand( hasCommand );
+                    //sql.CommandDAL.Delete( hasCommand.CommandID );
                 }
                 else
                 {

+ 11 - 5
Dev/OHV/VehicleControlSystem/Managers/Scheduler.cs

@@ -84,6 +84,7 @@ namespace VehicleControlSystem.Managers
         {
             try
             {
+                cmd.TargetName = RouteManager.Instance.Equipments.Where( e => e.pointID.ToString().Equals( cmd.TargetID ) ).FirstOrDefault().Name;
                 this.sql.CommandDAL.Insert( cmd );
                 logger.I( $"[Command Added] - Target : {cmd.TargetID} / Type : {cmd.Type}" );
             }
@@ -96,15 +97,20 @@ namespace VehicleControlSystem.Managers
             return true;
         }
 
-        bool RemoveCommand( Command cmd )
+        public bool RemoveCommand( Command cmd )
         {
-            if ( !this.CommandsList.Remove( cmd ) )
+            logger.I( $"Scheduler - [Command] : RemoveCommand OK ID-{ cmd.TargetID } / Type-{ cmd.Type } / TargetName - {cmd.TargetName} " );
+            try
+            {
+                this.sql.CommandDAL.Delete( cmd.CommandID );
+            }
+            catch ( Exception ex)
             {
+                logger.E( ex );
                 logger.D( $"Scheduler - [Command] : RemoveCommand fail ID-{cmd.CommandID} / Result-{cmd.Result} " );
                 return false;
             }
 
-            logger.D( $"Scheduler - [Command] : RemoveCommand OK ID-{cmd.CommandID} / Result-{cmd.Result} " );
             return true;
         }
 
@@ -305,9 +311,9 @@ namespace VehicleControlSystem.Managers
                     break;
 
                 case OHV.Common.Shareds.eCommandState.Complete:
-                    sql.CommandDAL.Delete( cmd.CommandID );
-                    logger.I( $"[Command Deleted] - Target : {cmd.TargetID} / Type : {cmd.Type}" );
+                    this.RemoveCommand( cmd );
                     break;
+
                 default:
                     break;
             }

+ 3 - 3
Dev/OHV/VehicleControlSystem/VCSystem.cs

@@ -126,7 +126,7 @@ namespace VehicleControlSystem
 
             //Process
             this.autoManager = new AutoManager(this.IO, this.eventAggregator, this.sql, this.Alarms);
-            this.scheduler = new Scheduler(eventAggregator, this.autoManager, this.sql, this.bMUManager);
+            this.scheduler = new Scheduler(eventAggregator, this.autoManager, this.sql, this.bMUManager );
             this.vehicle = new Vehicle(this.eventAggregator);
 
             this.hostManager = new HostManager(this.eventAggregator, this.vehicle, this.sql, this.autoManager, this.scheduler);
@@ -457,9 +457,9 @@ namespace VehicleControlSystem
 
             /*PIO Load// Unload*/
             if (msg.MessageText.Equals("PL"))
-                result = this.vehicle.PIOAndLoad("");
+                result = this.vehicle.ManualPIOAndLoad();
             else
-                result = this.vehicle.PIOAndUnload("");
+                result = this.vehicle.ManualPIOAndUnlaod();
 
             //실행 결과 확인 
             if (result <= 0)