Forráskód Böngészése

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

# Conflicts:
#	Dev/OHV/OHV.Module.Interactivity/PopUp/ConveyorControlView.xaml
#	Dev/OHV/VehicleControlSystem/ControlLayer/Serial/BatteryTabos/BMUManager.cs
#	Dev/OHV/VehicleControlSystem/VCSystem.cs
SK.Kang 6 éve
szülő
commit
c1c13ee682
23 módosított fájl, 614 hozzáadás és 403 törlés
  1. 6 0
      Dev/OHV/OHV.Common/Events/MessageEventArgs.cs
  2. 23 0
      Dev/OHV/OHV.Common/Model/BatteryInfo.cs
  3. 17 0
      Dev/OHV/OHV.Common/Model/DriveState.cs
  4. 0 12
      Dev/OHV/OHV.Common/Model/VehicleInfo.cs
  5. 2 0
      Dev/OHV/OHV.Common/OHV.Common.csproj
  6. 2 2
      Dev/OHV/OHV.Common/Shareds/SharedEnumType.cs
  7. 13 10
      Dev/OHV/OHV.Module.Interactivity/ConfirmationPopupView.xaml
  8. 77 0
      Dev/OHV/OHV.Module.Interactivity/ConfirmationPopupView.xaml.orig
  9. 31 87
      Dev/OHV/OHV.Module.Interactivity/PopUp/BatteryConfigViewModel.cs
  10. 7 4
      Dev/OHV/OHV.Module.Interactivity/PopUp/DriveServoView.xaml
  11. 12 9
      Dev/OHV/OHV.Module.Interactivity/PopUp/DriveServoViewModel.cs
  12. 185 103
      Dev/OHV/OHV.Module.Interactivity/PopUp/ServoConfigView.xaml
  13. 134 21
      Dev/OHV/OHV.Module.Interactivity/PopUp/ServoConfigViewModel.cs
  14. 2 2
      Dev/OHV/OHV.Module.MainViews/Views/EditView.xaml
  15. 1 1
      Dev/OHV/OHV.Module.MainViews/Views/HistoryView.xaml
  16. 3 18
      Dev/OHV/OHV.Vehicle/Concept/D_MainWindow.xaml
  17. 8 1
      Dev/OHV/OHV.Vehicle/Concept/D_MainWindowViewModel.cs
  18. 1 1
      Dev/OHV/VehicleControlSystem/ControlLayer/Clamp.cs
  19. 16 27
      Dev/OHV/VehicleControlSystem/ControlLayer/Serial/BatteryTabos/Advantech/Advantech.cs
  20. 9 35
      Dev/OHV/VehicleControlSystem/ControlLayer/Serial/BatteryTabos/BMUManager.cs
  21. 24 31
      Dev/OHV/VehicleControlSystem/ControlLayer/Serial/BatteryTabos/Peak/Peak.cs
  22. 8 18
      Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs
  23. 33 21
      Dev/OHV/VehicleControlSystem/VCSystem.cs

+ 6 - 0
Dev/OHV/OHV.Common/Events/MessageEventArgs.cs

@@ -40,6 +40,8 @@ namespace OHV.Common.Events
 
             RspObstaclePatternChg,
             RspObstaclePatternNo,
+
+            RspBatteryState,
         }
 
         //Property 이름임.
@@ -92,6 +94,8 @@ namespace OHV.Common.Events
 
             ReqObstaclePatternChg,
             ReqObstaclePatternNo,
+
+            ReqBatteryState,
         }
 
         public eVCSMessageKind Kind { get; set; }
@@ -268,6 +272,7 @@ namespace OHV.Common.Events
         {
             NONE = -1,
             DRIVE = 0,
+            CURRENT,
             CURVE,
             STATE,
             INFO,
@@ -276,6 +281,7 @@ namespace OHV.Common.Events
 
         public int Drive { get; set; }
         public int Curve { get; set; }
+        public int Current { get; set; }
         public string ObstacleState { get; set; }
 
         public FluentResults.Result Result { get; set; }

+ 23 - 0
Dev/OHV/OHV.Common/Model/BatteryInfo.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OHV.Common.Model
+{
+    public class BatteryInfo
+    {
+        public double Voltage { get; set; }
+        public double Current { get; set; }
+        public double State { get; set; }
+        public double ChargeTime { get; set; }
+        public double DisChargeTime { get; set; }
+        public double SOC { get; set; }
+        public double SOH { get; set; }
+        public double Capacity { get; set; }
+        public double Energy { get; set; }
+        public double Temperature { get; set; }
+        public bool IsConnect { get; set; }
+    }
+}

+ 17 - 0
Dev/OHV/OHV.Common/Model/DriveState.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OHV.Common.Model
+{
+    public class DriveState
+    {
+        public string DirveName { get; set; }
+        public int Speed { get; set; }
+        public int Torque { get; set; }
+        public int Rpm { get; set; }
+        public int Loadage { get; set; }
+    }
+}

+ 0 - 12
Dev/OHV/OHV.Common/Model/VehicleInfo.cs

@@ -19,17 +19,5 @@ namespace OHV.Common.Model
         public double CurrentTorque { get; set; }
         public eVehicleState VehicleState { get; set; }
         public eMachineMode MachineMode { get; set; }
-
-        public double Voltage { get; set; }
-        public double Current { get; set; }
-        public double BatteryState { get; set; }
-        public double ChargeTime { get; set; }
-        public double DisChargeTime { get; set; }
-        public double SOC { get; set; }
-        public double SOH { get; set; }
-        public double Capacity { get; set; }
-        public double Energy { get; set; }
-        public double Temperature {get;set;}
-        public bool BatteryIsConnect { get; set; }
     }
 }

+ 2 - 0
Dev/OHV/OHV.Common/OHV.Common.csproj

@@ -92,8 +92,10 @@
     <Compile Include="Model\AxisConfig.cs" />
     <Compile Include="Model\AxisPositionData.cs" />
     <Compile Include="Model\AxisVelocityData.cs" />
+    <Compile Include="Model\BatteryInfo.cs" />
     <Compile Include="Model\Command.cs" />
     <Compile Include="Model\Config.cs" />
+    <Compile Include="Model\DriveState.cs" />
     <Compile Include="Model\HisAlarm.cs" />
     <Compile Include="Model\Route.cs" />
     <Compile Include="Model\RoutePoint.cs" />

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

@@ -53,8 +53,8 @@
         Abnormal,
         Blocked,
         Decelerate,
-		DRIVE,
-		CURVE
+		Drive,
+		Curve
     }
 
 	public enum eSteeringState

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 13 - 10
Dev/OHV/OHV.Module.Interactivity/ConfirmationPopupView.xaml


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 77 - 0
Dev/OHV/OHV.Module.Interactivity/ConfirmationPopupView.xaml.orig


+ 31 - 87
Dev/OHV/OHV.Module.Interactivity/PopUp/BatteryConfigViewModel.cs

@@ -118,88 +118,13 @@ namespace OHV.Module.Interactivity.PopUp
 
         public event Action<IDialogResult> RequestClose;
 
-        public ICommand BatteryOpenCommand { get; set; }
-        public ICommand BatteryCloseCommand { get; set; }
-
-
         IEventAggregator eventAggregator = null;
-        VCSystem vcSystem;
 
