Browse Source

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

# Conflicts:
#	Dev/OHV/OHV.Vehicle/Concept/D_MainWindowViewModel.cs
ys-hwang 5 years ago
parent
commit
e81f28cedc

+ 148 - 111
Dev/OHV/OHV.Vehicle/Concept/D_MainWindowViewModel.cs

@@ -40,14 +40,14 @@ namespace OHV.Vehicle.Concept
         public string Title
         {
             get { return _title; }
-            set { SetProperty(ref _title, value); }
+            set { SetProperty( ref _title, value ); }
         }
 
         private double _cpu;
         public double CPU
         {
             get { return this._cpu; }
-            set { this.SetProperty(ref this._cpu, value); }
+            set { this.SetProperty( ref this._cpu, value ); }
         }
 
         private double _totalCPU;
@@ -57,7 +57,7 @@ namespace OHV.Vehicle.Concept
             set
             {
                 //this._totalCPU = dti.cpuResult.ToString();
-                this.SetProperty(ref this._totalCPU, value);
+                this.SetProperty( ref this._totalCPU, value );
             }
         }
 
@@ -66,14 +66,14 @@ namespace OHV.Vehicle.Concept
         public double RAM
         {
             get { return this._ram; }
-            set { this.SetProperty(ref this._ram, value); }
+            set { this.SetProperty( ref this._ram, value ); }
         }
 
         private double _cDrive;
         public double CDrive
         {
             get { return this._cDrive; }
-            set { this.SetProperty(ref this._cDrive, value); }
+            set { this.SetProperty( ref this._cDrive, value ); }
         }
 
         DateTime _dateTime;
@@ -82,7 +82,7 @@ namespace OHV.Vehicle.Concept
             get { return _dateTime; }
             set
             {
-                this.SetProperty(ref _dateTime, value);
+                this.SetProperty( ref _dateTime, value );
             }
         }
 
@@ -90,83 +90,93 @@ namespace OHV.Vehicle.Concept
         public string VehicleID
         {
             get { return this._vehicleID; }
-            set { this.SetProperty(ref this._vehicleID, value); }
+            set { this.SetProperty( ref this._vehicleID, value ); }
         }
 
         private string _vehicleIP = "127.0.0.1";
         public string VehicleIP
         {
             get { return this._vehicleIP; }
-            set { this.SetProperty(ref this._vehicleIP, value); }
+            set { this.SetProperty( ref this._vehicleIP, value ); }
         }
         private string _ocsIP;
         public string OcsIP
         {
             get { return this._ocsIP; }
-            set { this.SetProperty(ref this._ocsIP, value); }
+            set { this.SetProperty( ref this._ocsIP, value ); }
         }
 
         private string _swVersion;
         public string SwVersion
         {
             get { return this._swVersion; }
-            set { this.SetProperty(ref this._swVersion, value); }
+            set { this.SetProperty( ref this._swVersion, value ); }
         }
 
         bool _startEnable = true;
         public bool StartEnable
         {
             get { return this._startEnable; }
-            set { this.SetProperty(ref this._startEnable, value); }
+            set { this.SetProperty( ref this._startEnable, value ); }
         }
 
         bool _stopEnable = false;
         public bool StopEnable
         {
             get { return this._stopEnable; }
-            set { this.SetProperty(ref this._stopEnable, value); }
+            set { this.SetProperty( ref this._stopEnable, value ); }
         }
 
         private DateTime _lastBuildedTime;
         public DateTime LastBuildedTime
         {
             get { return this._lastBuildedTime; }
-            set { this.SetProperty(ref this._lastBuildedTime, value); }
+            set { this.SetProperty( ref this._lastBuildedTime, value ); }
         }
 
         private bool isManualMode = true;
         public bool IsManualMode
         {
             get { return isManualMode; }
-            set { SetProperty(ref isManualMode, value); }
+            set { SetProperty( ref isManualMode, value ); }
         }
 
         private bool isVehicleAlarm = false;
         public bool IsVehicleAlarm
         {
             get { return isVehicleAlarm; }
-            set { SetProperty(ref this.isVehicleAlarm, value); }
+            set { SetProperty( ref this.isVehicleAlarm, value ); }
         }
 
         private eMachineMode machineMode = eMachineMode.LocalMode;
         public eMachineMode MachineMode
         {
             get { return machineMode; }
-            set { SetProperty(ref this.machineMode, value); }
+            set { SetProperty( ref this.machineMode, value ); }
         }
 
         eOcsState ocsState = eOcsState.DisConnect;
         public eOcsState OcsState
         {
             get { return this.ocsState; }
-            set { this.SetProperty( ref this.ocsState , value ); }
+            set { this.SetProperty( ref this.ocsState, value ); }
         }
+<<<<<<< HEAD
+
+=======
+>>>>>>> 69c47f10da3d0471e11a86cb5cebfd28044ec0fd
+
 
         eBatteryState batteryState = eBatteryState.DisConnect;
         public eBatteryState BatteryState
         {
+<<<<<<< HEAD
+            get { return this.batteryConnectState; }
+            set { this.SetProperty( ref this.batteryConnectState, value ); }
+=======
             get { return this.batteryState; }
             set { this.SetProperty( ref this.batteryState , value ); }
+>>>>>>> 69c47f10da3d0471e11a86cb5cebfd28044ec0fd
         }
 
         #endregion
