Просмотр исходного кода

Pull thread 종료 QoQueue Class 추가

SK.Kang 6 лет назад
Родитель
Сommit
f8b1b0807e

+ 4 - 13
Dev/OHV/OHV.Module.Interactivity/PopUp/LockServoView.xaml

@@ -369,10 +369,6 @@
                                         <i:InvokeCommandAction Command="{Binding JogStopCommand}"/>
                                     </i:EventTrigger>
                                 </i:Interaction.Triggers>
-                                <!--<Button.InputBindings>
-                                    <MouseBinding Gesture="MouseLeftButtonUp" Command="{Binding JogStopCommand}" />
-                                    <MouseBinding Gesture="MouseLeftButtonDown" Command="{Binding JogCommand}" CommandParameter="-"/>
-                                </Button.InputBindings>-->
                                 <StackPanel>
                                     <materialDesign:PackIcon Kind="MinusBoxOutline" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="30" Width="auto"/>
                                     <TextBlock><Run Text="Jog(-)" FontSize="20"/></TextBlock>
@@ -403,19 +399,14 @@
                             HorizontalAlignment="Stretch"
                             Height="auto"
                             Width="90" PreviewMouseDown="Button_PreviewMouseDown" PreviewMouseUp="Button_PreviewMouseUp">
-                                <!--<i:Interaction.Triggers>
-                                    <i:EventTrigger EventName="MouseLeftButtonDown">
+                                <i:Interaction.Triggers>
+                                    <i:EventTrigger EventName="TouchDown">
                                         <i:InvokeCommandAction Command="{Binding JogCommand}" CommandParameter="+"/>
                                     </i:EventTrigger>
-                                    <i:EventTrigger EventName="MouseLeftButtonUp">
+                                    <i:EventTrigger EventName="TouchUp">
                                         <i:InvokeCommandAction Command="{Binding JogStopCommand}"/>
                                     </i:EventTrigger>
-                                </i:Interaction.Triggers>-->
-                                <!--<Button.InputBindings>
-                                    <MouseBinding Gesture="LeftButtonUp" Command="{Binding JogStopCommand}" />
-                                    <MouseBinding Gesture="LeftButtonDown" Command="{Binding JogCommand}" CommandParameter="+"/>
-                                </Button.InputBindings>-->
-
+                                </i:Interaction.Triggers>
                                 <StackPanel>
                                     <materialDesign:PackIcon Kind="PlusBoxOutline" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="30" Width="auto"/>
                                     <TextBlock><Run Text="Jog(+)" FontSize="20"/></TextBlock>

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

@@ -37,7 +37,7 @@
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>..\..\..\..\..\OutReales\</OutputPath>
+    <OutputPath>..\OutRelese\</OutputPath>
     <DefineConstants>TRACE;DEBUG</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>

+ 22 - 11
Dev/OHV/VehicleControlSystem/ControlLayer/IO/EzIO.cs

@@ -78,6 +78,8 @@ namespace VehicleControlSystem.ControlLayer.IO
 
         Thread _readThread;
 