-        public BatteryConfigViewModel( IEventAggregator _ea, VCSystem vcSystem)
+        public BatteryConfigViewModel( IEventAggregator _ea)
         {
             this.eventAggregator = _ea;
             this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Unsubscribe( UICallbackCommunication );
             this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Subscribe( UICallbackCommunication , ThreadOption.UIThread );
-
-            this.eventAggregator = _ea;
-            this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Unsubscribe( DriveControlCallBack );
-            this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Subscribe( DriveControlCallBack , ThreadOption.UIThread );
-
-            this.BatteryOpenCommand = new DelegateCommand( ExecuteOpenCommand );
-            this.BatteryCloseCommand = new DelegateCommand( ExecuteCloseCommand );
-        }
-
-        private void DriveControlCallBack( DriveControlEventArgs obj )
-        {
-            if(obj.EventDir == DriveControlEventArgs.eEventDir.ToFront)
-            {
-                switch ( obj.ControlKind )
-                {
-                    case DriveControlEventArgs.eControlKind.NONE:
-                        break;
-                    case DriveControlEventArgs.eControlKind.MOVE:
-                        break;
-                    case DriveControlEventArgs.eControlKind.STOP:
-                        break;
-                    case DriveControlEventArgs.eControlKind.Steering:
-                        break;
-                    case DriveControlEventArgs.eControlKind.SteeringState:
-                        break;
-                    case DriveControlEventArgs.eControlKind.ReqCurrentPos:
-                        break;
-                    case DriveControlEventArgs.eControlKind.ReqStopCurrentPos:
-                        break;
-                    case DriveControlEventArgs.eControlKind.FaultReset:
-                        break;
-                    case DriveControlEventArgs.eControlKind.DriveON:
-                        break;
-                    case DriveControlEventArgs.eControlKind.DriveOFF:
-                        break;
-                    case DriveControlEventArgs.eControlKind.JOG:
-                        break;
-                    case DriveControlEventArgs.eControlKind.VehicleState:
-                        ResponseVehicleState( obj );
-                        break;
-                    case DriveControlEventArgs.eControlKind.Conveyor:
-                        break;
-                }
-            }
-        }
-
-        private void ResponseVehicleState( DriveControlEventArgs obj )
-        {
-            var d = CastTo<VehicleInfo>.From<object>( obj.Args );
-            
-            this.Voltage = d.Voltage;
-            this.Current = d.Current;
-            this.BatteryState = d.BatteryState;
-            this.AverageTimeToFull = d.ChargeTime;
-            this.AverageTimeToEmpty = d.DisChargeTime;
-            this.SOC = d.SOC;
-            this.SOH = d.SOH;
-            this.Capacity = d.Capacity;
-            this.Energy = d.Energy;
-            this.Temperature = d.Temperature;
-            if ( d.BatteryIsConnect )
-            {
-                this.BatteryConnectBrush = Brushes.LimeGreen;
-                this.BatteryConnect = "Connecting";
-            }
-            else
-            {
-                this.BatteryConnectBrush = Brushes.Gray;
-                this.BatteryConnect = "DisConnecting";
-            }
         }
 
         private void UICallbackCommunication( GUIMessageEventArgs obj )
@@ -222,7 +147,7 @@ namespace OHV.Module.Interactivity.PopUp
                         case "ChargeCompleteTime":
                             this.AverageTimeToFull = CastTo<double>.From<object>( obj.Args );
                             break;
-                        case "DisChargeCompleteTime":
+                        case "BatteryDisChargeTime":
                             this.AverageTimeToEmpty = CastTo<double>.From<object>( obj.Args );
                             break;
                         case "BatteryStateOfCharge":
@@ -245,28 +170,47 @@ namespace OHV.Module.Interactivity.PopUp
                             if ( connected )
                             {
                                 this.BatteryConnectBrush = Brushes.LimeGreen;
-                                this.BatteryConnect = "Connecting";
+                                this.BatteryConnect = "Connect";
                             }
                             else
                             {
                                 this.BatteryConnectBrush = Brushes.Gray;
-                                this.BatteryConnect = "DisConnecting";
+                                this.BatteryConnect = "DisConnect";
                             }
                             break;
                     }
                 }
             }
+            else if (obj.Kind == GUIMessageEventArgs.eGUIMessageKind.RspBatteryState)
+            {
+                var recv = CastTo<BatteryInfo>.From<object>( obj.Args );
+                ResponseBatteryState( recv );
+            }
         }
 
-        private void ExecuteCloseCommand( )
+        void ResponseBatteryState( BatteryInfo args )
         {
-            //throw new NotImplementedException();
-        }
+            this.Voltage = args.Voltage;
+            this.Current = args.Current;
+            this.Energy = args.Energy;
+            this.AverageTimeToFull = args.ChargeTime;
+            this.AverageTimeToEmpty = args.DisChargeTime;
+            this.SOC = args.SOC;
+            this.SOH = args.SOH;
+            this.Temperature = args.Temperature;
+            this.BatteryState = args.State;
+            this.Capacity = args.Capacity;
 
-        private void ExecuteOpenCommand( )
-        {
-            //throw new NotImplementedException();
-            
+            if(args.IsConnect)
+            {
+                this.BatteryConnectBrush = Brushes.LimeGreen;
+                this.BatteryConnect = "Connect";
+            }
+            else
+            {
+                this.BatteryConnectBrush = Brushes.Gray;
+                this.BatteryConnect = "DisConnect";
+            }
         }
 
         #region Dialog
@@ -281,7 +225,7 @@ namespace OHV.Module.Interactivity.PopUp
 
         public void OnDialogOpened( IDialogParameters parameters )
         {
-            this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Publish( new DriveControlEventArgs { EventDir = DriveControlEventArgs.eEventDir.ToBack , ControlKind = DriveControlEventArgs.eControlKind.VehicleState } );
+            this.eventAggregator.GetEvent<VCSMessagePubSubEvent>().Publish( new VCSMessageEventArgs { Kind = VCSMessageEventArgs.eVCSMessageKind.ReqBatteryState } );
         }
 
         private void CloseDialog( string parameter )

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

@@ -199,7 +199,7 @@
                     <Button Background="{x:Null}" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Stretch" Margin="5" Height="auto"
                             Style="{StaticResource MaterialDesignRaisedButton}"
                             materialDesign:ButtonAssist.CornerRadius="10">
-                        <TextBlock><Run Text="{Binding CurrentDrive, StringFormat=0.000, FallbackValue=0.000}" FontSize="20"/></TextBlock>
+                        <TextBlock><Run Text="{Binding CurrentPosition, StringFormat=0.000, FallbackValue=0.000}" FontSize="20"/></TextBlock>
                     </Button>
 
                     <Button Background="{x:Null}" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Stretch" Margin="5" Height="auto"
@@ -208,7 +208,10 @@
                         <TextBlock><Run Text="{Binding DifferenceDrive, StringFormat=0.000, FallbackValue=0.000}" FontSize="20"/></TextBlock>
                     </Button>
 
-                    <StackPanel Grid.Column="2" Grid.Row="1" Grid.ColumnSpan="3" Grid.RowSpan="3"  Orientation="Horizontal" HorizontalAlignment="Center" Margin="82,52,43,31" Width="379"  >
+                    <StackPanel Grid.Column="2" Grid.Row="1" Grid.ColumnSpan="3" Grid.RowSpan="3"  Orientation="Horizontal" HorizontalAlignment="Center" Margin="82,52,43,31" Width="379" >
+                        
+                        <materialDesign:Badged Badge="Steering" BadgeColorZoneMode="Accent"></materialDesign:Badged>
+                        
                         <Button Margin="20,30" Width="150"
                         HorizontalAlignment="Stretch" 
                         Height="Auto" 
@@ -238,7 +241,7 @@
 
 
                     <!--Jog Button-->
-                    <Button
+                    <RepeatButton
                             Margin="5"
                             Grid.Row="0" 
                             Grid.Column="2"
@@ -251,7 +254,7 @@
                             <materialDesign:PackIcon Kind="MinusBoxOutline" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="30" Width="auto"/>
                             <TextBlock><Run Text="Jog(-)" FontSize="20"/></TextBlock>
                         </StackPanel>
-                    </Button>
+                    </RepeatButton>
 
                     <Button
                             Margin="5"

