unque781 6 лет назад
Родитель
Сommit
0ab39541e1
28 измененных файлов с 296 добавлено и 134 удалено
  1. 10 3
      Dev/Connection/OHVProtocolServer/OHVConnector/Manager.cs
  2. 9 1
      Dev/Connection/OHVProtocolServer/OHVConnector/OCSMessage.cs
  3. BIN
      Dev/OHV/Assambly/OHVConnector.dll
  4. BIN
      Dev/OHV/Assambly/OHVConnector.pdb
  5. 2 0
      Dev/OHV/OHV.Common/Shareds/SharedEnumType.cs
  6. 1 0
      Dev/OHV/OHV.Module.Interactivity/NotificatioinView.xaml
  7. 1 1
      Dev/OHV/OHV.Module.Interactivity/PopUp/BatteryConfigView.xaml
  8. 12 5
      Dev/OHV/OHV.Module.Interactivity/PopUp/BatteryConfigViewModel.cs
  9. 1 0
      Dev/OHV/OHV.Module.Interactivity/PopUp/ConfigView.xaml
  10. 19 1
      Dev/OHV/OHV.SqliteDAL/DAL/AbstractDAL.cs
  11. 3 3
      Dev/OHV/OHV.Vehicle/Concept/D_MainWindowViewModel.cs
  12. BIN
      Dev/OHV/OHV.Vehicle/Config/AlarmDefind.xlsx
  13. 1 3
      Dev/OHV/VehicleControlSystem/ControlLayer/Clamp.cs
  14. 1 5
      Dev/OHV/VehicleControlSystem/ControlLayer/ControlObjectBase.cs
  15. 0 4
      Dev/OHV/VehicleControlSystem/ControlLayer/IO/EzIO.cs
  16. 30 28
      Dev/OHV/VehicleControlSystem/ControlLayer/MQ/ZmqManager.cs
  17. 12 4
      Dev/OHV/VehicleControlSystem/ControlLayer/Motion/GSIDrive.cs
  18. 1 1
      Dev/OHV/VehicleControlSystem/ControlLayer/Serial/BatteryTabos/BMUManager.cs
  19. 11 3
      Dev/OHV/VehicleControlSystem/ControlLayer/Serial/BatteryTabos/Peak/Peak.cs
  20. 15 13
      Dev/OHV/VehicleControlSystem/ControlLayer/Serial/DataModel/ReceivedData.cs
  21. 90 29
      Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs
  22. 6 1
      Dev/OHV/VehicleControlSystem/Managers/AutoManager.cs
  23. 7 4
      Dev/OHV/VehicleControlSystem/Managers/HostManager.cs
  24. 51 24
      Dev/OHV/VehicleControlSystem/Managers/Scheduler.cs
  25. 12 0
      Dev/OHV/VehicleControlSystem/VCSystem.cs.rej
  26. BIN
      Dev/OHVDriveLogger/OHVDriveLogger/.vs/OHVDriveLogger/v16/Server/sqlite3/storage.ide-shm
  27. BIN
      Dev/OHVDriveLogger/OHVDriveLogger/.vs/OHVDriveLogger/v16/Server/sqlite3/storage.ide-wal
  28. 1 1
      Dev/OHVDriveLogger/OHVDriveLogger/OHVDriveLogger/App.config

+ 10 - 3
Dev/Connection/OHVProtocolServer/OHVConnector/Manager.cs

@@ -328,6 +328,7 @@ namespace OHVConnector
             do
             {
                 stx = h.ReadByte(); //STX
+                //logger.D( $"[OCS] - {stx}" );
             }
             while ( stx != STX );
 
@@ -358,11 +359,11 @@ namespace OHVConnector
                 ocsMeg.Tag = h.ReadAscii( 4 );
                 ocsMeg.SubCode = h.ReadAscii( 3 );
                 var viaCount = Convert.ToInt16( h.ReadAscii( 4 ) ); //4byte
-                for(int i = 0; i < viaCount; i++ )
+                for ( int i = 0; i < viaCount; i++ )
                 {
                     ocsMeg.ViaRouteList.Add( h.ReadAscii( 4 ) );
                 }
-                ocsMeg.CheckSum = h.ReadAscii(1);
+                ocsMeg.CheckSum = h.ReadAscii( 1 );
                 h.ReadUntil( ETX );
             }
             else
@@ -372,7 +373,7 @@ namespace OHVConnector
                 ocsMeg.SubCode = h.ReadAscii( 3 );
 
                 //CheckSum 을 해야 하나??
-                ocsMeg.CheckSum = h.ReadAscii(1);
+                ocsMeg.CheckSum = h.ReadAscii( 1 );
                 h.ReadUntil( ETX );
             }
 
@@ -413,6 +414,12 @@ namespace OHVConnector
                 return;
             }
 