@@ -179,7 +189,7 @@ namespace OHV.Vehicle.Concept
             get { return _ocsBrush; }
             set
             {
-                SetProperty(ref _ocsBrush, value);
+                SetProperty( ref _ocsBrush, value );
             }
         }
 
@@ -190,7 +200,7 @@ namespace OHV.Vehicle.Concept
             get { return batteryBrush; }
             set
             {
-                SetProperty( ref batteryBrush , value );
+                SetProperty( ref batteryBrush, value );
             }
         }
 
@@ -198,7 +208,7 @@ namespace OHV.Vehicle.Concept
         public double SOC
         {
             get { return this.soc; }
-            set { this.SetProperty( ref this.soc , value ); }
+            set { this.SetProperty( ref this.soc, value ); }
         }
 
         #endregion
@@ -223,21 +233,24 @@ namespace OHV.Vehicle.Concept
         VCSMessagePubSubEvent vcsMessagePublisher;
 
         IRegionManager regionManager;
+
+
+
         DeskTopInfo dti = new DeskTopInfo();
         SqliteManager sql;
 
-        public D_MainWindowViewModel( IEventAggregator _ea , VCSystem cSystem , IRegionManager _regionManager , MessageController _msgController, SqliteManager _sql )
+        public D_MainWindowViewModel( IEventAggregator _ea, VCSystem cSystem, IRegionManager _regionManager, MessageController _msgController, SqliteManager _sql )
         {
             this.regionManager = _regionManager;
 
             this.eventAggregator = _ea;
-            this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Subscribe( UICallbackCommunication , ThreadOption.UIThread );
-            this.eventAggregator.GetEvent<HostConnectedPubSubEvent>().Subscribe( OcsConnectCallBack , ThreadOption.UIThread , false );
+            this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Subscribe( UICallbackCommunication, ThreadOption.UIThread );
+            this.eventAggregator.GetEvent<HostConnectedPubSubEvent>().Subscribe( OcsConnectCallBack, ThreadOption.UIThread, false );
 
             vcsMessagePublisher = this.eventAggregator.GetEvent<VCSMessagePubSubEvent>();
 
             this.VCSystem = cSystem;
-            
+
             this.messageController = _msgController;
             this.sql = _sql;
 
@@ -246,28 +259,28 @@ namespace OHV.Vehicle.Concept
             this.OcsIP = sql.ConfigDal.GetK( ConstString.Addr ).Value;
 
             this.TestCommand = new DelegateCommand( ExecuteTextCommand );
-            this.NavigateCommand = new DelegateCommand<object>(this.Navigate);
-            this.SystemOffCommand = new DelegateCommand(ExecuteSystemOffCommand);
-            this.ChangeLanguage = new DelegateCommand(Execte_ChangeLanguage);
-            this.StartCommand = new DelegateCommand(ExecuteStartCommand);
-            this.StopCommand = new DelegateCommand(ExecuteStopCommand);
-            this.AlarmResetCommand = new DelegateCommand( ExecuteAlarmResetCommand);
-            this.EmergencyStopCommand = new DelegateCommand(ExecuteEStop);
+            this.NavigateCommand = new DelegateCommand<object>( this.Navigate );
+            this.SystemOffCommand = new DelegateCommand( ExecuteSystemOffCommand );
+            this.ChangeLanguage = new DelegateCommand( Execte_ChangeLanguage );
+            this.StartCommand = new DelegateCommand( ExecuteStartCommand );
+            this.StopCommand = new DelegateCommand( ExecuteStopCommand );
+            this.AlarmResetCommand = new DelegateCommand( ExecuteAlarmResetCommand );
+            this.EmergencyStopCommand = new DelegateCommand( ExecuteEStop );
             this.BuzzerStopCommand = new DelegateCommand( ExecuteBuzzerStop );
             this.MachineModeChgCommand = new DelegateCommand<string>( ExecuteMachineModeChgCommand );
 
             DispatcherTimer dateTimer = new DispatcherTimer();
-            dateTimer.Tick += (object sender, EventArgs e) =>
+            dateTimer.Tick += ( object sender, EventArgs e ) =>
             {
                 this.DateTime = DateTime.Now;
             };
-            dateTimer.Interval = TimeSpan.FromMilliseconds(500);
+            dateTimer.Interval = TimeSpan.FromMilliseconds( 500 );
             dateTimer.Start();
 
             this.SwVersion = AssemblyUtils.GetVersion();
             this.LastBuildedTime = new Helpler.AssemblyInfo().Get_BuildDateTime();
 
-            GSG.NET.Quartz.QuartzUtils.Invoke("RESOURCE_CHECK", GSG.NET.Quartz.QuartzUtils.GetExpnSecond(1), QuzOnResourceUsage);
+            GSG.NET.Quartz.QuartzUtils.Invoke( "RESOURCE_CHECK", GSG.NET.Quartz.QuartzUtils.GetExpnSecond( 1 ), QuzOnResourceUsage );
         }
 
         void QuzOnResourceUsage()