+ 12 - 9
Dev/OHV/OHV.Module.Interactivity/PopUp/DriveServoViewModel.cs

@@ -58,11 +58,14 @@ namespace OHV.Module.Interactivity.PopUp
             set { this.SetProperty(ref this._driveTargetPos , value); }
         }
 
-        private double _currentDrive;
-        public double CurrentDrive
+        private double _currentPosition;
+        /// <summary>
+        /// * Drive Current Position
+        /// </summary>
+        public double CurrentPosition
         {
-            get { return this._currentDrive; }
-            set { this.SetProperty(ref this._currentDrive, value); }
+            get { return this._currentPosition; }
+            set { this.SetProperty(ref this._currentPosition , value); }
         }
 
         private double _differenceDrive;
@@ -72,7 +75,7 @@ namespace OHV.Module.Interactivity.PopUp
             set { this.SetProperty(ref this._differenceDrive, value); }
         }
 
-        private double _jogVelocity;
+        private double _jogVelocity = 5;
         public double JogVelocity
         {
             get { return this._jogVelocity; }
@@ -188,7 +191,7 @@ namespace OHV.Module.Interactivity.PopUp
                         case "CurrentPosition":
                             {
                                 var v = CastTo<double>.From<object>(obj.Args);
-                                this.CurrentDrive = v;
+                                this.CurrentPosition = v;
                             }
                             break;
                         case "CurrentTag":
@@ -257,7 +260,7 @@ namespace OHV.Module.Interactivity.PopUp
                         //}
                         break;
                     case DriveControlEventArgs.eControlKind.ReqCurrentPos:
-                        this.CurrentDrive = args.CurrentPosition;
+                        this.CurrentPosition = args.CurrentPosition;
                         break;
                     case DriveControlEventArgs.eControlKind.ReqStopCurrentPos:
                         break;
@@ -282,7 +285,7 @@ namespace OHV.Module.Interactivity.PopUp
         {
             var state = CastTo<VehicleInfo>.From<object>( args.Args );
 
-            this.CurrentDrive = state.CurrentPosition;
+            this.CurrentPosition = state.CurrentPosition;            
         }
 
         private void ResponseMove( DriveControlEventArgs args )
@@ -500,7 +503,7 @@ namespace OHV.Module.Interactivity.PopUp
             {
                 if ( r.Result == ButtonResult.OK )
                 {
-                    this.DriveTargetPos = this.CurrentDrive;
+                    this.DriveTargetPos = this.CurrentPosition;
                 }
             } );
         }

+ 185 - 103
Dev/OHV/OHV.Module.Interactivity/PopUp/ServoConfigView.xaml

@@ -54,6 +54,190 @@
                     </Grid.RowDefinitions>
 
                     <Grid Grid.Row="0">
+                        <Border BorderBrush="Gray" BorderThickness="1">
+                            <StackPanel>
+                                <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
+                                    <Grid.ColumnDefinitions>
+                                        <ColumnDefinition Width="*"/>
+                                        <ColumnDefinition Width="*"/>
+                                        <ColumnDefinition Width="*"/>
+                                        <ColumnDefinition Width="*"/>
+                                    </Grid.ColumnDefinitions>
+                                    <Grid.RowDefinitions>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="*"/>
+                                    </Grid.RowDefinitions>
+
+                                    <Grid Grid.Row="0">
+                                        <TextBlock/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="1">
+                                        <Border BorderBrush="#FF349FDA" BorderThickness="1"/>
+                                        <TextBlock Text="Front" FontSize="30" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+                                    <Grid Grid.Row="2">
+                                        <TextBlock/>
+                                    </Grid>
+                                    <Grid Grid.Row="3">
+                                        <TextBlock/>
+                                    </Grid>
+                                    <Grid Grid.Row="4">
+                                        <TextBlock/>
+                                    </Grid>
+                                    <Grid Grid.Row="5">
+                                        <TextBlock/>
+                                    </Grid>
+                                    <Grid Grid.Row="6">
+                                        <TextBlock/>
+                                    </Grid>
+                                    <Grid Grid.Row="7">
+                                        <TextBlock/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="4">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="Speed" FontSize="30" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="4"  Grid.Column="1">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="Torque" FontSize="30" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="4" Grid.Column="2">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="Rpm" FontSize="30" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="4" Grid.Column="3">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="Loadage" FontSize="30" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="5">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="{Binding FrontSpeed, FallbackValue=0.0}" FontSize="30" Foreground="Orange" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="5" Grid.Column="1">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="{Binding FrontTorque, FallbackValue=0.0}" FontSize="30" Foreground="Orange" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="5" Grid.Column="2">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="{Binding FrontRpm, FallbackValue=0.0}" FontSize="30" Foreground="Orange" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="5" Grid.Column="3">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="{Binding FrontLoadage, FallbackValue=0.0}" FontSize="30" Foreground="Orange" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+                                </Grid>
+                            </StackPanel>
+                        </Border>
+                    </Grid>
+
+                    <Grid Grid.Row="1">
+                        <Border BorderBrush="Gray" BorderThickness="1">
+                            <StackPanel>
+                                <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
+                                    <Grid.ColumnDefinitions>
+                                        <ColumnDefinition Width="*"/>
+                                        <ColumnDefinition Width="*"/>
+                                        <ColumnDefinition Width="*"/>
+                                        <ColumnDefinition Width="*"/>
+                                    </Grid.ColumnDefinitions>
+                                    <Grid.RowDefinitions>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="*"/>
+                                        <RowDefinition Height="*"/>
+                                    </Grid.RowDefinitions>
+
+                                    <Grid Grid.Row="0">
+                                        <TextBlock/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="1">
+                                        <Border BorderBrush="#FF349FDA" BorderThickness="1"/>
+                                        <TextBlock Text="Back" FontSize="30" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center"/>
+                                    </Grid>
+                                    <Grid Grid.Row="2">
+                                        <TextBlock/>
+                                    </Grid>
+                                    <Grid Grid.Row="3">
+                                        <TextBlock/>
+                                    </Grid>
+                                    <Grid Grid.Row="4">
+                                        <TextBlock/>
+                                    </Grid>
+                                    <Grid Grid.Row="5">
+                                        <TextBlock/>
+                                    </Grid>
+                                    <Grid Grid.Row="6">
+                                        <TextBlock/>
+                                    </Grid>
+                                    <Grid Grid.Row="7">
+                                        <TextBlock/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="4">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="Speed" FontSize="30" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="4"  Grid.Column="1">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="Torque" FontSize="30" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="4" Grid.Column="2">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="Rpm" FontSize="30" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="4" Grid.Column="3">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="Loadage" FontSize="30" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="5">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="{Binding BackSpeed, FallbackValue=0.0}" FontSize="30" Foreground="Orange" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="5" Grid.Column="1">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="{Binding BackTorque, FallbackValue=0.0}" FontSize="30" Foreground="Orange" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="5" Grid.Column="2">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="{Binding BackRpm, FallbackValue=0.0}" FontSize="30" Foreground="Orange" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+
+                                    <Grid Grid.Row="5" Grid.Column="3">
+                                        <Border BorderBrush="Gray" BorderThickness="1"/>
+                                        <TextBlock Text="{Binding BackLoadage, FallbackValue=0.0}" FontSize="30" Foreground="Orange" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+                                    </Grid>
+                                </Grid>
+                            </StackPanel>
+                        </Border>
+                    </Grid>
+
+                    <!--<Grid Grid.Row="0">
                         <Border Margin="5" BorderBrush="Gray" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
                         <Button Background="{x:Null}" Foreground="Orange" Margin="10,10,657,226" Height="Auto">
                             <TextBlock Text="Drive" FontSize="20"/>