+            if ( recd.Kind == eKind.M && !ModeActive ) //M Code 응답은 없음 
+            {
+                this.qQ.Enqueue( new QoRecd { Arg0 = recd } );
+                return;
+            }
+
             //Send 한 Message 의 Reply 로 판단.
             if ( this.quzT3.HasId( recd.CheckSum ) )
             {

+ 9 - 1
Dev/Connection/OHVProtocolServer/OHVConnector/OCSMessage.cs

@@ -56,7 +56,15 @@ namespace OHVConnector
 
         public string LogFormat()
         {
-            return $"{this.Id} - {this.RevID} <- {this.SendID} : kind [{this.Kind.ToString()}] / Tag [{this.Tag}] / SubCode [{this.SubCode}] / CheckSum [{this.CheckSum}]";
+            if ( this.ViaRouteList.Count <= 0 )
+                return $"{this.Id} - {this.RevID} <- {this.SendID} : kind [{this.Kind.ToString()}] / Tag [{this.Tag}] / SubCode [{this.SubCode}] / CheckSum [{this.CheckSum}] / {this.ViaRouteList.Count}";
+            else
+            {
+                StringBuilder viaList = new StringBuilder();
+                var ll = this.ViaRouteList.ToList();
+                ll.ForEach( x => { viaList.Append( x ); viaList.Append( ";" ); } ); 
+                return $"{this.Id} - {this.RevID} <- {this.SendID} : kind [{this.Kind.ToString()}] / Tag [{this.Tag}] / SubCode [{this.SubCode}] / CheckSum [{this.CheckSum}] / {this.ViaRouteList.Count} / {viaList}";
+            }
         }
 
         public int SubCodeToInt()

BIN
Dev/OHV/Assambly/OHVConnector.dll


BIN
Dev/OHV/Assambly/OHVConnector.pdb


+ 2 - 0
Dev/OHV/OHV.Common/Shareds/SharedEnumType.cs

@@ -119,6 +119,7 @@
 		MoveNLoad,
 		MoveNUnload,
 		Charging,
+		Cancel,
 	}
 
 	public enum eCommandState
@@ -143,6 +144,7 @@
 		Load,
 		Unload,
 		Charge,
+		Cancel,
 	}
 
 	#endregion

+ 1 - 0
Dev/OHV/OHV.Module.Interactivity/NotificatioinView.xaml

@@ -12,6 +12,7 @@
 
     <prism:Dialog.WindowStyle>
         <Style TargetType="Window">
+            <Setter Property="Topmost" Value="True"/>
             <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterScreen" />
             <Setter Property="Background" Value="Transparent"/>
             <Setter Property="AllowsTransparency" Value="True"/>

+ 1 - 1
Dev/OHV/OHV.Module.Interactivity/PopUp/BatteryConfigView.xaml

@@ -130,7 +130,7 @@
                                VerticalAlignment="Center"
                                HorizontalAlignment="Center"
                                Foreground="Orange" FontSize="20">
-                                <Run Text="{Binding BatteryState, StringFormat={}{0:0}, FallbackValue=0x0}"/>
+                                <Run Text="{Binding BatteryState}"/>
                             </TextBlock>
                         </Border>
 

+ 12 - 5
Dev/OHV/OHV.Module.Interactivity/PopUp/BatteryConfigViewModel.cs

@@ -14,6 +14,7 @@ using System.Threading.Tasks;
 using System.Windows.Input;
 using System.Windows.Media;
 using VehicleControlSystem;
+using VehicleControlSystem.ControlLayer.Serial.DataModel;
 
 namespace OHV.Module.Interactivity.PopUp
 {
@@ -47,11 +48,17 @@ namespace OHV.Module.Interactivity.PopUp
             set { this.SetProperty( ref this.current , value ); }
         }
 
-        double batteryState;
-        public double BatteryState
+        //double batteryState;
+        //public double BatteryState
+        //{
+        //    get { return this.batteryState; }
+        //    set { this.SetProperty( ref this.batteryState , value ); }
+        //}
+        string batteryState = string.Empty;
+        public string BatteryState
         {
             get { return this.batteryState; }
-            set { this.SetProperty( ref this.batteryState , value ); }
+            set { this.SetProperty( ref this.batteryState, value ); }
         }
 
         double averageTimeToFull;
@@ -142,7 +149,7 @@ namespace OHV.Module.Interactivity.PopUp
                             this.Current = CastTo<double>.From<object>( obj.Args );
                             break;
                         case "BatteryState":
-                            this.BatteryState = CastTo<double>.From<object>( obj.Args );
+                            this.BatteryState = ((eBatteryState)CastTo<double>.From<object>( obj.Args )).ToString();
                             break;
                         case "BatteryChargeTime":
                             this.AverageTimeToFull = CastTo<double>.From<object>( obj.Args );
@@ -198,7 +205,7 @@ namespace OHV.Module.Interactivity.PopUp
             this.SOC = args.SOC;
             this.SOH = args.SOH;
             this.Temperature = args.Temperature;
-            this.BatteryState = args.State;
+            this.BatteryState = args.State.ToString();
             this.Capacity = args.Capacity;
 
             if(args.IsConnect)

+ 1 - 0
Dev/OHV/OHV.Module.Interactivity/PopUp/ConfigView.xaml

@@ -13,6 +13,7 @@
 
     <prism:Dialog.WindowStyle>
         <Style TargetType="Window">
+            <Setter Property="Topmost" Value="True"/>
             <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterScreen" />
             <Setter Property="Background" Value="Transparent"/>
             <Setter Property="AllowsTransparency" Value="True"/>

+ 19 - 1
Dev/OHV/OHV.SqliteDAL/DAL/AbstractDAL.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Data.Entity;
 using System.Data.Entity.Core.Objects;
+using System.Data.Entity.Infrastructure;
 using System.Linq;
 using System.Linq.Expressions;
 using System.Text;
