From fb8a0c3e52ffd8e43607e81daf90696e435a0898 Mon Sep 17 00:00:00 2001
From: "Burns, Terry" <Terry.Burns@ricardo.com>
Date: Fri, 9 Jan 2015 15:00:41 +0000
Subject: [PATCH] ADDED RL CODE FOR S/S AND OTHER PAUX CALL PRE CALCS FOR
 DRIVELINE POWER AND IDLE

git-tfs-id: [http://tfs00.element.root.com:8080/tfs/TFSCollection]$/VECTO;C1711
---
 VECTO/Input Files/cGBX.vb                     |  6 +-
 VECTO/MODcalc/cMOD.vb                         | 26 +++----
 VECTO/MODcalc/cPower.vb                       | 76 +++++++++++++------
 .../VectoAuxiliaries/AdvancedAuxiliaries.vb   | 22 +++++-
 .../VectoAuxiliaries/DownstreamModules/M9.vb  |  2 +-
 5 files changed, 90 insertions(+), 42 deletions(-)

diff --git a/VECTO/Input Files/cGBX.vb b/VECTO/Input Files/cGBX.vb
index 4f64001b20..984ad34660 100644
--- a/VECTO/Input Files/cGBX.vb	
+++ b/VECTO/Input Files/cGBX.vb	
@@ -495,14 +495,14 @@ Public Class cGBX
 
             AAUX_Gobal.ClutchEngaged = (Gear > 0)
 
-            AAUX_Gobal.Idle =  False' (Gear = 0 And Not Pplus And Not Pminus)
+            AAUX_Gobal.Idle = False'(Gear = 0 And Not Pplus And Not Pminus)
 
             AAUX_Gobal.InNeutral = (Gear = 0)
 
             'Driveline Power = required power at clutch = power at wheels plus powertrain losses
             '[kW]
-            '**** THIS IS NOT CORRECT< BUT NO PKU Variable is available at this point ****
-            AAUX_Gobal.EngineDrivelinePower = 0
+            '**** RL 7-7-15 ****
+            AAUX_Gobal.EngineDrivelinePower = PeOut
 
             '[1/min]
             AAUX_Gobal.EngineSpeed = nU
diff --git a/VECTO/MODcalc/cMOD.vb b/VECTO/MODcalc/cMOD.vb
index b2e31f9ab2..33270d5b64 100644
--- a/VECTO/MODcalc/cMOD.vb
+++ b/VECTO/MODcalc/cMOD.vb
@@ -742,19 +742,19 @@ Public Class cMOD
 
                     'AA-TB
                     'Advanced Auxiliaries
-                      s.Append(Sepp & AA_NonSmartAlternatorsEfficiency(t).ToString())             
-                      s.Append(Sepp & AA_SmartIdleCurrent_Amps(t).ToString())              
-                      s.Append(Sepp & AA_SmartIdleAlternatorsEfficiency(t).ToString())                  
-                      s.Append(Sepp & AA_SmartTractionCurrent_Amps(t).ToString())                     
-                      s.Append(Sepp & AA_SmartTractionAlternatorEfficiency(t).ToString())               
-                      s.Append(Sepp & AA_SmartOverrunCurrent_Amps(t).ToString())                      
-                      s.Append(Sepp & AA_SmartOverrunAlternatorEfficiency(t).ToString())               
-                      s.Append(Sepp & AA_CompressorFlowRate_LitrePerSec(t).ToString())                  
-                      s.Append(Sepp & AA_OverrunFlag(t).ToString())                                   
-                      s.Append(Sepp & AA_EngineIdleFlag(t).ToString())                                     
-                      s.Append(Sepp & AA_CompressorFlag(t).ToString())                                    
-                      s.Append(Sepp & AA_TotalCycleFC_BeforeSSandWHTCcorrection_Grams(t).ToString())  
-                      s.Append(Sepp & AA_TotalCycleFC_BeforeSSandWHTCcorrection_Litres(t).ToString())
+                      s.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC",AA_NonSmartAlternatorsEfficiency(t).ToString(),""))           
+                      s.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC",AA_SmartIdleCurrent_Amps(t).ToString(),""))              
+                      s.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC",AA_SmartIdleAlternatorsEfficiency(t).ToString(),""))                  
+                      s.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC",AA_SmartTractionCurrent_Amps(t).ToString(),""))                     
+                      s.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC",AA_SmartTractionAlternatorEfficiency(t).ToString(),""))               
+                      s.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC",AA_SmartOverrunCurrent_Amps(t).ToString(),""))                      
+                      s.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC",AA_SmartOverrunAlternatorEfficiency(t).ToString(),""))               
+                      s.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC",AA_CompressorFlowRate_LitrePerSec(t).ToString(),""))                  
+                      s.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC",AA_OverrunFlag(t).ToString(),""))                                   
+                      s.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC",AA_EngineIdleFlag(t).ToString(),""))                                     
+                      s.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC",AA_CompressorFlag(t).ToString(),""))                                    
+                      s.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC",AA_TotalCycleFC_BeforeSSandWHTCcorrection_Grams(t).ToString(),""))  
+                      s.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC",AA_TotalCycleFC_BeforeSSandWHTCcorrection_Litres(t).ToString(),""))
 
                 End If
 
diff --git a/VECTO/MODcalc/cPower.vb b/VECTO/MODcalc/cPower.vb
index 815b8a581e..f9404aa0e5 100644
--- a/VECTO/MODcalc/cPower.vb
+++ b/VECTO/MODcalc/cPower.vb
@@ -1442,9 +1442,24 @@ lb_nOK:
         'AA-TB    
         'Aggregate Fuel On Last Known Signals.  
         If Not AAUX_Gobal.advancedAuxModel is nothing
+
+         'EngineState ( used for start stop fueling adjustment )
+
+         If EngState0 = tEngState.Stopped then
+          advancedAuxModel.Signals.EngineStopped =true
+         else
+          advancedAuxModel.Signals.EngineStopped = false
+         End If
+
+
+
+
          advancedAuxModel.CycleStep(1,message)
 
 
+
+         try
+
          'Add Mod Data
          ModData.AA_NonSmartAlternatorsEfficiency                  .Add( advancedAuxModel.AA_NonSmartAlternatorsEfficiency)
          ModData.AA_SmartIdleCurrent_Amps                          .Add( advancedAuxModel.AA_SmartIdleCurrent_Amps)
@@ -1460,6 +1475,15 @@ lb_nOK:
          ModData.AA_TotalCycleFC_BeforeSSandWHTCcorrection_Grams   .Add( advancedAuxModel.AA_TotalCycleFC_BeforeSSandWHTCcorrection_Grams)
          ModData.AA_TotalCycleFC_BeforeSSandWHTCcorrection_Litres  .Add( advancedAuxModel.AA_TotalCycleFC_BeforeSSandWHTCcorrection_Litres)
 
+         Catch ex   as Exception
+
+         Dim dummy = 0
+
+
+         End try
+
+
+
         End if
 
         Loop Until jz >= MODdata.tDim
@@ -1754,38 +1778,41 @@ lb_nOK:
         'Do not allow positive road gradients     
         Grad = MODdata.Vh.fGrad(s)
 
-                    'AA-TB
-            'Recalculate for Advanced Auxiliaries.
+        
+        Pwheel = fPwheel(t, v, a, Grad)
+        Pe = Pwheel + fPlossGB(Pwheel, v, Gear, True) + fPlossDiff(Pwheel, v, True) + fPaG(v, a) + fPlossRt(v, Gear) + fPaux(t, nU) + fPaMotSimple(t, Gear, v, a)
 
-            AAUX_Gobal.ClutchEngaged = (Gear > 0)
 
-            AAUX_Gobal.Idle = (Gear = 0 And Not Pplus And Not Pminus)
+        'AA-TB
+       'Recalculate for Advanced Auxiliaries.
 
-            AAUX_Gobal.InNeutral = (Gear = 0)
+       AAUX_Gobal.ClutchEngaged = (Gear > 0)
 
-            'Driveline Power = required power at clutch = power at wheels plus powertrain losses
-            '[kW]
-            '**** THIS IS NOT CORRECT< BUT NO PKU Variable is available at this point ****
-            AAUX_Gobal.EngineDrivelinePower = 0
+       AAUX_Gobal.Idle = (Gear = 0 And Not Pplus And Not Pminus)
 
-            '[1/min]
-            AAUX_Gobal.EngineSpeed = nU
+       AAUX_Gobal.InNeutral = (Gear = 0)
 
-            '[Nm] (using Power => Torque conversion)
-            AAUX_Gobal.EngineDrivelineTorque = nPeToM(EngineSpeed, EngineDrivelinePower)
+       'Driveline Power = required power at clutch = power at wheels plus powertrain losses
+       '[kW]
+       '**** THIS IS NOT CORRECT< BUT NO PKU Variable is available at this point ****
+       AAUX_Gobal.EngineDrivelinePower = Pwheel + fPlossGB(Pwheel, v, Gear, True) + fPlossDiff(Pwheel, v, True) + fPaG(v, a) + fPlossRt(v, Gear)
 
-            'Motoring power (< 0 !!!)
-            '[kW]
-            '** MULTIPLIED BY - TO GET POSITIVE VALUE
-            AAUX_Gobal.EngineMotoringPower = - FLD(Gear).Pdrag(EngineSpeed)
+       '[1/min]
+       AAUX_Gobal.EngineSpeed = nU
 
-            'Additional aux power from driving cycle (optional user input)
-            '[kW]
-            AAUX_Gobal.PreExistingAuxPower = MODdata.Vh.Padd(t)
+       '[Nm] (using Power => Torque conversion)
+       AAUX_Gobal.EngineDrivelineTorque = nPeToM(EngineSpeed, EngineDrivelinePower)
+
+       'Motoring power (< 0 !!!)
+       '[kW]
+       '** MULTIPLIED BY - TO GET POSITIVE VALUE
+       AAUX_Gobal.EngineMotoringPower = - FLD(Gear).Pdrag(EngineSpeed)
+
+       'Additional aux power from driving cycle (optional user input)
+       '[kW]
+       AAUX_Gobal.PreExistingAuxPower = MODdata.Vh.Padd(t)
 
 
-        Pwheel = fPwheel(t, v, a, Grad)
-        Pe = Pwheel + fPlossGB(Pwheel, v, Gear, True) + fPlossDiff(Pwheel, v, True) + fPaG(v, a) + fPlossRt(v, Gear) + fPaux(t, nU) + fPaMotSimple(t, Gear, v, a)
 
         Diff = Math.Abs(Pdrag - Pe)
 
@@ -1833,8 +1860,8 @@ lb_nOK:
 
             'Driveline Power = required power at clutch = power at wheels plus powertrain losses
             '[kW]
-            '**** THIS IS NOT CORRECT< BUT NO PKU Variable is available at this point ****
-            AAUX_Gobal.EngineDrivelinePower = 0
+            '**** RL-7/1/15 ****
+            AAUX_Gobal.EngineDrivelinePower = Pwheel + fPlossGB(Pwheel, v, Gear, True) + fPlossDiff(Pwheel, v, True) + fPaG(v, a) + fPlossRt(v, Gear)
 
             '[1/min]
             AAUX_Gobal.EngineSpeed = nU
@@ -2543,6 +2570,7 @@ lb10:
              AAUX_Gobal.advancedAuxModel.Signals.Idle = AAUX_Gobal.Idle
              AAUX_Gobal.advancedAuxModel.Signals.InNeutral = AAUX_Gobal.InNeutral
 
+
              'Power coming out of Advanced Model is in Watts.
              power = (advancedAuxModel.AuxiliaryPowerAtCrankWatts /1000)
 
diff --git a/VECTOAux/VectoAuxiliaries/AdvancedAuxiliaries.vb b/VECTOAux/VectoAuxiliaries/AdvancedAuxiliaries.vb
index e360aa0647..668658a806 100644
--- a/VECTOAux/VectoAuxiliaries/AdvancedAuxiliaries.vb
+++ b/VECTOAux/VectoAuxiliaries/AdvancedAuxiliaries.vb
@@ -195,7 +195,20 @@ End Sub
        M11.CycleStep( seconds )
 
        'Used in the fuel aggregated output on M13 ( Sum 5 )
+
+       try
+
        Signals.CurrentCycleTimeInSeconds+=1
+
+
+       Catch ex As Exception
+
+          MessageBox.Show("Im an exception")
+          Return false
+
+       end try
+
+
      
        Return true
      
@@ -209,8 +222,15 @@ End Sub
 
     Public Function RunStart( ByVal auxFilePath As String,byval vectoFilePath as string , ByRef message As String) As Boolean Implements VectoAuxiliaries.IAdvancedAuxiliaries.RunStart
           
+          Try
+          Initialise(auxFilePath, vectoFilePath)  
+
+          Catch ex As Exception
+
+          Return false
 
-       Initialise(auxFilePath, vectoFilePath)   
+          End Try
+ 
        
        'TODO:Modify Initialise to return a Bool.
        Return true     
diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/M9.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/M9.vb
index fff4049db1..f57d61c95b 100644
--- a/VECTOAux/VectoAuxiliaries/DownstreamModules/M9.vb
+++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/M9.vb
@@ -71,7 +71,7 @@ Private Signals As ISignals
 Private Function S0( rpm As Single ) As Single
 
   If rpm=0  then   
-      Return 0
+      Return 0.00001
   End If
   
   Return rpm / RPM_TO_RADS_PER_SECOND
-- 
GitLab