Pārlūkot izejas kodu

현장 작업 업데이트

ys-hwang 6 gadi atpakaļ
vecāks
revīzija
fd3afe8b2a

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

@@ -39,6 +39,8 @@ namespace OHV.Common.Events
 
             RspObstaclePatternChg,
             RspObstaclePatternNo,
+
+            RspBatteryState,
         }
 
         //Property 이름임.
@@ -90,6 +92,8 @@ namespace OHV.Common.Events
 
             ReqObstaclePatternChg,
             ReqObstaclePatternNo,
+
+            ReqBatteryState,
         }
 
         public eVCSMessageKind Kind { get; set; }
@@ -266,6 +270,7 @@ namespace OHV.Common.Events
         {
             NONE = -1,
             DRIVE = 0,
+            CURRENT,
             CURVE,
             STATE,
             INFO,
@@ -274,6 +279,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

+ 4 - 0
Dev/OHV/OHV.Module.Interactivity/ConfirmationPopupView.xaml

@@ -63,6 +63,10 @@
                 <!--Style="{DynamicResource btn_Send}"-->
 
                 <Button x:Name="btnCancel" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Height="50" Content="Cancle" Command="{Binding CloseDialogCommand}" CommandParameter="false" Background="{DynamicResource PrimaryHueMidBrush}" Style="{StaticResource MaterialDesignRaisedButton}" FontSize="20"/>
+                <!--<Button x:Name="btnSend" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Margin="0,0,20,0" Height="40" Command="{Binding CloseDialogCommand}" CommandParameter="true" Content="확인" Background="#263238" Style="{StaticResource MaterialDesignRaisedButton}"/>-->
+                <!--Style="{DynamicResource btn_Send}"-->
+
+                <!--<Button x:Name="btnCancel" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Height="40"  Content="취소" Command="{Binding CloseDialogCommand}" CommandParameter="false" Background="#263238" Style="{StaticResource MaterialDesignRaisedButton}"/>-->
                 <!--Style="{DynamicResource btn_Close}"-->
             </StackPanel>
         </Grid>

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 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 )

+ 3 - 2
Dev/OHV/OHV.Module.Interactivity/PopUp/ConveyorControlView.xaml

@@ -9,7 +9,7 @@
              prism:ViewModelLocator.AutoWireViewModel="True"
              xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
              Background="#263238"
-             Height="750"
+             Height="800"
              Width="900">
 
     <prism:Dialog.WindowStyle>
@@ -22,8 +22,9 @@
             <Setter Property="BorderThickness" Value="1"/>
             <Setter Property="BorderBrush" Value="{DynamicResource BorderSolidNormal}"/>
             <Setter Property="Template" Value="{DynamicResource WindowTemplateKey}"/>
+            <Setter Property="SizeToContent" Value="WidthAndHeight"/>
 
-            <!--<Style.Triggers>
+                <!--<Style.Triggers>
                 <Trigger Property="ResizeMode" Value="CanResizeWithGrip">
                     <Setter Property="Template" Value="{StaticResource WindowTemplateKey}"/>
                 </Trigger>

+ 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>
 

+ 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;
             }
         }

+ 7 - 6
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()
@@ -162,6 +162,7 @@ namespace VehicleControlSystem.ControlLayer.Serial.BatteryTabos
             if ( 0 == collectNo )
             {
                 //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 );
             }

+ 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;
@@ -290,19 +291,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;
@@ -310,40 +313,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;
             }
         }

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

@@ -175,11 +175,39 @@ namespace VehicleControlSystem
                 case VCSMessageEventArgs.eVCSMessageKind.ReqPIOBatteryCharge:
                     this.ReqPIOBattery( msg );
                     break;
+                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;