Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 73b6582c authored by Terry Burns's avatar Terry Burns Committed by Kostis ANAGNOSTOPOULOS
Browse files

Removed dependency in ElectricalConsumerList from having to supply...

Removed dependency in ElectricalConsumerList from having to supply DoorDutyCycle. This must be inserted during construction as is depended on Cycle Actuations and does not have to be recalculated unless the cycle changes.

Also Completed M5_SmartAlternatorSetRegen

git-tfs-id: [http://tfs00.element.root.com:8080/tfs/TFSCollection]$/VECTO;C1638
parent c4a6e200
No related branches found
No related tags found
No related merge requests found
Showing
with 310 additions and 129 deletions
...@@ -9,6 +9,7 @@ Implements IElectricalConsumerList ...@@ -9,6 +9,7 @@ Implements IElectricalConsumerList
Private _items As New Dictionary(Of String, IElectricalConsumer) Private _items As New Dictionary(Of String, IElectricalConsumer)
Private _powernetVoltage As Single Private _powernetVoltage As Single
Private _doorDutyCycleZeroToOne As single
Public ReadOnly Property Items As Dictionary(Of String, IElectricalConsumer) Implements IElectricalConsumerList.Items Public ReadOnly Property Items As Dictionary(Of String, IElectricalConsumer) Implements IElectricalConsumerList.Items
Get Get
...@@ -17,12 +18,14 @@ Private _powernetVoltage As Single ...@@ -17,12 +18,14 @@ Private _powernetVoltage As Single
End Property End Property
'Create Empty List 'Create Empty List
Public Sub New(powenetVoltage As Single, Optional createDefaultList As Boolean = False) Public Sub New(powernetVoltage As Single,doorDutyCycle_ZeroToOne As single, Optional createDefaultList As Boolean = False)
_powernetVoltage = powenetVoltage _powernetVoltage = powernetVoltage
If createDefaultList Then SetDefaultConsumerList() If createDefaultList Then SetDefaultConsumerList()
_doorDutyCycleZeroToOne = doorDutyCycle_ZeroToOne
End Sub End Sub
...@@ -112,21 +115,16 @@ End Sub ...@@ -112,21 +115,16 @@ End Sub
End Sub End Sub
Public Function GetTotalAverageDemandAmps(doorDutyCyclePercentage? As Single, excludeOnBase As Boolean) As Single Implements Electrics.IElectricalConsumerList.GetTotalAverageDemandAmps Public Function GetTotalAverageDemandAmps(excludeOnBase As Boolean) As Single Implements Electrics.IElectricalConsumerList.GetTotalAverageDemandAmps
'Sanity check.
If doorDutyCyclePercentage Is Nothing Or doorDutyCyclePercentage > 1 Or doorDutyCyclePercentage < 0 Then
Throw New ArgumentException("doorDutyCyclePercentage must be between 0 and 1")
End If
Dim Amps As Single Dim Amps As Single
If excludeOnBase Then If excludeOnBase Then
Amps = Aggregate item In Items Where item.Value.BaseVehicle = False Into Sum(item.Value.TotalAvgConumptionAmps(doorDutyCyclePercentage)) Amps = Aggregate item In Items Where item.Value.BaseVehicle = False Into Sum(item.Value.TotalAvgConumptionAmps(_doorDutyCycleZeroToOne))
Else Else
Amps = Aggregate item In Items Into Sum(item.Value.TotalAvgConumptionAmps(doorDutyCyclePercentage)) Amps = Aggregate item In Items Into Sum(item.Value.TotalAvgConumptionAmps(_doorDutyCycleZeroToOne))
End If End If
......
...@@ -6,7 +6,7 @@ Public Interface IElectricalConsumerList ...@@ -6,7 +6,7 @@ Public Interface IElectricalConsumerList
ReadOnly Property Items As Dictionary(Of String, IElectricalConsumer) ReadOnly Property Items As Dictionary(Of String, IElectricalConsumer)
Sub AddConsumer(consumer As IElectricalConsumer) Sub AddConsumer(consumer As IElectricalConsumer)
Sub RemoveConsumer(consumer As IElectricalConsumer) Sub RemoveConsumer(consumer As IElectricalConsumer)
Function GetTotalAverageDemandAmps(doorDutyCyclePercentage? As Single, excludeOnBase As Boolean) As Single Function GetTotalAverageDemandAmps(excludeOnBase As Boolean) As Single
End Interface End Interface
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Function GetHVACElectricalPowerDemandAmps() As Single Function GetHVACElectricalPowerDemandAmps() As Single
Function GetEfficiency(crankRPM As Integer, DoorCycleActuationPercentage As Single) As Single Function GetEfficiency(crankRPM As Integer) As Single
End Interface End Interface
Public Interface IM5_SmartAlternatorSetGeneration
function AlternatorsGenerationPowerAtCrankIdleWatts(rpm As Integer) As Single
function AlternatorsGenerationPowerAtCrankTractionOnWatts(rpm As Integer) As Single
function AlternatorsGenerationPowerAtCrankOverrunWatts(rpm As Integer) As Single
End Interface
...@@ -12,42 +12,52 @@ Private _resultCardTraction As IResultCard ...@@ -12,42 +12,52 @@ Private _resultCardTraction As IResultCard
Private _resultCardOverrun As IResultCard Private _resultCardOverrun As IResultCard
Public ReadOnly Property SmartIdleCurrent As single
Get
End Get Public Function SmartIdleCurrent() As single
End Property
Public ReadOnly Property AlternatorsEfficiencyIdleResultCard As single
Get
End Get Return _resultCardIdle.GetSmartCurrentResult(HvacPlusNonBaseCurrents())
End Property
end Function
Public readonly Property SmartTractionCurrent As Single Public Function AlternatorsEfficiencyIdleResultCard(ByVal rpm As integer ) As single
Get
End Get Return _alternatorMap.GetEfficiency(rpm, SmartIdleCurrent()).Efficiency
End Property
Public readonly Property AlternatorsEfficiencyTractionOnResultCard As Single
Get
End Get End Function
End Property
Public ReadOnly Property SmartOverrunCurrent As Single
Get
End Get Public function SmartTractionCurrent As Single
End Property
Public ReadOnly Property AlternatorsEfficiencyOverrunResultCard As single
Get
End Get Return _resultCardTraction.GetSmartCurrentResult(HvacPlusNonBaseCurrents())
End Property
End Function
Public Function AlternatorsEfficiencyTractionOnResultCard(ByVal rpm As integer ) As Single
Return _alternatorMap.GetEfficiency(rpm, SmartTractionCurrent()).Efficiency
End Function
Public Function SmartOverrunCurrent As Single
Return _resultCardOverrun.GetSmartCurrentResult(HvacPlusNonBaseCurrents())
End Function
Public Function AlternatorsEfficiencyOverrunResultCard(ByVal rpm As integer) As single
Return _alternatorMap.GetEfficiency(rpm, SmartOverrunCurrent()).Efficiency
End Function
Private function HvacPlusNonBaseCurrents() As Single
Return _m0.GetHVACElectricalPowerDemandAmps() + _electricalConsumables.GetTotalAverageDemandAmps(true)
End Function
Public Sub new ( m0 As IM0_NonSmart_AlternatorsSetEfficiency, _ Public Sub new ( m0 As IM0_NonSmart_AlternatorsSetEfficiency, _
electricalConsumables as IElectricalConsumerList, _ electricalConsumables as IElectricalConsumerList, _
...@@ -62,14 +72,17 @@ Public Sub new ( m0 As IM0_NonSmart_AlternatorsSetEfficiency, _ ...@@ -62,14 +72,17 @@ Public Sub new ( m0 As IM0_NonSmart_AlternatorsSetEfficiency, _
If alternatorMap is Nothing then throw new ArgumentException("Must supply a valid alternator map") If alternatorMap is Nothing then throw new ArgumentException("Must supply a valid alternator map")
if resultCardIdle is nothing then throw new ArgumentException("Result Card 'IDLE' must be supplied even if it has no contents") if resultCardIdle is nothing then throw new ArgumentException("Result Card 'IDLE' must be supplied even if it has no contents")
if resultCardTraction is nothing then throw new ArgumentException("Result Card 'TRACTION' must be supplied even if it has no contents") if resultCardTraction is nothing then throw new ArgumentException("Result Card 'TRACTION' must be supplied even if it has no contents")
if resultCardOverrun is nothing then throw new ArgumentException("Result Card 'OVERRUN' must be supplied even if it has no contents") if resultCardOverrun is nothing then throw new ArgumentException("Result Card 'OVERRUN' must be supplied even if it has no contents")
'Assignments to private variables. 'Assignments to private variables.
_m0=m0
_electricalConsumables = electricalConsumables _electricalConsumables = electricalConsumables
_alternatorMap = alternatorMap _alternatorMap = alternatorMap
_resultCardIdle = resultCardIdle _resultCardIdle = resultCardIdle
_resultCardTraction = resultCardTraction _resultCardTraction = resultCardTraction
_resultCardOverrun = resultCardOverrun _resultCardOverrun = resultCardOverrun
End Sub End Sub
......
...@@ -35,15 +35,14 @@ Public Class M0_NonSmart_AlternatorsSetEfficiency ...@@ -35,15 +35,14 @@ Public Class M0_NonSmart_AlternatorsSetEfficiency
Public Function GetEfficiency(crankRPM As Integer, DoorCycleActuationPercentage As Single) As Single Implements IM0_NonSmart_AlternatorsSetEfficiency.GetEfficiency Public Function GetEfficiency(crankRPM As Integer) As Single Implements IM0_NonSmart_AlternatorsSetEfficiency.GetEfficiency
'Sanity Check. 'Sanity Check.
If crankRPM < 1 Then Throw New ArgumentException("CrankRMP must be greater than zero") If crankRPM < 1 Then Throw New ArgumentException("CrankRMP must be greater than zero")
If DoorCycleActuationPercentage < 0 Or DoorCycleActuationPercentage > 1 Then Throw New ArgumentException("DoorCyclyActuationPercentage must be between 0 and 1")
Dim rotationalSpeed As Single = crankRPM Dim rotationalSpeed As Single = crankRPM
Dim currentHVACDemandAmps As Single = _hvacMap.GetElectricalDemand(_hvacInputs.Region, _hvacInputs.Season) Dim currentHVACDemandAmps As Single = _hvacMap.GetElectricalDemand(_hvacInputs.Region, _hvacInputs.Season)
Dim currentElectricalConsumerDemandAmp As Single = _electricalConsumersList.GetTotalAverageDemandAmps(DoorCycleActuationPercentage, True) Dim currentElectricalConsumerDemandAmp As Single = _electricalConsumersList.GetTotalAverageDemandAmps(True)
Dim totalDemandAmps As Single = currentHVACDemandAmps + currentElectricalConsumerDemandAmp Dim totalDemandAmps As Single = currentHVACDemandAmps + currentElectricalConsumerDemandAmp
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
Private _electricalConsumers As IElectricalConsumerList Private _electricalConsumers As IElectricalConsumerList
Private _module0 As IM0_NonSmart_AlternatorsSetEfficiency Private _module0 As IM0_NonSmart_AlternatorsSetEfficiency
Private _alternatorPulleyEffiency As Single Private _alternatorPulleyEffiency As Single
Private _doorsPercentageZeroToOne As Single
Public Sub New(ByVal electricalConsumers As IElectricalConsumerList, m0 As IM0_NonSmart_AlternatorsSetEfficiency, altPulleyEfficiency As Single, powerNetVoltage As Single) Public Sub New(ByVal electricalConsumers As IElectricalConsumerList, m0 As IM0_NonSmart_AlternatorsSetEfficiency, altPulleyEfficiency As Single, powerNetVoltage As Single)
...@@ -28,23 +28,18 @@ ...@@ -28,23 +28,18 @@
End Sub End Sub
''' <summary>
'''
''' </summary>
''' <param name="doorDutyCycleZeroToOne"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Function GetAveragePowerDemandAtAlternator(doorDutyCycleZeroToOne As Single) As Single
Return _electricalConsumers.GetTotalAverageDemandAmps(doorDutyCycleZeroToOne, False) Public Function GetAveragePowerDemandAtAlternator() As Single
Return _electricalConsumers.GetTotalAverageDemandAmps(False)
End Function End Function
Public Function GetAveragePowerAtCrank(ByVal engineRpm As Integer, doorDutyCycleZeroToOne As Single) As Single Public Function GetAveragePowerAtCrank(ByVal engineRpm As Integer, doorDutyCycleZeroToOne As Single) As Single
Dim ElectricalPowerDemandsWatts As Single = GetAveragePowerDemandAtAlternator(doorDutyCycleZeroToOne) * _powerNetVoltage Dim ElectricalPowerDemandsWatts As Single = GetAveragePowerDemandAtAlternator() * _powerNetVoltage
Dim alternatorsEfficiency As Single = _module0.GetEfficiency(engineRpm,doorDutyCycleZeroToOne) Dim alternatorsEfficiency As Single = _module0.GetEfficiency(engineRpm)
Dim ElectricalPowerDemandsWattsDividedByAlternatorEfficiency as Single = ElectricalPowerDemandsWatts / alternatorsEfficiency Dim ElectricalPowerDemandsWattsDividedByAlternatorEfficiency as Single = ElectricalPowerDemandsWatts / alternatorsEfficiency
Dim averagePowerDemandAtCrankFromElectricsWatts As Single Dim averagePowerDemandAtCrankFromElectricsWatts As Single
......

Namespace Electrics
Public Class M5__SmartAlternatorSetGeneration
Implements IM5_SmartAlternatorSetGeneration
Private _powerNetVoltage As Single
Private _m05 As M0_5_SmartAlternatorSetEfficiency
Private _alternatorGearEfficiency As single
Public Sub new ( m05 As M0_5_SmartAlternatorSetEfficiency, ByVal powernetVoltage As single, alternatorGearEfficiency As single)
'sanity check
If m05 is Nothing then Throw New ArgumentException("Please supply a valid module M05")
If powernetVoltage < ElectricConstants.PowenetVoltageMin orelse powernetVoltage > ElectricConstants.PowenetVoltageMax then Throw New ArgumentException("Powernet Voltage out of range")
If alternatorGearEfficiency < 0 or alternatorGearEfficiency>1 then Throw New ArgumentException("AlternatorGearEfficiency Out of bounds, should be 0 to 1")
'assign private variables.
_m05=m05
_powerNetVoltage=powernetVoltage
_alternatorGearEfficiency = alternatorGearEfficiency
End Sub
Public Function AlternatorsGenerationPowerAtCrankIdleWatts(rpm As Integer) As Single Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankIdleWatts
Return (_m05.SmartIdleCurrent() * _powerNetVoltage) / ( _m05.AlternatorsEfficiencyIdleResultCard(rpm) * _alternatorGearEfficiency)
End Function
Public Function AlternatorsGenerationPowerAtCrankOverrunWatts(rpm As Integer) As Single Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankOverrunWatts
Return (_m05.SmartOverrunCurrent() * _powerNetVoltage) / ( _m05.AlternatorsEfficiencyOverrunResultCard(rpm) * _alternatorGearEfficiency)
End Function
Public Function AlternatorsGenerationPowerAtCrankTractionOnWatts(rpm As Integer) As Single Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankTractionOnWatts
Return (_m05.SmartTractionCurrent() * _powerNetVoltage) / ( _m05.AlternatorsEfficiencyTractionOnResultCard(rpm) * _alternatorGearEfficiency)
End Function
End Class
End Namespace
...@@ -13,7 +13,7 @@ Private _results As Dictionary(Of Single, Single) ...@@ -13,7 +13,7 @@ Private _results As Dictionary(Of Single, Single)
Public Sub New(results As Dictionary(Of Single, Single)) Public Sub New(results As Dictionary(Of Single, Single))
If results Is Nothing Then Throw New ArgumentException("A dictionary of smart results must be supplied.") If results Is Nothing Then Throw New ArgumentException("A dictionary of smart results must be supplied.")
If results.Count < 2 Then Throw New ArgumentException("More than two entries are needed to interpolate results")
_results = results _results = results
End Sub End Sub
...@@ -24,6 +24,8 @@ End Sub ...@@ -24,6 +24,8 @@ End Sub
Public Function GetSmartCurrentResult(key As Single) As Single Implements IResultCard.GetSmartCurrentResult Public Function GetSmartCurrentResult(key As Single) As Single Implements IResultCard.GetSmartCurrentResult
If _results.Count<2 then Return 0.1
Return GetOrInterpolate(key) Return GetOrInterpolate(key)
......
...@@ -5,15 +5,15 @@ Namespace Hvac ...@@ -5,15 +5,15 @@ Namespace Hvac
Public Class M1_AverageHVACLoadDemand Public Class M1_AverageHVACLoadDemand
Dim map As IHVACMap Dim map As IHVACMap
Dim alternator As IAlternator
Public Property Region As Integer Public Property Region As Integer
Public Property Season As Integer Public Property Season As Integer
Public Sub New(ByVal map As IHVACMap, ByVal alternator As IAlternator, inputs As IHVACInputs) Public Sub New(ByVal map As IHVACMap, inputs As IHVACInputs)
Me.map = map Me.map = map
Me.alternator = alternator
Me.Region = inputs.Region Me.Region = inputs.Region
Me.Season = inputs.Season Me.Season = inputs.Season
...@@ -22,36 +22,30 @@ Namespace Hvac ...@@ -22,36 +22,30 @@ Namespace Hvac
End Sub End Sub
Public Function Initialise() As Boolean Public Function Initialise() As Boolean
Return alternator.Initialise() AndAlso map.Initialise()
End Function End Function
Public Function AverageMechanicalPowerDemandAtCrank() As Single Public Function AverageMechanicalPowerDemandAtCrank() As Single
Dim mechD As Single = map.GetMechanicalDemand(Region, Season)
Dim pulleyGearEfficiency As Single = alternator.PulleyGearEfficiency
Return mechD / pulleyGearEfficiency Return 0 'TODO FIX THIS.
End Function End Function
Function AverageElectricalPowerDemandAtAlternator() As Single Function AverageElectricalPowerDemandAtAlternator() As Single
Return map.GetElectricalDemand(Region, Season) Return 0 'TODO FIX THIS
End Function End Function
Function AverageElectricalPowerDemandAtCrank(engineRPM As Single) As Single Function AverageElectricalPowerDemandAtCrank(engineRPM As Single) As Single
Dim alternatorEfficiency As Single = alternator.GetEfficiency(engineRPM)
Dim hvacElectricalPowerDemand As Single = map.GetElectricalDemand(Region, Season)
Dim result As Single = (hvacElectricalPowerDemand / alternatorEfficiency) / alternator.PulleyGearEfficiency
Return result Return 0 'TODO FIX THIS
End Function End Function
......
Namespace Pneumatics Namespace Pneumatics
Public Interface IAirCompressor Public Interface IM4_AirCompressor
''' <summary> ''' <summary>
''' Ratio of Gear or Pulley used to drive the compressor ''' Ratio of Gear or Pulley used to drive the compressor
''' </summary> ''' </summary>
......
 
Namespace Pneumatics Namespace Pneumatics
Public Class AirCompressor Public Class M4_AirCompressor
Implements IAirCompressor Implements IM4_AirCompressor
Private Const MinRatio As Single = 1.25 Private Const MinRatio As Single = 1.25
Private Const MaxRatio As Single = 5.5 Private Const MaxRatio As Single = 5.5
...@@ -19,7 +19,7 @@ Namespace Pneumatics ...@@ -19,7 +19,7 @@ Namespace Pneumatics
''' <value></value> ''' <value></value>
''' <returns></returns> ''' <returns></returns>
''' <remarks></remarks> ''' <remarks></remarks>
Public Property PulleyGearRatio() As Single Implements IAirCompressor.PulleyGearRatio Public Property PulleyGearRatio() As Single Implements IM4_AirCompressor.PulleyGearRatio
Get Get
Return _pulleyGearRatio Return _pulleyGearRatio
End Get End Get
...@@ -38,7 +38,7 @@ Namespace Pneumatics ...@@ -38,7 +38,7 @@ Namespace Pneumatics
''' <value></value> ''' <value></value>
''' <returns></returns> ''' <returns></returns>
''' <remarks></remarks> ''' <remarks></remarks>
Public Property PulleyGearEfficiency() As Single Implements IAirCompressor.PulleyGearEfficiency Public Property PulleyGearEfficiency() As Single Implements IM4_AirCompressor.PulleyGearEfficiency
Get Get
Return _pulleyGearEfficiency Return _pulleyGearEfficiency
End Get End Get
...@@ -78,7 +78,7 @@ Namespace Pneumatics ...@@ -78,7 +78,7 @@ Namespace Pneumatics
''' </summary> ''' </summary>
''' <returns></returns> ''' <returns></returns>
''' <remarks></remarks> ''' <remarks></remarks>
Public Function Initialise() As Boolean Implements IAirCompressor.Initialise Public Function Initialise() As Boolean Implements IM4_AirCompressor.Initialise
Return _map.Initialise() Return _map.Initialise()
End Function End Function
...@@ -99,7 +99,7 @@ Namespace Pneumatics ...@@ -99,7 +99,7 @@ Namespace Pneumatics
''' <param name="engineRpm">Engine speed in rpm</param> ''' <param name="engineRpm">Engine speed in rpm</param>
''' <returns></returns> ''' <returns></returns>
''' <remarks></remarks> ''' <remarks></remarks>
Public Function GetFlowRate(ByVal engineRpm As Integer) As Single Implements IAirCompressor.GetFlowRate Public Function GetFlowRate(ByVal engineRpm As Integer) As Single Implements IM4_AirCompressor.GetFlowRate
Dim compressorRpm As Single = engineRpm * PulleyGearRatio Dim compressorRpm As Single = engineRpm * PulleyGearRatio
Return _map.GetFlowRate(compressorRpm) Return _map.GetFlowRate(compressorRpm)
End Function End Function
...@@ -110,7 +110,7 @@ Namespace Pneumatics ...@@ -110,7 +110,7 @@ Namespace Pneumatics
''' <param name="engineRpm">Engine speed in rpm</param> ''' <param name="engineRpm">Engine speed in rpm</param>
''' <returns></returns> ''' <returns></returns>
''' <remarks></remarks> ''' <remarks></remarks>
Public Function GetPowerCompressorOff(ByVal engineRpm As Integer) As Single Implements IAirCompressor.GetPowerCompressorOff Public Function GetPowerCompressorOff(ByVal engineRpm As Integer) As Single Implements IM4_AirCompressor.GetPowerCompressorOff
Return GetCompressorPower(engineRpm, False) Return GetCompressorPower(engineRpm, False)
End Function End Function
...@@ -120,7 +120,7 @@ Namespace Pneumatics ...@@ -120,7 +120,7 @@ Namespace Pneumatics
''' <param name="engineRpm">Engine speed in rpm</param> ''' <param name="engineRpm">Engine speed in rpm</param>
''' <returns></returns> ''' <returns></returns>
''' <remarks></remarks> ''' <remarks></remarks>
Public Function GetPowerCompressorOn(ByVal engineRpm As Integer) As Single Implements IAirCompressor.GetPowerCompressorOn Public Function GetPowerCompressorOn(ByVal engineRpm As Integer) As Single Implements IM4_AirCompressor.GetPowerCompressorOn
Return GetCompressorPower(engineRpm, True) Return GetCompressorPower(engineRpm, True)
End Function End Function
...@@ -130,7 +130,7 @@ Namespace Pneumatics ...@@ -130,7 +130,7 @@ Namespace Pneumatics
''' <param name="engineRpm">Engine speed in rpm</param> ''' <param name="engineRpm">Engine speed in rpm</param>
''' <returns></returns> ''' <returns></returns>
''' <remarks></remarks> ''' <remarks></remarks>
Public Function GetPowerDifference(ByVal engineRpm As Integer) As Single Implements IAirCompressor.GetPowerDifference Public Function GetPowerDifference(ByVal engineRpm As Integer) As Single Implements IM4_AirCompressor.GetPowerDifference
Dim powerOn As Single = GetPowerCompressorOn(engineRpm) Dim powerOn As Single = GetPowerCompressorOn(engineRpm)
Dim powerOff As Single = GetPowerCompressorOff(engineRpm) Dim powerOff As Single = GetPowerCompressorOff(engineRpm)
Return powerOn - powerOff Return powerOn - powerOff
...@@ -156,7 +156,7 @@ Namespace Pneumatics ...@@ -156,7 +156,7 @@ Namespace Pneumatics
Public Function GetAveragePowerDemandPerCompressorUnitFlowRate() As Single Implements IAirCompressor.GetAveragePowerDemandPerCompressorUnitFlowRate Public Function GetAveragePowerDemandPerCompressorUnitFlowRate() As Single Implements IM4_AirCompressor.GetAveragePowerDemandPerCompressorUnitFlowRate
Return _map.GetAveragePowerDemandPerCompressorUnitFlowRate() Return _map.GetAveragePowerDemandPerCompressorUnitFlowRate()
......
...@@ -75,22 +75,22 @@ ...@@ -75,22 +75,22 @@
<Compile Include="Electrics\AlternatorMapValues.vb" /> <Compile Include="Electrics\AlternatorMapValues.vb" />
<Compile Include="Electrics\ElectricsUserInputsConfig.vb" /> <Compile Include="Electrics\ElectricsUserInputsConfig.vb" />
<Compile Include="Electrics\IElectricsUserInputsConfig.vb" /> <Compile Include="Electrics\IElectricsUserInputsConfig.vb" />
<Compile Include="Electrics\IM5_SmartAlternatorSetGeneration.vb" />
<Compile Include="Electrics\IResultCard.vb" /> <Compile Include="Electrics\IResultCard.vb" />
<Compile Include="Electrics\M0_5_SmartAlternatorSetEfficiency.vb" /> <Compile Include="Electrics\M0_5_SmartAlternatorSetEfficiency.vb" />
<Compile Include="Electrics\M0_NonSmart_AlternatorsSetEfficiency.vb" /> <Compile Include="Electrics\M0_NonSmart_AlternatorsSetEfficiency.vb" />
<Compile Include="Electrics\ElectricalConsumerList.vb" /> <Compile Include="Electrics\ElectricalConsumerList.vb" />
<Compile Include="Electrics\ElectricConstants.vb" /> <Compile Include="Electrics\ElectricConstants.vb" />
<Compile Include="Electrics\IM0_NonSmart_AlternatorsSetEfficiency.vb" /> <Compile Include="Electrics\IM0_NonSmart_AlternatorsSetEfficiency.vb" />
<Compile Include="Electrics\M5__SmartAlternatorSetGeneration.vb" />
<Compile Include="Electrics\ResultCard.vb" /> <Compile Include="Electrics\ResultCard.vb" />
<Compile Include="Hvac\HVACInputs.vb" /> <Compile Include="Hvac\HVACInputs.vb" />
<Compile Include="Electrics\IAlternator.vb" />
<Compile Include="Electrics\IElectricalConsumerList.vb" /> <Compile Include="Electrics\IElectricalConsumerList.vb" />
<Compile Include="Hvac\IHVACInputs.vb" /> <Compile Include="Hvac\IHVACInputs.vb" />
<Compile Include="Hvac\HVACMapParameter.vb" /> <Compile Include="Hvac\HVACMapParameter.vb" />
<Compile Include="Hvac\IHVACMap.vb" /> <Compile Include="Hvac\IHVACMap.vb" />
<Compile Include="Pneumatics\ActuationsKey.vb" /> <Compile Include="Pneumatics\ActuationsKey.vb" />
<Compile Include="Pneumatics\AirCompressor.vb" /> <Compile Include="Pneumatics\M4_AirCompressor.vb" />
<Compile Include="Electrics\Alternator.vb" />
<Compile Include="Electrics\AlternatorMap.vb" /> <Compile Include="Electrics\AlternatorMap.vb" />
<Compile Include="Electrics\M2_AverageElectricalLoadDemand.vb" /> <Compile Include="Electrics\M2_AverageElectricalLoadDemand.vb" />
<Compile Include="Hvac\M1_AverageHVACLoadDemand.vb" /> <Compile Include="Hvac\M1_AverageHVACLoadDemand.vb" />
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
<Compile Include="Electrics\ElectricalConsumer.vb" /> <Compile Include="Electrics\ElectricalConsumer.vb" />
<Compile Include="Hvac\HVACMap.vb" /> <Compile Include="Hvac\HVACMap.vb" />
<Compile Include="Electrics\IAlternatorMap.vb" /> <Compile Include="Electrics\IAlternatorMap.vb" />
<Compile Include="Pneumatics\IAirCompressor.vb" /> <Compile Include="Pneumatics\IM4_AirCompressor.vb" />
<Compile Include="Pneumatics\ICompressorMap.vb" /> <Compile Include="Pneumatics\ICompressorMap.vb" />
<Compile Include="Electrics\IElectricalConsumer.vb" /> <Compile Include="Electrics\IElectricalConsumer.vb" />
<Compile Include="My Project\AssemblyInfo.vb" /> <Compile Include="My Project\AssemblyInfo.vb" />
......
...@@ -5,7 +5,7 @@ Imports VectoAuxiliariesTests.Mocks ...@@ -5,7 +5,7 @@ Imports VectoAuxiliariesTests.Mocks
Namespace UnitTests Namespace UnitTests
<TestFixture()> <TestFixture()>
Public Class AirCompressorTests Public Class M4_AirCompressorTests
#Region "Test Constants" #Region "Test Constants"
Private Const GoodEfficiency As Single = 1 Private Const GoodEfficiency As Single = 1
Private Const TooLowEfficiency As Single = 0.1 Private Const TooLowEfficiency As Single = 0.1
...@@ -27,9 +27,9 @@ Namespace UnitTests ...@@ -27,9 +27,9 @@ Namespace UnitTests
Return New CompressorMapMock(True) Return New CompressorMapMock(True)
End Function End Function
Private Function GetGoodCompressor() As AirCompressor Private Function GetGoodCompressor() As M4_AirCompressor
Dim map As ICompressorMap = GetNonFailingCompressorMapMock() Dim map As ICompressorMap = GetNonFailingCompressorMapMock()
Dim target As AirCompressor = New AirCompressor(map, GoodRatio, GoodEfficiency) Dim target As M4_AirCompressor = New M4_AirCompressor(map, GoodRatio, GoodEfficiency)
Return target Return target
End Function End Function
#End Region #End Region
...@@ -37,14 +37,14 @@ Namespace UnitTests ...@@ -37,14 +37,14 @@ Namespace UnitTests
<Test()> <Test()>
Public Sub CreateNewJustPathTest() Public Sub CreateNewJustPathTest()
Dim map As ICompressorMap = GetNonFailingCompressorMapMock() Dim map As ICompressorMap = GetNonFailingCompressorMapMock()
Dim target As AirCompressor = New AirCompressor(map) Dim target As M4_AirCompressor = New M4_AirCompressor(map)
Assert.IsNotNull(target) Assert.IsNotNull(target)
End Sub End Sub
<Test()> <Test()>
Public Sub CreateNewAllParametersTest() Public Sub CreateNewAllParametersTest()
Dim map As ICompressorMap = GetNonFailingCompressorMapMock() Dim map As ICompressorMap = GetNonFailingCompressorMapMock()
Dim target As AirCompressor = New AirCompressor(map, GoodRatio, GoodEfficiency) Dim target As M4_AirCompressor = New M4_AirCompressor(map, GoodRatio, GoodEfficiency)
Assert.IsNotNull(target) Assert.IsNotNull(target)
End Sub End Sub
...@@ -52,27 +52,27 @@ Namespace UnitTests ...@@ -52,27 +52,27 @@ Namespace UnitTests
<Test()> <Test()>
Public Sub InitialiseTest() Public Sub InitialiseTest()
Dim map As ICompressorMap = GetNonFailingCompressorMapMock() Dim map As ICompressorMap = GetNonFailingCompressorMapMock()
Dim target As AirCompressor = New AirCompressor(map) Dim target As M4_AirCompressor = New M4_AirCompressor(map)
Assert.IsTrue(target.Initialise()) Assert.IsTrue(target.Initialise())
End Sub End Sub
<Test(), ExpectedException("System.ArgumentException")> <Test(), ExpectedException("System.ArgumentException")>
Public Sub InitialiseInvalidMapTest() Public Sub InitialiseInvalidMapTest()
Dim map As ICompressorMap = GetFailingCompressorMapMock() Dim map As ICompressorMap = GetFailingCompressorMapMock()
Dim target As AirCompressor = New AirCompressor(map) Dim target As M4_AirCompressor = New M4_AirCompressor(map)
target.Initialise() target.Initialise()
End Sub End Sub
<Test()> <Test()>
Public Sub GetEfficiencyTest() Public Sub GetEfficiencyTest()
Dim comp As AirCompressor = GetGoodCompressor() Dim comp As M4_AirCompressor = GetGoodCompressor()
Dim target = comp.PulleyGearEfficiency Dim target = comp.PulleyGearEfficiency
Assert.AreEqual(target, GoodEfficiency) Assert.AreEqual(target, GoodEfficiency)
End Sub End Sub
<Test()> <Test()>
Public Sub SetEfficiencyTest() Public Sub SetEfficiencyTest()
Dim comp As AirCompressor = GetGoodCompressor() Dim comp As M4_AirCompressor = GetGoodCompressor()
Dim target As Single = 0.3 Dim target As Single = 0.3
comp.PulleyGearEfficiency = target comp.PulleyGearEfficiency = target
Dim actual As Single = comp.PulleyGearEfficiency Dim actual As Single = comp.PulleyGearEfficiency
...@@ -83,21 +83,21 @@ Namespace UnitTests ...@@ -83,21 +83,21 @@ Namespace UnitTests
<TestCase(TooHighEfficiency)> _ <TestCase(TooHighEfficiency)> _
<ExpectedException("System.ArgumentOutOfRangeException")> <ExpectedException("System.ArgumentOutOfRangeException")>
Public Sub SetEfficiencyOutOfRangeTest(ByVal efficiency As Single) Public Sub SetEfficiencyOutOfRangeTest(ByVal efficiency As Single)
Dim comp As AirCompressor = GetGoodCompressor() Dim comp As M4_AirCompressor = GetGoodCompressor()
comp.PulleyGearEfficiency = efficiency comp.PulleyGearEfficiency = efficiency
End Sub End Sub
<Test()> <Test()>
Public Sub GetRatioTest() Public Sub GetRatioTest()
Dim comp As AirCompressor = GetGoodCompressor() Dim comp As M4_AirCompressor = GetGoodCompressor()
Dim target = comp.PulleyGearRatio Dim target = comp.PulleyGearRatio
Assert.AreEqual(target, GoodRatio) Assert.AreEqual(target, GoodRatio)
End Sub End Sub
<Test()> <Test()>
Public Sub SetRatioTest() Public Sub SetRatioTest()
Dim comp As AirCompressor = GetGoodCompressor() Dim comp As M4_AirCompressor = GetGoodCompressor()
Dim target As Single = 3 Dim target As Single = 3
comp.PulleyGearRatio = target comp.PulleyGearRatio = target
Dim actual As Single = comp.PulleyGearRatio Dim actual As Single = comp.PulleyGearRatio
...@@ -108,13 +108,13 @@ Namespace UnitTests ...@@ -108,13 +108,13 @@ Namespace UnitTests
<TestCase(TooHighRatio)> _ <TestCase(TooHighRatio)> _
<ExpectedException("System.ArgumentOutOfRangeException")> <ExpectedException("System.ArgumentOutOfRangeException")>
Public Sub SetRatioOutOfRangeTest(ByVal ratio As Single) Public Sub SetRatioOutOfRangeTest(ByVal ratio As Single)
Dim comp As AirCompressor = GetGoodCompressor() Dim comp As M4_AirCompressor = GetGoodCompressor()
comp.PulleyGearRatio = ratio comp.PulleyGearRatio = ratio
End Sub End Sub
<Test()> <Test()>
Public Sub GetCompressorFlowRateTest() Public Sub GetCompressorFlowRateTest()
Dim comp As AirCompressor = GetGoodCompressor() Dim comp As M4_AirCompressor = GetGoodCompressor()
Dim expected As Single = 2.0 Dim expected As Single = 2.0
Dim actual = comp.GetFlowRate(100) Dim actual = comp.GetFlowRate(100)
Assert.AreEqual(expected, actual) Assert.AreEqual(expected, actual)
...@@ -122,7 +122,7 @@ Namespace UnitTests ...@@ -122,7 +122,7 @@ Namespace UnitTests
<Test()> <Test()>
Public Sub GetPowerCompressorOffTest() Public Sub GetPowerCompressorOffTest()
Dim comp As AirCompressor = GetGoodCompressor() Dim comp As M4_AirCompressor = GetGoodCompressor()
Dim expected As Single = 5.0 Dim expected As Single = 5.0
Dim actual = comp.GetPowerCompressorOff(100) Dim actual = comp.GetPowerCompressorOff(100)
Assert.AreEqual(expected, actual) Assert.AreEqual(expected, actual)
...@@ -131,7 +131,7 @@ Namespace UnitTests ...@@ -131,7 +131,7 @@ Namespace UnitTests
<Test()> <Test()>
Public Sub GetPowerCompressorOnTest() Public Sub GetPowerCompressorOnTest()
Dim comp As AirCompressor = GetGoodCompressor() Dim comp As M4_AirCompressor = GetGoodCompressor()
Dim expected As Single = 8.0 Dim expected As Single = 8.0
Dim actual = comp.GetPowerCompressorOn(100) Dim actual = comp.GetPowerCompressorOn(100)
Assert.AreEqual(expected, actual) Assert.AreEqual(expected, actual)
...@@ -140,7 +140,7 @@ Namespace UnitTests ...@@ -140,7 +140,7 @@ Namespace UnitTests
<Test()> <Test()>
Public Sub GetPowerDifferenceTest() Public Sub GetPowerDifferenceTest()
Dim comp As AirCompressor = GetGoodCompressor() Dim comp As M4_AirCompressor = GetGoodCompressor()
Dim expected As Single = 3.0 Dim expected As Single = 3.0
Dim actual = comp.GetPowerDifference(100) Dim actual = comp.GetPowerDifference(100)
Assert.AreEqual(expected, actual) Assert.AreEqual(expected, actual)
...@@ -150,7 +150,7 @@ Namespace UnitTests ...@@ -150,7 +150,7 @@ Namespace UnitTests
<Test> <Test>
Public Sub GetAveragePowerDemandPerCompressorUnitFlowRate() Public Sub GetAveragePowerDemandPerCompressorUnitFlowRate()
Dim comp As AirCompressor = GetGoodCompressor() Dim comp As M4_AirCompressor = GetGoodCompressor()
Dim expected As Single = 0.01 Dim expected As Single = 0.01
Dim actual As Single = comp.GetAveragePowerDemandPerCompressorUnitFlowRate Dim actual As Single = comp.GetAveragePowerDemandPerCompressorUnitFlowRate
......
...@@ -8,7 +8,7 @@ Imports VectoAuxiliaries ...@@ -8,7 +8,7 @@ Imports VectoAuxiliaries
Namespace UnitTests Namespace UnitTests
<TestFixture> <TestFixture>
Public Class AveragePneumaticLoadDemandTests Public Class M3_AveragePneumaticLoadDemandTests
...@@ -71,7 +71,7 @@ Namespace UnitTests ...@@ -71,7 +71,7 @@ Namespace UnitTests
Dim psCompressorMap = CType(New CompressorMap(_compressorMapPath), ICompressorMap) Dim psCompressorMap = CType(New CompressorMap(_compressorMapPath), ICompressorMap)
psCompressorMap.Initialise() psCompressorMap.Initialise()
Dim target As New AveragePneumaticLoadDemand(psUserInputsConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes) Dim target As New M3_AveragePneumaticLoadDemand(psUserInputsConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes)
...@@ -90,7 +90,7 @@ Namespace UnitTests ...@@ -90,7 +90,7 @@ Namespace UnitTests
psCompressorMap.Initialise() psCompressorMap.Initialise()
Dim target As New AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes) Dim target As New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes)
Dim expected As Single = 7947.684 Dim expected As Single = 7947.684
Dim actual As Single = target.TotalAirDemand() Dim actual As Single = target.TotalAirDemand()
...@@ -111,7 +111,7 @@ Namespace UnitTests ...@@ -111,7 +111,7 @@ Namespace UnitTests
psCompressorMap.Initialise() psCompressorMap.Initialise()
Dim target As New AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes) Dim target As New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes)
Dim expected As Single = 0.0319030322 Dim expected As Single = 0.0319030322
Dim actual As Single = target.GetAveragePowerDemandAtCrankFromPneumatics() Dim actual As Single = target.GetAveragePowerDemandAtCrankFromPneumatics()
...@@ -134,7 +134,7 @@ Namespace UnitTests ...@@ -134,7 +134,7 @@ Namespace UnitTests
psCompressorMap.Initialise() psCompressorMap.Initialise()
Dim target As New AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes) Dim target As New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes)
Dim expected As Single = 0.025780227 Dim expected As Single = 0.025780227
Dim actual As Single = target.GetAveragePowerDemandAtCrankFromPneumatics() Dim actual As Single = target.GetAveragePowerDemandAtCrankFromPneumatics()
...@@ -154,7 +154,7 @@ Namespace UnitTests ...@@ -154,7 +154,7 @@ Namespace UnitTests
psCompressorMap.Initialise() psCompressorMap.Initialise()
Dim target As New AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes) Dim target As New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes)
Dim expected As Single = 7947.684 Dim expected As Single = 7947.684
Dim actual As Single = target.TotalAirConsumedPerCycle() Dim actual As Single = target.TotalAirConsumedPerCycle()
...@@ -177,7 +177,7 @@ Namespace UnitTests ...@@ -177,7 +177,7 @@ Namespace UnitTests
_defaultInputConfig.SmartRegeneration = False _defaultInputConfig.SmartRegeneration = False
Dim target As New AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes) Dim target As New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes)
Dim expected As Single = 8863.295 Dim expected As Single = 8863.295
Dim actual As Single = target.TotalAirConsumedPerCycle() Dim actual As Single = target.TotalAirConsumedPerCycle()
...@@ -200,7 +200,7 @@ Namespace UnitTests ...@@ -200,7 +200,7 @@ Namespace UnitTests
_defaultInputConfig.RetarderBrake = False _defaultInputConfig.RetarderBrake = False
Dim target As New AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes) Dim target As New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes)
Dim expected As Single = 8541.45 Dim expected As Single = 8541.45
...@@ -224,7 +224,7 @@ Namespace UnitTests ...@@ -224,7 +224,7 @@ Namespace UnitTests
_defaultInputConfig.KneelingHeightMilimeters = 100 _defaultInputConfig.KneelingHeightMilimeters = 100
Dim target As New AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes) Dim target As New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes)
Dim expected As Single = 8557.52 Dim expected As Single = 8557.52
...@@ -248,7 +248,7 @@ Namespace UnitTests ...@@ -248,7 +248,7 @@ Namespace UnitTests
_defaultInputConfig.AirSuspensionControl = "mechanically" _defaultInputConfig.AirSuspensionControl = "mechanically"
Dim target As New AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes) Dim target As New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes)
Dim expected As Single = 8726.18 Dim expected As Single = 8726.18
...@@ -272,7 +272,7 @@ Namespace UnitTests ...@@ -272,7 +272,7 @@ Namespace UnitTests
_defaultInputConfig.AdBlueDosing = "electric" _defaultInputConfig.AdBlueDosing = "electric"
Dim target As New AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes) Dim target As New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes)
Dim expected As Single = 6712.46 Dim expected As Single = 6712.46
...@@ -296,7 +296,7 @@ Namespace UnitTests ...@@ -296,7 +296,7 @@ Namespace UnitTests
_defaultInputConfig.Doors = "electric" _defaultInputConfig.Doors = "electric"
Dim target As New AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes) Dim target As New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, "Urban", _cycleDurationMinutes)
Dim expected As Single = 6880.88 Dim expected As Single = 6880.88
......
...@@ -4,7 +4,7 @@ Imports VectoAuxiliaries.Electrics ...@@ -4,7 +4,7 @@ Imports VectoAuxiliaries.Electrics
<TestFixture()> <TestFixture()>
Public Class ElectricalConsumerListTests Public Class ElectricalConsumerListTests
Private TestConsumerList As ElectricalConsumerList = New ElectricalConsumerList(26.3,True) Private TestConsumerList As ElectricalConsumerList = New ElectricalConsumerList(26.3,0.096,True)
Sub New() Sub New()
...@@ -15,7 +15,7 @@ End Sub ...@@ -15,7 +15,7 @@ End Sub
<Test()> <Test()>
Public Sub CreateNewTest() Public Sub CreateNewTest()
Dim target As New ElectricalConsumerList(26.3, True) Dim target As New ElectricalConsumerList(26.3,0.096, True)
Assert.IsNotNull(target) Assert.IsNotNull(target)
...@@ -27,7 +27,7 @@ Public Sub SumAllConsumersTest() ...@@ -27,7 +27,7 @@ Public Sub SumAllConsumersTest()
TestConsumerList.Items("Controllers,Valves etc").NumberInActualVehicle=1 TestConsumerList.Items("Controllers,Valves etc").NumberInActualVehicle=1
Dim actual As Single = TestConsumerList.GetTotalAverageDemandAmps(0.096, False) Dim actual As Single = TestConsumerList.GetTotalAverageDemandAmps( False)
TestConsumerList.Items("Controllers,Valves etc").NumberInActualVehicle=1 TestConsumerList.Items("Controllers,Valves etc").NumberInActualVehicle=1
...@@ -41,7 +41,7 @@ End Sub ...@@ -41,7 +41,7 @@ End Sub
Public Sub SumNonExcludedConsumersTest() Public Sub SumNonExcludedConsumersTest()
TestConsumerList.Items("Controllers,Valves etc").NumberInActualVehicle=1 TestConsumerList.Items("Controllers,Valves etc").NumberInActualVehicle=1
Dim actual As Single = TestConsumerList.GetTotalAverageDemandAmps(0.096, True) Dim actual As Single = TestConsumerList.GetTotalAverageDemandAmps(True)
TestConsumerList.Items("Controllers,Valves etc").NumberInActualVehicle=0 TestConsumerList.Items("Controllers,Valves etc").NumberInActualVehicle=0
Dim expected = 35.63 Dim expected = 35.63
Assert.AreEqual(expected, Math.Round(actual,2)) Assert.AreEqual(expected, Math.Round(actual,2))
...@@ -53,7 +53,7 @@ End Sub ...@@ -53,7 +53,7 @@ End Sub
<ExpectedException("System.ArgumentException")> _ <ExpectedException("System.ArgumentException")> _
Public Sub DuplicateConsumersTest_ThrowsArgumentException() Public Sub DuplicateConsumersTest_ThrowsArgumentException()
Dim target As New ElectricalConsumerList(26.3) Dim target As New ElectricalConsumerList(0.096,26.3)
'Add two OnBaseVehicle consumers 'Add two OnBaseVehicle consumers
target.AddConsumer(New ElectricalConsumer(True, "TEST", "Exclude1", 10, 1, 26.3, 1)) target.AddConsumer(New ElectricalConsumer(True, "TEST", "Exclude1", 10, 1, 26.3, 1))
target.AddConsumer(New ElectricalConsumer(True, "TEST", "Exclude1", 10, 1, 26.3, 1)) target.AddConsumer(New ElectricalConsumer(True, "TEST", "Exclude1", 10, 1, 26.3, 1))
......
Imports VectoAuxiliaries.Electrics
Imports VectoAuxiliaries.Hvac
Imports NUnit.Framework
Namespace UnitTests
<TestFixture()>
Public Class M0_5_SmartAlternatorSetEfficiencyTests
Private target As M0_5_SmartAlternatorSetEfficiency
Public Sub new()
Initialise()
End Sub
Private sub Initialise()
Dim elecConsumers As New ElectricalConsumerList(26.3,0.096,True)
Dim hvacInputs As New HVACInputs(1,1)
Dim hvacMap As New HVACMap("testFiles\TestHvacMap.csv")
hvacMap.Initialise()
Dim alternatoMap As New AlternatorMap("testFiles\testAlternatormap.csv")
alternatoMap.Initialise()
Dim m0 As New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers,hvacInputs,hvacMap,alternatoMap,26.3)
'Results Cards
Dim readings = new Dictionary(Of single, single)
readings.Add(10,8)
readings.Add(70,63)
Dim idleResult As New ResultCard(readings)
Dim tractionResult As New ResultCard(readings)
Dim overrunResult As New ResultCard(readings)
target = New M0_5_SmartAlternatorSetEfficiency(m0,elecConsumers,alternatoMap,idleResult,tractionResult,overrunResult)
End Sub
<Test()> _
Public Sub CreateNewTest()
Initialise()
Assert.IsNotNull( target)
End Sub
<Test()> _
Public Sub SmartIdleCurrentTest()
Initialise()
Assert.IsNotNull( target)
End Sub
<Test()> _
Public Sub SmartTractionCurrentTest()
Initialise()
Assert.IsNotNull( target)
End Sub
<Test()> _
Public Sub SmartOverrunCurrentTest()
Initialise()
Assert.IsNotNull( target)
End Sub
<Test()> _
Public Sub AlternatorsEfficiencyIdle2000rpmTest()
Initialise()
Dim expected As Single = 0.618566155
Dim actual As Single = target.AlternatorsEfficiencyIdleResultCard(2000)
Assert.AreEqual(expected, actual)
End Sub
<Test()> _
Public Sub AlternatorsEfficiencyTraction2000rpmTest()
Initialise()
Dim expected As Single = 0.618566155
Dim actual As Single = target.AlternatorsEfficiencyTractionOnResultCard(2000)
Assert.AreEqual(expected, actual)
End Sub
<Test()> _
Public Sub AlternatorsEfficiencyOverrun2000rpmTest()
Initialise()
Dim expected As Single = 0.618566155
Dim actual As Single = target.AlternatorsEfficiencyOverrunResultCard(2000)
Assert.AreEqual(expected, actual)
End Sub
End Class
End Namespace
...@@ -27,7 +27,7 @@ Private powernetVoltage As Single = 26.3 ...@@ -27,7 +27,7 @@ Private powernetVoltage As Single = 26.3
Public Sub New() Public Sub New()
'Setup consumers and HVAC ( 1 Consumer in Test Category ) 'Setup consumers and HVAC ( 1 Consumer in Test Category )
elecConsumers = CType(New ElectricalConsumerList(26.3), IElectricalConsumerList) elecConsumers = CType(New ElectricalConsumerList(0.096,26.3), IElectricalConsumerList)
elecConsumers.AddConsumer(New ElectricalConsumer(False, "TEST", "CONSUMER1", 20, 0.5, 26.3, 1)) elecConsumers.AddConsumer(New ElectricalConsumer(False, "TEST", "CONSUMER1", 20, 0.5, 26.3, 1))
'Setup HVAC 'Setup HVAC
...@@ -81,7 +81,7 @@ End Sub ...@@ -81,7 +81,7 @@ End Sub
Public Sub EfficiencyValueTest() Public Sub EfficiencyValueTest()
Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, hvacInputs, hvacMap, alternatorMap, powernetVoltage) Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, hvacInputs, hvacMap, alternatorMap, powernetVoltage)
Dim actual As Single = target.GetEfficiency(2000, 1) Dim actual As Single = target.GetEfficiency(2000)
Dim expected As Single = 0.6375106 Dim expected As Single = 0.6375106
......
...@@ -14,8 +14,8 @@ Namespace UnitTests ...@@ -14,8 +14,8 @@ Namespace UnitTests
#Region "Helpers" #Region "Helpers"
Private Function GetAverageElectricalDemandInstance() As M2_AverageElectricalLoadDemand Private Function GetAverageElectricalDemandInstance() As M2_AverageElectricalLoadDemand
Dim alt As IAlternator = New AlternatorMock
Dim consumers As IElectricalConsumerList = CType(New ElectricalConsumerList(26.3, True), IElectricalConsumerList) Dim consumers As IElectricalConsumerList = CType(New ElectricalConsumerList(26.3,0.096, True), IElectricalConsumerList)
Dim hvacInp As IHVACInputs = CType(New HVACInputs(1, 1), IHVACInputs) Dim hvacInp As IHVACInputs = CType(New HVACInputs(1, 1), IHVACInputs)
Dim hvacmap As IHVACMap = CType(New HVACMap("testfiles\TestHvacMap.csv"), IHVACMap) Dim hvacmap As IHVACMap = CType(New HVACMap("testfiles\TestHvacMap.csv"), IHVACMap)
hvacmap.Initialise() hvacmap.Initialise()
...@@ -46,9 +46,9 @@ Namespace UnitTests ...@@ -46,9 +46,9 @@ Namespace UnitTests
Public Sub GetAveragePowerAtAlternatorTest() Public Sub GetAveragePowerAtAlternatorTest()
Dim expected As Single =35.63705 Dim expected As Single =35.634
Dim target As M2_AverageElectricalLoadDemand = GetAverageElectricalDemandInstance() Dim target As M2_AverageElectricalLoadDemand = GetAverageElectricalDemandInstance()
Dim actual As Single = target.GetAveragePowerDemandAtAlternator(csngDoorDutyCycleZeroToOne) Dim actual As Single = target.GetAveragePowerDemandAtAlternator()
Assert.AreEqual(expected,actual) Assert.AreEqual(expected,actual)
End Sub End Sub
...@@ -56,7 +56,7 @@ Namespace UnitTests ...@@ -56,7 +56,7 @@ Namespace UnitTests
<Test()> <Test()>
Public Sub GetAveragePowerAtCrankTest() Public Sub GetAveragePowerAtCrankTest()
Dim target As M2_AverageElectricalLoadDemand = GetAverageElectricalDemandInstance() Dim target As M2_AverageElectricalLoadDemand = GetAverageElectricalDemandInstance()
Dim expected As Single = 2356.33154 Dim expected As Single = 2356.12964
Dim actual As Single = target.GetAveragePowerAtCrank(2000, csngDoorDutyCycleZeroToOne) Dim actual As Single = target.GetAveragePowerAtCrank(2000, csngDoorDutyCycleZeroToOne)
Assert.AreEqual(expected, actual) Assert.AreEqual(expected, actual)
End Sub End Sub
......
...@@ -39,15 +39,8 @@ Public Sub CreateNewBanResultsNullTest() ...@@ -39,15 +39,8 @@ Public Sub CreateNewBanResultsNullTest()
End Sub End Sub
<Test()>
<ExpectedException("System.ArgumentException")>
Public Sub CreateNewBanResultsInsufficientEntriesTest()
Dim target As New ResultCard(New Dictionary(Of Single, Single))
End Sub
<Test()> <Test()>
Public Sub GetBotomBoundryValueTest() Public Sub GetBotomBoundryValueTest()
...@@ -111,6 +104,18 @@ Assert.AreEqual(expected, actual) ...@@ -111,6 +104,18 @@ Assert.AreEqual(expected, actual)
End Sub End Sub
<Test()>
Public Sub EmptyOrInsufficientResultsTest()
Dim resultSet As New Dictionary(of single , Single )
Dim expected As Single = 0.1
Dim actual As Single = (New ResultCard(resultSet)).GetSmartCurrentResult(10)
Assert.AreEqual(expected, actual)
End Sub
End Class End Class
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment