Selaa lähdekoodia

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

# Conflicts:
#	Dev/OHV/VehicleControlSystem/ControlLayer/IO/EzIO.cs
SK.Kang 6 vuotta sitten
vanhempi
commit
b6a7316727

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

@@ -141,7 +141,7 @@
                                VerticalAlignment="Center"
                                HorizontalAlignment="Center"
                                Foreground="Orange" FontSize="20">
-                                <Run Text="{Binding AvereageTimeToFull,StringFormat={}{0:0.00}, FallbackValue=min}"/>
+                                <Run Text="{Binding AvereageTimeToFull,StringFormat={}{0:0.0}H, FallbackValue=H}"/>
                         </TextBlock>
                     </Border>
 
@@ -154,7 +154,7 @@
                                VerticalAlignment="Center"
                                HorizontalAlignment="Center"
                                Foreground="Orange" FontSize="20">
-                                <Run Text="{Binding AverageTimeToEmpty, StringFormat={}{0:0.00},FallbackValue=min}"/>
+                                <Run Text="{Binding AverageTimeToEmpty, StringFormat={}{0:0.0}H,FallbackValue=H}"/>
                         </TextBlock>
                     </Border>
 

+ 15 - 0
Dev/OHV/OHV.Module.Interactivity/PopUp/ConveyorControlView.xaml

@@ -203,6 +203,14 @@
                     <Grid Grid.Column="0">
                         <StackPanel VerticalAlignment="Center"
                                     HorizontalAlignment="Center">
+
+                            <Button Background="{x:Null}">
+                                <StackPanel Orientation="Horizontal">
+                                    <Ellipse Margin="0,0,8,0" Width="20" Height="20" Fill="{Binding AxisLeftIsServoOn, FallbackValue=Gray}"/>
+                                    <TextBlock Text="Axis-L ServoON"/>
+                                </StackPanel>
+                            </Button>
+
                             <Button Background="{x:Null}">
                                 <StackPanel Orientation="Horizontal">
                                     <Ellipse Margin="0,0,18,0" Width="20" Height="20" Fill="{Binding AxisLeftIsOrg, FallbackValue=Gray}"/>
@@ -217,6 +225,13 @@
                                 </StackPanel>
                             </Button>
 
+                            <Button Background="{x:Null}" Margin="0,10,0,0">
+                                <StackPanel Orientation="Horizontal">
+                                    <Ellipse Margin="0,0,8,0" Width="20" Height="20" Fill="{Binding AxisRightIsServoOn, FallbackValue=Gray}"/>
+                                    <TextBlock Text="Axis-R ServoON"/>
+                                </StackPanel>
+                            </Button>
+
                             <Button Background="{x:Null}">
                                 <StackPanel Orientation="Horizontal">
                                     <Ellipse Margin="0,0,16,0" Width="20" Height="20" Fill="{Binding AxisRightIsOrg, FallbackValue=Gray}"/>

+ 35 - 2
Dev/OHV/OHV.Module.Interactivity/PopUp/ConveyorControlViewModel.cs

@@ -61,10 +61,21 @@ namespace OHV.Module.Interactivity.PopUp
 
         private Brush _axisLeftIsOrg = Brushes.Red;
         private Brush _axisLeftAmpFault = Brushes.Gray;
+        private Brush _axisLeftIsServoOn = Brushes.Gray;
 
+        private Brush _axisRightIsServoOn = Brushes.Gray;
         private Brush _axisRightIsOrg = Brushes.Red;
         private Brush _axisRightAmpFault = Brushes.Gray;
 
+        public Brush AxisLeftIsServoOn
+        {
+            get { return this._axisLeftIsServoOn; }
+            set
+            {
+                this.SetProperty( ref this._axisLeftIsServoOn , value );
+            }
+        }
+
         public Brush AxisLeftIsOrg
         {
             get { return _axisLeftIsOrg; }
@@ -81,6 +92,16 @@ namespace OHV.Module.Interactivity.PopUp
                 SetProperty( ref _axisLeftAmpFault , value );
             }
         }
+
+        public Brush AxisRightIsServoOn
+        {
+            get { return this._axisRightIsServoOn; }
+            set
+            {
+                this.SetProperty( ref this._axisRightIsServoOn, value );
+            }
+        }
+
         public Brush AxisRightIsOrg
         {
             get { return _axisRightIsOrg; }
@@ -348,20 +369,32 @@ namespace OHV.Module.Interactivity.PopUp
             var left = args.Args[ "Left" ] as AxisState;
             var right = args.Args[ "Right" ] as AxisState;
 
+            /*Left*/
+            if ( left.IsServoOn )
+                this.AxisLeftIsServoOn = Brushes.LimeGreen;
+            else
+                this.AxisLeftIsServoOn = Brushes.Gray;
+
             if ( left.IsOriginReturn )
                 this.AxisLeftIsOrg = Brushes.LimeGreen;
             else
-                this.AxisLeftIsOrg = Brushes.Red;
+                this.AxisLeftIsOrg = Brushes.Gray;
 
             if ( left.IsAmpFault )
                 this.AxisLeftAmpFault = Brushes.Red;
             else
                 this.AxisLeftAmpFault = Brushes.Gray;
 
+            /*Right*/
+            if ( right.IsServoOn )
+                this.AxisRightIsServoOn = Brushes.LimeGreen;
+            else
+                this.AxisRightIsServoOn = Brushes.Gray;
+
             if ( right.IsOriginReturn )
                 this.AxisRightIsOrg = Brushes.LimeGreen;
             else
-                this.AxisRightIsOrg = Brushes.Red;
+                this.AxisRightIsOrg = Brushes.Gray;
 
             if ( right.IsAmpFault )
                 this.AxisRightAmpFault = Brushes.Red;

+ 4 - 3
Dev/OHV/OHV.Module.Interactivity/PopUp/DriveServoView.xaml

@@ -227,19 +227,20 @@
 
 
                 <!--Jog Button-->
-                <RepeatButton
+                <Button
                             Margin="5"
                             Grid.Row="0" 
                             Grid.Column="2"
                             HorizontalAlignment="Right"
                             Width="120"
                             Height="auto"
-                            Command="{Binding JogCommand}" CommandParameter="-">
+                            Command="{Binding JogCommand}" CommandParameter="-"
+                            >
                     <StackPanel>
                         <materialDesign:PackIcon Kind="MinusBoxOutline" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="30" Width="auto"/>
                         <TextBlock><Run Text="Jog(-)"/></TextBlock>
                     </StackPanel>
-                </RepeatButton>
+                </Button>
 
                 <Button
                             Margin="5"

+ 9 - 0
Dev/OHV/OHV.Module.Interactivity/PopUp/DriveServoView.xaml.cs

@@ -24,5 +24,14 @@ namespace OHV.Module.Interactivity.PopUp
         {
             InitializeComponent();
         }
+
+        private void Button_PreviewMouseDown( object sender , MouseButtonEventArgs e )
+        {  
+        }
+
+        private void Button_PreviewMouseUp( object sender , MouseButtonEventArgs e )
+        {
+
+        }
     }
 }

+ 6 - 6
Dev/OHV/OHV.Module.Interactivity/PopUp/LockServoView.xaml

@@ -281,7 +281,7 @@
                     </Grid.ColumnDefinitions>
                     <StackPanel Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center">
                         <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center" >
-                            <Button
+                            <!--<Button
                             Style="{StaticResource MaterialDesignRaisedButton}"
                             materialDesign:ButtonAssist.CornerRadius="10"
                             ToolTip="MaterialDesignRaisedButton with Round Corners"
@@ -293,9 +293,9 @@
                                 <StackPanel>
                                     <TextBlock><Run Text="Limit(-)"/></TextBlock>
                                 </StackPanel>
-                            </Button>
+                            </Button>-->
 
-                            <Button
+                            <!--<Button
                             Style="{StaticResource MaterialDesignRaisedButton}"
                             materialDesign:ButtonAssist.CornerRadius="10"
                             ToolTip="MaterialDesignRaisedButton with Round Corners"
@@ -307,9 +307,9 @@
                                 <StackPanel>
                                     <TextBlock><Run Text="Origin"/></TextBlock>
                                 </StackPanel>
-                            </Button>
+                            </Button>-->
 
-                            <Button
+                            <!--<Button
                             Style="{StaticResource MaterialDesignRaisedButton}"
                             materialDesign:ButtonAssist.CornerRadius="10"
                             ToolTip="MaterialDesignRaisedButton with Round Corners"
@@ -320,7 +320,7 @@
                                 <StackPanel>
                                     <TextBlock><Run Text="Limit(+)"/></TextBlock>
                                 </StackPanel>
-                            </Button>
+                            </Button>-->
                         </StackPanel>
 
                         <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center"

+ 26 - 14
Dev/OHV/OHV.Module.Interactivity/PopUp/LockServoViewModel.cs