@@ -112,96 +296,7 @@
                                 <Button Content="{Binding LockRightScale, FallbackValue=0.001}" FontSize="20" Background="{x:Null}" Height="Auto"/>
                             </StackPanel>
                         </StackPanel>
-                    </Grid>
-
-                    <!--<Border Margin="2,101,0,10" BorderBrush="#FF00FFD3" 
-                        BorderThickness="1" VerticalAlignment="Stretch"
-                        HorizontalAlignment="Stretch" Grid.Column="1" 
-                        Grid.ColumnSpan="3" Grid.RowSpan="2"/>
-                <Button
-                    Style="{StaticResource MaterialDesignRaisedButton}"
-                    materialDesign:ButtonAssist.CornerRadius="10"
-                    ToolTip="MaterialDesignRaisedButton with Round Corners"
-                    Margin="10,20,10,20"
-                    Grid.Row="1" 
-                    Grid.Column="1"
-                    Height="auto"
-                    HorizontalAlignment="Stretch">
-                    <StackPanel>
-                        <TextBlock><Run Text="Limit(-)"/></TextBlock>
-                    </StackPanel>
-                </Button>
-
-                <materialDesign:Badged
-                        Grid.Row="1"
-                        Grid.Column="2"
-                        Badge="Current Pos"
-                        BadgeColorZoneMode="Dark"
-                        BadgePlacementMode="Top"
-                        BadgeForeground="Aqua"
-                        VerticalAlignment="Center"
-                        HorizontalAlignment="Center"
-                        Height="auto">
-                    <Button Margin="15" VerticalAlignment="Center" HorizontalAlignment="Center" Height="50" >
-                        <StackPanel>
-                            <TextBlock Text="0.000"/>
-                        </StackPanel>
-                    </Button>
-                </materialDesign:Badged>
-
-                <Button
-                    Style="{StaticResource MaterialDesignRaisedButton}"
-                    materialDesign:ButtonAssist.CornerRadius="10"
-                    ToolTip="MaterialDesignRaisedButton with Round Corners"
-                    Margin="10,20,10,20"
-                    Grid.Row="1" 
-                    Grid.Column="3"
-                    Height="auto"
-                    HorizontalAlignment="Stretch">
-                    <StackPanel>
-                        <TextBlock><Run Text="Limit(-)"/></TextBlock>
-                    </StackPanel>
-                </Button>
-
-                <Button
-                    Margin="5"
-                    Grid.Row="2" 
-                    Grid.Column="1"
-                    HorizontalAlignment="Stretch"
-                    Height="auto">
-                    <StackPanel>
-                        <materialDesign:PackIcon Kind="ArrowLeftBoldCircleOutline" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="42" Width="auto"/>
-                        <TextBlock><Run Text="Jog(-)"/></TextBlock>
-                    </StackPanel>
-                </Button>
-
-                <materialDesign:Badged
-                        Grid.Row="2"
-                        Grid.Column="2"
-                        Badge="Jog Velocity"
-                        BadgeColorZoneMode="Dark"
-                        BadgePlacementMode="Top"
-                        BadgeForeground="Aqua"
-                        VerticalAlignment="Center"
-                    HorizontalAlignment="Center">
-                    <Button Margin="15" VerticalAlignment="Center" HorizontalAlignment="Center" Height="60" Width="Auto" >
-                        <StackPanel>
-                            <TextBlock Text="0.000"/>
-                        </StackPanel>
-                    </Button>
-                </materialDesign:Badged>
-
-                <Button
-                    Margin="5"
-                    Grid.Row="2" 
-                    Grid.Column="3"
-                    HorizontalAlignment="Stretch"
-                    Height="auto">
-                    <StackPanel>
-                        <materialDesign:PackIcon Kind="ArrowRightBoldCircleOutline" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="42" Width="auto"/>
-                        <TextBlock><Run Text="Jog(+)"/></TextBlock>
-                    </StackPanel>
-                </Button>-->
+                    </Grid>-->
 
                 </Grid>
             </Grid>
@@ -216,20 +311,7 @@
                         </StackPanel>
                     </Button>
                 </StackPanel>
-
             </Grid>
-
-            <!--<StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,5,0,0">
-            <Button x:Name="btnSend" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Margin="0,0,20,0" Height="25" Command="{Binding CloseDialogCommand}" CommandParameter="true" Content="확인" Background="#FF1368BD" Style="{StaticResource MaterialDesignRaisedButton}"/>
-            -->
-            <!--Style="{DynamicResource btn_Send}"-->
-            <!--
-
-            <Button x:Name="btnCancel" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Height="25"  Content="취소" Command="{Binding CloseDialogCommand}" CommandParameter="false" Background="#FF1368BD" Style="{StaticResource MaterialDesignRaisedButton}"/>
-            -->
-            <!--Style="{DynamicResource btn_Close}"-->
-            <!--
-        </StackPanel>-->
         </Grid>
     </Border>
    

+ 134 - 21
Dev/OHV/OHV.Module.Interactivity/PopUp/ServoConfigViewModel.cs

@@ -1,6 +1,10 @@
-using OHV.Common.Shareds;
+using GSG.NET.Extensions;
+using OHV.Common.Events;
+using OHV.Common.Model;
+using OHV.Common.Shareds;
 using OHV.SqliteDAL;
 using Prism.Commands;
+using Prism.Events;
 using Prism.Mvvm;
 using Prism.Services.Dialogs;
 using System;
@@ -90,34 +94,142 @@ namespace OHV.Module.Interactivity.PopUp
         {
             get { return this._lockRightScale; }
             set { this.SetProperty( ref this._lockRightScale , value ); }
-        } 
+        }
+        #endregion
+
+        #region Front Drive
+        private double frontSpeed;
+
+        public double FrontSpeed
+        {
+            get { return frontSpeed; }
+            set { this.SetProperty( ref this.frontSpeed , value ); }
+        }
+
+        private double frontTorque;
+
+        public double FrontTorque
+        {
+            get { return frontTorque; }
+            set { this.SetProperty( ref this.frontTorque , value ); }
+        }
+
+        private double frontRpm;
+
+        public double FrontRpm
+        {
+            get { return frontRpm; }
+            set { this.SetProperty( ref this.frontRpm , value ); }
+        }
+
+        private double frontLoadage;
+
+        public double FrontLoadage
+        {
+            get { return frontLoadage; }
+            set { this.SetProperty( ref this.frontLoadage , value ); }
+        }
+        #endregion
+
+        #region Back Drive
+        private double backSpeed;
+
+        public double BackSpeed
+        {
+            get { return backSpeed; }
+            set { this.SetProperty( ref this.backSpeed , value ); }
+        }
+
+        private double backTorque;
+
+        public double BackTorque
+        {
+            get { return backTorque; }
+            set { this.SetProperty( ref this.backTorque , value ); }
+        }
+
+        private double backRpm;
+
+        public double BackRpm
+        {
+            get { return backRpm; }
+            set { this.SetProperty( ref this.backRpm , value ); }
+        }
+
+        private double backLoadage;
+
+        public double BackLoadage
+        {
+            get { return backLoadage; }
+            set { this.SetProperty( ref this.backLoadage , value ); }
+        }
         #endregion
 
+        IEventAggregator eventAggregator = null;
         SqliteManager sql;
 
-        public ServoConfigViewModel( SqliteManager _sql )
+        public ServoConfigViewModel(IEventAggregator ea, SqliteManager _sql )
         {
+            this.eventAggregator = ea;
+            this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Unsubscribe( UICallbackCommunication );
+            this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Subscribe( UICallbackCommunication , ThreadOption.UIThread );
+
             this.sql = _sql;
 
             //this.LockLeftID = sql.AxisConfigDAL.GetK( ConstString.AXIS_CARRIER_LOCK_LEFT ).Id;
-            sql.AxisConfigDAL.All.ForEach( x =>
-             {
-                 switch(x.Id)
-                 {
-                     case 1:
-                         this.LockLeftID = x.Id;
-                         this.LockLeftIP = x.Address;
-                         this.LockLeftName = x.Name;
-                         this.LockLeftScale = x.Scale;
-                         break;
-                     case 2:
-                         this.LockRightID = x.Id;
-                         this.LockRightIP = x.Address;
-                         this.LockRightName = x.Name;
-                         this.LockRightScale = x.Scale;
-                         break;
-                 }
-             } );
+            //sql.AxisConfigDAL.All.ForEach( x =>
+            // {
+            //     switch(x.Id)
+            //     {
+            //         case 1:
+            //             this.LockLeftID = x.Id;
+            //             this.LockLeftIP = x.Address;
+            //             this.LockLeftName = x.Name;
+            //             this.LockLeftScale = x.Scale;
+            //             break;
+            //         case 2:
+            //             this.LockRightID = x.Id;
+            //             this.LockRightIP = x.Address;
+            //             this.LockRightName = x.Name;
+            //             this.LockRightScale = x.Scale;
+            //             break;
+            //     }
+            // } );
+        }
+
+        private void UICallbackCommunication( GUIMessageEventArgs obj )
+        {
+            if(obj.Kind == GUIMessageEventArgs.eGUIMessageKind.ModelPropertyChange)
+            {
+                if(obj.MessageKey.Equals(MessageKey.Vehicle))
+                {
+                    switch(obj.ModelPropertyName)
+                    {
+                        case "DriveState":
+                            var ds = CastTo<DriveState>.From<object>(obj.Args);
+                            this.ResponseDrive(ds);
+                            break;
+                    }
+                }
+            }
+        }
+
+        private void ResponseDrive( DriveState ds )
+        {
+            if(ds.DirveName.Equals("Front"))
+            {
+                this.FrontSpeed = ds.Speed;
+                this.FrontTorque = ds.Torque;
+                this.FrontRpm = ds.Rpm;
+                this.FrontLoadage = ds.Loadage;
+            }
+            else
+            {
+                this.BackSpeed = ds.Speed;
+                this.backTorque = ds.Torque;
+                this.BackRpm = ds.Rpm;
+                this.BackLoadage = ds.Loadage;
+            }
         }
 
         #region Dialog 
@@ -132,6 +244,7 @@ namespace OHV.Module.Interactivity.PopUp
 
         public void OnDialogOpened( IDialogParameters parameters )
         {
+            //Requst
         }
 
         protected virtual void CloseDialog( string parameter )

+ 2 - 2
Dev/OHV/OHV.Module.MainViews/Views/EditView.xaml

@@ -67,7 +67,7 @@
                             </StackPanel>
                         </Button>
 
-                        <Button HorizontalAlignment="Stretch"
+                        <!--<Button HorizontalAlignment="Stretch"
                             Style="{StaticResource MaterialDesignRaisedButton}"
                             Margin="20"
                             materialDesign:ButtonAssist.CornerRadius="20"
@@ -77,7 +77,7 @@
                                 <materialDesign:PackIcon Kind="BatteryCharging" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="100"/>
                                 <TextBlock FontSize="30" Text="Battery" VerticalAlignment="Stretch" HorizontalAlignment="Center"/>
                             </StackPanel>
-                        </Button>
+                        </Button>-->
                     </StackPanel>
                 </Grid>
 

+ 1 - 1
Dev/OHV/OHV.Module.MainViews/Views/HistoryView.xaml

@@ -9,7 +9,7 @@
              prism:ViewModelLocator.AutoWireViewModel="True"
              mc:Ignorable="d" 
              Width="Auto"
-             Height="942"
+             Height="Auto"
              MinWidth="1386"
              Background="#37474f">
     

+ 3 - 18
Dev/OHV/OHV.Vehicle/Concept/D_MainWindow.xaml

@@ -53,21 +53,6 @@
             </StackPanel>
 
             <StackPanel Margin="0,0,50,0" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Right">
-                <!--<Button Margin="1"
-                   Style="{DynamicResource MaterialDesignFloatingActionMiniButton}"     
-                   materialDesign:ShadowAssist.ShadowDepth="Depth5" Background="{Binding OcsBrush, FallbackValue={x:Null}}">
-                    OCS
-                </Button>-->
-
-                <!--<Button Margin="0" Width="47" Height="60"
-                   Style="{DynamicResource MaterialDesignFloatingActionButton}"     
-                   materialDesign:ShadowAssist.ShadowDepth="Depth5" Background="{Binding BatteryBrush, FallbackValue={x:Null}}">
-                    <StackPanel>
-                        <materialDesign:PackIcon Kind="BatteryCharging" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,0,0" Height="20" Width="auto"/>
-                        <TextBlock Text="{Binding SOC, StringFormat={}{0}%, FallbackValue=0%}"/>
-                    </StackPanel>
-                </Button>-->
-
                 <Button Margin="1" HorizontalAlignment="Left" Height="40" BorderBrush="Gray" BorderThickness="0" Background="{x:Null}">
                     <StackPanel Orientation="Horizontal">
                         <materialDesign:PackIcon HorizontalContentAlignment="Left" Kind="AccessPointNetworkOff" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0,0,0,0" Height="35" Width="auto" Foreground="Red"
@@ -78,9 +63,9 @@
                     </StackPanel>
                 </Button>
 
-                <Button Margin="1" HorizontalAlignment="Center" Height="40" BorderBrush="Gray" BorderThickness="0" Background="{x:Null}"
-                        HorizontalContentAlignment="Left">
-                    <StackPanel Orientation="Horizontal" Margin="3,0,0,0">
+                <Button Margin="1" HorizontalAlignment="Center" Height="40" BorderBrush="{DynamicResource PrimaryHueMidBrush}" BorderThickness="1" Background="{x:Null}"
+                        HorizontalContentAlignment="Left" Command="{Binding BatteryPopup}">
+                        <StackPanel Orientation="Horizontal" Margin="3,0,0,0">
                         <materialDesign:PackIcon HorizontalContentAlignment="Left" Kind="BatteryOff" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0,0,0,0" Height="30" Width="AUto" Foreground="Red"
                                                  Visibility="{c:Binding 'BatteryState == local:eBatteryState.DisConnect'}"/>
 

+ 8 - 1
Dev/OHV/OHV.Vehicle/Concept/D_MainWindowViewModel.cs

@@ -214,6 +214,7 @@ namespace OHV.Vehicle.Concept
         public ICommand AlarmResetCommand { get; set; }
         public ICommand ChangeLanguage { get; set; }
         public ICommand MachineModeChgCommand { get; set; }
+        public ICommand BatteryPopup { get; set; }
         #endregion
 
         IEventAggregator eventAggregator = null;
@@ -258,6 +259,7 @@ namespace OHV.Vehicle.Concept
             this.EmergencyStopCommand = new DelegateCommand( ExecuteEStop );
             this.BuzzerStopCommand = new DelegateCommand( ExecuteBuzzerStop );
             this.MachineModeChgCommand = new DelegateCommand<string>( ExecuteMachineModeChgCommand );
+            this.BatteryPopup = new DelegateCommand( ExecuteBatteryPopup );
 
             DispatcherTimer dateTimer = new DispatcherTimer();
             dateTimer.Tick += ( object sender, EventArgs e ) =>
@@ -273,6 +275,11 @@ namespace OHV.Vehicle.Concept
             GSG.NET.Quartz.QuartzUtils.Invoke( "RESOURCE_CHECK", GSG.NET.Quartz.QuartzUtils.GetExpnSecond( 1 ), QuzOnResourceUsage );
         }
 