@@ -291,19 +304,19 @@ namespace OHV.Vehicle.Concept
             else
                 msg.Arg = eMachineMode.LocalMode;
 
-            this.messageController.ShowConfirmationPopupView( $"Change to {msg.Arg} ?", r => 
-            { 
+            this.messageController.ShowConfirmationPopupView( $"Change to {msg.Arg} ?", r =>
+            {
                 if ( r.Result == ButtonResult.OK )
                     vcsMessagePublisher.Publish( msg );
             } );
 
         }
 
-        private void ExecuteBuzzerStop( )
+        private void ExecuteBuzzerStop()
         {
             var msg = new VCSMessageEventArgs
             {
-                Kind = VCSMessageEventArgs.eVCSMessageKind.ReqBuzzerStop ,
+                Kind = VCSMessageEventArgs.eVCSMessageKind.ReqBuzzerStop,
             };
             vcsMessagePublisher.Publish( msg );
 
@@ -319,61 +332,61 @@ namespace OHV.Vehicle.Concept
         {
             var msg = new VCSMessageEventArgs
             {
-                Kind = VCSMessageEventArgs.eVCSMessageKind.ReqEStop ,
+                Kind = VCSMessageEventArgs.eVCSMessageKind.ReqEStop,
             };
             vcsMessagePublisher.Publish( msg );
         }
 
-        private void ExecuteAlarmResetCommand( )
+        private void ExecuteAlarmResetCommand()
         {
-            this.messageController.ShowConfirmationPopupView(" Alarm Reset ? ", r =>
-            {
-                if (r.Result == ButtonResult.OK)
-                {
-                    var msg = new VCSMessageEventArgs
-                    {
-                        Kind = VCSMessageEventArgs.eVCSMessageKind.ReqAlarmReset,
-                    };
+            this.messageController.ShowConfirmationPopupView( " Alarm Reset ? ", r =>
+             {
+                 if ( r.Result == ButtonResult.OK )
+                 {
+                     var msg = new VCSMessageEventArgs
+                     {
+                         Kind = VCSMessageEventArgs.eVCSMessageKind.ReqAlarmReset,
+                     };
 
-                    vcsMessagePublisher.Publish(msg);
-                }
-            });
+                     vcsMessagePublisher.Publish( msg );
+                 }
+             } );
         }
 
         private void ExecuteStopCommand()
         {
-            this.messageController.ShowConfirmationPopupView(" Vehicle Stop ? ", r =>
-            {
-                if (r.Result == ButtonResult.OK)
-                {
-                    var msg = new VCSMessageEventArgs
-                    {
-                        Kind = VCSMessageEventArgs.eVCSMessageKind.ReqVehicleModeChange,
-                        MessageKey = MessageKey.ManualMode,
-                    };
+            this.messageController.ShowConfirmationPopupView( " Vehicle Stop ? ", r =>
+             {
+                 if ( r.Result == ButtonResult.OK )
+                 {
+                     var msg = new VCSMessageEventArgs
+                     {
+                         Kind = VCSMessageEventArgs.eVCSMessageKind.ReqVehicleModeChange,
+                         MessageKey = MessageKey.ManualMode,
+                     };
 
-                    vcsMessagePublisher.Publish(msg);
-                }
-            });
+                     vcsMessagePublisher.Publish( msg );
+                 }
+             } );
         }
 
         private void ExecuteStartCommand()
         {
-            this.messageController.ShowConfirmationPopupView("Request Vehicle Auto Mode ?", r =>
-            {
-                if (r.Result == ButtonResult.OK)
-                {
-                    var msg = new VCSMessageEventArgs
-                    {
-                        Kind = VCSMessageEventArgs.eVCSMessageKind.ReqVehicleModeChange,
-                        MessageKey = MessageKey.AutoMode,
-                    };
-                    vcsMessagePublisher.Publish(msg);
-                }
-            });
+            this.messageController.ShowConfirmationPopupView( "Request Vehicle Auto Mode ?", r =>
+             {
+                 if ( r.Result == ButtonResult.OK )
+                 {
+                     var msg = new VCSMessageEventArgs
+                     {
+                         Kind = VCSMessageEventArgs.eVCSMessageKind.ReqVehicleModeChange,
+                         MessageKey = MessageKey.AutoMode,
+                     };
+                     vcsMessagePublisher.Publish( msg );
+                 }
+             } );
         }
 
-        private void OcsConnectCallBack(HostConnectedEventArgs obj)
+        private void OcsConnectCallBack( HostConnectedEventArgs obj )
         {
             var state = obj.State;
 
@@ -390,28 +403,28 @@ namespace OHV.Vehicle.Concept
 
         private void ExecuteSystemOffCommand()
         {
-            this.messageController.ShowConfirmationPopupView("System ShutDown ?", r =>
-              {
-                  if (r.Result == ButtonResult.OK)
-                      App.Current.Shutdown();
-              });
+            this.messageController.ShowConfirmationPopupView( "System ShutDown ?", r =>
+               {
+                   if ( r.Result == ButtonResult.OK )
+                       App.Current.Shutdown();
+               } );
         }
 
-        private void Navigate(object obj)
+        private void Navigate( object obj )
         {
             var selectItem = obj.ToString();
-            if (!string.IsNullOrEmpty(selectItem))
-                regionManager.RequestNavigate("MainView", selectItem);
+            if ( !string.IsNullOrEmpty( selectItem ) )
+                regionManager.RequestNavigate( "MainView", selectItem );
         }
 
-        void VehicleModeChange(bool isAutoMode)
+        void VehicleModeChange( bool isAutoMode )
         {
-            if (isAutoMode)
+            if ( isAutoMode )
             {
                 this.StartEnable = false;
                 this.StopEnable = true;
                 this.IsManualMode = false;
-                regionManager.RequestNavigate(RegionNames.MainView, "AutoView");
+                regionManager.RequestNavigate( RegionNames.MainView, "AutoView" );
             }
             else
             {
@@ -421,8 +434,10 @@ namespace OHV.Vehicle.Concept
             }
         }
 
-        private void UICallbackCommunication(GUIMessageEventArgs obj)
+        private void UICallbackCommunication( GUIMessageEventArgs obj )
         {
+<<<<<<< HEAD
+=======
             if ( obj.Kind == GUIMessageEventArgs.eGUIMessageKind.ModelPropertyChange )
             {
                 if ( obj.MessageKey.Equals( MessageKey.Vehicle ) )
@@ -434,6 +449,7 @@ namespace OHV.Vehicle.Concept
                 }
             }
 
+>>>>>>> 69c47f10da3d0471e11a86cb5cebfd28044ec0fd
             switch ( obj.Kind )
             {
                 case GUIMessageEventArgs.eGUIMessageKind.ModelPropertyChange:
@@ -459,7 +475,7 @@ namespace OHV.Vehicle.Concept
                 case GUIMessageEventArgs.eGUIMessageKind.RspVihicleState:
                     break;
                 case GUIMessageEventArgs.eGUIMessageKind.RspMachineModeChg:
-                    RspMachineModeChg(obj);
+                    RspMachineModeChg( obj );
                     break;
                 default:
                     break;
@@ -488,7 +504,7 @@ namespace OHV.Vehicle.Concept
             FluentResults.Result result = obj.Result;
             if ( obj.Result.IsFailed )
             {
-                 reason = result.Errors.FirstOrDefault().Message;
+                reason = result.Errors.FirstOrDefault().Message;
             }
             else
             {
@@ -499,12 +515,12 @@ namespace OHV.Vehicle.Concept
             this.messageController.ShowNotificationView( reason );
         }
 
-        private void RspVehicleModeChange(GUIMessageEventArgs obj)
+        private void RspVehicleModeChange( GUIMessageEventArgs obj )
         {
-            if ( obj.Result.IsSuccess)
+            if ( obj.Result.IsSuccess )
             {
-                if (obj.MessageKey.Equals(MessageKey.AutoMode)) { this.VehicleModeChange(true); }
-                if (obj.MessageKey.Equals(MessageKey.ManualMode)) { this.VehicleModeChange(false); }
+                if ( obj.MessageKey.Equals( MessageKey.AutoMode ) ) { this.VehicleModeChange( true ); }
+                if ( obj.MessageKey.Equals( MessageKey.ManualMode ) ) { this.VehicleModeChange( false ); }
             }
             else
             {
@@ -512,19 +528,23 @@ namespace OHV.Vehicle.Concept
             }
         }
 
-        void UICallBackModelPropertyChange(GUIMessageEventArgs args)
+        void UICallBackModelPropertyChange( GUIMessageEventArgs args )
         {
-            if (args.MessageKey.Equals(MessageKey.Alarm))
+            if ( args.MessageKey.Equals( MessageKey.Alarm ) )
             {
                 var hisAlarm = args.Args as HisAlarm;
-                this.messageController.ShowNotificationView(args.MessageText);
-                this.VehicleModeChange(false);//알람이 발생하면 자동으로 Manual Mode 로 변경됨
+                this.messageController.ShowNotificationView( args.MessageText );
+                this.VehicleModeChange( false );//알람이 발생하면 자동으로 Manual Mode 로 변경됨
                 this.IsVehicleAlarm = true;
             }
 
-            if (args.MessageKey.Equals(MessageKey.Vehicle))
+            if ( args.MessageKey.Equals( MessageKey.Vehicle ) )
             {
+<<<<<<< HEAD
+                switch ( args.ModelPropertyName )
+=======
                 switch(args.ModelPropertyName)
+>>>>>>> 69c47f10da3d0471e11a86cb5cebfd28044ec0fd
                 {
                     case "VehicleStateProperty":
                         {
@@ -535,6 +555,22 @@ namespace OHV.Vehicle.Concept
                                 this.IsVehicleAlarm = false;
                         }
                         break;
+<<<<<<< HEAD
+
+                    case "MachineMode":
+                        this.MachineMode = CastTo<eMachineMode>.From<object>( args.Args );
+                        break;
+
+                    case "BatteryIsConnect":
+                        this.RspBatteryConnected( args );
+                        break;
+
+                    case "BatteryStateOfCharge":
+                        this.SOC = CastTo<double>.From<object>( args.Args );
+                        break;
+
+                    default:
+=======
                     case "MachineMode":
                         this.MachineMode = CastTo<eMachineMode>.From<object>( args.Args );
                         break;
@@ -554,6 +590,7 @@ namespace OHV.Vehicle.Concept
                         {
                             var cTime = CastTo<double>.From<object>( args.Args );
                         }
+>>>>>>> 69c47f10da3d0471e11a86cb5cebfd28044ec0fd
                         break;
                 }
             }
@@ -580,7 +617,7 @@ namespace OHV.Vehicle.Concept
             //}
             //var vsys = containerRegistry.GetContainer().Resolve<IContainerProvider>();
 
-            regionManager.RequestNavigate(RegionNames.MainView, "AutoView");
+            regionManager.RequestNavigate( RegionNames.MainView, "AutoView" );
         }
 
         public void Dispose()
@@ -588,38 +625,38 @@ namespace OHV.Vehicle.Concept
             //VCSystem.Instance.Dispose();
         }
 
-        public static void SelectCulture(string culture)
+        public static void SelectCulture( string culture )
         {
-            if (String.IsNullOrEmpty(culture))
+            if ( String.IsNullOrEmpty( culture ) )
                 return;
 
             //Copy all MergedDictionarys into a auxiliar list.
             var dictionaryList = Application.Current.Resources.MergedDictionaries.ToList();
 
             //Search for the specified culture.     
-            string requestedCulture = string.Format("StringResources.{0}.xaml", culture);
+            string requestedCulture = string.Format( "StringResources.{0}.xaml", culture );
             var resourceDictionary = dictionaryList.
-                FirstOrDefault(d => d.Source.OriginalString == "/OHV.ResourceDic;component/Resources/StringResource.en-US.xaml");
+                FirstOrDefault( d => d.Source.OriginalString == "/OHV.ResourceDic;component/Resources/StringResource.en-US.xaml" );
 
-            if (resourceDictionary == null)
+            if ( resourceDictionary == null )
             {
                 //If not found, select our default language.             
                 requestedCulture = "StringResources.xaml";
                 resourceDictionary = dictionaryList.
-                    FirstOrDefault(d => d.Source.OriginalString == requestedCulture);
+                    FirstOrDefault( d => d.Source.OriginalString == requestedCulture );
             }
 
             //If we have the requested resource, remove it from the list and place at the end.     
             //Then this language will be our string table to use.      
-            if (resourceDictionary != null)
+            if ( resourceDictionary != null )
             {
-                Application.Current.Resources.MergedDictionaries.Remove(resourceDictionary);
-                Application.Current.Resources.MergedDictionaries.Add(resourceDictionary);
+                Application.Current.Resources.MergedDictionaries.Remove( resourceDictionary );
+                Application.Current.Resources.MergedDictionaries.Add( resourceDictionary );
             }
 
             //Inform the threads of the new culture.     
-            Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
-            Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
+            Thread.CurrentThread.CurrentCulture = new CultureInfo( culture );
+            Thread.CurrentThread.CurrentUICulture = new CultureInfo( culture );
         }
     }
 }

+ 6 - 6
Dev/OHV/VehicleControlSystem/ControlLayer/Conveyor.cs

@@ -20,7 +20,7 @@ namespace VehicleControlSystem.ControlLayer
             this.ezIO = io;
         }
 