@@ -198,6 +199,12 @@ namespace OHV.SqliteDAL.DAL
         {
             lock ( this.lockObj )
             {
+                if ( obj == null )
+                {
+                    logger.E( $"[DataBase] - Update obj is Null {this.table.GetType().Name}" );
+                    return;
+                }
+
                 table.Attach( obj );
                 _context.Entry( obj ).State = EntityState.Modified;
                 this.Save();
@@ -238,7 +245,18 @@ namespace OHV.SqliteDAL.DAL
         }
         public void Save()
         {
-            _context.SaveChanges();
+            try
+            {
+                _context.SaveChanges();
+
+            }
+            catch ( DbUpdateConcurrencyException ex )
+            {
+                ex.Entries.Single().Reload();
+                logger.E( $"[DataBase] - DbUpdateConcurrencyException {this.table.GetType().Name}" );
+                return;
+            }
+
             this.OnChangeTable?.BeginInvoke( null, null );
         }
     }

+ 3 - 3
Dev/OHV/OHV.Vehicle/Concept/D_MainWindowViewModel.cs

@@ -427,14 +427,14 @@ namespace OHV.Vehicle.Concept
             {
                 this.StartEnable = false;
                 this.StopEnable = true;
-                //this.IsManualMode = false;
-                //regionManager.RequestNavigate( RegionNames.MainView, "AutoView" );
+                this.IsManualMode = false;
+                regionManager.RequestNavigate( RegionNames.MainView, "AutoView" );
             }
             else
             {
                 this.StartEnable = true;
                 this.StopEnable = false;
-                //this.IsManualMode = true;
+                this.IsManualMode = true;
             }
         }
 

BIN
Dev/OHV/OHV.Vehicle/Config/AlarmDefind.xlsx


+ 1 - 3
Dev/OHV/VehicleControlSystem/ControlLayer/Clamp.cs

@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.Linq;
-using System.Security.Cryptography.X509Certificates;
 using System.Threading;
 using System.Threading.Tasks;
 using FluentResults;

+ 1 - 5
Dev/OHV/VehicleControlSystem/ControlLayer/ControlObjectBase.cs

@@ -1,10 +1,6 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.ComponentModel;
-using System.Linq;
 using System.Runtime.CompilerServices;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace VehicleControlSystem.ControlLayer
 {

+ 0 - 4
Dev/OHV/VehicleControlSystem/ControlLayer/IO/EzIO.cs

@@ -737,7 +737,6 @@ namespace VehicleControlSystem.ControlLayer.IO
             {
                 if ( disposing )
                 {
-                    // TODO: 관리되는 상태(관리되는 개체)를 삭제합니다.
                     if ( this.pullThread != null )
                     {
                         this.IsThreadAlive = false;
@@ -753,9 +752,6 @@ namespace VehicleControlSystem.ControlLayer.IO
                     Terminate(); //Board Close 
                 }
 
-                // TODO: 관리되지 않는 리소스(관리되지 않는 개체)를 해제하고 아래의 종료자를 재정의합니다.
-                // TODO: 큰 필드를 null로 설정합니다.
-
                 disposedValue = true;
             }
         }

+ 30 - 28
Dev/OHV/VehicleControlSystem/ControlLayer/MQ/ZmqManager.cs

@@ -1,20 +1,14 @@
 using GSG.NET.Concurrent;
 using GSG.NET.Extensions;
 using GSG.NET.Logging;
-using GSG.NET.ObjectBase;
 using NetMQ;
 using NetMQ.Monitoring;
 using NetMQ.Sockets;
 using OHV.Common.Model;
 using OHV.Common.Shareds;
-using StackExchange.Redis.Extensions.Core.Extensions;
 using System;
 using System.Collections.Generic;
-using System.Diagnostics;
 using System.Linq;
-using System.Runtime.InteropServices.WindowsRuntime;
-using System.Text;
-using System.Threading.Tasks;
 using VehicleControlSystem.ControlLayer.Serial.BatteryTabos;
 using VehicleControlSystem.ControlLayer.Serial.DataModel;
 using VehicleControlSystem.Managers;
@@ -194,30 +188,38 @@ namespace VehicleControlSystem.ControlLayer.MQ
 
         private void BMUManager_OnChangedReceivedData( Serial.DataModel.ReceivedData obj )
         {
-            var kind = CastTo<eDataKind>.From<Enum>( obj.DataKind );
-            switch ( kind )
+            try
             {
-                case eDataKind.Current:
-                    this.pub.SendMoreFrame( "BatteryCurrent" ).SendFrame( obj.Value.ToString() ); 
-                    break;
-                case eDataKind.Voltage:
-                    this.pub.SendMoreFrame( "BatteryVoltage" ).SendFrame( obj.Value.ToString() ); 
-                    break;
-                case eDataKind.BatteryState:
-                case eDataKind.ChargeCompleteTime:
-                case eDataKind.DisChargeCompleteTime:
-                    break;
-                case eDataKind.SOC:
-                    this.pub.SendMoreFrame( "BatterySOC" ).SendFrame( obj.Value.ToString() ); 
-                    break;
-                case eDataKind.SOH:
-                case eDataKind.ResidualCapacity:
-                case eDataKind.ResidualEnergy:
-                case eDataKind.Temperature:
-                    break;
-                default:
-                    break;
+                var kind = CastTo<eDataKind>.From<Enum>( obj.DataKind );
+                switch ( kind )
+                {
+                    case eDataKind.Current:
+                        this.pub.SendMoreFrame( "BatteryCurrent" ).SendFrame( obj.Value.ToString() );
+                        break;
+                    case eDataKind.Voltage:
+                        this.pub.SendMoreFrame( "BatteryVoltage" ).SendFrame( obj.Value.ToString() );
+                        break;
+                    case eDataKind.BatteryState:
+                    case eDataKind.ChargeCompleteTime:
+                    case eDataKind.DisChargeCompleteTime:
+                        break;
+                    case eDataKind.SOC:
+                        this.pub.SendMoreFrame( "BatterySOC" ).SendFrame( obj.Value.ToString() );
+                        break;
+                    case eDataKind.SOH:
+                    case eDataKind.ResidualCapacity:
+                    case eDataKind.ResidualEnergy:
+                    case eDataKind.Temperature:
+                        break;
+                    default:
+                        break;
+                }
+
             }
+            catch ( Exception ex )
+            {
+                logger.E( ex );
+            }   
         }
 
         public void Dispose()

+ 12 - 4
Dev/OHV/VehicleControlSystem/ControlLayer/Motion/GSIDrive.cs

@@ -80,8 +80,8 @@ namespace VehicleControlSystem.ControlLayer.Drive
 
         public void Init()
         {
-            this.threadCancel.AddGo( Thread_DriveStateChcker );
-            this.threadCancel.AddGo( Thread_Logger );
+            //this.threadCancel.AddGo( Thread_DriveStateChcker );
+            //this.threadCancel.AddGo( Thread_Logger );
 
             zmq.PropertyChanged += Zmq_PropertyChanged;
 
@@ -227,11 +227,14 @@ namespace VehicleControlSystem.ControlLayer.Drive
             if ( IsDriveFault() )
                 return 34;
 
-            //ToDo: 이동 명령 실행.
             int result = ConstInt.EXECUTE_SUCCESS;
 
+            var steeringState = steering.GetSteeringState();
+            if (steeringState == eSteeringState.None ) //현재 가 None 이면 기다렸다가 다시 확인 필요.
+                LockUtils.Wait( 500 );
+
             zmq.SetCurrentSteeringState( steering.GetSteeringState() );
-            LockUtils.Wait( 100 );
+            LockUtils.Wait( 200 );
 
             StringBuilder sb = new StringBuilder();
             if ( sub.TargetList.Count <= 0 )
@@ -282,6 +285,11 @@ namespace VehicleControlSystem.ControlLayer.Drive
             return ConstInt.EXECUTE_SUCCESS;
         }
 
+        public void CancelCommand(SubCmd subCmd)
+        {
+
+        }
+
         /// <summary>
         /// 급정시 사용.
         /// </summary>

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

@@ -186,7 +186,7 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
             } );
 
             //다음 timer 기동 시 까지 잠시 대기