+        private void ExecuteBatteryPopup( )
+        {
+            this.messageController.ShowBatteryPopupView();
+        }
+
         void QuzOnResourceUsage()
         {
             this.CPU = GSG.NET.OSView.Mgnt.CpuUseRate();
@@ -544,7 +551,7 @@ namespace OHV.Vehicle.Concept
                         break;
                     case "BatteryDisChargeTime":
                         {
-                            var cTime = CastTo<double>.From<object>( args.Args );
+                            var dTime = CastTo<double>.From<object>( args.Args );
                         }
                         break;
                 }

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

@@ -142,7 +142,7 @@ namespace VehicleControlSystem.ControlLayer
             else
                 this.ClampState = eClampState.NONE;
 
-            this.ClampState = eClampState.NONE;
+            //this.ClampState = eClampState.NONE;
 
             var msg = new AxisControlEventArgs
             {

+ 16 - 27
Dev/OHV/VehicleControlSystem/ControlLayer/Serial/BatteryTabos/Advantech/Advantech.cs

@@ -1,6 +1,7 @@
 using GSG.NET.Concurrent;
 using GSG.NET.Extensions;
 using GSG.NET.Logging;
+using GSG.NET.Utils;
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -337,48 +338,36 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
                     if ( r == null )
                         return; //buffer empty
 
-                    if ( r[ 1 ] == 1 )
-                    { CanRecvSave( r , 1 ); }
-                    else if ( r[ 1 ] == 2 )
-                    { CanRecvSave( r , 2 ); }
-                    else if ( r[ 1 ] == 3 )
-                    { CanRecvSave( r , 3 ); }
-                    else
-                    { }
+                    CanRecvSave( r );
                 } );
             }
             catch (Exception e)
             { } 
         }
 
-        void CanRecvSave(byte[] data, int index)
+        void CanRecvSave(byte[] data)
         {
-            string packet = BitConverter.ToString( data ).Replace( "-" , "" );
-            
-            List<string> sList = new List<string>();
-            for ( int i = 0; i < packet.Length; i++ )
-            {
-                if ( i % 2 == 0 )
-                    sList.Add( packet.Substring( i , 2 ) );
-            }
+            var mb = new MemoryBuffer( data );
+            mb.Read1Byte();
+            var index = mb.Read1Byte();
 
             switch (index)
             {
                 case 1:
-                    this.manager.ReceivedDataDic[ eDataKind.Voltage ].Value = Int32.Parse( sList[ ( int )eMsgCaseFirst.Voltage_HIGH ] + sList[ ( int )eMsgCaseFirst.Voltage_LOW ] , System.Globalization.NumberStyles.HexNumber );
-                    this.manager.ReceivedDataDic[ eDataKind.Current ].Value = Int32.Parse( sList[ ( int )eMsgCaseFirst.Current_HIGH ] + sList[ ( int )eMsgCaseFirst.Current_LOW ] , System.Globalization.NumberStyles.HexNumber );
-                    this.manager.ReceivedDataDic[ eDataKind.BatteryState ].Value = Int32.Parse( sList[ ( int )eMsgCaseFirst.BatteryBitStatus_HIGH ] + sList[ ( int )eMsgCaseFirst.BatteryBitStatus_LOW ] , System.Globalization.NumberStyles.HexNumber );
+                    this.manager.ReceivedDataDic[ eDataKind.Voltage ].Value = mb.ReadLeShort();
+                    this.manager.ReceivedDataDic[ eDataKind.Current ].Value = mb.ReadLeShort();
+                    this.manager.ReceivedDataDic[ eDataKind.BatteryState ].Value = mb.ReadLeShort();
                     break;
                 case 2:
-                    this.manager.ReceivedDataDic[ eDataKind.ChargeCompleteTime ].Value = Int32.Parse( sList[ ( int )eMsgCaseSecond.ChargeFull_HIGH ] + sList[ ( int )eMsgCaseSecond.ChargeFull_LOW ] , System.Globalization.NumberStyles.HexNumber );
-                    this.manager.ReceivedDataDic[ eDataKind.DisChargeCompleteTime ].Value = Int32.Parse( sList[ ( int )eMsgCaseSecond.DisChargeEmpty_HIGH ] + sList[ ( int )eMsgCaseSecond.DisChargeEmpty_LOW ] , System.Globalization.NumberStyles.HexNumber );
-                    this.manager.ReceivedDataDic[ eDataKind.SOC ].Value = Int32.Parse( sList[ ( int )eMsgCaseSecond.SOC ] , System.Globalization.NumberStyles.HexNumber );
-                    this.manager.ReceivedDataDic[ eDataKind.SOH ].Value = Int32.Parse( sList[ ( int )eMsgCaseSecond.SOH ] , System.Globalization.NumberStyles.HexNumber );
+                    this.manager.ReceivedDataDic[ eDataKind.ChargeCompleteTime ].Value = mb.ReadLeShort();
+                    this.manager.ReceivedDataDic[ eDataKind.DisChargeCompleteTime ].Value = mb.ReadLeShort();
+                    this.manager.ReceivedDataDic[ eDataKind.SOC ].Value = mb.ReadByte();
+                    this.manager.ReceivedDataDic[ eDataKind.SOH ].Value = mb.ReadByte();
                     break;
                 case 3:
-                    this.manager.ReceivedDataDic[ eDataKind.ResidualCapacity ].Value = Int32.Parse( sList[ ( int )eMsgCaseThird.Capacity_High ] + sList[ ( int )eMsgCaseThird.Capacity_LOW ] , System.Globalization.NumberStyles.HexNumber );
-                    this.manager.ReceivedDataDic[ eDataKind.ResidualEnergy ].Value = Int32.Parse( sList[ ( int )eMsgCaseThird.Energy_HIGH ] + sList[ ( int )eMsgCaseThird.Energy_LOW ] , System.Globalization.NumberStyles.HexNumber );
-                    this.manager.ReceivedDataDic[ eDataKind.Temperature ].Value = Int32.Parse( sList[ ( int )eMsgCaseThird.Temperature_HIGH ] + sList[ ( int )eMsgCaseThird.Temperature_LOW ] , System.Globalization.NumberStyles.HexNumber );
+                    this.manager.ReceivedDataDic[ eDataKind.ResidualCapacity ].Value = mb.ReadLeShort();
+                    this.manager.ReceivedDataDic[ eDataKind.ResidualEnergy ].Value = mb.ReadLeShort();
+                    this.manager.ReceivedDataDic[ eDataKind.Temperature ].Value = mb.ReadLeShort();
                     break;
             }
         }

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

@@ -44,8 +44,8 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
         }
 
     #region Event
-        public event Action<string,bool> OnConnect;
-        public event Action<string, bool> OnDisconnect;
+        public event Action<string> OnConnect;
+        public event Action<string> OnDisconnect;
         public event Action<ReceivedData> OnChangedReceivedData;
         public event Action<List<ReceivedData>> OnFirstColtd;
     #endregion
@@ -116,9 +116,9 @@ 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 );
                     else if ( qo is QoDisconnected )
-                        DelegateUtils.Invoke( OnDisconnect, qo.Arg0, qo.Arg1 );
+                        DelegateUtils.Invoke( OnDisconnect, qo.Arg0 );
                     else if ( qo is QoReceivedDataChanged )
                         DelegateUtils.Invoke( OnChangedReceivedData, qo.Arg0 );
                     //else if ( qo is QoSendMessageSuccess )
@@ -146,14 +146,14 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
         internal void _OnConnected()
         {
             if ( 0 != collectNo )
-                this.qq.Enqueue( new QoConnect { Arg0 = this.BMUConfig.ID, Arg1 = true } );
+                this.qq.Enqueue( new QoConnect { Arg0 = this.BMUConfig.ID } );
 
             _OnTimePoll();
         }
 
         internal void _OnDisconnected()
         {
-            this.qq.Enqueue( new QoDisconnected { Arg0 = this.BMUConfig.ID, Arg1 = false } );
+            this.qq.Enqueue( new QoDisconnected { Arg0 = this.BMUConfig.ID } );
         }
 
         internal void _InvokeChgdWordsAndBits()