-        int OnOffConveyor( bool isOn, bool isLoad = false )
+        public int OnOffConveyor( bool isOn, bool isLoad = false )
         {
             if ( IsInverterError() )
                 return 16;
@@ -38,7 +38,7 @@ namespace VehicleControlSystem.ControlLayer
             return 0;
         }
 
-        void SetConveyorSpeed( bool IsHight )
+        public void SetConveyorSpeed( bool IsHight )
         {
             if ( IsHight )
                 this.ezIO.WriteOutputIO( "OUT_CV_DA", true );
@@ -46,14 +46,14 @@ namespace VehicleControlSystem.ControlLayer
                 this.ezIO.WriteOutputIO( "OUT_CV_DA", false );
         }
 
-        bool IsCvRun() => this.ezIO.IsOn( "OUT_CV_RUN" );
-        bool IsCvCWCCW() => this.ezIO.IsOn( "OUT_CV_CWCCW" );
+        public bool IsCvRun() => this.ezIO.IsOn( "OUT_CV_RUN" );
+        public bool IsCvCWCCW() => this.ezIO.IsOn( "OUT_CV_CWCCW" );
 
         /// <summary>
         /// 입구 감지 로딩시 감속 사용
         /// </summary>
         /// <returns></returns>
-        bool IsDetectedLoadStart() => this.ezIO.IsOn( "IN_CV_DETECT_00" );
+        public bool IsDetectedLoadStart() => this.ezIO.IsOn( "IN_CV_DETECT_00" );
 
         /// <summary>
         /// 실물 감지
