From 7ff0af6865718d36c2d09b393ac4cf68ef06c006 Mon Sep 17 00:00:00 2001 From: Raphael Luz <luz@ivt.tugraz.at> Date: Wed, 13 May 2015 09:10:08 +0200 Subject: [PATCH] - Added backwards compatibility with updated wheels list - WHTC Weighting Factors as separate file (not part of Segment Table) --- Declaration/WHTC-Weighting-Factors.csv | 4 ++ VECTO/Input Files/cVEH.vb | 9 +++-- VECTO/cDeclaration.vb | 54 ++++++++++++++++++++------ 3 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 Declaration/WHTC-Weighting-Factors.csv diff --git a/Declaration/WHTC-Weighting-Factors.csv b/Declaration/WHTC-Weighting-Factors.csv new file mode 100644 index 0000000000..4d00f736a8 --- /dev/null +++ b/Declaration/WHTC-Weighting-Factors.csv @@ -0,0 +1,4 @@ +Part,Long haul,Regional delivery,Urban delivery,Municipal utility,Construction,Heavy Urban,Urban,Suburban,Interurban,Coach +Urban,11,17,69,98,62,100,100,100,45,0 +Rural,0,30,27,0,32,0,0,0,36,22 +Motorway,89,53,4,2,6,0,0,0,19,78 diff --git a/VECTO/Input Files/cVEH.vb b/VECTO/Input Files/cVEH.vb index 97e05b6793..8212e5a7f2 100644 --- a/VECTO/Input Files/cVEH.vb +++ b/VECTO/Input Files/cVEH.vb @@ -13,7 +13,7 @@ Imports System.Collections.Generic Public Class cVEH 'V2 MassMax is now saved in [t] instead of [kg] - Private Const FormatVersion As Short = 5 + Private Const FormatVersion As Short = 6 Private FileVersion As Short Private sFilePath As String @@ -76,7 +76,7 @@ Public Class cVEH MyFileList = New List(Of String) '.vcdv / .vcdb - If Me.CdMode <> tCdMode.ConstCd0 Then MyFileList.Add(Me.CdFile.FullPath) + If Me.CdMode = tCdMode.CdOfVeng Or Me.CdMode = tCdMode.CdOfBeta Then MyFileList.Add(Me.CdFile.FullPath) 'Retarder If Me.RtType <> tRtType.None Then MyFileList.Add(Me.RtFile.FullPath) @@ -229,7 +229,8 @@ Public Class cVEH a0.Wheels = "-" Else a0.Inertia = CSng(dic("Inertia")) - a0.Wheels = CStr(dic("Wheels")) + a0.Wheels = CStr(dic("Wheels")) + If FileVersion < 6 Then a0.Wheels = a0.Wheels.Replace("R ", "R") End If a0.Share = CSng(dic("AxleWeightShare")) @@ -382,7 +383,7 @@ Public Class cVEH a0 = New cAxle a0.Inertia = 0 'Defined later - a0.Wheels = "385/65 R 22.5" + a0.Wheels = "385/65 R22.5" a0.Share = a / 100 a0.TwinTire = False diff --git a/VECTO/cDeclaration.vb b/VECTO/cDeclaration.vb index 0d17061429..63a570a451 100644 --- a/VECTO/cDeclaration.vb +++ b/VECTO/cDeclaration.vb @@ -108,7 +108,6 @@ Public Class cDeclaration Dim AxleShares As List(Of String) Dim AxleSharesTr As List(Of String) Dim l0 As List(Of Single) - Dim dWHTCWF As Dictionary(Of tWHTCpart, Single) Dim at0 As List(Of String) Dim AuxPower0 As Dictionary(Of tMission, Single) @@ -228,8 +227,46 @@ Public Class cDeclaration file.Close() + 'WHTC-Weighting-Factors.csv + If Not file.OpenRead(MyDeclPath & "WHTC-Weighting-Factors.csv") Then + GUImsg(tMsgID.Err, "Failed to load Declaration Config (WHTC-Weighting-Factors.csv)!") + Return False + End If + + 'Skip Header + file.ReadLine() + + Try + + For i = 0 To 2 + If file.EndOfFile Then Throw New Exception("Unexpected end of file.") + line = file.ReadLine + + a = 0 + For Each mt0 In Missions.Keys + a += 1 + mc0 = Missions(mt0) + Select Case i + Case 0 + mc0.WHTCWF = New Dictionary(Of tWHTCpart, Single) + mc0.WHTCWF.Add(tWHTCpart.Urban, line(a) / 100) + Case 1 + mc0.WHTCWF.Add(tWHTCpart.Rural, line(a) / 100) + Case Else '2 + mc0.WHTCWF.Add(tWHTCpart.Motorway, line(a) / 100) + End Select + Next + Next + Catch ex As Exception + file.Close() + GUImsg(tMsgID.Err, "Error in WHTC-Weighting-Factors! " & ex.Message) + Return False + End Try + + file.Close() + 'Segment Table If Not file.OpenRead(MyDeclPath & "SegmentTable.csv") Then GUImsg(tMsgID.Err, "Failed to load Declaration Config (Segment Table)!") @@ -336,13 +373,6 @@ Public Class cDeclaration ste0.AxleSharesTr.Add(SegmentTable.MissionList(i), l0) - dWHTCWF = New Dictionary(Of tWHTCpart, Single) - dWHTCWF.Add(tWHTCpart.Urban, 0) - dWHTCWF.Add(tWHTCpart.Rural, 0) - dWHTCWF.Add(tWHTCpart.Motorway, 0) - - ste0.WHTCWF.Add(SegmentTable.MissionList(i), dWHTCWF) - End If Next @@ -866,9 +896,9 @@ Public Class cDeclaration CurrentMission = Missions(SegRef.Missions(CycleIndex)) - WHTCcorrFactor = Declaration.SegRef.WHTCWF(Declaration.CurrentMission.MissionID)(tWHTCpart.Urban) * ENG.WHTCurban / Declaration.WHTCresults(tWHTCpart.Urban) _ - + Declaration.SegRef.WHTCWF(Declaration.CurrentMission.MissionID)(tWHTCpart.Rural) * ENG.WHTCrural / Declaration.WHTCresults(tWHTCpart.Rural) _ - + Declaration.SegRef.WHTCWF(Declaration.CurrentMission.MissionID)(tWHTCpart.Motorway) * ENG.WHTCmw / Declaration.WHTCresults(tWHTCpart.Motorway) + WHTCcorrFactor = CurrentMission.WHTCWF(tWHTCpart.Urban) * ENG.WHTCurban / Declaration.WHTCresults(tWHTCpart.Urban) _ + + CurrentMission.WHTCWF(tWHTCpart.Rural) * ENG.WHTCrural / Declaration.WHTCresults(tWHTCpart.Rural) _ + + CurrentMission.WHTCWF(tWHTCpart.Motorway) * ENG.WHTCmw / Declaration.WHTCresults(tWHTCpart.Motorway) If Not VEH.DeclInitCycle Then Return False @@ -1204,6 +1234,7 @@ Public Class cMission Public MissionID As tMission Public NameStr As String Public CyclePath As String + Public WHTCWF As New Dictionary(Of tWHTCpart, Single) End Class Public Class cSegmentTable @@ -1241,7 +1272,6 @@ Public Class cSegmentTableEntry Public Loading As New Dictionary(Of tMission, String) Public AxleShares As New Dictionary(Of tMission, List(Of Single)) Public AxleSharesTr As New Dictionary(Of tMission, List(Of Single)) - Public WHTCWF As New Dictionary(Of tMission, Dictionary(Of tWHTCpart, Single)) Public TrailerOnlyInLongHaul As Boolean Public Function GetCycles() As List(Of String) -- GitLab