@@ -161,7 +161,8 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
             //Todo: 변경 된 내용 처리.
             if ( 0 == collectNo )
             {
-                this.qq.Enqueue( new QoConnect { Arg0 = this.BMUConfig.ID, Arg1 = true } );
+                //this.qq.Enqueue( new QoConnect { Arg0 = this.BMUConfig.ID } );
+                this.qq.Enqueue( new QoConnect { Arg0 = this.BMUConfig.ID , Arg1 = true } );
                 var ll = this.ReceivedDataDic.Values.ToList();
                 DelegateUtils.Invoke( OnFirstColtd, ll );
             }
@@ -215,24 +216,6 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
     #region Public Method
         public void Connect(eCANSelect select)
         {
-#if SIMULATION
-            //외부 전달 시작
-            this.cancel.AddGo( _ThPullQueue );
-
-            //읽기 시작.
-
-            switch ( select )
-            {
-                case eCANSelect.Advantech:
-                    this.can = new Advantech( this, "can1" );
-                    //this.cancel.AddGo( this.can._ThreadPoolingReceiveData );
-                    break;
-                case eCANSelect.Peak:
-                    this.can = new Peak( this );
-                    //this.cancel.AddGo( this.can._ThreadPoolingReceiveData );
-                    break;
-            }
-#else
             //외부 전달 시작
             this.cancel.AddGo( _ThPullQueue );
 
@@ -249,24 +232,15 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
                     this.cancel.AddGo( this.can._ThreadPoolingReceiveData );
                     break;
             }
-#endif
         }
 
         public void Disconnect()
         {
-#if SIMULATION
-            collectNo = 0;
-            //Thread Stop
-            this.cancel.Cancel();
-            this.qq.Enqueue( new QoDispose() );
-            this.cancel.StopWaitAll();
-#else
             collectNo = 0;
             //Thread Stop
             this.cancel.Cancel();
             this.qq.Enqueue( new QoDispose() );
             this.cancel.StopWaitAll();
-#endif
         }
 
         public void test()
@@ -274,6 +248,6 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
             var clone = this.ReceivedDataDic.Values.FirstOrDefault(); 
             this.qq.Enqueue( new QoReceivedDataChanged { Arg0 = clone } );
         }
-#endregion
+    #endregion
     }
 }

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

@@ -2,6 +2,7 @@
 using GSG.NET.Extensions;
 using GSG.NET.Logging;
 using GSG.NET.TCP;
+using GSG.NET.Utils;
 using Peak.Can.Basic;
 using System;
 using System.Collections;
@@ -289,19 +290,21 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
             TPCANTimestamp CANTimeStamp;
             TPCANStatus stsResult = TPCANStatus.PCAN_ERROR_UNKNOWN;
 
-            Thread.Sleep( 100 );
             for ( int i = 0; i < 3; i++ )
             {
+                Thread.Sleep( 30 );
                 stsResult = PCANBasic.Read( this.handle , out canMsg , out CANTimeStamp );
 
-                if ( canMsg.ID != 0x460 )
-                {
-                    this.IsConnected = false;
-                    return 0;
-                }
+                //if ( canMsg.ID != 0x460 )
+                //{
+                //    this.IsConnected = false;
+                //    return 0;
+                //}
 
-                if(stsResult == TPCANStatus.PCAN_ERROR_OK)
+                if ( stsResult == TPCANStatus.PCAN_ERROR_OK && canMsg.ID == 0x460 )
                     this.PeackCANRecv( canMsg );
+                else if ( canMsg.ID != 0x460 )
+                    this.isConnected = this.GetStatus();
             }
 
             return stsResult;
@@ -309,40 +312,30 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
 
         void PeackCANRecv(TPCANMsg recv)
         {
-            string packet = BitConverter.ToString( recv.DATA ).Replace( "-" , "" );
-            eCanRecvCase recvIndex = eCanRecvCase.NONE;
-
-            List<string> sList = new List<string>();
-            for ( int i = 0; i < packet.Length; i++ )
-            {
-                if ( i % 2 == 0 )
-                    sList.Add( packet.Substring( i , 2 ) );
-            }
+            var mb = new MemoryBuffer( recv.DATA );
 
-            if ( recv.DATA[ 1 ] == 0 ) //empty
-                return;
-            else
-                recvIndex = ( eCanRecvCase )recv.DATA[ 1 ];
+            mb.Read1Byte();
+            var index =  ( eCanRecvCase )mb.Read1Byte();
 
-            switch ( recvIndex )
+            switch ( index )
             {
                 case eCanRecvCase.NONE:
                     break;
                 case eCanRecvCase.CASE1:
-                    this.manager.ReceivedDataDic[ eDataKind.Voltage ].Value = Int32.Parse( sList[ ( int )eMsgCaseFirst.Voltage_HIGH ] + sList[ ( int )eMsgCaseFirst.Voltage_LOW ] , System.Globalization.NumberStyles.HexNumber );
-                    this.manager.ReceivedDataDic[ eDataKind.Current ].Value = Int32.Parse( sList[ ( int )eMsgCaseFirst.Current_HIGH ] + sList[ ( int )eMsgCaseFirst.Current_LOW ] , System.Globalization.NumberStyles.HexNumber );
-                    this.manager.ReceivedDataDic[ eDataKind.BatteryState ].Value = Int32.Parse( sList[ ( int )eMsgCaseFirst.BatteryBitStatus_HIGH ] + sList[ ( int )eMsgCaseFirst.BatteryBitStatus_LOW ] , System.Globalization.NumberStyles.HexNumber );
+                    this.manager.ReceivedDataDic[ eDataKind.Voltage ].Value = mb.ReadBeShort();
+                    this.manager.ReceivedDataDic[ eDataKind.Current ].Value = mb.ReadBeShort();
+                    this.manager.ReceivedDataDic[ eDataKind.BatteryState ].Value = mb.ReadBeShort();
                     break;
                 case eCanRecvCase.CASE2:
-                    this.manager.ReceivedDataDic[ eDataKind.ChargeCompleteTime ].Value = Int32.Parse( sList[ ( int )eMsgCaseSecond.ChargeFull_HIGH ] + sList[ ( int )eMsgCaseSecond.ChargeFull_LOW ] , System.Globalization.NumberStyles.HexNumber );
-                    this.manager.ReceivedDataDic[ eDataKind.DisChargeCompleteTime ].Value = Int32.Parse( sList[ ( int )eMsgCaseSecond.DisChargeEmpty_HIGH ] + sList[ ( int )eMsgCaseSecond.DisChargeEmpty_LOW ] , System.Globalization.NumberStyles.HexNumber );
-                    this.manager.ReceivedDataDic[ eDataKind.SOC ].Value = Int32.Parse( sList[ ( int )eMsgCaseSecond.SOC ] , System.Globalization.NumberStyles.HexNumber );
-                    this.manager.ReceivedDataDic[ eDataKind.SOH ].Value = Int32.Parse( sList[ ( int )eMsgCaseSecond.SOH ] , System.Globalization.NumberStyles.HexNumber );
+                    this.manager.ReceivedDataDic[ eDataKind.ChargeCompleteTime ].Value = mb.ReadLeShort();
+                    this.manager.ReceivedDataDic[ eDataKind.DisChargeCompleteTime ].Value = mb.ReadLeShort();
+                    this.manager.ReceivedDataDic[ eDataKind.SOC ].Value = mb.ReadByte();
+                    this.manager.ReceivedDataDic[ eDataKind.SOH ].Value = mb.ReadByte();
                     break;
                 case eCanRecvCase.CASE3:
-                    this.manager.ReceivedDataDic[ eDataKind.ResidualCapacity ].Value = Int32.Parse( sList[ ( int )eMsgCaseThird.Capacity_High ] + sList[ ( int )eMsgCaseThird.Capacity_LOW ] , System.Globalization.NumberStyles.HexNumber );
-                    this.manager.ReceivedDataDic[ eDataKind.ResidualEnergy ].Value = Int32.Parse( sList[ ( int )eMsgCaseThird.Energy_HIGH ] + sList[ ( int )eMsgCaseThird.Energy_LOW ] , System.Globalization.NumberStyles.HexNumber );
-                    this.manager.ReceivedDataDic[ eDataKind.Temperature ].Value = Int32.Parse( sList[ ( int )eMsgCaseThird.Temperature_HIGH ] + sList[ ( int )eMsgCaseThird.Temperature_LOW ] , System.Globalization.NumberStyles.HexNumber );
+                    this.manager.ReceivedDataDic[ eDataKind.ResidualCapacity ].Value = mb.ReadLeShort();
+                    this.manager.ReceivedDataDic[ eDataKind.ResidualEnergy ].Value = mb.ReadLeShort();
+                    this.manager.ReceivedDataDic[ eDataKind.Temperature ].Value = mb.ReadLeShort();
                     break;
             }
         }