@@ -62,7 +62,7 @@ namespace VehicleControlSystem.ControlLayer
         public bool IsDetectedCenter() => this.ezIO.IsOn( "IN_CV_DETECT_01" );
 
         public bool IsDetectedLoadStop() => this.ezIO.IsOn( "IN_CV_DETECT_02" );
-        bool IsInverterError() => !this.ezIO.IsOn( "IN_CV_ERROR" ); //Normal Close 로 생각 됨.
+        public bool IsInverterError() => !this.ezIO.IsOn( "IN_CV_ERROR" ); //Normal Close 로 생각 됨.
         public bool IsLifterPositinCheck() => this.ezIO.IsOn( "IN_LIFTER_POSITION_DETECT" );
         public bool IsLifterDuplication() => this.ezIO.IsOn( "IN_LIFTER_DUPLICATION_DETECT" );
         public bool IsPIOInterLockOn() => this.ezIO.IsOn( "OUT_PIO_INTERLOCK" );

+ 2 - 2
Dev/OHV/VehicleControlSystem/ControlLayer/Serial/BatteryTabos/BMUManager.cs

@@ -219,11 +219,11 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
             this.cancel.AddGo( _ThPullQueue );
 
             //읽기 시작.
-            
+
             switch ( select )
             {
                 case eCANSelect.Advantech:
-                    this.can = new Advantech( this , "can1" );
+                    this.can = new Advantech( this, "can1" );
                     this.cancel.AddGo( this.can._ThreadPoolingReceiveData );
                     break;
                 case eCANSelect.Peak:

+ 1 - 1
Dev/OHV/VehicleControlSystem/ControlLayer/Serial/BatteryTabos/Peak/Peak.cs

@@ -23,7 +23,7 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
         /// <summary>
         /// Peak USB Handle
         /// </summary>
-        UInt16 handle = PCANBasic.PCAN_PCIBUS1;
+        UInt16 handle = PCANBasic.PCAN_PCIBUS2;
 
         static Logger logger = Logger.GetLogger();
 

+ 43 - 94
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -470,11 +470,11 @@ namespace VehicleControlSystem.ControlLayer
         public void ReqConveyorMove( string dir )
         {
             if ( dir.Equals( "CW" ) )
-                this.OnOffConveyor( true, false );
+                this.conveyor.OnOffConveyor( true, false );
             else if ( dir.Equals( "CCW" ) )
-                this.OnOffConveyor( true, true );
+                this.conveyor.OnOffConveyor( true, true );
             else if ( dir.Equals( "STOP" ) )
-                this.OnOffConveyor( false, false );
+                this.conveyor.OnOffConveyor( false, false );
         }
 
         private void DriveControlEventPublish( DriveControlEventArgs args )
@@ -509,7 +509,7 @@ namespace VehicleControlSystem.ControlLayer
             return 0;
 #else
             int result = 0;
-            if ( this.IsDetectedCenter() ) //자제가 있으면 Lock
+            if ( this.conveyor.IsDetectedCenter() ) //자제가 있으면 Lock
                 result = this.clamp.Lock_Sync();
             else
                 result = this.clamp.Unlock_Sync();
@@ -692,18 +692,6 @@ namespace VehicleControlSystem.ControlLayer
             logger.D( "Vehicle - _ThObstacleChecker Dispose" );
         }
 
