Prechádzať zdrojové kódy

OCS Disconnected Alarm 발생 시기 변경 - Disconnection 상태로 변경시 5분동안 Disconnet 상태가 지속 되면 알람!

DESKTOP-Kang 5 rokov pred
rodič
commit
61c0a0c888

+ 34 - 5
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -640,7 +640,7 @@ namespace VehicleControlSystem.ControlLayer
             this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Publish( args );
         }
 
-        public void Init(HostManager host)
+        public void Init( HostManager host )
         {
             ThreadStart();
 
@@ -654,7 +654,7 @@ namespace VehicleControlSystem.ControlLayer
 
             sql.VehicleInfoDAL.Update( v );
         }
-        
+
         public int InitializationVehicle()
         {
 #if SIMULATION
@@ -890,9 +890,6 @@ namespace VehicleControlSystem.ControlLayer
                         case eSubCommandType.Move:
                             this.CurrentSubCommand = subCmd;
                             this.Move( subCmd );
-
-                            //if ( !refObjects.HostManager.IsConnected )
-                            //    OccurVehicleAlarm( 43 );
                             break;
 
                         case eSubCommandType.Load:
@@ -986,6 +983,8 @@ namespace VehicleControlSystem.ControlLayer
             this.taskMoveCancel.Cancel();
             this.taskMoveCancel.WaitAll();
 
+            this.CheckOCSConnectionState();
+
             logger.I( $"[SubCommand Complete] - Target : {sub.TargetID} / Type : {sub.Type}" );
         }
 
@@ -1859,6 +1858,36 @@ namespace VehicleControlSystem.ControlLayer
         #endregion
 
         #region Help Method
+        Task taskHostConnection = null;
+        /// <summary>
+        /// Move 이후 OCS 연결을 확인 후 Disconnected 상태이면 5분 상태 확인 후 Alarm 발생.
+        /// </summary>
+        void CheckOCSConnectionState()
+        {
+            if ( this.taskHostConnection != null )
+                return;
+
+            if ( refObjects.HostManager.IsConnected )
+                return;
+
+            this.taskHostConnection = new Task( () =>
+             {
+                 long sTime = SwUtils.CurrentTimeMillis;
+                 while ( !refObjects.HostManager.IsConnected )
+                 {
+                     LockUtils.Wait( 100 );
+
+                     if ( SwUtils.Gt( sTime, 30 * ConstUtils.ONE_SECOND ) )
+                     {
+                         OccurVehicleAlarm( 43 );
+                         break;
+                     }
+                 }
+             } );
+
+            this.taskHostConnection = null;
+        }
+
         void BatteryChargeStateLED( double percent )
         {
             if ( percent > 60 )