+ 8 - 18
Dev/OHV/VehicleControlSystem/ControlLayer/Vehicle.cs

@@ -123,6 +123,8 @@ namespace VehicleControlSystem.ControlLayer
         public int ObstacleDrive { get { return this._obstacleDrive; } set { SetField( ref this._obstacleDrive, value ); } }
         private int _obstacleCurve;
         public int ObstacleCurve { get { return this._obstacleCurve; } set { SetField( ref this._obstacleCurve, value ); } }
+        private int obstacleCurrent;
+        public int ObstacleCurrent { get { return this.ObstacleCurrent; } set { SetField( ref this.obstacleCurrent , value ); } }
 
         private eObstacleState obstacleState = eObstacleState.Normal;
         public eObstacleState ObstacleStateProperty
@@ -264,8 +266,7 @@ namespace VehicleControlSystem.ControlLayer
         {
             get
             {
-                this.BatteryIsConnect = this.bMUManager.IsConnected;
-                return this.bMUManager.IsConnected;
+                return batteryIsConnect;
             }
             set { this.SetField( ref this.batteryIsConnect, value ); }
         }
@@ -378,6 +379,7 @@ namespace VehicleControlSystem.ControlLayer
                                 ControlKind = ObstacleControlEventArgs.eControlKind.INFO,
                                 Drive = this.ObstacleDrive,
                                 Curve = this.ObstacleCurve,
+                                Current = this.GetObstacleDetectPattern(),
                                 ObstacleState = this.ObstacleStateProperty.ToString()
                             };
                             this.ObstacleControlEventPublish( msg );
@@ -546,18 +548,6 @@ namespace VehicleControlSystem.ControlLayer
             state.CurrentTag = this.CurrentTag;
             state.CurrentTorque = this.CurrentTorque;
 
-            state.Voltage = this.BatteryVoltage;
-            state.Current = this.BatteryCurrent;
-            state.BatteryState = this.BatteryState;
-            state.ChargeTime = this.BatteryChargeTime;
-            state.DisChargeTime = this.BatteryDisChargeTime;
-            state.SOC = this.BatteryStateOfCharge;
-            state.SOH = this.BatteryStateOfHealth;
-            state.Capacity = this.BatteryCapacity;
-            state.Energy = this.BatteryEnergy;
-            state.Temperature = this.BatteryTemperature;
-            state.BatteryIsConnect = this.BatteryIsConnect;
-
             var msg = new DriveControlEventArgs();
             msg.ControlKind = args.ControlKind;
             msg.Args = state;
@@ -1595,15 +1585,15 @@ namespace VehicleControlSystem.ControlLayer
             this.bMUManager.Connect( canType );
         }
 
-        private void BMUManager_OnDisconnect( string obj, bool state )
+        private void BMUManager_OnDisconnect( string obj)
         {
-            this.BatteryIsConnect = state;
+            this.BatteryIsConnect = false;
             this.OccurVehicleAlarm( 32 );
         }
 
-        private void BMUManager_OnConnect( string obj, bool state )
+        private void BMUManager_OnConnect( string obj )
         {
-            this.BatteryIsConnect = state;
+            this.BatteryIsConnect = true;
         }
 
         private void BMUManager_OnFirstColtd( List<ReceivedData> obj )

+ 33 - 21
Dev/OHV/VehicleControlSystem/VCSystem.cs

@@ -175,14 +175,39 @@ namespace VehicleControlSystem
                 case VCSMessageEventArgs.eVCSMessageKind.ReqPIOBatteryCharge:
                     this.ReqPIOBattery( msg );
                     break;
-                case VCSMessageEventArgs.eVCSMessageKind.ReqPIOBatteryChargeStop:
-                    ReqPIOBatteryChargeStop();
+                case VCSMessageEventArgs.eVCSMessageKind.ReqBatteryState:
+                    this.ReqBatteryState();
                     break;
                 default:
                     break;
             }
         }
 
+        void ReqBatteryState()
+        {
+            BatteryInfo battery = new BatteryInfo();
+
+            battery.Voltage = vehicle.BatteryVoltage;
+            battery.Current = vehicle.BatteryCurrent;
+            battery.ChargeTime = vehicle.BatteryChargeTime;
+            battery.DisChargeTime = vehicle.BatteryDisChargeTime;
+            battery.Capacity = vehicle.BatteryCapacity;
+            battery.Energy = vehicle.BatteryEnergy;
+            battery.SOC = vehicle.BatteryStateOfCharge;
+            battery.SOH = vehicle.BatteryStateOfHealth;
+            battery.State = vehicle.BatteryState;
+            battery.IsConnect = vehicle.BatteryIsConnect;
+            battery.Temperature = vehicle.BatteryTemperature;
+
+            var reply = new GUIMessageEventArgs()
+            {
+                Args = battery,
+                Kind = GUIMessageEventArgs.eGUIMessageKind.RspBatteryState
+            };
+
+            GUIMessageEventPublish( reply );
+        }
+
         private void ReqConveyorMove( VCSMessageEventArgs msg )
         {
             var result = 0;
@@ -236,17 +261,9 @@ namespace VehicleControlSystem
 
             /*PIO Load// Unload*/
             if ( msg.MessageText.Equals( "PL" ) )
-            {
-                //this.vehicle.DriveServoOff();
                 result = this.vehicle.PIOAndLoad( "" );
-                //this.vehicle.DriveServoOn();
-            }
             else
-            {
-                //this.vehicle.DriveServoOff();
                 result = this.vehicle.PIOAndUnload( "" );
-                //this.vehicle.DriveServoOn();
-            }
 
             //실행 결과 확인 
             if ( result <= 0 )
@@ -272,19 +289,14 @@ namespace VehicleControlSystem
             subCmd.Type = eSubCommandType.Charge;
 
             //result = this.vehicle.PIOBatteryCharge( subCmd );
-            this.vehicle.ManualBatteryCharge( );
+            this.vehicle.BatteryCharge( subCmd );
 
-            //if ( result <= 0 )
-            //    reply.Result = FluentResults.Results.Ok();
-            //else
-            //    reply.Result = FluentResults.Results.Fail( "Battery Charge Fail" );
-
-            //GUIMessageEventPublish( reply );
-        }
+            if ( result <= 0 )
+                reply.Result = FluentResults.Results.Ok();
+            else
+                reply.Result = FluentResults.Results.Fail( "Battery Charge Fail" );
 
-        void ReqPIOBatteryChargeStop()
-        {
-            this.vehicle.IsCharging = false;
+            GUIMessageEventPublish( reply );
         }
 
         private void ReqTest()