-        private void CheckIOState()
-        {
-            //이미 알람이면 체크 안함.
-            if ( this.VehicleStateProperty == eVehicleState.Abnormal ) return;
-
-            if ( !this.iO.IsConnectError ) return;
-
-            if ( this.iO.IsOn( "IN_EMS_SW" ) ) this.OccurVehicleAlarm( 28 );
-            if ( !this.iO.IsOn( "IN_CP_ON_SAFETY" ) ) this.OccurVehicleAlarm( 31 );
-            if ( !this.iO.IsOn( "IN_CP_ON_24V" ) ) this.OccurVehicleAlarm( 30 );
-            if ( !this.iO.IsOn( "IN_MC_ON" ) ) this.OccurVehicleAlarm( 29 );
-        }
 
         /// <summary>
         /// Scheduler 가 주는 Sub Command 를 이용하여 동작하자.
@@ -777,7 +765,7 @@ namespace VehicleControlSystem.ControlLayer
         #region Control Action Method
         public void EStop()
         {
-            OnOffConveyor( false );
+            this.conveyor.OnOffConveyor( false );
             //Clamp EStop
             this.clamp.ClampEStop();
             this.drive.EStop();
@@ -1124,63 +1112,24 @@ namespace VehicleControlSystem.ControlLayer
             return false;
         }
 