-            polling.Once( _OnTimePoll, 100 );
+            polling.Once( _OnTimePoll, 300 );
         }
 
         void _OnTimePoll()

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

@@ -113,7 +113,6 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
                 this.IsConnected = this.GetStatus();
         }
 
-        //Todo:Dll 에서 상태 가져오기
         bool isConnected = false;
         public bool IsConnected
         {
@@ -304,7 +303,10 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
                 if ( stsResult == TPCANStatus.PCAN_ERROR_OK && canMsg.ID == 0x460 )
                     this.PeackCANRecv( canMsg );
                 else if ( canMsg.ID != 0x460 )
-                    this.isConnected = this.GetStatus();
+                {
+                    this.IsConnected = this.GetStatus();
+                    return stsResult = TPCANStatus.PCAN_ERROR_UNKNOWN;
+                }
             }
 
             return stsResult;
@@ -313,6 +315,12 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
         void PeackCANRecv(TPCANMsg recv)
         {
             var mb = new MemoryBuffer( recv.DATA );
+            
+            if ( mb.Length < 8 )
+            {
+                logger.E( $" - [Battery Recv Length Error] - {mb.Length} -" );
+                return;
+            }
 
             mb.Read1Byte();
             var index =  ( eCanRecvCase )mb.Read1Byte();
@@ -324,7 +332,7 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
                 case eCanRecvCase.CASE1:
                     this.manager.ReceivedDataDic[ eDataKind.Voltage ].Value = mb.ReadLeShort();
                     this.manager.ReceivedDataDic[eDataKind.Current].Value = mb.ReadLeShort();
-                    this.manager.ReceivedDataDic[ eDataKind.BatteryState ].Value = mb.ReadLeShort();
+                    this.manager.ReceivedDataDic[eDataKind.BatteryState].Value = mb.ReadLeShort();
                     break;
                 case eCanRecvCase.CASE2:
                     this.manager.ReceivedDataDic[ eDataKind.ChargeCompleteTime ].Value = mb.ReadLeShort();

+ 15 - 13
Dev/OHV/VehicleControlSystem/ControlLayer/Serial/DataModel/ReceivedData.cs

@@ -22,6 +22,7 @@ namespace VehicleControlSystem.ControlLayer.Serial.DataModel
 
     public enum eBatteryState
     {
+        None = 0,
         OverVolte,
         LowVolte,
         OverChargeCurrent,
@@ -38,21 +39,22 @@ namespace VehicleControlSystem.ControlLayer.Serial.DataModel
 
         public string Orgvalue { get; set; }
 
-        public double? Value { 
+        public double Value { 
             get 
-            { 
-                if ( this.DataKind != eDataKind.BatteryState )
-                {
-                    double dOrg = 0d;
-                    double.TryParse( this.Orgvalue, out dOrg );
+            {
+                double dOrg = 0d;
+                double.TryParse( this.Orgvalue, out dOrg );
 
-                    return dOrg;
-                }
-                else
-                {
-                    return null;
-                }
-            } 
+                return dOrg;
+
+                //if ( this.DataKind != eDataKind.BatteryState )
+                //{
+                //    double dOrg = 0d;
+                //    double.TryParse( this.Orgvalue, out dOrg );
+
+                //    return dOrg;
+                //}
+            }
             set
             {
                 if(Value != (double)value)

+ 90 - 29
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -2,7 +2,6 @@
 using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
-using System.Security.Cryptography.X509Certificates;
 using System.Threading;
 using System.Threading.Tasks;
 using FluentResults;
@@ -10,7 +9,6 @@ using GSG.NET.Concurrent;
 using GSG.NET.Extensions;
 using GSG.NET.LINQ;
 using GSG.NET.Logging;
-using GSG.NET.Quartz;
 using GSG.NET.Utils;
 using OHV.Common.Events;
 using OHV.Common.Model;
@@ -167,6 +165,11 @@ namespace VehicleControlSystem.ControlLayer
             {
                 if ( SetField( ref this.vehicleState, value ) )
                 {
+                    if ( value == eVehicleState.Charge )
+                        this.OnCharging?.Invoke();
+                    else
+                        this.OnChargingFull?.Invoke();
+
                     var info = sql.VehicleInfoDAL.GetAll().FirstOrDefault();
                     info.VehicleState = value;
                     sql.VehicleInfoDAL.Update( info );
@@ -869,6 +872,10 @@ namespace VehicleControlSystem.ControlLayer
                             this.CurrentSubCommand = subCmd;
                             this.BatteryCharge( subCmd );
                             break;
+                        case eSubCommandType.Cancel:
+                            this.CurrentSubCommand = subCmd;
+                            CancelCommand( subCmd );
+                            break;
                         default:
                             break;
                     }
@@ -885,6 +892,18 @@ namespace VehicleControlSystem.ControlLayer
             logger.D( "Vehicle - _ThSubCmdWorker Dispose" );
         }
 
+        private void CancelCommand( SubCmd subCmd )
+        {
+            this.refObjects.Drive.CancelCommand( subCmd );
+
+            var cmd = sql.CommandDAL.GetById( subCmd.CmdID );
+            cmd.State = eCommandState.Complete;
+            sql.CommandDAL.Update( cmd );
+            sql.SubCmdDAL.Clean();
+
+            logger.D( $"[Cancel Command] {cmd.TargetID} / {cmd.Type}" );
+        }
+
         #endregion
 
         #region Control Action Method
@@ -923,10 +942,12 @@ namespace VehicleControlSystem.ControlLayer
                 }
             }
 
+            sql.SubCmdDAL.Clean();
+
             this.taskMoveCancel.Cancel();
             this.taskMoveCancel.WaitAll();
 
-            sql.SubCmdDAL.Clean();
+            logger.D( $"[Move Command Complete] {sub.TargetID}" );
         }
 
         int MoveTo( SubCmd sub )
@@ -982,7 +1003,6 @@ namespace VehicleControlSystem.ControlLayer
 
                 if ( SwUtils.Gt( st, waitTime ) )
                 {
-                    //Todo: 이동시간 초과 시 동작들.
                     logger.D( "Wait4MoveDone Time Over" );
                     return 39;
                 }
@@ -1057,10 +1077,13 @@ namespace VehicleControlSystem.ControlLayer
             this.PIOSensorOff();
 
             //Load, Unload 가 끝나면 메인 Command 를 완료 했다고 판단.
-            var cmd = sql.CommandDAL.GetById( sub.CmdID );
-            cmd.State = eCommandState.Complete;
-            sql.CommandDAL.Update( cmd );
             sql.SubCmdDAL.Clean();
+            var cmd = sql.CommandDAL.GetById( sub.CmdID );
+            if ( cmd != null )
+            {
+                cmd.State = eCommandState.Complete;
+                sql.CommandDAL.Update( cmd );
+            }
 
             LockUtils.Wait( 1000 );
             this.OnLoadComplete?.Invoke(); //일찍 주면 다음 명령을 500ms 안에 주는 현상 있음. 그러니까 천천히 주자 
@@ -1107,10 +1130,13 @@ namespace VehicleControlSystem.ControlLayer
 
             this.PIOSensorOff();
 
-            var cmd = sql.CommandDAL.GetById( sub.CmdID );
-            cmd.State = eCommandState.Complete;
-            sql.CommandDAL.Update( cmd );
             sql.SubCmdDAL.Clean();
+            var cmd = sql.CommandDAL.GetById( sub.CmdID );
+            if ( cmd != null )
+            {
+                cmd.State = eCommandState.Complete;
+                sql.CommandDAL.Update( cmd );
+            }
 
             LockUtils.Wait( 1000 );
             this.OnUnloadComplete?.Invoke(); //일찍 주면 다음 명령을 500ms 안에 주는 현상 있음. 그러니까 천천히 주자 
@@ -1128,10 +1154,14 @@ namespace VehicleControlSystem.ControlLayer
             if ( result != ConstInt.EXECUTE_SUCCESS )
                 this.OccurVehicleAlarm( result );
 
+            sql.SubCmdDAL.Clean();
+
             var cmd = sql.CommandDAL.GetById( subCmd.CmdID );
+            if ( cmd == null )
+                return;
+
             cmd.State = eCommandState.Complete;
             sql.CommandDAL.Update( cmd );
-            sql.SubCmdDAL.Clean();
         }
 
         /// <summary>
@@ -1250,6 +1280,7 @@ namespace VehicleControlSystem.ControlLayer
             return 0;
 #else
             this.PIOSensorOn();
+            LockUtils.Wait( 500 );
 
             var pioTimeout = Convert.ToInt32( sql.ConfigDal.GetById( ConstString.PIOTimeOut ).Value );
 
@@ -1267,7 +1298,7 @@ namespace VehicleControlSystem.ControlLayer
             this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECEIVABLE", true );
             loggerPIO.I( "[Vehicle] - 4 Receivable" );
 
-            if ( !this.refObjects.IO.WaitChangeInputIO( true, 20000, "IN_PIO_SEND_RUN" ) )
+            if ( !this.refObjects.IO.WaitChangeInputIO( true, 5000, "IN_PIO_SEND_RUN" ) )
             {
                 PIOClear();
                 loggerPIO.E( "[Port] - 5 Sending Run Time Out" );
@@ -1326,7 +1357,7 @@ namespace VehicleControlSystem.ControlLayer
             this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECIVE_COMPLITE", true );
             loggerPIO.I( "[Vehicle] Receive Complete On" );
 
-            if ( !this.refObjects.IO.WaitChangeInputIO( true, 10000, "IN_PIO_SEND_COMPLITE" ) )
+            if ( !this.refObjects.IO.WaitChangeInputIO( true, 5000, "IN_PIO_SEND_COMPLITE" ) )
             {
                 this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECIVE_COMPLITE", false );
                 loggerPIO.E( "[Port]  IN_PIO_SEND_COMPLITE On Time Out" );
@@ -1445,6 +1476,8 @@ namespace VehicleControlSystem.ControlLayer
             Thread.Sleep( 1000 );
             this.OnLoadComplete?.Invoke();
 #else
+            loggerPIO.I( $"Start Load PIO - [{targetName}]" );
+
             this.PIOSensorOn();
             LockUtils.Wait( 500 );
 
@@ -1461,24 +1494,34 @@ namespace VehicleControlSystem.ControlLayer
             if ( this.refObjects.Conveyor.IsInverterError() )
                 return 16;
 
-            if ( !this.refObjects.Conveyor.IsLifterPositinCheck() )
-                return 14;
+            if ( !this.refObjects.IO.WaitChangeInputIO( true, 20 * ConstUtils.ONE_SECOND, "IN_LIFTER_POSITION_DETECT" ) )
+            {
+                loggerPIO.E( "[Port] - Lift Position Check Error" );
+                this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
+                return 0; //14
+            }
 
-            //Todo: Sensor Setting 이 후 주석 풀기.
-            //if ( !this.IsLifterDuplication() )
-            //{
-            //    this.OnFailReport?.Invoke( eFailCode.Load_PortHasNotCarrier );
-            //    return 0;
-            //}
+            //if ( !this.refObjects.Conveyor.IsLifterPositinCheck() )
+                //{
+                //    loggerPIO.E( "[Port] - Lift Position Check Error" );
+                //    this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
+                //    return 0; //14
+                //}
 
-            if ( this.refObjects.Conveyor.IsDetectedCenter() )
+                //Todo: Sensor Setting 이 후 주석 풀기.
+                //if ( !this.IsLifterDuplication() )
+                //{
+                //    this.OnFailReport?.Invoke( eFailCode.Load_PortHasNotCarrier );
+                //    return 0;
+                //}
+
+                if ( this.refObjects.Conveyor.IsDetectedCenter() )
             {
                 this.OnFailReport?.Invoke( eFailCode.Load_VehicleHasCarrier );
                 return 0;
             }
 
             PIOClear();
-            loggerPIO.I( $"Start Load PIO - [{targetName}]" );
             this.OnPIOStart?.Invoke( true );
 
             this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECEIVABLE", true );
@@ -1601,6 +1644,7 @@ namespace VehicleControlSystem.ControlLayer
             Thread.Sleep( 1000 );
             this.OnUnloadComplete?.Invoke();
 #else
+            loggerPIO.E( $"Start Unload PIO -[{targetName}]" );
             this.PIOSensorOn();
             LockUtils.Wait( 500 );
 
@@ -1623,11 +1667,21 @@ namespace VehicleControlSystem.ControlLayer
                 return 0;
             }
 
-            if ( !this.refObjects.Conveyor.IsLifterPositinCheck() )
-                return 13;
+            if ( !this.refObjects.IO.WaitChangeInputIO( true, 20 * ConstUtils.ONE_SECOND, "IN_LIFTER_POSITION_DETECT" ) )
+            {
+                loggerPIO.E( "[Port] - Lift Position Check Error" );
+                this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
+                return 0;
+            }
+
+            //if ( !this.refObjects.Conveyor.IsLifterPositinCheck() )
+            //{
+            //    loggerPIO.E( "[Port] - Lift Position Check Error" );
+            //    this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout ); //Unloading Fail Code 를 Time Out 으로 하자. 정의 된 코드 없음.
+            //    return 0; //13 -> Alarm Code 보고 없음. 경알람 상태 이므로 한번 보고 후 정상 동작
+            //}
 
             PIOClear();
-            loggerPIO.I( $"Start Unload PIO - [{targetName}]" );
             this.OnPIOStart?.Invoke( false );
 
             if ( !this.refObjects.IO.IsOn( "IN_PIO_READY" ) )
@@ -1867,8 +1921,15 @@ namespace VehicleControlSystem.ControlLayer
                     if ( obj.Value == null /*|| obj.Value <= 0 */)
                         return;
                     this.BatteryChargeTime = (double)obj.Value;
-                    if ( this.BatteryChargeTime > 0 )
-                        this.VehicleStateProperty = eVehicleState.Charge;
+
+                    //if ( this.BatteryChargeTime > 0 )
+                    //{
+                    //    //this.OnCharging?.Invoke();
+                    //    //this.VehicleStateProperty = eVehicleState.Charge;
+                    //}
+                    //else
+                    //    //this.OnChargingFull?.Invoke();
+
                     break;
                 case eDataKind.DisChargeCompleteTime:
                     if ( obj.Value == null || obj.Value <= 0 )
@@ -1877,7 +1938,7 @@ namespace VehicleControlSystem.ControlLayer
                     break;
                 case eDataKind.SOC:
                     this.BatteryStateOfCharge = (double)obj.Value;
-                    if ( this.BatteryStateOfCharge >= 80 )
+                    if ( this.BatteryStateOfCharge >= 78 )
                     {
                         if ( this.autoManager.AutoModeStateProperty != eAutoModeState.Run )
                             return;

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

@@ -142,7 +142,10 @@ namespace VehicleControlSystem.Managers
         #region Vehicle Events
         private void Vehicle_OnChargingFull()
         {
-            LampStateChange( eLampState.AutoRunNChargingFull );
+            if ( this.OperationModeProperty == eOperatationMode.AutoMode )
+                LampStateChange( eLampState.AutoRunNChargingFull );
+            else
+                LampStateChange( eLampState.Alarm );
         }
 
         private void Vehicle_OnCharging()
@@ -304,6 +307,8 @@ namespace VehicleControlSystem.Managers
                 alarm = new Alarm();
                 alarm.AlarmId = alarmID;
                 alarm.Text = "Not Define Alarm";
+
+                logger.E( $"[{this.GetType().Name}] - Not Defiine Alarm No {alarmID}" );
             }
             else
             {

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

@@ -9,8 +9,6 @@ using VehicleControlSystem.ControlLayer;
 using GSG.NET.Extensions;
 using OHV.Common.Model;
 using GSG.NET.Quartz;
-using System.Text;
-using GSG.NET.LINQ;
 using System.Linq;
 using System.Collections.Generic;
 
@@ -446,16 +444,20 @@ namespace VehicleControlSystem.Managers
                         case "003": //Move and Charge
                             cmd.Type = eCommandType.Charging;
                             break;
+                        case "004": //Cancel
+                            cmd.Type = eCommandType.Cancel;
+                            break;
                         default:
                             return;
                     }
+
                     cmd.ByWho = eCommandByWho.HostOverWrite;
                     cmd.TargetList = new List<string>( msg.ViaRouteList );
 
                     cmd.TargetID = msg.Tag;
 
                     this.sql.CommandDAL.Insert( cmd );
-                    logger.I( $"[Command] - Add Host : Target {cmd.TargetID} / Type {cmd.Type}" );
+                    logger.I( $"[Command] - Add HostOverWrite : Target {cmd.TargetID} / Type {cmd.Type}" );
 
                     sql.CommandDAL.Delete( hasCommand.CommandID );
                 }
@@ -480,13 +482,14 @@ namespace VehicleControlSystem.Managers
                     case "002": //Move and Unload
                         cmd.Type = eCommandType.MoveNUnload;
                         break;
-                    case "003": //Move and Charge
+                    case "003": //Cancel
                         cmd.Type = eCommandType.Charging;
                         break;
                     default:
                         return;
                 }
                 cmd.ByWho = eCommandByWho.Host;
