From 677b44fa3ca88b70d73b65a9d9e627c5b4a650a6 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Fri, 2 Sep 2016 16:14:30 +0200 Subject: [PATCH] refactoring: variable names match coding style, more cleanup (engine) --- VECTO/GUI/EngineForm.vb | 4 +- VECTO/GUI/FileSignDialog.vb | 24 +- VECTO/GUI/GearboxForm.vb | 102 ++--- VECTO/GUI/VectoJobForm.vb | 82 ++-- VECTO/GUI/VehicleForm.vb | 32 +- VECTO/Input Files/EngineFullLoadCurve.vb | 495 ++++++++--------------- VECTO/Input Files/FuelconsumptionMap.vb | 27 +- VECTO/Input Files/Gearbox.vb | 217 +++++----- VECTO/Input Files/VectoJob.vb | 108 ++--- VECTO/Input Files/Vehicle.vb | 131 +++--- VECTO/Input Files/cAdvancedAuxiliary.vb | 10 +- VECTO/MainModule.vb | 8 +- 12 files changed, 530 insertions(+), 710 deletions(-) diff --git a/VECTO/GUI/EngineForm.vb b/VECTO/GUI/EngineForm.vb index 98fa44ac6c..9259aa0a3b 100644 --- a/VECTO/GUI/EngineForm.vb +++ b/VECTO/GUI/EngineForm.vb @@ -388,7 +388,7 @@ Public Class EngineForm If fldOK Then s = New Series - s.Points.DataBindXY(FLD0.LnU, FLD0.LTq) + s.Points.DataBindXY(FLD0.EngineSpeedList, FLD0.MaxTorqueList) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkBlue @@ -396,7 +396,7 @@ Public Class EngineForm MyChart.Series.Add(s) s = New Series - s.Points.DataBindXY(FLD0.LnU, FLD0.LTqDrag) + s.Points.DataBindXY(FLD0.EngineSpeedList, FLD0.DragTorqueList) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.Blue diff --git a/VECTO/GUI/FileSignDialog.vb b/VECTO/GUI/FileSignDialog.vb index ad5ee67b1a..1806f515be 100644 --- a/VECTO/GUI/FileSignDialog.vb +++ b/VECTO/GUI/FileSignDialog.vb @@ -19,8 +19,8 @@ Imports vectolic Public Class FileSignDialog 'Create signature file Private Sub BtSign_Click(sender As Object, e As EventArgs) Handles BtSign.Click - Dim lv0 As ListViewItem - Dim MainDir As String + Dim listViewItem As ListViewItem + Dim mainDirectory As String If lvFiles.Items.Count = 0 Then MsgBox("No files selected!", MsgBoxStyle.Critical) @@ -39,17 +39,17 @@ Public Class FileSignDialog ClearForm(False) - MainDir = fPATH(TbSigFile.Text) + mainDirectory = fPATH(TbSigFile.Text) Lic.FileSigning.NewFile() Lic.FileSigning.Mode = cFileSigning.tMode.Manual - For Each lv0 In lvFiles.Items - Lic.FileSigning.AddFile(fFileRepl(lv0.SubItems(0).Text, MainDir)) - lv0.SubItems(1).Text = "" - lv0.ForeColor = Color.Black + For Each listViewItem In lvFiles.Items + Lic.FileSigning.AddFile(fFileRepl(listViewItem.SubItems(0).Text, mainDirectory)) + listViewItem.SubItems(1).Text = "" + listViewItem.ForeColor = Color.Black Next If Lic.FileSigning.WriteSigFile(TbSigFile.Text, LicSigAppCode) Then @@ -66,12 +66,12 @@ Public Class FileSignDialog LbDateStr.Text = Lic.FileSigning.DateStr If Lic.FileSigning.FilesOK.Count > 0 Then - For Each lv0 In lvFiles.Items - lv0.SubItems(1).Text = Lic.FileSigning.FilesMsg(lv0.Index) - If Lic.FileSigning.FilesOK(lv0.Index) Then - lv0.ForeColor = Color.DarkGreen + For Each listViewItem In lvFiles.Items + listViewItem.SubItems(1).Text = Lic.FileSigning.FilesMsg(listViewItem.Index) + If Lic.FileSigning.FilesOK(listViewItem.Index) Then + listViewItem.ForeColor = Color.DarkGreen Else - lv0.ForeColor = Color.Red + listViewItem.ForeColor = Color.Red Exit For End If Next diff --git a/VECTO/GUI/GearboxForm.vb b/VECTO/GUI/GearboxForm.vb index 54b713201a..d246fe834a 100644 --- a/VECTO/GUI/GearboxForm.vb +++ b/VECTO/GUI/GearboxForm.vb @@ -251,16 +251,16 @@ Public Class GearboxForm LvGears.Items.Clear() - For i = 0 To GBX0.Igetr.Count - 1 + For i = 0 To GBX0.GearRatios.Count - 1 If i = 0 Then 'lv0 = New ListViewItem("Axle") - LvGears.Items.Add(CreateListviewItem("Axle", "-", GBX0.Igetr(i), GBX0.GetrMap(i, True), GBX0.gsFile(i, True), + LvGears.Items.Add(CreateListviewItem("Axle", "-", GBX0.GearRatios(i), GBX0.GearLossMap(i, True), GBX0.ShiftPolygonFile(i, True), GBX0.MaxTorque(i))) Else 'lv0 = New ListViewItem(i.ToString("00")) - LvGears.Items.Add(CreateListviewItem(i.ToString("00"), "-", GBX0.Igetr(i), GBX0.GetrMap(i, True), - GBX0.gsFile(i, True), GBX0.MaxTorque(i))) + LvGears.Items.Add(CreateListviewItem(i.ToString("00"), "-", GBX0.GearRatios(i), GBX0.GearLossMap(i, True), + GBX0.ShiftPolygonFile(i, True), GBX0.MaxTorque(i))) End If Next @@ -273,10 +273,10 @@ Public Class GearboxForm TbStartAcc.Text = GBX0.StartAcc.ToString ChShiftInside.Checked = GBX0.ShiftInside - TbTCfile.Text = GBX0.TCfile(True) + TbTCfile.Text = GBX0.TorqueConverterFile(True) TbTCrefrpm.Text = GBX0.TorqueConverterReferenceRPM TbTCinertia.Text = GBX0.TorqueConverterInertia - TBTCShiftPolygon.Text = GBX0.TCshiftFile + TBTCShiftPolygon.Text = GBX0.TorqueConverterShiftPolygonFile tbUpshiftMinAcceleration.Text = GBX0.UpshiftMinAcceleration tbDownshiftAfterUpshift.Text = GBX0.DownshiftAfterUpshift @@ -341,11 +341,11 @@ Public Class GearboxForm For i = 0 To LvGears.Items.Count - 1 'GBX0.IsTCgear.Add(Me.LvGears.Items(i).SubItems(GearboxTbl.TorqueConverter).Text = "on" And i > 0) - GBX0.Igetr.Add(CSng(LvGears.Items(i).SubItems(GearboxTbl.Ratio).Text)) - GBX0.GetrMaps.Add(New SubPath) - GBX0.GetrMap(i) = LvGears.Items(i).SubItems(GearboxTbl.LossMapEfficiency).Text - GBX0.gs_files.Add(New SubPath) - GBX0.gsFile(i) = LvGears.Items(i).SubItems(GearboxTbl.ShiftPolygons).Text + GBX0.GearRatios.Add(CSng(LvGears.Items(i).SubItems(GearboxTbl.Ratio).Text)) + GBX0.GearLossmaps.Add(New SubPath) + GBX0.GearLossMap(i) = LvGears.Items(i).SubItems(GearboxTbl.LossMapEfficiency).Text + GBX0.GearshiftFiles.Add(New SubPath) + GBX0.ShiftPolygonFile(i) = LvGears.Items(i).SubItems(GearboxTbl.ShiftPolygons).Text 'GBX0.FldFiles.Add(New cSubPath) 'GBX0.FldFile(i) = Me.LvGears.Items(i).SubItems(GearboxTbl.MaxTorque).Text GBX0.MaxTorque.Add(LvGears.Items(i).SubItems(GearboxTbl.MaxTorque).Text) @@ -362,10 +362,10 @@ Public Class GearboxForm GBX0.Type = CbGStype.SelectedValue GBX0.TorqueConverterEnabled = ChTCon.Checked - GBX0.TCfile = TbTCfile.Text + GBX0.TorqueConverterFile = TbTCfile.Text GBX0.TorqueConverterReferenceRPM = fTextboxToNumString(TbTCrefrpm.Text) GBX0.TorqueConverterInertia = fTextboxToNumString(TbTCinertia.Text) - GBX0.TCshiftFile = TBTCShiftPolygon.Text + GBX0.TorqueConverterShiftPolygonFile = TBTCShiftPolygon.Text GBX0.DownshiftAfterUpshift = fTextboxToNumString(tbDownshiftAfterUpshift.Text) GBX0.UpshiftAfterDownshift = fTextboxToNumString(tbUpshiftAfterDownshift.Text) @@ -737,7 +737,7 @@ Public Class GearboxForm fldpath = VectoJobForm.FLDfile - fldOK = fldpath.Trim <> "" + fldOK = Not IsNothing(fldpath) AndAlso fldpath.Trim <> "" If fldOK Then FLD0 = New EngineFullLoadCurve @@ -823,7 +823,7 @@ Public Class GearboxForm If fldOK AndAlso vectoOk AndAlso vehicleOk Then s = New Series - s.Points.DataBindXY(FLD0.LnU, FLD0.LTq) + s.Points.DataBindXY(FLD0.EngineSpeedList, FLD0.MaxTorqueList) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkBlue @@ -831,43 +831,43 @@ Public Class GearboxForm MyChart.Series.Add(s) If VectoJobForm.Visible AndAlso VectoJobForm.n_idle > 0 Then - If FLD0.Init(VectoJobForm.n_idle) Then - - 'Dim fullLoadCurve As FullLoadCurve = ConvertToFullLoadCurve(FLD0.LnU, FLD0.LTq) - Dim gears As IList(Of ITransmissionInputData) = ConvertToGears(LvGears.Items) - If (CType(CbGStype.SelectedValue, GearboxType).ManualTransmission() AndAlso gears.Count > 1) Then - Dim engine As CombustionEngineData = ConvertToEngineData(FLD0, VectoJobForm.n_idle) - Dim shiftLines As ShiftPolygon = DeclarationData.Gearbox.ComputeShiftPolygon(Gear - 1, engine.FullLoadCurve, gears, - engine, - Double.Parse(LvGears.Items(0).SubItems(GearboxTbl.Ratio).Text, CultureInfo.InvariantCulture), - (vehicle.rdyn / 1000.0).SI(Of Meter)) - - s = New Series - - 's.Points.DataBindXY(Shiftpoly.gs_nUup, Shiftpoly.gs_TqUp) - s.Points.DataBindXY( - shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), - shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToList()) - s.ChartType = SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.DarkRed - s.BorderDashStyle = ChartDashStyle.Dash - s.Name = "Upshift curve (generic)" - MyChart.Series.Add(s) - - s = New Series - 's.Points.DataBindXY(Shiftpoly.gs_nUdown, Shiftpoly.gs_TqDown) - s.Points.DataBindXY( - shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), - shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToList()) - s.ChartType = SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.DarkRed - s.BorderDashStyle = ChartDashStyle.Dash - s.Name = "Downshift curve (generic)" - MyChart.Series.Add(s) - End If + 'If FLD0.Init(VectoJobForm.n_idle) Then + + 'Dim fullLoadCurve As FullLoadCurve = ConvertToFullLoadCurve(FLD0.LnU, FLD0.LTq) + Dim gears As IList(Of ITransmissionInputData) = ConvertToGears(LvGears.Items) + If (CType(CbGStype.SelectedValue, GearboxType).ManualTransmission() AndAlso gears.Count > 1) Then + Dim engine As CombustionEngineData = ConvertToEngineData(FLD0, VectoJobForm.n_idle) + Dim shiftLines As ShiftPolygon = DeclarationData.Gearbox.ComputeShiftPolygon(Gear - 1, engine.FullLoadCurve, gears, + engine, + Double.Parse(LvGears.Items(0).SubItems(GearboxTbl.Ratio).Text, CultureInfo.InvariantCulture), + (vehicle.DynamicTyreRadius / 1000.0).SI(Of Meter)) + + s = New Series + + 's.Points.DataBindXY(Shiftpoly.gs_nUup, Shiftpoly.gs_TqUp) + s.Points.DataBindXY( + shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), + shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToList()) + s.ChartType = SeriesChartType.FastLine + s.BorderWidth = 2 + s.Color = Color.DarkRed + s.BorderDashStyle = ChartDashStyle.Dash + s.Name = "Upshift curve (generic)" + MyChart.Series.Add(s) + + s = New Series + 's.Points.DataBindXY(Shiftpoly.gs_nUdown, Shiftpoly.gs_TqDown) + s.Points.DataBindXY( + shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), + shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToList()) + s.ChartType = SeriesChartType.FastLine + s.BorderWidth = 2 + s.Color = Color.DarkRed + s.BorderDashStyle = ChartDashStyle.Dash + s.Name = "Downshift curve (generic)" + MyChart.Series.Add(s) End If + 'End If End If End If diff --git a/VECTO/GUI/VectoJobForm.vb b/VECTO/GUI/VectoJobForm.vb index 7111cc4210..047ab9b1e4 100644 --- a/VECTO/GUI/VectoJobForm.vb +++ b/VECTO/GUI/VectoJobForm.vb @@ -391,7 +391,7 @@ Public Class VectoJobForm ChBStartStop.Checked = VEC0.StartStop TbSSspeed.Text = VEC0.StStV.ToString() TbSStime.Text = VEC0.StStT.ToString() - TbSSdelay.Text = VEC0.StStDelay.ToString() + TbSSdelay.Text = VEC0.StartStopDelay.ToString() 'VACC TbDesMaxFile.Text = VEC0.DesMaxFile(True) @@ -429,7 +429,7 @@ Public Class VectoJobForm LvCycles.Items.Add(lv0) Next - CbEngOnly.Checked = VEC0.EngOnly + CbEngOnly.Checked = VEC0.EngineOnly If VEC0.EcoRollOn Then RdEcoRoll.Checked = True @@ -523,7 +523,7 @@ Public Class VectoJobForm vec0.StartStop = ChBStartStop.Checked vec0.StStV = CSng(fTextboxToNumString(TbSSspeed.Text)) vec0.StStT = CSng(fTextboxToNumString(TbSStime.Text)) - vec0.StStDelay = CInt(fTextboxToNumString(TbSSdelay.Text)) + vec0.StartStopDelay = CInt(fTextboxToNumString(TbSSdelay.Text)) 'a_DesMax vec0.DesMaxFile = TbDesMaxFile.Text @@ -546,7 +546,7 @@ Public Class VectoJobForm vec0.AuxPaths.Add(lv0.SubItems(0).Text, auxEntry) Next - vec0.EngOnly = CbEngOnly.Checked + vec0.EngineOnly = CbEngOnly.Checked vec0.EcoRollOn = RdEcoRoll.Checked vec0.OverSpeedOn = RdOverspeed.Checked @@ -1010,7 +1010,7 @@ lbDlog: Dim s0 As Segment = Nothing Try - s0 = DeclarationData.Segments.Lookup(VEH0.VehCat, VEH0.AxleConf, maxMass, 0.SI(Of Kilogram), True) + s0 = DeclarationData.Segments.Lookup(VEH0.VehicleCategory, VEH0.AxleConfiguration, maxMass, 0.SI(Of Kilogram), True) Catch End Try If Not s0 Is Nothing Then @@ -1030,9 +1030,9 @@ lbDlog: PicVehicle.Image = ConvPicPath(HDVclass, False) 'Image.FromFile(cDeclaration.ConvPicPath(HDVclass, False)) TbHVCclass.Text = "HDV Class " & HDVclass - TbVehCat.Text = VEH0.VehCat.GetCategoryName() 'ConvVehCat(VEH0.VehCat, True) + TbVehCat.Text = VEH0.VehicleCategory.GetCategoryName() 'ConvVehCat(VEH0.VehCat, True) TbMass.Text = VEH0.MassMax & " t" - TbAxleConf.Text = VEH0.AxleConf.GetName() 'ConvAxleConf(VEH0.AxleConf) + TbAxleConf.Text = VEH0.AxleConfiguration.GetName() 'ConvAxleConf(VEH0.AxleConf) End If @@ -1062,7 +1062,7 @@ lbDlog: If FLD0.ReadFile(False, False) Then s = New Series - s.Points.DataBindXY(FLD0.LnU, FLD0.LTq) + s.Points.DataBindXY(FLD0.EngineSpeedList, FLD0.MaxTorqueList) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkBlue @@ -1070,7 +1070,7 @@ lbDlog: MyChart.Series.Add(s) s = New Series - s.Points.DataBindXY(FLD0.LnU, FLD0.LTqDrag) + s.Points.DataBindXY(FLD0.EngineSpeedList, FLD0.DragTorqueList) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.Blue @@ -1079,7 +1079,7 @@ lbDlog: OkCount += 1 - pmax = FLD0.Pfull(FLD0.fnUrated) + pmax = FLD0.Pfull(FLD0.EngineRatedSpeed) End If @@ -1122,40 +1122,40 @@ lbDlog: If FLD0.ReadFile(True, False) Then - If FLD0.Init(ENG0.Nidle) Then - - 'Dim engine As CombustionEngineData = ConvertToEngineData(FLD0, F_VECTO.n_idle) - 'Dim shiftLines As ShiftPolygon = DeclarationData.Gearbox.ComputeShiftPolygon(Gear - 1, - ' engine.FullLoadCurve, gears, - ' engine, - ' Double.Parse(LvGears.Items(0).SubItems(F_GBX.GearboxTbl.Ratio).Text, - ' CultureInfo.InvariantCulture), - ' (.rdyn / 1000.0).SI(Of Meter)) - - 's = New Series - 's.Points.DataBindXY(shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), - ' shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToList()) - 's.ChartType = SeriesChartType.FastLine - 's.BorderWidth = 2 - 's.Color = Color.DarkRed - 's.Name = "Upshift curve (" & i & ")" - 'MyChart.Series.Add(s) - - 's = New Series - 's.Points.DataBindXY( - ' shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), - ' shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToList()) - 's.ChartType = SeriesChartType.FastLine - 's.BorderWidth = 2 - 's.Color = Color.DarkRed - 's.Name = "Downshift curve (" & i & ")" - 'MyChart.Series.Add(s) - End If + 'If FLD0.Init(ENG0.Nidle) Then '' use engine from below... + + 'Dim engine As CombustionEngineData = ConvertToEngineData(FLD0, F_VECTO.n_idle) + 'Dim shiftLines As ShiftPolygon = DeclarationData.Gearbox.ComputeShiftPolygon(Gear - 1, + ' engine.FullLoadCurve, gears, + ' engine, + ' Double.Parse(LvGears.Items(0).SubItems(F_GBX.GearboxTbl.Ratio).Text, + ' CultureInfo.InvariantCulture), + ' (.rdyn / 1000.0).SI(Of Meter)) + + 's = New Series + 's.Points.DataBindXY(shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), + ' shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToList()) + 's.ChartType = SeriesChartType.FastLine + 's.BorderWidth = 2 + 's.Color = Color.DarkRed + 's.Name = "Upshift curve (" & i & ")" + 'MyChart.Series.Add(s) + + 's = New Series + 's.Points.DataBindXY( + ' shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.Value() / Constants.RPMToRad).ToList(), + ' shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToList()) + 's.ChartType = SeriesChartType.FastLine + 's.BorderWidth = 2 + 's.Color = Color.DarkRed + 's.Name = "Downshift curve (" & i & ")" + 'MyChart.Series.Add(s) + 'End If OkCount += 1 - pmax = FLD0.Pfull(FLD0.fnUrated) + pmax = FLD0.Pfull(FLD0.EngineRatedSpeed) End If @@ -1172,7 +1172,7 @@ lbDlog: lup = New List(Of Single) ldown = New List(Of Single) - If f.OpenRead(GBX0.gsFile(i)) Then + If f.OpenRead(GBX0.ShiftPolygonFile(i)) Then f.ReadLine() diff --git a/VECTO/GUI/VehicleForm.vb b/VECTO/GUI/VehicleForm.vb index 870ded15c8..cbf0e9c50d 100644 --- a/VECTO/GUI/VehicleForm.vb +++ b/VECTO/GUI/VehicleForm.vb @@ -321,20 +321,20 @@ Public Class VehicleForm TbMass.Text = veh.Mass TbMassExtra.Text = veh.MassExtra TbLoad.Text = veh.Loading - TBrdyn.Text = veh.rdyn + TBrdyn.Text = veh.DynamicTyreRadius - CbCdMode.SelectedValue = veh.CdMode - TbCdFile.Text = veh.CdFile.OriginalPath + CbCdMode.SelectedValue = veh.CrossWindCorrectionMode + TbCdFile.Text = veh.CrossWindCorrectionFile.OriginalPath - CbRtType.SelectedValue = veh.RtType - TbRtRatio.Text = veh.RtRatio - TbRtPath.Text = veh.RtFile.OriginalPath + CbRtType.SelectedValue = veh.RetarderType + TbRtRatio.Text = veh.RetarderRatio + TbRtPath.Text = veh.RetarderLossMapFile.OriginalPath cbAngularGearType.SelectedValue = veh.AngularGearType tbAngularGearRatio.Text = veh.AngularGearRatio tbAngularGearLossMapPath.Text = veh.AngularGearLossMapFile.OriginalPath - CbCat.SelectedValue = veh.VehCat + CbCat.SelectedValue = veh.VehicleCategory LvRRC.Items.Clear() @@ -376,7 +376,7 @@ Public Class VehicleForm TbMassMass.Text = veh.MassMax TbMassExtra.Text = veh.MassExtra - CbAxleConfig.SelectedValue = veh.AxleConf + CbAxleConfig.SelectedValue = veh.AxleConfiguration TBcdA.Text = veh.CdA0 @@ -403,18 +403,18 @@ Public Class VehicleForm veh.CdA0 = CSng(fTextboxToNumString(TBcdA.Text)) - veh.rdyn = CSng(fTextboxToNumString(TBrdyn.Text)) - veh.CdMode = CbCdMode.SelectedValue - veh.CdFile.Init(fPATH(file), TbCdFile.Text) - veh.RtType = CbRtType.SelectedValue - veh.RtRatio = CSng(fTextboxToNumString(TbRtRatio.Text)) - veh.RtFile.Init(fPATH(file), TbRtPath.Text) + veh.DynamicTyreRadius = CSng(fTextboxToNumString(TBrdyn.Text)) + veh.CrossWindCorrectionMode = CbCdMode.SelectedValue + veh.CrossWindCorrectionFile.Init(fPATH(file), TbCdFile.Text) + veh.RetarderType = CbRtType.SelectedValue + veh.RetarderRatio = CSng(fTextboxToNumString(TbRtRatio.Text)) + veh.RetarderLossMapFile.Init(fPATH(file), TbRtPath.Text) veh.AngularGearType = cbAngularGearType.SelectedValue veh.AngularGearRatio = CSng(fTextboxToNumString(tbAngularGearRatio.Text)) veh.AngularGearLossMapFile.Init(fPATH(file), tbAngularGearLossMapPath.Text) - veh.VehCat = CbCat.SelectedValue 'CType(CbCat.SelectedIndex, tVehCat) + veh.VehicleCategory = CbCat.SelectedValue 'CType(CbCat.SelectedIndex, tVehCat) Dim axleShareCheck As Double For Each LV0 In LvRRC.Items @@ -436,7 +436,7 @@ Public Class VehicleForm veh.MassMax = CSng(fTextboxToNumString(TbMassMass.Text)) veh.MassExtra = CSng(fTextboxToNumString(TbMassExtra.Text)) - veh.AxleConf = CbAxleConfig.SelectedValue + veh.AxleConfiguration = CbAxleConfig.SelectedValue '--------------------------------------------------------------------------------- diff --git a/VECTO/Input Files/EngineFullLoadCurve.vb b/VECTO/Input Files/EngineFullLoadCurve.vb index e5ed5ff910..75ad3e685b 100644 --- a/VECTO/Input Files/EngineFullLoadCurve.vb +++ b/VECTO/Input Files/EngineFullLoadCurve.vb @@ -9,110 +9,70 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.Collections.Generic +Imports System.Linq ''' <summary> ''' Full load/motoring curve input file ''' </summary> ''' <remarks></remarks> Public Class EngineFullLoadCurve - ''' <summary> - ''' Full file path. Needs to be defined via FilePath property before calling ReadFile or SaveFile. - ''' </summary> - ''' <remarks></remarks> - Private sFilePath As String - ''' <summary> ''' List of full load torque values [Nm] ''' </summary> ''' <remarks></remarks> - Public LTq As List(Of Single) + Public MaxTorqueList As List(Of Single) ''' <summary> ''' List of motoring torque values [Nm] ''' </summary> ''' <remarks></remarks> - Public LTqDrag As List(Of Single) + Public DragTorqueList As List(Of Single) ''' <summary> ''' List of engine speed values [1/min] ''' </summary> ''' <remarks></remarks> - Public LnU As List(Of Single) + Public EngineSpeedList As List(Of Single) ''' <summary> ''' List of PT1 values [s] ''' </summary> ''' <remarks></remarks> - Private LPT1 As List(Of Single) + Private _pt1List As List(Of Single) ''' <summary> ''' Last index of lists (items count - 1) ''' </summary> ''' <remarks></remarks> - Private iDim As Integer - - ''' <summary> - ''' Nlo [1/min]. Lowest enging speed with 55% of max. power. Defined in Init. - ''' </summary> - ''' <remarks></remarks> - Public Nlo As Single - - ''' <summary> - ''' Nhi [1/min]. Highest engine speed with 70% of max. power. Defined in Init. - ''' </summary> - ''' <remarks></remarks> - Public Nhi As Single - - ''' <summary> - ''' Npref [1/min]. Speed at 51% torque/speed-integral between idling and N95h. Defined in Init. - ''' </summary> - ''' <remarks></remarks> - Public Npref As Single - - ''' <summary> - ''' N95h [1/min]. Highest engine speed with 95% of max. power. Defined in Init. - ''' </summary> - ''' <remarks></remarks> - Public N95h As Single - - ''' <summary> - ''' N80h [1/min]. Highest engine speed with 80% of max. power. Defined in Init. - ''' </summary> - ''' <remarks></remarks> - Public N80h As Single + 'Private _iDim As Integer ''' <summary> ''' Read file. FilePath must be set before calling. ''' </summary> ''' <returns>True if successful.</returns> ''' <remarks></remarks> - Public Function ReadFile(ByVal TqOnly As Boolean, Optional ByVal ShowMsg As Boolean = True) As Boolean - Dim file As CsvFile - Dim line As String() - Dim PT1set As Boolean - Dim FirstLine As Boolean - Dim nU As Double - Dim MsgSrc As String + Public Function ReadFile(tqOnly As Boolean, Optional ByVal showMsg As Boolean = True) As Boolean + Dim pt1Set As Boolean - MsgSrc = "Main/ReadInp/FLD" + Const msgSrc As String = "Main/ReadInp/FLD" 'Reset - LTq = Nothing - LTqDrag = Nothing - LnU = Nothing - LPT1 = Nothing - iDim = -1 + MaxTorqueList = Nothing + DragTorqueList = Nothing + EngineSpeedList = Nothing + _pt1List = Nothing + Dim lineCount As Integer = -1 'Stop if there's no file - If sFilePath = "" OrElse Not IO.File.Exists(sFilePath) Then - If ShowMsg Then WorkerMsg(MessageType.Err, "FLD file '" & sFilePath & "' not found!", MsgSrc) + If FilePath = "" OrElse Not IO.File.Exists(FilePath) Then + If showMsg Then WorkerMsg(MessageType.Err, "FLD file '" & FilePath & "' not found!", msgSrc) Return False End If 'Open file - file = New CsvFile - If Not file.OpenRead(sFilePath) Then - If ShowMsg Then WorkerMsg(MessageType.Err, "Failed to open file (" & sFilePath & ") !", MsgSrc) + Dim file As CsvFile = New CsvFile + If Not file.OpenRead(FilePath) Then + If showMsg Then WorkerMsg(MessageType.Err, "Failed to open file (" & FilePath & ") !", msgSrc) Return False End If @@ -121,53 +81,54 @@ Public Class EngineFullLoadCurve file.ReadLine() 'Initialize Lists - LTq = New List(Of Single) - LTqDrag = New List(Of Single) - LnU = New List(Of Single) - LPT1 = New List(Of Single) + MaxTorqueList = New List(Of Single) + DragTorqueList = New List(Of Single) + EngineSpeedList = New List(Of Single) + _pt1List = New List(Of Single) - FirstLine = True + Dim firstLine As Boolean = True Try Do While Not file.EndOfFile 'Read Line - line = file.ReadLine + Dim line As String() = file.ReadLine 'VECTO: M => Pe - nU = CDbl(line(0)) + Dim rpm As Double = CDbl(line(0)) - LnU.Add(nU) - LTq.Add(CDbl(line(1))) + EngineSpeedList.Add(rpm) + MaxTorqueList.Add(CDbl(line(1))) - If TqOnly Then - LTqDrag.Add(0) + If tqOnly Then + DragTorqueList.Add(0) Else - LTqDrag.Add(CDbl(line(2))) + DragTorqueList.Add(CDbl(line(2))) End If - If FirstLine Then - PT1set = (Not TqOnly) AndAlso (UBound(line) > 2) - FirstLine = False + If firstLine Then + pt1Set = (Not tqOnly) AndAlso (UBound(line) > 2) + firstLine = False End If 'If PT1 not defined, use default value (0) - If PT1set Then - LPT1.Add(CSng(line(3))) + If pt1Set Then + _pt1List.Add(CSng(line(3))) Else - LPT1.Add(0) + _pt1List.Add(0) End If 'Line-counter up (was reset in ResetMe) - iDim += 1 + lineCount += 1 Loop Catch ex As Exception - If ShowMsg Then _ - WorkerMsg(MessageType.Err, "Error during file read! Line number: " & iDim + 1 & " (" & sFilePath & ")", MsgSrc, sFilePath) + If showMsg Then _ + WorkerMsg(MessageType.Err, "Error during file read! Line number: " & lineCount + 1 & " (" & FilePath & ")", msgSrc, + FilePath) GoTo lbEr End Try @@ -193,29 +154,32 @@ lbEr: ''' <param name="nU">engine speed [1/min]</param> ''' <returns>stationary full load power [kW]</returns> ''' <remarks></remarks> - Public Function Pfull(ByVal nU As Single) As Single + Public Function Pfull(nU As Single) As Single Dim i As Int32 'Extrapolation for x < x(1) - If LnU(0) >= nU Then + If EngineSpeedList(0) >= nU Then 'If LnU(0) > nU Then MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" i = 1 GoTo lbInt End If i = 0 - Do While LnU(i) < nU And i < iDim + Do While EngineSpeedList(i) < nU And i < EngineSpeedList.Count - 1 i += 1 Loop 'Extrapolation for x > x(imax) - If LnU(i) < nU Then + If EngineSpeedList(i) < nU Then 'MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" End If lbInt: 'Interpolation - Return nMtoPe(nU, (nU - LnU(i - 1)) * (LTq(i) - LTq(i - 1)) / (LnU(i) - LnU(i - 1)) + LTq(i - 1)) + Return _ + nMtoPe(nU, + (nU - EngineSpeedList(i - 1)) * (MaxTorqueList(i) - MaxTorqueList(i - 1)) / + (EngineSpeedList(i) - EngineSpeedList(i - 1)) + MaxTorqueList(i - 1)) End Function ''' <summary> @@ -224,274 +188,154 @@ lbInt: ''' <param name="nU">engine speed [1/min]</param> ''' <returns>stationary full load torque [Nm]</returns> ''' <remarks></remarks> - Public Function Tq(ByVal nU As Single) As Single + Private Function Torque(ByVal nU As Single) As Single Dim i As Int32 'Extrapolation for x < x(1) - If LnU(0) >= nU Then + If EngineSpeedList(0) >= nU Then 'If LnU(0) > nU Then MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" i = 1 GoTo lbInt End If i = 0 - Do While LnU(i) < nU And i < iDim + Do While EngineSpeedList(i) < nU And i < EngineSpeedList.Count - 1 i += 1 Loop 'Extrapolation for x > x(imax) - If LnU(i) < nU Then + If EngineSpeedList(i) < nU Then 'MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" End If lbInt: 'Interpolation - Return (nU - LnU(i - 1)) * (LTq(i) - LTq(i - 1)) / (LnU(i) - LnU(i - 1)) + LTq(i - 1) - End Function - - ''' <summary> - ''' Calculates and returns Npref [1/min]. Speed at 51% torque/speed-integral between idling and N95h. Defined in Init. - ''' </summary> - ''' <returns>Npref [1/min]</returns> - ''' <remarks></remarks> - Public Function fNpref(ByVal Nidle As Single) As Single - Dim i As Integer - Dim Amax As Single - Dim N95h As Single - Dim n As Single - Dim T0 As Single - Dim dn As Single - Dim A As Single - Dim k As Single - - - dn = 0.001 - - N95h = fnUofPfull(0.95 * Pfull(fnUrated), False) - - If N95h < 0 Then Return -1 - - Amax = Area(Nidle, N95h) - - For i = 0 To iDim - 1 - - If Area(Nidle, LnU(i + 1)) > 0.51 * Amax Then - - n = LnU(i) - T0 = LTq(i) - A = Area(Nidle, n) - - k = (LTq(i + 1) - LTq(i)) / (LnU(i + 1) - LnU(i)) - - Do While A < 0.51 * Amax - n += dn - A += dn * (2 * T0 + k * dn) / 2 - Loop - - Exit For - - End If - - Next - - Return n + Return _ + (nU - EngineSpeedList(i - 1)) * (MaxTorqueList(i) - MaxTorqueList(i - 1)) / (EngineSpeedList(i) - EngineSpeedList(i - 1)) + + MaxTorqueList(i - 1) End Function - ''' <summary> - ''' Calculates torque/speed-integral between two engine speed limits. Used for Npref. - ''' </summary> - ''' <param name="nFrom">lower engine speed limit [1/min]</param> - ''' <param name="nTo">upper engine speed limit [1/min]</param> - ''' <returns>torque/speed-integral between nFrom and nTo [Nm/min]</returns> - ''' <remarks></remarks> - Private Function Area(ByVal nFrom As Single, ByVal nTo As Single) As Single - Dim A As Single - Dim i As Integer - - - A = 0 - For i = 1 To iDim - - If LnU(i - 1) >= nTo Then Exit For - - If LnU(i - 1) >= nFrom Then - - - If LnU(i) <= nTo Then - - 'Add full segment - A += (LnU(i) - LnU(i - 1)) * (LTq(i) + LTq(i - 1)) / 2 - - Else - - 'Add segment till nTo - A += (nTo - LnU(i - 1)) * (Tq(nTo) + LTq(i - 1)) / 2 - - End If - - Else - - If LnU(i) > nFrom Then - - 'Add segment starting from nFrom - A += (LnU(i) - nFrom) * (LTq(i) + Tq(nFrom)) / 2 - - End If - - End If - - Next - - Return A - End Function + ' ''' <summary> + ' ''' Calculates and returns Npref [1/min]. Speed at 51% torque/speed-integral between idling and N95h. Defined in Init. + ' ''' </summary> + ' ''' <returns>Npref [1/min]</returns> + ' ''' <remarks></remarks> + ' Public Function fNpref(ByVal Nidle As Single) As Single + ' Dim i As Integer + ' Dim Amax As Single + ' Dim N95h As Single + ' Dim n As Single + ' Dim T0 As Single + ' Dim dn As Single + ' Dim A As Single + ' Dim k As Single + ' + ' + ' dn = 0.001 + ' + ' N95h = fnUofPfull(0.95 * Pfull(fnUrated), False) + ' + ' If N95h < 0 Then Return -1 + ' + ' Amax = Area(Nidle, N95h) + ' + ' For i = 0 To iDim - 1 + ' + ' If Area(Nidle, LnU(i + 1)) > 0.51 * Amax Then + ' + ' n = LnU(i) + ' T0 = LTq(i) + ' A = Area(Nidle, n) + ' + ' k = (LTq(i + 1) - LTq(i)) / (LnU(i + 1) - LnU(i)) + ' + ' Do While A < 0.51 * Amax + ' n += dn + ' A += dn * (2 * T0 + k * dn) / 2 + ' Loop + ' + ' Exit For + ' + ' End If + ' + ' Next + ' + ' Return n + ' End Function + + ' ''' <summary> + ' ''' Calculates torque/speed-integral between two engine speed limits. Used for Npref. + ' ''' </summary> + ' ''' <param name="nFrom">lower engine speed limit [1/min]</param> + ' ''' <param name="nTo">upper engine speed limit [1/min]</param> + ' ''' <returns>torque/speed-integral between nFrom and nTo [Nm/min]</returns> + ' ''' <remarks></remarks> + ' Private Function Area(ByVal nFrom As Single, ByVal nTo As Single) As Single + ' Dim A As Single + ' Dim i As Integer + ' + ' + ' A = 0 + ' For i = 1 To iDim + ' + ' If LnU(i - 1) >= nTo Then Exit For + ' + ' If LnU(i - 1) >= nFrom Then + ' + ' + ' If LnU(i) <= nTo Then + ' + ' 'Add full segment + ' A += (LnU(i) - LnU(i - 1)) * (LTq(i) + LTq(i - 1)) / 2 + ' + ' Else + ' + ' 'Add segment till nTo + ' A += (nTo - LnU(i - 1)) * (Tq(nTo) + LTq(i - 1)) / 2 + ' + ' End If + ' + ' Else + ' + ' If LnU(i) > nFrom Then + ' + ' 'Add segment starting from nFrom + ' A += (LnU(i) - nFrom) * (LTq(i) + Tq(nFrom)) / 2 + ' + ' End If + ' + ' End If + ' + ' Next + ' + ' Return A + ' End Function ''' <summary> ''' Calculates and returns engine speed at maximum power [1/min]. ''' </summary> ''' <returns>engine speed at maximum power [1/min]</returns> ''' <remarks></remarks> - Public Function fnUrated() As Single - Dim PeMax As Single - Dim nU As Single - Dim nUmax As Single - Dim nUrated As Single - Dim dnU As Single - Dim P As Single - - dnU = 1 - PeMax = 0 - nU = LnU(0) - nUmax = LnU(iDim) - nUrated = nU + Public Function EngineRatedSpeed() As Single + + Dim stepSize As Single = 1 + Dim maxPower As Single = 0 + Dim rpm As Single = EngineSpeedList(0) + Dim maxSpeed As Single = EngineSpeedList.Last() + Dim ratedSpeed As Single = rpm Do - P = nMtoPe(nU, Tq(nU)) - If P > PeMax Then - PeMax = P - nUrated = nU + Dim power As Single = nMtoPe(rpm, Torque(rpm)) + If power > maxPower Then + maxPower = power + ratedSpeed = rpm End If - nU += dnU - Loop Until nU > nUmax - - Return nUrated - End Function - - ''' <summary> - ''' Calculates and returns lowest or highest engine speed at given full load power [1/min]. - ''' </summary> - ''' <param name="PeTarget">full load power [kW]</param> - ''' <param name="FromLeft">True= lowest engine speed; False= highest engine speed</param> - ''' <returns>lowest or highest engine speed at given full load power [1/min]</returns> - ''' <remarks></remarks> - Public Function fnUofPfull(ByVal PeTarget As Single, ByVal FromLeft As Boolean) As Single - Dim Pe As Single - Dim LastPe As Single - Dim nU As Single - Dim nUmin As Single - Dim nUmax As Single - Dim nUtarget As Single - Dim dnU As Single - - dnU = 1 - nUmin = LnU(0) - nUmax = LnU(iDim) - - If FromLeft Then - - nU = nUmin - LastPe = nMtoPe(nU, Tq(nU)) - nUtarget = nU - - If LastPe > PeTarget Then Return -1 - - Do - Pe = nMtoPe(nU, Tq(nU)) - - If Pe > PeTarget Then - If Math.Abs(LastPe - PeTarget) < Math.Abs(Pe - PeTarget) Then - Return nU - dnU - Else - Return nU - End If - End If - - LastPe = Pe - nU += dnU - Loop Until nU > nUmax - - Else - - nU = nUmax - LastPe = nMtoPe(nU, Tq(nU)) - nUtarget = nU - - If LastPe > PeTarget Then Return -1 - - Do - Pe = nMtoPe(nU, Tq(nU)) - - If Pe > PeTarget Then - If Math.Abs(LastPe - PeTarget) < Math.Abs(Pe - PeTarget) Then - Return nU + dnU - Else - Return nU - End If - End If + rpm += stepSize + Loop Until rpm > maxSpeed - LastPe = Pe - nU -= dnU - Loop Until nU < nUmin - - End If - - Return nUtarget + Return ratedSpeed End Function - Public Function Init(ByVal Nidle As Single) As Boolean - Dim Pmax As Single - Dim MsgSrc As String - - MsgSrc = "Main/ReadInp/Eng.Init" - - Pmax = Pfull(fnUrated) - - Nlo = fnUofPfull(0.55 * Pmax, True) - - If Nlo < 0 Then - WorkerMsg(MessageType.Err, "Failed to calculate Nlo! Expand full load curve!", MsgSrc) - Return False - End If - - N95h = fnUofPfull(0.95 * Pmax, False) - - If N95h < 0 Then - WorkerMsg(MessageType.Err, "Failed to calculate N95h! Expand full load curve!", MsgSrc) - Return False - End If - - N80h = fnUofPfull(0.8 * Pmax, False) - - If N80h < 0 Then - WorkerMsg(MessageType.Err, "Failed to calculate N80h! Expand full load curve!", MsgSrc) - Return False - End If - - Npref = fNpref(Nidle) - - If Npref < 0 Then - WorkerMsg(MessageType.Err, "Failed to calculate Npref! Expand full load curve!", MsgSrc) - Return False - End If - - Nhi = fnUofPfull(0.7 * Pmax, False) - - If Nhi < 0 Then - WorkerMsg(MessageType.Err, "Failed to calculate Nhi! Expand full load curve!", MsgSrc) - Return False - End If - - Return True - End Function ''' <summary> ''' Get or set Filepath before calling ReadFile @@ -499,12 +343,5 @@ lbInt: ''' <value></value> ''' <returns>Full filepath</returns> ''' <remarks></remarks> - Public Property FilePath() As String - Get - Return sFilePath - End Get - Set(ByVal value As String) - sFilePath = value - End Set - End Property + Public Property FilePath As String End Class diff --git a/VECTO/Input Files/FuelconsumptionMap.vb b/VECTO/Input Files/FuelconsumptionMap.vb index 2b1e55b2fc..2989b09df6 100644 --- a/VECTO/Input Files/FuelconsumptionMap.vb +++ b/VECTO/Input Files/FuelconsumptionMap.vb @@ -25,29 +25,24 @@ Public Class FuelconsumptionMap _angularSpeedList = Nothing End Sub - Public Function ReadFile(Optional ByVal ShowMsg As Boolean = True) As Boolean - Dim file As CsvFile - Dim line As String() - Dim nU As Double - Dim MsgSrc As String + Public Function ReadFile(Optional ByVal showMsg As Boolean = True) As Boolean - - MsgSrc = "Main/ReadInp/MAP" + Const msgSrc As String = "Main/ReadInp/MAP" 'Reset ResetMe() 'Stop if there's no file If _filePath = "" OrElse Not IO.File.Exists(_filePath) Then - If ShowMsg Then WorkerMsg(MessageType.Err, "Map file not found! (" & _filePath & ")", MsgSrc) + If showMsg Then WorkerMsg(MessageType.Err, "Map file not found! (" & _filePath & ")", msgSrc) Return False End If 'Open file - file = New CsvFile + Dim file As CsvFile = New CsvFile If Not file.OpenRead(_filePath) Then - If ShowMsg Then WorkerMsg(MessageType.Err, "Failed to open file (" & _filePath & ") !", MsgSrc) + If showMsg Then WorkerMsg(MessageType.Err, "Failed to open file (" & _filePath & ") !", msgSrc) Return False End If @@ -65,15 +60,15 @@ Public Class FuelconsumptionMap Do While Not file.EndOfFile 'Line read - line = file.ReadLine + Dim line As String() = file.ReadLine 'Line counter up (was reset in ResetMe) lineCount += 1 'Revolutions - nU = CDbl(line(0)) + Dim rpm As Double = CDbl(line(0)) - _angularSpeedList.Add(nU) + _angularSpeedList.Add(rpm) 'Power _torqueList.Add(line(1)) @@ -82,7 +77,7 @@ Public Class FuelconsumptionMap 'Check sign If CSng(line(2)) < 0 Then file.Close() - If ShowMsg Then WorkerMsg(MessageType.Err, "FC < 0 in map at " & nU & " [1/min], " & line(1) & " [Nm]", MsgSrc) + If showMsg Then WorkerMsg(MessageType.Err, "FC < 0 in map at " & rpm & " [1/min], " & line(1) & " [Nm]", msgSrc) Return False End If @@ -92,8 +87,8 @@ Public Class FuelconsumptionMap Loop Catch ex As Exception - If ShowMsg Then _ - WorkerMsg(MessageType.Err, "Error during file read! Line number " & lineCount + 1 & " (" & _filePath & ")", MsgSrc, + If showMsg Then _ + WorkerMsg(MessageType.Err, "Error during file read! Line number " & lineCount + 1 & " (" & _filePath & ")", msgSrc, _filePath) GoTo lbEr diff --git a/VECTO/Input Files/Gearbox.vb b/VECTO/Input Files/Gearbox.vb index 3f8bfd83dd..bb60b420ba 100644 --- a/VECTO/Input Files/Gearbox.vb +++ b/VECTO/Input Files/Gearbox.vb @@ -25,12 +25,11 @@ Public Class Gearbox Public GbxInertia As Single Public TracIntrSi As Single - Public Igetr As List(Of Single) - Public GetrMaps As List(Of SubPath) - 'Public IsTCgear As List(Of Boolean) + Public GearRatios As List(Of Single) + Public GearLossmaps As List(Of SubPath) 'Gear shift polygons - Public gs_files As List(Of SubPath) + Public GearshiftFiles As List(Of SubPath) Public MaxTorque As List(Of String) @@ -47,15 +46,15 @@ Public Class Gearbox 'Torque Converter Input Public TorqueConverterEnabled As Boolean Public TorqueConverterReferenceRpm As Single - Private ReadOnly TorqueConverterFile As New SubPath + Private ReadOnly _torqueConverterFile As New SubPath Public TorqueConverterInertia As Single + Public TorqueConverterShiftPolygonFile As String Public SavedInDeclMode As Boolean Public UpshiftMinAcceleration As Single Public DownshiftAfterUpshift As Single Public UpshiftAfterDownshift As Single - Public TCshiftFile As String Public Sub New() @@ -70,9 +69,9 @@ Public Class Gearbox GbxInertia = 0 TracIntrSi = 0 - Igetr = New List(Of Single) - GetrMaps = New List(Of SubPath) - gs_files = New List(Of SubPath) + GearRatios = New List(Of Single) + GearLossmaps = New List(Of SubPath) + GearshiftFiles = New List(Of SubPath) MaxTorque = New List(Of String) TorqueResv = 0 @@ -87,7 +86,7 @@ Public Class Gearbox TorqueConverterEnabled = False TorqueConverterReferenceRpm = 0 - TorqueConverterFile.Clear() + _torqueConverterFile.Clear() TorqueConverterInertia = 0 @@ -96,174 +95,171 @@ Public Class Gearbox Public Function SaveFile() As Boolean Dim i As Integer - Dim JSON As New JSONParser - Dim dic As Dictionary(Of String, Object) - Dim dic0 As Dictionary(Of String, Object) - Dim ls As List(Of Object) + Dim writer As New JSONParser + Dim content As Dictionary(Of String, Object) 'Header - dic = New Dictionary(Of String, Object) - dic.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") - dic.Add("Date", Now.ToUniversalTime().ToString("o")) - dic.Add("AppVersion", VECTOvers) - dic.Add("FileVersion", FormatVersion) - JSON.Content.Add("Header", dic) + content = New Dictionary(Of String, Object) + content.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") + content.Add("Date", Now.ToUniversalTime().ToString("o")) + content.Add("AppVersion", VECTOvers) + content.Add("FileVersion", FormatVersion) + writer.Content.Add("Header", content) 'Body - dic = New Dictionary(Of String, Object) + content = New Dictionary(Of String, Object) - dic.Add("SavedInDeclMode", Cfg.DeclMode) + content.Add("SavedInDeclMode", Cfg.DeclMode) SavedInDeclMode = Cfg.DeclMode - dic.Add("ModelName", ModelName) + content.Add("ModelName", ModelName) - dic.Add("Inertia", GbxInertia) - dic.Add("TracInt", TracIntrSi) + content.Add("Inertia", GbxInertia) + content.Add("TracInt", TracIntrSi) - ls = New List(Of Object) - For i = 0 To Igetr.Count - 1 - dic0 = New Dictionary(Of String, Object) - dic0.Add("Ratio", Igetr(i)) - If IsNumeric(GetrMap(i, True)) Then - dic0.Add("Efficiency", GetrMaps(i).PathOrDummy) + Dim ls As New List(Of Object) + For i = 0 To GearRatios.Count - 1 + Dim gearDict As New Dictionary(Of String, Object) + gearDict.Add("Ratio", GearRatios(i)) + If IsNumeric(GearLossMap(i, True)) Then + gearDict.Add("Efficiency", GearLossmaps(i).PathOrDummy) Else - dic0.Add("LossMap", GetrMaps(i).PathOrDummy) + gearDict.Add("LossMap", GearLossmaps(i).PathOrDummy) End If If i > 0 Then - dic0.Add("ShiftPolygon", gs_files(i).PathOrDummy) - dic0.Add("MaxTorque", MaxTorque(i)) + gearDict.Add("ShiftPolygon", GearshiftFiles(i).PathOrDummy) + gearDict.Add("MaxTorque", MaxTorque(i)) End If - ls.Add(dic0) + ls.Add(gearDict) Next - dic.Add("Gears", ls) + content.Add("Gears", ls) - dic.Add("TqReserve", TorqueResv) - dic.Add("SkipGears", SkipGears) - dic.Add("ShiftTime", ShiftTime) - dic.Add("EaryShiftUp", ShiftInside) + content.Add("TqReserve", TorqueResv) + content.Add("SkipGears", SkipGears) + content.Add("ShiftTime", ShiftTime) + content.Add("EaryShiftUp", ShiftInside) - dic.Add("StartTqReserve", TorqueResvStart) - dic.Add("StartSpeed", StartSpeed) - dic.Add("StartAcc", StartAcc) + content.Add("StartTqReserve", TorqueResvStart) + content.Add("StartSpeed", StartSpeed) + content.Add("StartAcc", StartAcc) - dic.Add("GearboxType", Type) + content.Add("GearboxType", Type) - dic0 = New Dictionary(Of String, Object) - dic0.Add("Enabled", TorqueConverterEnabled) - dic0.Add("File", TorqueConverterFile.PathOrDummy) - dic0.Add("RefRPM", TorqueConverterReferenceRpm) - dic0.Add("Inertia", TorqueConverterInertia) - dic0.Add("ShiftPolygon", TCshiftFile) - dic.Add("TorqueConverter", dic0) + Dim torqueConverterDict As New Dictionary(Of String, Object) + torqueConverterDict.Add("Enabled", TorqueConverterEnabled) + torqueConverterDict.Add("File", _torqueConverterFile.PathOrDummy) + torqueConverterDict.Add("RefRPM", TorqueConverterReferenceRpm) + torqueConverterDict.Add("Inertia", TorqueConverterInertia) + torqueConverterDict.Add("ShiftPolygon", TorqueConverterShiftPolygonFile) + content.Add("TorqueConverter", torqueConverterDict) - dic.Add("DownshiftAferUpshiftDelay", DownshiftAfterUpshift) - dic.Add("UpshiftAfterDownshiftDelay", UpshiftAfterDownshift) - dic.Add("UpshiftMinAcceleration", UpshiftMinAcceleration) + content.Add("DownshiftAferUpshiftDelay", DownshiftAfterUpshift) + content.Add("UpshiftAfterDownshiftDelay", UpshiftAfterDownshift) + content.Add("UpshiftMinAcceleration", UpshiftMinAcceleration) - JSON.Content.Add("Body", dic) + writer.Content.Add("Body", content) - Return JSON.WriteFile(_filePath) + Return writer.WriteFile(_filePath) End Function - Public Function ReadFile(Optional ByVal ShowMsg As Boolean = True) As Boolean + Public Function ReadFile(Optional ByVal showMsg As Boolean = True) As Boolean Dim i As Integer - Dim MsgSrc As String - Dim JSON As New JSONParser + Dim parser As New JSONParser Dim dic As Object - MsgSrc = "GBX/ReadFile" + Const msgSrc As String = "GBX/ReadFile" SetDefault() - If Not JSON.ReadFile(_filePath) Then Return False + If Not parser.ReadFile(_filePath) Then Return False Try - _fileVersion = JSON.Content("Header")("FileVersion") + _fileVersion = parser.Content("Header")("FileVersion") If _fileVersion > 3 Then - SavedInDeclMode = JSON.Content("Body")("SavedInDeclMode") + SavedInDeclMode = parser.Content("Body")("SavedInDeclMode") Else SavedInDeclMode = Cfg.DeclMode End If - ModelName = JSON.Content("Body")("ModelName") - GbxInertia = JSON.Content("Body")("Inertia") - TracIntrSi = JSON.Content("Body")("TracInt") + ModelName = parser.Content("Body")("ModelName") + GbxInertia = parser.Content("Body")("Inertia") + TracIntrSi = parser.Content("Body")("TracInt") i = -1 - For Each dic In JSON.Content("Body")("Gears") + For Each dic In parser.Content("Body")("Gears") i += 1 - Igetr.Add(dic("Ratio")) - GetrMaps.Add(New SubPath) + GearRatios.Add(dic("Ratio")) + GearLossmaps.Add(New SubPath) If dic("Efficiency") Is Nothing Then - GetrMaps(i).Init(_myPath, dic("LossMap")) + GearLossmaps(i).Init(_myPath, dic("LossMap")) Else - GetrMaps(i).Init(_myPath, dic("Efficiency")) + GearLossmaps(i).Init(_myPath, dic("Efficiency")) End If MaxTorque.Add(dic("MaxTorque")) - gs_files.Add(New SubPath) + GearshiftFiles.Add(New SubPath) If i = 0 Then - gs_files(i).Init(_myPath, sKey.NoFile) + GearshiftFiles(i).Init(_myPath, sKey.NoFile) Else If _fileVersion < 2 Then - gs_files(i).Init(_myPath, JSON.Content("Body")("ShiftPolygons")) + GearshiftFiles(i).Init(_myPath, parser.Content("Body")("ShiftPolygons")) Else - gs_files(i).Init(_myPath, dic("ShiftPolygon")) + GearshiftFiles(i).Init(_myPath, dic("ShiftPolygon")) End If End If Next - TorqueResv = JSON.Content("Body")("TqReserve") - SkipGears = JSON.Content("Body")("SkipGears") - ShiftTime = JSON.Content("Body")("ShiftTime") - TorqueResvStart = JSON.Content("Body")("StartTqReserve") - StartSpeed = JSON.Content("Body")("StartSpeed") - StartAcc = JSON.Content("Body")("StartAcc") - ShiftInside = JSON.Content("Body")("EaryShiftUp") + TorqueResv = parser.Content("Body")("TqReserve") + SkipGears = parser.Content("Body")("SkipGears") + ShiftTime = parser.Content("Body")("ShiftTime") + TorqueResvStart = parser.Content("Body")("StartTqReserve") + StartSpeed = parser.Content("Body")("StartSpeed") + StartAcc = parser.Content("Body")("StartAcc") + ShiftInside = parser.Content("Body")("EaryShiftUp") - Type = JSON.Content("Body")("GearboxType").ToString.ParseEnum(Of GearboxType)() + Type = parser.Content("Body")("GearboxType").ToString.ParseEnum(Of GearboxType)() - If JSON.Content("Body")("UpshiftMinAcceleration") Is Nothing Then + If parser.Content("Body")("UpshiftMinAcceleration") Is Nothing Then UpshiftMinAcceleration = 0.1 Else - UpshiftMinAcceleration = JSON.Content("Body")("UpshiftMinAcceleration") + UpshiftMinAcceleration = parser.Content("Body")("UpshiftMinAcceleration") End If - If JSON.Content("Body")("DownshiftAferUpshiftDelay") Is Nothing Then + If parser.Content("Body")("DownshiftAferUpshiftDelay") Is Nothing Then DownshiftAfterUpshift = 10 Else - DownshiftAfterUpshift = JSON.Content("Body")("DownshiftAferUpshiftDelay") + DownshiftAfterUpshift = parser.Content("Body")("DownshiftAferUpshiftDelay") End If - If JSON.Content("Body")("UpshiftAfterDownshiftDelay") Is Nothing Then + If parser.Content("Body")("UpshiftAfterDownshiftDelay") Is Nothing Then UpshiftAfterDownshift = 10 Else - UpshiftAfterDownshift = JSON.Content("Body")("UpshiftAfterDownshiftDelay") + UpshiftAfterDownshift = parser.Content("Body")("UpshiftAfterDownshiftDelay") End If - If JSON.Content("Body")("TorqueConverter") Is Nothing Then + If parser.Content("Body")("TorqueConverter") Is Nothing Then TorqueConverterEnabled = False Else - TorqueConverterEnabled = JSON.Content("Body")("TorqueConverter")("Enabled") - TorqueConverterFile.Init(_myPath, JSON.Content("Body")("TorqueConverter")("File")) - TorqueConverterReferenceRpm = JSON.Content("Body")("TorqueConverter")("RefRPM") + TorqueConverterEnabled = parser.Content("Body")("TorqueConverter")("Enabled") + _torqueConverterFile.Init(_myPath, parser.Content("Body")("TorqueConverter")("File")) + TorqueConverterReferenceRpm = parser.Content("Body")("TorqueConverter")("RefRPM") If _fileVersion > 2 Then - TorqueConverterInertia = JSON.Content("Body")("TorqueConverter")("Inertia") + TorqueConverterInertia = parser.Content("Body")("TorqueConverter")("Inertia") End If If _fileVersion > 5 Then - TCshiftFile = JSON.Content("Body")("TorqueConverter")("ShiftPolygon") + TorqueConverterShiftPolygonFile = parser.Content("Body")("TorqueConverter")("ShiftPolygon") End If End If Catch ex As Exception - If ShowMsg Then WorkerMsg(MessageType.Err, "Failed to read VECTO file! " & ex.Message, MsgSrc) + If showMsg Then WorkerMsg(MessageType.Err, "Failed to read VECTO file! " & ex.Message, msgSrc) Return False End Try @@ -272,7 +268,7 @@ Public Class Gearbox Public Function GearCount() As Integer - Return Igetr.Count - 1 + Return GearRatios.Count - 1 End Function @@ -290,42 +286,43 @@ Public Class Gearbox End Set End Property - Public Property GetrMap(ByVal x As Short, Optional ByVal Original As Boolean = False) As String + Public Property GearLossMap(ByVal gearNr As Short, Optional ByVal original As Boolean = False) As String Get If Original Then - Return GetrMaps(x).OriginalPath + Return GearLossmaps(gearNr).OriginalPath Else - Return GetrMaps(x).FullPath + Return GearLossmaps(gearNr).FullPath End If End Get Set(ByVal value As String) - GetrMaps(x).Init(_myPath, value) + GearLossmaps(gearNr).Init(_myPath, value) End Set End Property - Public Property gsFile(ByVal x As Short, Optional ByVal Original As Boolean = False) As String + Public Property ShiftPolygonFile(ByVal gearNr As Short, Optional ByVal original As Boolean = False) As String Get - If Original Then - Return gs_files(x).OriginalPath + If original Then + Return GearshiftFiles(gearNr).OriginalPath Else - Return gs_files(x).FullPath + Return GearshiftFiles(gearNr).FullPath End If End Get Set(value As String) - gs_files(x).Init(_myPath, value) + GearshiftFiles(gearNr).Init(_myPath, value) End Set End Property - Public Property TCfile(Optional ByVal Original As Boolean = False) As String + Public Property TorqueConverterFile(Optional ByVal original As Boolean = False) As String Get If Original Then - Return TorqueConverterFile.OriginalPath + Return _torqueConverterFile.OriginalPath Else - Return TorqueConverterFile.FullPath + Return _torqueConverterFile.FullPath End If End Get Set(value As String) - TorqueConverterFile.Init(_myPath, value) + _torqueConverterFile.Init(_myPath, value) End Set End Property End Class + diff --git a/VECTO/Input Files/VectoJob.vb b/VECTO/Input Files/VectoJob.vb index bac43a76bb..d67674d414 100644 --- a/VECTO/Input Files/VectoJob.vb +++ b/VECTO/Input Files/VectoJob.vb @@ -30,14 +30,14 @@ Public Class VectoJob Private _myPath As String 'Input parameters - Private ReadOnly _stPathVeh As SubPath - Private ReadOnly _stPathEng As SubPath - Private ReadOnly _stPathGbx As SubPath + Private ReadOnly _vehicleFile As SubPath + Private ReadOnly _engineFile As SubPath + Private ReadOnly _gearboxFile As SubPath - Private _boStartStop As Boolean - Private _siStStV As Single - Private _siStStT As Single - Public StStDelay As Integer + Private _startStop As Boolean + Private _startStopMaxSpeed As Single + Private _startStopMinTime As Single + Public StartStopDelay As Integer Private ReadOnly _driverAccelerationFile As SubPath @@ -46,7 +46,7 @@ Public Class VectoJob Public ReadOnly CycleFiles As List(Of SubPath) - Public EngOnly As Boolean + Public EngineOnly As Boolean Public VMin As Single Public LookAheadOn As Boolean @@ -72,9 +72,9 @@ Public Class VectoJob _myPath = "" _sFilePath = "" - _stPathVeh = New SubPath - _stPathEng = New SubPath - _stPathGbx = New SubPath + _vehicleFile = New SubPath + _engineFile = New SubPath + _gearboxFile = New SubPath _driverAccelerationFile = New SubPath @@ -100,9 +100,9 @@ Public Class VectoJob SavedInDeclMode = Cfg.DeclMode 'Main Files - dic0.Add("VehicleFile", _stPathVeh.PathOrDummy) - dic0.Add("EngineFile", _stPathEng.PathOrDummy) - dic0.Add("GearboxFile", _stPathGbx.PathOrDummy) + dic0.Add("VehicleFile", _vehicleFile.PathOrDummy) + dic0.Add("EngineFile", _engineFile.PathOrDummy) + dic0.Add("GearboxFile", _gearboxFile.PathOrDummy) 'Cycles If CycleFiles.Count > 0 Then @@ -125,12 +125,12 @@ Public Class VectoJob End If dic0.Add("VACC", _driverAccelerationFile.PathOrDummy) - dic0.Add("EngineOnlyMode", EngOnly) + dic0.Add("EngineOnlyMode", EngineOnly) dic0.Add("StartStop", New Dictionary(Of String, Object) From { - {"Enabled", _boStartStop}, - {"MaxSpeed", _siStStV}, - {"MinTime", _siStStT}, - {"Delay", StStDelay}}) + {"Enabled", _startStop}, + {"MaxSpeed", _startStopMaxSpeed}, + {"MinTime", _startStopMinTime}, + {"Delay", StartStopDelay}}) dic0.Add("LAC", New Dictionary(Of String, Object) From { {"Enabled", LookAheadOn}, {"PreviewDistanceFactor", LacPreviewFactor}, @@ -177,12 +177,12 @@ Public Class VectoJob End If If Not body("VehicleFile") Is Nothing Then _ - _stPathVeh.Init(_myPath, body("VehicleFile")) + _vehicleFile.Init(_myPath, body("VehicleFile")) - _stPathEng.Init(_myPath, body("EngineFile")) + _engineFile.Init(_myPath, body("EngineFile")) If Not body("GearboxFile") Is Nothing Then _ - _stPathGbx.Init(_myPath, body("GearboxFile")) + _gearboxFile.Init(_myPath, body("GearboxFile")) If Not body("Cycles") Is Nothing Then For Each str As String In body("Cycles") @@ -252,7 +252,8 @@ Public Class VectoJob Else auxEntry.TechStr = "Standard technology - LED headlights, all" End If - WorkerMsg(MessageType.Normal, "Aux: Automatically Upgraded Electric System to new format: '" + auxEntry.TechStr + "'", + WorkerMsg(MessageType.Normal, + "Aux: Automatically Upgraded Electric System to new format: '" + auxEntry.TechStr + "'", msgSrc) End If End If @@ -294,16 +295,16 @@ Public Class VectoJob _driverAccelerationFile.Init(_myPath, body("VACC")) End If - EngOnly = body("EngineOnlyMode") + EngineOnly = body("EngineOnlyMode") If Not body("StartStop") Is Nothing Then Dim dic = body("StartStop") - _boStartStop = dic("Enabled") - _siStStV = dic("MaxSpeed") - _siStStT = dic("MinTime") - StStDelay = dic("Delay") + _startStop = dic("Enabled") + _startStopMaxSpeed = dic("MaxSpeed") + _startStopMinTime = dic("MinTime") + StartStopDelay = dic("Delay") Else - _boStartStop = False + _startStop = False End If If Not body("LAC") Is Nothing Then @@ -335,7 +336,8 @@ Public Class VectoJob EcoRollOn = False Case Else - WorkerMsg(MessageType.Err, "Value '" & dic("Mode").ToString() & "' is not valid for OverSpeedEcoRoll/Mode!", msgSrc) + WorkerMsg(MessageType.Err, "Value '" & dic("Mode").ToString() & "' is not valid for OverSpeedEcoRoll/Mode!", + msgSrc) Return False End Select @@ -365,20 +367,20 @@ Public Class VectoJob AdvancedAuxiliaryFilePath = String.Empty - _boStartStop = False - _siStStV = 5 - _siStStT = 5 - StStDelay = 0 + _startStop = False + _startStopMaxSpeed = 5 + _startStopMinTime = 5 + StartStopDelay = 0 - _stPathVeh.Clear() - _stPathEng.Clear() + _vehicleFile.Clear() + _engineFile.Clear() CycleFiles.Clear() - _stPathGbx.Clear() + _gearboxFile.Clear() _driverAccelerationFile.Clear() AuxPaths.Clear() - EngOnly = False + EngineOnly = False VMin = 0 LookAheadOn = True @@ -414,67 +416,67 @@ Public Class VectoJob Public Property PathVeh(Optional ByVal original As Boolean = False) As String Get If original Then - Return _stPathVeh.OriginalPath + Return _vehicleFile.OriginalPath Else - Return _stPathVeh.FullPath + Return _vehicleFile.FullPath End If End Get Set(value As String) - _stPathVeh.Init(_myPath, value) + _vehicleFile.Init(_myPath, value) End Set End Property Public Property PathEng(Optional ByVal original As Boolean = False) As String Get If original Then - Return _stPathEng.OriginalPath + Return _engineFile.OriginalPath Else - Return _stPathEng.FullPath + Return _engineFile.FullPath End If End Get Set(value As String) - _stPathEng.Init(_myPath, value) + _engineFile.Init(_myPath, value) End Set End Property Public Property PathGbx(Optional ByVal original As Boolean = False) As String Get If original Then - Return _stPathGbx.OriginalPath + Return _gearboxFile.OriginalPath Else - Return _stPathGbx.FullPath + Return _gearboxFile.FullPath End If End Get Set(value As String) - _stPathGbx.Init(_myPath, value) + _gearboxFile.Init(_myPath, value) End Set End Property Public Property StartStop As Boolean Get - Return _boStartStop + Return _startStop End Get Set(value As Boolean) - _boStartStop = value + _startStop = value End Set End Property Public Property StStV As Single Get - Return _siStStV + Return _startStopMaxSpeed End Get Set(value As Single) - _siStStV = value + _startStopMaxSpeed = value End Set End Property Public Property StStT As Single Get - Return _siStStT + Return _startStopMinTime End Get Set(value As Single) - _siStStT = value + _startStopMinTime = value End Set End Property diff --git a/VECTO/Input Files/Vehicle.vb b/VECTO/Input Files/Vehicle.vb index 236bf0dd6b..c4c9b04062 100644 --- a/VECTO/Input Files/Vehicle.vb +++ b/VECTO/Input Files/Vehicle.vb @@ -21,39 +21,34 @@ Imports TUGraz.VectoCommon.Utils Public Class Vehicle 'V2 MassMax is now saved in [t] instead of [kg] Private Const FormatVersion As Short = 7 - Private FileVersion As Short + Private _fileVersion As Short - Private sFilePath As String - Private MyPath As String + Private _filePath As String + Private _path As String Public Mass As Single Public Loading As Single Public CdA0 As Single - Public CdMode As CrossWindCorrectionMode - Public ReadOnly CdFile As SubPath - Private ReadOnly CdX As List(Of Single) - Private ReadOnly CdY As List(Of Single) + Public CrossWindCorrectionMode As CrossWindCorrectionMode + Public ReadOnly CrossWindCorrectionFile As SubPath + Public RetarderType As RetarderType + Public RetarderRatio As Single = 0 + Public ReadOnly RetarderLossMapFile As SubPath - Public RtType As RetarderType 'tRtType '0=None, 1=Primary, 2=Secondary - Public RtRatio As Single = 0 - Public ReadOnly RtFile As SubPath - Private ReadOnly RtnU As List(Of Single) - Private ReadOnly RtM As List(Of Single) - - Public rdyn As Single + Public DynamicTyreRadius As Single Public ReadOnly Axles As List(Of Axle) - Public VehCat As VehicleCategory + Public VehicleCategory As VehicleCategory Public MassExtra As Single Public MassMax As Single - Public AxleConf As AxleConfiguration + Public AxleConfiguration As AxleConfiguration Public SavedInDeclMode As Boolean - Public AngularGearType As AngularGearType '0=None, 1=Separate, 2=Included + Public AngularGearType As AngularGearType Public AngularGearRatio As Single Public ReadOnly AngularGearLossMapFile As SubPath @@ -69,15 +64,13 @@ Public Class Vehicle Public Sub New() - MyPath = "" - sFilePath = "" - CdFile = New SubPath - CdX = New List(Of Single) - CdY = New List(Of Single) - RtFile = New SubPath + _path = "" + _filePath = "" + CrossWindCorrectionFile = New SubPath + + RetarderLossMapFile = New SubPath AngularGearLossMapFile = New SubPath() - RtnU = New List(Of Single) - RtM = New List(Of Single) + Axles = New List(Of Axle) SetDefault() End Sub @@ -89,18 +82,14 @@ Public Class Vehicle CdA0 = 0 ' CdA0Act = CdA0 ' CdA02 = 0 - CdFile.Clear() - CdMode = CrossWindCorrectionMode.NoCorrection - CdX.Clear() - CdY.Clear() - - rdyn = 0 - - RtType = RetarderType.None - RtRatio = 1 - RtnU.Clear() - RtM.Clear() - RtFile.Clear() + CrossWindCorrectionFile.Clear() + CrossWindCorrectionMode = CrossWindCorrectionMode.NoCorrection + + DynamicTyreRadius = 0 + + RetarderType = RetarderType.None + RetarderRatio = 1 + RetarderLossMapFile.Clear() AngularGearLossMapFile.Clear() AngularGearType = AngularGearType.None @@ -108,9 +97,9 @@ Public Class Vehicle AngularGearRatio = 1 Axles.Clear() - VehCat = VehicleCategory.RigidTruck 'tVehCat.Undef + VehicleCategory = VehicleCategory.RigidTruck 'tVehCat.Undef MassMax = 0 - AxleConf = AxleConfiguration.AxleConfig_4x2 'tAxleConf.Undef + AxleConfiguration = AxleConfiguration.AxleConfig_4x2 'tAxleConf.Undef SavedInDeclMode = False End Sub @@ -120,14 +109,14 @@ Public Class Vehicle SetDefault() Dim json As New JSONParser - If Not json.ReadFile(sFilePath) Then Return False + If Not json.ReadFile(_filePath) Then Return False Try Dim header = json.Content("Header") Dim body = json.Content("Body") - FileVersion = header("FileVersion") - If FileVersion > 4 Then + _fileVersion = header("FileVersion") + If _fileVersion > 4 Then SavedInDeclMode = body("SavedInDeclMode") Else SavedInDeclMode = Cfg.DeclMode @@ -136,16 +125,16 @@ Public Class Vehicle Mass = body("CurbWeight") MassExtra = body("CurbWeightExtra") Loading = body("Loading") - VehCat = body("VehCat").ToString.ParseEnum(Of VehicleCategory)() 'ConvVehCat(body("VehCat").ToString) - AxleConf = AxleConfigurationHelper.Parse(body("AxleConfig")("Type").ToString) - If FileVersion < 2 Then + VehicleCategory = body("VehCat").ToString.ParseEnum(Of VehicleCategory)() 'ConvVehCat(body("VehCat").ToString) + AxleConfiguration = AxleConfigurationHelper.Parse(body("AxleConfig")("Type").ToString) + If _fileVersion < 2 Then 'convert kg to ton MassMax /= 1000 Else MassMax = body("MassMax") End If - If FileVersion < 7 Then + If _fileVersion < 7 Then 'calc CdA from Cd and area value CdA0 = CSng(body("Cd")) * CSng(body("CrossSecArea")) Else @@ -154,20 +143,20 @@ Public Class Vehicle 'CdA02 = CdA0 - CdMode = CrossWindCorrectionModeHelper.Parse(body("CdCorrMode").ToString) + CrossWindCorrectionMode = CrossWindCorrectionModeHelper.Parse(body("CdCorrMode").ToString) If Not body("CdCorrFile") Is Nothing Then - CdFile.Init(MyPath, body("CdCorrFile")) + CrossWindCorrectionFile.Init(_path, body("CdCorrFile")) End If If body("Retarder") Is Nothing Then - RtType = RetarderType.None + RetarderType = RetarderType.None Else - RtType = RetarderTypeHelper.Parse(body("Retarder")("Type").ToString) + RetarderType = RetarderTypeHelper.Parse(body("Retarder")("Type").ToString) If Not body("Retarder")("Ratio") Is Nothing Then - RtRatio = body("Retarder")("Ratio") + RetarderRatio = body("Retarder")("Ratio") End If If Not body("Retarder")("File") Is Nothing Then - RtFile.Init(MyPath, body("Retarder")("File")) + RetarderLossMapFile.Init(_path, body("Retarder")("File")) End If End If @@ -179,16 +168,16 @@ Public Class Vehicle AngularGearRatio = body("AngularGear")("Ratio") End If If Not body("AngularGear")("LossMap") Is Nothing Then - AngularGearLossMapFile.Init(MyPath, body("AngularGear")("LossMap")) + AngularGearLossMapFile.Init(_path, body("AngularGear")("LossMap")) End If End If Dim inertiaTemp As Single - If FileVersion < 3 Then + If _fileVersion < 3 Then inertiaTemp = body("WheelsInertia") - rdyn = 1000 * body("WheelsDiaEff") / 2 + DynamicTyreRadius = 1000 * body("WheelsDiaEff") / 2 Else - rdyn = body("rdyn") + DynamicTyreRadius = body("rdyn") End If Dim axleCount = body("AxleConfig")("Axles").Count() @@ -199,7 +188,7 @@ Public Class Vehicle .RRC = CSng(axleEntry("RRCISO")), .FzISO = CSng(axleEntry("FzISO"))} - If FileVersion < 3 Then + If _fileVersion < 3 Then axle.Wheels = "-" axle.Inertia = inertiaTemp / (IIf(axle.TwinTire, 4, 2) * axleCount) Else @@ -232,25 +221,25 @@ Public Class Vehicle Dim dic As Dictionary(Of String, Object) dic = New Dictionary(Of String, Object) From { {"SavedInDeclMode", Cfg.DeclMode}, - {"VehCat", VehCat.ToString()}, + {"VehCat", VehicleCategory.ToString()}, {"CurbWeight", Mass}, {"CurbWeightExtra", MassExtra}, {"Loading", Loading}, {"MassMax", MassMax}, {"CdA", CdA0}, - {"rdyn", rdyn}, - {"CdCorrMode", CdMode.GetName()}, - {"CdCorrFile", CdFile.PathOrDummy}, + {"rdyn", DynamicTyreRadius}, + {"CdCorrMode", CrossWindCorrectionMode.GetName()}, + {"CdCorrFile", CrossWindCorrectionFile.PathOrDummy}, {"Retarder", New Dictionary(Of String, Object) From { - {"Type", RtType.GetName()}, - {"Ratio", RtRatio}, - {"File", RtFile.PathOrDummy}}}, + {"Type", RetarderType.GetName()}, + {"Ratio", RetarderRatio}, + {"File", RetarderLossMapFile.PathOrDummy}}}, {"AngularGear", New Dictionary(Of String, Object) From { {"Type", AngularGearType.ToString()}, {"Ratio", AngularGearRatio}, {"LossMap", AngularGearLossMapFile.PathOrDummy}}}, {"AxleConfig", New Dictionary(Of String, Object) From { - {"Type", AxleConf.GetName()}, + {"Type", AxleConfiguration.GetName()}, {"Axles", (From axle In Axles Select New Dictionary(Of String, Object) From { {"Inertia", axle.Inertia}, {"Wheels", axle.Wheels}, @@ -261,7 +250,7 @@ Public Class Vehicle } json.Content.Add("Body", dic) - Return json.WriteFile(sFilePath) + Return json.WriteFile(_filePath) End Function @@ -270,14 +259,14 @@ Public Class Vehicle Public Property FilePath() As String Get - Return sFilePath + Return _filePath End Get Set(value As String) - sFilePath = value - If sFilePath = "" Then - MyPath = "" + _filePath = value + If _filePath = "" Then + _path = "" Else - MyPath = Path.GetDirectoryName(sFilePath) & "\" + _path = Path.GetDirectoryName(_filePath) & "\" End If End Set End Property diff --git a/VECTO/Input Files/cAdvancedAuxiliary.vb b/VECTO/Input Files/cAdvancedAuxiliary.vb index c38fb317a0..f2d123221e 100644 --- a/VECTO/Input Files/cAdvancedAuxiliary.vb +++ b/VECTO/Input Files/cAdvancedAuxiliary.vb @@ -38,11 +38,11 @@ Public Class cAdvancedAuxiliary _AssemblyName = "CLASSIC" End Sub - Public Sub New(AuxiliaryName As String, AuxiliaryVersion As String, FileName As String, AssemblyName As String) + Public Sub New(auxiliaryName As String, auxiliaryVersion As String, fileName As String, assemblyName As String) - _AuxiliaryName = AuxiliaryName - _AuxiliaryVersion = AuxiliaryVersion - _FileName = FileName - _AssemblyName = AssemblyName + _auxiliaryName = auxiliaryName + _auxiliaryVersion = auxiliaryVersion + _fileName = fileName + _assemblyName = assemblyName End Sub End Class diff --git a/VECTO/MainModule.vb b/VECTO/MainModule.vb index 7ffac9567e..8796e12985 100644 --- a/VECTO/MainModule.vb +++ b/VECTO/MainModule.vb @@ -25,12 +25,12 @@ Module MainModule Dim retVal As CombustionEngineData = New CombustionEngineData() retVal.FullLoadCurve = New TUGraz.VectoCore.Models.SimulationComponent.Data.Engine.EngineFullLoadCurve() retVal.FullLoadCurve.FullLoadEntries = New List(Of FullLoadCurve.FullLoadCurveEntry) - For i As Integer = 0 To fld.LnU.Count - 1 + For i As Integer = 0 To fld.EngineSpeedList.Count - 1 retVal.FullLoadCurve.FullLoadEntries.Add( New FullLoadCurve.FullLoadCurveEntry() _ - With {.EngineSpeed = CType(fld.LnU(i), Double).RPMtoRad(), - .TorqueFullLoad = CType(fld.LTq(i), Double).SI(Of NewtonMeter)(), - .TorqueDrag = CType(fld.LTqDrag(i), Double).SI(Of NewtonMeter)()}) + With {.EngineSpeed = CType(fld.EngineSpeedList(i), Double).RPMtoRad(), + .TorqueFullLoad = CType(fld.MaxTorqueList(i), Double).SI(Of NewtonMeter)(), + .TorqueDrag = CType(fld.DragTorqueList(i), Double).SI(Of NewtonMeter)()}) Next retVal.IdleSpeed = CType(nIdle, Double).RPMtoRad() -- GitLab