-        #endregion
-
-        #region Mechanical Method
-
-        #region Conveyor
-        /// <summary>
-        /// (Run = true, CW = true CCW = false)
-        /// </summary>
-        /// <param name="isOn"></param>
-        /// <param name="isLoad">bit On 시 Unload 방향 진행.</param>
-        /// <returns></returns>
-        int OnOffConveyor( bool isOn, bool isLoad = false )
+        void CheckIOState()
         {
-            if ( IsInverterError() )
-                return 16;
-
-            if ( isLoad )
-                this.iO.OutputOn( "OUT_CV_CWCCW" );
-            else
-                this.iO.OutputOff( "OUT_CV_CWCCW" );
-
-            if ( isOn )
-                this.iO.OutputOn( "OUT_CV_RUN" );
-            else
-                this.iO.OutputOff( "OUT_CV_RUN" );
+            //이미 알람이면 체크 안함.
+            if ( this.VehicleStateProperty == eVehicleState.Abnormal ) return;
 
-            return 0;
-        }
+            if ( !this.iO.IsConnectError ) return;
 
-        void SetConveyorSpeed( bool IsHight )
-        {
-            if ( IsHight )
-                this.iO.WriteOutputIO( "OUT_CV_DA", true );
-            else
-                this.iO.WriteOutputIO( "OUT_CV_DA", false );
+            if ( this.iO.IsOn( "IN_EMS_SW" ) ) this.OccurVehicleAlarm( 28 );
+            if ( !this.iO.IsOn( "IN_CP_ON_SAFETY" ) ) this.OccurVehicleAlarm( 31 );
+            if ( !this.iO.IsOn( "IN_CP_ON_24V" ) ) this.OccurVehicleAlarm( 30 );
+            if ( !this.iO.IsOn( "IN_MC_ON" ) ) this.OccurVehicleAlarm( 29 );
         }
 
-        bool IsCvRun() => this.iO.IsOn( "OUT_CV_RUN" );
-        bool IsCvCWCCW() => this.iO.IsOn( "OUT_CV_CWCCW" );
-
-        /// <summary>
-        /// 입구 감지 로딩시 감속 사용
-        /// </summary>
-        /// <returns></returns>
-        bool IsDetectedLoadStart() => this.iO.IsOn( "IN_CV_DETECT_00" );
+        #endregion
 
-        /// <summary>
-        /// 실물 감지
-        /// </summary>
-        /// <returns></returns>
-        public bool IsDetectedCenter() => this.iO.IsOn( "IN_CV_DETECT_01" );
+        #region Mechanical Method
 
-        bool IsDetectedLoadStop() => this.iO.IsOn( "IN_CV_DETECT_02" );
-        bool IsInverterError() => !this.iO.IsOn( "IN_CV_ERROR" ); //Normal Close 로 생각 됨.
-        bool IsLifterPositinCheck() => this.iO.IsOn( "IN_LIFTER_POSITION_DETECT" );
-        bool IsLifterDuplication() => this.iO.IsOn( "IN_LIFTER_DUPLICATION_DETECT" );
-        bool IsPIOInterLockOn() => this.iO.IsOn( "IN_PIO_INTERLOCK" );
+        #region Conveyor
 
         public int ConveyorLoad() => this.conveyor.ConveyorLoad();
 
@@ -1215,10 +1164,10 @@ namespace VehicleControlSystem.ControlLayer
 #else
             var pioTimeout = sql.ConfigDal.GetValueToInt( ConstString.PIOTimeOut );
 
-            if ( this.IsInverterError() )
+            if ( this.conveyor.IsInverterError() )
                 return 16;
 
-            if ( !this.IsLifterPositinCheck() )
+            if ( !this.conveyor.IsLifterPositinCheck() )
                 return 14;
 
             //Todo: Sensor Setting 이 후 주석 풀기.
@@ -1228,7 +1177,7 @@ namespace VehicleControlSystem.ControlLayer
             //    return 0;
             //}
 
-            if ( this.IsDetectedCenter() )
+            if ( this.conveyor.IsDetectedCenter() )
             {
                 this.OnFailReport?.Invoke( eFailCode.Load_VehicleHasCarrier );
                 return 0;
@@ -1250,15 +1199,15 @@ namespace VehicleControlSystem.ControlLayer
             }
             loggerPIO.E( "[Port] - 4 Ready On" );
 