+        ThreadCancel threadCancel = new ThreadCancel();
+
         bool isConnectError = false;
         public bool IsConnectError
         {
@@ -396,16 +398,19 @@ namespace VehicleControlSystem.ControlLayer.IO
         }
         public void ThreadStart()
         {
-            this.IsThreadAlive = true;
-            this._readThread = ThreadUtils.Invoke( IOThread );
+            this.threadCancel.AddGo( new Action( this.IOThread ) );
+            this.threadCancel.AddGo( new Action( this.PullQueueThread ) );
 
-            this.pullThread = ThreadUtils.Invoke( PullQueueThread );
+            //this.IsThreadAlive = true;
+            //this._readThread = ThreadUtils.Invoke( IOThread );
+
+            //this.pullThread = ThreadUtils.Invoke( PullQueueThread );
         }
         void IOThread()
         {
             var sTime = SwUtils.CurrentTimeMillis;
 
-            while ( IsThreadAlive )
+            while ( !this.threadCancel.Canceled )
             {
                 Thread.Sleep( 5 );
                 try
@@ -551,7 +556,7 @@ namespace VehicleControlSystem.ControlLayer.IO
 
         void PullQueueThread()
         {
-            while ( IsThreadAlive )
+            while ( !this.threadCancel.Canceled )
             {
                 try
                 {
@@ -567,6 +572,8 @@ namespace VehicleControlSystem.ControlLayer.IO
                         DelegateUtils.Invoke( OnWriteIO, o.Arg0 );
                     else if ( o is QoLog )
                         DelegateUtils.Invoke( OnLog, o.Arg0, o.Arg1 );
+                    else if ( o is QoDispose )
+                        break;
                     else
                         Assert.Fail( "Unk Object {0}", o );
                 }
@@ -636,12 +643,16 @@ namespace VehicleControlSystem.ControlLayer.IO
 
         public int Terminate()
         {
-            this.IsThreadAlive = false;
-            if ( this._readThread != null && this._readThread.IsAlive )
-            {
-                if ( !this._readThread.Join( 3000 ) )
-                    this._readThread.Abort();
-            }
+            this.threadCancel.Cancel();
+            this.qQ.Enqueue( new QoDispose() );
+
+            //this.IsThreadAlive = false;
+            //if ( this._readThread != null && this._readThread.IsAlive )
+            //{
+            //    if ( !this._readThread.Join( 3000 ) )
+            //        this._readThread.Abort();
+            //}
+            this.threadCancel.StopWaitAll();
 
             this.BoardList.ForEach( b =>
             {

+ 2 - 0
Dev/OHV/VehicleControlSystem/ControlLayer/IO/QueueObjects.cs

@@ -17,4 +17,6 @@ namespace VehicleControlSystem.ControlLayer.IO
     public class QoChangedIO : QueueObject { }
     public class QoWriteIO : QueueObject { }
     public class QoLog : QueueObject { }
+    public class QoDispose : QueueObject { }
+
 }

+ 3 - 0
Dev/OHV/VehicleControlSystem/ControlLayer/Serial/BatteryTabos/Advantech/Advantech.cs

@@ -240,6 +240,9 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
                     logger.E( $"eSlnet {exception.Message}" );
                 }
             }
+
+            logger.D( "[BMU] - Receive Thread End" );
+
         }
 
         /// <summary>

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

@@ -111,15 +111,17 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
                     var qo = this.qq.Dequeue();
 
                     if ( qo is QoConnect )
-                        DelegateUtils.Invoke( OnConnect , qo.Arg0, qo.Arg1 );
+                        DelegateUtils.Invoke( OnConnect, qo.Arg0, qo.Arg1 );
                     else if ( qo is QoDisconnected )
-                        DelegateUtils.Invoke( OnDisconnect , qo.Arg0, qo.Arg1 );
+                        DelegateUtils.Invoke( OnDisconnect, qo.Arg0, qo.Arg1 );
                     else if ( qo is QoReceivedDataChanged )
-                        DelegateUtils.Invoke( OnChangedReceivedData , qo.Arg0 );
+                        DelegateUtils.Invoke( OnChangedReceivedData, qo.Arg0 );
                     //else if ( qo is QoSendMessageSuccess )
                     //    DelegateUtils.Invoke( OnSendSetDataSuccess, qo.Arg0 );
+                    else if ( qo is QoDispose )
+                        break;
                     else
-                        Assert.Fail( "Unk Object {0}" , qo );
+                        Assert.Fail( "Unk Object {0}", qo );
                 }
                 catch ( ThreadAbortException )
                 {
@@ -130,6 +132,8 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
                     logger.E( e );
                 }
             }
+
+            logger.D( "[BMU] - Pull Queue Thread End" );
         }
 
 
@@ -229,6 +233,7 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
             collectNo = 0;
             //Thread Stop
             this.cancel.Cancel();
+            this.qq.Enqueue( new QoDispose() );
             this.cancel.StopWaitAll();
         }
 

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

@@ -24,6 +24,7 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
     internal class QoDisconnected : QueObject { }
     internal class QoSendMessageSuccess : QueObject { }
     internal class QoReceivedDataChanged : QueObject { }
+    internal class QoDispose : QueObject { }
 
 
     public class QoVoltage : QueObject { }

+ 2 - 0
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -519,6 +519,8 @@ namespace VehicleControlSystem.ControlLayer
         {
             this.cancel.Cancel();
             this.cancel.StopWaitAll();
+
+            this.bMUManager.Disconnect();
         }
 
         #region Request Method