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 5799616b authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

cMap (Vecto) implements IFuelConsumption Interface (to work with AAUX)

parent 5f6e6e5b
No related branches found
No related tags found
No related merge requests found
......@@ -9,190 +9,188 @@
'
' See the LICENSE.txt for the specific language governing permissions and limitations.
Imports System.Collections.Generic
Imports VectoAuxiliaries
Public Class cMAP
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
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
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
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()
If 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()
If 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
If ShowMsg Then WorkerMsg(tMsgID.Err, "Error during file read! Line number " & iMapDim + 1 & " (" & sFilePath & ")", MsgSrc, sFilePath)
GoTo lbEr
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
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
Dim val As Single
val = FuelMap.Intpol(nU, Tq)
If FuelMap.ExtrapolError Then
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
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
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
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
......@@ -92,7 +92,7 @@ Namespace IntegrationTests
aux.Signals.RunningCalc = True
aux.Signals.Internal_Engine_Power = internalPower 'kW
Dim msg As String
Dim msg As String = String.Empty
For i As Integer = 0 To 9
Assert.AreEqual(6087.0317, aux.AuxiliaryPowerAtCrankWatts, 0.001)
aux.CycleStep(1, msg)
......
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