-            this.SetConveyorSpeed( true );
-            this.OnOffConveyor( true, true );
+            this.conveyor.SetConveyorSpeed( true );
+            this.conveyor.OnOffConveyor( true, true );
             this.iO.WriteOutputIO( "OUT_PIO_RECEIVE_RUN", true, 1000 ); //1Sec 이후 On
             loggerPIO.I( "[Vehicle] - Conveyor Run" );
             this.OnConveyorStart?.Invoke( true );
 
             if ( !this.iO.WaitChangeInputIO( true, pioTimeout, "IN_PIO_SEND_RUN" ) )
             {
-                this.OnOffConveyor( false, true );
+                this.conveyor.OnOffConveyor( false, true );
                 PIOClear();
                 loggerPIO.E( "[Port] - 5 Sending Run Time Out" );
                 this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
@@ -1275,37 +1224,37 @@ namespace VehicleControlSystem.ControlLayer
                 if ( SwUtils.Gt( sTime, 20 * ConstUtils.ONE_SECOND ) )
                 {
                     PIOClear();
-                    this.OnOffConveyor( false, true );
+                    this.conveyor.OnOffConveyor( false, true );
                     loggerPIO.E( "[Vehicle] Conveyor Wait Time Out" );
                     this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
 
-                    if ( this.IsDetectedLoadStart() ) // 감지가 시작 되었으면 이동중 Error 로 판단 설비를 정지 상태로
+                    if ( this.conveyor.IsDetectedLoadStart() ) // 감지가 시작 되었으면 이동중 Error 로 판단 설비를 정지 상태로
                         return 10; //Conveyor Moving Timeout
                     else
                         return 0;
                 }
 
-                if ( this.IsDetectedLoadStart() && !isStartDetected )
+                if ( this.conveyor.IsDetectedLoadStart() && !isStartDetected )
                     isStartDetected = true;
 
-                if ( !this.IsDetectedLoadStart() && isStartDetected )
-                    this.SetConveyorSpeed( false );
+                if ( !this.conveyor.IsDetectedLoadStart() && isStartDetected )
+                    this.conveyor.SetConveyorSpeed( false );
 
-                if ( this.IsDetectedLoadStop() ) break;
+                if ( this.conveyor.IsDetectedLoadStop() ) break;
 
-                if ( this.IsPIOInterLockOn() )
+                if ( this.conveyor.IsPIOInterLockOn() )
                 {
                     PIOClear();
-                    this.OnOffConveyor( false ); //Stop
+                    this.conveyor.OnOffConveyor( false ); //Stop
                     loggerPIO.E( "[Port] PIO InterLock On " );
                     return 19; //
                 }
             }
 
-            if ( this.IsDetectedCenter() )
+            if ( this.conveyor.IsDetectedCenter() )
                 this.OnCarrierDetected?.Invoke( true );
 
-            this.OnOffConveyor( false ); //Stop
+            this.conveyor.OnOffConveyor( false ); //Stop
             PIOClear();
             this.OnConveyorStop?.Invoke( true );
             loggerPIO.I( "[Vehicle] Conveyor Stop" );
@@ -1354,22 +1303,22 @@ namespace VehicleControlSystem.ControlLayer
 #else
             var pioTimeout = sql.ConfigDal.GetValueToInt( ConstString.PIOTimeOut );
 
-            if ( this.IsInverterError() )
+            if ( this.conveyor.IsInverterError() )
                 return 16;
 
-            if ( this.IsLifterDuplication() )
+            if ( this.conveyor.IsLifterDuplication() )
             {
                 this.OnFailReport?.Invoke( eFailCode.Unload_PortHasCarrier );
                 return 0;
             }
 
-            if ( !this.IsDetectedCenter() )
+            if ( !this.conveyor.IsDetectedCenter() )
             {
                 this.OnFailReport?.Invoke( eFailCode.Unload_VehicleHasNotCarrier );
                 return 0;
             }
 
-            if ( !this.IsLifterPositinCheck() )
+            if ( !this.conveyor.IsLifterPositinCheck() )
                 return 13;
 
             PIOClear();
@@ -1398,8 +1347,8 @@ namespace VehicleControlSystem.ControlLayer
             this.iO.WriteOutputIO( "OUT_PIO_SENDING_RUN", true );
             loggerPIO.I( "[Vehicle] - 2 Send Run On" );
 
-            this.SetConveyorSpeed( true );
-            this.OnOffConveyor( true );
+            this.conveyor.SetConveyorSpeed( true );
+            this.conveyor.OnOffConveyor( true );
             this.OnConveyorStart?.Invoke( false );
 
             var sTime = SwUtils.CurrentTimeMillis;
@@ -1408,18 +1357,18 @@ namespace VehicleControlSystem.ControlLayer
                 if ( SwUtils.Gt( sTime, 20 * ConstUtils.ONE_SECOND ) )
                 {
                     PIOClear();
-                    this.OnOffConveyor( false, true );
+                    this.conveyor.OnOffConveyor( false, true );
                     loggerPIO.E( "[Port] Conveyor Wait Time Out" );
                     this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
 
-                    if ( IsDetectedLoadStart() || IsDetectedCenter() ) //중간에 걸려 있다고 생각해서 알람 처리.
+                    if ( this.conveyor.IsDetectedLoadStart() || this.conveyor.IsDetectedCenter() ) //중간에 걸려 있다고 생각해서 알람 처리.
                         return 12; //Conveyor Moving Timeout
                     else
                         return 0;
                 }
 
 
-                if ( !IsDetectedLoadStart() && !IsDetectedCenter() )
+                if ( !this.conveyor.IsDetectedLoadStart() && !this.conveyor.IsDetectedCenter() )
                 {
                     if ( this.iO.IsOn( "IN_PIO_RECEIVE_COMPLITE" ) )
                     {
@@ -1429,10 +1378,10 @@ namespace VehicleControlSystem.ControlLayer
                 }
             }
 
-            if ( !IsDetectedCenter() )
+            if ( !this.conveyor.IsDetectedCenter() )
                 this.OnCarrierDetected?.Invoke( false );
 
-            this.OnOffConveyor( false ); //Stop
+            this.conveyor.OnOffConveyor( false ); //Stop
             this.OnConveyorStop?.Invoke( false );
             PIOClear();