@@ -540,22 +540,34 @@ namespace OHV.Module.Interactivity.PopUp
 
         private void ExecuteMoveToCommand( )
         {
-            this.messageController.ShowConfirmationPopupView( $"Clamp Move To {this.SelectedPosition}" , r =>
-              {
-                  if ( r.Result == ButtonResult.OK )
-                  {
-                      var msg = new AxisControlEventArgs();
-                      msg.Kind = AxisControlEventArgs.eAxisControlKind.Move;
-                      msg.AxisName = this.SelectAxis;
+            var error = string.Empty;
 
-                      if ( SelectedPosition.Equals( ConstString.TEACH_POSITION_LOCK ) )
-                          msg.PosDir = AxisControlEventArgs.ePosDir.Lock;
-                      else
-                          msg.PosDir = AxisControlEventArgs.ePosDir.UnLock;
+            if ( this.IsLeftServoFault || this.IsRightServoFault )
+                error = "Is Servo Fault";
+            else if ( !this.IsLeftServoOn || !this.IsRightServoOn )
+                error = "Is Servo OFF";
 
-                      this.PublishEvent( msg );
-                  }
-              } );
+            if ( error != string.Empty )
+                this.messageController.ShowNotificationView( error );
+            else
+            {
+                this.messageController.ShowConfirmationPopupView( $"Clamp Move To {this.SelectedPosition}" , r =>
+                {
+                    if ( r.Result == ButtonResult.OK )
+                    {
+                        var msg = new AxisControlEventArgs();
+                        msg.Kind = AxisControlEventArgs.eAxisControlKind.Move;
+                        msg.AxisName = this.SelectAxis;
+
+                        if ( SelectedPosition.Equals( ConstString.TEACH_POSITION_LOCK ) )
+                            msg.PosDir = AxisControlEventArgs.ePosDir.Lock;
+                        else
+                            msg.PosDir = AxisControlEventArgs.ePosDir.UnLock;
+
+                        this.PublishEvent( msg );
+                    }
+                } );
+            }
         }
 
         private void ExecuteSelectPosCommand( object obj )

+ 3 - 0
Dev/OHV/OHV.Vehicle/Concept/D_MainWindow.xaml.cs

@@ -55,6 +55,9 @@ namespace OHV.Vehicle.Concept
 
             App.splashScreen.AddMessage("Done !");
             App.splashScreen.LoadComplete();
+
+            var model = this.DataContext as D_MainWindowViewModel;
+            model.InitViewModel();
         }
 
         private void Button_Click(object sender, RoutedEventArgs e)

+ 59 - 13
Dev/OHV/VehicleControlSystem/ControlLayer/Serial/BatteryTabos/Advantech/Advantech.cs

@@ -30,7 +30,25 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
         string errormsg = string.Empty;
 
         //Todo:Dll 에서 상태 가져오기
-        bool IsConnected = false;
+        //bool IsConnected = false;
+        bool IsConnected
+        {
+            get 
+            {
+                var state = new AdvCan.CanStatusPar_t();
+                var ret = this.device.acGetStatus( ref state );
+                if ( ret == AdvCANIO.SUCCESS )
+                {
+                    //정상 연결일때 값이 12 들어옴.
+                    if ( state.status == 12/*AdvCan.STATUS_OK*/ )
+                        return true;
+                    else
+                        return false;
+                }
+                else
+                    return false;
+            }
+        }
 
         #region Enum
         public enum eSendMode
@@ -78,6 +96,7 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
         public Advantech( BMUManager mrg, string canPortName )
         {
             this.manager = mrg;
+
             this.canPortName = canPortName;
 
             this.device = new AdvCANIO();
@@ -90,9 +109,13 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
 
         void TryToConnect( )
         {
+            //var a = AdvCANIO.OPERATION_ERROR; == -1
             this.qqW.Clear();
 
-            var ret = this.device.acCanOpen( this.canPortName/*this.manager.BMUConfig.ID*/ , false , 500 , 500 );
+            var d = this.device.acCanClose();
+            Thread.Sleep( 50 );
+
+            var ret = this.device.acCanOpen( this.canPortName, false , 500 , 500 );
 
             if(ret < 0)
             {
@@ -101,12 +124,19 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
             }
 
             ret = this.device.acEnterResetMode();
-            if(ret < 0)
+            if ( ret < 0 )
             {
                 throw new Exception( "AdvCAN Reset Error" );
                 return;
             }
 
+            //ret = this.device.acSetAcceptanceFilterMode( AdvCan.PELICAN_SINGLE_FILTER );
+            //if ( ret < 0 )
+            //{
+            //    throw new Exception( "AdvCAN AcceptFilterMode Set Error" );
+            //    return;
+            //}
+
             ret = this.device.acSetBaud(500);
             if ( ret < 0 )
             {
@@ -114,6 +144,20 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
                 return;
             }
 
+            ret = this.device.acSetAcceptanceFilterMask( Convert.ToUInt32( "FFFFFFFF" , 16 ));
+            if ( ret < AdvCANIO.SUCCESS )
+            {
+                throw new Exception( "AdvCAN AcceptFilterMask Set Error " );
+                return;
+            }
+
+            ret = this.device.acSetAcceptanceFilterCode( Convert.ToUInt32( "FFFFFFFF" , 16 ) );
+            if ( ret < AdvCANIO.SUCCESS )
+            {
+                throw new Exception( "AdvCAN AcceptFilterCode Set Error " );
+                return;
+            }
+
             ret = this.device.acSetTimeOut( 2000 , 2000 );
             if(ret < AdvCANIO.SUCCESS)
             {
@@ -135,8 +179,8 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
                 return;
             }
 
-            this.IsConnected = true;
-
+            //this.IsConnected = true;
+            this.Write( eSendMode.AUTO );
             manager._OnConnected();
         }
 
@@ -244,7 +288,7 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
             uint pulNumberofWritten = 1;
             AdvCan.canmsg_t[] msg = new AdvCan.canmsg_t[1];
             
-            msg[ 0 ].flags = AdvCan.MSG_EXT;
+            msg[ 0 ].flags = 0; // -> standard = 0, 
             msg[ 0 ].cob = 0;
             msg[ 0 ].id = idOffset + Convert.ToByte( this.manager.BMUConfig.ID );
             msg[ 0 ].length = ( short )AdvCan.DATALENGTH;
@@ -269,11 +313,13 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
 
             if(ret == AdvCANIO.TIME_OUT)
             {
-                CanError( );
+                CanError();
+                logger.E( "Battery Write TimeOut Error" );
             }
             else if (ret == AdvCANIO.OPERATION_ERROR)
             {
-                CanError(  );
+                CanError();
+                logger.E( "Battery Operation Error" );
             }
 
             return 1;
@@ -290,8 +336,8 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
         /// <returns></returns>
         void ReadMessage( )
         {
-            Thread.Sleep( 1000 );
-            uint readCount = 3;
+            Thread.Sleep( 10 );
+            uint readCount = 3; 
             uint pulNumberofRead = 3;
             AdvCan.canmsg_t[] recv = new AdvCan.canmsg_t[ 3 ];
 
@@ -317,7 +363,7 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
         {
             //null check battery receive
             var ll = recv.Select( x => x.data ).ToList();
-            if ( !ll.Any(null) )
+            if ( !ll.Any() )
                 return;
 
             ll.ForEach( r =>
@@ -380,7 +426,7 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
         void CanError(  )
         {
             //var result = PCANBasic.Uninitialize( this.handle );
-            this.IsConnected = false;
+            //this.IsConnected = false;
             var ret = this.device.acCanClose();
 
             //logger.E( $"[Battery Advantech] - {e.Message} -" );
@@ -458,7 +504,7 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
 
         private void DisConnect( )
         {
-            this.IsConnected = false;
+            //this.IsConnected = false;
             //PCANBasic.Reset( this.handle );
             //PCANBasic.Uninitialize( this.handle );
 

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

@@ -69,10 +69,10 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
                         data.Scale = 1;
                         break;
                     case eDataKind.ChargeCompleteTime:
-                        data.Scale = 1;
+                        data.Scale = 60;
                         break;
                     case eDataKind.DisChargeCompleteTime:
-                        data.Scale = 1;
+                        data.Scale = 60;
                         break;
                     case eDataKind.SOC:
                         data.Scale = 1;

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

@@ -1454,10 +1454,14 @@ namespace VehicleControlSystem.ControlLayer
                     this.BatteryState = ( double )obj.Value;
                     break;
                 case eDataKind.ChargeCompleteTime:
-                    this.BatteryChargeTime = (double)obj.Value * obj.Scale;
+                    if ( obj.Value == null || obj.Value <= 0 )
+                        return;
+                    this.BatteryChargeTime = (double)obj.Value / obj.Scale;
                     break;
                 case eDataKind.DisChargeCompleteTime:
-                    this.BatteryDisChargeTime = ( double )obj.Value * obj.Scale;
+                    if ( obj.Value == null || obj.Value <= 0 )
+                        return;
+                    this.BatteryDisChargeTime = ( double )obj.Value / obj.Scale;
                     break;
                 case eDataKind.SOC:
                     this.BatteryStateOfCharge = ( double )obj.Value * obj.Scale;

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

@@ -73,6 +73,7 @@ namespace VehicleControlSystem
             this.vehicle.Init();
             this.scheduler.Init();
             this.autoManager.Init(this.vehicle);
+
         }
 
         private void Vehicle_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
@@ -107,6 +108,8 @@ namespace VehicleControlSystem
         }
         private void EzIO_OnContd(string ID)
         {
+            this.IO.OutputOn( "OUT_TEACH_MODE" );
+
             //throw new NotImplementedException();
         }
         #endregion