Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 006664b8 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

refactor: use new IFuelMap Interface

parent af031df2
No related branches found
No related tags found
No related merge requests found
......@@ -10,41 +10,43 @@
' See the LICENSE.txt for the specific language governing permissions and limitations.
Public Interface IVectoInputs
''' <summary>
''' Vehicle Mass (KG)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Property VehicleWeightKG As Single
''' <summary>
''' Vehicle Mass (KG)
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Property VehicleWeightKG As Single
''' <summary>
''' Cycle ( Urban, Interurban etc )
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Property Cycle As String
''' <summary>
''' PowerNet Voltage (V) Volts available on the bus by Batteries
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Property PowerNetVoltage As Single
''' <summary>
''' Fuel Map Used in Vecto.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Property FuelMap As String
''' <summary>
''' Fuel density used in Vecto.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Property FuelDensity As String
''' <summary>
''' Cycle ( Urban, Interurban etc )
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Property Cycle As String
''' <summary>
''' PowerNet Voltage (V) Volts available on the bus by Batteries
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Property PowerNetVoltage As Single
''' <summary>
''' Fuel Map Used in Vecto.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Property FuelMap As IFuelConsumptionMap
''' <summary>
''' Fuel density used in Vecto.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Property FuelDensity As Double
End Interface
This diff is collapsed.
......@@ -14,225 +14,229 @@ Imports VectoAuxiliaries.Pneumatics
Imports VectoAuxiliaries.Hvac
Namespace DownstreamModules
Public Class M11
Implements IM11
Public Class M11
Implements IM11
Private Const RPM_to_RadiansPerSecond As Single = 9.55
Private Const RPM_to_RadiansPerSecond As Single = 9.55
#Region "Private Aggregates"
'Private Aggregations
Private AG1 As Single
Private AG2 As Single
Private AG3 As Single
Private AG4 As Single
Private AG5 As Single
Private AG6 As Single
Private AG7 As Single
'Private Aggregations
Private AG1 As Single
Private AG2 As Single
Private AG3 As Single
Private AG4 As Single
Private AG5 As Single
Private AG6 As Single
Private AG7 As Single
#End Region
#Region "Private Fields Assigned by Constructor."
Private M1 As IM1_AverageHVACLoadDemand
Private M3 As IM3_AveragePneumaticLoadDemand
Private M6 As IM6
Private M8 As IM8
Private fmap As IFUELMAP
Private signals As ISignals
Private M1 As IM1_AverageHVACLoadDemand
Private M3 As IM3_AveragePneumaticLoadDemand
Private M6 As IM6
Private M8 As IM8
Private fmap As IFuelConsumptionMap
Private signals As ISignals
#End Region
'Staging Calculations
Private Function Sum0(ByVal rpm As Single) As Single
If rpm < 1 Then rpm = 1
Return rpm / RPM_to_RadiansPerSecond
End Function
Private ReadOnly Property Sum1 As Single
Get
Return m6.OverrunFlag * m8.SmartElectricalAlternatorPowerGenAtCrank
End Get
End Property
Private ReadOnly Property Sum2 As Single
Get
Return m3.GetAveragePowerDemandAtCrankFromPneumatics + m1.AveragePowerDemandAtCrankFromHVACMechanicalsWatts
End Get
End Property
Private ReadOnly Property Sum3 As Single
Get
Return m8.SmartElectricalAlternatorPowerGenAtCrank / Sum0(signals.EngineSpeed)
End Get
End Property
Private ReadOnly Property Sum4 As Single
Get
Return Sum2 / Sum0(signals.EngineSpeed)
End Get
End Property
Private ReadOnly Property Sum5 As Single
Get
Return Sum4 + Sum9
End Get
End Property
Private ReadOnly Property Sum6 As Single
Get
Return Sum3 + Sum5
End Get
End Property
Private ReadOnly Property Sum7 As Single
Get
'SCM 3_02
Dim intrp1 As Single = fmap.fFCdelaunay_Intp(signals.EngineSpeed, sum6)
intrp1 = If(Not Single.IsNaN(intrp1) AndAlso intrp1 > 0, intrp1, 0)
Return intrp1
End Get
End Property
Private ReadOnly Property Sum8 As Single
Get
'SCHM 3_2
Dim intrp2 As Single = fmap.fFCdelaunay_Intp(signals.EngineSpeed, sum5)
intrp2 = If(Not Single.IsNaN(intrp2) AndAlso intrp2 > 0, intrp2, 0)
Return intrp2
End Get
End Property
Private ReadOnly Property Sum9 As Single
Get
Return signals.EngineDrivelineTorque + ((signals.PreExistingAuxPower * 1000) / Sum0(signals.EngineSpeed))
End Get
End Property
Private ReadOnly Property Sum10 As Single
Get
Return M6.AvgPowerDemandAtCrankFromElectricsIncHVAC \ Sum0(signals.EngineSpeed)
End Get
End Property
Private ReadOnly Property Sum11 As Single
Get
Return Sum5 + Sum10
End Get
End Property
Private ReadOnly Property Sum12 As Single
Get
'SCHM 3_2
Dim intrp3 As Single = fmap.fFCdelaunay_Intp(signals.EngineSpeed, Sum11)
intrp3 = If(Not Single.IsNaN(intrp3) AndAlso intrp3 > 0, intrp3, 0)
Return intrp3
End Get
End Property
'OUT1
Public ReadOnly Property SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly As Single Implements IM11.SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly
Get
Return AG1
End Get
End Property
'OUT2
Public ReadOnly Property SmartElectricalTotalCycleEletricalEnergyGenerated As Single Implements IM11.SmartElectricalTotalCycleEletricalEnergyGenerated
Get
Return AG2
End Get
End Property
'OUT3
Public ReadOnly Property TotalCycleElectricalDemand As Single Implements IM11.TotalCycleElectricalDemand
Get
Return AG3
End Get
End Property
'OUT4
Public ReadOnly Property TotalCycleFuelConsumptionSmartElectricalLoad As Single Implements IM11.TotalCycleFuelConsumptionSmartElectricalLoad
Get
Return AG4
End Get
End Property
'OUT5
Public ReadOnly Property TotalCycleFuelConsumptionZeroElectricalLoad As Single Implements IM11.TotalCycleFuelConsumptionZeroElectricalLoad
Get
Return AG5
End Get
End Property
'OUT6
Public ReadOnly Property StopStartSensitiveTotalCycleElectricalDemand As Single Implements IM11.StopStartSensitiveTotalCycleElectricalDemand
Get
Return AG6
End Get
End Property
'OUT7
Public ReadOnly Property TotalCycleFuelConsuptionAverageLoads As Single Implements IM11.TotalCycleFuelConsuptionAverageLoads
Get
Return AG7
End Get
End Property
Private ReadOnly Property SW1 As Single
Get
Return If(signals.EngineStopped, 0, 1)
End Get
End Property
'Clear at the beginning of cycle
Sub ClearAggregates() Implements IM11.ClearAggregates
AG1 = 0
AG2 = 0
AG3 = 0
AG4 = 0
AG5 = 0
AG6 = 0
AG7 = 0
End Sub
'Add to Aggregates dependent on cycle step time.
Sub CycleStep(Optional stepTimeInSeconds As Single = 0.0) Implements IM11.CycleStep
'S/S Insensitive
AG3 += (stepTimeInSeconds * m6.AvgPowerDemandAtCrankFromElectricsIncHVAC)
If Signals.EngineStopped Then Return
'S/S Sensitive
AG1 += (stepTimeInSeconds * sum1 * SW1)
AG2 += (stepTimeInSeconds * M8.SmartElectricalAlternatorPowerGenAtCrank * SW1)
AG6 += (stepTimeInSeconds * m6.AvgPowerDemandAtCrankFromElectricsIncHVAC * SW1)
'These need to be divided by 3600 as the Fuel Map output is in Grams/Second.
AG4 += (stepTimeInSeconds * sum7 / 3600 * SW1)
AG5 += (stepTimeInSeconds * Sum8 / 3600 * SW1)
AG7 += (stepTimeInSeconds * Sum12 / 3600 * SW1)
End Sub
'Constructor
Public Sub New(m1 As IM1_AverageHVACLoadDemand, m3 As IM3_AveragePneumaticLoadDemand, m6 As IM6, m8 As IM8, fmap As IFUELMAP, signals As ISignals)
Me.M1 = m1
Me.M3 = m3
Me.M6 = m6
Me.M8 = m8
Me.fmap = fmap
Me.signals = signals
End Sub
End Class
'Staging Calculations
Private Function Sum0(ByVal rpm As Single) As Single
If rpm < 1 Then rpm = 1
Return rpm / RPM_to_RadiansPerSecond
End Function
Private ReadOnly Property Sum1 As Single
Get
Return m6.OverrunFlag * m8.SmartElectricalAlternatorPowerGenAtCrank
End Get
End Property
Private ReadOnly Property Sum2 As Single
Get
Return m3.GetAveragePowerDemandAtCrankFromPneumatics + m1.AveragePowerDemandAtCrankFromHVACMechanicalsWatts
End Get
End Property
Private ReadOnly Property Sum3 As Single
Get
Return m8.SmartElectricalAlternatorPowerGenAtCrank / Sum0(signals.EngineSpeed)
End Get
End Property
Private ReadOnly Property Sum4 As Single
Get
Return Sum2 / Sum0(signals.EngineSpeed)
End Get
End Property
Private ReadOnly Property Sum5 As Single
Get
Return Sum4 + Sum9
End Get
End Property
Private ReadOnly Property Sum6 As Single
Get
Return Sum3 + Sum5
End Get
End Property
Private ReadOnly Property Sum7 As Single
Get
'SCM 3_02
Dim intrp1 As Single = fmap.GetFuelConsumption(sum6, signals.EngineSpeed)
intrp1 = If(Not Single.IsNaN(intrp1) AndAlso intrp1 > 0, intrp1, 0)
Return intrp1
End Get
End Property
Private ReadOnly Property Sum8 As Single
Get
'SCHM 3_2
Dim intrp2 As Single = fmap.GetFuelConsumption(Sum5, signals.EngineSpeed)
intrp2 = If(Not Single.IsNaN(intrp2) AndAlso intrp2 > 0, intrp2, 0)
Return intrp2
End Get
End Property
Private ReadOnly Property Sum9 As Single
Get
Return signals.EngineDrivelineTorque + ((signals.PreExistingAuxPower * 1000) / Sum0(signals.EngineSpeed))
End Get
End Property
Private ReadOnly Property Sum10 As Single
Get
Return M6.AvgPowerDemandAtCrankFromElectricsIncHVAC \ Sum0(signals.EngineSpeed)
End Get
End Property
Private ReadOnly Property Sum11 As Single
Get
Return Sum5 + Sum10
End Get
End Property
Private ReadOnly Property Sum12 As Single
Get
'SCHM 3_2
Dim intrp3 As Single = fmap.GetFuelConsumption(Sum11, signals.EngineSpeed)
intrp3 = If(Not Single.IsNaN(intrp3) AndAlso intrp3 > 0, intrp3, 0)
Return intrp3
End Get
End Property
'OUT1
Public ReadOnly Property SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly As Single _
Implements IM11.SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly
Get
Return AG1
End Get
End Property
'OUT2
Public ReadOnly Property SmartElectricalTotalCycleEletricalEnergyGenerated As Single _
Implements IM11.SmartElectricalTotalCycleEletricalEnergyGenerated
Get
Return AG2
End Get
End Property
'OUT3
Public ReadOnly Property TotalCycleElectricalDemand As Single Implements IM11.TotalCycleElectricalDemand
Get
Return AG3
End Get
End Property
'OUT4
Public ReadOnly Property TotalCycleFuelConsumptionSmartElectricalLoad As Single _
Implements IM11.TotalCycleFuelConsumptionSmartElectricalLoad
Get
Return AG4
End Get
End Property
'OUT5
Public ReadOnly Property TotalCycleFuelConsumptionZeroElectricalLoad As Single _
Implements IM11.TotalCycleFuelConsumptionZeroElectricalLoad
Get
Return AG5
End Get
End Property
'OUT6
Public ReadOnly Property StopStartSensitiveTotalCycleElectricalDemand As Single _
Implements IM11.StopStartSensitiveTotalCycleElectricalDemand
Get
Return AG6
End Get
End Property
'OUT7
Public ReadOnly Property TotalCycleFuelConsuptionAverageLoads As Single _
Implements IM11.TotalCycleFuelConsuptionAverageLoads
Get
Return AG7
End Get
End Property
Private ReadOnly Property SW1 As Single
Get
Return If(signals.EngineStopped, 0, 1)
End Get
End Property
'Clear at the beginning of cycle
Sub ClearAggregates() Implements IM11.ClearAggregates
AG1 = 0
AG2 = 0
AG3 = 0
AG4 = 0
AG5 = 0
AG6 = 0
AG7 = 0
End Sub
'Add to Aggregates dependent on cycle step time.
Sub CycleStep(Optional stepTimeInSeconds As Single = 0.0) Implements IM11.CycleStep
'S/S Insensitive
AG3 += (stepTimeInSeconds * m6.AvgPowerDemandAtCrankFromElectricsIncHVAC)
If Signals.EngineStopped Then Return
'S/S Sensitive
AG1 += (stepTimeInSeconds * sum1 * SW1)
AG2 += (stepTimeInSeconds * M8.SmartElectricalAlternatorPowerGenAtCrank * SW1)
AG6 += (stepTimeInSeconds * m6.AvgPowerDemandAtCrankFromElectricsIncHVAC * SW1)
'These need to be divided by 3600 as the Fuel Map output is in Grams/Second.
AG4 += (stepTimeInSeconds * sum7 / 3600 * SW1)
AG5 += (stepTimeInSeconds * Sum8 / 3600 * SW1)
AG7 += (stepTimeInSeconds * Sum12 / 3600 * SW1)
End Sub
'Constructor
Public Sub New(m1 As IM1_AverageHVACLoadDemand, m3 As IM3_AveragePneumaticLoadDemand, m6 As IM6, m8 As IM8,
fmap As IFuelConsumptionMap, signals As ISignals)
Me.M1 = m1
Me.M3 = m3
Me.M6 = m6
Me.M8 = m8
Me.fmap = fmap
Me.signals = signals
End Sub
End Class
End Namespace
......@@ -14,205 +14,218 @@ Imports VectoAuxiliaries.Pneumatics
Imports VectoAuxiliaries.Hvac
Namespace DownstreamModules
Public Class M9
Implements IM9
Private Const RPM_TO_RADS_PER_SECOND As Single = 9.55F
Public Class M9
Implements IM9
Private Const RPM_TO_RADS_PER_SECOND As Single = 9.55F
#Region "Aggregates"
'AG1
Private _LitresOfAirCompressorOnContinuallyAggregate As Single
'AG2
Private _LitresOfAirCompressorOnOnlyInOverrunAggregate As Single
'AG3
Private _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate As Single
'AG4
Private _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate As Single
'AG1
Private _LitresOfAirCompressorOnContinuallyAggregate As Single
'AG2
Private _LitresOfAirCompressorOnOnlyInOverrunAggregate As Single
'AG3
Private _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate As Single
'AG4
Private _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate As Single
#End Region
#Region "Constructor Requirements"
Private M1 As IM1_AverageHVACLoadDemand
Private M4 As IM4_AirCompressor
Private M6 As IM6
Private M8 As IM8
Private FMAP As IFUELMAP
Private PSAC As IPneumaticsAuxilliariesConfig
Private Signals As ISignals
Private M1 As IM1_AverageHVACLoadDemand
Private M4 As IM4_AirCompressor
Private M6 As IM6
Private M8 As IM8
Private FMAP As IFuelConsumptionMap
Private PSAC As IPneumaticsAuxilliariesConfig
Private Signals As ISignals
#End Region
#Region "Class Outputs"
'OUT 1
Public ReadOnly Property LitresOfAirCompressorOnContinually As Single Implements IM9.LitresOfAirCompressorOnContinually
Get
Return _LitresOfAirCompressorOnContinuallyAggregate
End Get
End Property
'OUT 2
Public ReadOnly Property LitresOfAirCompressorOnOnlyInOverrun As Single Implements IM9.LitresOfAirCompressorOnOnlyInOverrun
Get
Return _LitresOfAirCompressorOnOnlyInOverrunAggregate
End Get
End Property
'OUT 3
Public ReadOnly Property TotalCycleFuelConsumptionCompressorOffContinuously As Single Implements IM9.TotalCycleFuelConsumptionCompressorOffContinuously
Get
Return _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate
End Get
End Property
'OUT 4
Public ReadOnly Property TotalCycleFuelConsumptionCompressorOnContinuously As Single Implements IM9.TotalCycleFuelConsumptionCompressorOnContinuously
Get
Return _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate
End Get
End Property
'OUT 1
Public ReadOnly Property LitresOfAirCompressorOnContinually As Single _
Implements IM9.LitresOfAirCompressorOnContinually
Get
Return _LitresOfAirCompressorOnContinuallyAggregate
End Get
End Property
'OUT 2
Public ReadOnly Property LitresOfAirCompressorOnOnlyInOverrun As Single _
Implements IM9.LitresOfAirCompressorOnOnlyInOverrun
Get
Return _LitresOfAirCompressorOnOnlyInOverrunAggregate
End Get
End Property
'OUT 3
Public ReadOnly Property TotalCycleFuelConsumptionCompressorOffContinuously As Single _
Implements IM9.TotalCycleFuelConsumptionCompressorOffContinuously
Get
Return _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate
End Get
End Property
'OUT 4
Public ReadOnly Property TotalCycleFuelConsumptionCompressorOnContinuously As Single _
Implements IM9.TotalCycleFuelConsumptionCompressorOnContinuously
Get
Return _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate
End Get
End Property
#End Region
'Staging Calculations
Private Function S0(ByVal rpm As Single) As Single
If rpm < 1 Then rpm = 1
Return rpm / RPM_TO_RADS_PER_SECOND
End Function
Private ReadOnly Property S1 As Single
Get
Return M6.AvgPowerDemandAtCrankFromElectricsIncHVAC + M1.AveragePowerDemandAtCrankFromHVACMechanicalsWatts
End Get
End Property
Private ReadOnly Property S2 As Single
Get
If S0(Signals.EngineSpeed) = 0 Then Throw New DivideByZeroException("Engine speed is zero and cannot be used as a divisor.")
Return M4.GetPowerCompressorOn / S0(Signals.EngineSpeed)
End Get
End Property
Private ReadOnly Property S3 As Single
Get
If S0(Signals.EngineSpeed) = 0 Then Throw New DivideByZeroException("Engine speed is zero and cannot be used as a divisor.")
Return M4.GetPowerCompressorOff / S0(Signals.EngineSpeed)
End Get
End Property
Private ReadOnly Property S4 As Single
Get
If S0(Signals.EngineSpeed) = 0 Then Throw New DivideByZeroException("Engine speed is zero and cannot be used as a divisor.")
Return S1 / S0(Signals.EngineSpeed)
End Get
End Property
Private ReadOnly Property S5 As Single
Get
Return S2 + S14
End Get
End Property
Private ReadOnly Property S6 As Single
Get
Return S14 + S3
End Get
End Property
Private ReadOnly Property S7 As Single
Get
Return S4 + S5
End Get
End Property
Private ReadOnly Property S8 As Single
Get
Return S4 + S6
End Get
End Property
Private ReadOnly Property S9 As Single
Get
Return M4.GetFlowRate * M6.OverrunFlag * M8.CompressorFlag
End Get
End Property
Private ReadOnly Property S10 As Single
Get
Return S13 * PSAC.OverrunUtilisationForCompressionFraction
End Get
End Property
Private ReadOnly Property S11 As Single
Get
'SCHM 3_02
Dim int1 As Single = FMAP.fFCdelaunay_Intp(Signals.EngineSpeed, s7)
int1 = If(int1 > 0 AndAlso Not Single.IsNaN(int1), int1, 0)
Return int1 / 3600
End Get
End Property
Private ReadOnly Property S12 As Single
Get
'SCHM 3_02
Dim int2 As Single = FMAP.fFCdelaunay_Intp(Signals.EngineSpeed, s8)
int2 = If(int2 > 0 AndAlso Not Single.IsNaN(int2), int2, 0)
Return int2 / 3600
End Get
End Property
Private ReadOnly Property S13 As Single
Get
Return (Signals.ClutchEngaged * Not (Signals.InNeutral)) * S9
End Get
End Property
Private ReadOnly Property S14 As Single
Get
Return Signals.EngineDrivelineTorque + ((Signals.PreExistingAuxPower * 1000) / S0(Signals.EngineSpeed))
End Get
End Property
Private ReadOnly Property SW1 As Integer
Get
Return If(Signals.EngineStopped, 0, 1)
End Get
End Property
'Utility Methods
Public Sub ClearAggregates() Implements IM9.ClearAggregates
_LitresOfAirCompressorOnContinuallyAggregate = 0
_LitresOfAirCompressorOnOnlyInOverrunAggregate = 0
_TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate = 0
_TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate = 0
End Sub
Public Sub CycleStep(Optional stepTimeInSeconds As Single = 0.0) Implements IM9.CycleStep
If Signals.EngineStopped Then Return
_LitresOfAirCompressorOnContinuallyAggregate += stepTimeInSeconds * M4.GetFlowRate * sw1
_LitresOfAirCompressorOnOnlyInOverrunAggregate += stepTimeInSeconds * s10 * sw1
_TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate += stepTimeInSeconds * s11 * sw1
_TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate += stepTimeInSeconds * s12 * sw1
End Sub
'Constructor
Public Sub New(m1 As IM1_AverageHVACLoadDemand, m4 As IM4_AirCompressor, m6 As IM6, m8 As IM8, fmap As IFUELMAP, psac As IPneumaticsAuxilliariesConfig, signals As ISignals)
Me.M1 = m1
Me.M4 = m4
Me.M6 = m6
Me.M8 = m8
Me.FMAP = fmap
Me.PSAC = psac
Me.Signals = signals
End Sub
'Auxiliary Event
Public Event AuxiliaryEvent(ByRef sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) Implements IAuxiliaryEvent.AuxiliaryEvent
End Class
'Staging Calculations
Private Function S0(ByVal rpm As Single) As Single
If rpm < 1 Then rpm = 1
Return rpm / RPM_TO_RADS_PER_SECOND
End Function
Private ReadOnly Property S1 As Single
Get
Return M6.AvgPowerDemandAtCrankFromElectricsIncHVAC + M1.AveragePowerDemandAtCrankFromHVACMechanicalsWatts
End Get
End Property
Private ReadOnly Property S2 As Single
Get
If S0(Signals.EngineSpeed) = 0 Then _
Throw New DivideByZeroException("Engine speed is zero and cannot be used as a divisor.")
Return M4.GetPowerCompressorOn / S0(Signals.EngineSpeed)
End Get
End Property
Private ReadOnly Property S3 As Single
Get
If S0(Signals.EngineSpeed) = 0 Then _
Throw New DivideByZeroException("Engine speed is zero and cannot be used as a divisor.")
Return M4.GetPowerCompressorOff / S0(Signals.EngineSpeed)
End Get
End Property
Private ReadOnly Property S4 As Single
Get
If S0(Signals.EngineSpeed) = 0 Then _
Throw New DivideByZeroException("Engine speed is zero and cannot be used as a divisor.")
Return S1 / S0(Signals.EngineSpeed)
End Get
End Property
Private ReadOnly Property S5 As Single
Get
Return S2 + S14
End Get
End Property
Private ReadOnly Property S6 As Single
Get
Return S14 + S3
End Get
End Property
Private ReadOnly Property S7 As Single
Get
Return S4 + S5
End Get
End Property
Private ReadOnly Property S8 As Single
Get
Return S4 + S6
End Get
End Property
Private ReadOnly Property S9 As Single
Get
Return M4.GetFlowRate * M6.OverrunFlag * M8.CompressorFlag
End Get
End Property
Private ReadOnly Property S10 As Single
Get
Return S13 * PSAC.OverrunUtilisationForCompressionFraction
End Get
End Property
Private ReadOnly Property S11 As Single
Get
'SCHM 3_02
Dim int1 As Single = FMAP.GetFuelConsumption(S7, Signals.EngineSpeed)
int1 = If(int1 > 0 AndAlso Not Single.IsNaN(int1), int1, 0)
Return int1 / 3600
End Get
End Property
Private ReadOnly Property S12 As Single
Get
'SCHM 3_02
Dim int2 As Single = FMAP.GetFuelConsumption(S8, Signals.EngineSpeed)
int2 = If(int2 > 0 AndAlso Not Single.IsNaN(int2), int2, 0)
Return int2 / 3600
End Get
End Property
Private ReadOnly Property S13 As Single
Get
Return (Signals.ClutchEngaged *
Not (Signals.InNeutral)) * S9
End Get
End Property
Private ReadOnly Property S14 As Single
Get
Return Signals.EngineDrivelineTorque + ((Signals.PreExistingAuxPower * 1000) / S0(Signals.EngineSpeed))
End Get
End Property
Private ReadOnly Property SW1 As Integer
Get
Return If(Signals.EngineStopped, 0, 1)
End Get
End Property
'Utility Methods
Public Sub ClearAggregates() Implements IM9.ClearAggregates
_LitresOfAirCompressorOnContinuallyAggregate = 0
_LitresOfAirCompressorOnOnlyInOverrunAggregate = 0
_TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate = 0
_TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate = 0
End Sub
Public Sub CycleStep(Optional stepTimeInSeconds As Single = 0.0) Implements IM9.CycleStep
If Signals.EngineStopped Then Return
_LitresOfAirCompressorOnContinuallyAggregate += stepTimeInSeconds * M4.GetFlowRate * SW1
_LitresOfAirCompressorOnOnlyInOverrunAggregate += stepTimeInSeconds * S10 * SW1
_TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate += stepTimeInSeconds * S11 * SW1
_TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate += stepTimeInSeconds * S12 * SW1
End Sub
'Constructor
Public Sub New(m1 As IM1_AverageHVACLoadDemand, m4 As IM4_AirCompressor, m6 As IM6, m8 As IM8,
fmap As IFuelConsumptionMap, psac As IPneumaticsAuxilliariesConfig, signals As ISignals)
Me.M1 = m1
Me.M4 = m4
Me.M6 = m6
Me.M8 = m8
Me.FMAP = fmap
Me.PSAC = psac
Me.Signals = signals
End Sub
'Auxiliary Event
Public Event AuxiliaryEvent(ByRef sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) _
Implements IAuxiliaryEvent.AuxiliaryEvent
End Class
End Namespace
......@@ -11,188 +11,181 @@
Imports System.Collections.Generic
Public Class cMAP
Implements IFUELMAP
Implements IFuelConsumptionMap
Private LnU As List(Of Single)
Private LTq As List(Of Single)
Private lFC As List(Of Single)
Private LnU As List(Of Single)
Private LTq As List(Of Single)
Private lFC As List(Of Single)
Private sFilePath As String
Private iMapDim As Integer
Private sFilePath As String
Private iMapDim As Integer
Private FuelMap As cDelaunayMap
Private FuelMap As cDelaunayMap
Private Sub ResetMe()
lFC = Nothing
LTq = Nothing
LnU = Nothing
iMapDim = -1
FuelMap = New cDelaunayMap
End Sub
Private Sub ResetMe()
lFC = Nothing
LTq = Nothing
LnU = Nothing
iMapDim = -1
FuelMap = New cDelaunayMap
End Sub
Public Function ReadFile(Optional ByVal ShowMsg As Boolean = True) As Boolean Implements IFUELMAP.ReadFile
Dim file As cFile_V3
Dim line As String()
Dim nU As Double
Dim MsgSrc As String
Public Function ReadFile(Optional ByVal ShowMsg As Boolean = True) As Boolean
Dim file As cFile_V3
Dim line As String()
Dim nU As Double
Dim MsgSrc As String
MsgSrc = "Main/ReadInp/MAP"
MsgSrc = "Main/ReadInp/MAP"
'Reset
ResetMe()
'Reset
ResetMe()
'Stop if there's no file
If sFilePath = "" OrElse Not IO.File.Exists(sFilePath) Then
'If ShowMsg Then WorkerMsg(tMsgID.Err, "Map file not found! (" & sFilePath & ")", MsgSrc)
Return False
End If
'Stop if there's no file
If sFilePath = "" OrElse Not IO.File.Exists(sFilePath) Then
'If ShowMsg Then WorkerMsg(tMsgID.Err, "Map file not found! (" & sFilePath & ")", MsgSrc)
Return False
End If
'Open file
file = New cFile_V3
If Not file.OpenRead(sFilePath) Then
file = Nothing
'TODO:WORKERMESSAGE If ShowMsg Then WorkerMsg(tMsgID.Err, "Failed to open file (" & sFilePath & ") !", MsgSrc)
Return False
End If
'Open file
file = New cFile_V3
If Not file.OpenRead(sFilePath) Then
file = Nothing
'TODO:WORKERMESSAGE If ShowMsg Then WorkerMsg(tMsgID.Err, "Failed to open file (" & sFilePath & ") !", MsgSrc)
Return False
End If
'Skip Header
file.ReadLine()
'Skip Header
file.ReadLine()
'Initi Lists (before version check so ReadOldFormat works)
lFC = New System.Collections.Generic.List(Of Single)
LTq = New System.Collections.Generic.List(Of Single)
LnU = New System.Collections.Generic.List(Of Single)
'Initi Lists (before version check so ReadOldFormat works)
lFC = New System.Collections.Generic.List(Of Single)
LTq = New System.Collections.Generic.List(Of Single)
LnU = New System.Collections.Generic.List(Of Single)
Try
Do While Not file.EndOfFile
Try
Do While Not file.EndOfFile
'Line read
line = file.ReadLine
'Line read
line = file.ReadLine
'Line counter up (was reset in ResetMe)
iMapDim += 1
'Line counter up (was reset in ResetMe)
iMapDim += 1
'Revolutions
nU = CDbl(line(0))
'Revolutions
nU = CDbl(line(0))
LnU.Add(nU)
LnU.Add(nU)
'Power
LTq.Add(line(1))
'Power
LTq.Add(line(1))
'FC
'Check sign
If CSng(line(2)) < 0 Then
file.Close()
'TODO:WORKERMESSAGEIf ShowMsg Then WorkerMsg(tMsgID.Err, "FC < 0 in map at " & nU & " [1/min], " & line(1) & " [Nm]", MsgSrc)
Return False
End If
'FC
'Check sign
If CSng(line(2)) < 0 Then
file.Close()
'TODO:WORKERMESSAGEIf ShowMsg Then WorkerMsg(tMsgID.Err, "FC < 0 in map at " & nU & " [1/min], " & line(1) & " [Nm]", MsgSrc)
Return False
End If
lFC.Add(CSng(line(2)))
lFC.Add(CSng(line(2)))
Loop
Catch ex As Exception
Loop
Catch ex As Exception
'TODO:WORKERMESSAGE If ShowMsg Then WorkerMsg(tMsgID.Err, "Error during file read! Line number " & iMapDim + 1 & " (" & sFilePath & ")", MsgSrc, sFilePath)
GoTo lbEr
'TODO:WORKERMESSAGE If ShowMsg Then WorkerMsg(tMsgID.Err, "Error during file read! Line number " & iMapDim + 1 & " (" & sFilePath & ")", MsgSrc, sFilePath)
GoTo lbEr
End Try
End Try
'Close file
file.Close()
'Close file
file.Close()
file = Nothing
file = Nothing
Return True
Return True
'ERROR-label for clean Abort
'ERROR-label for clean Abort
lbEr:
file.Close()
file = Nothing
file.Close()
file = Nothing
Return False
Return False
End Function
End Function
Public Function Triangulate() As Boolean
Dim i As Integer
Public Function Triangulate() As Boolean Implements IFUELMAP.Triangulate
Dim i As Integer
Dim MsgSrc As String
Dim MsgSrc As String
MsgSrc = "MAP/Norm"
MsgSrc = "MAP/Norm"
'FC Delauney
For i = 0 To iMapDim
FuelMap.AddPoints(LnU(i), LTq(i), lFC(i))
Next
'FC Delauney
For i = 0 To iMapDim
FuelMap.AddPoints(LnU(i), LTq(i), lFC(i))
Next
Return FuelMap.Triangulate()
End Function
Return FuelMap.Triangulate()
End Function
Public Function fFCdelaunay_Intp(ByVal nU As Single, ByVal Tq As Single) As Single
Dim val As Single
val = FuelMap.Intpol(nU, Tq)
Public Function fFCdelaunay_Intp(ByVal nU As Single, ByVal Tq As Single) As Single Implements IFUELMAP.fFCdelaunay_Intp
Dim val As Single
val = FuelMap.Intpol(nU, Tq)
If FuelMap.ExtrapolError Then
'TODO:WORKERMESSAGE WorkerMsg(tMsgID.Err, "Cannot extrapolate FC map! n= " & nU.ToString("0.0") & " [1/min], Me= " & Tq.ToString("0.0") & " [Nm]", "MAP/FC_Intp")
Return -10000
Else
Return val
End If
End Function
If FuelMap.ExtrapolError Then
'TODO:WORKERMESSAGE WorkerMsg(tMsgID.Err, "Cannot extrapolate FC map! n= " & nU.ToString("0.0") & " [1/min], Me= " & Tq.ToString("0.0") & " [Nm]", "MAP/FC_Intp")
Return -10000
Else
Return val
End If
End Function
#Region "Properties"
Public Property FilePath() As String Implements IFUELMAP.FilePath
Get
Return sFilePath
End Get
Set(ByVal value As String)
sFilePath = value
End Set
End Property
Public ReadOnly Property MapDim As Integer Implements IFUELMAP.MapDim
Get
Return iMapDim
End Get
End Property
Public ReadOnly Property Tq As List(Of Single) Implements IFUELMAP.Tq
Get
Return LTq
End Get
End Property
Public ReadOnly Property FC As List(Of Single) Implements IFUELMAP.FC
Get
Return lFC
End Get
End Property
Public ReadOnly Property nU As List(Of Single) Implements IFUELMAP.nU
Get
Return LnU
End Get
End Property
Public Property FilePath() As String
Get
Return sFilePath
End Get
Set(ByVal value As String)
sFilePath = value
End Set
End Property
Public ReadOnly Property MapDim As Integer
Get
Return iMapDim
End Get
End Property
Public ReadOnly Property Tq As List(Of Single)
Get
Return LTq
End Get
End Property
Public ReadOnly Property FC As List(Of Single)
Get
Return lFC
End Get
End Property
Public ReadOnly Property nU As List(Of Single)
Get
Return LnU
End Get
End Property
#End Region
Public Function GetFuelConsumption(torque As Double, angularVelocity As Double) As Double _
Implements IFuelConsumptionMap.GetFuelConsumption
Return fFCdelaunay_Intp(angularVelocity, torque)
End Function
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