+                cmd.TargetList = new List<string>( msg.ViaRouteList );
 
                 this.sql.CommandDAL.Insert( cmd );
                 logger.I( $"[Command] - Add Host : Target {cmd.TargetID} / Type {cmd.Type}" );

+ 51 - 24
Dev/OHV/VehicleControlSystem/Managers/Scheduler.cs

@@ -160,13 +160,13 @@ namespace VehicleControlSystem.Managers
 
 
         int copyTarget = 0;
-
+        bool isSTK = false;
         void DryRunTest()
         {
             if ( !IsCreateDryRunCommand )
                 return;
 
-            if ( this.bMUManager.ReceivedDataDic[eDataKind.SOC].Value <= 10 )
+            if ( this.bMUManager.ReceivedDataDic[eDataKind.SOC].Value <= 30 )
             {
                 //var targetPoint = "2";
                 //Command cmd = new Command() { TargetID = targetPoint, Type = eCommandType.Charging };
@@ -178,35 +178,54 @@ namespace VehicleControlSystem.Managers
                 return;
             }
 
-            var ram = NumUtils.Random( 0, RouteManager.Instance.Equipments.Count - 1 );
-            if ( ram == this.copyTarget )
-                return;
+            string targetPoint = string.Empty;
+            if ( isSTK )
+            {
+                targetPoint = RouteManager.Instance.Equipments.Where( x => x.Name.Equals( "CAN_STATION_IP01" ) ).SingleOrDefault().pointID.ToString();
+                isSTK = false;
+            }
             else
             {
-                var target = RouteManager.Instance.Equipments[ram];
-                this.copyTarget = ram;
+                targetPoint = RouteManager.Instance.Equipments.Where( x => x.Name.Equals( "STOKER_LIFT_IP01" ) ).SingleOrDefault().pointID.ToString();
+                isSTK = true;
+            }
 
-                var targetPoint = target.pointID.ToString();
-                Command cmd = new Command() { TargetID = targetPoint, Type = eCommandType.Move };
-                cmd.ByWho = eCommandByWho.LocalSystem;
+            Command cmd = new Command() { TargetID = targetPoint, Type = eCommandType.Move };
+            cmd.ByWho = eCommandByWho.LocalSystem;
 
-                this.AddCommand( cmd );
-                LockUtils.Wait( 2500 );
+            this.AddCommand( cmd );
+            LockUtils.Wait( 2500 );
 
-                //if ( ( target.Name.Equals( "CHARGING_02" ) ) || ( target.Name.Equals( "STOKER_LIFT_IP01" ) ) ||
-                //    ( target.Name.Equals( "STOKER_LIFT_OP01" ) ) || ( target.Name.Equals( "WORK_STATION_IP01" ) ) ||
-                //    ( target.Name.Equals( "WORK_STATION_OP01" ) ) )
-                //{
-                //    this.copyTarget = ram;
 
-                //    var targetPoint = target.pointID.ToString();
-                //    Command cmd = new Command() { TargetID = targetPoint, Type = eCommandType.Move };
-                //    cmd.ByWho = eCommandByWho.LocalSystem;
+            //var ram = NumUtils.Random( 0, RouteManager.Instance.Equipments.Count - 1 );
+            //if ( ram == this.copyTarget )
+            //    return;
+            //else
+            //{
+            //    var target = RouteManager.Instance.Equipments[ram];
+            //    this.copyTarget = ram;
 
-                //    this.AddCommand( cmd );
-                //    LockUtils.Wait( 2000 );
-                //}
-            }
+            //    var targetPoint = target.pointID.ToString();
+            //    Command cmd = new Command() { TargetID = targetPoint, Type = eCommandType.Move };
+            //    cmd.ByWho = eCommandByWho.LocalSystem;
+
+            //    this.AddCommand( cmd );
+            //    LockUtils.Wait( 2500 );
+
+            //    //if ( ( target.Name.Equals( "CHARGING_02" ) ) || ( target.Name.Equals( "STOKER_LIFT_IP01" ) ) ||
+            //    //    ( target.Name.Equals( "STOKER_LIFT_OP01" ) ) || ( target.Name.Equals( "WORK_STATION_IP01" ) ) ||
+            //    //    ( target.Name.Equals( "WORK_STATION_OP01" ) ) )
+            //    //{
+            //    //    this.copyTarget = ram;
+
+            //    //    var targetPoint = target.pointID.ToString();
+            //    //    Command cmd = new Command() { TargetID = targetPoint, Type = eCommandType.Move };
+            //    //    cmd.ByWho = eCommandByWho.LocalSystem;
+
+            //    //    this.AddCommand( cmd );
+            //    //    LockUtils.Wait( 2000 );
+            //    //}
+            //}
         }
 
         private void DoWork( Command cmd )
