diff --git a/VECTO/GUI/EngineForm.vb b/VECTO/GUI/EngineForm.vb index d75f7ea3fd985b06c43c1a35df35b35fb3c324a1..84327c92f89f4bc47a6b1dc849d51c73044a172d 100644 --- a/VECTO/GUI/EngineForm.vb +++ b/VECTO/GUI/EngineForm.vb @@ -1,12 +1,18 @@ Imports System.Drawing.Imaging Imports System.IO +Imports System.Linq Imports System.Text.RegularExpressions Imports System.Windows.Forms.DataVisualization.Charting Imports System.Xml.Linq +Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore.InputData.FileIO.JSON +Imports TUGraz.VectoCore.InputData.Reader Imports TUGraz.VectoCore.Models.Declaration +Imports TUGraz.VectoCore.Models.SimulationComponent.Data +Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine ' Copyright 2014 European Union. ' Licensed under the EUPL (the 'Licence'); ' @@ -52,7 +58,7 @@ Public Class EngineForm If Not Cfg.DeclMode Then Exit Sub - TbInertia.Text = DeclarationData.Engine.EngineInertia((TbDispl.Text.ToDouble() / 1000.0 / 1000.0).SI(Of CubicMeter), + TbInertia.Text = DeclarationData.Engine.EngineInertia((TbDispl.Text.ToDouble(0.0) / 1000.0 / 1000.0).SI(Of CubicMeter), GearboxType.AMT).ToGUIFormat() End Sub @@ -140,21 +146,18 @@ Public Class EngineForm End Sub 'Open VENG file - Public Sub OpenEngineFile(ByVal file As String) - Dim ENG0 As Engine + Public Sub OpenEngineFile(file As String) + Dim engine As IEngineEngineeringInputData If ChangeCheckCancel() Then Exit Sub - ENG0 = New Engine + Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(file), + IEngineeringInputDataProvider) - ENG0.FilePath = file + engine = inputData.EngineInputData - If Not ENG0.ReadFile Then - MsgBox("Cannot read " & file & "!") - Exit Sub - End If - If Cfg.DeclMode <> ENG0.SavedInDeclMode Then + If Cfg.DeclMode <> engine.SavedInDeclarationMode Then Select Case WrongMode() Case 1 Close() @@ -167,16 +170,17 @@ Public Class EngineForm End Select End If - TbName.Text = ENG0.ModelName - TbDispl.Text = ENG0.Displacement.ToString - TbInertia.Text = ENG0.EngineInertia.ToString - TbNleerl.Text = ENG0.IdleSpeed.ToString + Dim basePath As String = Path.GetDirectoryName(file) + TbName.Text = engine.ModelName + TbDispl.Text = (engine.Displacement * 1000 * 1000).ToGUIFormat() + TbInertia.Text = engine.Inertia.ToGUIFormat() + TbNleerl.Text = engine.IdleSpeed.AsRPM.ToGUIFormat() - TbMAP.Text = ENG0.PathMAP(True) - TbFLD.Text = ENG0.PathFLD(True) - TbWHTCurban.Text = ENG0.WHTCurban.ToGUIFormat() - TbWHTCrural.Text = ENG0.WHTCrural.ToGUIFormat() - TbWHTCmw.Text = ENG0.WHTCmw.ToGUIFormat() + TbMAP.Text = GetRelativePath(engine.FuelConsumptionMap.Source, basePath) + TbFLD.Text = GetRelativePath(engine.FullLoadCurve.Source, basePath) + TbWHTCurban.Text = engine.WHTCUrban.ToGUIFormat() + TbWHTCrural.Text = engine.WHTCRural.ToGUIFormat() + TbWHTCmw.Text = engine.WHTCMotorway.ToGUIFormat() DeclInit() @@ -350,31 +354,34 @@ Public Class EngineForm Private Sub UpdatePic() - Dim fldOK As Boolean = False - Dim mapOK As Boolean = False - Dim fullLoadCurve As New EngineFullLoadCurve - Dim fcMap As New FuelconsumptionMap + 'Dim fldOK As Boolean = False + 'Dim mapOK As Boolean = False + Dim fullLoadCurve As FullLoadCurve + Dim fcMap As FuelConsumptionMap Dim chart As Chart - Dim s As Series - Dim a As ChartArea + Dim series As Series + Dim chartArea As ChartArea Dim img As Bitmap + Dim engine As IEngineEngineeringInputData PicBox.Image = Nothing + If Not File.Exists(_engFile) Then Exit Sub + Try 'Read Files - fullLoadCurve.FilePath = fFileRepl(TbFLD.Text, GetPath(_engFile)) - fldOK = fullLoadCurve.ReadFile(False, False) - - fcMap.FilePath = fFileRepl(TbMAP.Text, GetPath(_engFile)) - mapOK = fcMap.ReadFile(False) + Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(_engFile), + IEngineeringInputDataProvider) + engine = inputData.EngineInputData + fullLoadCurve = FullLoadCurveReader.Create(engine.FullLoadCurve, engineFld:=True) + fcMap = FuelConsumptionMapReader.Create(engine.FuelConsumptionMap) Catch ex As Exception End Try - If Not fldOK And Not mapOK Then Exit Sub + If fullLoadCurve Is Nothing OrElse fcMap Is Nothing Then Exit Sub 'Create plot @@ -382,59 +389,59 @@ Public Class EngineForm chart.Width = PicBox.Width chart.Height = PicBox.Height - a = New ChartArea + chartArea = New ChartArea - If fldOK Then - s = New Series - s.Points.DataBindXY(fullLoadCurve.EngineSpeedList, fullLoadCurve.MaxTorqueList) - s.ChartType = SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.DarkBlue - s.Name = "Full load (" & GetFilenameWithoutPath(fullLoadCurve.FilePath, True) & ")" - chart.Series.Add(s) + series = New Series + series.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueFullLoad.Value()).ToArray()) + series.ChartType = SeriesChartType.FastLine + series.BorderWidth = 2 + series.Color = Color.DarkBlue + series.Name = "Full load (" & Path.GetFileNameWithoutExtension(engine.FullLoadCurve.Source) & ")" + chart.Series.Add(series) - s = New Series - s.Points.DataBindXY(fullLoadCurve.EngineSpeedList, fullLoadCurve.DragTorqueList) - s.ChartType = SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.Blue - s.Name = "Motoring (" & GetFilenameWithoutPath(fullLoadCurve.FilePath, True) & ")" - chart.Series.Add(s) + series = New Series + series.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueDrag.Value()).ToArray()) + series.ChartType = SeriesChartType.FastLine + series.BorderWidth = 2 + series.Color = Color.Blue + series.Name = "Motoring (" & Path.GetFileNameWithoutExtension(engine.FullLoadCurve.Source) & ")" + chart.Series.Add(series) - End If - If mapOK Then - s = New Series - s.Points.DataBindXY(fcMap.nU, fcMap.Tq) - s.ChartType = SeriesChartType.Point - s.MarkerSize = 3 - s.Color = Color.Red - s.Name = "Map" - chart.Series.Add(s) - End If + series = New Series + series.Points.DataBindXY(fcMap.Entries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + fcMap.Entries.Select(Function(x) x.Torque.Value()).ToArray()) + series.ChartType = SeriesChartType.Point + series.MarkerSize = 3 + series.Color = Color.Red + series.Name = "Map" + chart.Series.Add(series) + - a.Name = "main" + chartArea.Name = "main" - a.AxisX.Title = "engine speed [1/min]" - a.AxisX.TitleFont = New Font("Helvetica", 10) - a.AxisX.LabelStyle.Font = New Font("Helvetica", 8) - a.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.None - a.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dot + chartArea.AxisX.Title = "engine speed [1/min]" + chartArea.AxisX.TitleFont = New Font("Helvetica", 10) + chartArea.AxisX.LabelStyle.Font = New Font("Helvetica", 8) + chartArea.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.None + chartArea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dot - a.AxisY.Title = "engine torque [Nm]" - a.AxisY.TitleFont = New Font("Helvetica", 10) - a.AxisY.LabelStyle.Font = New Font("Helvetica", 8) - a.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None - a.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot + chartArea.AxisY.Title = "engine torque [Nm]" + chartArea.AxisY.TitleFont = New Font("Helvetica", 10) + chartArea.AxisY.LabelStyle.Font = New Font("Helvetica", 8) + chartArea.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None + chartArea.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot - a.AxisX.Minimum = 300 - a.BorderDashStyle = ChartDashStyle.Solid - a.BorderWidth = 1 + chartArea.AxisX.Minimum = 300 + chartArea.BorderDashStyle = ChartDashStyle.Solid + chartArea.BorderWidth = 1 - a.BackColor = Color.GhostWhite + chartArea.BackColor = Color.GhostWhite - chart.ChartAreas.Add(a) + chart.ChartAreas.Add(chartArea) chart.Update() diff --git a/VECTO/GUI/GearboxForm.vb b/VECTO/GUI/GearboxForm.vb index 16ff1fae24b8e26519933fd2e4eb67a0513d000d..8d1c05b909f8319505b8893b8b49365b372e8fc5 100644 --- a/VECTO/GUI/GearboxForm.vb +++ b/VECTO/GUI/GearboxForm.vb @@ -22,8 +22,10 @@ Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.Configuration Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.InputData.Impl +Imports TUGraz.VectoCore.InputData.Reader Imports TUGraz.VectoCore.Models.Declaration Imports TUGraz.VectoCore.Models.SimulationComponent.Data +Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox ''' <summary> @@ -236,17 +238,20 @@ Public Class GearboxForm End Select End If + Dim basePath As String = Path.GetDirectoryName(file) TbName.Text = gearbox.ModelName TbTracInt.Text = gearbox.TractionInterruption.ToGUIFormat() TBI_getr.Text = gearbox.Inertia.ToGUIFormat() LvGears.Items.Clear() - LvGears.Items.Add(CreateListviewItem("Axle", "-", axlegear.Ratio, axlegear.LossMap.Source, "", "")) + LvGears.Items.Add(CreateListviewItem("Axle", "-", axlegear.Ratio, GetRelativePath(axlegear.LossMap.Source, basePath), + "", "")) For Each gear As ITransmissionInputData In gearbox.Gears LvGears.Items.Add(CreateListviewItem(gear.Gear.ToString("00"), "-", gear.Ratio, gear.LossMap.Source, - gear.ShiftPolygon.Source, If(gear.MaxTorque Is Nothing, "", gear.MaxTorque.ToGUIFormat()))) + GetRelativePath(gear.ShiftPolygon.Source, basePath), + If(gear.MaxTorque Is Nothing, "", gear.MaxTorque.ToGUIFormat()))) Next ChSkipGears.Checked = gearbox.SkipGears @@ -264,10 +269,10 @@ Public Class GearboxForm TbTCinertia.Text = "" TBTCShiftPolygon.Text = "" Else - TbTCfile.Text = torqueConverter.TCData.Source + TbTCfile.Text = GetRelativePath(torqueConverter.TCData.Source, basePath) TbTCrefrpm.Text = torqueConverter.ReferenceRPM.AsRPM.ToGUIFormat() TbTCinertia.Text = torqueConverter.Inertia.ToGUIFormat() - TBTCShiftPolygon.Text = torqueConverter.ShiftPolygon.Source + TBTCShiftPolygon.Text = GetRelativePath(torqueConverter.ShiftPolygon.Source, basePath) End If tbUpshiftMinAcceleration.Text = gearbox.UpshiftMinAcceleration.ToGUIFormat() @@ -688,97 +693,40 @@ Public Class GearboxForm Private Sub UpdatePic() - Dim f As CsvFile Dim path As String - Dim lM As List(Of Single) = Nothing - Dim lup As List(Of Single) = Nothing - Dim ldown As List(Of Single) = Nothing - Dim line As String() + Dim chart As Chart Dim s As Series Dim a As ChartArea Dim img As Bitmap Dim gear As Integer Dim fldOk As Boolean - Dim fldpath As String - Dim fullLoadCurve As EngineFullLoadCurve = Nothing - Dim shiftOk As Boolean + 'Dim fullLoadCurve As EngineFullLoadCurve = Nothing + 'Dim shiftOk As Boolean PicBox.Image = Nothing - Try - - 'Check Files - If LvGears.Items.Count > 1 Then - - If LvGears.SelectedItems.Count > 0 AndAlso LvGears.SelectedIndices(0) > 0 Then - path = fFileRepl(LvGears.SelectedItems(0).SubItems(GearboxTbl.ShiftPolygons).Text, GetPath(GbxFile)) - 'fldpath = fFileRepl(LvGears.SelectedItems(0).SubItems(GearboxTbl.MaxTorque).Text, fPATH(GbxFile)) - gear = LvGears.SelectedIndices(0) - Else - path = fFileRepl(LvGears.Items(1).SubItems(GearboxTbl.ShiftPolygons).Text, GetPath(GbxFile)) - 'fldpath = fFileRepl(Me.LvGears.Items(1).SubItems(GearboxTbl.MaxTorque).Text, fPATH(GbxFile)) - gear = 1 - End If - - f = New CsvFile - shiftOk = f.OpenRead(path) - - fldpath = VectoJobForm.EngineFullLoadFile + Dim shiftPolygon As ShiftPolygon + 'Dim engineFld As FullLoadCurve - fldOk = Not IsNothing(fldpath) AndAlso fldpath.Trim <> "" - - If fldOk Then - fullLoadCurve = New EngineFullLoadCurve - fullLoadCurve.FilePath = fldpath - fldOk = fullLoadCurve.ReadFile(True, False) - End If + If LvGears.Items.Count <= 1 Then Exit Sub + Try + If LvGears.SelectedItems.Count > 0 AndAlso LvGears.SelectedIndices(0) > 0 Then + path = fFileRepl(LvGears.SelectedItems(0).SubItems(GearboxTbl.ShiftPolygons).Text, GetPath(GbxFile)) + gear = LvGears.SelectedIndices(0) Else - - Exit Sub - + path = fFileRepl(LvGears.Items(1).SubItems(GearboxTbl.ShiftPolygons).Text, GetPath(GbxFile)) + gear = 1 End If + shiftPolygon = ShiftPolygonReader.ReadFromFile(path) + Catch ex As Exception - Exit Sub End Try - 'Read ShiftPolygon - If shiftOk Then - - 'Header - f.ReadLine() - - Try - lM = New List(Of Single) - lup = New List(Of Single) - ldown = New List(Of Single) - - Do While Not f.EndOfFile - line = f.ReadLine - lM.Add(CSng(line(0))) - lup.Add(CSng(line(1))) - ldown.Add(CSng(line(2))) - Loop - - f.Close() - - Catch ex As Exception - f.Close() - Exit Sub - End Try - - If lM.Count < 2 Then shiftOk = False - - End If - - - 'Create plot - If Not shiftOk And Not fldOk Then Exit Sub - chart = New Chart chart.Width = PicBox.Width chart.Height = PicBox.Height @@ -786,9 +734,11 @@ Public Class GearboxForm a = New ChartArea 'Shiftpolygons from file - If shiftOk Then + + If Not shiftPolygon Is Nothing Then s = New Series - s.Points.DataBindXY(lup, lM) + s.Points.DataBindXY(shiftPolygon.Upshift.Select(Function(x) x.AngularSpeed.AsRPM).ToArray(), + shiftPolygon.Upshift.Select(Function(x) x.Torque.Value()).ToArray()) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkRed @@ -796,7 +746,8 @@ Public Class GearboxForm chart.Series.Add(s) s = New Series - s.Points.DataBindXY(ldown, lM) + s.Points.DataBindXY(shiftPolygon.Downshift.Select(Function(x) x.AngularSpeed.AsRPM).ToArray(), + shiftPolygon.Downshift.Select(Function(x) x.Torque.Value()).ToArray()) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkRed @@ -810,24 +761,28 @@ Public Class GearboxForm Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(vectoJob.PathVeh(False)), IEngineeringInputDataProvider) Dim vehicle As IVehicleEngineeringInputData = inputData.VehicleInputData + inputData = TryCast(JSONInputDataFactory.ReadComponentData(vectoJob.PathEng(False)), IEngineeringInputDataProvider) + Dim engine As IEngineEngineeringInputData = inputData.EngineInputData + Dim engineFld As EngineFullLoadCurve = EngineFullLoadCurve.Create(engine.FullLoadCurve) 'Fld - If fldOk AndAlso vectoOk AndAlso Not vehicle Is Nothing Then + If vectoOk AndAlso Not vehicle Is Nothing Then s = New Series - s.Points.DataBindXY(fullLoadCurve.EngineSpeedList, fullLoadCurve.MaxTorqueList) + s.Points.DataBindXY(engineFld.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + engineFld.FullLoadEntries.Select(Function(x) x.TorqueFullLoad.Value()).ToArray()) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkBlue s.Name = "Full load" chart.Series.Add(s) - If VectoJobForm.Visible AndAlso VectoJobForm.EngineIdleSpeed > 0 Then + If VectoJobForm.Visible AndAlso engine.IdleSpeed > 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) - Dim shiftLines As ShiftPolygon = GetShiftLines(fullLoadCurve, vehicle, gears, gear) + Dim shiftLines As ShiftPolygon = GetShiftLines(engine.IdleSpeed, engineFld, vehicle, gears, gear) If (CType(CbGStype.SelectedValue, GearboxType).ManualTransmission() AndAlso Not IsNothing(shiftLines)) Then @@ -835,9 +790,9 @@ Public Class GearboxForm 's.Points.DataBindXY(Shiftpoly.gs_nUup, Shiftpoly.gs_TqUp) s.Points.DataBindXY( - shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.Value() / TUGraz.VectoCore.Configuration.Constants.RPMToRad). - ToList(), - shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToList()) + shiftLines.Upshift.Select(Function(pt) pt.AngularSpeed.AsRPM). + ToArray(), + shiftLines.Upshift.Select(Function(pt) pt.Torque.Value()).ToArray()) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkRed @@ -848,9 +803,9 @@ Public Class GearboxForm s = New Series 's.Points.DataBindXY(Shiftpoly.gs_nUdown, Shiftpoly.gs_TqDown) s.Points.DataBindXY( - shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.Value() / TUGraz.VectoCore.Configuration.Constants.RPMToRad) _ - .ToList(), - shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToList()) + shiftLines.Downshift.Select(Function(pt) pt.AngularSpeed.AsRPM) _ + .ToArray(), + shiftLines.Downshift.Select(Function(pt) pt.Torque.Value()).ToArray()) s.ChartType = SeriesChartType.FastLine s.BorderWidth = 2 s.Color = Color.DarkRed @@ -898,9 +853,8 @@ Public Class GearboxForm End Sub - Private Function GetShiftLines(engineFullLoadCurve As EngineFullLoadCurve, vehicle As IVehicleEngineeringInputData, - gears As IList(Of ITransmissionInputData), gear As Integer) As ShiftPolygon - Dim engine As CombustionEngineData = ConvertToEngineData(engineFullLoadCurve, VectoJobForm.EngineIdleSpeed) + Private Function GetShiftLines(ByVal idleSpeed As PerSecond, engineFullLoadCurve As EngineFullLoadCurve, vehicle As IVehicleEngineeringInputData, gears As IList(Of ITransmissionInputData), ByVal gear As Integer) As ShiftPolygon + Dim engine As CombustionEngineData = ConvertToEngineData(engineFullLoadCurve, idleSpeed) If gears.Count <= 1 Then Return Nothing End If diff --git a/VECTO/GUI/MainForm.vb b/VECTO/GUI/MainForm.vb index b0b4ee56b33175d9c48a9906ff87cc9ace1c3e97..52f85878a590af1b8f65dcaeb1771f253a42929c 100644 --- a/VECTO/GUI/MainForm.vb +++ b/VECTO/GUI/MainForm.vb @@ -39,6 +39,7 @@ Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports System.Text Imports System.Text.RegularExpressions Imports System.Threading +Imports Microsoft.VisualBasic.FileIO Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils @@ -356,7 +357,7 @@ Public Class MainForm If GearboxForm.WindowState = FormWindowState.Minimized Then GearboxForm.WindowState = FormWindowState.Normal GearboxForm.BringToFront() End If - GearboxForm.openGBX(File) + GearboxForm.OpenGbx(File) Case ".VVEH" If Not VehicleForm.Visible Then VehicleForm.Show() @@ -1189,24 +1190,21 @@ lbFound: Public Sub SaveList(Optional ByVal Path As String = "") Dim x As Int32 - Dim file As CsvFile - 'If LVbox.Items.Count = 0 Then Exit Sub - file = New CsvFile If Path = "" Then If Not LoadedDefault Then Exit Sub Path = FilePath End If - file.OpenWrite(Path, "?") + Dim file As StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(Path, True, Encoding.UTF8) For x = 1 To LVbox.Items.Count - file.WriteLine(LVbox.Items(x - 1).SubItems(0).Text, Math.Abs(CInt(LVbox.Items(x - 1).Checked))) + file.WriteLine(String.Join("?", LVbox.Items(x - 1).SubItems(0).Text, Math.Abs(CInt(LVbox.Items(x - 1).Checked)))) Next file.Close() End Sub Public Sub LoadList(Optional ByVal Path As String = "") - Dim line As String() + 'Dim line As String() Dim NoCheck As Boolean - Dim file As CsvFile + 'Dim file As CsvFile Dim ListViewItem0 As ListViewItem If Path = "" Then @@ -1214,9 +1212,9 @@ lbFound: LoadedDefault = True End If - file = New CsvFile + 'file = New CsvFile - If Not file.OpenRead(Path, "?") Then + If Not File.Exists(Path) Then If Not LoadedDefault Then GUIMsg(MessageType.Err, "Cannot open file (" & Path & ")!") Exit Sub End If @@ -1227,8 +1225,13 @@ lbFound: LVbox.Items.Clear() NoCheck = False - Do While Not file.EndOfFile - line = file.ReadLine + Dim reader As TextFieldParser = New TextFieldParser(Path, Encoding.Default) + reader.TextFieldType = FieldType.Delimited + reader.Delimiters = New String() {"?"} + + Do While Not reader.EndOfData + Dim line As String() = reader.ReadFields() + If Strings.Left(Trim(line(0)), 1) = "#" Then Continue Do ListViewItem0 = New ListViewItem(line(0)) ListViewItem0.SubItems.Add(" ") @@ -1250,7 +1253,7 @@ lbFound: LVbox.Items.Add(ListViewItem0) Loop - file.Close() + reader.Close() LVbox.EndUpdate() MainForm.CheckLock = False diff --git a/VECTO/GUI/VectoJobForm.vb b/VECTO/GUI/VectoJobForm.vb index 281f0ae1dc657c2062c747ba3f1e789c52e03168..aa7f7a3ec8d7098898055e78659658358f34b0bc 100644 --- a/VECTO/GUI/VectoJobForm.vb +++ b/VECTO/GUI/VectoJobForm.vb @@ -23,6 +23,8 @@ Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.InputData.Reader Imports TUGraz.VectoCore.Models.Declaration +Imports TUGraz.VectoCore.Models.SimulationComponent.Data +Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox ''' <summary> @@ -1053,8 +1055,8 @@ lbDlog: Dim OkCount As Integer = 0 - Dim ENG0 As Engine = New Engine - ENG0.FilePath = fFileRepl(TbENG.Text, GetPath(VECTOfile)) + Dim engine As IEngineEngineeringInputData = inputData.EngineInputData + 'engine.FilePath = fFileRepl(TbENG.Text, GetPath(VECTOfile)) 'Create plot Dim MyChart As Chart = New Chart @@ -1063,59 +1065,53 @@ lbDlog: a = New ChartArea - Dim FLD0 As EngineFullLoadCurve = New EngineFullLoadCurve + 'Dim FLD0 As EngineFullLoadCurve = New EngineFullLoadCurve - If ENG0.ReadFile(False) Then + If Not engine Is Nothing Then - EngineIdleSpeed = ENG0.IdleSpeed - EngineFullLoadFile = ENG0.PathFLD + EngineIdleSpeed = engine.IdleSpeed.Value() - EngOK = True - FLD0.FilePath = ENG0.PathFLD + Dim fullLoadCurve As FullLoadCurve = FullLoadCurveReader.Create(engine.FullLoadCurve) - If FLD0.ReadFile(False, False) Then + s = New Series + s.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM), + fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueFullLoad.Value())) + s.ChartType = SeriesChartType.FastLine + s.BorderWidth = 2 + s.Color = Color.DarkBlue + s.Name = "Full load" + MyChart.Series.Add(s) - s = New Series - s.Points.DataBindXY(FLD0.EngineSpeedList, FLD0.MaxTorqueList) - s.ChartType = SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.DarkBlue - s.Name = "Full load" - MyChart.Series.Add(s) + s = New Series + s.Points.DataBindXY(fullLoadCurve.FullLoadEntries.Select(Function(x) x.EngineSpeed.AsRPM), + fullLoadCurve.FullLoadEntries.Select(Function(x) x.TorqueDrag.Value())) + s.ChartType = SeriesChartType.FastLine + s.BorderWidth = 2 + s.Color = Color.Blue + s.Name = "Motoring" + MyChart.Series.Add(s) - s = New Series - s.Points.DataBindXY(FLD0.EngineSpeedList, FLD0.DragTorqueList) - s.ChartType = SeriesChartType.FastLine - s.BorderWidth = 2 - s.Color = Color.Blue - s.Name = "Motoring" - MyChart.Series.Add(s) + OkCount += 1 - OkCount += 1 + pmax = fullLoadCurve.RatedSpeed.Value() / 1000 'FLD0.Pfull(FLD0.EngineRatedSpeed) - pmax = FLD0.Pfull(FLD0.EngineRatedSpeed) - End If - - TbEngTxt.Text = (ENG0.Displacement / 1000).ToString("0.0") & " l " & pmax.ToString("#") & " kW " & ENG0.ModelName + TbEngTxt.Text = (engine.Displacement.Value() / 1000).ToString("0.0") & " l " & pmax.ToString("#") & " kW " & + engine.ModelName + Dim fuelConsumptionMap As FuelConsumptionMap = FuelConsumptionMapReader.Create(engine.FuelConsumptionMap) - Dim MAP0 As FuelconsumptionMap = New FuelconsumptionMap - MAP0.FilePath = ENG0.PathMAP + s = New Series + s.Points.DataBindXY(fuelConsumptionMap.Entries.Select(Function(x) x.EngineSpeed.AsRPM).ToArray(), + fuelConsumptionMap.Entries.Select(Function(x) x.Torque.Value()).ToArray()) + s.ChartType = SeriesChartType.Point + s.MarkerSize = 3 + s.Color = Color.Red + s.Name = "Map" + MyChart.Series.Add(s) - If MAP0.ReadFile(False) Then + OkCount += 1 - s = New Series - s.Points.DataBindXY(MAP0.nU, MAP0.Tq) - s.ChartType = SeriesChartType.Point - s.MarkerSize = 3 - s.Color = Color.Red - s.Name = "Map" - MyChart.Series.Add(s) - - OkCount += 1 - - End If End If @@ -1131,46 +1127,43 @@ lbDlog: For i = 1 To gearbox.Gears.Count - FLD0.FilePath = ENG0.PathFLD - - If FLD0.ReadFile(True, False) Then - 'If FLD0.Init(ENG0.Nidle) Then '' use engine from below... + '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)) + '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.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 + '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 + ' OkCount += 1 - pmax = FLD0.Pfull(FLD0.EngineRatedSpeed) + ' pmax = FLD0.Pfull(FLD0.EngineRatedSpeed) - End If + 'End If Next diff --git a/VECTO/Input Files/Engine.vb b/VECTO/Input Files/Engine.vb index 9a9d25876eaef03407479b4bf068fde6b80712f7..4a948d7e726ab291dec975b18552a01c6f518dc7 100644 --- a/VECTO/Input Files/Engine.vb +++ b/VECTO/Input Files/Engine.vb @@ -175,61 +175,6 @@ Public Class Engine Return json.WriteFile(_filePath) End Function - ''' <summary> - ''' Read file. <see cref="P:VECTO.cENG.FilePath" /> must be set before calling. - ''' </summary> - ''' <returns>True if successful.</returns> - ''' <remarks></remarks> - Public Function ReadFile(Optional ByVal showMsg As Boolean = True) As Boolean - Dim msgSrc As String - Dim json As New JSONParser - - msgSrc = "ENG/ReadFile" - - SetDefault() - - - If Not json.ReadFile(_filePath) Then Return False - - Try - - _fileVersion = json.Content.GetEx("Header").GetEx(Of Integer)("FileVersion") - - Dim body As JToken = json.Content.GetEx("Body") - If _fileVersion > 1 Then - SavedInDeclMode = body.GetEx(Of Boolean)("SavedInDeclMode") - Else - SavedInDeclMode = Cfg.DeclMode - End If - - ModelName = body.GetEx(Of String)("ModelName") - - Displacement = body.GetEx(Of Double)("Displacement") - IdleSpeed = body.GetEx(Of Double)("IdlingSpeed") - EngineInertia = body.GetEx(Of Double)("Inertia") - - If _fileVersion < 3 Then - _fullLoadCurvePath.Init(_myPath, body.GetEx("FullLoadCurves").First.GetEx(Of String)("Path")) - Else - _fullLoadCurvePath.Init(_myPath, body.GetEx(Of String)("FullLoadCurve")) - End If - - _fuelConsumptionMapPath.Init(_myPath, body.GetEx(Of String)("FuelMap")) - - If _fileVersion > 2 AndAlso Not body("WHTC-Urban") Is Nothing Then - WHTCurban = (body.GetEx(Of Double)("WHTC-Urban")) - WHTCrural = (body.GetEx(Of Double)("WHTC-Rural")) - WHTCmw = (body.GetEx(Of Double)("WHTC-Motorway")) - End If - - Catch ex As Exception - If showMsg Then WorkerMsg(MessageType.Err, "Failed to read VECTO file! " & ex.Message, msgSrc) - Return False - End Try - - Return True - End Function - ''' <summary> ''' Get or set Filepath before calling <see cref="M:VECTO.cENG.ReadFile" /> or <see cref="M:VECTO.cENG.SaveFile" /> diff --git a/VECTO/Input Files/EngineFullLoadCurve.vb b/VECTO/Input Files/EngineFullLoadCurve.vb deleted file mode 100644 index 846d686378005098c4503efe1dc1d8db2e048b53..0000000000000000000000000000000000000000 --- a/VECTO/Input Files/EngineFullLoadCurve.vb +++ /dev/null @@ -1,340 +0,0 @@ -' Copyright 2014 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' 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> - ''' List of full load torque values [Nm] - ''' </summary> - ''' <remarks></remarks> - Public MaxTorqueList As List(Of Double) - - ''' <summary> - ''' List of motoring torque values [Nm] - ''' </summary> - ''' <remarks></remarks> - Public DragTorqueList As List(Of Double) - - ''' <summary> - ''' List of engine speed values [1/min] - ''' </summary> - ''' <remarks></remarks> - Public EngineSpeedList As List(Of Double) - - ''' <summary> - ''' List of PT1 values [s] - ''' </summary> - ''' <remarks></remarks> - Private _pt1List As List(Of Double) - - ''' <summary> - ''' Read file. FilePath must be set before calling. - ''' </summary> - ''' <returns>True if successful.</returns> - ''' <remarks></remarks> - Public Function ReadFile(tqOnly As Boolean, Optional ByVal showMsg As Boolean = True) As Boolean - Dim pt1Set As Boolean - - Const msgSrc As String = "Main/ReadInp/FLD" - - 'Reset - MaxTorqueList = Nothing - DragTorqueList = Nothing - EngineSpeedList = Nothing - _pt1List = Nothing - Dim lineCount As Integer = -1 - - 'Stop if there's no file - 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 - 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 - - 'Skip Header - file.ReadLine() - - 'Initialize Lists - MaxTorqueList = New List(Of Double) - DragTorqueList = New List(Of Double) - EngineSpeedList = New List(Of Double) - _pt1List = New List(Of Double) - - Dim firstLine As Boolean = True - Try - - Do While Not file.EndOfFile - - 'Read Line - Dim line As String() = file.ReadLine - - 'VECTO: M => Pe - Dim rpm As Double = CDbl(line(0)) - - EngineSpeedList.Add(rpm) - MaxTorqueList.Add(CDbl(line(1))) - - If tqOnly Then - DragTorqueList.Add(0) - Else - DragTorqueList.Add(CDbl(line(2))) - End If - - 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 - _pt1List.Add(CSng(line(3))) - Else - _pt1List.Add(0) - End If - - 'Line-counter up (was reset in ResetMe) - lineCount += 1 - - - Loop - - Catch ex As Exception - - If showMsg Then _ - WorkerMsg(MessageType.Err, "Error during file read! Line number: " & lineCount + 1 & " (" & FilePath & ")", msgSrc, - FilePath) - GoTo lbEr - - End Try - - - 'Close file - file.Close() - - Return True - - - 'ERROR-label for clean Abort -lbEr: - file.Close() - - - Return False - End Function - - ''' <summary> - ''' Returns stationary full load power [kW] at given engine speed. - ''' </summary> - ''' <param name="nU">engine speed [1/min]</param> - ''' <returns>stationary full load power [kW]</returns> - ''' <remarks></remarks> - Public Function Pfull(nU As Double) As Double - Dim i As Int32 - - 'Extrapolation for x < x(1) - 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 EngineSpeedList(i) < nU And i < EngineSpeedList.Count - 1 - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If EngineSpeedList(i) < nU Then - 'MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" - End If - -lbInt: - 'Interpolation - Return nMtoPe(nU, - (nU - EngineSpeedList(i - 1)) * (MaxTorqueList(i) - MaxTorqueList(i - 1)) / - (EngineSpeedList(i) - EngineSpeedList(i - 1)) + MaxTorqueList(i - 1)) - End Function - - ''' <summary> - ''' Returns stationary full load torque [Nm] at given engine speed. - ''' </summary> - ''' <param name="nU">engine speed [1/min]</param> - ''' <returns>stationary full load torque [Nm]</returns> - ''' <remarks></remarks> - Private Function Torque(nU As Double) As Double - Dim i As Int32 - - 'Extrapolation for x < x(1) - 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 EngineSpeedList(i) < nU And i < EngineSpeedList.Count - 1 - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If EngineSpeedList(i) < nU Then - 'MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" - End If - -lbInt: - 'Interpolation - Return _ - (nU - EngineSpeedList(i - 1)) * (MaxTorqueList(i) - MaxTorqueList(i - 1)) / (EngineSpeedList(i) - EngineSpeedList(i - 1)) + - MaxTorqueList(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 - ' 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 EngineRatedSpeed() As Double - - Dim stepSize As Single = 1 - Dim maxPower As Double = 0 - Dim rpm As Double = EngineSpeedList(0) - Dim maxSpeed As Double = EngineSpeedList.Last() - Dim ratedSpeed As Double = rpm - - Do - Dim power As Double = nMtoPe(rpm, Torque(rpm)) - If power > maxPower Then - maxPower = power - ratedSpeed = rpm - End If - rpm += stepSize - Loop Until rpm > maxSpeed - - Return ratedSpeed - End Function - - - ''' <summary> - ''' Get or set Filepath before calling ReadFile - ''' </summary> - ''' <value></value> - ''' <returns>Full filepath</returns> - ''' <remarks></remarks> - Public Property FilePath As String -End Class diff --git a/VECTO/Input Files/FuelconsumptionMap.vb b/VECTO/Input Files/FuelconsumptionMap.vb deleted file mode 100644 index 8b98ce834421e09abdb8c6e9f5b376d4c10c91c5..0000000000000000000000000000000000000000 --- a/VECTO/Input Files/FuelconsumptionMap.vb +++ /dev/null @@ -1,140 +0,0 @@ -' Copyright 2014 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. -Imports System.Collections.Generic -Imports TUGraz.VectoCommon.Utils - -Public Class FuelconsumptionMap - 'Implements IFuelConsumptionMap - - Private _angularSpeedList As List(Of Double) - Private _torqueList As List(Of Double) - Private _fuelconsumptionList As List(Of Double) - - Private _filePath As String - - Private Sub ResetMe() - _fuelconsumptionList = Nothing - _torqueList = Nothing - _angularSpeedList = Nothing - End Sub - - Public Function ReadFile(Optional ByVal showMsg As Boolean = True) As Boolean - - 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) - Return False - End If - - 'Open file - 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 - - 'Skip Header - file.ReadLine() - - 'Initi Lists (before version check so ReadOldFormat works) - _fuelconsumptionList = New List(Of Double) - _torqueList = New List(Of Double) - _angularSpeedList = New List(Of Double) - - Dim lineCount As Integer = -1 - - Try - Do While Not file.EndOfFile - - 'Line read - Dim line As String() = file.ReadLine - - 'Line counter up (was reset in ResetMe) - lineCount += 1 - - 'Revolutions - Dim rpm As Double = line(0).ToDouble() - - _angularSpeedList.Add(rpm) - - 'Power - _torqueList.Add(line(1).ToDouble()) - - 'FC - 'Check sign - If CSng(line(2)) < 0 Then - file.Close() - If showMsg Then WorkerMsg(MessageType.Err, "FC < 0 in map at " & rpm & " [1/min], " & line(1) & " [Nm]", msgSrc) - Return False - End If - - _fuelconsumptionList.Add(line(2).ToDouble()) - - - Loop - Catch ex As Exception - - If showMsg Then _ - WorkerMsg(MessageType.Err, "Error during file read! Line number " & lineCount + 1 & " (" & _filePath & ")", msgSrc, - _filePath) - GoTo lbEr - - End Try - - 'Close file - file.Close() - - - Return True - - - 'ERROR-label for clean Abort -lbEr: - file.Close() - - - Return False - End Function - - -#Region "Properties" - - Public Property FilePath() As String - Get - Return _filePath - End Get - Set(ByVal value As String) - _filePath = value - End Set - End Property - - Public ReadOnly Property Tq As List(Of Double) - Get - Return _torqueList - End Get - End Property - - Public ReadOnly Property nU As List(Of Double) - Get - Return _angularSpeedList - End Get - End Property - -#End Region -End Class - - diff --git a/VECTO/MainModule.vb b/VECTO/MainModule.vb index 896b037bc845ac0be50c1b8f31414795dc7e0370..2e27e75185b9d750678fa033e8bb9bcc51226de6 100644 --- a/VECTO/MainModule.vb +++ b/VECTO/MainModule.vb @@ -21,20 +21,11 @@ Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine Module MainModule Public JobFileList As List(Of String) - Public Function ConvertToEngineData(fld As EngineFullLoadCurve, nIdle As Double) As CombustionEngineData + Public Function ConvertToEngineData(fld As EngineFullLoadCurve, nIdle As PerSecond) As CombustionEngineData 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.EngineSpeedList.Count - 1 - retVal.FullLoadCurve.FullLoadEntries.Add( - New FullLoadCurve.FullLoadCurveEntry() _ - With {.EngineSpeed = fld.EngineSpeedList(i).RPMtoRad(), - .TorqueFullLoad = fld.MaxTorqueList(i).SI(Of NewtonMeter)(), - .TorqueDrag = fld.DragTorqueList(i).SI(Of NewtonMeter)()}) - Next - - retVal.IdleSpeed = CType(nIdle, Double).RPMtoRad() + retVal.FullLoadCurve = fld + retVal.IdleSpeed = nIdle Return retVal End Function diff --git a/VECTO/VECTO.vbproj b/VECTO/VECTO.vbproj index a16a9cae168d6753c3c9530e8dc6ed66e6419ea9..bf3eebf583714aedc57b59b18dc09fe75510d552 100644 --- a/VECTO/VECTO.vbproj +++ b/VECTO/VECTO.vbproj @@ -241,8 +241,6 @@ <Compile Include="File Browser\FileBrowserFavoritesDialog.vb"> <SubType>Form</SubType> </Compile> - <Compile Include="Input Files\EngineFullLoadCurve.vb" /> - <Compile Include="Input Files\FuelconsumptionMap.vb" /> <Compile Include="Input Files\VectoJob.vb" /> <Compile Include="Input Files\Vehicle.vb" /> <Compile Include="GUI\GearboxGearDialog.Designer.vb">