@@ -222,6 +241,7 @@ namespace VehicleControlSystem.Managers
                             case OHV.Common.Shareds.eCommandType.MoveNLoad:
                             case OHV.Common.Shareds.eCommandType.MoveNUnload:
                             case OHV.Common.Shareds.eCommandType.Charging:
+                            case eCommandType.Cancel:
                                 CreateSubCommand( cmd, eSubCommandType.Move );
                                 break;
                             default:
@@ -291,6 +311,11 @@ namespace VehicleControlSystem.Managers
             }
         }
 
+        private void CommandCancel( Command cmd )
+        {
+            
+        }
+
         private bool CreateSubCommand( Command cmd, eSubCommandType type )
         {
             //명령을 만들기 전에 Vehicle 의 상태를 확인하여 만들자.
@@ -304,6 +329,8 @@ namespace VehicleControlSystem.Managers
                     break;
                 case eSubCommandType.Charge:
                     break;
+                case eSubCommandType.Cancel:
+                    break;
                 default:
                     break;
             }

+ 12 - 0
Dev/OHV/VehicleControlSystem/VCSystem.cs.rej

@@ -0,0 +1,12 @@
+diff a/Dev/OHV/VehicleControlSystem/VCSystem.cs b/Dev/OHV/VehicleControlSystem/VCSystem.cs	(rejected hunks)
+@@ -120,6 +120,10 @@
+ <<<<<<< HEAD
+             this.autoManager = new AutoManager( this.IO, this.eventAggregator, this.sql );
+             this.scheduler = new Scheduler( eventAggregator, this.autoManager, this.sql, this.bMUManager );
++=======
++            this.autoManager = new AutoManager( this.IO, this.eventAggregator, this.sql, this.Alarms );
++            this.scheduler = new Scheduler( eventAggregator, this.autoManager, this.sql );
++>>>>>>> 40833c20f413059976af5288d531c63e4acb93d8
+ 
+             this.vehicle = new Vehicle( refObject, this.IO, this.sql, this.eventAggregator, this.autoManager );
+             this.vehicle.PropertyChanged += Vehicle_PropertyChanged;

BIN
Dev/OHVDriveLogger/OHVDriveLogger/.vs/OHVDriveLogger/v16/Server/sqlite3/storage.ide-shm


BIN
Dev/OHVDriveLogger/OHVDriveLogger/.vs/OHVDriveLogger/v16/Server/sqlite3/storage.ide-wal


+ 1 - 1
Dev/OHVDriveLogger/OHVDriveLogger/OHVDriveLogger/App.config

@@ -6,7 +6,7 @@
 
 	<appSettings>
 		<add key="VehicleID" value="V01"/>
-		<add key="FTPUploadIP" value="192.168.127.123"/>
+		<add key="FTPUploadIP" value="192.168.127.200"/>
 		<add key="PLC_IP" value="192.168.0.20"/>
 		<add key="PLC_PORT" value="5000"/>
 	</appSettings>