diff --git a/Tools/VectoLegacyTests/TorqueConverterTest.cs b/Tools/VectoLegacyTests/TorqueConverterTest.cs index c06fe136a0063c3ab944cbb2184cbc2bd9958472..079d6b9438cc74e1acb3b44f2c9234ccfaf0075e 100644 --- a/Tools/VectoLegacyTests/TorqueConverterTest.cs +++ b/Tools/VectoLegacyTests/TorqueConverterTest.cs @@ -21,79 +21,5 @@ namespace VectoLegacyTests Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); } catch (Exception) {} } - - [TestMethod] - public void TestTorqueConverter() - { - cGBX cGbx = new cGBX(); - VECTO_Global.MyAppPath = @".\"; - VECTO_Global.MyDeclPath = @"E:\QUAM\Workspace\VECTO_quam\Declaration\"; - VECTO_Global.sKey = new csKey(); - VECTO_Global.Declaration = new cDeclaration(); - VECTO_Global.Cfg = new Configuration() { - DeclMode = false - }; - VECTO_Global.DEV = new cDEV() { - TClimitOn = true, - TClimit = 1600, - TCaccmin = 0.025f, - TCiterPrec = 0.001f, - }; - VECTO_Global.VEC = new cVECTO() { - EngOnly = false, - AuxiliaryAssembly = "CLASSIC" - }; - VECTO_Global.VEC.set_DesMaxFile(true, - @"E:\QUAM\Workspace\VECTO_quam\Generic Vehicles\Engineering Mode\12t Delivery Truck\Truck.vacc"); - VECTO_Global.VEC.Init(); - - VECTO_Global.DRI = new cDRI(); - VECTO_Global.DRI.FilePath = @"..\..\..\..\Declaration\MissionCycles\Citybus_Suburban.vdri"; - VECTO_Global.DRI.ReadFile(); - VECTO_Global.DRI.GradToAlt(); - - VECTO_Global.MODdata = new cMOD(); - VECTO_Global.MODdata.Init(); - - if (VECTO_Global.DRI.Scycle) { - VECTO_Global.MODdata.Vh.SetAlt(); - var foo = VECTO_Global.DRI.ConvStoT(); - } - - VECTO_Global.MODdata.CycleInit(); - - VECTO_Global.GBX = cGbx; - VECTO_Global.ENG = new cENG(); - VECTO_Global.ENG.FilePath = - @"..\..\..\..\Generic Vehicles\Engineering Mode\AT-TC Demo Vehicle\Engine.veng"; - //"..\\..\\..\\Generic Vehicles\\Declaration Mode\\12t Delivery Truck\\12t Delivery Truck.veng"; - VECTO_Global.ENG.ReadFile(true); - VECTO_Global.ENG.Init(); - VECTO_Global.LogFile = new VECTO_Global.cLogFile(); - cGbx.FilePath = @"..\..\..\..\Generic Vehicles\Engineering Mode\AT-TC Demo Vehicle\Gearbox.vgbx"; - //"..\\..\\..\\Generic Vehicles\\Declaration Mode\\12t Delivery Truck\\12t Delivery Truck.vgbx"; - var flag = cGbx.ReadFile(true); - flag = cGbx.GSinit(); - if (cGbx.TCon) { - cGbx.TCinit(); - } - flag = ((cENG)VECTO_Global.ENG).Init(); - //cGbx.DeclInit(); - - for (var nOut = 10; nOut < 200; nOut += 10) { - for (var Pout = 10; Pout < 200; Pout += 20) { - flag = cGbx.TCiteration(1, nOut, Pout, 0); - Assert.IsTrue(flag); - Debug.WriteLine("n_out: {0}, P_out: {1}, n_in: {2}, Tq_in: {3}, reduce: {4}", nOut, Pout, cGbx.TCnUin, cGbx.TCMin, - cGbx.TCReduce); - } - } - - //flag = cGbx.TCiteration(1, 100, 5, 0); - //Assert.IsTrue(flag); - - //Assert.AreEqual(0, cGbx.TCnUin); - //Assert.AreEqual(0, cGbx.TCMin); - } } } \ No newline at end of file diff --git a/VECTO/File Browser/FB_Global.vb b/VECTO/File Browser/FB_Global.vb index 741f01d03da42e89a5eb177d6e1825092bb29990..ff68f211244100772c8964bc62d61034393e811c 100644 --- a/VECTO/File Browser/FB_Global.vb +++ b/VECTO/File Browser/FB_Global.vb @@ -38,6 +38,7 @@ Public Module FB_Global Public fbTLM As cFileBrowser Public fbRLM As cFileBrowser Public fbTCC As cFileBrowser + Public fbTCCShift As cFileBrowser Public fbCDx As cFileBrowser Public fbVMOD As cFileBrowser diff --git a/VECTO/GUI/F_ENG.vb b/VECTO/GUI/F_ENG.vb index 46e6fab3f7a91034b6d5ea1790dd46c1a12277a1..963279e7abf4083a9ae1761dc7fe2f6bdf1d9cb3 100644 --- a/VECTO/GUI/F_ENG.vb +++ b/VECTO/GUI/F_ENG.vb @@ -278,10 +278,6 @@ Public Class F_ENG Change() End Sub - Private Sub TbPnenn_TextChanged(sender As System.Object, e As System.EventArgs) - Change() - End Sub - Private Sub TbDispl_TextChanged(sender As System.Object, e As System.EventArgs) Handles TbDispl.TextChanged Change() DeclInit() @@ -296,10 +292,6 @@ Public Class F_ENG Change() End Sub - Private Sub TbNnenn_TextChanged(sender As System.Object, e As System.EventArgs) - Change() - End Sub - Private Sub TbMAP_TextChanged(sender As System.Object, e As System.EventArgs) _ Handles TbMAP.TextChanged, TbFLD.TextChanged UpdatePic() @@ -318,10 +310,6 @@ Public Class F_ENG Change() End Sub - Private Sub LvFLDs_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) - UpdatePic() - End Sub - #End Region diff --git a/VECTO/GUI/F_GBX.Designer.vb b/VECTO/GUI/F_GBX.Designer.vb index 54e7839d598fe4615bfbecdf9ef2b217b1fb0bce..db02054df92c0b76a732482cad234ebecb9bfe43 100644 --- a/VECTO/GUI/F_GBX.Designer.vb +++ b/VECTO/GUI/F_GBX.Designer.vb @@ -50,7 +50,6 @@ Partial Class F_GBX Me.TbTracInt = New System.Windows.Forms.TextBox() Me.LvGears = New System.Windows.Forms.ListView() Me.ColumnHeader1 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) - 'Me.ColumnHeader4 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) 'TC Column Me.ColumnHeader2 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.ColumnHeader3 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.ColumnHeader5 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) @@ -117,6 +116,9 @@ Partial Class F_GBX Me.Label32 = New System.Windows.Forms.Label() Me.PnInertiaTI = New System.Windows.Forms.Panel() Me.PicBox = New System.Windows.Forms.PictureBox() + Me.TBTCShiftPolygon = New System.Windows.Forms.TextBox() + Me.LblTCShiftFile = New System.Windows.Forms.Label() + Me.BtTCShiftFileBrowse = New System.Windows.Forms.Button() Me.ToolStrip1.SuspendLayout() Me.StatusStrip1.SuspendLayout() CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() @@ -275,11 +277,6 @@ Partial Class F_GBX Me.ColumnHeader1.Text = "Gear" Me.ColumnHeader1.Width = 46 ' - ''ColumnHeader4 - '' - 'Me.ColumnHeader4.Text = "TC" - 'Me.ColumnHeader4.Width = 31 - ' 'ColumnHeader2 ' Me.ColumnHeader2.Text = "Ratio" @@ -297,7 +294,7 @@ Partial Class F_GBX ' 'ColumnHeader6 ' - Me.ColumnHeader6.Text = "Full Load Curve" + Me.ColumnHeader6.Text = "Max Torque" Me.ColumnHeader6.Width = 95 ' 'TBI_getr @@ -686,11 +683,14 @@ Partial Class F_GBX ' 'GroupBox3 ' + Me.GroupBox3.Controls.Add(Me.BtTCShiftFileBrowse) + Me.GroupBox3.Controls.Add(Me.LblTCShiftFile) + Me.GroupBox3.Controls.Add(Me.TBTCShiftPolygon) Me.GroupBox3.Controls.Add(Me.PnTC) Me.GroupBox3.Controls.Add(Me.ChTCon) Me.GroupBox3.Location = New System.Drawing.Point(459, 440) Me.GroupBox3.Name = "GroupBox3" - Me.GroupBox3.Size = New System.Drawing.Size(414, 119) + Me.GroupBox3.Size = New System.Drawing.Size(414, 162) Me.GroupBox3.TabIndex = 5 Me.GroupBox3.TabStop = False Me.GroupBox3.Text = "Torque Converter" @@ -888,6 +888,35 @@ Partial Class F_GBX Me.PicBox.TabIndex = 48 Me.PicBox.TabStop = False ' + 'TBTCShiftPolygon + ' + Me.TBTCShiftPolygon.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.TBTCShiftPolygon.Location = New System.Drawing.Point(10, 136) + Me.TBTCShiftPolygon.Name = "TBTCShiftPolygon" + Me.TBTCShiftPolygon.Size = New System.Drawing.Size(343, 20) + Me.TBTCShiftPolygon.TabIndex = 37 + ' + 'LblTCShiftFile + ' + Me.LblTCShiftFile.AutoSize = True + Me.LblTCShiftFile.Location = New System.Drawing.Point(7, 120) + Me.LblTCShiftFile.Name = "LblTCShiftFile" + Me.LblTCShiftFile.Size = New System.Drawing.Size(172, 13) + Me.LblTCShiftFile.TabIndex = 5 + Me.LblTCShiftFile.Text = "Torque converter shift polygons file" + ' + 'BtTCShiftFileBrowse + ' + Me.BtTCShiftFileBrowse.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.BtTCShiftFileBrowse.Image = Global.VECTO.My.Resources.Resources.Open_icon + Me.BtTCShiftFileBrowse.Location = New System.Drawing.Point(354, 134) + Me.BtTCShiftFileBrowse.Name = "BtTCShiftFileBrowse" + Me.BtTCShiftFileBrowse.Size = New System.Drawing.Size(24, 24) + Me.BtTCShiftFileBrowse.TabIndex = 5 + Me.BtTCShiftFileBrowse.TabStop = False + Me.BtTCShiftFileBrowse.UseVisualStyleBackColor = True + ' 'F_GBX ' Me.AcceptButton = Me.ButOK @@ -942,77 +971,77 @@ Partial Class F_GBX Me.PerformLayout() End Sub - Friend WithEvents ToolStrip1 As System.Windows.Forms.ToolStrip - Friend WithEvents ToolStripBtNew As System.Windows.Forms.ToolStripButton - Friend WithEvents ToolStripBtOpen As System.Windows.Forms.ToolStripButton - Friend WithEvents ToolStripBtSave As System.Windows.Forms.ToolStripButton - Friend WithEvents ToolStripBtSaveAs As System.Windows.Forms.ToolStripButton - Friend WithEvents ToolStripSeparator3 As System.Windows.Forms.ToolStripSeparator - Friend WithEvents ToolStripBtSendTo As System.Windows.Forms.ToolStripButton - Friend WithEvents StatusStrip1 As System.Windows.Forms.StatusStrip - Friend WithEvents LbStatus As System.Windows.Forms.ToolStripStatusLabel - Friend WithEvents ButCancel As System.Windows.Forms.Button - Friend WithEvents ButOK As System.Windows.Forms.Button - Friend WithEvents BtRemGear As System.Windows.Forms.Button - Friend WithEvents TbTracInt As System.Windows.Forms.TextBox - Friend WithEvents LvGears As System.Windows.Forms.ListView - Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader - Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader - Friend WithEvents ColumnHeader3 As System.Windows.Forms.ColumnHeader - Friend WithEvents TBI_getr As System.Windows.Forms.TextBox - Friend WithEvents Label49 As System.Windows.Forms.Label - Friend WithEvents Label33 As System.Windows.Forms.Label - Friend WithEvents Label48 As System.Windows.Forms.Label - Friend WithEvents Label6 As System.Windows.Forms.Label - Friend WithEvents Label3 As System.Windows.Forms.Label - Friend WithEvents TbName As System.Windows.Forms.TextBox - Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox - Friend WithEvents ToolStripSeparator1 As System.Windows.Forms.ToolStripSeparator - Friend WithEvents ToolStripButton1 As System.Windows.Forms.ToolStripButton - Friend WithEvents GrGearShift As System.Windows.Forms.GroupBox - Friend WithEvents Label2 As System.Windows.Forms.Label - Friend WithEvents TbTqResvStart As System.Windows.Forms.TextBox - Friend WithEvents TbTqResv As System.Windows.Forms.TextBox - Friend WithEvents Label7 As System.Windows.Forms.Label - Friend WithEvents Label5 As System.Windows.Forms.Label - Friend WithEvents Label4 As System.Windows.Forms.Label - Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox - Friend WithEvents TbStartAcc As System.Windows.Forms.TextBox - Friend WithEvents Label11 As System.Windows.Forms.Label - Friend WithEvents TbStartSpeed As System.Windows.Forms.TextBox - Friend WithEvents Label9 As System.Windows.Forms.Label - Friend WithEvents Label10 As System.Windows.Forms.Label - Friend WithEvents Label8 As System.Windows.Forms.Label - Friend WithEvents TbShiftTime As System.Windows.Forms.TextBox - Friend WithEvents Label12 As System.Windows.Forms.Label - Friend WithEvents Label13 As System.Windows.Forms.Label - Friend WithEvents ChSkipGears As System.Windows.Forms.CheckBox - Friend WithEvents ChShiftInside As System.Windows.Forms.CheckBox - Friend WithEvents CmOpenFile As System.Windows.Forms.ContextMenuStrip - Friend WithEvents OpenWithToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem - Friend WithEvents ShowInFolderToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem - Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox - Friend WithEvents TbTCfile As System.Windows.Forms.TextBox - Friend WithEvents ChTCon As System.Windows.Forms.CheckBox - Friend WithEvents BtTCfileBrowse As System.Windows.Forms.Button - Friend WithEvents BtTCfileOpen As System.Windows.Forms.Button - Friend WithEvents TbTCrefrpm As System.Windows.Forms.TextBox - Friend WithEvents Label14 As System.Windows.Forms.Label - Friend WithEvents Label15 As System.Windows.Forms.Label - Friend WithEvents Label16 As System.Windows.Forms.Label - Friend WithEvents CbGStype As System.Windows.Forms.ComboBox - Friend WithEvents Label17 As System.Windows.Forms.Label - Friend WithEvents PnTC As System.Windows.Forms.Panel - Friend WithEvents PnTorqRes As System.Windows.Forms.Panel - Friend WithEvents BtAddGear As System.Windows.Forms.Button + Friend WithEvents ToolStrip1 As System.Windows.Forms.ToolStrip + Friend WithEvents ToolStripBtNew As System.Windows.Forms.ToolStripButton + Friend WithEvents ToolStripBtOpen As System.Windows.Forms.ToolStripButton + Friend WithEvents ToolStripBtSave As System.Windows.Forms.ToolStripButton + Friend WithEvents ToolStripBtSaveAs As System.Windows.Forms.ToolStripButton + Friend WithEvents ToolStripSeparator3 As System.Windows.Forms.ToolStripSeparator + Friend WithEvents ToolStripBtSendTo As System.Windows.Forms.ToolStripButton + Friend WithEvents StatusStrip1 As System.Windows.Forms.StatusStrip + Friend WithEvents LbStatus As System.Windows.Forms.ToolStripStatusLabel + Friend WithEvents ButCancel As System.Windows.Forms.Button + Friend WithEvents ButOK As System.Windows.Forms.Button + Friend WithEvents BtRemGear As System.Windows.Forms.Button + Friend WithEvents TbTracInt As System.Windows.Forms.TextBox + Friend WithEvents LvGears As System.Windows.Forms.ListView + Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader + Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader + Friend WithEvents ColumnHeader3 As System.Windows.Forms.ColumnHeader + Friend WithEvents TBI_getr As System.Windows.Forms.TextBox + Friend WithEvents Label49 As System.Windows.Forms.Label + Friend WithEvents Label33 As System.Windows.Forms.Label + Friend WithEvents Label48 As System.Windows.Forms.Label + Friend WithEvents Label6 As System.Windows.Forms.Label + Friend WithEvents Label3 As System.Windows.Forms.Label + Friend WithEvents TbName As System.Windows.Forms.TextBox + Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox + Friend WithEvents ToolStripSeparator1 As System.Windows.Forms.ToolStripSeparator + Friend WithEvents ToolStripButton1 As System.Windows.Forms.ToolStripButton + Friend WithEvents GrGearShift As System.Windows.Forms.GroupBox + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents TbTqResvStart As System.Windows.Forms.TextBox + Friend WithEvents TbTqResv As System.Windows.Forms.TextBox + Friend WithEvents Label7 As System.Windows.Forms.Label + Friend WithEvents Label5 As System.Windows.Forms.Label + Friend WithEvents Label4 As System.Windows.Forms.Label + Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox + Friend WithEvents TbStartAcc As System.Windows.Forms.TextBox + Friend WithEvents Label11 As System.Windows.Forms.Label + Friend WithEvents TbStartSpeed As System.Windows.Forms.TextBox + Friend WithEvents Label9 As System.Windows.Forms.Label + Friend WithEvents Label10 As System.Windows.Forms.Label + Friend WithEvents Label8 As System.Windows.Forms.Label + Friend WithEvents TbShiftTime As System.Windows.Forms.TextBox + Friend WithEvents Label12 As System.Windows.Forms.Label + Friend WithEvents Label13 As System.Windows.Forms.Label + Friend WithEvents ChSkipGears As System.Windows.Forms.CheckBox + Friend WithEvents ChShiftInside As System.Windows.Forms.CheckBox + Friend WithEvents CmOpenFile As System.Windows.Forms.ContextMenuStrip + Friend WithEvents OpenWithToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents ShowInFolderToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox + Friend WithEvents TbTCfile As System.Windows.Forms.TextBox + Friend WithEvents ChTCon As System.Windows.Forms.CheckBox + Friend WithEvents BtTCfileBrowse As System.Windows.Forms.Button + Friend WithEvents BtTCfileOpen As System.Windows.Forms.Button + Friend WithEvents TbTCrefrpm As System.Windows.Forms.TextBox + Friend WithEvents Label14 As System.Windows.Forms.Label + Friend WithEvents Label15 As System.Windows.Forms.Label + Friend WithEvents Label16 As System.Windows.Forms.Label + Friend WithEvents CbGStype As System.Windows.Forms.ComboBox + Friend WithEvents Label17 As System.Windows.Forms.Label + Friend WithEvents PnTC As System.Windows.Forms.Panel + Friend WithEvents PnTorqRes As System.Windows.Forms.Panel + Friend WithEvents BtAddGear As System.Windows.Forms.Button Friend WithEvents ColumnHeader4 As System.Windows.Forms.ColumnHeader - Friend WithEvents GroupBox4 As System.Windows.Forms.GroupBox - Friend WithEvents Label32 As System.Windows.Forms.Label - Friend WithEvents PnInertiaTI As System.Windows.Forms.Panel - Friend WithEvents ColumnHeader5 As System.Windows.Forms.ColumnHeader - Friend WithEvents PicBox As System.Windows.Forms.PictureBox - Friend WithEvents TbTCinertia As System.Windows.Forms.TextBox - Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents GroupBox4 As System.Windows.Forms.GroupBox + Friend WithEvents Label32 As System.Windows.Forms.Label + Friend WithEvents PnInertiaTI As System.Windows.Forms.Panel + Friend WithEvents ColumnHeader5 As System.Windows.Forms.ColumnHeader + Friend WithEvents PicBox As System.Windows.Forms.PictureBox + Friend WithEvents TbTCinertia As System.Windows.Forms.TextBox + Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label18 As System.Windows.Forms.Label Friend WithEvents ColumnHeader6 As System.Windows.Forms.ColumnHeader Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox @@ -1025,4 +1054,7 @@ Partial Class F_GBX Friend WithEvents Label21 As System.Windows.Forms.Label Friend WithEvents Label20 As System.Windows.Forms.Label Friend WithEvents Label19 As System.Windows.Forms.Label + Friend WithEvents BtTCShiftFileBrowse As System.Windows.Forms.Button + Friend WithEvents LblTCShiftFile As System.Windows.Forms.Label + Friend WithEvents TBTCShiftPolygon As System.Windows.Forms.TextBox End Class diff --git a/VECTO/GUI/F_GBX.vb b/VECTO/GUI/F_GBX.vb index c034e2940ac1e14180ac1d2cabb4d1373a4e3069..a2b716c9a3bce3a49f35edc559ec07ea9e0d7492 100644 --- a/VECTO/GUI/F_GBX.vb +++ b/VECTO/GUI/F_GBX.vb @@ -31,7 +31,7 @@ Public Class F_GBX Ratio = 1 LossMapEfficiency = 2 ShiftPolygons = 3 - FullLoadCurve = 4 + MaxTorque = 4 End Enum Private GbxFile As String = "" @@ -244,11 +244,11 @@ Public Class F_GBX If i = 0 Then 'lv0 = New ListViewItem("Axle") Me.LvGears.Items.Add(CreateListviewItem("Axle", "-", GBX0.Igetr(i), GBX0.GetrMap(i, True), GBX0.gsFile(i, True), - GBX0.FldFile(i, True))) + GBX0.MaxTorque(i))) Else 'lv0 = New ListViewItem(i.ToString("00")) - Me.LvGears.Items.Add(CreateListviewItem(i.ToString("00"), "-", GBX0.Igetr(i), GBX0.GetrMap(i, True), GBX0.gsFile(i, True), - GBX0.FldFile(i, True))) + Me.LvGears.Items.Add(CreateListviewItem(i.ToString("00"), "-", GBX0.Igetr(i), GBX0.GetrMap(i, True), + GBX0.gsFile(i, True), GBX0.MaxTorque(i))) End If Next @@ -264,6 +264,7 @@ Public Class F_GBX Me.TbTCfile.Text = GBX0.TCfile(True) Me.TbTCrefrpm.Text = GBX0.TCrefrpm Me.TbTCinertia.Text = GBX0.TCinertia + TBTCShiftPolygon.Text = GBX0.TCshiftFile tbUpshiftMinAcceleration.Text = GBX0.UpshiftMinAcceleration tbDownshiftAfterUpshift.Text = GBX0.DownshiftAfterUpshift @@ -332,8 +333,9 @@ Public Class F_GBX GBX0.GetrMap(i) = Me.LvGears.Items(i).SubItems(GearboxTbl.LossMapEfficiency).Text GBX0.gs_files.Add(New cSubPath) GBX0.gsFile(i) = Me.LvGears.Items(i).SubItems(GearboxTbl.ShiftPolygons).Text - GBX0.FldFiles.Add(New cSubPath) - GBX0.FldFile(i) = Me.LvGears.Items(i).SubItems(GearboxTbl.FullLoadCurve).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) Next GBX0.gs_TorqueResv = fTextboxToNumString(Me.TbTqResv.Text) @@ -350,6 +352,7 @@ Public Class F_GBX GBX0.TCfile = Me.TbTCfile.Text GBX0.TCrefrpm = fTextboxToNumString(Me.TbTCrefrpm.Text) GBX0.TCinertia = fTextboxToNumString(Me.TbTCinertia.Text) + GBX0.TCshiftFile = TBTCShiftPolygon.Text GBX0.DownshiftAfterUpshift = fTextboxToNumString(tbDownshiftAfterUpshift.Text) GBX0.UpshiftAfterDownshift = fTextboxToNumString(tbUpshiftAfterDownshift.Text) @@ -555,10 +558,10 @@ Public Class F_GBX GearDia.TbMapPath.Text = Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.LossMapEfficiency).Text If Me.LvGears.SelectedIndices(0) > 0 Then GearDia.TbShiftPolyFile.Text = Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.ShiftPolygons).Text - GearDia.TbFld.Text = Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.FullLoadCurve).Text + GearDia.TbMaxTorque.Text = Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.MaxTorque).Text Else GearDia.TbShiftPolyFile.Text = "" - GearDia.TbFld.Text = "" + GearDia.TbMaxTorque.Text = "" End If If LvGears.SelectedItems(0).Index = 0 Then @@ -575,7 +578,7 @@ Public Class F_GBX Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.Ratio).Text = GearDia.TbRatio.Text Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.LossMapEfficiency).Text = GearDia.TbMapPath.Text Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.ShiftPolygons).Text = GearDia.TbShiftPolyFile.Text - Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.FullLoadCurve).Text = GearDia.TbFld.Text + Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.MaxTorque).Text = GearDia.TbMaxTorque.Text UpdatePic() Change() @@ -716,21 +719,19 @@ Public Class F_GBX If Me.LvGears.SelectedItems.Count > 0 AndAlso Me.LvGears.SelectedIndices(0) > 0 Then path = fFileRepl(Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.ShiftPolygons).Text, fPATH(GbxFile)) - fldpath = fFileRepl(Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.FullLoadCurve).Text, fPATH(GbxFile)) + 'fldpath = fFileRepl(Me.LvGears.SelectedItems(0).SubItems(GearboxTbl.MaxTorque).Text, fPATH(GbxFile)) Gear = Me.LvGears.SelectedIndices(0) Else path = fFileRepl(Me.LvGears.Items(1).SubItems(GearboxTbl.ShiftPolygons).Text, fPATH(GbxFile)) - fldpath = fFileRepl(Me.LvGears.Items(1).SubItems(GearboxTbl.FullLoadCurve).Text, fPATH(GbxFile)) + 'fldpath = fFileRepl(Me.LvGears.Items(1).SubItems(GearboxTbl.MaxTorque).Text, fPATH(GbxFile)) Gear = 1 End If f = New cFile_V3 ShiftOK = f.OpenRead(path) - If fldpath.Trim = "" Then - If F_VECTO.Visible AndAlso F_VECTO.FLDfile <> "" Then fldpath = F_VECTO.FLDfile - End If - + fldpath = F_VECTO.FLDfile + fldOK = fldpath.Trim <> "" If fldOK Then @@ -831,7 +832,7 @@ Public Class F_GBX Shiftpoly.SetGenericShiftPoly(FLD0, F_VECTO.n_idle) 'Dim fullLoadCurve As FullLoadCurve = ConvertToFullLoadCurve(FLD0.LnU, FLD0.LTq) Dim gears As IList(Of ITransmissionInputData) = ConvertToGears(LvGears.Items) - If (gears.Count > 1) Then + If (Not AutomaticTransmission(CType(Me.CbGStype.SelectedIndex, tGearbox)) AndAlso gears.Count > 1) Then Dim engine As CombustionEngineData = ConvertToEngineData(FLD0, F_VECTO.n_idle) Dim shiftLines As ShiftPolygon = DeclarationData.Gearbox.ComputeShiftPolygon(Gear - 1, engine.FullLoadCurve, gears, engine, @@ -944,6 +945,8 @@ Public Class F_GBX Change() CheckGearTC() PnTC.Enabled = ChTCon.Checked + LblTCShiftFile.Enabled = ChTCon.Checked + TBTCShiftPolygon.Enabled = ChTCon.Checked End Sub 'Browse TC file @@ -984,4 +987,10 @@ Public Class F_GBX ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. End Sub + + Private Sub BtTCShiftFileBrowse_Click(sender As Object, e As EventArgs) Handles BtTCShiftFileBrowse.Click + If fbTCCShift.OpenDialog(fFileRepl(Me.TBTCShiftPolygon.Text, fPATH(GbxFile))) Then + Me.TBTCShiftPolygon.Text = fFileWoDir(fbTCCShift.Files(0), fPATH(GbxFile)) + End If + End Sub End Class diff --git a/VECTO/GUI/F_JIRA.vb b/VECTO/GUI/F_JIRA.vb index 3bc92cb6223e4f2ac3ab88c3797498f79535d944..5094fe39c33b00b4fe130372bb7ef66de612fb93 100644 --- a/VECTO/GUI/F_JIRA.vb +++ b/VECTO/GUI/F_JIRA.vb @@ -5,11 +5,6 @@ Public Class F_JIRA Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click Me.DialogResult = System.Windows.Forms.DialogResult.OK Me.Close() - End Sub - - Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) - Me.DialogResult = System.Windows.Forms.DialogResult.Cancel - Me.Close() End Sub Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked diff --git a/VECTO/GUI/F_MAINForm.vb b/VECTO/GUI/F_MAINForm.vb index dc963b9631f8f8951fea0cb4dbe1e7645306e7ec..57fc0286be87d01ad3ac2aec362b512ff60a9e99 100644 --- a/VECTO/GUI/F_MAINForm.vb +++ b/VECTO/GUI/F_MAINForm.vb @@ -61,9 +61,6 @@ Public Class F_MAINForm Private ConMenTarget As ListView Private ConMenTarJob As Boolean - Private MODpath As String - Private MODVehList As Int32() - Private CycleTabPage As TabPage Private CycleTabPageVisible As Boolean @@ -137,6 +134,7 @@ Public Class F_MAINForm fbRLM = New cFileBrowser("vrlm") fbTLM = New cFileBrowser("vtlm") fbTCC = New cFileBrowser("vtcc") + fbTCCShift = New cFileBrowser("vgbs") fbCDx = New cFileBrowser("vcdx") fbDfVelocityDrop = New cFileBrowser("DfVelocityDrop") fbDfTargetSpeed = New cFileBrowser("DfTargetSpeed") @@ -161,6 +159,7 @@ Public Class F_MAINForm fbRLM.Extensions = New String() {"vrlm"} fbTLM.Extensions = New String() {"vtlm"} fbTCC.Extensions = New String() {"vtcc"} + fbTCCShift.Extensions = New String() {"vgbs"} fbCDx.Extensions = New String() {"vcdv", "vcdb"} fbVMOD.Extensions = New String() {"vmod"} @@ -182,6 +181,7 @@ Public Class F_MAINForm fbRLM.Close() fbTLM.Close() fbTCC.Close() + fbTCCShift.Close() fbCDx.Close() fbVMOD.Close() End Sub @@ -358,23 +358,6 @@ Public Class F_MAINForm #Region "BackgroundWorker Events" - 'DoWork - Start Calculations - Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) _ - Handles BackgroundWorker1.DoWork - - 'Prevent SLEEP - AllowSleepOFF() - - If SetCulture Then - Try - Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US") - Catch ex As Exception - GUImsg(tMsgID.Err, "Failed to set thread culture 'en-US'! Check system decimal- and group- separators!") - End Try - End If - - e.Result = VECTO() - End Sub 'Progress Report - Progressbar, Messages, etc. Private Sub BackgroundWorker1_ProgressChanged(sender As Object, @@ -1510,27 +1493,6 @@ lbFound: #End Region 'VECTO Start button - Calls VECTO_Launcher or aborts calculation - Private Sub Button1_Click(sender As Object, e As EventArgs) - - 'VECTO Start/Stop - If VECTOworker.IsBusy Then - - 'If VECTO already running: STOP - ComLineShutDown = False - JobAbort() - - Else - - '...Otherwise: START - - 'Save Lists if Crash - SaveFileLists() - - 'Start - VECTO_Launcher() - - End If - End Sub Private Sub btStartV3_Click(sender As Object, e As EventArgs) Handles btStartV3.Click If Not VECTOworkerV3.IsBusy Then @@ -1684,7 +1646,8 @@ lbFound: sender.ReportProgress(100, New _ With {.Target = "ListBox", - .Message = String.Format("PDF-Report for '{0}' written to {1}", Path.GetFileName(job), report), .Link = "<RUN>" + report}) + .Message = String.Format("PDF-Report for '{0}' written to {1}", Path.GetFileName(job), report), + .Link = "<RUN>" + report}) End If Next @@ -2778,7 +2741,6 @@ Lb1: Private Sub LvMsg_MouseUp(sender As Object, e As MouseEventArgs) Handles LvMsg.MouseUp mouseDownOnListView = False - End Sub Private Sub LvGEN_MouseUp(sender As Object, e As MouseEventArgs) Handles LvGEN.MouseUp diff --git a/VECTO/GUI/F_VECTO.vb b/VECTO/GUI/F_VECTO.vb index acbb447b32df41c7ffbd7f8b982c6c4b08261c20..773946ca649d3fcb7aa3ea6426f8a7c570fc762d 100644 --- a/VECTO/GUI/F_VECTO.vb +++ b/VECTO/GUI/F_VECTO.vb @@ -698,10 +698,6 @@ Public Class F_VECTO Change() End Sub - Private Sub TbAlookahead_TextChanged(sender As Object, e As EventArgs) - Change() - End Sub - Private Sub LvCycles_AfterLabelEdit(sender As Object, e As LabelEditEventArgs) _ Handles LvCycles.AfterLabelEdit Change() @@ -1131,8 +1127,7 @@ lbDlog: For i = 1 To GBX0.GearCount - FLD0.FilePath = GBX0.FldFile(i) - If FLD0.FilePath.Trim = "" Then FLD0.FilePath = ENG0.PathFLD + FLD0.FilePath = ENG0.PathFLD If FLD0.ReadFile(True, False) Then diff --git a/VECTO/GUI/F_VEH.vb b/VECTO/GUI/F_VEH.vb index 54eee8866ba17bd8fc6b9649eef44861cc203137..341a85eab07244217b1c37fa358def214a3fcd95 100644 --- a/VECTO/GUI/F_VEH.vb +++ b/VECTO/GUI/F_VEH.vb @@ -543,11 +543,6 @@ Public Class F_VEH Change() End Sub - Private Sub CbRim_SelectedIndexChanged(sender As Object, e As EventArgs) - Change() - DeclInit() - End Sub - Private Sub TBcw_TextChanged(sender As Object, e As EventArgs) _ Handles TbLoad.TextChanged, TBrdyn.TextChanged, TBcdA.TextChanged, TbCdFile.TextChanged, TbRtRatio.TextChanged, cbAngularGearType.SelectedIndexChanged, TbRtPath.TextChanged, tbAngularGearLossMapPath.TextChanged, diff --git a/VECTO/GUI/GearboxGearDialog.Designer.vb b/VECTO/GUI/GearboxGearDialog.Designer.vb index 33be827cdf75b836065eb446074aa4b10b625b64..ee93d30b9390a9bc40dd3bbfb084f879c63f5bc2 100644 --- a/VECTO/GUI/GearboxGearDialog.Designer.vb +++ b/VECTO/GUI/GearboxGearDialog.Designer.vb @@ -39,11 +39,10 @@ Partial Class GearboxGearDialog Me.Label4 = New System.Windows.Forms.Label() Me.PnShiftPoly = New System.Windows.Forms.Panel() Me.Label5 = New System.Windows.Forms.Label() - Me.BtBrowseFld = New System.Windows.Forms.Button() - Me.TbFld = New System.Windows.Forms.TextBox() + Me.TbMaxTorque = New System.Windows.Forms.TextBox() Me.PnFld = New System.Windows.Forms.Panel() - Me.Label6 = New System.Windows.Forms.Label() Me.BtPrevious = New System.Windows.Forms.Button() + Me.Label6 = New System.Windows.Forms.Label() Me.TableLayoutPanel1.SuspendLayout() Me.PnShiftPoly.SuspendLayout() Me.PnFld.SuspendLayout() @@ -57,7 +56,7 @@ Partial Class GearboxGearDialog Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) Me.TableLayoutPanel1.Controls.Add(Me.OK_Button, 0, 0) Me.TableLayoutPanel1.Controls.Add(Me.Cancel_Button, 1, 0) - Me.TableLayoutPanel1.Location = New System.Drawing.Point(377, 210) + Me.TableLayoutPanel1.Location = New System.Drawing.Point(370, 184) Me.TableLayoutPanel1.Name = "TableLayoutPanel1" Me.TableLayoutPanel1.RowCount = 1 Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) @@ -147,7 +146,7 @@ Partial Class GearboxGearDialog 'BtNext ' Me.BtNext.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) - Me.BtNext.Location = New System.Drawing.Point(203, 213) + Me.BtNext.Location = New System.Drawing.Point(196, 187) Me.BtNext.Name = "BtNext" Me.BtNext.Size = New System.Drawing.Size(67, 23) Me.BtNext.TabIndex = 11 @@ -195,64 +194,53 @@ Partial Class GearboxGearDialog Me.Label5.AutoSize = True Me.Label5.Location = New System.Drawing.Point(1, 5) Me.Label5.Name = "Label5" - Me.Label5.Size = New System.Drawing.Size(97, 13) + Me.Label5.Size = New System.Drawing.Size(123, 13) Me.Label5.TabIndex = 0 - Me.Label5.Text = "Full Load Curve file" - ' - 'BtBrowseFld - ' - Me.BtBrowseFld.Image = CType(resources.GetObject("BtBrowseFld.Image"), System.Drawing.Image) - Me.BtBrowseFld.Location = New System.Drawing.Point(478, 17) - Me.BtBrowseFld.Name = "BtBrowseFld" - Me.BtBrowseFld.Size = New System.Drawing.Size(24, 24) - Me.BtBrowseFld.TabIndex = 2 - Me.BtBrowseFld.TabStop = False - Me.BtBrowseFld.UseVisualStyleBackColor = True + Me.Label5.Text = "Maximum allowed torque" ' - 'TbFld + 'TbMaxTorque ' - Me.TbFld.Location = New System.Drawing.Point(2, 19) - Me.TbFld.Name = "TbFld" - Me.TbFld.Size = New System.Drawing.Size(476, 20) - Me.TbFld.TabIndex = 1 + Me.TbMaxTorque.Location = New System.Drawing.Point(2, 19) + Me.TbMaxTorque.Name = "TbMaxTorque" + Me.TbMaxTorque.Size = New System.Drawing.Size(88, 20) + Me.TbMaxTorque.TabIndex = 1 ' 'PnFld ' Me.PnFld.Controls.Add(Me.Label6) - Me.PnFld.Controls.Add(Me.TbFld) - Me.PnFld.Controls.Add(Me.BtBrowseFld) + Me.PnFld.Controls.Add(Me.TbMaxTorque) Me.PnFld.Controls.Add(Me.Label5) Me.PnFld.Location = New System.Drawing.Point(10, 126) Me.PnFld.Name = "PnFld" - Me.PnFld.Size = New System.Drawing.Size(513, 61) + Me.PnFld.Size = New System.Drawing.Size(513, 46) Me.PnFld.TabIndex = 9 ' - 'Label6 - ' - Me.Label6.AutoSize = True - Me.Label6.Location = New System.Drawing.Point(1, 41) - Me.Label6.Name = "Label6" - Me.Label6.Size = New System.Drawing.Size(347, 13) - Me.Label6.TabIndex = 3 - Me.Label6.Text = "(If no file is defined the Full Load Curve from the Engine File will be used)" - ' 'BtPrevious ' Me.BtPrevious.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) - Me.BtPrevious.Location = New System.Drawing.Point(136, 213) + Me.BtPrevious.Location = New System.Drawing.Point(129, 187) Me.BtPrevious.Name = "BtPrevious" Me.BtPrevious.Size = New System.Drawing.Size(67, 23) Me.BtPrevious.TabIndex = 10 Me.BtPrevious.Text = "< &Previous" Me.BtPrevious.UseVisualStyleBackColor = True ' + 'Label6 + ' + Me.Label6.AutoSize = True + Me.Label6.Location = New System.Drawing.Point(96, 22) + Me.Label6.Name = "Label6" + Me.Label6.Size = New System.Drawing.Size(29, 13) + Me.Label6.TabIndex = 2 + Me.Label6.Text = "[Nm]" + ' 'GearboxGearDialog ' Me.AcceptButton = Me.OK_Button Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.CancelButton = Me.Cancel_Button - Me.ClientSize = New System.Drawing.Size(528, 254) + Me.ClientSize = New System.Drawing.Size(528, 225) Me.Controls.Add(Me.BtPrevious) Me.Controls.Add(Me.PnFld) Me.Controls.Add(Me.PnShiftPoly) @@ -297,10 +285,9 @@ Partial Class GearboxGearDialog Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents PnShiftPoly As System.Windows.Forms.Panel Friend WithEvents Label5 As System.Windows.Forms.Label - Friend WithEvents BtBrowseFld As System.Windows.Forms.Button - Friend WithEvents TbFld As System.Windows.Forms.TextBox + Friend WithEvents TbMaxTorque As System.Windows.Forms.TextBox Friend WithEvents PnFld As System.Windows.Forms.Panel - Friend WithEvents Label6 As System.Windows.Forms.Label Friend WithEvents BtPrevious As System.Windows.Forms.Button + Friend WithEvents Label6 As System.Windows.Forms.Label End Class diff --git a/VECTO/GUI/GearboxGearDialog.resx b/VECTO/GUI/GearboxGearDialog.resx index 8547a1a13733e7be98a611d6e03f887a46cb2616..859d7075df62d5435774a8a6d6f3355c4355e97c 100644 --- a/VECTO/GUI/GearboxGearDialog.resx +++ b/VECTO/GUI/GearboxGearDialog.resx @@ -121,7 +121,7 @@ <data name="BtBrowse.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw + YQUAAAAJcEhZcwAADsEAAA7BAbiRa+0AAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw 0kIrs5JsTOcKRANNEs0827KM0BA1MlSo0G3o1DxkEsso1JqH8rBUSlPzPOfSeajkbu+7NSl/9MD147u/ 776eF96P0VbB7+6Q8tFZJcCH2gj01wsx0BD5F5+aRFA1iTR99ZERjH+HlKHLxexgEoZao0Geh96mY2FC AkBpYlX7HL3PhBpjbXNIYWP5DjaWDKwv3MKMKomKMHIXGDWikaGu5gw8n3LhUWKXZ6wbBL+0tyk/Fwk5 @@ -139,25 +139,7 @@ <data name="BtShiftPolyBrowse.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw - 0kIrs5JsTOcKRANNEs0827KM0BA1MlSo0G3o1DxkEsso1JqH8rBUSlPzPOfSeajkbu+7NSl/9MD147u/ - 776eF96P0VbB7+6Q8tFZJcCH2gj01wsx0BD5F5+aRFA1iTR99ZERjH+HlKHLxexgEoZao0Geh96mY2FC - AkBpYlX7HL3PhBpjbXNIYWP5DjaWDKwv3MKMKomKMHIXGDWikaGu5gw8n3LhUWKXZ6wbBL+0tyk/Fwk5 - FJKv98Rjo/ca0J9AqakKxr5ye7iU7sCufBuFSfBjIYduXldvQnKdMg5r3fEmQVe1AO7FtkecH1rDvtAK - TtnsDCpYmxNjddbIjBgreki+2BELXWccVEoRAqu8EPTEC2Sp03223KqUCbsMSw0VrEzfhG4qG7rJbCwb - Ifnsmyt4/1oAX5kHqtUSnKj2pQIHsZWCCKzTLUAFSxNZWBrPwnfCWCa0ekiuaL6As408yNVSxPYI4FbI - gWM2u4ybxwIRsJKZBoH2ayYWRzOg+ULQX+HndMikpxDSxINC9wJRyiAcatiJPQUcuBTawOGxQWCZYG4Q - kIJ6OA3qoTTMD6bhW08iAmp98GqlBdHKABxrcacCb7kj3CQcKmAVM8G8vE1BBfODqZhTpWJ2IIUevV3C - x1HZfkS1+yOk1XOLgFvGgmWcuYYZzvChAlKc7ruBqY/JVNBYEobiB4HgFbnCv9HdJPCs4MIxl43tMWYj - zEv6MhlSIMXJnuuY6DL8gTVFoajMP4+68ovg5bvisHw3FXDTWBDn8ehNmKatIlSjehmDcWUSxt4lUkF5 - znEUpPhBmncStY+CcSDLGT4VzrBPtkJz2TnD5j/TLQ/ndEjD5F01Qgy3XkWnXIj4yIOx+ld7DV8wGLax - DI5ltLncQmRWZoy2Tnsl/zQ5DTnBvRQ/b2P8n2EwfgPZDDiygt3V8AAAAABJRU5ErkJggg== -</value> - </data> - <data name="BtBrowseFld.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> - <value> - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw + YQUAAAAJcEhZcwAADsEAAA7BAbiRa+0AAALVSURBVDhPhZJrSJNhGIYXOs1Nc8o8gJWZ+UNEEupPxDAw 0kIrs5JsTOcKRANNEs0827KM0BA1MlSo0G3o1DxkEsso1JqH8rBUSlPzPOfSeajkbu+7NSl/9MD147u/ 776eF96P0VbB7+6Q8tFZJcCH2gj01wsx0BD5F5+aRFA1iTR99ZERjH+HlKHLxexgEoZao0Geh96mY2FC AkBpYlX7HL3PhBpjbXNIYWP5DjaWDKwv3MKMKomKMHIXGDWikaGu5gw8n3LhUWKXZ6wbBL+0tyk/Fwk5 diff --git a/VECTO/GUI/GearboxGearDialog.vb b/VECTO/GUI/GearboxGearDialog.vb index b237053189851e7dcf9a1de2a406383c569bffe6..df1841fa57ade9d095badc59374bdf961b495a19 100644 --- a/VECTO/GUI/GearboxGearDialog.vb +++ b/VECTO/GUI/GearboxGearDialog.vb @@ -88,12 +88,6 @@ Public Class GearboxGearDialog End If End Sub - Private Sub BtBrowseFld_Click(sender As Object, e As EventArgs) Handles BtBrowseFld.Click - If fbFLD.OpenDialog(fFileRepl(TbFld.Text, GbxPath)) Then - TbFld.Text = fFileWoDir(fbFLD.Files(0), GbxPath) - End If - End Sub - Private Sub Button1_Click(sender As Object, e As EventArgs) Handles BtPrevious.Click If Not IsNumeric(TbRatio.Text) Then MsgBox("Gear ratio is invalid!") diff --git a/VECTO/Input Files/cAux.vb b/VECTO/Input Files/cAux.vb index 5ce00d8d8c66d0b14c707bc73de7936d3386db67..f24758078d6b24cae5447edc08a9d265dd9a0407 100644 --- a/VECTO/Input Files/cAux.vb +++ b/VECTO/Input Files/cAux.vb @@ -14,165 +14,129 @@ ''' </summary> ''' <remarks></remarks> Public Class cAux - - ''' <summary> - ''' Input file path (.vaux) - ''' </summary> - ''' <remarks></remarks> - Public Filepath As String - - ''' <summary> - ''' Transmission ratio to engine speed [-] - ''' </summary> - ''' <remarks></remarks> - Public TransRatio As Single - - ''' <summary> - ''' Efficiency to engine [-] - ''' </summary> - ''' <remarks></remarks> - Public EffToEng As Single - - ''' <summary> - ''' Efficiency auxiliary to supply [-] - ''' </summary> - ''' <remarks></remarks> - Public EffToSply As Single - - ''' <summary> - ''' Efficiency map - ''' </summary> - ''' <remarks>x= Auxiliary speed [rpm]; y= Supply power [kW]; z= Mechanical power [kW]. Note that the columns in the input file are different!</remarks> - Private EffMap As cDelaunayMap - - ''' <summary> - ''' New instance. Creates new efficiency map - ''' </summary> - ''' <remarks></remarks> - Public Sub New() - EffMap = New cDelaunayMap - End Sub - - ''' <summary> - ''' Read input file (.vaux) - ''' </summary> - ''' <returns>True if successful, else False.</returns> - ''' <remarks></remarks> - Public Function Readfile() As Boolean - Dim MsgSrc As String - Dim file As cFile_V3 - Dim line As String() - - MsgSrc = "Main/ReadInp/Aux" - - 'Open file - Abort if file not accessible - file = New cFile_V3 - If Not file.OpenRead(Filepath) Then - file = Nothing - WorkerMsg(tMsgID.Err, "Failed to open file (" & Filepath & ") !", MsgSrc) - Return False - End If - - 'Map reset - EffMap = New cDelaunayMap - - 'Abort if file is empty - If file.EndOfFile Then GoTo lbFileEndErr - - 'Read file - Try - - 'Transmission ration to engine rpm [-] - file.ReadLine() - If file.EndOfFile Then GoTo lbFileEndErr - line = file.ReadLine - TransRatio = CSng(line(0)) - - 'Efficiency to engine [-] - file.ReadLine() - If file.EndOfFile Then GoTo lbFileEndErr - line = file.ReadLine - EffToEng = CSng(line(0)) - - 'Efficiency auxiliary to supply [-] - file.ReadLine() - If file.EndOfFile Then GoTo lbFileEndErr - line = file.ReadLine - EffToSply = CSng(line(0)) - - 'Efficiency Map - file.ReadLine() - If file.EndOfFile Then GoTo lbFileEndErr - - 'Column 1 = Auxiliary speed [rpm] => X-axis - 'Column 2 = Mechanical power [kW] => Z-Axis (!) - 'Column 3 = Output power [kW] => Y-Axis (!) - - Do While Not file.EndOfFile - line = file.ReadLine - EffMap.AddPoints(CDbl(line(0)), CDbl(line(2)), CDbl(line(1))) - Loop - - 'Triangulate map - If Not EffMap.Triangulate Then - WorkerMsg(tMsgID.Err, "Aux Map is invalid! (Triangulation Error)", MsgSrc) - GoTo lbErr - End If - - Catch ex As Exception - - WorkerMsg(tMsgID.Err, "Error while reading aux file! (" & ex.Message & ")", MsgSrc) - GoTo lbErr - - End Try - - file.Close() - - Return True + ''' <summary> + ''' Input file path (.vaux) + ''' </summary> + ''' <remarks></remarks> + Public Filepath As String + + ''' <summary> + ''' Transmission ratio to engine speed [-] + ''' </summary> + ''' <remarks></remarks> + Public TransRatio As Single + + ''' <summary> + ''' Efficiency to engine [-] + ''' </summary> + ''' <remarks></remarks> + Public EffToEng As Single + + ''' <summary> + ''' Efficiency auxiliary to supply [-] + ''' </summary> + ''' <remarks></remarks> + Public EffToSply As Single + + ''' <summary> + ''' Efficiency map + ''' </summary> + ''' <remarks>x= Auxiliary speed [rpm]; y= Supply power [kW]; z= Mechanical power [kW]. Note that the columns in the input file are different!</remarks> + Private EffMap As cDelaunayMap + + ''' <summary> + ''' New instance. Creates new efficiency map + ''' </summary> + ''' <remarks></remarks> + Public Sub New() + EffMap = New cDelaunayMap + End Sub + + ''' <summary> + ''' Read input file (.vaux) + ''' </summary> + ''' <returns>True if successful, else False.</returns> + ''' <remarks></remarks> + Public Function Readfile() As Boolean + Dim MsgSrc As String + Dim file As cFile_V3 + Dim line As String() + + MsgSrc = "Main/ReadInp/Aux" + + 'Open file - Abort if file not accessible + file = New cFile_V3 + If Not file.OpenRead(Filepath) Then + file = Nothing + WorkerMsg(tMsgID.Err, "Failed to open file (" & Filepath & ") !", MsgSrc) + Return False + End If + + 'Map reset + EffMap = New cDelaunayMap + + 'Abort if file is empty + If file.EndOfFile Then GoTo lbFileEndErr + + 'Read file + Try + + 'Transmission ration to engine rpm [-] + file.ReadLine() + If file.EndOfFile Then GoTo lbFileEndErr + line = file.ReadLine + TransRatio = CSng(line(0)) + + 'Efficiency to engine [-] + file.ReadLine() + If file.EndOfFile Then GoTo lbFileEndErr + line = file.ReadLine + EffToEng = CSng(line(0)) + + 'Efficiency auxiliary to supply [-] + file.ReadLine() + If file.EndOfFile Then GoTo lbFileEndErr + line = file.ReadLine + EffToSply = CSng(line(0)) + + 'Efficiency Map + file.ReadLine() + If file.EndOfFile Then GoTo lbFileEndErr + + 'Column 1 = Auxiliary speed [rpm] => X-axis + 'Column 2 = Mechanical power [kW] => Z-Axis (!) + 'Column 3 = Output power [kW] => Y-Axis (!) + + Do While Not file.EndOfFile + line = file.ReadLine + EffMap.AddPoints(CDbl(line(0)), CDbl(line(2)), CDbl(line(1))) + Loop + + 'Triangulate map + If Not EffMap.Triangulate Then + WorkerMsg(tMsgID.Err, "Aux Map is invalid! (Triangulation Error)", MsgSrc) + GoTo lbErr + End If + + Catch ex As Exception + + WorkerMsg(tMsgID.Err, "Error while reading aux file! (" & ex.Message & ")", MsgSrc) + GoTo lbErr + + End Try + + file.Close() + + Return True lbFileEndErr: - WorkerMsg(tMsgID.Err, "Unexpected end of file (aux)!", MsgSrc) + WorkerMsg(tMsgID.Err, "Unexpected end of file (aux)!", MsgSrc) lbErr: - file.Close() - Return False - - - - End Function - - ''' <summary> - ''' Returns power demand for given engine speed and supply power - ''' </summary> - ''' <param name="nU">Engine speed [1/min]</param> - ''' <param name="Psupply">Supply power [kW] from driving cycle</param> - ''' <returns>Power demand [kW]</returns> - ''' <remarks></remarks> - Public Function Paux(ByVal nU As Single, ByVal Psupply As Single) As Single - - Dim nUaux As Single - Dim PsplyAux As Single - Dim PauxEff As Single - - nUaux = nU * TransRatio - PsplyAux = Psupply / EffToSply - - PauxEff = EffMap.Intpol(nUaux, PsplyAux) - - If EffMap.ExtrapolError Then - MODdata.ModErrors.AuxMapExtr = fFILE(Filepath, False) & ", U= " & nUaux & " [1/min], PsupplyAux= " & PsplyAux & " [kW]" - Return 0 - End If - - Return PauxEff / EffToEng - - End Function - - - - - + file.Close() + Return False + End Function End Class diff --git a/VECTO/Input Files/cDRI.vb b/VECTO/Input Files/cDRI.vb index 39f66437cc14f376210840b2984f24d43ee5c1dd..846c5b1fc8254391eeba77b7bd8ac4f6db4fbf5d 100644 --- a/VECTO/Input Files/cDRI.vb +++ b/VECTO/Input Files/cDRI.vb @@ -15,946 +15,652 @@ Imports System.Collections.Generic ''' </summary> ''' <remarks></remarks> Public Class cDRI + ''' <summary> + ''' Last index of driving cycle columns + ''' </summary> + ''' <remarks></remarks> + Public tDim As Integer + + ''' <summary> + ''' Dictionary holding all driving cycle columns. Key= Parameter-ID (enum), Value= parameter value per time step + ''' </summary> + ''' <remarks></remarks> + Public Values As Dictionary(Of tDriComp, List(Of Double)) + + ''' <summary> + ''' First time stamp in driving cycle + ''' </summary> + ''' <remarks></remarks> + Public t0 As Integer + + ''' <summary> + ''' Full filepath. Needs to be defined before calling ReadFile. + ''' </summary> + ''' <remarks></remarks> + Public FilePath As String + + ''' <summary> + ''' True= Cycle includes time stamps. Defined in ReadFile. + ''' </summary> + ''' <remarks></remarks> + Public Tvorg As Boolean + + ''' <summary> + ''' True= Cycle includes time vehicle speed. Defined in ReadFile. + ''' </summary> + ''' <remarks></remarks> + Public Vvorg As Boolean + + ''' <summary> + ''' True= Cycle includes engine power. Defined in ReadFile. + ''' </summary> + ''' <remarks></remarks> + Public Pvorg As Boolean + + + Public PwheelVorg As Boolean + + ''' <summary> + ''' True= Cycle includes additional auxiliary power demand (not to be confused with auxiliary supply power). Defined in ReadFile. + ''' </summary> + ''' <remarks></remarks> + Public PaddVorg As Boolean + + ''' <summary> + ''' True= Cycle includes engine speed. Defined in ReadFile. + ''' </summary> + ''' <remarks></remarks> + Public Nvorg As Boolean + + ''' <summary> + ''' True= Cycle includes gear input. Defined in ReadFile. + ''' </summary> + ''' <remarks></remarks> + Public Gvorg As Boolean + + ''' <summary> + ''' True= Cycle includes slope. Defined in ReadFile. + ''' </summary> + ''' <remarks></remarks> + Public GradVorg As Boolean + + ''' <summary> + ''' True= Cycle includes auxiliary supply power for at least one auxiliary. Defined in ReadFile. + ''' </summary> + ''' <remarks></remarks> + Public AuxDef As Boolean + + ''' <summary> + ''' Auxiliary supply power input. Key= Aux-ID, Value= Supply power [kW] per time step + ''' </summary> + ''' <remarks></remarks> + Public AuxComponents As Dictionary(Of String, List(Of Single)) + + ''' <summary> + ''' True= Cycle includes VairRes and VairBeta for side wind correction. Defined in ReadFile. + ''' </summary> + ''' <remarks></remarks> + Public VairVorg As Boolean + + ''' <summary> + ''' True= Cycle includes distance. Defined in ReadFile. + ''' </summary> + ''' <remarks></remarks> + Public Scycle As Boolean + + ''' <summary> + ''' True= Cycle includes slope. Defined in ReadFile. + ''' </summary> + ''' <remarks></remarks> + Public VoglS As List(Of Double) + + ''' <summary> + ''' Reset all fields, etc. berfore loading new file. Called by ReadFile. + ''' </summary> + ''' <remarks></remarks> + Private Sub ResetMe() + Values = Nothing + PaddVorg = False + Tvorg = False + Vvorg = False + GradVorg = False + Nvorg = False + Gvorg = False + Pvorg = False + PwheelVorg = False + tDim = -1 + t0 = 1 'Default if no time steps are defined in driving cycle + AuxDef = False + AuxComponents = Nothing + VairVorg = False + Scycle = False + End Sub + + ''' <summary> + ''' Read driving cycle. FilePath must be defined before calling. + ''' </summary> + ''' <returns>True= File loaded successfully.</returns> + ''' <remarks></remarks> + Public Function ReadFile() As Boolean + Dim file As cFile_V3 + Dim line As String() + Dim s1 As Integer + Dim s As Integer + Dim txt As String + Dim Comp As tDriComp + Dim AuxComp As tAuxComp + Dim AuxID As String + Dim Svorg As Boolean = False + + Dim DRIcheck As Dictionary(Of tDriComp, Boolean) + Dim Spalten As Dictionary(Of tDriComp, Integer) + Dim sKV As KeyValuePair(Of tDriComp, Integer) + + Dim AuxSpalten As Dictionary(Of String, Integer) = Nothing + Dim Mvorg As Boolean = False + + + Dim MsgSrc As String + + + MsgSrc = "Main/ReadInp/DRI" + + + 'Reset + ResetMe() + + 'Abort if there's no file + If FilePath = "" OrElse Not IO.File.Exists(FilePath) Then + WorkerMsg(tMsgID.Err, "Cycle file not found (" & FilePath & ") !", MsgSrc) + Return False + End If + + 'EmComp Init + '...now in New() + + 'Open file + file = New cFile_V3 + If Not file.OpenRead(FilePath) Then + WorkerMsg(tMsgID.Err, "Failed to open file (" & FilePath & ") !", MsgSrc) + file = Nothing + Return False + End If + + DRIcheck = New Dictionary(Of tDriComp, Boolean) + DRIcheck.Add(tDriComp.t, False) + DRIcheck.Add(tDriComp.V, False) + DRIcheck.Add(tDriComp.Grad, False) + DRIcheck.Add(tDriComp.nU, False) + DRIcheck.Add(tDriComp.Gears, False) + DRIcheck.Add(tDriComp.Padd, False) + DRIcheck.Add(tDriComp.Pe, False) + DRIcheck.Add(tDriComp.VairVres, False) + DRIcheck.Add(tDriComp.VairBeta, False) + DRIcheck.Add(tDriComp.s, False) + DRIcheck.Add(tDriComp.StopTime, False) + DRIcheck.Add(tDriComp.Torque, False) + DRIcheck.Add(tDriComp.Pwheel, False) + + If file.EndOfFile Then + WorkerMsg(tMsgID.Err, "Driving cycle invalid!", MsgSrc) + Return False + End If + + Spalten = New Dictionary(Of tDriComp, Integer) + Values = New Dictionary(Of tDriComp, List(Of Double)) + + '*** + '*** First row: Name/Identification of the Components + line = file.ReadLine + + 'Check Number of Columns/Components + s1 = UBound(line) + + For s = 0 To s1 + + Comp = fDriComp(line(s)) - ''' <summary> - ''' Last index of driving cycle columns - ''' </summary> - ''' <remarks></remarks> - Public tDim As Integer - - ''' <summary> - ''' Dictionary holding all driving cycle columns. Key= Parameter-ID (enum), Value= parameter value per time step - ''' </summary> - ''' <remarks></remarks> - Public Values As Dictionary(Of tDriComp, List(Of Double)) - - ''' <summary> - ''' First time stamp in driving cycle - ''' </summary> - ''' <remarks></remarks> - Public t0 As Integer - - ''' <summary> - ''' Full filepath. Needs to be defined before calling ReadFile. - ''' </summary> - ''' <remarks></remarks> - Public FilePath As String - - ''' <summary> - ''' True= Cycle includes time stamps. Defined in ReadFile. - ''' </summary> - ''' <remarks></remarks> - Public Tvorg As Boolean - - ''' <summary> - ''' True= Cycle includes time vehicle speed. Defined in ReadFile. - ''' </summary> - ''' <remarks></remarks> - Public Vvorg As Boolean - - ''' <summary> - ''' True= Cycle includes engine power. Defined in ReadFile. - ''' </summary> - ''' <remarks></remarks> - Public Pvorg As Boolean - - - Public PwheelVorg As Boolean - - ''' <summary> - ''' True= Cycle includes additional auxiliary power demand (not to be confused with auxiliary supply power). Defined in ReadFile. - ''' </summary> - ''' <remarks></remarks> - Public PaddVorg As Boolean - - ''' <summary> - ''' True= Cycle includes engine speed. Defined in ReadFile. - ''' </summary> - ''' <remarks></remarks> - Public Nvorg As Boolean - - ''' <summary> - ''' True= Cycle includes gear input. Defined in ReadFile. - ''' </summary> - ''' <remarks></remarks> - Public Gvorg As Boolean - - ''' <summary> - ''' True= Cycle includes slope. Defined in ReadFile. - ''' </summary> - ''' <remarks></remarks> - Public GradVorg As Boolean - - ''' <summary> - ''' True= Cycle includes auxiliary supply power for at least one auxiliary. Defined in ReadFile. - ''' </summary> - ''' <remarks></remarks> - Public AuxDef As Boolean - - ''' <summary> - ''' Auxiliary supply power input. Key= Aux-ID, Value= Supply power [kW] per time step - ''' </summary> - ''' <remarks></remarks> - Public AuxComponents As Dictionary(Of String, List(Of Single)) - - ''' <summary> - ''' True= Cycle includes VairRes and VairBeta for side wind correction. Defined in ReadFile. - ''' </summary> - ''' <remarks></remarks> - Public VairVorg As Boolean - - ''' <summary> - ''' True= Cycle includes distance. Defined in ReadFile. - ''' </summary> - ''' <remarks></remarks> - Public Scycle As Boolean - - ''' <summary> - ''' True= Cycle includes slope. Defined in ReadFile. - ''' </summary> - ''' <remarks></remarks> - Public VoglS As List(Of Double) - - ''' <summary> - ''' Reset all fields, etc. berfore loading new file. Called by ReadFile. - ''' </summary> - ''' <remarks></remarks> - Private Sub ResetMe() - Values = Nothing - PaddVorg = False - Tvorg = False - Vvorg = False - GradVorg = False - Nvorg = False - Gvorg = False - Pvorg = False - PwheelVorg = False - tDim = -1 - t0 = 1 'Default if no time steps are defined in driving cycle - AuxDef = False - AuxComponents = Nothing - VairVorg = False - Scycle = False - End Sub - - ''' <summary> - ''' Read driving cycle. FilePath must be defined before calling. - ''' </summary> - ''' <returns>True= File loaded successfully.</returns> - ''' <remarks></remarks> - Public Function ReadFile() As Boolean - Dim file As cFile_V3 - Dim line As String() - Dim s1 As Integer - Dim s As Integer - Dim txt As String - Dim Comp As tDriComp - Dim AuxComp As tAuxComp - Dim AuxID As String - Dim Svorg As Boolean = False - - Dim DRIcheck As Dictionary(Of tDriComp, Boolean) - Dim Spalten As Dictionary(Of tDriComp, Integer) - Dim sKV As KeyValuePair(Of tDriComp, Integer) - - Dim AuxSpalten As Dictionary(Of String, Integer) = Nothing - Dim Mvorg As Boolean = False - - - Dim MsgSrc As String - - - MsgSrc = "Main/ReadInp/DRI" - - - 'Reset - ResetMe() - - 'Abort if there's no file - If FilePath = "" OrElse Not IO.File.Exists(FilePath) Then - WorkerMsg(tMsgID.Err, "Cycle file not found (" & FilePath & ") !", MsgSrc) - Return False - End If - - 'EmComp Init - '...now in New() - - 'Open file - file = New cFile_V3 - If Not file.OpenRead(FilePath) Then - WorkerMsg(tMsgID.Err, "Failed to open file (" & FilePath & ") !", MsgSrc) - file = Nothing - Return False - End If - - DRIcheck = New Dictionary(Of tDriComp, Boolean) - DRIcheck.Add(tDriComp.t, False) - DRIcheck.Add(tDriComp.V, False) - DRIcheck.Add(tDriComp.Grad, False) - DRIcheck.Add(tDriComp.nU, False) - DRIcheck.Add(tDriComp.Gears, False) - DRIcheck.Add(tDriComp.Padd, False) - DRIcheck.Add(tDriComp.Pe, False) - DRIcheck.Add(tDriComp.VairVres, False) - DRIcheck.Add(tDriComp.VairBeta, False) - DRIcheck.Add(tDriComp.s, False) - DRIcheck.Add(tDriComp.StopTime, False) - DRIcheck.Add(tDriComp.Torque, False) - DRIcheck.Add(tDriComp.Pwheel, False) - - If file.EndOfFile Then - WorkerMsg(tMsgID.Err, "Driving cycle invalid!", MsgSrc) - Return False - End If - - Spalten = New Dictionary(Of tDriComp, Integer) - Values = New Dictionary(Of tDriComp, List(Of Double)) - - '*** - '*** First row: Name/Identification of the Components - line = file.ReadLine - - 'Check Number of Columns/Components - s1 = UBound(line) - - For s = 0 To s1 + 'Falls DRIcomp = Undefined dann wirds als EXS-Comp oder als Emission für KF-Erstellung / Eng-Analysis verwendet |@@| If used DRIcomp = Undefined it will get as EXS-Comp or Emission for KF-Creation / Eng-Analysis + If Comp = tDriComp.Undefined Then - Comp = fDriComp(line(s)) + AuxComp = fAuxComp(line(s)) - 'Falls DRIcomp = Undefined dann wirds als EXS-Comp oder als Emission für KF-Erstellung / Eng-Analysis verwendet |@@| If used DRIcomp = Undefined it will get as EXS-Comp or Emission for KF-Creation / Eng-Analysis - If Comp = tDriComp.Undefined Then + If AuxComp = tAuxComp.Undefined Then - AuxComp = fAuxComp(line(s)) + 'ERROR when component is unknown + WorkerMsg(tMsgID.Err, "'" & line(s) & "' is no valid cycle input parameter!", MsgSrc) + GoTo lbEr - If AuxComp = tAuxComp.Undefined Then + Else - 'ERROR when component is unknown - WorkerMsg(tMsgID.Err, "'" & line(s) & "' is no valid cycle input parameter!", MsgSrc) - GoTo lbEr + txt = fCompSubStr(line(s)) - Else + If Not AuxDef Then + AuxComponents = New Dictionary(Of String, List(Of Single)) + AuxSpalten = New Dictionary(Of String, Integer) + End If - txt = fCompSubStr(line(s)) + If AuxComponents.ContainsKey(txt) Then + WorkerMsg(tMsgID.Err, "Multiple definitions of auxiliary '" & txt & "' in driving cycle! Column " & s + 1, MsgSrc) + GoTo lbEr + End If - If Not AuxDef Then - AuxComponents = New Dictionary(Of String, List(Of Single)) - AuxSpalten = New Dictionary(Of String, Integer) - End If + AuxComponents.Add(txt, New List(Of Single)) + AuxSpalten.Add(txt, s) - If AuxComponents.ContainsKey(txt) Then - WorkerMsg(tMsgID.Err, "Multiple definitions of auxiliary '" & txt & "' in driving cycle! Column " & s + 1, MsgSrc) - GoTo lbEr - End If + AuxDef = True - AuxComponents.Add(txt, New List(Of Single)) - AuxSpalten.Add(txt, s) + End If - AuxDef = True - End If + Else + If DRIcheck(Comp) Then + WorkerMsg(tMsgID.Err, "Component '" & line(s) & "' already defined! Column " & s + 1, MsgSrc) + GoTo lbEr + End If + DRIcheck(Comp) = True + Spalten.Add(Comp, s) + Values.Add(Comp, New List(Of Double)) - Else + End If - If DRIcheck(Comp) Then - WorkerMsg(tMsgID.Err, "Component '" & line(s) & "' already defined! Column " & s + 1, MsgSrc) - GoTo lbEr - End If + Next - DRIcheck(Comp) = True - Spalten.Add(Comp, s) - Values.Add(Comp, New List(Of Double)) + 'Set Gvorg/Nvorg: + Tvorg = DRIcheck(tDriComp.t) + Vvorg = DRIcheck(tDriComp.V) + Svorg = DRIcheck(tDriComp.s) + Gvorg = DRIcheck(tDriComp.Gears) + Nvorg = DRIcheck(tDriComp.nU) + Pvorg = DRIcheck(tDriComp.Pe) + PaddVorg = DRIcheck(tDriComp.Padd) + GradVorg = DRIcheck(tDriComp.Grad) + VairVorg = DRIcheck(tDriComp.VairVres) And DRIcheck(tDriComp.VairBeta) + Mvorg = DRIcheck(tDriComp.Torque) + PwheelVorg = DRIcheck(tDriComp.Pwheel) - End If + If Mvorg And Pvorg Then + WorkerMsg(tMsgID.Warn, "Engine torque and power defined in cycle! Torque will be ignored!", MsgSrc) + Mvorg = False + End If - Next - 'Set Gvorg/Nvorg: - Tvorg = DRIcheck(tDriComp.t) - Vvorg = DRIcheck(tDriComp.V) - Svorg = DRIcheck(tDriComp.s) - Gvorg = DRIcheck(tDriComp.Gears) - Nvorg = DRIcheck(tDriComp.nU) - Pvorg = DRIcheck(tDriComp.Pe) - PaddVorg = DRIcheck(tDriComp.Padd) - GradVorg = DRIcheck(tDriComp.Grad) - VairVorg = DRIcheck(tDriComp.VairVres) And DRIcheck(tDriComp.VairBeta) - Mvorg = DRIcheck(tDriComp.Torque) - PwheelVorg = DRIcheck(tDriComp.Pwheel) + Try + Do While Not file.EndOfFile + tDim += 1 'wird in ResetMe zurück gesetzt + line = file.ReadLine - If Mvorg And Pvorg Then - WorkerMsg(tMsgID.Warn, "Engine torque and power defined in cycle! Torque will be ignored!", MsgSrc) - Mvorg = False - End If + For Each sKV In Spalten + If sKV.Key = tDriComp.Pe Or sKV.Key = tDriComp.Torque Then + If Trim(line(sKV.Value)) = sKey.EngDrag Then line(sKV.Value) = -999999 + End If - Try - Do While Not file.EndOfFile - tDim += 1 'wird in ResetMe zurück gesetzt - line = file.ReadLine + Values(sKV.Key).Add(CDbl(line(sKV.Value))) + Next - For Each sKV In Spalten + If AuxDef Then + For Each AuxID In AuxSpalten.Keys + AuxComponents(AuxID).Add(CSng(line(AuxSpalten(AuxID)))) + Next + End If - If sKV.Key = tDriComp.Pe Or sKV.Key = tDriComp.Torque Then - If Trim(line(sKV.Value)) = sKey.EngDrag Then line(sKV.Value) = -999999 - End If + Loop + Catch ex As Exception - Values(sKV.Key).Add(CDbl(line(sKV.Value))) - Next + WorkerMsg(tMsgID.Err, "Error during file read! Line number: " & tDim + 1 & " (" & FilePath & ")", MsgSrc, FilePath) + GoTo lbEr - If AuxDef Then - For Each AuxID In AuxSpalten.Keys - AuxComponents(AuxID).Add(CSng(line(AuxSpalten(AuxID)))) - Next - End If + End Try - Loop - Catch ex As Exception + file.Close() - WorkerMsg(tMsgID.Err, "Error during file read! Line number: " & tDim + 1 & " (" & FilePath & ")", MsgSrc, FilePath) - GoTo lbEr + Scycle = (Svorg And Not Tvorg) - End Try + If Vvorg Then + For s = 0 To tDim + Values(tDriComp.V)(s) /= 3.6 + If Values(tDriComp.V)(s) < 0.025 Then Values(tDriComp.V)(s) = 0 + Next + End If - file.Close() + If Mvorg And Nvorg Then + Values.Add(tDriComp.Pe, New List(Of Double)) + Pvorg = True + For s = 0 To tDim + Values(tDriComp.Pe).Add(nMtoPe(Values(tDriComp.nU)(s), Values(tDriComp.Torque)(s))) + Next + End If - Scycle = (Svorg And Not Tvorg) - - If Vvorg Then - For s = 0 To tDim - Values(tDriComp.V)(s) /= 3.6 - If Values(tDriComp.V)(s) < 0.025 Then Values(tDriComp.V)(s) = 0 - Next - End If - - If Mvorg And Nvorg Then - Values.Add(tDriComp.Pe, New List(Of Double)) - Pvorg = True - For s = 0 To tDim - Values(tDriComp.Pe).Add(nMtoPe(Values(tDriComp.nU)(s), Values(tDriComp.Torque)(s))) - Next - End If - - Return True + Return True lbEr: - file.Close() - - Return False + file.Close() - End Function + Return False + End Function - ''' <summary> - ''' Calculates altitude for each time step if driving cycle includes slope. - ''' </summary> - ''' <remarks></remarks> - Public Sub GradToAlt() - Dim i As Integer - Dim v0 As New List(Of Double) - Dim vg As List(Of Double) - Dim vs As List(Of Double) - Dim vv As List(Of Double) - Dim vt As List(Of Double) + ''' <summary> + ''' Calculates altitude for each time step if driving cycle includes slope. + ''' </summary> + ''' <remarks></remarks> + Public Sub GradToAlt() + Dim i As Integer + Dim v0 As New List(Of Double) + Dim vg As List(Of Double) + Dim vs As List(Of Double) + Dim vv As List(Of Double) + Dim vt As List(Of Double) - 'Skip if altitude is defined already - If Values.ContainsKey(tDriComp.Alt) Then Exit Sub + 'Skip if altitude is defined already + If Values.ContainsKey(tDriComp.Alt) Then Exit Sub - If GradVorg And Vvorg Then + If GradVorg And Vvorg Then - vg = Values(tDriComp.Grad) + vg = Values(tDriComp.Grad) - v0.Add(0) + v0.Add(0) - If Scycle Then + If Scycle Then - vs = Values(tDriComp.s) + vs = Values(tDriComp.s) - For i = 1 To tDim - v0.Add(v0(i - 1) + ((vg(i) + vg(i - 1)) / 200) * (vs(i) - vs(i - 1))) - Next + For i = 1 To tDim + v0.Add(v0(i - 1) + ((vg(i) + vg(i - 1)) / 200) * (vs(i) - vs(i - 1))) + Next - Else + Else - vv = Values(tDriComp.V) + vv = Values(tDriComp.V) - If Tvorg Then + If Tvorg Then - vt = Values(tDriComp.t) + vt = Values(tDriComp.t) - For i = 1 To tDim - v0.Add(v0(i - 1) + ((vg(i) + vg(i - 1)) / 200) * vv(i) * (vt(i) - vt(i - 1))) - Next + For i = 1 To tDim + v0.Add(v0(i - 1) + ((vg(i) + vg(i - 1)) / 200) * vv(i) * (vt(i) - vt(i - 1))) + Next - Else + Else - For i = 1 To tDim - v0.Add(v0(i - 1) + ((vg(i) + vg(i - 1)) / 200) * vv(i) * 1) - Next + For i = 1 To tDim + v0.Add(v0(i - 1) + ((vg(i) + vg(i - 1)) / 200) * vv(i) * 1) + Next - End If - End If + End If + End If + Else - Else - - For i = 0 To tDim - v0.Add(0) - Next - - End If - - Values.Add(tDriComp.Alt, v0) - Values.Remove(tDriComp.Grad) - - End Sub - - ''' <summary> - ''' Convert distance-based cycle to time-based cycle. - ''' </summary> - ''' <returns>True= Convertion successful.</returns> - ''' <remarks></remarks> - Public Function ConvStoT() As Boolean - Dim i As Integer - Dim j As Integer - Dim ds As Double - Dim vm As Double - Dim a As Double - Dim am As Double - Dim dv As Double - Dim s As Double - Dim t As Double - Dim dt As Double - Dim vstep As Double - Dim Dist As List(Of Double) - Dim Speed As List(Of Double) - Dim Alt As List(Of Double) - Dim StopTime As List(Of Double) - Dim Time As New List(Of Double) - Dim tValues As New Dictionary(Of tDriComp, List(Of Double)) - Dim tDist As New List(Of Double) - Dim hzTime As New List(Of Double) - Dim hzDist As New List(Of Double) - Dim hzValues As New Dictionary(Of tDriComp, List(Of Double)) - Dim ValKV As KeyValuePair(Of tDriComp, List(Of Double)) - Dim tmax As Integer + For i = 0 To tDim + v0.Add(0) + Next - Dim tAuxValues As Dictionary(Of String, List(Of Single)) = Nothing - Dim hzAuxValues As Dictionary(Of String, List(Of Single)) = Nothing - Dim AuxKV As KeyValuePair(Of String, List(Of Single)) + End If - Dim SpeedOgl As New List(Of Double) - Dim tSpeedOgl As New List(Of Double) - Dim hzSpeedOgl As New List(Of Double) + Values.Add(tDriComp.Alt, v0) + Values.Remove(tDriComp.Grad) + End Sub - Dim StopTimeError As Boolean = False - Dim MsgSrc As String + ''' <summary> + ''' Convert cycle to 1Hz. + ''' </summary> + ''' <returns>True= Convertion successful.</returns> + ''' <remarks></remarks> + Public Function ConvTo1Hz() As Boolean - MsgSrc = "Main/DRI/ConvStoT" + Dim tMin As Double + Dim tMax As Double + Dim tMid As Integer + Dim Anz As Integer + Dim z As Integer + Dim Time As Double + Dim t1 As Double + Dim Finish As Boolean + Dim NewValues As Dictionary(Of tDriComp, List(Of Double)) + Dim KV As KeyValuePair(Of tDriComp, List(Of Double)) + Dim KVd As KeyValuePair(Of tDriComp, Double) + Dim fTime As List(Of Double) + Dim Summe As Dictionary(Of tDriComp, Double) - If Not Values.ContainsKey(tDriComp.StopTime) Then - WorkerMsg(tMsgID.Err, "Stop time not defined in cycle (" & sKey.DRI.StopTime & ")!", MsgSrc) - Return False - End If + Dim NewAuxValues As Dictionary(Of String, List(Of Single)) = Nothing + Dim AuxKV As KeyValuePair(Of String, List(Of Single)) + Dim AuxSumme As Dictionary(Of String, Single) = Nothing - If Not Values.ContainsKey(tDriComp.V) Then - WorkerMsg(tMsgID.Err, "Vehicle speed not defined in cycle (" & sKey.DRI.V & ")!", MsgSrc) - Return False - End If + Dim MsgSrc As String - Dist = Values(tDriComp.s) - Speed = New List(Of Double) - For i = 0 To tDim - Speed.Add(Values(tDriComp.V)(i)) - SpeedOgl.Add(Values(tDriComp.V)(i)) - Next - - StopTime = Values(tDriComp.StopTime) - vstep = 0.001 - - If Values.ContainsKey(tDriComp.Alt) Then - Alt = Values(tDriComp.Alt) - Else - Alt = New List(Of Double) - For i = 0 To tDim - Alt.Add(0) - Next - Values.Add(tDriComp.Alt, Alt) - End If - - For Each ValKV In Values - If ValKV.Key <> tDriComp.s And ValKV.Key <> tDriComp.StopTime Then - tValues.Add(ValKV.Key, New List(Of Double)) - hzValues.Add(ValKV.Key, New List(Of Double)) - End If - Next - - If AuxDef Then - tAuxValues = New Dictionary(Of String, List(Of Single)) - hzAuxValues = New Dictionary(Of String, List(Of Single)) - For Each AuxKV In AuxComponents - tAuxValues.Add(AuxKV.Key, New List(Of Single)) - hzAuxValues.Add(AuxKV.Key, New List(Of Single)) - Next - End If - - 'Check if smallest distance step is smaller or equal 1m - For i = 1 To tDim - If Dist(i) - Dist(i - 1) > 1 Then - WorkerMsg(tMsgID.Err, "Distance-based cycles must not include larger distance-steps than 1[m]!", MsgSrc) - Return False - End If - Next - - '*********************************** Deceleration(Verzögerung) limit ******************************** - For i = tDim To 1 Step -1 - - ds = Dist(i) - Dist(i - 1) - - vm = (Speed(i) + Speed(i - 1)) / 2 - dv = Speed(i) - Speed(i - 1) - - a = vm * dv / ds - - am = VEC.aDesMin(vm) - - Do While a < am - - Speed(i - 1) -= vstep - - vm = (Speed(i) + Speed(i - 1)) / 2 - dv = Speed(i) - Speed(i - 1) - - a = vm * dv / ds - - am = VEC.aDesMin(vm) - - Loop - - Next - - - '*********************************** Create Time-sequence '*********************************** - t = 0 - s = Dist(0) - - Time.Add(t) - For Each ValKV In tValues - If ValKV.Key <> tDriComp.V Then tValues(ValKV.Key).Add(Values(ValKV.Key)(0)) - Next - tValues(tDriComp.V).Add(Speed(0)) - tSpeedOgl.Add(SpeedOgl(0)) - tDist.Add(s) - If AuxDef Then - For Each AuxKV In AuxComponents - tAuxValues(AuxKV.Key).Add(AuxKV.Value(0)) - Next - End If + MsgSrc = "DRI/Convert" + fTime = Values(tDriComp.t) - If Speed(0) < 0.0001 Then - - If StopTime(0) = 0 Then - WorkerMsg(tMsgID.Err, "Stop time = 0 at cylce start!", MsgSrc) - StopTimeError = True - End If - - t += StopTime(0) - Time.Add(t) - For Each ValKV In tValues - If ValKV.Key <> tDriComp.V Then tValues(ValKV.Key).Add(Values(ValKV.Key)(0)) - Next - tValues(tDriComp.V).Add(Speed(0)) - tSpeedOgl.Add(SpeedOgl(0)) - tDist.Add(s) - If AuxDef Then - For Each AuxKV In AuxComponents - tAuxValues(AuxKV.Key).Add(AuxKV.Value(0)) - Next - End If - End If - - For i = 0 To tDim - 1 - - vm = (Speed(i) + Speed(i + 1)) / 2 - - If vm = 0 Then - WorkerMsg(tMsgID.Err, "Speed can't be zero while distance changes! (line " & i.ToString & ")", MsgSrc) - Return False - End If - - ds = Dist(i + 1) - Dist(i) - dt = ds / vm - - t += dt - s += ds + 'Check whether Time is not reversed + For z = 1 To tDim + If fTime(z) < fTime(z - 1) Then + WorkerMsg(tMsgID.Err, + "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]", MsgSrc) + Return False + End If + Next - Time.Add(t) - For Each ValKV In tValues - If ValKV.Key <> tDriComp.V Then tValues(ValKV.Key).Add(Values(ValKV.Key)(i + 1)) - Next - tValues(tDriComp.V).Add(Speed(i + 1)) - tSpeedOgl.Add(SpeedOgl(i + 1)) - tDist.Add(s) - If AuxDef Then - For Each AuxKV In AuxComponents - tAuxValues(AuxKV.Key).Add(AuxKV.Value(i + 1)) - Next - End If + 'Define Time-range + t0 = CInt(Math.Round(fTime(0), 0, MidpointRounding.AwayFromZero)) + t1 = fTime(tDim) - If Speed(i + 1) < 0.0001 Then + 'Create Output, Total and Num-of-Dictionaries + NewValues = New Dictionary(Of tDriComp, List(Of Double)) + Summe = New Dictionary(Of tDriComp, Double) - If StopTime(i + 1) = 0 Then - WorkerMsg(tMsgID.Err, "Stop time = 0 at distance= " & s & "[m]!", MsgSrc) - StopTimeError = True - End If + For Each KV In Values + NewValues.Add(KV.Key, New List(Of Double)) + If KV.Key <> tDriComp.t Then Summe.Add(KV.Key, 0) + Next - t += StopTime(i + 1) + If AuxDef Then + NewAuxValues = New Dictionary(Of String, List(Of Single)) + AuxSumme = New Dictionary(Of String, Single) + For Each AuxKV In AuxComponents + NewAuxValues.Add(AuxKV.Key, New List(Of Single)) + AuxSumme.Add(AuxKV.Key, 0) + Next + End If - Time.Add(t) - For Each ValKV In tValues - If ValKV.Key <> tDriComp.V Then tValues(ValKV.Key).Add(Values(ValKV.Key)(i + 1)) - Next - tValues(tDriComp.V).Add(Speed(i + 1)) - tSpeedOgl.Add(SpeedOgl(i + 1)) - tDist.Add(s) + 'Start-values + tMin = fTime(0) + tMid = CInt(tMin) + tMax = tMid + 0.5 - If AuxDef Then - For Each AuxKV In AuxComponents - tAuxValues(AuxKV.Key).Add(AuxKV.Value(i + 1)) - Next - End If - - End If - - Next - - - If StopTimeError Then Return False - - '*********************************** Convert to 1Hz '*********************************** - i = 0 - j = -1 - tDim = Time.Count - 1 - s = 0 - - tmax = Math.Floor(Time(tDim)) - - - - Do - j += 1 - - hzTime.Add(j) - - Do While Time(i) <= hzTime(j) - i += 1 - Loop - - If Time(i) - Time(i - 1) = 0 Then - hzDist.Add(tDist(i - 1)) - Else - hzDist.Add((hzTime(j) - Time(i - 1)) * (tDist(i) - tDist(i - 1)) / (Time(i) - Time(i - 1)) + tDist(i - 1)) - End If - - If tDist(i) - tDist(i - 1) = 0 Then - For Each ValKV In tValues - If ValKV.Key = tDriComp.V Then - hzValues(ValKV.Key).Add(0) - Else - hzValues(ValKV.Key).Add(tValues(ValKV.Key)(i - 1)) - End If - Next - hzSpeedOgl.Add(0) - - If AuxDef Then - For Each AuxKV In AuxComponents - 'WRONG!! => hzAuxValues(AuxKV.Key).Add(AuxKV.Value(i - 1)) - hzAuxValues(AuxKV.Key).Add(tAuxValues(AuxKV.Key)(i - 1)) - Next - End If - - Else - - For Each ValKV In tValues - hzValues(ValKV.Key).Add((hzDist(j) - tDist(i - 1)) * (tValues(ValKV.Key)(i) - tValues(ValKV.Key)(i - 1)) / (tDist(i) - tDist(i - 1)) + tValues(ValKV.Key)(i - 1)) - Next - hzSpeedOgl.Add((hzDist(j) - tDist(i - 1)) * (tSpeedOgl(i) - tSpeedOgl(i - 1)) / (tDist(i) - tDist(i - 1)) + tSpeedOgl(i - 1)) - - If AuxDef Then - For Each AuxKV In AuxComponents - hzAuxValues(AuxKV.Key).Add((hzDist(j) - tDist(i - 1)) * (tAuxValues(AuxKV.Key)(i) - tAuxValues(AuxKV.Key)(i - 1)) / (tDist(i) - tDist(i - 1)) + tAuxValues(AuxKV.Key)(i - 1)) - Next - End If - - End If - - Loop Until i = tDim + 1 Or j + 1 > tmax - - Values = hzValues - VoglS = hzSpeedOgl - MODdata.Vh.Weg = hzDist - If AuxDef Then AuxComponents = hzAuxValues - tDim = Values(tDriComp.V).Count - 1 - - For i = 0 To tDim - If Values(tDriComp.V)(i) < 0.5 Then Values(tDriComp.V)(i) = 0 - Next + If fTime(0) >= tMax Then + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 + t0 = tMid + End If + + Anz = 0 + Finish = False - - Return True - - End Function - - ''' <summary> - ''' Convert cycle to 1Hz. - ''' </summary> - ''' <returns>True= Convertion successful.</returns> - ''' <remarks></remarks> - Public Function ConvTo1Hz() As Boolean - - Dim tMin As Double - Dim tMax As Double - Dim tMid As Integer - Dim Anz As Integer - Dim z As Integer - Dim Time As Double - Dim t1 As Double - Dim Finish As Boolean - Dim NewValues As Dictionary(Of tDriComp, List(Of Double)) - Dim KV As KeyValuePair(Of tDriComp, List(Of Double)) - Dim KVd As KeyValuePair(Of tDriComp, Double) - Dim fTime As List(Of Double) - Dim Summe As Dictionary(Of tDriComp, Double) - - Dim NewAuxValues As Dictionary(Of String, List(Of Single)) = Nothing - Dim AuxKV As KeyValuePair(Of String, List(Of Single)) - Dim AuxSumme As Dictionary(Of String, Single) = Nothing - - Dim MsgSrc As String - - MsgSrc = "DRI/Convert" - - fTime = Values(tDriComp.t) - - 'Check whether Time is not reversed - For z = 1 To tDim - If fTime(z) < fTime(z - 1) Then - WorkerMsg(tMsgID.Err, "Time step invalid! t(" & z - 1 & ") = " & fTime(z - 1) & "[s], t(" & z & ") = " & fTime(z) & "[s]", MsgSrc) - Return False - End If - Next - - 'Define Time-range - t0 = CInt(Math.Round(fTime(0), 0, MidpointRounding.AwayFromZero)) - t1 = fTime(tDim) - - 'Create Output, Total and Num-of-Dictionaries - NewValues = New Dictionary(Of tDriComp, List(Of Double)) - Summe = New Dictionary(Of tDriComp, Double) - - For Each KV In Values - NewValues.Add(KV.Key, New List(Of Double)) - If KV.Key <> tDriComp.t Then Summe.Add(KV.Key, 0) - Next - - If AuxDef Then - NewAuxValues = New Dictionary(Of String, List(Of Single)) - AuxSumme = New Dictionary(Of String, Single) - For Each AuxKV In AuxComponents - NewAuxValues.Add(AuxKV.Key, New List(Of Single)) - AuxSumme.Add(AuxKV.Key, 0) - Next - End If - - 'Start-values - tMin = fTime(0) - tMid = CInt(tMin) - tMax = tMid + 0.5 - - If fTime(0) >= tMax Then - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 - t0 = tMid - End If - - Anz = 0 - Finish = False - - For z = 0 To tDim - - 'Next Time-step - Time = fTime(z) + For z = 0 To tDim + + 'Next Time-step + Time = fTime(z) lb10: - 'If Time-step > tMax: - If Time >= tMax Or z = tDim Then - - 'Conclude Second - NewValues(tDriComp.t).Add(tMid) - - 'If no values ​​in Sum: Interpolate - If Anz = 0 Then - - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (Values(KVd.Key)(z) - Values(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + Values(KVd.Key)(z - 1)) - Next - - If AuxDef Then - For Each AuxKV In AuxComponents - NewAuxValues(AuxKV.Key).Add((tMid - fTime(z - 1)) * (AuxKV.Value(z) - AuxKV.Value(z - 1)) / (fTime(z) - fTime(z - 1)) + AuxKV.Value(z - 1)) - Next - End If - - Else - - If Time = tMax Then - - For Each KVd In Summe - NewValues(KVd.Key).Add((Summe(KVd.Key) + Values(KVd.Key)(z)) / (Anz + 1)) - Next - - If AuxDef Then - For Each AuxKV In AuxComponents - NewAuxValues(AuxKV.Key).Add((AuxSumme(AuxKV.Key) + AuxKV.Value(z)) / (Anz + 1)) - Next - End If - - Else - 'If only one Value: Inter- /Extrapolate - If Anz = 1 Then - - If z < 2 OrElse fTime(z - 1) < tMid Then + 'If Time-step > tMax: + If Time >= tMax Or z = tDim Then + + 'Conclude Second + NewValues(tDriComp.t).Add(tMid) + + 'If no values ​​in Sum: Interpolate + If Anz = 0 Then + + For Each KVd In Summe + NewValues(KVd.Key).Add( + (tMid - fTime(z - 1)) * (Values(KVd.Key)(z) - Values(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + + Values(KVd.Key)(z - 1)) + Next + + If AuxDef Then + For Each AuxKV In AuxComponents + NewAuxValues(AuxKV.Key).Add( + (tMid - fTime(z - 1)) * (AuxKV.Value(z) - AuxKV.Value(z - 1)) / (fTime(z) - fTime(z - 1)) + AuxKV.Value(z - 1)) + Next + End If - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 1)) * (Values(KVd.Key)(z) - Values(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + Values(KVd.Key)(z - 1)) - Next + Else - If AuxDef Then - For Each AuxKV In AuxComponents - NewAuxValues(AuxKV.Key).Add((tMid - fTime(z - 1)) * (AuxKV.Value(z) - AuxKV.Value(z - 1)) / (fTime(z) - fTime(z - 1)) + AuxKV.Value(z - 1)) - Next - End If + If Time = tMax Then - Else + For Each KVd In Summe + NewValues(KVd.Key).Add((Summe(KVd.Key) + Values(KVd.Key)(z)) / (Anz + 1)) + Next - For Each KVd In Summe - NewValues(KVd.Key).Add((tMid - fTime(z - 2)) * (Values(KVd.Key)(z - 1) - Values(KVd.Key)(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + Values(KVd.Key)(z - 2)) - Next + If AuxDef Then + For Each AuxKV In AuxComponents + NewAuxValues(AuxKV.Key).Add((AuxSumme(AuxKV.Key) + AuxKV.Value(z)) / (Anz + 1)) + Next + End If - If AuxDef Then - For Each AuxKV In AuxComponents - NewAuxValues(AuxKV.Key).Add((tMid - fTime(z - 2)) * (AuxKV.Value(z - 1) - AuxKV.Value(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + AuxKV.Value(z - 2)) - Next - End If + Else + 'If only one Value: Inter- /Extrapolate + If Anz = 1 Then - End If + If z < 2 OrElse fTime(z - 1) < tMid Then - Else + For Each KVd In Summe + NewValues(KVd.Key).Add( + (tMid - fTime(z - 1)) * (Values(KVd.Key)(z) - Values(KVd.Key)(z - 1)) / (fTime(z) - fTime(z - 1)) + + Values(KVd.Key)(z - 1)) + Next - For Each KVd In Summe - NewValues(KVd.Key).Add(Summe(KVd.Key) / Anz) - Next + If AuxDef Then + For Each AuxKV In AuxComponents + NewAuxValues(AuxKV.Key).Add( + (tMid - fTime(z - 1)) * (AuxKV.Value(z) - AuxKV.Value(z - 1)) / (fTime(z) - fTime(z - 1)) + AuxKV.Value(z - 1)) + Next + End If - If AuxDef Then - For Each AuxKV In AuxComponents - NewAuxValues(AuxKV.Key).Add(AuxSumme(AuxKV.Key) / Anz) - Next - End If + Else - End If - End If - End If + For Each KVd In Summe + NewValues(KVd.Key).Add( + (tMid - fTime(z - 2)) * (Values(KVd.Key)(z - 1) - Values(KVd.Key)(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + + Values(KVd.Key)(z - 2)) + Next - If Not Finish Then + If AuxDef Then + For Each AuxKV In AuxComponents + NewAuxValues(AuxKV.Key).Add( + (tMid - fTime(z - 2)) * (AuxKV.Value(z - 1) - AuxKV.Value(z - 2)) / (fTime(z - 1) - fTime(z - 2)) + + AuxKV.Value(z - 2)) + Next + End If - 'Set New Area(Bereich) - tMid = tMid + 1 - tMin = tMid - 0.5 - tMax = tMid + 0.5 + End If - 'Check whether last second - If tMax > t1 Then - tMax = t1 - Finish = True - End If + Else - 'New Sum /Num no start - For Each KV In Values - If KV.Key <> tDriComp.t Then Summe(KV.Key) = 0 - Next + For Each KVd In Summe + NewValues(KVd.Key).Add(Summe(KVd.Key) / Anz) + Next - If AuxDef Then - For Each AuxKV In AuxComponents - AuxSumme(AuxKV.Key) = 0 - Next - End If + If AuxDef Then + For Each AuxKV In AuxComponents + NewAuxValues(AuxKV.Key).Add(AuxSumme(AuxKV.Key) / Anz) + Next + End If - Anz = 0 + End If + End If + End If - GoTo lb10 + If Not Finish Then - End If + 'Set New Area(Bereich) + tMid = tMid + 1 + tMin = tMid - 0.5 + tMax = tMid + 0.5 - End If + 'Check whether last second + If tMax > t1 Then + tMax = t1 + Finish = True + End If - For Each KV In Values - If KV.Key <> tDriComp.t Then Summe(KV.Key) += Values(KV.Key)(z) - Next + 'New Sum /Num no start + For Each KV In Values + If KV.Key <> tDriComp.t Then Summe(KV.Key) = 0 + Next + + If AuxDef Then + For Each AuxKV In AuxComponents + AuxSumme(AuxKV.Key) = 0 + Next + End If - If AuxDef Then - For Each AuxKV In AuxComponents - AuxSumme(AuxKV.Key) += AuxKV.Value(z) - Next - End If + Anz = 0 - Anz = Anz + 1 + GoTo lb10 - Next + End If - 'Accept New fields - Values = NewValues + End If - If AuxDef Then - For Each AuxKV In NewAuxValues - AuxComponents(AuxKV.Key) = AuxKV.Value - Next - End If + For Each KV In Values + If KV.Key <> tDriComp.t Then Summe(KV.Key) += Values(KV.Key)(z) + Next - tDim = Values(tDriComp.t).Count - 1 + If AuxDef Then + For Each AuxKV In AuxComponents + AuxSumme(AuxKV.Key) += AuxKV.Value(z) + Next + End If + + Anz = Anz + 1 - Return True + Next - End Function + 'Accept New fields + Values = NewValues - ''' <summary> - ''' Duplicates first time step. Needed for distance-based cycles to ensure vehicle stop at cycle start. - ''' </summary> - ''' <remarks></remarks> - Public Sub FirstZero() - Dim AuxKV As KeyValuePair(Of String, List(Of Single)) - Dim ValKV As KeyValuePair(Of tDriComp, List(Of Double)) + If AuxDef Then + For Each AuxKV In NewAuxValues + AuxComponents(AuxKV.Key) = AuxKV.Value + Next + End If + + tDim = Values(tDriComp.t).Count - 1 - tDim += 1 + Return True + End Function - For Each ValKV In Values - ValKV.Value.Insert(0, ValKV.Value(0)) - Next + ''' <summary> + ''' Duplicates first time step. Needed for distance-based cycles to ensure vehicle stop at cycle start. + ''' </summary> + ''' <remarks></remarks> + Public Sub FirstZero() + Dim AuxKV As KeyValuePair(Of String, List(Of Single)) + Dim ValKV As KeyValuePair(Of tDriComp, List(Of Double)) - If Scycle Then VoglS.Insert(0, VoglS(0)) + tDim += 1 - If AuxDef Then - For Each AuxKV In AuxComponents - AuxKV.Value.Insert(0, AuxKV.Value(0)) - Next - End If + For Each ValKV In Values + ValKV.Value.Insert(0, ValKV.Value(0)) + Next - End Sub + If Scycle Then VoglS.Insert(0, VoglS(0)) + If AuxDef Then + For Each AuxKV In AuxComponents + AuxKV.Value.Insert(0, AuxKV.Value(0)) + Next + End If + End Sub End Class diff --git a/VECTO/Input Files/cENG.vb b/VECTO/Input Files/cENG.vb index 72d732b2d50e3da77dfe2aa17b5cbb31080aa37c..587318770e0c7492c42f6cd05afad5865e263057 100644 --- a/VECTO/Input Files/cENG.vb +++ b/VECTO/Input Files/cENG.vb @@ -15,249 +15,243 @@ Imports System.Collections.Generic ''' </summary> ''' <remarks></remarks> Public Class cENG - - ''' <summary> - ''' Current format version - ''' </summary> - ''' <remarks></remarks> + ''' <summary> + ''' Current format version + ''' </summary> + ''' <remarks></remarks> Private Const FormatVersion As Short = 3 - ''' <summary> - ''' Format version of input file. Defined in ReadFile. - ''' </summary> - ''' <remarks></remarks> - Private FileVersion As Short - - ''' <summary> - ''' Engine description (model, type, etc.). Saved in input file. - ''' </summary> - ''' <remarks></remarks> - Public ModelName As String - - ''' <summary> - ''' Engine displacement [ccm]. Saved in input file. - ''' </summary> - ''' <remarks></remarks> - Public Displ As Single - - ''' <summary> - ''' Idling speed [1/min]. Saved in input file. - ''' </summary> - ''' <remarks></remarks> - Public Nidle As Single - - ''' <summary> - ''' Rotational inertia including flywheel [kgm²]. Saved in input file. Overwritten by generic value in Declaration mode. - ''' </summary> - ''' <remarks></remarks> - Public I_mot As Single - - ''' <summary> - ''' List of full load/motoring curve files (.vfld) - ''' </summary> - ''' <remarks></remarks> + ''' <summary> + ''' Format version of input file. Defined in ReadFile. + ''' </summary> + ''' <remarks></remarks> + Private FileVersion As Short + + ''' <summary> + ''' Engine description (model, type, etc.). Saved in input file. + ''' </summary> + ''' <remarks></remarks> + Public ModelName As String + + ''' <summary> + ''' Engine displacement [ccm]. Saved in input file. + ''' </summary> + ''' <remarks></remarks> + Public Displ As Single + + ''' <summary> + ''' Idling speed [1/min]. Saved in input file. + ''' </summary> + ''' <remarks></remarks> + Public Nidle As Single + + ''' <summary> + ''' Rotational inertia including flywheel [kgm²]. Saved in input file. Overwritten by generic value in Declaration mode. + ''' </summary> + ''' <remarks></remarks> + Public I_mot As Single + + ''' <summary> + ''' List of full load/motoring curve files (.vfld) + ''' </summary> + ''' <remarks></remarks> Public fFLD As cSubPath + Public FLD As cFLD - ''' <summary> - ''' Path to fuel consumption map - ''' </summary> - ''' <remarks></remarks> - Private fMAP As cSubPath + ''' <summary> + ''' Path to fuel consumption map + ''' </summary> + ''' <remarks></remarks> + Private fMAP As cSubPath ''' <summary> ''' Directory of engine file. Defined in FilePath property (Set) ''' </summary> ''' <remarks></remarks> - Private MyPath As String + Private MyPath As String - ''' <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 sub input files (e.g. FC map). Can be accessed by FileList property. Generated by CreateFileList. - ''' </summary> - ''' <remarks></remarks> - Private MyFileList As List(Of String) - - ''' <summary> - ''' WHTC Urban test results. Saved in input file. - ''' </summary> - ''' <remarks></remarks> - Public WHTCurban As Single + ''' <summary> + ''' Full file path. Needs to be defined via FilePath property before calling ReadFile or SaveFile. + ''' </summary> + ''' <remarks></remarks> + Private sFilePath As String - ''' <summary> - ''' WHTC Rural test results. Saved in input file. - ''' </summary> - ''' <remarks></remarks> - Public WHTCrural As Single + ''' <summary> + ''' List of sub input files (e.g. FC map). Can be accessed by FileList property. Generated by CreateFileList. + ''' </summary> + ''' <remarks></remarks> + Private MyFileList As List(Of String) - ''' <summary> - ''' WHTC Motorway test results. Saved in input file. - ''' </summary> - ''' <remarks></remarks> - Public WHTCmw As Single + ''' <summary> + ''' WHTC Urban test results. Saved in input file. + ''' </summary> + ''' <remarks></remarks> + Public WHTCurban As Single - ''' <summary> - ''' Rated engine speed [1/min]. Engine speed at max. power. Defined in Init. - ''' </summary> - ''' <remarks></remarks> - Public Nrated As Single + ''' <summary> + ''' WHTC Rural test results. Saved in input file. + ''' </summary> + ''' <remarks></remarks> + Public WHTCrural As Single - ''' <summary> - ''' Maximum engine power [kW]. Power at rated engine speed. - ''' </summary> - ''' <remarks></remarks> - Public Pmax As Single + ''' <summary> + ''' WHTC Motorway test results. Saved in input file. + ''' </summary> + ''' <remarks></remarks> + Public WHTCmw As Single - Public SavedInDeclMode As Boolean + ''' <summary> + ''' Rated engine speed [1/min]. Engine speed at max. power. Defined in Init. + ''' </summary> + ''' <remarks></remarks> + Public Nrated As Single - 'AA-TB - 'Added in order to expose readonly the full path of the fuel map being used by vecto - Public ReadOnly property FuelMapFullPath as string - Get + ''' <summary> + ''' Maximum engine power [kW]. Power at rated engine speed. + ''' </summary> + ''' <remarks></remarks> + Public Pmax As Single - Return fMAP.FullPath + Public SavedInDeclMode As Boolean - End Get -End Property + 'AA-TB + 'Added in order to expose readonly the full path of the fuel map being used by vecto + Public ReadOnly Property FuelMapFullPath As String + Get + Return fMAP.FullPath + End Get + End Property - ''' <summary> - ''' Generates list of all sub input files (e.g. FC map). Sets MyFileList. - ''' </summary> - ''' <returns>True if successful.</returns> - ''' <remarks></remarks> - Public Function CreateFileList() As Boolean + ''' <summary> + ''' Generates list of all sub input files (e.g. FC map). Sets MyFileList. + ''' </summary> + ''' <returns>True if successful.</returns> + ''' <remarks></remarks> + Public Function CreateFileList() As Boolean - MyFileList = New List(Of String) + MyFileList = New List(Of String) MyFileList.Add(PathFLD) - MyFileList.Add(PathMAP) - - 'Not used!!! MyFileList.Add(PathWHTC) + MyFileList.Add(PathMAP) - Return True + 'Not used!!! MyFileList.Add(PathWHTC) - End Function + Return True + End Function - ''' <summary> - ''' New instance. Initialise - ''' </summary> - ''' <remarks></remarks> - Public Sub New() - MyPath = "" - sFilePath = "" + ''' <summary> + ''' New instance. Initialise + ''' </summary> + ''' <remarks></remarks> + Public Sub New() + MyPath = "" + sFilePath = "" fMAP = New cSubPath fFLD = New cSubPath - SetDefault() - End Sub - - ''' <summary> - ''' Set default values - ''' </summary> - ''' <remarks></remarks> - Private Sub SetDefault() - ModelName = "Undefined" - Displ = 0 - Nidle = 0 - I_mot = 0 - Nrated = 0 - Pmax = 0 + SetDefault() + End Sub + + ''' <summary> + ''' Set default values + ''' </summary> + ''' <remarks></remarks> + Private Sub SetDefault() + ModelName = "Undefined" + Displ = 0 + Nidle = 0 + I_mot = 0 + Nrated = 0 + Pmax = 0 fMAP.Clear() fFLD.Clear() - WHTCurban = 0 - WHTCrural = 0 - WHTCmw = 0 + WHTCurban = 0 + WHTCrural = 0 + WHTCmw = 0 - SavedInDeclMode = False + SavedInDeclMode = False + End Sub - End Sub - - ''' <summary> - ''' Save file. <see cref="P:VECTO.cENG.FilePath" /> must be set before calling. - ''' </summary> - ''' <returns>True if successful.</returns> - ''' <remarks></remarks> - Public Function SaveFile() As Boolean - Dim JSON As New JSON - Dim dic As Dictionary(Of String, Object) + ''' <summary> + ''' Save file. <see cref="P:VECTO.cENG.FilePath" /> must be set before calling. + ''' </summary> + ''' <returns>True if successful.</returns> + ''' <remarks></remarks> + Public Function SaveFile() As Boolean + Dim JSON As New JSON + Dim dic As Dictionary(Of String, Object) - 'Header - dic = New Dictionary(Of String, Object) - dic.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") + '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) + dic.Add("AppVersion", VECTOvers) + dic.Add("FileVersion", FormatVersion) + JSON.Content.Add("Header", dic) - 'Body - dic = New Dictionary(Of String, Object) + 'Body + dic = New Dictionary(Of String, Object) - dic.Add("SavedInDeclMode", Cfg.DeclMode) - SavedInDeclMode = Cfg.DeclMode + dic.Add("SavedInDeclMode", Cfg.DeclMode) + SavedInDeclMode = Cfg.DeclMode - dic.Add("ModelName", ModelName) + dic.Add("ModelName", ModelName) - dic.Add("Displacement", Displ) - dic.Add("IdlingSpeed", Nidle) - dic.Add("Inertia", I_mot) + dic.Add("Displacement", Displ) + dic.Add("IdlingSpeed", Nidle) + dic.Add("Inertia", I_mot) dic.Add("FullLoadCurve", fFLD.PathOrDummy) - dic.Add("FuelMap", fMAP.PathOrDummy) - - dic.Add("WHTC-Urban", WHTCurban) - dic.Add("WHTC-Rural", WHTCrural) - dic.Add("WHTC-Motorway", WHTCmw) - + dic.Add("FuelMap", fMAP.PathOrDummy) - JSON.Content.Add("Body", dic) + dic.Add("WHTC-Urban", WHTCurban) + dic.Add("WHTC-Rural", WHTCrural) + dic.Add("WHTC-Motorway", WHTCmw) - Return JSON.WriteFile(sFilePath) + JSON.Content.Add("Body", dic) - End Function + Return JSON.WriteFile(sFilePath) + 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 JSON + ''' <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 JSON - MsgSrc = "ENG/ReadFile" + MsgSrc = "ENG/ReadFile" - SetDefault() + SetDefault() - If Not JSON.ReadFile(sFilePath) Then Return False + If Not JSON.ReadFile(sFilePath) Then Return False - Try + Try - FileVersion = JSON.Content("Header")("FileVersion") + FileVersion = JSON.Content("Header")("FileVersion") - If FileVersion > 1 Then - SavedInDeclMode = JSON.Content("Body")("SavedInDeclMode") - Else - SavedInDeclMode = Cfg.DeclMode - End If + If FileVersion > 1 Then + SavedInDeclMode = JSON.Content("Body")("SavedInDeclMode") + Else + SavedInDeclMode = Cfg.DeclMode + End If - ModelName = JSON.Content("Body")("ModelName") + ModelName = JSON.Content("Body")("ModelName") - Displ = JSON.Content("Body")("Displacement") - Nidle = JSON.Content("Body")("IdlingSpeed") - I_mot = JSON.Content("Body")("Inertia") + Displ = JSON.Content("Body")("Displacement") + Nidle = JSON.Content("Body")("IdlingSpeed") + I_mot = JSON.Content("Body")("Inertia") If FileVersion < 3 Then fFLD.Init(MyPath, JSON.Content("Body")("FullLoadCurves")(0)("Path")) @@ -265,7 +259,7 @@ End Property fFLD.Init(MyPath, JSON.Content("Body")("FullLoadCurve")) End If - fMAP.Init(MyPath, JSON.Content("Body")("FuelMap")) + fMAP.Init(MyPath, JSON.Content("Body")("FuelMap")) If FileVersion > 2 AndAlso Not JSON.Content("Body")("WHTC-Urban") Is Nothing Then WHTCurban = CSng(JSON.Content("Body")("WHTC-Urban")) @@ -273,105 +267,60 @@ End Property WHTCmw = CSng(JSON.Content("Body")("WHTC-Motorway")) End If - Catch ex As Exception - If ShowMsg Then WorkerMsg(tMsgID.Err, "Failed to read VECTO file! " & ex.Message, MsgSrc) - Return False - End Try - - Return True - - End Function - - ''' <summary> - ''' Initialise for calculation. File must be read already. - ''' </summary> - ''' <returns>True if successful.</returns> - ''' <remarks></remarks> - Public Function Init() As Boolean - - Dim MsgSrc As String - MsgSrc = "ENG/Init" - - - 'read .vfld file - FLD = New cFLD - FLD.FilePath = PathFLD - If Not FLD.ReadFile(False) Then - WorkerMsg(tMsgID.Err, "File read error! (" & PathFLD & ")", MsgSrc, PathFLD) + Catch ex As Exception + If ShowMsg Then WorkerMsg(tMsgID.Err, "Failed to read VECTO file! " & ex.Message, MsgSrc) Return False - End If - - 'Read FC map - MAP = New cMAP - MAP.FilePath = PathMAP + End Try - Try - If Not MAP.ReadFile Then Return False 'Fehlermeldung hier nicht notwendig weil schon von in ReadFile - Catch ex As Exception - WorkerMsg(tMsgID.Err, "File read error! (" & PathMAP & ")", MsgSrc, PathMAP) - Return False - End Try + Return True + End Function - 'Triangulate FC map. - If Not MAP.Triangulate() Then - WorkerMsg(tMsgID.Err, "Failed to triangulate FC map! (" & PathMAP & ")", MsgSrc, PathMAP) - Return False - End If - - Nrated = FLD.fnUrated - - Pmax = FLD.Pfull(FLD.fnUrated) - - Return True - - End Function - - ''' <summary> - ''' Set generic values for Declaration Mode - ''' </summary> - ''' <returns>True if successful.</returns> - ''' <remarks></remarks> - Public Function DeclInit() As Boolean + ''' <summary> + ''' Set generic values for Declaration Mode + ''' </summary> + ''' <returns>True if successful.</returns> + ''' <remarks></remarks> + Public Function DeclInit() As Boolean I_mot = cDeclaration.EngInertia(Displ) FLD.DeclInit() - Return True - End Function - - ''' <summary> - ''' Returns list of sub input files after calling CreateFileList. - ''' </summary> - ''' <value></value> - ''' <returns>list of sub input files</returns> - ''' <remarks></remarks> - Public ReadOnly Property FileList As List(Of String) - Get - Return MyFileList - End Get - End Property - - ''' <summary> - ''' Get or set Filepath before calling <see cref="M:VECTO.cENG.ReadFile" /> or <see cref="M:VECTO.cENG.SaveFile" /> - ''' </summary> - ''' <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 - If sFilePath = "" Then - MyPath = "" - Else - MyPath = IO.Path.GetDirectoryName(sFilePath) & "\" - End If - End Set - End Property + Return True + End Function + + ''' <summary> + ''' Returns list of sub input files after calling CreateFileList. + ''' </summary> + ''' <value></value> + ''' <returns>list of sub input files</returns> + ''' <remarks></remarks> + Public ReadOnly Property FileList As List(Of String) + Get + Return MyFileList + End Get + End Property + + ''' <summary> + ''' Get or set Filepath before calling <see cref="M:VECTO.cENG.ReadFile" /> or <see cref="M:VECTO.cENG.SaveFile" /> + ''' </summary> + ''' <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 + If sFilePath = "" Then + MyPath = "" + Else + MyPath = IO.Path.GetDirectoryName(sFilePath) & "\" + End If + End Set + End Property Public Property PathFLD(Optional ByVal Original As Boolean = False) As String @@ -387,24 +336,23 @@ End Property End Set End Property - ''' <summary> - ''' Get or set file path (cSubPath) to FC map (.vmap) - ''' </summary> - ''' <param name="Original">True= (relative) file path as saved in file; False= full file path</param> - ''' <value></value> - ''' <returns>Relative or absolute file path to FC map</returns> - ''' <remarks></remarks> - Public Property PathMAP(Optional ByVal Original As Boolean = False) As String - Get - If Original Then - Return fMAP.OriginalPath - Else - Return fMAP.FullPath - End If - End Get - Set(ByVal value As String) - fMAP.Init(MyPath, value) - End Set - End Property - + ''' <summary> + ''' Get or set file path (cSubPath) to FC map (.vmap) + ''' </summary> + ''' <param name="Original">True= (relative) file path as saved in file; False= full file path</param> + ''' <value></value> + ''' <returns>Relative or absolute file path to FC map</returns> + ''' <remarks></remarks> + Public Property PathMAP(Optional ByVal Original As Boolean = False) As String + Get + If Original Then + Return fMAP.OriginalPath + Else + Return fMAP.FullPath + End If + End Get + Set(ByVal value As String) + fMAP.Init(MyPath, value) + End Set + End Property End Class diff --git a/VECTO/Input Files/cFLD.vb b/VECTO/Input Files/cFLD.vb index 0c8b5047e83c847b076844dbc25a178051a232ff..7f453795d1141c7e7cf77c2b5af7cb51f2e56387 100644 --- a/VECTO/Input Files/cFLD.vb +++ b/VECTO/Input Files/cFLD.vb @@ -15,78 +15,77 @@ Imports System.Collections.Generic ''' </summary> ''' <remarks></remarks> Public Class cFLD - - ''' <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) - - ''' <summary> - ''' List of motoring torque values [Nm] - ''' </summary> - ''' <remarks></remarks> - Public LTqDrag As List(Of Single) - - ''' <summary> - ''' List of engine speed values [1/min] - ''' </summary> - ''' <remarks></remarks> - Public LnU As List(Of Single) - - ''' <summary> - ''' List of PT1 values [s] - ''' </summary> - ''' <remarks></remarks> - Private LPT1 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 - - ''' <summary> - ''' Read file. FilePath must be set before calling. - ''' </summary> - ''' <returns>True if successful.</returns> - ''' <remarks></remarks> + ''' <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) + + ''' <summary> + ''' List of motoring torque values [Nm] + ''' </summary> + ''' <remarks></remarks> + Public LTqDrag As List(Of Single) + + ''' <summary> + ''' List of engine speed values [1/min] + ''' </summary> + ''' <remarks></remarks> + Public LnU As List(Of Single) + + ''' <summary> + ''' List of PT1 values [s] + ''' </summary> + ''' <remarks></remarks> + Private LPT1 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 + + ''' <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 cFile_V3 Dim line As String() @@ -167,7 +166,8 @@ Public Class cFLD Catch ex As Exception - If ShowMsg Then WorkerMsg(tMsgID.Err, "Error during file read! Line number: " & iDim + 1 & " (" & sFilePath & ")", MsgSrc, sFilePath) + If ShowMsg Then _ + WorkerMsg(tMsgID.Err, "Error during file read! Line number: " & iDim + 1 & " (" & sFilePath & ")", MsgSrc, sFilePath) GoTo lbEr End Try @@ -185,361 +185,352 @@ lbEr: file = Nothing Return False - End Function - ''' <summary> - ''' Returns motoring power [kW] for given engine speed - ''' </summary> - ''' <param name="nU">engine speed [1/min]</param> - ''' <returns>motoring power [kW]</returns> - ''' <remarks></remarks> - Public Function Pdrag(ByVal nU As Single) As Single - Dim i As Int32 - - 'Extrapolation for x < x(1) - If LnU(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 - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If LnU(i) < nU Then - MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" - End If + ''' <summary> + ''' Returns motoring power [kW] for given engine speed + ''' </summary> + ''' <param name="nU">engine speed [1/min]</param> + ''' <returns>motoring power [kW]</returns> + ''' <remarks></remarks> + Public Function Pdrag(ByVal nU As Single) As Single + Dim i As Int32 + + 'Extrapolation for x < x(1) + If LnU(0) >= nU Then + 'If LnU(0) > nU Then MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" + i = 1 + GoTo lbInt + End If -lbInt: - 'Interpolation - Return nMtoPe(nU, (nU - LnU(i - 1)) * (LTqDrag(i) - LTqDrag(i - 1)) / (LnU(i) - LnU(i - 1)) + LTqDrag(i - 1)) - - End Function - - ''' <summary> - ''' Returns full load power [kW] at given engine speed considering transient torque build-up via PT1. - ''' </summary> - ''' <param name="nU">engine speed [1/min]</param> - ''' <param name="LastPe">engine power at previous time step</param> - ''' <returns>full load power [kW]</returns> - ''' <remarks></remarks> - Public Function Pfull(ByVal nU As Single, ByVal LastPe As Single) As Single - Dim i As Int32 - Dim PfullStat As Single - Dim PT1 As Single - - 'Extrapolation for x < x(1) - If LnU(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 - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If LnU(i) < nU Then - MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" - End If + i = 0 + Do While LnU(i) < nU And i < iDim + i += 1 + Loop + + 'Extrapolation for x > x(imax) + If LnU(i) < nU Then + 'MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" + End If lbInt: - 'Interpolation - PfullStat = nMtoPe(nU, (nU - LnU(i - 1)) * (LTq(i) - LTq(i - 1)) / (LnU(i) - LnU(i - 1)) + LTq(i - 1)) - PT1 = (nU - LnU(i - 1)) * (LPT1(i) - LPT1(i - 1)) / (LnU(i) - LnU(i - 1)) + LPT1(i - 1) - - 'Dynamic Full-load - Return Math.Min((1 / (PT1 + 1)) * (PfullStat + PT1 * LastPe), PfullStat) - - 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(ByVal nU As Single) As Single - Dim i As Int32 - - 'Extrapolation for x < x(1) - If LnU(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 - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If LnU(i) < nU Then - MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" - End If + 'Interpolation + Return nMtoPe(nU, (nU - LnU(i - 1)) * (LTqDrag(i) - LTqDrag(i - 1)) / (LnU(i) - LnU(i - 1)) + LTqDrag(i - 1)) + End Function + + ''' <summary> + ''' Returns full load power [kW] at given engine speed considering transient torque build-up via PT1. + ''' </summary> + ''' <param name="nU">engine speed [1/min]</param> + ''' <param name="LastPe">engine power at previous time step</param> + ''' <returns>full load power [kW]</returns> + ''' <remarks></remarks> + Public Function Pfull(ByVal nU As Single, ByVal LastPe As Single) As Single + Dim i As Int32 + Dim PfullStat As Single + Dim PT1 As Single + + 'Extrapolation for x < x(1) + If LnU(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 + i += 1 + Loop + + 'Extrapolation for x > x(imax) + If LnU(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)) - 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> - Public Function Tq(ByVal nU As Single) As Single - Dim i As Int32 - - 'Extrapolation for x < x(1) - If LnU(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 - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If LnU(i) < nU Then - MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" - End If + 'Interpolation + PfullStat = nMtoPe(nU, (nU - LnU(i - 1)) * (LTq(i) - LTq(i - 1)) / (LnU(i) - LnU(i - 1)) + LTq(i - 1)) + PT1 = (nU - LnU(i - 1)) * (LPT1(i) - LPT1(i - 1)) / (LnU(i) - LnU(i - 1)) + LPT1(i - 1) + + 'Dynamic Full-load + Return Math.Min((1 / (PT1 + 1)) * (PfullStat + PT1 * LastPe), PfullStat) + 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(ByVal nU As Single) As Single + Dim i As Int32 + + 'Extrapolation for x < x(1) + If LnU(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 + i += 1 + Loop + + 'Extrapolation for x > x(imax) + If LnU(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 + 'Interpolation + Return nMtoPe(nU, (nU - LnU(i - 1)) * (LTq(i) - LTq(i - 1)) / (LnU(i) - LnU(i - 1)) + LTq(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> + Public Function Tq(ByVal nU As Single) As Single + Dim i As Int32 + + 'Extrapolation for x < x(1) + If LnU(0) >= nU Then + 'If LnU(0) > nU Then MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" + i = 1 + GoTo lbInt + End If - ''' <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 + i = 0 + Do While LnU(i) < nU And i < iDim + i += 1 + Loop + 'Extrapolation for x > x(imax) + If LnU(i) < nU Then + 'MODdata.ModErrors.FLDextrapol = "n= " & nU & " [1/min]" + End If - dn = 0.001 +lbInt: + 'Interpolation + Return (nU - LnU(i - 1)) * (LTq(i) - LTq(i - 1)) / (LnU(i) - LnU(i - 1)) + LTq(i - 1) + End Function - N95h = fnUofPfull(0.95 * Pfull(fnUrated), False) + ''' <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 - If N95h < 0 Then Return -1 - Amax = Area(Nidle, N95h) + dn = 0.001 - For i = 0 To iDim - 1 + N95h = fnUofPfull(0.95 * Pfull(fnUrated), False) - If Area(Nidle, LnU(i + 1)) > 0.51 * Amax Then + If N95h < 0 Then Return -1 - n = LnU(i) - T0 = LTq(i) - A = Area(Nidle, n) + Amax = Area(Nidle, N95h) - k = (LTq(i + 1) - LTq(i)) / (LnU(i + 1) - LnU(i)) + For i = 0 To iDim - 1 - Do While A < 0.51 * Amax - n += dn - A += dn * (2 * T0 + k * dn) / 2 - Loop + If Area(Nidle, LnU(i + 1)) > 0.51 * Amax Then - Exit For + n = LnU(i) + T0 = LTq(i) + A = Area(Nidle, n) - End If + k = (LTq(i + 1) - LTq(i)) / (LnU(i + 1) - LnU(i)) - Next + Do While A < 0.51 * Amax + n += dn + A += dn * (2 * T0 + k * dn) / 2 + Loop - Return n + Exit For - End Function + End If - ''' <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 + Next + Return n + End Function - A = 0 - For i = 1 To iDim + ''' <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 - If LnU(i - 1) >= nTo Then Exit For - If LnU(i - 1) >= nFrom Then + A = 0 + For i = 1 To iDim + If LnU(i - 1) >= nTo Then Exit For - If LnU(i) <= nTo Then + If LnU(i - 1) >= nFrom Then - 'Add full segment - A += (LnU(i) - LnU(i - 1)) * (LTq(i) + LTq(i - 1)) / 2 - Else + If LnU(i) <= nTo Then - 'Add segment till nTo - A += (nTo - LnU(i - 1)) * (Tq(nTo) + LTq(i - 1)) / 2 + 'Add full segment + A += (LnU(i) - LnU(i - 1)) * (LTq(i) + LTq(i - 1)) / 2 - End If + Else - Else + 'Add segment till nTo + A += (nTo - LnU(i - 1)) * (Tq(nTo) + LTq(i - 1)) / 2 - If LnU(i) > nFrom Then + End If - 'Add segment starting from nFrom - A += (LnU(i) - nFrom) * (LTq(i) + Tq(nFrom)) / 2 + Else - End If + If LnU(i) > nFrom Then - End If + 'Add segment starting from nFrom + A += (LnU(i) - nFrom) * (LTq(i) + Tq(nFrom)) / 2 - Next + End If - Return A + End If + Next - End Function + 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 + ''' <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 + + Do + P = nMtoPe(nU, Tq(nU)) + If P > PeMax Then + PeMax = P + nUrated = nU + End If + nU += dnU + Loop Until nU > nUmax + + Return nUrated + End Function - dnU = 1 - PeMax = 0 - nU = LnU(0) - nUmax = LnU(iDim) - nUrated = nU + ''' <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 - Do - P = nMtoPe(nU, Tq(nU)) - If P > PeMax Then - PeMax = P - nUrated = nU - End If - nU += dnU - Loop Until nU > nUmax + dnU = 1 + nUmin = LnU(0) + nUmax = LnU(iDim) - Return nUrated + If FromLeft Then - End Function + nU = nUmin + LastPe = nMtoPe(nU, Tq(nU)) + nUtarget = nU - ''' <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 + If LastPe > PeTarget Then Return -1 - dnU = 1 - nUmin = LnU(0) - nUmax = LnU(iDim) + Do + Pe = nMtoPe(nU, Tq(nU)) - If FromLeft Then + If Pe > PeTarget Then + If Math.Abs(LastPe - PeTarget) < Math.Abs(Pe - PeTarget) Then + Return nU - dnU + Else + Return nU + End If + End If - nU = nUmin - LastPe = nMtoPe(nU, Tq(nU)) - nUtarget = nU + LastPe = Pe + nU += dnU + Loop Until nU > nUmax - If LastPe > PeTarget Then Return -1 + Else - Do - Pe = nMtoPe(nU, Tq(nU)) + nU = nUmax + LastPe = nMtoPe(nU, Tq(nU)) + nUtarget = 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 + If LastPe > PeTarget Then Return -1 - LastPe = Pe - nU += dnU - Loop Until nU > nUmax + Do + Pe = nMtoPe(nU, Tq(nU)) - Else + If Pe > PeTarget Then + If Math.Abs(LastPe - PeTarget) < Math.Abs(Pe - PeTarget) Then + Return nU + dnU + Else + Return nU + End If + End If - nU = nUmax - LastPe = nMtoPe(nU, Tq(nU)) - nUtarget = nU + LastPe = Pe + nU -= dnU + Loop Until nU < nUmin - If LastPe > PeTarget Then Return -1 + End If - Do - Pe = nMtoPe(nU, Tq(nU)) + Return nUtarget + End Function - 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 < nUmin - - End If - - Return nUtarget - - End Function - - ''' <summary> - ''' Calculates and returns maximum torque [Nm]. - ''' </summary> - ''' <returns>maximum torque [Nm]</returns> - ''' <remarks></remarks> - Public Function Tmax() As Single - Dim i As Int16 - Dim Tm As Single - - Tm = LTq(0) - For i = 1 To iDim - If LTq(i) > Tm Then Tm = LTq(i) - Next - - Return Tm + ''' <summary> + ''' Calculates and returns maximum torque [Nm]. + ''' </summary> + ''' <returns>maximum torque [Nm]</returns> + ''' <remarks></remarks> + Public Function Tmax() As Single + Dim i As Int16 + Dim Tm As Single + + Tm = LTq(0) + For i = 1 To iDim + If LTq(i) > Tm Then Tm = LTq(i) + Next + Return Tm End Function Public Sub LimitToEng() @@ -552,81 +543,74 @@ lbInt: TqEng = ENG.FLD.Tq(nU) If TqEng < LTq(i) Then LTq(i) = TqEng Next - End Sub - 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(tMsgID.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(tMsgID.Err, "Failed to calculate N95h! Expand full load curve!", MsgSrc) - Return False - End If + Public Function Init(ByVal Nidle As Single) As Boolean + Dim Pmax As Single + Dim MsgSrc As String - N80h = fnUofPfull(0.8 * Pmax, False) + MsgSrc = "Main/ReadInp/Eng.Init" - If N80h < 0 Then - WorkerMsg(tMsgID.Err, "Failed to calculate N80h! Expand full load curve!", MsgSrc) - Return False - End If + Pmax = Pfull(fnUrated) - Npref = fNpref(Nidle) + Nlo = fnUofPfull(0.55 * Pmax, True) - If Npref < 0 Then - WorkerMsg(tMsgID.Err, "Failed to calculate Npref! Expand full load curve!", MsgSrc) - Return False - End If + If Nlo < 0 Then + WorkerMsg(tMsgID.Err, "Failed to calculate Nlo! Expand full load curve!", MsgSrc) + Return False + End If - Nhi = fnUofPfull(0.7 * Pmax, False) + N95h = fnUofPfull(0.95 * Pmax, False) - If Nhi < 0 Then - WorkerMsg(tMsgID.Err, "Failed to calculate Nhi! Expand full load curve!", MsgSrc) - Return False - End If + If N95h < 0 Then + WorkerMsg(tMsgID.Err, "Failed to calculate N95h! Expand full load curve!", MsgSrc) + Return False + End If - Return True + N80h = fnUofPfull(0.8 * Pmax, False) - End Function + If N80h < 0 Then + WorkerMsg(tMsgID.Err, "Failed to calculate N80h! Expand full load curve!", MsgSrc) + Return False + End If - Public Sub DeclInit() - Dim i As Integer + Npref = fNpref(Nidle) - For i = 0 To iDim - LPT1(i) = Declaration.PT1(LnU(i)) - Next + If Npref < 0 Then + WorkerMsg(tMsgID.Err, "Failed to calculate Npref! Expand full load curve!", MsgSrc) + Return False + End If - End Sub + Nhi = fnUofPfull(0.7 * Pmax, False) - ''' <summary> - ''' Get or set Filepath before calling ReadFile - ''' </summary> - ''' <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 + If Nhi < 0 Then + WorkerMsg(tMsgID.Err, "Failed to calculate Nhi! Expand full load curve!", MsgSrc) + Return False + End If + Return True + End Function + Public Sub DeclInit() + Dim i As Integer + For i = 0 To iDim + LPT1(i) = Declaration.PT1(LnU(i)) + Next + End Sub + ''' <summary> + ''' Get or set Filepath before calling ReadFile + ''' </summary> + ''' <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 End Class diff --git a/VECTO/Input Files/cGBX.vb b/VECTO/Input Files/cGBX.vb index 41f2cf929faab3513712562f3c3252b6d70e9f93..e564129a3909d021feecafd228b6ca46d82b8de1 100644 --- a/VECTO/Input Files/cGBX.vb +++ b/VECTO/Input Files/cGBX.vb @@ -32,9 +32,7 @@ Public Class cGBX 'Gear shift polygons Public gs_files As List(Of cSubPath) Public Shiftpolygons As List(Of cShiftPolygon) - - Public FldFiles As List(Of cSubPath) - Public FLD As List(Of cFLD) + Public MaxTorque As List(Of String) Public gs_TorqueResv As Single Public gs_SkipGears As Boolean @@ -77,6 +75,7 @@ Public Class cGBX Public UpshiftMinAcceleration As Single Public DownshiftAfterUpshift As Single Public UpshiftAfterDownshift As Single + Public TCshiftFile As String Public Function CreateFileList() As Boolean @@ -120,8 +119,7 @@ Public Class cGBX 'IsTCgear = New List(Of Boolean) GetrMaps = New List(Of cSubPath) gs_files = New List(Of cSubPath) - FldFiles = New List(Of cSubPath) - FLD = New List(Of cFLD) + MaxTorque = New List(Of String) GetrEffDef = New List(Of Boolean) GetrEff = New List(Of Single) @@ -185,7 +183,8 @@ Public Class cGBX If i > 0 Then 'dic0.Add("TCactive", IsTCgear(i)) dic0.Add("ShiftPolygon", gs_files(i).PathOrDummy) - dic0.Add("FullLoadCurve", FldFiles(i).PathOrDummy) + 'dic0.Add("FullLoadCurve", FldFiles(i).PathOrDummy) + dic0.Add("MaxTorque", MaxTorque(i)) End If ls.Add(dic0) @@ -208,8 +207,10 @@ Public Class cGBX dic0.Add("File", TC_file.PathOrDummy) dic0.Add("RefRPM", TCrefrpm) dic0.Add("Inertia", TCinertia) + dic0.Add("ShiftPolygon", TCshiftFile) dic.Add("TorqueConverter", dic0) + dic.Add("DownshiftAferUpshiftDelay", DownshiftAfterUpshift) dic.Add("UpshiftAfterDownshiftDelay", UpshiftAfterDownshift) dic.Add("UpshiftMinAcceleration", UpshiftMinAcceleration) @@ -258,14 +259,14 @@ Public Class cGBX GetrMaps(i).Init(MyPath, dic("Efficiency")) End If - + MaxTorque.Add(dic("MaxTorque")) gs_files.Add(New cSubPath) - FldFiles.Add(New cSubPath) + 'FldFiles.Add(New cSubPath) If i = 0 Then 'IsTCgear.Add(False) gs_files(i).Init(MyPath, sKey.NoFile) - FldFiles(i).Init(MyPath, sKey.NoFile) + 'FldFiles(i).Init(MyPath, sKey.NoFile) Else 'IsTCgear.Add(dic("TCactive")) If FileVersion < 2 Then @@ -273,11 +274,11 @@ Public Class cGBX Else gs_files(i).Init(MyPath, dic("ShiftPolygon")) End If - If FileVersion < 5 Then - FldFiles(i).Init(MyPath, sKey.NoFile) - Else - FldFiles(i).Init(MyPath, dic("FullLoadCurve")) - End If + 'If FileVersion < 5 Then + ' FldFiles(i).Init(MyPath, sKey.NoFile) + 'Else + ' FldFiles(i).Init(MyPath, dic("FullLoadCurve")) + 'End If End If Next @@ -316,9 +317,13 @@ Public Class cGBX TCon = JSON.Content("Body")("TorqueConverter")("Enabled") TC_file.Init(MyPath, JSON.Content("Body")("TorqueConverter")("File")) TCrefrpm = JSON.Content("Body")("TorqueConverter")("RefRPM") - If FileVersion > 2 Then TCinertia = JSON.Content("Body")("TorqueConverter")("Inertia") + If FileVersion > 2 Then + TCinertia = JSON.Content("Body")("TorqueConverter")("Inertia") + End If + If FileVersion > 5 Then + TCshiftFile = JSON.Content("Body")("TorqueConverter")("ShiftPolygon") + End If End If - Catch ex As Exception If ShowMsg Then WorkerMsg(tMsgID.Err, "Failed to read VECTO file! " & ex.Message, MsgSrc) Return False @@ -355,7 +360,7 @@ Public Class cGBX TCon = (AutomaticTransmission(gs_Type)) For i = 1 To GearCount() - Shiftpolygons(i).SetGenericShiftPoly(FLD(i), ENG.Nidle) + Shiftpolygons(i).SetGenericShiftPoly(ENG.FLD, ENG.Nidle) Next @@ -442,815 +447,11 @@ Public Class cGBX Return True End Function - Public Function TCiteration(ByVal Gear As Integer, ByVal nUout As Single, ByVal PeOut As Single, ByVal t As Integer, - Optional ByVal LastnU As Single? = Nothing, Optional ByVal LastPe As Single? = Nothing) As Boolean - - Dim i As Integer - Dim iDim As Integer - Dim nUin As Single - Dim Mout As Single - Dim Min As Single - Dim MinMax As Single - Dim MinCalc As Single - Dim nuStep As Single - Dim nuMin As Single - Dim nuMax As Single - - Dim nu As Single - Dim mu As Single - - Dim MoutCalc As Single - - Dim Paux As Single - Dim PaMot As Single - Dim Pfull As Single - Dim PinMax As Single - - Dim nuList As New List(Of Single) - Dim McalcRatio As New List(Of Single) - - Dim McalcRatMax As Single - Dim ErrMin As Single - Dim iMin As Integer - - Dim Brake As Boolean - Dim FirstDone As Boolean - - Dim rpmLimit As Single - - Dim iOptPassed As Integer - - Dim MsgSrc As String - - MsgSrc = "GBX/TCiteration/t= " & t + 1 - - TC_PeBrake = 0 - TCReduce = False - Brake = False - TCNeutral = False - - 'TC rpm limit - If DEV.TClimitOn Then - If MODdata.Vh.a(t) >= DEV.TCaccmin Then - rpmLimit = DEV.TClimit - Else - rpmLimit = ENG.Nrated - End If - Else - rpmLimit = ENG.Nrated - End If - - 'Power to torque - Mout = nPeToM(nUout, PeOut) - - - 'Set nu boundaries - If Mout < 0 Then - - 'Speed too low in motoring(check if nu=1 allows enough engine speed) - If nUout < ENG.Nidle Then - TCNeutral = True - Return True - End If - - nuMin = 1 - nuMax = Math.Min(TCnu(TCdim), nUout / ENG.Nidle) - - Else - nuMin = Math.Max(nUout / rpmLimit, TCnu(0)) - nuMax = Math.Min(TCnuMax, nUout / ENG.Nidle) - End If - - If nuMax <= nuMin Then - TCReduce = True - Return True - End If - - 'Reduce step size if nu-range is too low - nuStep = 0.01 - Do While (nuMax - nuMin) / nuStep < 10 And nuStep > 0.00001 - nuStep *= 0.1 - Loop - - - Do - - iOptPassed = -1 - FirstDone = False - nu = nuMin - nuStep - iDim = -1 - nuList.Clear() - McalcRatio.Clear() - Do While nu + nuStep <= nuMax - - 'nu - nu += nuStep - - 'Abort if nu<=0 - If nu <= 0 Then Continue Do - - 'mu - mu = fTCmu(nu) - - 'Abort if mu<=0 - If mu <= 0 Then Continue Do - - 'nIn - nUin = nUout / nu - - - 'AA-TB - 'Recalculate for Advanced Auxiliaries. - - mAAUX_Global.ClutchEngaged = (Gear > 0) - - mAAUX_Global.Idle = False '(Gear = 0 And Not Pplus And Not Pminus) - - mAAUX_Global.InNeutral = (Gear = 0) - - 'Driveline Power = required power at clutch = power at wheels plus powertrain losses - '[kW] - '**** RL 7-7-15 **** - mAAUX_Global.EngineDrivelinePower = PeOut - - '[1/min] - mAAUX_Global.EngineSpeed = nu - - '[Nm] (using Power => Torque conversion) - mAAUX_Global.EngineDrivelineTorque = nPeToM(EngineSpeed, EngineDrivelinePower) - - 'Motoring power (< 0 !!!) - '[kW] - '** MULTIPLIED BY - TO GET POSITIVE VALUE - mAAUX_Global.EngineMotoringPower = -FLD(Gear).Pdrag(EngineSpeed) - - 'Additional aux power from driving cycle (optional user input) - '[kW] - mAAUX_Global.PreExistingAuxPower = MODdata.Vh.Padd(t) - - - 'MinMax - Paux = MODdata.Px.fPaux(t, Math.Max(nUin, ENG.Nidle)) - If LastnU Is Nothing Then - PaMot = 0 - Else - PaMot = MODdata.Px.fPaMot(nUin, LastnU) - End If - If LastPe Is Nothing Then - Pfull = FLD(Gear).Pfull(nUin) - Else - Pfull = FLD(Gear).Pfull(nUin, LastPe) - End If - PinMax = 0.999 * (Pfull - Paux - PaMot) - MinMax = nPeToM(nUin, PinMax) - - 'Min - Min = Mout / mu - - 'Check if Min is too high - If Min > MinMax Then Continue Do - - 'Calculated input and output torque for given mu - MinCalc = fTCtorque(nu, nUin) - MoutCalc = MinCalc * mu - - 'Add to lists - nuList.Add(nu) - McalcRatio.Add(MoutCalc / Mout) - iDim += 1 - - 'Calc smallest error for each mu value - If FirstDone Then - If Math.Abs(1 - McalcRatio(iDim)) < ErrMin Then - ErrMin = Math.Abs(1 - McalcRatio(iDim)) - iMin = iDim - End If - If McalcRatio(iDim) > McalcRatMax Then McalcRatMax = McalcRatio(iDim) - If _ - (McalcRatio(iDim) > 1 AndAlso McalcRatio(iDim - 1) < 1) OrElse - (McalcRatio(iDim) < 1 AndAlso McalcRatio(iDim - 1) > 1) Then - iOptPassed = iDim - End If - Else - FirstDone = True - ErrMin = Math.Abs(1 - McalcRatio(iDim)) - iMin = iDim - McalcRatMax = McalcRatio(iDim) - End If - - 'Abort if error is small enough - If ErrMin <= DEV.TCiterPrec Then Exit Do - - Loop - - If iDim = -1 Then - TCReduce = True - Return True - End If - - If ErrMin > DEV.TCiterPrec AndAlso iOptPassed > -1 AndAlso nuStep > 0.00001 Then - nuMin = nuList(iOptPassed - 1) - nuMax = nuList(iOptPassed) - nuStep = Math.Max((nuMax - nuMin) / 10.0, 0.00001) - Else - Exit Do - End If - - Loop - - If ErrMin > DEV.TCiterPrec Then - - If McalcRatMax >= 1 Then - - 'Creeping... - FirstDone = False - For i = 0 To iDim - If McalcRatio(i) > 1 Then - If FirstDone Then - If Math.Abs(1 - McalcRatio(i)) < ErrMin Then - ErrMin = Math.Abs(1 - McalcRatio(i)) - iMin = i - End If - Else - FirstDone = True - ErrMin = Math.Abs(1 - McalcRatio(i)) - iMin = i - End If - End If - Next - - Brake = True - - Else - - If MoutCalc > 0 Then - TCReduce = True - Return True - End If - - - End If - - End If - - nu = nuList(iMin) - mu = fTCmu(nu) - TCnUin = nUout / nu - TCMout = fTCtorque(nu, TCnUin) * mu - TCMin = TCMout / mu - TCnUout = nUout - - TC_mu = mu - TC_nu = nu - - If Brake Then TC_PeBrake = nMtoPe(TCnUout, Mout - TCMout) - - - Return True - End Function - - - Private Function fTCmu(ByVal nu As Single) As Single - Dim i As Int32 - - 'Extrapolation for x < x(1) - If TCnu(0) >= nu Then - If TCnu(0) > nu Then MODdata.ModErrors.TCextrapol = "nu= " & nu & " [n_out/n_in]" - i = 1 - GoTo lbInt - End If - - i = 0 - Do While TCnu(i) < nu And i < TCdim - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If TCnu(i) < nu Then - MODdata.ModErrors.TCextrapol = "nu= " & nu & " [n_out/n_in]" - End If - -lbInt: - 'Interpolation - Return (nu - TCnu(i - 1)) * (TCmu(i) - TCmu(i - 1)) / (TCnu(i) - TCnu(i - 1)) + TCmu(i - 1) - End Function - - Private Function fTCtorque(ByVal nu As Single, ByVal nUin As Single) As Single - Dim i As Int32 - Dim M0 As Single - - 'Extrapolation for x < x(1) - If TCnu(0) >= nu Then - If TCnu(0) > nu Then MODdata.ModErrors.TCextrapol = "nu= " & nu & " [n_out/n_in]" - i = 1 - GoTo lbInt - End If - - i = 0 - Do While TCnu(i) < nu And i < TCdim - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If TCnu(i) < nu Then - MODdata.ModErrors.TCextrapol = "nu= " & nu & " [n_out/n_in]" - End If - -lbInt: - 'Interpolation - M0 = (nu - TCnu(i - 1)) * (TCtorque(i) - TCtorque(i - 1)) / (TCnu(i) - TCnu(i - 1)) + TCtorque(i - 1) - - Return M0 * (nUin / TCrefrpm) ^ 2 - End Function - - Public Function GSinit() As Boolean - Dim i As Integer - Dim MsgSrc As String - - MsgSrc = "GBX/Init" - - 'Set Gearbox Type-specific settings - If gs_Type <> tGearbox.Custom Then - - gs_ShiftInside = cDeclaration.ShiftInside(gs_Type) - TCon = AutomaticTransmission(gs_Type) - gs_SkipGears = cDeclaration.SkipGears(gs_Type) - - End If - - Shiftpolygons = New List(Of cShiftPolygon) - For i = 0 To Igetr.Count - 1 - Shiftpolygons.Add(New cShiftPolygon(gs_files(i).FullPath, i)) - If Not Cfg.DeclMode And i > 0 Then - 'Error-notification within ReadFile() - If Not Shiftpolygons(i).ReadFile() Then Return False - End If - Next - - 'Fld - For i = 0 To GearCount() - - FLD.Add(New cFLD) - - If FldFile(i) = "" Then - FLD(i).FilePath = ENG.FLD.FilePath - Else - FLD(i).FilePath = FldFile(i) - End If - - Try - If Not FLD(i).ReadFile(True) Then Return False 'Error message in ReadFile - Catch ex As Exception - WorkerMsg(tMsgID.Err, "File read error! (" & FldFile(i) & ")", MsgSrc, FldFile(i)) - Return False - End Try - - 'If Engine full load is lower than gear's max torque then limit to engine - FLD(i).LimitToEng() - - - If Not FLD(i).Init(ENG.Nidle) Then Return False - - Next - - - Return True - End Function Public Function GearCount() As Integer Return Me.Igetr.Count - 1 End Function -#Region "Transmission Loss Maps" - - Public Function TrLossMapInit() As Boolean - Dim i As Short - Dim GBmap0 As cDelaunayMap - 'Dim n_norm As Double - 'Dim Pe_norm As Double - Dim file As cFile_V3 - Dim path As String - Dim line As String() - Dim l As Integer - Dim nU As Double - Dim M_in As Double - Dim M_loss As Double - Dim M_out As Double - - Dim dnU As Single - Dim dM As Single - Dim P_In As Single - Dim P_Loss As Single - Dim EffSum As Single - Dim Anz As Integer - Dim EffDiffSum As Single = 0 - Dim AnzDiff As Integer = 0 - - Dim MinG As Single - Dim plossG As Single - - Dim MsgSrc As String - - MyGBmaps = New List(Of cDelaunayMap) - file = New cFile_V3 - - For i = 0 To GBX.GearCount - - MsgSrc = "VEH/TrLossMapInit/G" & i - - If IsNumeric(GetrMap(i, True)) Then - GetrEffDef.Add(True) - GetrEff.Add(CSng(GBX.GetrMap(i, True))) - Else - GetrEffDef.Add(False) - GetrEff.Add(0) - End If - - If GetrEffDef(i) Then - - If GetrEff(i) > 1 Or GetrEff(i) <= 0 Then - WorkerMsg(tMsgID.Err, "Gearboy efficiency '" & GetrEff(i) & "' invalid!", MsgSrc) - Return False - End If - - MyGBmaps.Add(Nothing) - - Else - - path = GetrMaps(i).FullPath - - If Not file.OpenRead(path) Then - WorkerMsg(tMsgID.Err, "Cannot read file '" & path & "'!", MsgSrc) - MyGBmaps = Nothing - Return False - End If - - 'Skip header - file.ReadLine() - - GBmap0 = New cDelaunayMap - GBmap0.DualMode = True - - l = 0 'Nur für Fehler-Ausgabe - Do While Not file.EndOfFile - l += 1 - line = file.ReadLine - Try - - nU = CDbl(line(0)) - M_in = CDbl(line(1)) - M_loss = CDbl(line(2)) - - M_out = M_in - M_loss - - 'old version: Power instead of torque: GBmap0.AddPoints(nU, nMtoPe(nU, M_out), nMtoPe(nU, M_in)) - GBmap0.AddPoints(nU, M_out, M_in) - Catch ex As Exception - WorkerMsg(tMsgID.Err, "Error during file read! Line number: " & l & " (" & path & ")", MsgSrc, path) - file.Close() - MyGBmaps = Nothing - Return False - End Try - Loop - - file.Close() - - If Not GBmap0.Triangulate Then - WorkerMsg(tMsgID.Err, "Map triangulation failed! File: " & path, MsgSrc, path) - MyGBmaps = Nothing - Return False - End If - - MyGBmaps.Add(GBmap0) - - 'Calculate average efficiency for fast approx. calculation - If i > 0 Then - - 'If GBX.IsTCgear(i) Then - - ' GetrEff(i) = -1 - - 'Else - - EffSum = 0 - Anz = 0 - - dnU = (2 / 3) * (ENG.Nrated - ENG.Nidle) / 10 - nU = ENG.Nidle + dnU - - Do While nU <= ENG.Nrated - - dM = nPeToM(nU, (2 / 3) * FLD(i).Pfull(nU) / 10) - M_in = nPeToM(nU, (1 / 3) * FLD(i).Pfull(nU)) - - Do While M_in <= nPeToM(nU, FLD(i).Pfull(nU)) - - P_In = nMtoPe(nU, M_in) - - P_Loss = IntpolPeLossFwd(i, nU, P_In, False) - - EffSum += (P_In - P_Loss) / P_In - Anz += 1 - - - plossG = P_Loss - MinG = M_in - - - 'Axle - P_In -= P_Loss - P_Loss = IntpolPeLossFwd(0, nU / GBX.Igetr(i), P_In, False) - EffDiffSum += (P_In - P_Loss) / P_In - AnzDiff += 1 - - If MODdata.ModErrors.TrLossMapExtr <> "" Then - WorkerMsg(tMsgID.Err, "Transmission loss map does not cover full engine operating range!", MsgSrc) - WorkerMsg(tMsgID.Err, MODdata.ModErrors.TrLossMapExtr, MsgSrc) - WorkerMsg(tMsgID.Err, "nU_In(GB)=" & nU & " [1/min]", MsgSrc) - WorkerMsg(tMsgID.Err, "M_In(GB)=" & MinG & " [Nm]", MsgSrc) - WorkerMsg(tMsgID.Err, "P_Loss(GB)=" & plossG & " [kW]", MsgSrc) - WorkerMsg(tMsgID.Err, "nU_In(axle)=" & CStr(nU / Igetr(i)) & " [1/min]", MsgSrc) - WorkerMsg(tMsgID.Err, "M_In(axle)=" & CStr(nPeToM(nU / Igetr(i), P_In)) & " [Nm]", MsgSrc) - WorkerMsg(tMsgID.Err, "P_Loss(axle)=" & P_Loss & " [kW]", MsgSrc) - Return False - End If - - M_in += dM - Loop - - - nU += dnU - Loop - - If Anz = 0 Then - WorkerMsg(tMsgID.Err, "Failed to calculate approx. transmission losses!", MsgSrc) - Return False - End If - - GetrEff(i) = EffSum / Anz - - ' End If - - End If - - - End If - - Next - - If Not GetrEffDef(0) Then - GetrEff(0) = EffDiffSum / AnzDiff - End If - - - Return True - End Function - - Public Function IntpolPeLoss(ByVal Gear As Integer, ByVal nU As Double, ByVal PeOut As Double, ByVal Approx As Boolean) _ - As Double - - Dim PeIn As Double - Dim WG As Double - Dim GBmap As cDelaunayMap - Dim i As Integer - Dim Ab As Double - Dim AbMin As Double - Dim iMin As Integer - Dim PeOutX As Double - Dim GrTxt As String - Dim Ploss As Single - - Dim MsgSrc As String - - MsgSrc = "VEH/TrLossMapInterpol/G" & Gear - - If Gear = 0 Then - GrTxt = "A" - Else - GrTxt = Gear.ToString - End If - - If GetrEffDef(Gear) Or (Approx AndAlso GetrEff(Gear) > 0) Then - - If PeOut > 0 Then - PeIn = PeOut / GetrEff(Gear) - Else - PeIn = PeOut * GetrEff(Gear) - End If - Ploss = PeIn - PeOut - - Else - - GBmap = MyGBmaps(Gear) - - - 'Interpolate with Original Values - PeIn = nMtoPe(nU, GBmap.Intpol(nU, nPeToM(nU, PeOut))) - - If GBmap.ExtrapolError Then - - 'If error: try extrapolation - - 'Search for the nearest Map point - AbMin = ((GBmap.ptList(0).X - nU) ^ 2 + (GBmap.ptList(0).Y - nPeToM(nU, PeOut)) ^ 2) ^ 0.5 - iMin = 0 - For i = 1 To GBmap.ptDim - Ab = ((GBmap.ptList(i).X - nU) ^ 2 + (GBmap.ptList(i).Y - nPeToM(nU, PeOut)) ^ 2) ^ 0.5 - If Ab < AbMin Then - AbMin = Ab - iMin = i - End If - Next - - PeOutX = nMtoPe(nU, GBmap.ptList(iMin).Y) - PeIn = nMtoPe(nU, GBmap.ptList(iMin).Z) - - 'Efficiency - If PeOutX > 0 Then - If PeIn > 0 Then - - WG = PeOutX / PeIn - PeIn = PeOut / WG - Ploss = PeIn - PeOut - - Else - - 'Drag => Drive: ERROR! - WorkerMsg(tMsgID.Err, - "Transmission Loss Map invalid! Gear= " & GrTxt & ", nU= " & nU.ToString("0.00") & " [1/min], PeIn=" & - PeIn.ToString("0.0") & " [kW], PeOut=" & PeOutX.ToString("0.0") & " [kW]", MsgSrc) - WorkerAbort() - Return 0 - - End If - - ElseIf PeOutX < 0 Then - - If PeIn > 0 Then - - WG = (PeIn - (PeIn - PeOutX)) / PeIn - PeIn = PeOut / WG - Ploss = PeIn - PeOut - - ElseIf PeIn < 0 Then - - WG = PeIn / PeOutX - PeIn = PeOut * WG - Ploss = PeIn - PeOut - - Else - - Ploss = Math.Abs(PeOut) - - End If - - - Else - - If PeIn > 0 Then - - Ploss = PeIn - - ElseIf PeIn < 0 Then - - 'Drag => Zero: ERROR! - WorkerMsg(tMsgID.Err, - "Transmission Loss Map invalid! Gear= " & GrTxt & ", nU= " & nU.ToString("0.00") & " [1/min], PeIn=" & - PeIn.ToString("0.0") & " [kW], PeOut=" & PeOutX.ToString("0.0") & " [kW]", MsgSrc) - WorkerAbort() - Return 0 - Else - - Ploss = Math.Abs(PeOut) - - End If - - End If - - MODdata.ModErrors.TrLossMapExtr = "Gear= " & GrTxt & ", nU= " & nU.ToString("0.00") & " [1/min], MeOut=" & - nPeToM(nU, PeOut).ToString("0.00") & " [Nm]" - - Else - - Ploss = PeIn - PeOut - - - End If - - End If - - Return Math.Max(Ploss, 0) - End Function - - Public Function IntpolPeLossFwd(ByVal Gear As Integer, ByVal nU As Double, ByVal PeIn As Double, - ByVal Approx As Boolean) As Double - - Dim PeOut As Double - Dim WG As Double - Dim GBmap As cDelaunayMap - Dim i As Integer - Dim Ab As Double - Dim AbMin As Double - Dim iMin As Integer - Dim PeInX As Double - Dim GrTxt As String - - Dim MsgSrc As String - - MsgSrc = "VEH/TrLossMapInterpolFwd/G" & Gear - - If Gear = 0 Then - GrTxt = "A" - Else - GrTxt = Gear.ToString - End If - - If GetrEffDef(Gear) Or (Approx AndAlso GetrEff(Gear) > 0) Then - - If PeIn > 0 Then - PeOut = PeIn * GetrEff(Gear) - Else - PeOut = PeIn / GetrEff(Gear) - End If - - Else - - GBmap = MyGBmaps(Gear) - - - 'Interpolate with original values - PeOut = nMtoPe(nU, GBmap.IntpolXZ(nU, nPeToM(nU, PeIn))) - - If GBmap.ExtrapolError Then - - 'If error: try extrapolation - - 'Search for the nearest Map-point - AbMin = ((GBmap.ptList(0).X - nU) ^ 2 + (GBmap.ptList(0).Z - nPeToM(nU, PeIn)) ^ 2) ^ 0.5 - iMin = 0 - For i = 1 To GBmap.ptDim - Ab = ((GBmap.ptList(i).X - nU) ^ 2 + (GBmap.ptList(i).Z - nPeToM(nU, PeIn)) ^ 2) ^ 0.5 - If Ab < AbMin Then - AbMin = Ab - iMin = i - End If - Next - - PeInX = nMtoPe(nU, GBmap.ptList(iMin).Z) - PeOut = nMtoPe(nU, GBmap.ptList(iMin).Y) - - 'Efficiency - If PeOut > 0 Then - If PeInX > 0 Then - - 'Drivetrain => Drivetrain - WG = PeOut / PeInX - - Else - - 'Drag => Drivetrain: ERROR! - WorkerMsg(tMsgID.Err, - "Transmission Loss Map invalid! Gear= " & GrTxt & ", nU= " & nU.ToString("0.00") & " [1/min], PeIn=" & - PeInX.ToString("0.00") & " [kW], PeOut=" & PeOut.ToString("0.00") & " [kW] (fwd)", MsgSrc) - WorkerAbort() - Return 0 - - End If - - Else - If PeInX > 0 Then - - WorkerMsg(tMsgID.Warn, - "Change of sign in Transmission Loss Map! Set efficiency to 10%. Gear= " & GrTxt & ", nU= " & - nU.ToString("0.00") & " [1/min], PeIn=" & PeInX.ToString("0.00") & " [kW], PeOut=" & PeOut.ToString("0.00") & - " [kW] (fwd)", MsgSrc) - 'WorkerAbort() - WG = 0.1 - - Else - - 'Drag => Drag - WG = PeInX / PeOut - - - End If - End If - - 'Calculate efficiency with PeIn for original PeOut - PeOut = PeIn * WG - - MODdata.ModErrors.TrLossMapExtr = "Gear= " & GrTxt & ", nU= " & nU.ToString("0.00") & " [1/min], MeIn=" & - nPeToM(nU, PeIn).ToString("0.00") & " [Nm] (fwd)" - - End If - - End If - - Return Math.Max(PeIn - PeOut, 0) - End Function - - -#End Region Public ReadOnly Property FileList As List(Of String) Get @@ -1298,18 +499,18 @@ lbInt: End Set End Property - Public Property FldFile(ByVal x As Short, Optional ByVal Original As Boolean = False) As String - Get - If Original Then - Return FldFiles(x).OriginalPath - Else - Return FldFiles(x).FullPath - End If - End Get - Set(value As String) - FldFiles(x).Init(MyPath, value) - End Set - End Property + 'Public Property FldFile(ByVal x As Short, Optional ByVal Original As Boolean = False) As String + ' Get + ' If Original Then + ' Return FldFiles(x).OriginalPath + ' Else + ' Return FldFiles(x).FullPath + ' End If + ' End Get + ' Set(value As String) + ' FldFiles(x).Init(MyPath, value) + ' End Set + 'End Property Public Property TCfile(Optional ByVal Original As Boolean = False) As String diff --git a/VECTO/Input Files/cVECTO.vb b/VECTO/Input Files/cVECTO.vb index b3dcf06c2bcc2bc3c36928840163981758d36d46..521454ebd952a6ba56641933d50a63e6618e3a1d 100644 --- a/VECTO/Input Files/cVECTO.vb +++ b/VECTO/Input Files/cVECTO.vb @@ -525,7 +525,7 @@ Public Class cVECTO line = file.ReadLine - _laDesV.Add(CSng(line(0)) / 3.6) 'km/h => m/s !!!! + _laDesV.Add(CSng(line(0)) / 3.6) 'km/h => m/s !!!! _laDesMax.Add(CSng(line(1))) _laDesMin.Add(CSng(line(2))) @@ -547,97 +547,6 @@ Public Class cVECTO Return True End Function -#Region "Aux" - - Public Function AuxInit() As Boolean - Dim msgSrc = "VEH/AuxInit" - AuxRefs = New Dictionary(Of String, cAux) - - If Cfg.DeclMode Then - For Each auxPathKv In AuxPaths - AuxRefs.Add(auxPathKv.Key, Nothing) - Next - Return True - End If - - If DRI.AuxDef Xor AuxDef Then - If AuxDef Then - WorkerMsg(tMsgID.Err, "No auxiliary input defined in driving cycle!", msgSrc) - Return False - Else - WorkerMsg(tMsgID.Warn, "No auxiliary defined in vehicle file! Psupply input will be ignored!", msgSrc) - Return True - End If - End If - - If Not (DRI.AuxDef Or AuxDef) Then - Return True - End If - - Dim drIauxcheck = DRI.AuxComponents.Keys.ToDictionary(Function(auxId) auxId, Function(auxId) False) - - For Each auxPathKv In AuxPaths - msgSrc = "VEH/AuxInit/" & auxPathKv.Key - If Not DRI.AuxComponents.ContainsKey(auxPathKv.Key) Then - WorkerMsg(tMsgID.Err, "No Psupply input defined in driving cycle for auxiliary '" & auxPathKv.Key & "'!", msgSrc) - Return False - End If - - Dim aux0 = New cAux - aux0.Filepath = auxPathKv.Value.Path.FullPath - - If Not aux0.Readfile Then - Return False - End If - - AuxRefs.Add(auxPathKv.Key, aux0) - drIauxcheck(auxPathKv.Key) = True - Next - - msgSrc = "VEH/AuxInit" - - For Each auxId In DRI.AuxComponents.Keys - If Not drIauxcheck(auxId) Then - WorkerMsg(tMsgID.Warn, "Auxiliary '" & auxId & "' not found! Psupply input will be ignored!", msgSrc) - End If - Next - - Return True - End Function - - Public Function Paux(auxId As String, t As Integer, nU As Single) As Single - If Cfg.DeclMode Then Return Declaration.AuxPower(auxId) - - If AuxDef Then - Dim aux0 = AuxRefs(auxId) - Dim psupply As Single = DRI.AuxComponents(auxId)(t) - If psupply < 0 Then - GoTo lbAuxError - End If - - Dim px As Single = aux0.Paux(nU, psupply) - If px < 0 Then - GoTo lbAuxError - End If - Return px - Else - Return 0 - End If - -lbAuxError: - MODdata.ModErrors.AuxNegative = auxId - Return 0 - End Function - - Public Function PauxSum(t As Integer, nU As Single) As Single - If AuxDef Then - Return AuxRefs.Keys.Sum(Function(auxId) Paux(auxId, t, nU)) - End If - Return 0 - End Function - -#End Region - #Region "Properties" @@ -750,56 +659,6 @@ lbAuxError: #End Region - - Public Function ADesMax(v As Single) As Single - Dim i As Int32 - - 'Extrapolation for x < x(1) - If _laDesV(0) >= v Then - If _laDesV(0) > v Then MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" - i = 1 - GoTo lbInt - End If - - i = 0 - Do While _laDesV(i) < v And i < _desMaxDim - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If _laDesV(i) < v Then - MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" - End If - -lbInt: - 'Interpolation - Return (v - _laDesV(i - 1)) * (_laDesMax(i) - _laDesMax(i - 1)) / (_laDesV(i) - _laDesV(i - 1)) + _laDesMax(i - 1) - End Function - - Public Function ADesMin(v As Single) As Single - Dim i As Int32 - - 'Extrapolation for x < x(1) - If _laDesV(0) >= v Then - If _laDesV(0) > v Then MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" - i = 1 - GoTo lbInt - End If - - i = 0 - Do While _laDesV(i) < v And i < _desMaxDim - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If _laDesV(i) < v Then - MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" - End If - -lbInt: - 'Interpolation - Return (v - _laDesV(i - 1)) * (_laDesMin(i) - _laDesMin(i - 1)) / (_laDesV(i) - _laDesV(i - 1)) + _laDesMin(i - 1) - End Function End Class diff --git a/VECTO/Input Files/cVEH.vb b/VECTO/Input Files/cVEH.vb index 456aeb9cbf53d2d22662de0d3d1d2e8114a80d37..8308bdbdf47b97150f408b9589a502702b920710 100644 --- a/VECTO/Input Files/cVEH.vb +++ b/VECTO/Input Files/cVEH.vb @@ -42,7 +42,6 @@ Public Class cVEH Public RtType As tRtType '0=None, 1=Primary, 2=Secondary Public RtRatio As Single = 0 Public RtFile As cSubPath - Private RtDim As Integer Private RtnU As List(Of Single) Private RtM As List(Of Single) @@ -421,353 +420,6 @@ Public Class cVEH End Function - Public Function VehmodeInit() As Boolean - Const msgSrc = "VEH/Init" - - 'Cd-Init - If Not CdInit() Then Return False - - 'Transmission Loss Maps - If Not GBX.TrLossMapInit Then - WorkerMsg(tMsgID.Err, "Failed to initialize Transmission Loss Maps!", msgSrc) - Return False - End If - - 'Retarder - If Not RtInit() Then Return False - - 'Fr0 - If Axles.Count < 2 Then - WorkerMsg(tMsgID.Err, "At least 2 axle configurations are required!", msgSrc, "<GUI>" & sFilePath) - Return False - End If - - 'Check if sum=100% - If Math.Abs(Axles.Sum(Function(axle) axle.Share) - 1) > 0.0001 Then - WorkerMsg(tMsgID.Err, "Sum of relative axle shares is not 100%!", msgSrc, "<GUI>" & sFilePath) - Return False - End If - - If rdyn <= 0 Then - WorkerMsg(tMsgID.Err, "rdyn is invalid!", msgSrc, "<GUI>" & sFilePath) - Return False - End If - - Dim rrc = 0.0 - m_red0 = 0 - For Each a0 In Axles - - If a0.RRC < -0.000001 Then - WorkerMsg(tMsgID.Err, "Invalid RRC value! (" & a0.RRC & ")", msgSrc, "<GUI>" & sFilePath) - Return False - End If - - If a0.FzISO < 0.00001 Then - WorkerMsg(tMsgID.Err, "Invalid FzISO value! (" & a0.FzISO & ")", msgSrc, "<GUI>" & sFilePath) - Return False - End If - - Dim nrwheels As Single - If a0.TwinTire Then - nrwheels = 4 - Else - nrwheels = 2 - End If - - rrc += a0.Share * (a0.RRC * ((Loading + Mass + MassExtra) * a0.Share * 9.81 / (a0.FzISO * nrwheels)) ^ (0.9 - 1)) 'Beta=0.9 - - m_red0 += nrwheels * a0.Inertia / ((rdyn / 1000) ^ 2) - - Next - - siFr0 = rrc - - Return True - End Function - - -#Region "Cd Funktionen" - - Private Function CdInit() As Boolean - Dim file As cFile_V3 - Dim line As String() - - Const msgSrc = "VEH/CdInit" - - 'Warn If Vair specified in DRI but CdType != CdOfBeta - If DRI.VairVorg Xor CdMode = tCdMode.CdOfBeta Then - - If DRI.VairVorg Then - WorkerMsg(tMsgID.Warn, "Vair input in driving cycle will be irgnored! (Side wind correction disabled in .veh file)", - msgSrc) - Else - WorkerMsg(tMsgID.Err, "No Vair input in driving cycle defined! Vres and Beta is required!", msgSrc) - Return False - End If - - End If - - 'If Cd-value is constant then do nothing - If CdMode = tCdMode.ConstCd0 Then Return True - - 'Declaration Mode - If CdMode = tCdMode.CdOfVdecl Then Return CdofVdeclInit() - - - 'Read Inputfile - file = New cFile_V3 - - If Not file.OpenRead(CdFile.FullPath) Then - WorkerMsg(tMsgID.Err, "Failed to read Cd input file! (" & CdFile.FullPath & ")", msgSrc) - Return False - End If - - 'Skip Header - file.ReadLine() - - CdX.Clear() - CdY.Clear() - CdDim = -1 - Do While Not file.EndOfFile - - CdDim += 1 - line = file.ReadLine - - Try - CdX.Add(CSng(line(0))) - CdY.Add(CSng(line(1))) - Catch ex As Exception - WorkerMsg(tMsgID.Err, "Error during file read! Line number: " & CdDim + 1 & " (" & CdFile.FullPath & ")", msgSrc, - CdFile.FullPath) - file.Close() - Return False - End Try - - Loop - - file.Close() - - If CdDim < 1 Then - WorkerMsg(tMsgID.Err, "Cd input file invalid! Two or more lines required! (" & CdFile.FullPath & ")", msgSrc, - CdFile.FullPath) - Return False - End If - - Return True - End Function - - Private Function CdofVdeclInit() As Boolean - Dim lBeta As New List(Of Single) - Dim lDeltaCdA As New List(Of Single) - Dim beta As Single - Dim a As List(Of Single) - Dim share As Single - - Const vwind = cDeclaration.Vwind * 3.6 - - Try - If Cfg.DeclMode Then - a = Declaration.SegRef.VCDVparam(Declaration.CurrentMission.MissionID) - Else - a = Declaration.VCDVparamPerCat(VEH.VehCat) - End If - Catch ex As Exception - Return False - End Try - - For i = 0 To 12 - beta = CSng(i) - lBeta.Add(beta) - lDeltaCdA.Add(a(0) * beta + a(1) * beta ^ 2 + a(2) * beta ^ 3) - Next - - Dim iDim As Integer = lBeta.Count - 1 - - CdX.Clear() - CdY.Clear() - CdDim = -1 - - CdX.Add(0) - CdY.Add(0) - For i = 60 To 100 Step 5 - Dim vveh = CSng(i) - - Dim cdAsum As Single = 0 - For j = 0 To 180 Step 10 - Dim alpha = CSng(j) - Dim vwindX As Single = vwind * Math.Cos(alpha * Math.PI / 180) - Dim vwindY As Single = vwind * Math.Sin(alpha * Math.PI / 180) - Dim vairX As Single = vveh + vwindX - Dim vairY As Single = vwindY - Dim vair As Single = Math.Sqrt(vairX ^ 2 + vairY ^ 2) - beta = Math.Atan(vairY / vairX) * 180 / Math.PI - - Dim k As Integer - If lBeta(0) >= beta Then - k = 1 - Else - k = 0 - Do While lBeta(k) < beta And k < iDim - k += 1 - Loop - End If - Dim deltaCdA = (beta - lBeta(k - 1)) * (lDeltaCdA(k) - lDeltaCdA(k - 1)) / (lBeta(k) - lBeta(k - 1)) + - lDeltaCdA(k - 1) - - Dim cdA = CdA0Act + deltaCdA - - If j = 0 OrElse j = 180 Then - share = 5 / 180 - Else - share = 10 / 180 - End If - - cdAsum += share * cdA * (vair ^ 2 / vveh ^ 2) - - Next - CdX.Add(vveh) - CdY.Add(cdAsum) - Next - CdY(0) = CdY(1) - CdDim = CdX.Count - 1 - - Return True - End Function - - Public Function CdA_Y(x As Single) As Single - Return CdIntpol(x) - End Function - - - Public Function CdA() As Single - Return CdA0Act - End Function - - Private Function CdIntpol(x As Single) As Single - Dim i As Int32 - - 'Extrapolation for x < x(1) - If CdX(0) >= x Then - If CdX(0) > x Then - If CdMode = tCdMode.CdOfBeta Then - MODdata.ModErrors.CdExtrapol = "β= " & x - Else - MODdata.ModErrors.CdExtrapol = "v= " & x - End If - End If - i = 1 - GoTo lbInt - End If - - i = 0 - Do While CdX(i) < x And i < CdDim - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If CdX(i) < x Then - If CdMode = tCdMode.CdOfBeta Then - MODdata.ModErrors.CdExtrapol = "β= " & x - Else - MODdata.ModErrors.CdExtrapol = "v= " & x - End If - End If - -lbInt: - 'Interpolation - Return (x - CdX(i - 1)) * (CdY(i) - CdY(i - 1)) / (CdX(i) - CdX(i - 1)) + CdY(i - 1) - End Function - -#End Region - -#Region "Retarder" - - Private Function RtInit() As Boolean - Dim file As cFile_V3 - Dim line As String() - - Const msgSrc = "VEH/RtInit" - - If RtType = tRtType.None Then Return True - - 'Read Inputfile - file = New cFile_V3 - If Not file.OpenRead(RtFile.FullPath) Then - WorkerMsg(tMsgID.Err, "Failed to read Retarder input file! (" & RtFile.FullPath & ")", msgSrc) - Return False - End If - - 'Skip Header - file.ReadLine() - - RtDim = -1 - Do While Not file.EndOfFile - - RtDim += 1 - line = file.ReadLine - - Try - RtnU.Add(CSng(line(0))) - RtM.Add(CSng(line(1))) - Catch ex As Exception - WorkerMsg(tMsgID.Err, "Error during file read! Line number: " & RtDim + 1 & " (" & RtFile.FullPath & ")", msgSrc, - RtFile.FullPath) - file.Close() - Return False - End Try - - Loop - - file.Close() - - If RtDim < 1 Then - WorkerMsg(tMsgID.Err, "Retarder input file invalid! Two or more lines required! (" & RtFile.FullPath & ")", msgSrc, - RtFile.FullPath) - Return False - End If - - Return True - End Function - - - Public Function RtPeLoss(v As Single, gear As Integer) As Single - Dim nU As Single - - Select Case RtType - Case tRtType.Primary - nU = (60 * v) / (2 * VEH.rdyn * Math.PI / 1000) * GBX.Igetr(0) * GBX.Igetr(gear) * RtRatio - Case tRtType.Secondary - nU = (60 * v) / (2 * VEH.rdyn * Math.PI / 1000) * GBX.Igetr(0) * RtRatio - Case Else 'tRtType.None - Return 0 - End Select - Return RtIntpol(nU) * nU * 2 * Math.PI / 60 / 1000 - End Function - - Private Function RtIntpol(nU As Single) As Single - Dim i As Int32 - 'Extrapolation for x < x(1) - If RtnU(0) >= nU Then - If RtnU(0) > nU Then MODdata.ModErrors.RtExtrapol = "n= " & nU & " [1/min]" - i = 1 - GoTo lbInt - End If - - i = 0 - Do While RtnU(i) < nU And i < RtDim - i += 1 - Loop - - 'Extrapolation for x> x(imax) - If RtnU(i) < nU Then MODdata.ModErrors.RtExtrapol = "n= " & nU & " [1/min]" - -lbInt: - 'Interpolation - Return (nU - RtnU(i - 1)) * (RtM(i) - RtM(i - 1)) / (RtnU(i) - RtnU(i - 1)) + RtM(i - 1) - End Function - -#End Region - #Region "Properties" Public ReadOnly Property FileList As List(Of String) diff --git a/VECTO/MODcalc/cMOD.vb b/VECTO/MODcalc/cMOD.vb deleted file mode 100644 index b82a9ae3ae8bef569288a1b3743c4f1ee3520060..0000000000000000000000000000000000000000 --- a/VECTO/MODcalc/cMOD.vb +++ /dev/null @@ -1,1058 +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 - -Public Class cMOD - Public Pe As List(Of Single) - Public nU As List(Of Single) - Public nUvorg As List(Of Single) - Public tDim As Integer - Public tDimOgl As Integer - Public Px As cPower - Public Vh As cVh - Public CylceKin As cCycleKin - Public ModOutpName As String - Public ModErrors As cModErrors - - 'Power - Public Psum As List(Of Single) - Public Proll As List(Of Single) - Public Pstg As List(Of Single) - Public Pair As List(Of Single) - Public Pa As List(Of Single) - Public Pbrake As List(Of Single) - Public PauxSum As List(Of Single) - Public PlossGB As List(Of Single) - Public PlossDiff As List(Of Single) - Public PlossRt As List(Of Single) - Public PlossTC As List(Of Single) - Public PaEng As List(Of Single) - Public PaGB As List(Of Single) - Public Paux As Dictionary(Of String, List(Of Single)) - Public Pclutch As List(Of Single) - Public Grad As List(Of Single) - - 'AA-TB - 'ADVANCED AUXILIARIES - DIAGNOSTIC OUTPUT - Public AA_NonSmartAlternatorsEfficiency As List(Of Single?) - Public AA_SmartIdleCurrent_Amps As List(Of Single?) - Public AA_SmartIdleAlternatorsEfficiency As List(Of Single?) - Public AA_SmartTractionCurrent_Amps As List(Of Single?) - Public AA_SmartTractionAlternatorEfficiency As List(Of Single?) - Public AA_SmartOverrunCurrent_Amps As List(Of Single?) - Public AA_SmartOverrunAlternatorEfficiency As List(Of Single?) - Public AA_CompressorFlowRate_LitrePerSec As List(Of Single?) - Public AA_OverrunFlag As List(Of Integer?) - Public AA_EngineIdleFlag As List(Of Integer?) - Public AA_CompressorFlag As List(Of Integer?) - Public AA_TotalCycleFC_Grams As List(Of Single?) - Public AA_TotalCycleFC_Litres As List(Of Single?) - Public AA_AveragePowerDemandCrankHVACMechanicals As List(Of Single?) - Public AA_AveragePowerDemandCrankHVACElectricals As List(Of Single?) - Public AA_AveragePowerDemandCrankElectrics As List(Of Single?) - Public AA_AveragePowerDemandCrankPneumatics As List(Of Single?) - Public AA_TotalCycleFuelConsumptionCompressorOff As List(Of Single?) - Public AA_TotalCycleFuelConsumptionCompressorOn As List(Of Single?) - - 'TODO:DIAGNOSTICS (D) REMOVE WHEN TESTED - 'public AA_D_M12_P1X as list( of single ) - 'public AA_D_M12_P1Y as list( of single ) - 'public AA_D_M12_P2X as list( of single ) - 'public AA_D_M12_P2Y as list( of single ) - 'public AA_D_M12_P3X as list( of single ) - 'public AA_D_M12_P3Y as list( of single ) - 'public AA_D_M12_XTAIN as list( of single ) - 'public AA_D_M12_INTERP1 as list( of single ) - 'public AA_D_M12_INTERP2 as list( of single ) - - - '*********************************************************** - - - Public EngState As List(Of tEngState) - - 'Vehicle - Public Gear As List(Of Single) - Public VehState As List(Of tVehState) - - Public TCnu As List(Of Single) - Public TCmu As List(Of Single) - Public TCMout As List(Of Single) - Public TCnOut As List(Of Single) - - 'FC - Public FCerror As Boolean - Public lFC As List(Of Single) - Public lFCAUXc As List(Of Single) - Public lFCWHTCc As List(Of Single) - Public FCavg As Single - Public FCavgAUXc As Single - Public FCavgWHTCc As Single - Public FCavgFinal As Single - - Public FCAUXcSet As Boolean - - Private bInit As Boolean - - Public Sub New() - bInit = False - End Sub - - Public Sub Init() - Pe = New List(Of Single) - nU = New List(Of Single) - Px = New cPower - Vh = New cVh - CylceKin = New cCycleKin - - - 'AA-TB - AA_NonSmartAlternatorsEfficiency = New List(Of Single?) - AA_SmartIdleCurrent_Amps = New List(Of Single?) - AA_SmartIdleAlternatorsEfficiency = New List(Of Single?) - AA_SmartTractionCurrent_Amps = New List(Of Single?) - AA_SmartTractionAlternatorEfficiency = New List(Of Single?) - AA_SmartOverrunCurrent_Amps = New List(Of Single?) - AA_SmartOverrunAlternatorEfficiency = New List(Of Single?) - AA_CompressorFlowRate_LitrePerSec = New List(Of Single?) - AA_OverrunFlag = New List(Of Integer?) - AA_EngineIdleFlag = New List(Of Integer?) - AA_CompressorFlag = New List(Of Integer?) - AA_TotalCycleFC_Grams = New List(Of Single?) - AA_TotalCycleFC_Litres = New List(Of Single?) - AA_AveragePowerDemandCrankHVACMechanicals = New List(Of Single?) - AA_AveragePowerDemandCrankHVACElectricals = New List(Of Single?) - AA_AveragePowerDemandCrankElectrics = New List(Of Single?) - AA_AveragePowerDemandCrankPneumatics = New List(Of Single?) - AA_TotalCycleFuelConsumptionCompressorOff = New List(Of Single?) - AA_TotalCycleFuelConsumptionCompressorOn = New List(Of Single?) - - 'TODO REMOVE WHEN TESTING COMPLETE - 'AA_D_M12_P1X = new List(Of single ) - 'AA_D_M12_P1Y = new List(Of single ) - 'AA_D_M12_P2X = new List(Of single ) - 'AA_D_M12_P2Y = new List(Of single ) - 'AA_D_M12_P3X = new List(Of single ) - 'AA_D_M12_P3Y = new List(Of single ) - 'AA_D_M12_XTAIN = new List(Of single ) - 'AA_D_M12_INTERP1 = new List(Of single ) - 'AA_D_M12_INTERP2 = new List(Of single ) - - '************************************************************************* - - Proll = New List(Of Single) - Psum = New List(Of Single) - Pstg = New List(Of Single) - Pbrake = New List(Of Single) - Pair = New List(Of Single) - Pa = New List(Of Single) - PauxSum = New List(Of Single) - PlossGB = New List(Of Single) - PlossDiff = New List(Of Single) - PlossRt = New List(Of Single) - PlossTC = New List(Of Single) - PaEng = New List(Of Single) - PaGB = New List(Of Single) - Paux = New Dictionary(Of String, List(Of Single)) - Pclutch = New List(Of Single) - Grad = New List(Of Single) - - EngState = New List(Of tEngState) - - Gear = New List(Of Single) - VehState = New List(Of tVehState) - - TCnu = New List(Of Single) - TCmu = New List(Of Single) - TCMout = New List(Of Single) - TCnOut = New List(Of Single) - - lFC = New List(Of Single) - lFCAUXc = New List(Of Single) - lFCWHTCc = New List(Of Single) - FCAUXcSet = False - - FCerror = False - - - Vh.Init() - ModErrors = New cModErrors - - - bInit = True - End Sub - - Public Sub CleanUp() - If bInit Then - lFC = Nothing - lFCAUXc = Nothing - lFCWHTCc = Nothing - - Vh.CleanUp() - Px = Nothing - Vh = Nothing - Pe = Nothing - nU = Nothing - - Proll = Nothing - Psum = Nothing - Pstg = Nothing - Pair = Nothing - Pa = Nothing - Pbrake = Nothing - PauxSum = Nothing - PlossGB = Nothing - PlossDiff = Nothing - PlossRt = Nothing - PlossTC = Nothing - PaEng = Nothing - PaGB = Nothing - Paux = Nothing - Pclutch = Nothing - Grad = Nothing - - EngState = Nothing - - Gear = Nothing - VehState = Nothing - - TCnu = Nothing - TCmu = Nothing - TCMout = Nothing - TCnOut = Nothing - - CylceKin = Nothing - ModErrors = Nothing - bInit = False - End If - End Sub - - Public Sub Duplicate(ByVal t As Integer) - Dim AuxKV As KeyValuePair(Of String, List(Of Single)) - - If DRI.Nvorg Then - nUvorg.Insert(t, nUvorg(t)) - End If - - If DRI.AuxDef Then - For Each AuxKV In DRI.AuxComponents - AuxKV.Value.Insert(t, AuxKV.Value(t)) - Next - End If - End Sub - - Public Sub Cut(ByVal t As Integer) - Dim AuxKV As KeyValuePair(Of String, List(Of Single)) - - If DRI.Nvorg Then - nUvorg.RemoveAt(t) - End If - - If DRI.AuxDef Then - For Each AuxKV In DRI.AuxComponents - AuxKV.Value.RemoveAt(t) - Next - End If - End Sub - - - Public Sub CycleInit() - - If VEC.EngOnly Then - EngCycleInit() - Else - VehCycleInit() - End If - - tDimOgl = tDim - End Sub - - Private Sub VehCycleInit() - Dim s As Integer - Dim L As List(Of Double) - Dim AuxKV As KeyValuePair(Of String, List(Of Single)) - Dim st As String - - 'Define Cycle-length (shorter by 1sec than original because of Interim-seconds) - tDim = DRI.tDim - 1 - - 'Here the actual cycle is read: - Vh.VehCylceInit() - - 'Revolutions-setting - If DRI.Nvorg Then - - MODdata.nUvorg = New List(Of Single) - - L = DRI.Values(tDriComp.nU) - - 'Revolutions - For s = 0 To tDim - MODdata.nUvorg.Add(((L(s + 1) + L(s)) / 2)) - Next - - End If - - 'Specify average Aux and Aux-lists, when Aux present in DRI and VEH - If Cfg.DeclMode Then - - For Each st In VEC.AuxPaths.Keys - MODdata.Paux.Add(st, New List(Of Single)) - Next - - Else - - If DRI.AuxDef Then - For Each AuxKV In DRI.AuxComponents - - For s = 0 To tDim - AuxKV.Value(s) = (AuxKV.Value(s + 1) + AuxKV.Value(s)) / 2 - Next - - If VEC.AuxPaths.ContainsKey(AuxKV.Key) Then MODdata.Paux.Add(AuxKV.Key, New List(Of Single)) - - Next - End If - - End If - End Sub - - Private Sub EngCycleInit() - Dim s As Integer - Dim L As List(Of Double) - - 'Zykluslänge definieren: Gleiche Länge wie Zyklus (nicht reduziert weil keine "Zwischensekunden") |@@| Define Cycle-length: Same length as Cycle (not reduced because no "interim seconds") - tDim = DRI.tDim - - Vh.EngCylceInit() - - 'Revolutions-setting - If DRI.Nvorg Then - - MODdata.nUvorg = New List(Of Single) - - L = DRI.Values(tDriComp.nU) - - 'Revolutions - For s = 0 To MODdata.tDim - MODdata.nUvorg.Add(L(s)) - Next - - End If - End Sub - - - Public Sub FCcalc(ByVal WHTCcorrection As Boolean) - Dim v As Single - Dim i As Integer - Dim Result As Boolean - Dim x As Single - Dim sum As Double - Dim LostEnergy As Double - Dim EngOnTime As Integer - Dim AddEngLoad As Single - Dim info As cRegression.RegressionProcessInfo - Dim reg As cRegression - Dim rx As List(Of Double) - Dim ry As List(Of Double) - Dim rR2 As Single - Dim rA As Double - Dim rB As Double - Dim rSE As Double - Dim PeAdd As Double - - Dim MsgSrc As String - - MsgSrc = "MAP/FC_Intp" - - FCerror = False - Result = True - LostEnergy = 0 - EngOnTime = 0 - rx = New List(Of Double) - ry = New List(Of Double) - - For i = 0 To MODdata.tDim - - Select Case MODdata.EngState(i) - - Case tEngState.Stopped - - lFC.Add(0) - LostEnergy += MODdata.PauxSum(i) / 3600 - - Case Else '<= Idle / Drag / FullLoad-Unterscheidung...? - - - 'Delaunay - v = MAP.fFCdelaunay_Intp(MODdata.nU(i), nPeToM(MODdata.nU(i), MODdata.Pe(i))) - - If v < 0 And v > -999 Then v = 0 - - If Result Then - If v < -999 Then Result = False - End If - lFC.Add(v) - - EngOnTime += 1 - rx.Add(MODdata.Pe(i)) - ry.Add(v) - - End Select - - Next - - 'Calc average FC - sum = 0 - For Each x In lFC - sum += x - Next - FCavg = CSng(sum / lFC.Count) - FCavgFinal = FCavg - - 'Start/Stop-Aux - Correction - If Result AndAlso LostEnergy > 0 Then - - WorkerMsg(tMsgID.Normal, "Correcting FC due to wrong aux energy balance during engine stop times", MsgSrc) - WorkerMsg(tMsgID.Normal, " > Error in aux energy balance: " & LostEnergy.ToString("0.000") & " [kWh]", MsgSrc) - - If EngOnTime < 1 Then - WorkerMsg(tMsgID.Err, " > ERROR: Engine-On Time = 0!", MsgSrc) - FCerror = True - Exit Sub - End If - - 'Linear regression of FC=f(Pe) - reg = New cRegression - - info = reg.Regress(rx.ToArray, ry.ToArray) - rR2 = info.PearsonsR ^ 2 - rA = info.a - rB = info.b - rSE = info.StandardError - - If rB <= 0 Then - WorkerMsg(tMsgID.Err, " > ERROR in linear regression ( b=" & rB & ")!", MsgSrc) - FCerror = True - Exit Sub - End If - - 'Additional engine load due to lost Aux energy: [kW] = [kWh]/[h] - AddEngLoad = LostEnergy / (EngOnTime / 3600) - - WorkerMsg(tMsgID.Normal, " > Additional engine load: " & AddEngLoad.ToString("0.000") & " [kW]", MsgSrc) - - For i = 0 To MODdata.tDim - lFCAUXc.Add(lFC(i)) - If MODdata.EngState(i) <> tEngState.Stopped Then - PeAdd = AddEngLoad + MODdata.Pbrake(i) - If PeAdd > 0 Then - lFCAUXc(i) += rB * PeAdd - End If - End If - Next - - 'average - sum = 0 - For Each x In lFCAUXc - sum += x - Next - FCavgAUXc = CSng(sum / lFC.Count) - - FCAUXcSet = True - - FCavgFinal = FCavgAUXc - - - End If - - 'WHTC Correction - If Cfg.DeclMode Then - - If FCAUXcSet Then - For i = 0 To MODdata.tDim - lFCWHTCc.Add(lFCAUXc(i) * Declaration.WHTCcorrFactor) - Next - Else - For i = 0 To MODdata.tDim - lFCWHTCc.Add(lFC(i) * Declaration.WHTCcorrFactor) - Next - End If - - sum = 0 - For Each x In lFCWHTCc - sum += x - Next - FCavgWHTCc = CSng(sum / lFC.Count) - - FCavgFinal = FCavgWHTCc - - End If - - If Not Result Then FCerror = True - End Sub - - - Public Function Output() As Boolean - - Dim f As cFile_V3 - Dim s As System.Text.StringBuilder - Dim su As System.Text.StringBuilder - Dim t As Integer - Dim t1 As Integer - - Dim Sepp As String - Dim path As String - Dim dist As Double - Dim MsgSrc As String - Dim tdelta As Single - - Dim StrKey As String - - Dim AuxList As New List(Of String) - - Dim HeaderList As New List(Of String()) - - Dim Gear As Integer - - MsgSrc = "MOD/Output" - - '*********** Initialization / Open File ************** - If ModOutpName = "" Then - WorkerMsg(tMsgID.Err, "Invalid output path!", MsgSrc) - Return False - End If - - f = New cFile_V3 - - path = ModOutpName & ".vmod" - - If Not f.OpenWrite(path, ",", False) Then - WorkerMsg(tMsgID.Err, "Can't write to " & path, MsgSrc) - Return False - End If - - s = New System.Text.StringBuilder - - '*********** Settings ************** - Sepp = "," - t1 = MODdata.tDim - If VEC.EngOnly Then - tdelta = 0 - Else - tdelta = 0.5 - End If - - - '********** Aux-List ************ - For Each StrKey In VEC.AuxRefs.Keys 'Wenn Engine Only dann wird das garnicht verwendet - AuxList.Add(StrKey) - Next - - - If DEV.AdvFormat Then - f.WriteLine("VECTO " & VECTOvers) - f.WriteLine(Now.ToUniversalTime().ToString("o")) - f.WriteLine("Input File: " & JobFile) - End If - - - '*********************************************************************************************** - '*********************************************************************************************** - '*********************************************************************************************** - '*** Header & Units **************************************************************************** - - s.Length = 0 - - - HeaderList.Add(New String() {"time", "s"}) - - If Not VEC.EngOnly Then - HeaderList.Add(New String() {"dist", "m"}) - HeaderList.Add(New String() {"v_act", "km/h"}) - HeaderList.Add(New String() {"v_targ", "km/h"}) - HeaderList.Add(New String() {"acc", "m/s²"}) - HeaderList.Add(New String() {"grad", "%"}) - dist = 0 - End If - - HeaderList.Add(New String() {"n", "1/min"}) - HeaderList.Add(New String() {"Tq_eng", "Nm"}) - HeaderList.Add(New String() {"Tq_clutch", "Nm"}) - HeaderList.Add(New String() {"Tq_full", "Nm"}) - HeaderList.Add(New String() {"Tq_drag", "Nm"}) - HeaderList.Add(New String() {"P_eng_out", "kW"}) - HeaderList.Add(New String() {"Pe_full", "kW"}) - HeaderList.Add(New String() {"Pe_drag", "kW"}) - HeaderList.Add(New String() {"P_clutch_out", "kW"}) - HeaderList.Add(New String() {"Pa Eng", "kW"}) - HeaderList.Add(New String() {"Paux", "kW"}) - - If Not VEC.EngOnly Then - - HeaderList.Add(New String() {"Gear", "-"}) - HeaderList.Add(New String() {"Ploss GB", "kW"}) - HeaderList.Add(New String() {"Ploss Diff", "kW"}) - HeaderList.Add(New String() {"Ploss Retarder", "kW"}) - HeaderList.Add(New String() {"Pa GB", "kW"}) - HeaderList.Add(New String() {"Pa Veh", "kW"}) - HeaderList.Add(New String() {"Proll", "kW"}) - HeaderList.Add(New String() {"Pair", "kW"}) - HeaderList.Add(New String() {"Pgrad", "kW"}) - HeaderList.Add(New String() {"Pwheel", "kW"}) - HeaderList.Add(New String() {"Pbrake", "kW"}) - - If GBX.TCon Then - HeaderList.Add(New String() {"TCν", "-"}) - HeaderList.Add(New String() {"TCµ", "-"}) - HeaderList.Add(New String() {"TC_T_Out", "Nm"}) - HeaderList.Add(New String() {"TC_n_Out", "1/min"}) - End If - - 'Auxiliaries - For Each StrKey In AuxList - HeaderList.Add(New String() {"Paux_" & StrKey, "kW"}) - Next - - 'AA-TB - 'Advanced Auxiliaries - HeaderList.Add(New String() {"AA_NonSmartAlternatorsEfficiency", "Fraction"}) - HeaderList.Add(New String() {"AA_SmartIdleCurrent_Amps", "Amps"}) - HeaderList.Add(New String() {"AA_SmartIdleAlternatorsEfficiency", "Fraction"}) - HeaderList.Add(New String() {"AA_SmartTractionCurrent_Amps", "Amps"}) - HeaderList.Add(New String() {"AA_SmartTractionAlternatorEfficiency", "Fraction"}) - HeaderList.Add(New String() {"AA_SmartOverrunCurrent_Amps", "Amps"}) - HeaderList.Add(New String() {"AA_SmartOverrunAlternatorEfficiency", "Fraction"}) - HeaderList.Add(New String() {"AA_CompressorFlowRate_LitrePerSec", "Ni L/S"}) - HeaderList.Add(New String() {"AA_OverrunFlag", "Integer 0/1"}) - HeaderList.Add(New String() {"AA_EngineIdleFlag", "Integer 0/1"}) - HeaderList.Add(New String() {"AA_CompressorFlag", "Integer 0/1"}) - HeaderList.Add(New String() {"AA_TotalCycleFC_Grams", ""}) - HeaderList.Add(New String() {"AA_TotalCycleFC_Litres", ""}) - HeaderList.Add(New String() {"AA_AveragePowerDemandCrankHVACMechanicals", ""}) - HeaderList.Add(New String() {"AA_AveragePowerDemandCrankHVACElectricals", ""}) - HeaderList.Add(New String() {"AA_AveragePowerDemandCrankElectrics", ""}) - HeaderList.Add(New String() {"AA_AveragePowerDemandCrankPneumatics", ""}) - HeaderList.Add(New String() {"AA_TotalCycleFuelConsumptionCompressorOff", ""}) - HeaderList.Add(New String() {"AA_TotalCycleFuelConsumptionCompressorOn", ""}) - - 'TODO: - 'DIAGNOSTICS REMOVE WHEN TESTED - 's.Append(",AA_D_M12_P1X [Single]") - 's.Append(",AA_D_M12_P1Y [Single]") - 's.Append(",AA_D_M12_P2X [Single]") - 's.Append(",AA_D_M12_P2Y [Single]") - 's.Append(",AA_D_M12_P3X [Single]") - 's.Append(",AA_D_M12_P3Y [Single]") - 's.Append(",AA_D_M12_XTAIN [Single]") - 's.Append(",AA_D_M12_INTERP1 [Single]") - 's.Append(",AA_D_M12_INTERP2 [Single]") - - - End If - - HeaderList.Add(New String() {"FC-Map", "g/h"}) - HeaderList.Add(New String() {"FC-AUXc", "g/h"}) - HeaderList.Add(New String() {"FC-WHTCc", "g/h"}) - - - 'Write to File - If DEV.AdvFormat Then - su = New System.Text.StringBuilder - s.Append(HeaderList(0)(0)) - su.Append("[" & HeaderList(0)(1) & "]") - For t = 1 To HeaderList.Count - 1 - s.Append(Sepp & HeaderList(t)(0)) - su.Append(Sepp & "[" & HeaderList(t)(1) & "]") - Next - f.WriteLine(s.ToString) - f.WriteLine(su.ToString) - Else - s.Append(HeaderList(0)(0) & " [" & HeaderList(0)(1) & "]") - For t = 1 To HeaderList.Count - 1 - s.Append(Sepp & HeaderList(t)(0) & " [" & HeaderList(t)(1) & "]") - Next - f.WriteLine(s.ToString) - End If - - - '*********************************************************************************************** - '*********************************************************************************************** - '*********************************************************************************************** - '*** Values ************************************************************************************* - - With MODdata - - For t = 0 To t1 - - 'Predefine Gear for FLD assignment - If VEC.EngOnly Then - Gear = 0 - Else - Gear = .Gear(t) - End If - - - s.Length = 0 - - 'Time - s.Append(t + DRI.t0 + tdelta) - - If Not VEC.EngOnly Then - - If DRI.Vvorg Then - - 'distance - dist += .Vh.V(t) - s.Append(Sepp & dist) - - 'Actual-speed. - s.Append(Sepp & .Vh.V(t) * 3.6) - - 'Target-speed - s.Append(Sepp & .Vh.Vsoll(t) * 3.6) - - 'Acc. - s.Append(Sepp & .Vh.a(t)) - - Else - - 'distance - s.Append(Sepp & "-") - - 'Actual-speed. - s.Append(Sepp & "-") - - 'Target-speed - s.Append(Sepp & "-") - - 'Acc. - s.Append(Sepp & "-") - - End If - - - 'Slope - s.Append(Sepp & .Grad(t)) - - End If - - 'Revolutions - s.Append(Sepp & .nU(t)) - - If Math.Abs(2 * Math.PI * .nU(t) / 60) < 0.00001 Then - s.Append(Sepp & "0" & Sepp & "0" & Sepp & "0" & Sepp & "0") - Else - - 'Torque - s.Append(Sepp & nPeToM(.nU(t), .Pe(t))) - - 'Torque at clutch - s.Append(Sepp & nPeToM(.nU(t), .Pclutch(t))) - - 'Full-load and Drag torque - If .EngState(t) = tEngState.Stopped Then - s.Append(Sepp & "0" & Sepp & "0") - Else - If Not VEC.EngOnly Then - If t = 0 Then - s.Append(Sepp & nPeToM(.nU(t), GBX.FLD(Gear).Pfull(.nU(t))) & Sepp & nPeToM(.nU(t), ENG.FLD.Pdrag(.nU(t)))) - Else - s.Append( - Sepp & nPeToM(.nU(t), GBX.FLD(Gear).Pfull(.nU(t), .Pe(t - 1))) & Sepp & nPeToM(.nU(t), ENG.FLD.Pdrag(.nU(t)))) - End If - Else - If t = 0 Then - s.Append(Sepp & nPeToM(.nU(t), ENG.FLD.Pfull(.nU(t))) & Sepp & nPeToM(.nU(t), ENG.FLD.Pdrag(.nU(t)))) - Else - s.Append( - Sepp & nPeToM(.nU(t), ENG.FLD.Pfull(.nU(t), .Pe(t - 1))) & Sepp & nPeToM(.nU(t), ENG.FLD.Pdrag(.nU(t)))) - End If - End If - End If - - End If - - 'Power - s.Append(Sepp & .Pe(t)) - - 'Revolutions normalized - 's.Append(Sepp & .nn(t)) - - 'Power normalized - 's.Append(Sepp & .Pe(t)) - - 'Full-load and Drag - If .EngState(t) = tEngState.Stopped Then - s.Append(Sepp & "-" & Sepp & "-") - Else - If Not VEC.EngOnly Then - If t = 0 Then - s.Append(Sepp & GBX.FLD(Gear).Pfull(.nU(t)) & Sepp & ENG.FLD.Pdrag(.nU(t))) - Else - s.Append(Sepp & GBX.FLD(Gear).Pfull(.nU(t), .Pe(t - 1)) & Sepp & ENG.FLD.Pdrag(.nU(t))) - End If - Else - If t = 0 Then - s.Append(Sepp & ENG.FLD.Pfull(.nU(t)) & Sepp & ENG.FLD.Pdrag(.nU(t))) - Else - s.Append(Sepp & ENG.FLD.Pfull(.nU(t), .Pe(t - 1)) & Sepp & ENG.FLD.Pdrag(.nU(t))) - End If - End If - End If - - 'Power at Clutch - s.Append(Sepp & .Pclutch(t)) - - 'PaEng - s.Append(Sepp & .PaEng(t)) - - 'Aux.. - s.Append(Sepp & .PauxSum(t)) - - - If Not VEC.EngOnly Then - - 'Gear - s.Append(Sepp & .Gear(t)) - - 'Transmission-losses - s.Append(Sepp & .PlossGB(t)) - - 'Diff-losses - s.Append(Sepp & .PlossDiff(t)) - - 'Retarder-losses - s.Append(Sepp & .PlossRt(t)) - - 'PaGB - s.Append(Sepp & .PaGB(t)) - - 'Pa Veh - s.Append(Sepp & .Pa(t)) - - 'Roll.. - s.Append(Sepp & .Proll(t)) - - 'Drag - s.Append(Sepp & .Pair(t)) - - 'Slope .. - s.Append(Sepp & .Pstg(t)) - - 'Wheel-power - s.Append(Sepp & .Psum(t)) - - 'Brake - s.Append(Sepp & .Pbrake(t)) - - 'Torque Converter output - If GBX.TCon Then s.Append(Sepp & .TCnu(t) & Sepp & .TCmu(t) & Sepp & .TCMout(t) & Sepp & .TCnOut(t)) - - 'Auxiliaries - For Each StrKey In AuxList - s.Append(Sepp & .Paux(StrKey)(t)) - Next - - 'AA-TB - 'Advanced Auxiliaries - s.Append( - Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_NonSmartAlternatorsEfficiency(t).ToString(), "")) - s.Append(Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_SmartIdleCurrent_Amps(t).ToString(), "")) - s.Append( - Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_SmartIdleAlternatorsEfficiency(t).ToString(), "")) - s.Append(Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_SmartTractionCurrent_Amps(t).ToString(), "")) - s.Append( - Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_SmartTractionAlternatorEfficiency(t).ToString(), "")) - s.Append(Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_SmartOverrunCurrent_Amps(t).ToString(), "")) - s.Append( - Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_SmartOverrunAlternatorEfficiency(t).ToString(), "")) - s.Append( - Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_CompressorFlowRate_LitrePerSec(t).ToString(), "")) - s.Append(Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_OverrunFlag(t).ToString(), "")) - s.Append(Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_EngineIdleFlag(t).ToString(), "")) - s.Append(Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_CompressorFlag(t).ToString(), "")) - s.Append(Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_TotalCycleFC_Grams(t).ToString(), "")) - s.Append(Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_TotalCycleFC_Litres(t).ToString(), "")) - s.Append( - Sepp & - If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_AveragePowerDemandCrankHVACMechanicals(t).ToString(), "")) - s.Append( - Sepp & - If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_AveragePowerDemandCrankHVACElectricals(t).ToString(), "")) - s.Append( - Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_AveragePowerDemandCrankElectrics(t).ToString(), "")) - s.Append( - Sepp & If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_AveragePowerDemandCrankPneumatics(t).ToString(), "")) - s.Append( - Sepp & - If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_TotalCycleFuelConsumptionCompressorOff(t).ToString(), "")) - s.Append( - Sepp & - If(VECTO_Global.VEC.AuxiliaryAssembly <> "CLASSIC", AA_TotalCycleFuelConsumptionCompressorOn(t).ToString(), "")) - - 'TODO:REMOVE WHEN TESTED - 'DIAGNOSTICS - 's.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC", AA_D_M12_P1X (t).toString(),"")) - 's.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC", AA_D_M12_P1Y (t).toString(),"")) - 's.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC", AA_D_M12_P2X (t).toString(),"")) - 's.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC", AA_D_M12_P2Y (t).toString(),"")) - 's.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC", AA_D_M12_P3X (t).toString(),"")) - 's.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC", AA_D_M12_P3Y (t).toString(),"")) - 's.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC", AA_D_M12_XTAIN (t).toString(),"")) - 's.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC", AA_D_M12_INTERP1 (t).toString(),"")) - 's.Append(Sepp & if(vecto_global.VEC.AuxiliaryAssembly<>"CLASSIC", AA_D_M12_INTERP2 (t).toString(),"")) - - - End If - - 'FC - If .lFC(t) > -0.0001 Then - s.Append(Sepp & .lFC(t)) - Else - s.Append(Sepp & "ERROR") - End If - - If FCAUXcSet Then - If .lFCAUXc(t) > -0.0001 Then - s.Append(Sepp & .lFCAUXc(t)) - Else - s.Append(Sepp & "ERROR") - End If - Else - s.Append(Sepp & "-") - End If - - - If Cfg.DeclMode Then - If .lFCWHTCc(t) > -0.0001 Then - s.Append(Sepp & .lFCWHTCc(t)) - Else - s.Append(Sepp & "ERROR") - End If - Else - s.Append(Sepp & "-") - End If - - 'Write to File - f.WriteLine(s.ToString) - - Next - - End With - - f.Close() - - 'Add file to signing list - Lic.FileSigning.AddFile(path) - - Return True - End Function - - 'Errors/Warnings die sekündlich auftreten können |@@| Errors/Warnings occuring every second - Public Class cModErrors - Public TrLossMapExtr As String - Public AuxMapExtr As String - Public AuxNegative As String - Public FLDextrapol As String - Public CdExtrapol As String - Public RtExtrapol As String - Public DesMaxExtr As String - Public TCextrapol As String - - Public Sub New() - ResetAll() - End Sub - - - 'Reset-Hierarchie: - ' ResetAll - ' DesMaxExtr - ' -GeschRedReset(Speed-Reduce-Reset) - ' CdExtrapol - ' -PxReset - ' TrLossMapExtr - ' AuxMapExtr - ' AuxNegative - ' FLDextrapol - - 'Full reset (at the beginning of each second step) - Public Sub ResetAll() - DesMaxExtr = "" - GeschRedReset() - End Sub - - 'Reset Errors related to Speed Reduction (within iteration) - Public Sub GeschRedReset() - CdExtrapol = "" - RtExtrapol = "" - TCextrapol = "" - PxReset() - End Sub - - 'Reset von Errors die mit der Leistungsberechnung zu tun haben (nach Schaltmodell durchzuführen) |@@| Reset errors related to Power-calculation (towards performing the Gear-shifting model) - Public Sub PxReset() - TrLossMapExtr = "" - AuxMapExtr = "" - AuxNegative = "" - FLDextrapol = "" - End Sub - - 'Emit Errors - Public Function MsgOutputAbort(ByVal Second As String, ByVal MsgSrc As String) As Boolean - Dim Abort As Boolean - - Abort = False - - If TrLossMapExtr <> "" Then - If Cfg.DeclMode Then - WorkerMsg(tMsgID.Err, "Extrapolation of Transmission Loss Map (" & TrLossMapExtr & ")!", MsgSrc & "/t= " & Second) - Else - WorkerMsg(tMsgID.Warn, "Extrapolation of Transmission Loss Map (" & TrLossMapExtr & ")!", MsgSrc & "/t= " & Second) - End If - End If - - If AuxMapExtr <> "" Then - WorkerMsg(tMsgID.Err, "Invalid extrapolation in Auxiliary Map (" & AuxMapExtr & ")!", MsgSrc & "/t= " & Second) - End If - - If AuxNegative <> "" Then - WorkerMsg(tMsgID.Err, "Aux power < 0 (" & AuxNegative & ") Check cycle and aux efficiency map!", - MsgSrc & "/t= " & Second) - Abort = True - End If - - If FLDextrapol <> "" Then - WorkerMsg(tMsgID.Warn, "Extrapolation of Full load / drag curve (" & FLDextrapol & ")!", MsgSrc & "/t= " & Second) - End If - - If CdExtrapol <> "" Then - WorkerMsg(tMsgID.Warn, "Extrapolation in Cd input file (" & CdExtrapol & ")!", MsgSrc & "/t= " & Second) - End If - - If DesMaxExtr <> "" Then - WorkerMsg(tMsgID.Warn, "Extrapolation in .vacc input file (" & DesMaxExtr & ")!", MsgSrc & "/t= " & Second) - End If - - If RtExtrapol <> "" Then - WorkerMsg(tMsgID.Warn, "Extrapolation in Retarder input file (" & RtExtrapol & ")!", MsgSrc & "/t= " & Second) - End If - - If TCextrapol <> "" Then - WorkerMsg(tMsgID.Warn, "Extrapolation in Torque Converter file (" & TCextrapol & ")!", MsgSrc & "/t= " & Second) - End If - - Return Abort - End Function - End Class -End Class - - diff --git a/VECTO/MODcalc/cPower.vb b/VECTO/MODcalc/cPower.vb deleted file mode 100644 index ee712ba7ffbc03a5dc87c0538d8df11d2c2d5a42..0000000000000000000000000000000000000000 --- a/VECTO/MODcalc/cPower.vb +++ /dev/null @@ -1,2857 +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 cPower - Private ClutchNorm As Single 'Normalized clutch speed - Private ClutchEta As Single 'clutch efficiency - - 'Settings - Private GearInput As Boolean - Private RpmInput As Boolean - - - 'Per-second Data - Private Clutch As tEngClutch - Private VehState0 As tVehState - Private EngState0 As tEngState - Private Pplus As Boolean - Private Pminus As Boolean - Private GVmax As Single - Private Pwheel As Single - Private Vact As Single - Private aact As Single - - 'Interruption of traction - Private TracIntrI As Integer - Private TracIntrIx As Integer - Private TracIntrOn As Boolean - Private TracIntrTurnOff As Boolean - Private TracIntrGear As Integer - - Private LastGearChange As Integer - Private LastClutch As tEngClutch - - Public Positions As New List(Of Short) - - Private EngSideInertia As Single - - Private PwheelVorg As Boolean - - - Public Function PreRun() As Boolean - Dim i As Integer - Dim i0 As Integer - Dim Vh As cVh - Dim P As Single - Dim Pmin As Single - Dim PlossGB As Single - Dim PlossDiff As Single - Dim PlossRt As Single - Dim PaMot As Single - Dim PaGetr As Single - Dim Pkup As Single - Dim Paux As Single - Dim Gear As Integer - Dim nU As Single - Dim vCoasting As Single - Dim Vmax As Single - Dim Vmin As Single - Dim Tlookahead As Integer - Dim vset1 As Single - Dim vset2 As Single - Dim j As Integer - Dim t As Integer - Dim adec As Single - Dim LookAheadDone As Boolean - Dim aCoasting As Single - Dim Gears As New List(Of Integer) - Dim vRollout As Single - Dim ProgBarShare As Int16 - Dim ProgBarLACpart As Int16 - Dim dist As New List(Of Double) - Dim LastnU As Single = 0 - - 'AA-TB - '************************************************************************* - 'Informs Power Calculation to aggregate fuel or not if in Advanced mode. - mAAUX_Global.RunningCalc = False - 'Cycle Time in Seconds, set this in AAUX_GLOBAL. - mAAUX_Global.CycleTimeInSeconds = MODdata.tDim - '************************************************************************* - - Dim MsgSrc As String - MsgSrc = "Power/PreRun" - - - 'AA-TB - 'Try and Initialise the Advanced Aux Model if selected. - If VEC.AuxiliaryAssembly <> "CLASSIC" Then - WorkerMsg(tMsgID.Normal, "Initialising Advanced Auxiliaries Model", MsgSrc) - If mAAUX_Global.InitialiseAdvancedAuxModel(VEC.AdvancedAuxiliaryFilePath) Then - 'Setting Mode / WHTC for fueling in model. - mAAUX_Global.advancedAuxModel.Signals.DeclarationMode = Cfg.DeclMode - mAAUX_Global.advancedAuxModel.Signals.WHTC = Declaration.WHTCcorrFactor - WorkerMsg(tMsgID.Normal, "Successfully Initialised Advanced Auxiliaries", MsgSrc) - Else - WorkerMsg(tMsgID.Err, "FAILED to Initialised Advanced Auxiliaries", MsgSrc) - Return False - End If - End If - - - 'Check Input - If VEC.LookAheadOn AndAlso VEC.ALookahead >= 0 Then - WorkerMsg(tMsgID.Err, "Lookahead deceleration invalid! Value must be below zero.", MsgSrc) - Return False - End If - - If VEC.OverSpeedOn And VEC.EcoRollOn Then - WorkerMsg(tMsgID.Err, "Overrun and Ecoroll can't be enabled both at the same time!", MsgSrc) - Return False - End If - - ' Initialize - Vh = MODdata.Vh - GearInput = DRI.Gvorg - RpmInput = DRI.Nvorg - - If VEC.EcoRollOn Or VEC.OverSpeedOn Then - If VEC.LookAheadOn Then - ProgBarShare = 4 - ProgBarLACpart = 2 - Else - ProgBarShare = 2 - ProgBarLACpart = 0 '0=OFF - End If - Else - If VEC.LookAheadOn Then - ProgBarShare = 2 - ProgBarLACpart = 1 - Else - ProgBarShare = 0 - ProgBarLACpart = 0 '0=OFF - End If - End If - - Positions = New List(Of Short) - - If GBX.TCon Then - EngSideInertia = ENG.I_mot + GBX.TCinertia - Else - EngSideInertia = ENG.I_mot - End If - - 'Distance over time - dist.Add(0) - For i = 1 To MODdata.tDim - dist.Add(dist(i - 1) + Vh.V(i)) - Next - - - 'Generate Positions List - For i = 0 To MODdata.tDim - Positions.Add(0) - Next - - '*** Positions *** - '0... Normal (Cruise/Acc) - '1... Brake or Coasting - '2... Brake corrected with v(a) (.vacc file) - '3... Coasting - '4... Eco-Roll - - 'Overspeed / Eco-Roll Loop (Forward) - i = -1 - Do - i += 1 - - 'Check if cancellation pending - If VECTOworker.CancellationPending Then Return True - - Vact = Vh.V(i) - aact = Vh.a(i) - - 'Determine Driving-state ------------------------- - Pplus = False - Pminus = False - - If Vact < 0.0001 Then - VehState0 = tVehState.Stopped - Else - If aact >= 0.01 Then - VehState0 = tVehState.Acc - ElseIf aact < -0.01 Then - VehState0 = tVehState.Dec - Else - VehState0 = tVehState.Cruise - End If - End If - - - 'Wheel-Power - Pwheel = fPwheel(i, Vh.fGrad(dist(i))) - - Select Case Pwheel - Case Is > 0.0001 - Pplus = True - Case Is < -0.0001 - Pminus = True - Case Else - P = 0 - End Select - - 'Gear - If VehState0 = tVehState.Stopped Then - Gear = 0 - - 'Engine Speed - If RpmInput Then - nU = MODdata.nUvorg(i) - Else - nU = ENG.Nidle - End If - - Else - - If GearInput Then - Gear = Math.Min(Vh.GearVorg(i), GBX.GearCount) - Else - Gear = fFastGearCalc(Vact, Pwheel) - End If - - 'Engine Speed - If RpmInput Then - nU = MODdata.nUvorg(i) - Else - nU = fnU(Vact, Gear, False) - End If - - End If - - 'ICE-inertia - If i = 0 Then - PaMot = 0 - Else - PaMot = fPaMot(nU, LastnU) - End If - - 'AA-TB - ( RAFAEL ) - '********************* ADVANCED AUXILIARIES START ***************************** - - 'Dim ClutchEngaged As Boolean - 'Dim EngineDrivelinePower As Single - 'Dim EngineDrivelineTorque As Single - 'Dim EngineMotoringPower As Single - 'Dim EngineSpeed As Integer - 'Dim PreExistingAuxPower As Single - 'Dim Idle As Boolean - 'Dim InNeutral As Boolean - - - 'Calculate powertrain losses => power at clutch - If Pplus Or Pminus Then - PlossGB = fPlossGB(Pwheel, Vact, Gear, True) - PlossDiff = fPlossDiff(Pwheel, Vact, True) - PlossRt = fPlossRt(Vact, Gear) - PaGetr = fPaG(Vact, aact) - Pkup = Pwheel + PlossGB + PlossDiff + PaGetr + PlossRt - Else - Pkup = 0 - End If - - 'Clutch closed/engaged = True - mAAUX_Global.ClutchEngaged = (Gear > 0) - - mAAUX_Global.Idle = (Gear = 0 And Not Pplus And Not Pminus) - - mAAUX_Global.InNeutral = (Gear = 0) - - 'Driveline Power = required power at clutch = power at wheels plus powertrain losses - '[kW] - mAAUX_Global.EngineDrivelinePower = Pkup - - '[1/min] - mAAUX_Global.EngineSpeed = nU - - '[Nm] (using Power => Torque conversion) - mAAUX_Global.EngineDrivelineTorque = nPeToM(EngineSpeed, EngineDrivelinePower) - - 'Motoring power (< 0 !!!) - '[kW] - '*** NOTE THIS IS MULTIPLIED BY - to get a positive value - mAAUX_Global.EngineMotoringPower = -GBX.FLD(Gear).Pdrag(EngineSpeed) - - 'Additional aux power from driving cycle (optional user input) - '[kW] - mAAUX_Global.PreExistingAuxPower = MODdata.Vh.Padd(t) - - 'Total aux power - '[kW] - Paux = fPaux(t, EngineSpeed) - - 'Internal Engine Power (Pclutch plus Aux plus Inertia) - P = Pkup + Paux + PaMot - - 'AA-TB/RL************** ADVANCED AUXILIARIES END *************************** - - 'AA-TB REMOVED - ' Paux = fPaux(i, nU) - - 'Calculate powertrain losses => power at clutch - If Pplus Or Pminus Then - PlossGB = fPlossGB(Pwheel, Vact, Gear, True) - PlossDiff = fPlossDiff(Pwheel, Vact, True) - PlossRt = fPlossRt(Vact, Gear) - PaGetr = fPaG(Vact, aact) - Pkup = Pwheel + PlossGB + PlossDiff + PaGetr + PlossRt - Else - Pkup = 0 - End If - - 'Total aux power - '[kW] - Paux = fPaux(i, nU) - - 'Internal Engine Power (Pclutch plus Aux plus Inertia) - P = Pkup + Paux + PaMot - - - 'Full load / motoring - Pmin = ENG.FLD.Pdrag(nU) - - If Vact >= VEC.vMin / 3.6 Then - - If VEC.EcoRollOn Then - - 'Secondary Progressbar - ProgBarCtrl.ProgJobInt = CInt((100 / ProgBarShare) * i / MODdata.tDim) - - If Pwheel < 0 Or (i > 0 AndAlso Vh.EcoRoll(i - 1)) Then - - Vmax = MODdata.Vh.Vsoll(i) + VEC.OverSpeed / 3.6 - Vmin = Math.Max(0, MODdata.Vh.Vsoll(i) - VEC.UnderSpeed / 3.6) - vRollout = fRolloutSpeed(i, 1, Vh.fGrad(dist(i))) - - If vRollout < Vmin Then - - 'Eco-Roll deactivated - - ElseIf vRollout <= Vmax Then - - If 2 * vRollout - Vh.V0(i) > Vmax Then - Vh.SetSpeed0(i, Vmax) - ElseIf 2 * vRollout - Vh.V0(i) < Vmin Then - Vh.SetSpeed0(i, Vmin) - Else - Vh.SetSpeed(i, vRollout) - 'Vh.SetAcc(i, aRollout) - End If - - Positions(i) = 4 - - 'Mark position for Calc - Vh.EcoRoll(i) = True - - Else - - If 2 * Vmax - Vh.V0(i) >= Vmax Then - Vh.SetSpeed0(i, Vmax) - Else - Vh.SetSpeed(i, Vmax) - End If - - Positions(i) = 1 - - 'Do NOT mark position for Calc => Motoring NOT Idling - 'Vh.EcoRoll(i) = True - - End If - - - End If - - Else - - If P < Pmin Then - - If VEC.OverSpeedOn Then - - 'Secondary Progressbar - ProgBarCtrl.ProgJobInt = CInt((100 / ProgBarShare) * i / MODdata.tDim) - - vCoasting = fCoastingSpeed(i, dist(i), Gear) - Vmax = MODdata.Vh.Vsoll(i) + VEC.OverSpeed / 3.6 - - If vCoasting <= Vmax Then - - If 2 * vCoasting - Vh.V0(i) > Vmax Then - Vh.SetSpeed0(i, Vmax) - Else - Vh.SetSpeed(i, vCoasting) - End If - - Else - - If 2 * Vmax - Vh.V0(i) > Vmax Then - Vh.SetSpeed0(i, Vmax) - Else - Vh.SetSpeed(i, Vmax) - End If - - End If - - End If - - End If - - End If - - End If - - LastnU = nU - - Gears.Add(Gear) - - Loop Until i >= MODdata.tDim - - - 'Look Ahead & Limit Acc (Backward) - - 'Mark Brake Positions - For i = MODdata.tDim To 1 Step -1 - If Vh.V(i - 1) - Vh.V(i) > 0.0001 And Not Positions(i) = 4 Then Positions(i) = 1 - Next - - 'Look-Ahead Coasting - i = MODdata.tDim + 1 - Do - i -= 1 - - 'Secondary Progressbar - If ProgBarLACpart > 0 Then _ - ProgBarCtrl.ProgJobInt = - CInt((100 / ProgBarShare) * (MODdata.tDim - i) / MODdata.tDim + (ProgBarLACpart - 1) * (100 / ProgBarShare)) - - 'Check if cancellation pending - If VECTOworker.CancellationPending Then Return True - - If Positions(i) = 1 Then - vset2 = Vh.V(i) - For j = i To 0 Step -1 - If Positions(j) = 0 Or Positions(j) = 4 Then - vset1 = Vh.V(j) - Exit For - End If - Next - - 'Calc Coasting-Start time step - If VEC.LookAheadOn Then - Tlookahead = CInt((vset2 - vset1) / VEC.ALookahead) - t = Math.Max(0, i - Tlookahead) - End If - - 'Check if target-speed change inside of Coasting Phase - For i0 = i To t Step -1 - If i0 = 0 Then Exit For - If Vh.Vsoll(i0) - Vh.Vsoll(i0 - 1) > 0.0001 Then - t = Math.Min(i0 + 1, i) - Exit For - End If - Next - - LookAheadDone = False - - 'Limit deceleration - adec = VEC.aDesMin(Vact) - If Vh.a(i) < adec Then Vh.SetMinAccBackw(i) - - i0 = i - - 'If vehicle stops too early reduce coasting time, i.e. set Coasting-Start later - If VEC.LookAheadOn Then - Do While i0 > t AndAlso fCoastingSpeed(t, dist(t), Gears(t), i0 - t) < Vh.V(i0) - t += 1 - Loop - End If - - - Do - i -= 1 - aact = Vh.a(i) - Vact = Vh.V(i) - adec = VEC.aDesMin(Vact) - - If aact < adec Then - Vh.SetMinAccBackw(i) - Positions(i) = 2 - Else - 'Coasting (Forward) - If VEC.LookAheadOn And Vact >= VEC.vMinLA / 3.6 Then - - For j = t To i0 - Vact = Vh.V(j) - vCoasting = fCoastingSpeed(j, dist(j), Gears(j)) - aCoasting = (2 * vCoasting - Vh.V0(j)) - Vh.V0(j) - If vCoasting < Vact And aCoasting >= VEC.aDesMin(Vact) Then - 'If Vrollout < Vist Then - Vh.SetSpeed(j, vCoasting) - Positions(j) = 3 - ' Vh.NoDistCorr(j) = True - Else - Exit For - End If - Next - - End If - - LookAheadDone = True - End If - - Loop Until LookAheadDone Or i = 0 - - i = i0 - - End If - - Loop Until i = 0 - - - Return True - End Function - - Public Function Calc() As Boolean - - Dim message As String = String.Empty - - Dim i As Integer - Dim M As Single - Dim nU As Single - Dim omega_p As Single - Dim omega1 As Single - Dim omega2 As Single - Dim nUx As Single - Dim PminX As Single - - Dim jz As Integer - - 'Start/Stop Control - Dim StStOff As Boolean - Dim StStTx As Single - Dim StStDelayTx As Integer - Dim StStPossible As Boolean - - Dim Vh As cVh - - Dim Gear As Integer - - Dim P As Single - Dim Pclutch As Single - Dim PaMot As Single - Dim PaGbx As Single - Dim Pmin As Single - Dim Pmax As Single - Dim Paux As Single - Dim Pbrake As Single - Dim PlossGB As Single - Dim PlossDiff As Single - Dim PlossRt As Single - Dim PlossTC As Single - Dim GVset As Boolean - Dim Vrollout As Single - Dim SecSpeedRed As Integer - Dim FirstSecItar As Boolean - Dim TracIntrIs As Single - Dim amax As Single - Dim ProgBarShare As Int16 - Dim LastPmax As Single - Dim dist As Double - Dim dist0 As Double - Dim LastGear As Integer - - Dim MsgSrc As String - - MsgSrc = "Power/Calc" - - - 'AA-TB - 'Informs Power Calculation to aggregate fuel or not if in Advanced mode. - mAAUX_Global.RunningCalc = True - - - 'Abort if no speed given - If Not DRI.Vvorg And Not (DRI.PwheelVorg And DRI.Nvorg And DRI.Gvorg) Then - WorkerMsg(tMsgID.Err, "Driving cycle is not valid! Vehicle Speed required or Pwheel + Gear + Engine Speed.", MsgSrc) - Return False - End If - - PwheelVorg = DRI.PwheelVorg - - 'Messages - If Not Cfg.DistCorr And Not PwheelVorg Then WorkerMsg(tMsgID.Warn, "Distance Correction is disabled!", MsgSrc) - - ' Initialize - Vh = MODdata.Vh - - If VEC.EcoRollOn Or VEC.OverSpeedOn Or VEC.LookAheadOn Then - ProgBarShare = 2 - Else - ProgBarShare = 1 - End If - - If GBX.TCon Then - EngSideInertia = ENG.I_mot + GBX.TCinertia - Else - EngSideInertia = ENG.I_mot - End If - - If Cfg.GnUfromCycle Or PwheelVorg Then - GearInput = DRI.Gvorg - RpmInput = DRI.Nvorg - If PwheelVorg And Not (GearInput And RpmInput) Then - WorkerMsg(tMsgID.Err, "Driving cycle is not valid! Vehicle Speed required or Pwheel + Gear + Engine Speed.", MsgSrc) - Return False - End If - If Not Cfg.BatchMode Then - If GearInput Then WorkerMsg(tMsgID.Normal, "Using gears from driving cycle", MsgSrc) - If RpmInput Then WorkerMsg(tMsgID.Normal, "Using rpm from driving cycle", MsgSrc) - If PwheelVorg Then WorkerMsg(tMsgID.Normal, "Using Pwheel from driving cycle", MsgSrc) - End If - Else - If (DRI.Gvorg Or DRI.Nvorg) And Not Cfg.BatchMode Then _ - WorkerMsg(tMsgID.Warn, "Gears/rpm from driving cycle ignored.", MsgSrc) - GearInput = False - RpmInput = False - End If - StStOff = False - StStTx = 0 - StStDelayTx = 0 - SecSpeedRed = 0 - - If GBX.TracIntrSi < 0.001 Then - TracIntrI = 0 - Else - TracIntrI = CInt(Math.Max(1, Math.Round(GBX.TracIntrSi, 0, MidpointRounding.AwayFromZero))) - End If - TracIntrIx = 0 - TracIntrOn = False - TracIntrTurnOff = False - - ClutchNorm = 0.03 - ClutchEta = 1 - - LastGear = 0 - - LastClutch = tEngClutch.Opened - - 'Theoretical maximum speed [m/s] - set to Speed ​​at 1.2 x Nominal-Revolutions in top-Gear - GVmax = 1.2 * ENG.Nrated * 2 * VEH.rdyn * Math.PI / (1000 * GBX.Igetr(0) * GBX.Igetr(GBX.GearCount) * 60) - - dist = 0 - dist0 = 0 - - jz = -1 - - '*********************************************************************************************** - '*********************************** Time-loop **************************************** - '*********************************************************************************************** - - Do - jz += 1 - - MODdata.ModErrors.ResetAll() - - GVset = False - FirstSecItar = True - - 'Secondary Progressbar - ProgBarCtrl.ProgJobInt = CInt((100 / ProgBarShare) * (jz + 1) / (MODdata.tDim + 1) + (100 - 100 / ProgBarShare)) - - - ' Determine State -lbGschw: - - 'Reset the second by second Errors - MODdata.ModErrors.GeschRedReset() - - 'Calculate Speed​/Acceleration ------------------- - 'Now through DRI-class - - If Not PwheelVorg Then - Vact = Vh.V(jz) - aact = Vh.a(jz) - End If - - 'distance - dist = dist0 + Vact - - StStPossible = False - EngState0 = tEngState.Undef - - 'If Speed over Top theoretical Speed => Reduce - If Vact > GVmax + 0.0001 And Not GVset Then - Vh.SetSpeed0(jz, GVmax) - GVset = True - GoTo lbGschw - End If - - 'Check if Acceleration is too high - amax = VEC.aDesMax(Vact) - - If amax < 0.0001 Then - WorkerMsg(tMsgID.Err, "aDesMax(acc) invalid! v= " & Vact & ", aDesMax(acc) =" & amax, MsgSrc) - Return False - End If - - If aact > amax + 0.0001 Then - - 'Vh.SetSpeed0(jz, Vh.V0(jz) + amax) - Vh.SetMaxAcc(jz) - - GoTo lbGschw - - - ElseIf FirstSecItar Then 'this is necessary to avoid speed reduction failure - - 'Check whether Deceleration too high - amax = VEC.aDesMin(Vact) - If amax > -0.001 Then - WorkerMsg(tMsgID.Err, "aDesMax(dec) invalid! v= " & Vact & ", aDesMax(dec) =" & amax, MsgSrc) - Return False - End If - If aact < amax - 0.0001 And Not Vh.EcoRoll(jz) Then - Vh.SetSpeed0(jz, Vh.V0(jz) + amax) - GoTo lbGschw - End If - - - End If - - 'Power demand at wheels - Pwheel = fPwheel(jz, Vh.fGrad(dist)) - - 'Determine Driving-state ------------------------- - Pplus = False - Pminus = False - If PwheelVorg Then - Select Case Pwheel - Case Is > 0.0001 - VehState0 = tVehState.Acc - Case Is < -0.0001 - VehState0 = tVehState.Dec - Case Else - VehState0 = tVehState.Stopped - End Select - Else - If Vact < 0.0001 Then - VehState0 = tVehState.Stopped - Else - If aact >= 0.01 Then - VehState0 = tVehState.Acc - ElseIf aact < -0.01 Then - VehState0 = tVehState.Dec - Else - VehState0 = tVehState.Cruise - End If - End If - - End If - - - Select Case Pwheel - Case Is > 0.0001 - Pplus = True - Case Is < -0.0001 - Pminus = True - End Select - - 'Eco-Roll Speed Correction (because PreRun speed profile might still be too high or speed might generally be too low) - If _ - Vh.EcoRoll(jz) AndAlso Vact > MODdata.Vh.Vsoll(jz) - VEC.UnderSpeed / 3.6 AndAlso Not VehState0 = tVehState.Stopped AndAlso - Pplus Then - If Not Vh.ReduceSpeed(jz, 0.9999) Then - WorkerMsg(tMsgID.Err, - "Engine full load too low for vehicle start! Road gradient = " & Vh.fGrad(dist) & "[%] at " & - dist.ToString("#.0") & "[m]", MsgSrc & "/t= " & jz + 1) - Return False - End If - FirstSecItar = False - GoTo lbGschw - End If - - - '************************************ Gear selection ************************************ - If VehState0 = tVehState.Stopped Or TracIntrOn Then - - If TracIntrTurnOff And Not VehState0 = tVehState.Stopped Then - - Gear = TracIntrGear - - If Not GBX.TCon AndAlso fnn(Vact, Gear, False) < ClutchNorm And Pplus Then - Clutch = tEngClutch.Slipping - Else - Clutch = tEngClutch.Closed - End If - - Else - Gear = 0 - Clutch = tEngClutch.Opened - End If - - Else - - 'Check whether Clutch will slip (important for Gear-shifting model): - If Not GBX.TCon AndAlso fnn(Vact, 1, False) < ClutchNorm And Pplus And Not PwheelVorg Then - Clutch = tEngClutch.Slipping - Else - Clutch = tEngClutch.Closed - End If - - If GearInput Then - 'Gear-settings - Gear = Math.Min(Vh.GearVorg(jz), GBX.GearCount) - ElseIf RpmInput Then - 'Revolutions-setting - Gear = fGearByU(MODdata.nUvorg(jz), Vact) - ElseIf GBX.GearCount = 1 Then - Gear = 1 - Else - - 'Gear-shifting Model - If GBX.TCon Then - - - Gear = fGearTC(jz, Vh.fGrad(dist)) - Else - Gear = fGearVECTO(jz, Vh.fGrad(dist)) - End If - - 'Must be reset here because the Gear-shifting model may cause changes - MODdata.ModErrors.PxReset() - - End If - - 'Gear shifting-model / gear input can open Clutch - If Gear < 1 Then - - Clutch = tEngClutch.Opened - - Else - - If _ - Not GBX.TCon AndAlso fnn(Vact, Gear, False) < ClutchNorm And Pplus And Not VehState0 = tVehState.Dec And - Not PwheelVorg Then - Clutch = tEngClutch.Slipping - Else - Clutch = tEngClutch.Closed - End If - - End If - - End If - - - If PwheelVorg Then - nU = MODdata.nUvorg(jz) - Vact = fV(nU, Gear) - End If - - If Gear = -1 Then - WorkerMsg(tMsgID.Err, "Error in Gear Shift Model!", MsgSrc & "/t= " & jz + 1) - Return False - End If - - 'Eco-Roll (triggers if Pwheel < 2 [kW]) - If Vh.EcoRoll(jz) AndAlso Pwheel <= 0 Then - Clutch = tEngClutch.Opened - Gear = 0 - End If - - If Gear = 1 And Pminus And Vact <= 5 / 3.6 Then - Clutch = tEngClutch.Opened - Gear = 0 - End If - - ' Important checks -lbCheck: - - 'Reduce : |@@| If before?(vor) Gear-shift is detected that Clutch does not Lock, then Downshift at too low Revolutions: - 'Falls vor Gangwahl festgestellt wurde, dass nicht KupplSchleif, dann bei zu niedriger Drehzahl runterschalten: |@@| If before?(vor) Gear-shift is detected that Clutch does not Lock, then Downshift at too low Revolutions: - If Not GBX.TCon Then - If Clutch = tEngClutch.Closed Then - If fnn(Vact, Gear, False) < ClutchNorm And Not VehState0 = tVehState.Dec And Gear > 1 Then Gear -= 1 - End If - End If - - - 'Check whether idling although Power > 0 - ' if power at wheels > 0.2 [kW], then clutch in - If Clutch = tEngClutch.Opened Then - If Pwheel > 0.2 Then - - If TracIntrOn Then - Gear = TracIntrGear - Else - Gear = 1 - End If - - - If Not GBX.TCon AndAlso fnn(Vact, Gear, False) < ClutchNorm Then - Clutch = tEngClutch.Slipping - Else - Clutch = tEngClutch.Closed - End If - - GoTo lbCheck - - End If - End If - - '************************************ Revolutions ************************************ - - '*** If Revolutions specified then the next block is skipped *** - If RpmInput Then - - nU = MODdata.nUvorg(jz) - - 'If Start/Stop then it will be set at the same nn < -0.05 to nU = 0 - If VEC.StartStop And nU < ENG.Nidle - 100 Then - If Pplus Then - nU = ENG.Nidle - If FirstSecItar Then _ - WorkerMsg(tMsgID.Warn, "target rpm < rpm_idle while power demand > 0", MsgSrc & "/t= " & jz + 1) - Else - nU = 0 - End If - End If - - If nU < ENG.Nidle - 100 And Not VEC.StartStop Then - If FirstSecItar Then _ - WorkerMsg(tMsgID.Warn, "target rpm < rpm_idle (Start/Stop disabled)", MsgSrc & "/t= " & jz + 1) - End If - - GoTo lb_nOK - - End If - - 'Revolutions drop when decoupling - If Clutch = tEngClutch.Opened Then - If jz = 0 Then - nU = ENG.Nidle - Else - - If MODdata.nU(jz - 1) <= ENG.Nidle + 0.00001 Then - nU = MODdata.nU(jz - 1) - GoTo lb_nOK - End If - - - nUx = MODdata.nU(jz - 1) - omega1 = nUx * 2 * Math.PI / 60 - Pmin = 0 - nU = nUx - i = 0 - Do - PminX = Pmin - Pmin = ENG.FLD.Pdrag(nU) - - 'Limit Power-drop to 75% - P = (MODdata.Pe(jz - 1) - MODdata.PauxSum(jz - 1)) - 0.75 * ((MODdata.Pe(jz - 1) - MODdata.PauxSum(jz - 1)) - Pmin) - - M = -P * 1000 * 60 / (2 * Math.PI * nU) - omega_p = M / EngSideInertia - omega2 = omega1 - omega_p - nU = omega2 * 60 / (2 * Math.PI) - i += 1 - '01:10:12 Luz: Revolutions must not be higher than previously - If nU > nUx Then - nU = nUx - Exit Do - End If - Loop Until Math.Abs(Pmin - PminX) < 0.001 Or nU <= ENG.Nidle Or i = 999 - - 'If i = 999 Then WorkerMsg(tMsgID.Warn, "i=999", MsgSrc & "/t= " & jz + 1) - - nU = Math.Max(ENG.Nidle, nU) - - MODdata.ModErrors.FLDextrapol = "" - - End If - - Else - - If GBX.TCon And False Then 'GBX.IsTCgear(Gear) Then - - PlossGB = fPlossGB(Pwheel, Vact, Gear, False) - PlossDiff = fPlossDiff(Pwheel, Vact, False) - PlossRt = fPlossRt(Vact, Gear) - PaGbx = fPaG(Vact, aact) - Pclutch = Pwheel + PlossGB + PlossDiff + PaGbx + PlossRt - - If jz = 0 Then - If Not GBX.TCiteration(Gear, fnUout(Vact, Gear), Pclutch, jz) Then - WorkerMsg(tMsgID.Err, "TC Iteration failed!", MsgSrc & "/t= " & jz + 1) - Return False - End If - Else - If Not GBX.TCiteration(Gear, fnUout(Vact, Gear), Pclutch, jz, MODdata.nU(jz - 1), MODdata.Pe(jz - 1)) Then - WorkerMsg(tMsgID.Err, "TC Iteration failed!", MsgSrc & "/t= " & jz + 1) - Return False - End If - End If - - If GBX.TCNeutral Then - Gear = 0 - Clutch = tEngClutch.Opened - GoTo lbCheck - End If - - If GBX.TCReduce Then - If Not Vh.ReduceSpeed(jz, 0.999) Then - WorkerMsg(tMsgID.Err, "Engine full load too low for vehicle start (speed reduction failed) !", - MsgSrc & "/t= " & jz + 1) - Return False - End If - FirstSecItar = False - GoTo lbGschw - End If - - nU = GBX.TCnUin - - Else - - nU = fnU(Vact, Gear, Clutch = tEngClutch.Slipping) - - '*** Start: Revolutions Check - - 'Check whether Revolutions too high! => Speed Reduction - Do While Gear < GBX.GearCount AndAlso nU > 1.2 * (ENG.Nrated - ENG.Nidle) + ENG.Nidle - Gear += 1 - nU = fnU(Vact, Gear, Clutch = tEngClutch.Slipping) - Loop - - 'Check whether Revolutions too low with the Clutch closed - If Clutch = tEngClutch.Closed Then - If nU < ENG.Nidle + 0.0001 Then - Gear -= 1 - If Gear = 0 Then Clutch = tEngClutch.Opened - GoTo lbCheck - 'nU = fnU(Vact, Gear, Clutch = tEngClutch.Slipping) - End If - End If - - End If - - End If - - -lb_nOK: - - '************************************ Determine Engine-state ************************************ - ' nU is final here! - - ''Determine Aux power demand (from VEH and DRI) - 'Paux = fPaux(jz, Math.Max(nU, ENG.Nidle)) - - - 'AA-TB - ( RAFAEL ) - '************************ ADVANCED AUXILIARIES STARTS ********************************************** - 'Clutch closed/engaged = True - 'Note: Slipping clutch is also considered enganged. - mAAUX_Global.ClutchEngaged = (Clutch <> tEngClutch.Opened) - - 'Note: Vehicles with Start/Stop will stop engine at vehicle stop => EngState0 = tEngState.Stopped - mAAUX_Global.Idle = (EngState0 = tEngState.Idle) - - mAAUX_Global.InNeutral = (Gear = 0) - - 'Driveline Power = required power at clutch = power at wheels plus powertrain losses - '[kW] - mAAUX_Global.EngineDrivelinePower = Pclutch - - '[1/min] - mAAUX_Global.EngineSpeed = nU - - '[Nm] (using Power => Torque conversion) - mAAUX_Global.EngineDrivelineTorque = nPeToM(EngineSpeed, EngineDrivelinePower) - - 'Motoring power (< 0 !!!) - '[kW] - '** NOTE THIS IS MULTIPLIED BY - to get a positive value. - mAAUX_Global.EngineMotoringPower = -GBX.FLD(Gear).Pdrag(EngineSpeed) - - 'Additional aux power from driving cycle (optional user input) - '[kW] - mAAUX_Global.PreExistingAuxPower = MODdata.Vh.Padd(jz) - - 'Total aux power - '[kW] - Paux = fPaux(jz, EngineSpeed) - '***************** ADVANCED AUXILIARIES END ******************************************************** - - 'ICE-inertia - If jz = 0 Then - PaMot = 0 - Else - 'Not optimal since jz-1 to jz not the right interval - PaMot = fPaMot(nU, MODdata.nU(jz - 1)) - End If - - 'Total Engine-power - ' => Pantr - ' => P - ' => Pkup - 'Power at clutch - Select Case Clutch - Case tEngClutch.Opened - Pclutch = 0 - PlossGB = 0 - PlossDiff = 0 - PlossRt = 0 - PlossTC = 0 - PaGbx = 0 - Case tEngClutch.Closed - - If GBX.TCon And False Then ' GBX.IsTCgear(Gear) Then - - Pclutch = nMtoPe(nU, GBX.TCMin) - - If Pclutch >= 0 Then - PlossTC = Math.Abs(nMtoPe(GBX.TCnUin, GBX.TCMin) * (1 - GBX.TC_mu * GBX.TC_nu)) - Else - PlossTC = Math.Abs(nMtoPe(GBX.TCnUout, GBX.TCMout) * (1 - GBX.TC_mu * GBX.TC_nu)) - End If - - Else - - PlossGB = fPlossGB(Pwheel, Vact, Gear, False) - PlossDiff = fPlossDiff(Pwheel, Vact, False) - PlossRt = fPlossRt(Vact, Gear) - PlossTC = 0 - PaGbx = fPaG(Vact, aact) - Pclutch = Pwheel + PlossGB + PlossDiff + PaGbx + PlossRt - - End If - Case Else 'tEngClutch.Slipping: never in AT mode! - PlossGB = fPlossGB(Pwheel, Vact, Gear, False) - PlossDiff = fPlossDiff(Pwheel, Vact, False) - PlossRt = fPlossRt(Vact, Gear) - PlossTC = 0 - PaGbx = fPaG(Vact, aact) - Pclutch = (Pwheel + PlossGB + PlossDiff + PaGbx + PlossRt) / ClutchEta - End Select - - - 'Total aux power - '[kW] - Paux = fPaux(jz, Math.Max(nU, ENG.Nidle)) - - - 'ICE-inertia - If jz = 0 Then - PaMot = 0 - Else - 'Not optimal since jz-1 to jz not the right interval - PaMot = fPaMot(nU, MODdata.nU(jz - 1)) - End If - - 'Internal Engine Power (Pclutch plus Aux plus Inertia) - P = Pclutch + Paux + PaMot - - 'EngState - If Clutch = tEngClutch.Opened Then - - 'Start/Stop >>> tEngState.Stopped - If VEC.StartStop AndAlso Vact <= VEC.StStV / 3.6 AndAlso Math.Abs(PaMot) < 0.0001 Then - StStPossible = True - If StStOff And jz > 0 Then - If MODdata.EngState(jz - 1) = tEngState.Stopped Then - P = 0 - EngState0 = tEngState.Stopped - End If - Else - P = 0 - EngState0 = tEngState.Stopped - End If - End If - - Select Case P - Case Is > 0.0001 'Antrieb - EngState0 = tEngState.Load - - Case Is < -0.0001 'Schlepp - EngState0 = tEngState.Drag - - Case Else 'Idle/Stop - If Not EngState0 = tEngState.Stopped Then EngState0 = tEngState.Idle - End Select - - Else - - If P < 0 Then - EngState0 = tEngState.Drag - Else - EngState0 = tEngState.Load - End If - - End If - - - '*************** Leistungsverteilung usw. ****************** |@@| Power distribution, etc. ****************** - - 'Full-Load/Drag curve - If EngState0 = tEngState.Stopped Then - - Pmin = 0 - Pmax = 0 - - 'Revolutions Correction - nU = 0 - - Else - - Pmin = ENG.FLD.Pdrag(nU) - - If jz = 0 Then - Pmax = GBX.FLD(Gear).Pfull(nU) - Else - Pmax = GBX.FLD(Gear).Pfull(nU, MODdata.Pe(jz - 1)) - End If - - 'If Pmax < 0 or Pmin > 0 then Abort with Error! - If Pmin >= 0 And P < 0 Then - WorkerMsg(tMsgID.Err, "Pe_drag > 0! n= " & nU & " [1/min]", MsgSrc & "/t= " & jz + 1, ENG.FLD.FilePath) - Return False - ElseIf Pmax <= 0 And P > 0 Then - WorkerMsg(tMsgID.Err, "Pe_full < 0! n= " & nU & " [1/min]", MsgSrc & "/t= " & jz + 1, GBX.FLD(Gear).FilePath) - Return False - End If - - End If - - ' => Pbrake - If Clutch = tEngClutch.Opened Then - If Pwheel < -0.00001 Then - Pbrake = Pwheel - Else - Pbrake = 0 - End If - - If P < Pmin Then P = Pmin - - 'AA-TB - mAAUX_Global.Internal_Engine_Power = P - - Else - - 'AA-TB - mAAUX_Global.Internal_Engine_Power = P - - If EngState0 = tEngState.Load Then - Pbrake = 0 - If GBX.TCon And False Then 'GBX.IsTCgear(Gear) Then - Pbrake = GBX.TC_PeBrake - End If - If Math.Abs(P / Pmax - 1) < 0.02 Then EngState0 = tEngState.FullLoad - Else ' tEngState.Drag (tEngState.Idle, tEngState.Stopped kann's hier nicht geben weil Clutch <> Closed) - If P < Pmin Then - - 'Overspeed - 'If Not OvrSpeed AndAlso Not VehState0 = tVehState.Dec Then - - ' OvrSpeed = True - - ' If DEV.OverSpeedOn And (Pmin - P) / VEH.Pnenn > DEV.SpeedPeEps Then - - ' Vcoasting = fCoastingSpeed(jz, Gear) - - ' If Vcoasting <= MODdata.Vh.Vsoll(jz) + DEV.OverSpeed / 3.6 Then - ' Vh.SetSpeed(jz, Vcoasting) - ' GoTo lbGschw - ' ElseIf Vist < 0.999 * (MODdata.Vh.Vsoll(jz) + DEV.OverSpeed / 3.6) Then - ' Vh.SetSpeed(jz, MODdata.Vh.Vsoll(jz) + DEV.OverSpeed / 3.6) - ' GoTo lbGschw - ' End If - - ' End If - 'End If - - MODdata.ModErrors.TrLossMapExtr = "" - - 'VKM to Drag-curve - P = Pmin - - 'Forward-calculation to Wheel (PvorD) - Pclutch = P - Paux - PaMot - PaGbx = fPaG(Vact, aact) - PlossGB = fPlossGBfwd(Pclutch, Vact, Gear, False) - PlossRt = fPlossRt(Vact, Gear) - PlossDiff = fPlossDiffFwd(Pclutch - PlossGB - PlossRt, Vact, False) - - Pbrake = Pwheel - (Pclutch - PlossGB - PlossDiff - PaGbx - PlossRt) - - EngState0 = tEngState.FullDrag - Else - Pbrake = 0 - End If - End If - End If - - 'Check if cancellation pending (before Speed-reduce-iteration, otherwise it hangs) - If VECTOworker.CancellationPending Then Return True - - - 'If jz = 6915 Then - ' Stop - ' Debug.Print( - ' Vact * 3.6 & "," & aact & "," & Vh.fGrad(dist) & "," & GBX.TC_nu & "," & GBX.TC_mu & "," & nU & "," & Pwheel & "," & - ' nMtoPe(GBX.TCnUout, GBX.TCMout) & "," & - ' Pclutch & "," & Paux & "," & PaMot & "," & - ' P & "," & Pmax) - 'End If - - - 'Check whether P above Full-load => Reduce Speed - If P > Pmax Then - If EngState0 = tEngState.Load Or EngState0 = tEngState.FullLoad Then - If PwheelVorg Then - MODdata.Vh.Pwheel(jz) *= 0.999 - GoTo lbGschw - ElseIf Vact > 0.01 Then - Vh.ReduceSpeed(jz, 0.9999) - FirstSecItar = False - GoTo lbGschw - Else - 'ERROR: Speed Reduction failed. (Road gradient too high) - WorkerMsg(tMsgID.Err, - "Engine full load too low for vehicle start! Road gradient = " & Vh.fGrad(dist) & "[%] at " & - dist.ToString("#.0") & "[m]", MsgSrc & "/t= " & jz + 1) - Return False - End If - - Else 'tEngState.Idle, tEngState.Stopped, tEngState.Drag - If FirstSecItar Then - If P > 0.1 Then WorkerMsg(tMsgID.Warn, "Pwheel > 0 but EngState undefined ?!", MsgSrc & "/t= " & jz + 1) - End If - End If - End If - - - 'Interruption of traction(Zugkraftunterbrechung) - If TracIntrI > 0 Then - - If Not TracIntrOn Then - - If jz > 0 AndAlso Gear > 0 AndAlso MODdata.Gear(jz - 1) > 0 AndAlso Gear <> MODdata.Gear(jz - 1) Then - - TracIntrGear = Gear - Gear = 0 - Clutch = tEngClutch.Opened - TracIntrIx = 0 - TracIntrOn = True - - If TracIntrIx + 1 = TracIntrI Then - TracIntrIs = GBX.TracIntrSi - CSng(TracIntrIx) - Else - TracIntrIs = 1 - End If - - If Not PwheelVorg Then - Vrollout = fRolloutSpeed(jz, TracIntrIs, Vh.fGrad(dist)) - If Vrollout < Vact Or VehState0 <> tVehState.Dec Then Vh.SetSpeed(jz, Vrollout) - GoTo lbGschw - End If - - - End If - - End If - - End If - - '-------------------------------------------------------------------------------------------------- - '------------------------- PNR -------------------------------------------------------------------- - '-------------------------------------------------------------------------------------------------- - ' Finish Second - - 'If Gear > 1 AndAlso Gear = LastGear + 1 Then - ' Debug.Print(jz & "," & nU.ToString() & "," & nPeToM(nU, P) & "," & Gear) - 'Else - ' Debug.Print(jz & ",-,-,-") - 'End If - - 'distance - dist0 += Vact - - 'Start / Stop - Activation-Speed Control - If VEC.StartStop Then - If StStPossible Then - StStDelayTx += 1 - Else - StStDelayTx = 0 - End If - If StStOff Then - If Not EngState0 = tEngState.Stopped Then - StStTx += 1 - If StStTx > VEC.StStT And StStDelayTx >= VEC.StStDelay Then - StStTx = 1 - StStOff = False - End If - End If - Else - If EngState0 = tEngState.Stopped Or StStDelayTx < VEC.StStDelay Then StStOff = True - End If - End If - - 'Write Modal-values Fields - MODdata.Pe.Add(P) - MODdata.nU.Add(nU) - - MODdata.EngState.Add(EngState0) - - If DRI.PwheelVorg Then - MODdata.Pa.Add(0) - MODdata.Pair.Add(0) - MODdata.Proll.Add(0) - MODdata.Pstg.Add(0) - Else - MODdata.Pa.Add(fPaFZ(MODdata.Vh.V(jz), MODdata.Vh.a(jz))) - MODdata.Pair.Add(fPair(MODdata.Vh.V(jz), jz)) - MODdata.Proll.Add(fPr(MODdata.Vh.V(jz), Vh.fGrad(dist))) - MODdata.Pstg.Add(fPs(MODdata.Vh.V(jz), Vh.fGrad(dist))) - End If - - MODdata.Pbrake.Add(Pbrake) - MODdata.Psum.Add(Pwheel) - MODdata.PauxSum.Add(Paux) - MODdata.Grad.Add(Vh.fGrad(dist)) - - For Each AuxID As String In VEC.AuxRefs.Keys - MODdata.Paux(AuxID).Add(VEC.Paux(AuxID, jz, Math.Max(nU, ENG.Nidle))) - Next - - MODdata.PlossGB.Add(PlossGB) - MODdata.PlossDiff.Add(PlossDiff) - MODdata.PlossRt.Add(PlossRt) - MODdata.PlossTC.Add(PlossTC) - MODdata.PaEng.Add(PaMot) - MODdata.PaGB.Add(PaGbx) - MODdata.Pclutch.Add(Pclutch) - - MODdata.VehState.Add(VehState0) - MODdata.Gear.Add(Gear) - - 'Torque Converter output - If GBX.TCon Then - If False Then 'GBX.IsTCgear(Gear) Then - If nU = 0 Then - MODdata.TCnu.Add(0) - Else - MODdata.TCnu.Add(GBX.TCnUout / nU) - End If - If GBX.TCMin = 0 Then - MODdata.TCmu.Add(0) - Else - MODdata.TCmu.Add(GBX.TCMout / GBX.TCMin) - End If - MODdata.TCMout.Add(GBX.TCMout) - MODdata.TCnOut.Add(GBX.TCnUout) - Else - If Clutch = tEngClutch.Opened Then - MODdata.TCnu.Add(0) - MODdata.TCmu.Add(0) - MODdata.TCMout.Add(0) - MODdata.TCnOut.Add(0) - Else - MODdata.TCnu.Add(1) - MODdata.TCmu.Add(1) - MODdata.TCMout.Add(nPeToM(nU, Pclutch)) - MODdata.TCnOut.Add(nU) - End If - End If - End If - - Vh.DistCorrection(jz, VehState0) - - 'Traction Interruption - If TracIntrTurnOff Then - - TracIntrOn = False - TracIntrTurnOff = False - - ElseIf TracIntrOn Then - - TracIntrIx += 1 - - If TracIntrIx = TracIntrI Then - - TracIntrTurnOff = True - - ElseIf jz < MODdata.tDim Then - - If TracIntrIx + 1 = TracIntrI Then - TracIntrIs = GBX.TracIntrSi - CSng(TracIntrIx) - Else - TracIntrIs = 1 - End If - - If Not PwheelVorg Then - Vrollout = fRolloutSpeed(jz + 1, TracIntrIs, Vh.fGrad(dist)) - If Vrollout < Vh.V(jz + 1) Or VehState0 <> tVehState.Dec Then Vh.SetSpeed(jz + 1, Vrollout) - End If - - End If - - End If - - If Not PwheelVorg Then - If Vh.Vsoll(jz) - Vact > 1.5 Then SecSpeedRed += 1 - End If - - - LastGearChange = -1 - For i = jz - 1 To 0 Step -1 - If MODdata.Gear(i) <> 0 Then - If MODdata.Gear(i) <> Gear Then - LastGearChange = i - Exit For - End If - End If - Next - - - LastClutch = Clutch - - 'Messages - If MODdata.ModErrors.MsgOutputAbort(jz + 1, MsgSrc) Then Return False - - If Clutch = tEngClutch.Closed And RpmInput Then - If Math.Abs(nU - fnU(Vact, Gear, False)) > 0.2 * ENG.Nrated Then - WorkerMsg(tMsgID.Warn, "Target rpm =" & nU & ", calculated rpm(gear " & Gear & ")= " & fnU(Vact, Gear, False), - MsgSrc & "/t= " & jz + 1) - End If - End If - - LastPmax = Pmax - - LastGear = Gear - - 'AA-TB - 'Aggregate Fuel On Last Known Signals. - If Not mAAUX_Global.advancedAuxModel Is Nothing Then - - 'EngineState ( used for start stop fueling adjustment ) - - If EngState0 = tEngState.Stopped Then - advancedAuxModel.Signals.EngineStopped = True - Else - advancedAuxModel.Signals.EngineStopped = False - End If - - mAAUX_Global.EngineDrivelineTorque = nPeToM(nU, P) - (((Paux) * 1000) / (EngineSpeed / 9.55)) - mAAUX_Global.advancedAuxModel.Signals.EngineDrivelineTorque = - mAAUX_Global.EngineDrivelineTorque.SI(Of NewtonMeter)() - - - advancedAuxModel.CycleStep(1.SI(Of Second), message) - - - Try - - 'Add Mod Data - MODdata.AA_NonSmartAlternatorsEfficiency.Add(advancedAuxModel.AA_NonSmartAlternatorsEfficiency()) - MODdata.AA_SmartIdleCurrent_Amps.Add(advancedAuxModel.AA_SmartIdleCurrent_Amps().Value()) - MODdata.AA_SmartIdleAlternatorsEfficiency.Add(advancedAuxModel.AA_SmartIdleAlternatorsEfficiency()) - MODdata.AA_SmartTractionCurrent_Amps.Add(advancedAuxModel.AA_SmartTractionCurrent_Amps().Value()) - MODdata.AA_SmartTractionAlternatorEfficiency.Add(advancedAuxModel.AA_SmartTractionAlternatorEfficiency()) - MODdata.AA_SmartOverrunCurrent_Amps.Add(advancedAuxModel.AA_SmartOverrunCurrent_Amps().Value()) - MODdata.AA_SmartOverrunAlternatorEfficiency.Add(advancedAuxModel.AA_SmartOverrunAlternatorEfficiency()) - MODdata.AA_CompressorFlowRate_LitrePerSec.Add(advancedAuxModel.AA_CompressorFlowRate_LitrePerSec().Value()) - MODdata.AA_OverrunFlag.Add(advancedAuxModel.AA_OverrunFlag()) - MODdata.AA_EngineIdleFlag.Add(advancedAuxModel.AA_EngineIdleFlag) - MODdata.AA_CompressorFlag.Add(advancedAuxModel.AA_CompressorFlag()) - MODdata.AA_TotalCycleFC_Grams.Add(advancedAuxModel.AA_TotalCycleFC_Grams().Value()) - MODdata.AA_TotalCycleFC_Litres.Add(advancedAuxModel.AA_TotalCycleFC_Litres().Value()) - - MODdata.AA_AveragePowerDemandCrankHVACMechanicals.Add( - advancedAuxModel.AA_AveragePowerDemandCrankHVACMechanicals().Value()) - MODdata.AA_AveragePowerDemandCrankHVACElectricals.Add( - advancedAuxModel.AA_AveragePowerDemandCrankHVACElectricals().Value()) - MODdata.AA_AveragePowerDemandCrankElectrics.Add(advancedAuxModel.AA_AveragePowerDemandCrankElectrics().Value()) - MODdata.AA_AveragePowerDemandCrankPneumatics.Add(advancedAuxModel.AA_AveragePowerDemandCrankPneumatics().Value()) - MODdata.AA_TotalCycleFuelConsumptionCompressorOff.Add( - advancedAuxModel.AA_TotalCycleFuelConsumptionCompressorOff().Value()) - MODdata.AA_TotalCycleFuelConsumptionCompressorOn.Add( - advancedAuxModel.AA_TotalCycleFuelConsumptionCompressorOn().Value()) - - - 'TODO:DIAGNOSTICS - REMOVE WHEN TESTED - 'ModData.AA_D_M12_P1X .Add( advancedAuxModel.AA_D_M12_P1X) - 'ModData.AA_D_M12_P1Y .Add( advancedAuxModel.AA_D_M12_P1Y) - 'ModData.AA_D_M12_P2X .Add( advancedAuxModel.AA_D_M12_P2X) - 'ModData.AA_D_M12_P2Y .Add( advancedAuxModel.AA_D_M12_P2Y) - 'ModData.AA_D_M12_P3X .Add( advancedAuxModel.AA_D_M12_P3X) - 'ModData.AA_D_M12_P3Y .Add( advancedAuxModel.AA_D_M12_P3Y) - 'ModData.AA_D_M12_XTAIN .Add( advancedAuxModel.AA_D_M12_XTAIN) - 'ModData.AA_D_M12_INTERP1 .Add( advancedAuxModel.AA_D_M12_INTERP1) - 'ModData.AA_D_M12_INTERP2 .Add( advancedAuxModel.AA_D_M12_INTERP2) - - - Catch ex As Exception - - Dim dummy As Single = 0 - - - End Try - - - End If - - Loop Until jz >= MODdata.tDim - - - '*********************************************************************************************** - '*********************************** Time loop END *********************************** - '*********************************************************************************************** - - 'Notify - If Cfg.DistCorr Then - If MODdata.tDim > MODdata.tDimOgl Then _ - WorkerMsg(tMsgID.Normal, "Cycle extended by " & MODdata.tDim - MODdata.tDimOgl & " seconds to meet target distance.", - MsgSrc) - - If Math.Abs(Vh.WegIst - Vh.WegSoll) > 80 Then - WorkerMsg(tMsgID.Warn, - "Target distance= " & (Vh.WegSoll / 1000).ToString("#.000") & "[km], Actual distance= " & - (Vh.WegIst / 1000).ToString("#.000") & "[km], Error= " & Math.Abs(Vh.WegIst - Vh.WegSoll).ToString("#.0") & "[m]", - MsgSrc) - Else - WorkerMsg(tMsgID.Normal, - "Target distance= " & (Vh.WegSoll / 1000).ToString("#.000") & "[km], Actual distance= " & - (Vh.WegIst / 1000).ToString("#.000") & "[km], Error= " & Math.Abs(Vh.WegIst - Vh.WegSoll).ToString("#.0") & "[m]", - MsgSrc) - End If - End If - - If SecSpeedRed > 0 Then _ - WorkerMsg(tMsgID.Normal, "Speed reduction > 1.5 m/s in " & SecSpeedRed & " time steps.", MsgSrc) - - - 'CleanUp - Vh = Nothing - - Return True - End Function - - Public Function Eng_Calc(ByVal NoWarnings As Boolean) As Boolean - - Dim Pmr As Single - Dim t As Integer - Dim t1 As Integer - Dim Pmin As Single - Dim Pmax As Single - Dim nUDRI As List(Of Double) - Dim PeDRI As List(Of Double) - Dim PcorCount As Integer - Dim MsgSrc As String - Dim Padd As Single - - MsgSrc = "Power/Eng_Calc" - - 'Abort if Power/Revolutions not given - If Not (DRI.Nvorg And DRI.Pvorg) Then - WorkerMsg(tMsgID.Err, "Load cycle is not valid! rpm and load required.", MsgSrc) - Return False - End If - - PcorCount = 0 - t1 = MODdata.tDim - nUDRI = DRI.Values(tDriComp.nU) - PeDRI = DRI.Values(tDriComp.Pe) - - 'Drehzahlen vorher weil sonst scheitert die Pmr-Berechnung bei MODdata.nU(t + 1) |@@| Revolutions previously, otherwise Pmr-calculation fails at MODdata.nU(t + 1) - For t = 0 To t1 - MODdata.nU.Add(Math.Max(0, nUDRI(t))) - Next - - 'Power calculation - For t = 0 To t1 - - 'Secondary Progressbar - ProgBarCtrl.ProgJobInt = CInt(100 * t / t1) - - 'Reset the second-by-second Errors - MODdata.ModErrors.ResetAll() - - 'OLD and wrong because not time shifted: P_mr(jz) = 0.001 * (I_mot * 0.0109662 * (n(jz) * nnrom) * nnrom * (n(jz) - n(jz - 1))) - If t > 0 And t < t1 Then - Pmr = 0.001 * - (ENG.I_mot * (2 * Math.PI / 60) ^ 2 * ((MODdata.nU(t + 1) + MODdata.nU(t - 1)) / 2) * 0.5 * (MODdata.nU(t + 1) - MODdata.nU(t - 1))) - Else - Pmr = 0 - End If - - Padd = MODdata.Vh.Padd(t) - - 'Power = P_clutch + + Pa_eng + Padd - MODdata.Pe.Add(PeDRI(t) + (Pmr + Padd)) - - 'Revolutions of the Cycle => Determined in Cycle-init - 'If Revolutions under idle, assume Engine is stopped - If MODdata.nU(t) < ENG.Nidle - 100 Then - EngState0 = tEngState.Stopped - Else - Pmin = ENG.FLD.Pdrag(MODdata.nU(t)) - - If t = 0 Then - Pmax = ENG.FLD.Pfull(MODdata.nU(t)) - Else - Pmax = ENG.FLD.Pfull(MODdata.nU(t), MODdata.Pe(t - 1)) - End If - - 'If Pmax < 0 or Pmin > 0 then Abort with Error! - If Pmin >= 0 AndAlso MODdata.Pe(t) < 0 Then - WorkerMsg(tMsgID.Err, "Pe_drag > 0! n= " & MODdata.nU(t) & " [1/min]", MsgSrc & "/t= " & t + 1, ENG.FLD.FilePath) - Return False - ElseIf Pmax <= 0 AndAlso MODdata.Pe(t) > 0 Then - WorkerMsg(tMsgID.Err, "Pe_full < 0! n= " & MODdata.nU(t) & " [1/min]", MsgSrc & "/t= " & t + 1, ENG.FLD.FilePath) - Return False - End If - - 'FLD Check - If MODdata.Pe(t) > Pmax Then - If MODdata.Pe(t) / Pmax > 1.05 Then PcorCount += 1 - MODdata.Pe(t) = Pmax - ElseIf MODdata.Pe(t) < Pmin Then - If MODdata.Pe(t) / Pmin > 1.05 And MODdata.Pe(t) > -99999 Then PcorCount += 1 - MODdata.Pe(t) = Pmin - End If - - Select Case MODdata.Pe(t) - Case Is > 0.0001 'Antrieb - If Math.Abs(MODdata.Pe(t) / Pmax - 1) < 0.01 Then - EngState0 = tEngState.FullLoad - Else - EngState0 = tEngState.Load - End If - Case Is < -0.0001 'Schlepp - If Math.Abs(MODdata.Pe(t) / Pmin - 1) < 0.01 Then - EngState0 = tEngState.FullDrag - Else - EngState0 = tEngState.Drag - End If - Case Else - EngState0 = tEngState.Idle - End Select - End If - - MODdata.EngState.Add(EngState0) - MODdata.PaEng.Add(Pmr) - MODdata.Pclutch.Add(MODdata.Pe(t) - (Pmr + Padd)) - MODdata.PauxSum.Add(Padd) - - 'Notify - If MODdata.ModErrors.MsgOutputAbort(t + 1, MsgSrc) Then Return False - - Next - - If PcorCount > 0 And Not NoWarnings Then _ - WorkerMsg(tMsgID.Warn, "Power corrected (>5%) in " & PcorCount & " time steps.", MsgSrc) - - Return True - End Function - - Private Function fTracIntPower(ByVal t As Single, ByVal Gear As Integer) As Single - Dim PminX As Single - Dim P As Single - Dim M As Single - Dim Pmin As Single - Dim nU As Single - Dim omega_p As Single - Dim omega1 As Single - Dim omega2 As Single - Dim nUx As Single - Dim i As Integer - - - nUx = MODdata.nU(t - 1) - omega1 = nUx * 2 * Math.PI / 60 - Pmin = 0 - nU = nUx - i = 0 - - Do - PminX = Pmin - Pmin = ENG.FLD.Pdrag(nU) - 'Leistungsabfall limitieren auf Pe(t-1) minus 75% von (Pe(t-1) - Pschlepp) |@@| Limit Power-drop to Pe(t-1) minus 75% of (Pe(t-1) - Pdrag) - ' aus Auswertung ETC des Motors mit dem dynamische Volllast parametriert wurde |@@| of the evaluated ETC of the Enginges with the dynamic parametrized Full-load - ' Einfluss auf Beschleunigungsvermögen gering (Einfluss durch Pe(t-1) bei dynamischer Volllast mit PT1) |@@| Influence at low acceleration (influence dynamic Full-load through Pe(t-1) with PT1) - ' Luz/Rexeis 21.08.2012 - ' Iteration loop: 01.10.2012 - P = MODdata.Pe(t - 1) - 0.75 * (MODdata.Pe(t - 1) - Pmin) - M = -P * 1000 * 60 / (2 * Math.PI * nU) - 'original: M = -Pmin * 1000 * 60 / (2 * Math.PI * ((nU + nUx) / 2)) - omega_p = M / EngSideInertia - omega2 = omega1 - omega_p - nU = omega2 * 60 / (2 * Math.PI) - i += 1 - '01:10:12 Luz: Revolutions must not be higher than previously - If nU > nUx Then - nU = nUx - Exit Do - End If - Loop Until Math.Abs(Pmin - PminX) < 0.001 Or nU <= ENG.Nidle Or i = 999 - - Return P - End Function - - Private Function fRolloutSpeed(ByVal t As Integer, ByVal dt As Single, ByVal Grad As Single) As Single - - Dim vstep As Double - Dim vVorz As Integer - Dim PvD As Single - Dim a As Single - Dim v As Single - Dim eps As Single - Dim LastPvD As Single - Dim vMin As Single - - v = MODdata.Vh.V(t) - - vMin = (MODdata.Vh.V0(t) + 0) / 2 - - If v <= vMin Then Return vMin - - vstep = 0.1 - eps = 0.00005 - a = MODdata.Vh.a(t) - - PvD = fPwheel(t, v, a, Grad) - - If PvD > eps Then - vVorz = -1 - ElseIf PvD < -eps Then - vVorz = 1 - Else - Return v - End If - - LastPvD = PvD + 10 * eps - - Do While Math.Abs(PvD) > eps And Math.Abs(LastPvD - PvD) > eps - - If Math.Abs(LastPvD) < Math.Abs(PvD) Then - vVorz *= -1 - vstep *= 0.5 - - If vstep = 0 Then Exit Do - - End If - - v += vVorz * vstep - - If v < vMin Then - - LastPvD = 0 - v -= vVorz * vstep - - Else - - a = 2 * (v - MODdata.Vh.V0(t)) / dt - - LastPvD = PvD - - PvD = fPwheel(t, v, a, Grad) - - End If - - Loop - - Return v - End Function - - Private Function fCoastingSpeed(ByVal t As Integer, ByVal s As Double, ByVal Gear As Integer) As Single - - Return fCoastingSpeed(t, s, Gear, MODdata.Vh.V(t), MODdata.Vh.a(t)) - End Function - - Private Function fCoastingSpeed(ByVal t As Integer, ByVal s As Double, ByVal Gear As Integer, ByVal v As Single, - ByVal a As Single, Optional ByVal v0 As Single? = Nothing) As Single - - - Dim vstep As Double - Dim vSign As Integer - Dim Pe As Single - Dim Pwheel As Single - Dim LastDiff As Single - Dim Diff As Single - Dim nU As Single - Dim Pdrag As Single - Dim Grad As Single - - vstep = 5 - nU = fnU(v, Gear, False) - Pdrag = ENG.FLD.Pdrag(nU) - - 'Do not allow positive road gradients - Grad = MODdata.Vh.fGrad(s) - - - Pwheel = fPwheel(t, v, a, Grad) - Pe = Pwheel + fPlossGB(Pwheel, v, Gear, True) + fPlossDiff(Pwheel, v, True) + fPaG(v, a) + fPlossRt(v, Gear) + - fPaux(t, nU) + fPaMotSimple(t, Gear, v, a) - - - 'AA-TB - 'Recalculate for Advanced Auxiliaries. - - mAAUX_Global.ClutchEngaged = (Gear > 0) - - mAAUX_Global.Idle = (Gear = 0 And Not Pplus And Not Pminus) - - mAAUX_Global.InNeutral = (Gear = 0) - - 'Driveline Power = required power at clutch = power at wheels plus powertrain losses - '[kW] - '**** THIS IS NOT CORRECT< BUT NO PKU Variable is available at this point **** - mAAUX_Global.EngineDrivelinePower = Pwheel + fPlossGB(Pwheel, v, Gear, True) + fPlossDiff(Pwheel, v, True) + - fPaG(v, a) + fPlossRt(v, Gear) - - '[1/min] - mAAUX_Global.EngineSpeed = nU - - '[Nm] (using Power => Torque conversion) - mAAUX_Global.EngineDrivelineTorque = nPeToM(EngineSpeed, EngineDrivelinePower) - - 'Motoring power (< 0 !!!) - '[kW] - '** MULTIPLIED BY - TO GET POSITIVE VALUE - mAAUX_Global.EngineMotoringPower = -GBX.FLD(Gear).Pdrag(EngineSpeed) - - 'Additional aux power from driving cycle (optional user input) - '[kW] - mAAUX_Global.PreExistingAuxPower = MODdata.Vh.Padd(t) - - - Diff = Math.Abs(Pdrag - Pe) - - If Diff > 0.0001 Then - vSign = 1 - Else - Return v - End If - - LastDiff = Diff + 10 * 0.0001 - - Do While Diff > 0.00001 'And Math.Abs(LastDiff - Diff) > eps - - If LastDiff < Diff Or v + vSign * vstep <= 0.0001 Then - vSign *= -1 - vstep *= 0.5 - - If vstep < 0.001 Then Exit Do - - End If - - v += vSign * vstep - - If v0 Is Nothing Then - a = 2 * (v - MODdata.Vh.V0(t)) / 1 'dt = 1[s] - Else - a = 2 * (v - v0) / 1 'dt = 1[s] - End If - - nU = fnU(v, Gear, False) - Pdrag = ENG.FLD.Pdrag(nU) - - LastDiff = Diff - - Pwheel = fPwheel(t, v, a, Grad) - - 'AA-TB - 'Recalculate for Advanced Auxiliaries. - - mAAUX_Global.ClutchEngaged = (Gear > 0) - - mAAUX_Global.Idle = (Gear = 0 And Not Pplus And Not Pminus) - - mAAUX_Global.InNeutral = (Gear = 0) - - 'Driveline Power = required power at clutch = power at wheels plus powertrain losses - '[kW] - '**** RL-7/1/15 **** - mAAUX_Global.EngineDrivelinePower = Pwheel + fPlossGB(Pwheel, v, Gear, True) + fPlossDiff(Pwheel, v, True) + - fPaG(v, a) + fPlossRt(v, Gear) - - '[1/min] - mAAUX_Global.EngineSpeed = nU - - '[Nm] (using Power => Torque conversion) - mAAUX_Global.EngineDrivelineTorque = nPeToM(EngineSpeed, EngineDrivelinePower) - - 'Motoring power (< 0 !!!) - '[kW] - '** MULTIPLIED BY - TO GET POSITIVE VALUE - mAAUX_Global.EngineMotoringPower = -GBX.FLD(Gear).Pdrag(EngineSpeed) - - 'Additional aux power from driving cycle (optional user input) - '[kW] - mAAUX_Global.PreExistingAuxPower = MODdata.Vh.Padd(t) - - Pe = Pwheel + fPlossGB(Pwheel, v, Gear, True) + fPlossDiff(Pwheel, v, True) + fPaG(v, a) + fPlossRt(v, Gear) + - fPaux(t, nU) + fPaMotSimple(t, Gear, v, a) - - Diff = Math.Abs(Pdrag - Pe) - - Loop - - Return v - End Function - - Private Function fCoastingSpeed(ByVal t As Integer, ByVal s As Double, ByVal Gear As Integer, ByVal dt As Integer) _ - As Single - Dim a As Single - Dim v As Single - Dim vtemp As Single - Dim t0 As Integer - Dim v0 As Single - Dim v0p As Single - - v0 = MODdata.Vh.V0(t) - v = MODdata.Vh.V(t) - a = MODdata.Vh.a(t) - - If t + dt > MODdata.tDim - 1 Then - dt = MODdata.tDim - 1 - t - End If - - For t0 = t To t + dt - vtemp = fCoastingSpeed(t0, s, Gear, v, a, v0) - - If 2 * vtemp - v0 < 0 Then vtemp = v0 / 2 - - v0p = 2 * vtemp - v0 - a = v0p - v0 - - v = (MODdata.Vh.V0(t0 + 2) + v0p) / 2 - a = MODdata.Vh.V0(t0 + 2) - v0p - - v0 = v0p - - Next - - Return vtemp - End Function - -#Region "Gear Shift Methods" - - Private Function fFastGearCalc(ByVal V As Single, ByVal Pe As Single) As Integer - Dim Gear As Integer - Dim Tq As Single - Dim nU As Single - Dim nUup As Single - Dim nUdown As Single - - For Gear = GBX.GearCount To 1 Step -1 - - nU = CSng(Vact * 60.0 * GBX.Igetr(0) * GBX.Igetr(Gear) / (2 * VEH.rdyn * Math.PI / 1000)) - - 'Current torque demand with previous gear - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - - 'Up/Downshift rpms - nUup = GBX.Shiftpolygons(Gear).fGSnUup(Tq) - nUdown = GBX.Shiftpolygons(Gear).fGSnUdown(Tq) - - If nU > nUdown Then Return Gear - - Next - - Return 1 - End Function - - Private Function fStartGear(ByVal t As Integer, ByVal Grad As Single) As Integer - Dim Gear As Integer - Dim MsgSrc As String - Dim nU As Single - Dim nUup As Single - Dim nUdown As Single - Dim Tq As Single - Dim Pe As Single - Dim TqX As Single - Dim MdMax As Single - Dim Pmax As Single - - MsgSrc = "StartGear" - - If GBX.TCon Then Return 1 - - If t = 0 AndAlso VehState0 <> tVehState.Stopped Then - - 'Calculate gear when cycle starts with speed > 0 - For Gear = GBX.GearCount To 1 Step -1 - - 'rpm - nU = fnU(Vact, Gear, Clutch = tEngClutch.Slipping) - - 'full load - Pmax = GBX.FLD(Gear).Pfull(nU) - - 'power demand - cut at full load / drag so that fGSnnUp and fGSnnDown don't extrapolate - Pe = Math.Min(fPeGearMod(Gear, t, Grad), Pmax) - Pe = Math.Max(Pe, ENG.FLD.Pdrag(nU)) - - 'torque demand - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - - 'Up/Downshift rpms - nUup = GBX.Shiftpolygons(Gear).fGSnUup(Tq) - nUdown = GBX.Shiftpolygons(Gear).fGSnUdown(Tq) - - 'Max torque - MdMax = Pmax * 1000 / (nU * 2 * Math.PI / 60) - - 'Find highest gear with rpm below Upshift-rpm and with enough torque reserve - If nU < nUup And nU > nUdown And 1 - Tq / MdMax >= GBX.gs_TorqueResv / 100 Then - Exit For - ElseIf nU > nUup And Gear < GBX.GearCount Then - Return Gear + 1 - End If - - Next - - Else - - 'Calculate Start Gear - ' Loop finishes at Gear = 1 (If "Exit For" is not called) - For Gear = GBX.GearCount To 2 Step -1 - - 'rpm at StartSpeed [m/s] - nU = GBX.gs_StartSpeed * 60.0 * GBX.Igetr(0) * GBX.Igetr(Gear) / (2 * VEH.rdyn * Math.PI / 1000) - - If nU > GBX.FLD(Gear).fnUrated Then Continue For - - 'full load - Pmax = GBX.FLD(Gear).Pfull(nU) - - 'Max torque - MdMax = Pmax * 1000 / (nU * 2 * Math.PI / 60) - - 'power demand - Pe = fPeGearMod(Gear, t, GBX.gs_StartSpeed, GBX.gs_StartAcc, Grad) - - 'torque demand - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - - 'torque (limited to max) - TqX = Math.Min(Tq, GBX.FLD(Gear).Tmax) - - 'Up/Downshift rpms - nUup = GBX.Shiftpolygons(Gear).fGSnUup(TqX) - nUdown = GBX.Shiftpolygons(Gear).fGSnUdown(TqX) - - If nU > nUdown And nU >= ENG.Nidle And (1 - Tq / MdMax >= GBX.gs_TorqueResvStart / 100 Or Tq < 0) Then Exit For - - Next - - End If - - Return Gear - End Function - - Private Function fGearTC(ByVal t As Int16, ByVal Grad As Single) As Integer - Dim LastGear As Int16 - Dim tx As Int16 - Dim nU As Single - Dim nUup As Single - Dim nUdown As Single - Dim nUnext As Single - Dim OutOfRpmRange As Boolean - Dim PlusGearLockUp As Boolean - Dim MinusGearTC As Boolean - Dim iRatio As Single - Dim n As Single - Dim TqNext As Single = 0 - Dim TqCurrent As Single - Dim TCaccmin As Single - - - 'First time step (for vehicles with TC always the first gear is used) - If t = 0 Then Return fStartGear(0, Grad) - - 'Always start with first gear from stop - If MODdata.VehState(t - 1) = tVehState.Stopped Then Return 1 - - 'Previous Gear - tx = 1 - LastGear = 0 - Do While LastGear = 0 And t - tx > -1 - LastGear = MODdata.Gear(t - tx) - tx += 1 - Loop - - 'If idling (but no vehicle stop...?) then - If LastGear = 0 Then Return 1 - - If LastGear < GBX.GearCount Then - PlusGearLockUp = True 'Not GBX.IsTCgear(LastGear + 1) - Else - PlusGearLockUp = False - End If - - If LastGear > 1 Then - MinusGearTC = False 'GBX.IsTCgear(LastGear - 1) - Else - MinusGearTC = False - End If - - '2C-to-1C - If MinusGearTC And False Then ' GBX.IsTCgear(LastGear) Then - If fnUout(Vact, LastGear) <= ENG.Nidle Then - Return LastGear - 1 - End If - End If - - If LastGear < GBX.GearCount AndAlso PlusGearLockUp Then - nUnext = Vact * 60.0 * GBX.Igetr(0) * GBX.Igetr(LastGear + 1) / (2 * VEH.rdyn * Math.PI / 1000) - Else - nUnext = 0 - End If - - 'nU - If False Then 'GBX.IsTCgear(LastGear) Then - n = MODdata.TCnu(t - 1) - nU = (Vact * 60.0 * GBX.Igetr(0) * GBX.Igetr(LastGear) / (2 * VEH.rdyn * Math.PI / 1000)) / n - Else - nU = Vact * 60.0 * GBX.Igetr(0) * GBX.Igetr(LastGear) / (2 * VEH.rdyn * Math.PI / 1000) - OutOfRpmRange = (nU >= ENG.Nrated) Or (nU < ENG.Nidle) - 'No gear change 3s after last one -except rpm out of range - If Not OutOfRpmRange AndAlso t - LastGearChange <= GBX.gs_ShiftTime And t > GBX.gs_ShiftTime - 1 Then Return LastGear - End If - - If OutOfRpmRange Then - If (nU >= ENG.Nrated) And LastGear < GBX.GearCount Then - Return LastGear + 1 - ElseIf nU < ENG.Nidle Then - Return LastGear - 1 - End If - End If - - - 'Upshift - If LastGear < GBX.GearCount Then - - TqNext = Math.Min(nPeToM(fnU(Vact, LastGear + 1, False), fPeGearMod(LastGear + 1, t, Grad)), - GBX.FLD(LastGear + 1).Tq(fnU(Vact, LastGear + 1, False))) - nUup = GBX.Shiftpolygons(LastGear).fGSnUup(TqNext) - - TCaccmin = Math.Min(DEV.TCaccmin, MODdata.Vh.a(t)) - - If PlusGearLockUp Then - 'C-to-L / L-to-L - If DEV.TCshiftModeNew Then - If _ - nUnext > nUup AndAlso - fPeGearMod(LastGear + 1, t, MODdata.Vh.V(t), TCaccmin, Grad) <= GBX.FLD(LastGear + 1).Pfull(nUnext) Then - Return LastGear + 1 - End If - Else - If nUnext > nUup AndAlso fPeGearMod(LastGear + 1, t, Grad) <= GBX.FLD(LastGear + 1).Pfull(nUnext) Then - Return LastGear + 1 - End If - End If - Else - 'C-to-C - If LastGear < GBX.GearCount Then - - iRatio = GBX.Igetr(LastGear + 1) / GBX.Igetr(LastGear) - - If DEV.TCshiftModeNew Then - If _ - fnUout(Vact, LastGear + 1) > Math.Min(700, iRatio * (GBX.FLD(LastGear).N80h - 150)) AndAlso - GBX.FLD(LastGear + 1).Pfull(nU * iRatio) >= fPeGearMod(LastGear + 1, t, MODdata.Vh.V(t), TCaccmin, Grad) Then - Return LastGear + 1 - End If - Else - If _ - fnUout(Vact, LastGear + 1) > Math.Min(700, iRatio * (GBX.FLD(LastGear).N80h - 150)) AndAlso - GBX.FLD(LastGear + 1).Pfull(nU * iRatio) > 0.7 * GBX.FLD(LastGear).Pfull(nU) Then - Return LastGear + 1 - End If - End If - - - End If - End If - - End If - - - 'Downshift - If LastGear > 0 Then - - 'Up/Downshift rpms - TqCurrent = Math.Min(nPeToM(fnU(Vact, LastGear, False), fPeGearMod(LastGear, t, Grad)), - GBX.FLD(LastGear).Tq(fnU(Vact, LastGear, False))) - nUdown = GBX.Shiftpolygons(LastGear).fGSnUdown(TqCurrent) - - If MinusGearTC Then - If nU < ENG.Nidle Then - Return LastGear - 1 - End If - Else - If nU < nUdown AndAlso fnU(Vact, LastGear - 1, False) <= ENG.Nrated Then - Return LastGear - 1 - End If - End If - End If - - - Return LastGear - End Function - - Private Function fGearVECTO(ByVal t As Integer, ByVal Grad As Single) As Integer - Dim nU As Single - Dim nnUp As Single - Dim nnDown As Single - Dim Tq As Single - Dim Pe As Single - Dim LastGear As Int16 - Dim Gear As Int16 - Dim MdMax As Single - Dim LastPeNorm As Single - - Dim tx As Int16 - Dim RpmTooHigh As Boolean - Dim RpmTooLow As Boolean - - 'First time step OR first time step after stand still - If t = 0 OrElse MODdata.VehState(t - 1) = tVehState.Stopped Then Return fStartGear(t, Grad) - - - '********* Gear Shift Polygon Model ********* - - 'Previous normalized engine power - LastPeNorm = MODdata.Pe(t - 1) - - 'Previous Gear - tx = 1 - LastGear = 0 - Do While LastGear = 0 And t - tx > -1 - LastGear = MODdata.Gear(t - tx) - tx += 1 - Loop - - 'First time step after stand still - If LastGear = 0 Then Return fStartGear(t, Grad) - - nU = fnUout(Vact, LastGear) - - RpmTooLow = (nU < ENG.Nidle) - RpmTooHigh = ((nU - ENG.Nidle) / (ENG.Nrated - ENG.Nidle) >= 1.2) - - 'No gear change 3s after last one -except rpm out of range - If Not (RpmTooHigh Or RpmTooLow) AndAlso t - LastGearChange <= GBX.gs_ShiftTime And t > GBX.gs_ShiftTime - 1 Then _ - Return LastGear - - 'During start (clutch slipping) no gear shift - If LastClutch = tEngClutch.Slipping And VehState0 = tVehState.Acc Then Return LastGear - - - If Not (RpmTooHigh Or RpmTooLow) Then - - 'Current rpm with previous gear - nU = fnU(Vact, LastGear, Clutch = tEngClutch.Slipping) - - 'Current power demand with previous gear - Pe = Math.Min(fPeGearMod(LastGear, t, Grad), GBX.FLD(LastGear).Pfull(nU)) - Pe = Math.Max(Pe, ENG.FLD.Pdrag(nU)) - - 'Current torque demand with previous gear - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - MdMax = GBX.FLD(LastGear).Pfull(nU, LastPeNorm) * 1000 / (nU * 2 * Math.PI / 60) - - 'Up/Downshift rpms - nnUp = GBX.Shiftpolygons(LastGear).fGSnUup(Tq) - nnDown = GBX.Shiftpolygons(LastGear).fGSnUdown(Tq) - - End If - - - 'Compare rpm with Up/Downshift rpms - If (RpmTooLow OrElse nU <= nnDown) And LastGear > 1 Then - - 'Shift DOWN - Gear = LastGear - 1 - - 'Skip Gears - If GBX.gs_SkipGears AndAlso Gear > 1 Then - - 'Calculate Shift-rpm for lower gear - nU = fnU(Vact, Gear - 1, False) - - 'Continue only if rpm (for lower gear) is above idling - If nU >= ENG.Nidle Then - Pe = Math.Min(fPeGearMod(Gear - 1, t, Grad), GBX.FLD(Gear - 1).Pfull(nU)) - Pe = Math.Max(Pe, ENG.FLD.Pdrag(nU)) - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - nnUp = GBX.Shiftpolygons(Gear - 1).fGSnUup(Tq) - nnDown = GBX.Shiftpolygons(Gear - 1).fGSnUdown(Tq) - - 'Shift down as long as Gear > 1 and rpm is below UpShift-rpm - Do While Gear > 1 AndAlso nU < nnUp - - 'Shift DOWN - Gear -= 1 - - 'Continue only if Gear > 1 - If Gear = 1 Then Exit Do - - 'Calculate Shift-rpm for lower gear - nU = fnU(Vact, Gear - 1, False) - - 'Continue only if rpm (for lower gear) is above idling - If nU < ENG.Nidle Then Exit Do - - Pe = Math.Min(fPeGearMod(Gear - 1, t, Grad), GBX.FLD(Gear - 1).Pfull(nU)) - Pe = Math.Max(Pe, ENG.FLD.Pdrag(nU)) - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - nnUp = GBX.Shiftpolygons(Gear - 1).fGSnUup(Tq) - nnDown = GBX.Shiftpolygons(Gear - 1).fGSnUdown(Tq) - - Loop - - End If - - End If - - ElseIf (RpmTooHigh OrElse nU > nnUp) And LastGear < GBX.GearCount Then - - 'Shift UP - Gear = LastGear + 1 - - 'Skip Gears - If GBX.gs_SkipGears AndAlso Gear < GBX.GearCount Then - - If GBX.TracIntrSi > 0.001 Then - LastPeNorm = fTracIntPower(t, Gear) - End If - - 'Calculate Shift-rpm for higher gear - nU = fnU(Vact, Gear + 1, False) - - Pe = Math.Min(fPeGearMod(Gear + 1, t, Grad), GBX.FLD(Gear + 1).Pfull(nU)) - Pe = Math.Max(Pe, ENG.FLD.Pdrag(nU)) - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - nnUp = GBX.Shiftpolygons(Gear + 1).fGSnUup(Tq) - nnDown = GBX.Shiftpolygons(Gear + 1).fGSnUdown(Tq) - - 'Max Torque - MdMax = GBX.FLD(Gear + 1).Pfull(nU, LastPeNorm) * 1000 / (nU * 2 * Math.PI / 60) - - 'Shift up as long as Torque reserve is okay and Gear < Max-Gear and rpm is above DownShift-rpm - Do While Gear < GBX.GearCount AndAlso 1 - Tq / MdMax >= GBX.gs_TorqueResv / 100 AndAlso nU > nnDown _ -'+ 0.1 * (nnUp - nnDown) - - 'Shift UP - Gear += 1 - - 'Continue only if Gear < Max-Gear - If Gear = GBX.GearCount Then Exit Do - - 'Calculate Shift-rpm for higher gear - nU = fnU(Vact, Gear + 1, False) - - 'Continue only if rpm (for higher gear) is below rated rpm - If nU > ENG.Nrated Then Exit Do - - Pe = Math.Min(fPeGearMod(Gear + 1, t, Grad), GBX.FLD(Gear + 1).Pfull(nU)) - Pe = Math.Max(Pe, ENG.FLD.Pdrag(nU)) - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - nnUp = GBX.Shiftpolygons(Gear + 1).fGSnUup(Tq) - nnDown = GBX.Shiftpolygons(Gear + 1).fGSnUdown(Tq) - - 'Max Torque - MdMax = GBX.FLD(Gear + 1).Pfull(nU, LastPeNorm) * 1000 / (nU * 2 * Math.PI / 60) - - Loop - - End If - - Else - - 'Keep last gear - Gear = LastGear - - 'Shift UP inside shift polygons - If GBX.gs_ShiftInside And LastGear < GBX.GearCount Then - - 'Calculate Shift-rpm for higher gear - 'old: nU = fnU(Vact, Gear + 1, False) - nU = fnUout(Vact, Gear + 1) - - 'Continue only if rpm (for higher gear) is below rated rpm - If nU > ENG.Nidle AndAlso nU <= ENG.Nrated Then - Pe = Math.Min(fPeGearMod(Gear + 1, t, Grad), GBX.FLD(Gear + 1).Pfull(nU)) - Pe = Math.Max(Pe, ENG.FLD.Pdrag(nU)) - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - nnUp = GBX.Shiftpolygons(Gear + 1).fGSnUup(Tq) - nnDown = GBX.Shiftpolygons(Gear + 1).fGSnUdown(Tq) - - 'Max Torque - MdMax = GBX.FLD(Gear + 1).Pfull(nU, LastPeNorm) * 1000 / (nU * 2 * Math.PI / 60) - - 'Shift up as long as Torque reserve is okay and Gear < Max-Gear and rpm is above DownShift-rpm - Do While Gear < GBX.GearCount AndAlso 1 - Tq / MdMax >= GBX.gs_TorqueResv / 100 AndAlso nU > nnDown _ -'+ 0.1 * (nnUp - nnDown) - - 'Shift UP - Gear += 1 - - 'Continue only if Gear < Max-Gear - If Gear = GBX.GearCount Then Exit Do - - 'Calculate Shift-rpm for higher gear - nU = fnU(Vact, Gear + 1, False) - - 'Continue only if rpm (for higher gear) is below rated rpm - If nU > ENG.Nrated Then Exit Do - - Pe = Math.Min(fPeGearMod(Gear + 1, t, Grad), GBX.FLD(Gear + 1).Pfull(nU)) - Pe = Math.Max(Pe, ENG.FLD.Pdrag(nU)) - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - nnUp = GBX.Shiftpolygons(Gear + 1).fGSnUup(Tq) - nnDown = GBX.Shiftpolygons(Gear + 1).fGSnUdown(Tq) - - 'Max Torque - MdMax = GBX.FLD(Gear + 1).Pfull(nU, LastPeNorm) * 1000 / (nU * 2 * Math.PI / 60) - - Loop - - - End If - - End If - - End If - -lb10: - '*** Error-Msg-Check *** - 'Current rpm - nU = fnU(Vact, Gear, Clutch = tEngClutch.Slipping) - 'Current power demand - Pe = Math.Min(fPeGearMod(Gear, t, Grad), GBX.FLD(Gear).Pfull(nU)) - Pe = Math.Max(Pe, ENG.FLD.Pdrag(nU)) - 'Current torque demand - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - - 'If GearCorrection is OFF then return here - Return Gear - End Function - - Private Function fGearByU(ByVal nU As Single, ByVal V As Single) As Integer - Dim Dif As Single - Dim DifMin As Single - Dim g As Int16 - Dim g0 As Integer - DifMin = 9999 - For g = 1 To GBX.GearCount - Dif = Math.Abs(GBX.Igetr(g) - nU * (2 * VEH.rdyn * Math.PI) / (1000 * V * 60.0 * GBX.Igetr(0))) - If Dif <= DifMin Then - g0 = g - DifMin = Dif - End If - Next - Return g0 - End Function - - 'Function calculating the Power easily for Gear-shift-model - Private Function fPeGearModvD(ByVal t As Integer, ByVal Grad As Single) As Single - Return fPwheel(t, Grad) - End Function - - Private Function fPeGearMod(ByVal Gear As Integer, ByVal t As Integer, ByVal V As Single, ByVal a As Single, - ByVal Grad As Single) As Single - Dim PaM As Single - Dim nU As Single - Dim Pwheel As Single - - Pwheel = fPwheel(t, V, a, Grad) - - nU = fnU(V, Gear, False) - - If t = 0 Then - PaM = 0 - Else - PaM = fPaMot(nU, MODdata.nU(t - 1)) - End If - - - If Clutch = tEngClutch.Closed Then - Return (Pwheel + fPlossGB(Pwheel, V, Gear, True) + fPlossDiff(Pwheel, V, True) + fPaG(V, a) + fPaux(t, nU) + PaM) - Else 'Clutch = tEngClutch.Slipping - Return _ - ((Pwheel + fPlossGB(Pwheel, V, Gear, True) + fPlossDiff(Pwheel, V, True) + fPaG(V, a)) / ClutchEta + fPaux(t, nU) + - PaM) - End If - End Function - - Private Function fPeGearMod(ByVal Gear As Integer, ByVal t As Integer, ByVal Grad As Single) As Single - Return fPeGearMod(Gear, t, MODdata.Vh.V(t), MODdata.Vh.a(t), Grad) - End Function - - -#End Region - -#Region "Engine Speed Calculation" - - Private Function fnn(ByVal V As Single, ByVal Gear As Integer, ByVal ClutchSlip As Boolean) As Single - Return (fnU(V, Gear, ClutchSlip) - ENG.Nidle) / (ENG.Nrated - ENG.Nidle) - End Function - - Private Function fnU(ByVal V As Single, ByVal Gear As Integer, ByVal ClutchSlip As Boolean) As Single - Dim akn As Single - Dim U As Single - U = fnUout(V, Gear) - If U < ENG.Nidle Then U = ENG.Nidle - If ClutchSlip Then - akn = ClutchNorm / ((ENG.Nidle + ClutchNorm * (ENG.Nrated - ENG.Nidle)) / ENG.Nrated) - U = (akn * U / ENG.Nrated) * (ENG.Nrated - ENG.Nidle) + ENG.Nidle - End If - Return U - End Function - - Private Function fV(ByVal nU As Single, ByVal Gear As Integer) As Single - Return nU * (2 * VEH.rdyn * Math.PI / 1000) / (60.0 * GBX.Igetr(0) * GBX.Igetr(Gear)) - End Function - - Private Function fnUout(ByVal V As Single, ByVal Gear As Integer) As Single - Return V * 60.0 * GBX.Igetr(0) * GBX.Igetr(Gear) / (2 * Math.PI * VEH.rdyn / 1000) - End Function - -#End Region - -#Region "Power Calculation" - - '--------------Power before Diff = At Wheel ------------- - Private Function fPwheel(ByVal t As Integer, ByVal Grad As Single) As Single - If PwheelVorg Then - Return MODdata.Vh.Pwheel(t) - Else - Return _ - fPr(MODdata.Vh.V(t), Grad) + fPair(MODdata.Vh.V(t), t) + fPaFZ(MODdata.Vh.V(t), MODdata.Vh.a(t)) + - fPs(MODdata.Vh.V(t), Grad) - End If - End Function - - Private Function fPwheel(ByVal t As Integer, ByVal v As Single, ByVal a As Single, ByVal Grad As Single) As Single - Return fPr(v, Grad) + fPair(v, t) + fPaFZ(v, a) + fPs(v, Grad) - End Function - - '----------------Rolling-resistance---------------- - Private Function fPr(ByVal v As Single, ByVal Grad As Single) As Single - Return CSng(Math.Cos(Math.Atan(Grad * 0.01)) * (VEH.Loading + VEH.Mass + VEH.MassExtra) * 9.81 * VEH.Fr0 * v * 0.001) - End Function - - '----------------Drag-resistance---------------- - Private Function fPair(ByVal v As Single, ByVal t As Integer) As Single - Dim vair As Single - Dim Vkmh As Single - Dim CdA As Single - - Vkmh = v * 3.6 - - Select Case VEH.CdMode - - Case tCdMode.ConstCd0 - vair = v - CdA = VEH.CdA - - Case tCdMode.CdOfVeng - vair = v - CdA = VEH.CdA_Y(Vkmh) * VEH.CdA - - Case tCdMode.CdOfVdecl - vair = v - CdA = VEH.CdA_Y(Vkmh) - - Case Else 'tCdType.CdOfBeta - vair = MODdata.Vh.VairVres(t) - CdA = VEH.CdA_Y(Math.Abs(MODdata.Vh.VairBeta(t))) * VEH.CdA - - End Select - - Return CSng((CdA * Cfg.AirDensity / 2 * ((vair) ^ 2)) * v * 0.001) - End Function - - '--------Vehicle Acceleration-capability(Beschleunigungsleistung) -------- - Private Function fPaFZ(ByVal v As Single, ByVal a As Single) As Single - Return CSng(((VEH.Mass + VEH.MassExtra + VEH.MRed + VEH.Loading) * a * v) * 0.001) - End Function - - Private Function fPaMotSimple(ByVal t As Integer, ByVal Gear As Integer, ByVal v As Single, ByVal a As Single) _ - As Single - Return ((ENG.I_mot * (GBX.Igetr(0) * GBX.Igetr(Gear) / (VEH.rdyn / 1000)) ^ 2) * a * v) * 0.001 - End Function - - Public Function fPaMot(ByVal nU As Single, ByVal nUBefore As Single) As Single - If GBX.TCon Then - Return ((ENG.I_mot + GBX.TCinertia) * (nU - nUBefore) * 0.01096 * ((nU + nUBefore) / 2)) * 0.001 - Else - Return (ENG.I_mot * (nU - nUBefore) * 0.01096 * ((nU + nUBefore) / 2)) * 0.001 - End If - End Function - - '----------------Slope resistance ---------------- - Private Function fPs(ByVal v As Single, ByVal Grad As Single) As Single - Return CSng(((VEH.Loading + VEH.Mass + VEH.MassExtra) * 9.81 * Math.Sin(Math.Atan(Grad * 0.01)) * v) * 0.001) - End Function - - '----------------Auxillaries(Nebenaggregate) ---------------- - - 'NOTES TO SELF FOR MONDAY - - 'IF WE HANDLE THE MODEL HERE, THEN WE NEED TO DISCRIMINATE IF TO SINGLE STEP OR NOT BECAUSE WE DONT NEED IT IN PREP - - 'ALSO NEED TO GET VEHICLE MASS AND OTHER THINGS WHEN WE GENERATE THE auxModel in AAUX GLOBAL, DONT HAVE THEM YET - - 'ENSURE WE ARE ALSO CREATING THIS MODEL IN CYCLE OR AT LEAST CHECK TO SEE IF WE NEED TO, PERHAPS NOT AS POWER - 'CALCS ARE DONE DURING PRE AND ONLY STEPPED IN CYCLE SO IT MAY BE OK. - - - 'AA-TB-IMPLEMENT - - Public Function fPaux(ByVal t As Integer, ByVal nU As Single) As Single - - 'AA-TB ( RAFAEL ) - 'This function descriminates between Advanced and Auxiliaries and if in Advanced only calculate the - 'Fuel during Calc as we conly create the AdvancedAuxiliaries object at the beginning of Pre-Run and do - 'Not Re-Create it again for Calc, simply turn on Aggregation using Cycle step. - ' - 'If not in Advanced mode ( CLASSIC ), then use the original formulae. - Dim message As String = String.Empty - Dim power As Single - - If VECTO_Global.VEC.AuxiliaryAssembly = "CLASSIC" Then - - Return CSng(MODdata.Vh.Padd(t) + VEC.PauxSum(t, nU)) - - Else - - Try - - mAAUX_Global.advancedAuxModel.Signals.ClutchEngaged = mAAUX_Global.ClutchEngaged - mAAUX_Global.advancedAuxModel.Signals.EngineDrivelinePower = (mAAUX_Global.EngineDrivelinePower * 1000).SI(Of Watt)() - mAAUX_Global.advancedAuxModel.Signals.EngineDrivelineTorque = - mAAUX_Global.EngineDrivelineTorque.SI(Of NewtonMeter)() - mAAUX_Global.advancedAuxModel.Signals.EngineMotoringPower = (mAAUX_Global.EngineMotoringPower * 1000).SI(Of Watt)() - mAAUX_Global.advancedAuxModel.Signals.EngineSpeed = mAAUX_Global.EngineSpeed.RPMtoRad() - mAAUX_Global.advancedAuxModel.Signals.PreExistingAuxPower = (mAAUX_Global.PreExistingAuxPower * 1000).SI(Of Watt)() - mAAUX_Global.advancedAuxModel.Signals.Idle = mAAUX_Global.Idle - mAAUX_Global.advancedAuxModel.Signals.InNeutral = mAAUX_Global.InNeutral - mAAUX_Global.advancedAuxModel.Signals.RunningCalc = mAAUX_Global.RunningCalc - mAAUX_Global.advancedAuxModel.Signals.InternalEnginePower = (mAAUX_Global.Internal_Engine_Power * 1000).SI(Of Watt)() - - 'Power coming out of Advanced Model is in Watts. - power = PreExistingAuxPower + (advancedAuxModel.AuxiliaryPowerAtCrankWatts.Value() / 1000) - - 'Glenn: Comment the previous line and uncomment the next line to include the classic auxilaries power togeher with the advanced auxiliary power. - 'power = VEC.PauxSum(t, nU) + (advancedAuxModel.AuxiliaryPowerAtCrankWatts / 1000) - - Catch ex As Exception - - 'EXIT THIS IS A FAILURE - WorkerMsg(tMsgID.Err, "Error in Advanced Power Calc :" & ex.Message, "paux") - Return False - - End Try - - Return power - - End If - End Function - - '-------------------Transmission(Getriebe)------------------- - Private Function fPlossGB(ByVal PvD As Single, ByVal V As Single, ByVal Gear As Integer, ByVal TrLossApprox As Boolean) _ - As Single - Dim Pdiff As Single - Dim Prt As Single - Dim P As Single - Dim nU As Single - - If Gear = 0 Then Return 0 - - nU = (60 * V) / (2 * VEH.rdyn * Math.PI / 1000) * GBX.Igetr(0) * GBX.Igetr(Gear) - - 'Pdiff - Pdiff = fPlossDiff(PvD, V, TrLossApprox) - - If VEH.RtType = tRtType.Secondary Then - Prt = fPlossRt(V, Gear) - Else - Prt = 0 - End If - - '***Differential - ' Power before Transmission; after Differential and Retarder (if Type=Secondary) - P = PvD + Pdiff + Prt - - Return Math.Max(GBX.IntpolPeLoss(Gear, nU, P, TrLossApprox), 0) - End Function - - Private Function fPlossDiff(ByVal PvD As Single, ByVal V As Single, ByVal TrLossApprox As Boolean) As Single - - '***Differential - ' Power before Differential - Return Math.Max(GBX.IntpolPeLoss(0, (60 * V) / (2 * VEH.rdyn * Math.PI / 1000) * GBX.Igetr(0), PvD, TrLossApprox), 0) - End Function - - Private Function fPlossGBfwd(ByVal PeICE As Single, ByVal V As Single, ByVal Gear As Integer, - ByVal TrLossApprox As Boolean) As Single - Dim nU As Single - Dim Prt As Single - - If Gear = 0 Then Return 0 - - If VEH.RtType = tRtType.Primary Then - Prt = fPlossRt(V, Gear) - Else - Prt = 0 - End If - - nU = (60 * V) / (2 * VEH.rdyn * Math.PI / 1000) * GBX.Igetr(0) * GBX.Igetr(Gear) - - Return Math.Max(GBX.IntpolPeLossFwd(Gear, nU, PeICE + Prt, TrLossApprox), 0) - End Function - - Private Function fPlossDiffFwd(ByVal PeIn As Single, ByVal V As Single, ByVal TrLossApprox As Boolean) As Single - Dim nU As Single - - nU = (60 * V) / (2 * VEH.rdyn * Math.PI / 1000) * GBX.Igetr(0) - - Return Math.Max(GBX.IntpolPeLossFwd(0, nU, PeIn, TrLossApprox), 0) - End Function - - Private Function fPlossRt(ByVal Vist As Single, ByVal Gear As Integer) As Single - Return VEH.RtPeLoss(Vist, Gear) - End Function - - '----------------Gearbox inertia ---------------- - Private Function fPaG(ByVal V As Single, ByVal a As Single) As Single - Dim Mred As Single - Mred = GBX.GbxInertia * (GBX.Igetr(0) / (VEH.rdyn / 1000)) ^ 2 - Return (Mred * a * V) * 0.001 - End Function - -#End Region -End Class - diff --git a/VECTO/MODcalc/cPowerRL.vb b/VECTO/MODcalc/cPowerRL.vb deleted file mode 100644 index 5d838340e7f248565c324216ff52de811a30635e..0000000000000000000000000000000000000000 --- a/VECTO/MODcalc/cPowerRL.vb +++ /dev/null @@ -1,2456 +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 - -Public Class cPowerRL - - Private ClutchNorm As Single 'Normalized clutch speed - Private ClutchEta As Single 'clutch efficiency - - 'Settings - Private GearInput As Boolean - Private RpmInput As Boolean - - - 'Per-second Data - Private Clutch As tEngClutch - Private VehState0 As tVehState - Private EngState0 As tEngState - Private Pplus As Boolean - Private Pminus As Boolean - Private GVmax As Single - Private Pwheel As Single - Private Vact As Single - Private aact As Single - - 'Interruption of traction - Private TracIntrI As Integer - Private TracIntrIx As Integer - Private TracIntrOn As Boolean - Private TracIntrTurnOff As Boolean - Private TracIntrGear As Integer - - Private LastGearChange As Integer - Private LastClutch As tEngClutch - - Public Positions As New List(Of Short) - - Private EngSideInertia As Single - - Public Function PreRun() As Boolean - Dim i As Integer - Dim i0 As Integer - Dim Vh As cVh - Dim P As Single - Dim Pmin As Single - Dim PlossGB As Single - Dim PlossDiff As Single - Dim PlossRt As Single - Dim PaMot As Single - Dim PaGetr As Single - Dim Pkup As Single - Dim Paux As Single - Dim Gear As Integer - Dim nU As Single - Dim vCoasting As Single - Dim Vmax As Single - Dim Vmin As Single - Dim Tlookahead As Integer - Dim vset1 As Single - Dim vset2 As Single - Dim j As Integer - Dim t As Integer - Dim adec As Single - Dim LookAheadDone As Boolean - Dim aCoasting As Single - Dim Gears As New List(Of Integer) - Dim vRollout As Single - Dim ProgBarShare As Int16 - Dim ProgBarLACpart As Int16 - Dim dist As New List(Of Double) - Dim LastnU As Single = 0 - - Dim MsgSrc As String - - - MsgSrc = "Power/PreRun" - - 'Check Input - If VEC.LookAheadOn AndAlso VEC.a_lookahead >= 0 Then - WorkerMsg(tMsgID.Err, "Lookahead deceleration invalid! Value must be below zero.", MsgSrc) - Return False - End If - - If VEC.OverSpeedOn And VEC.EcoRollOn Then - WorkerMsg(tMsgID.Err, "Overrun and Ecoroll can't be enabled both at the same time!", MsgSrc) - Return False - End If - - ' Initialize - Vh = MODdata.Vh - GearInput = DRI.Gvorg - RpmInput = DRI.Nvorg - - If VEC.EcoRollOn Or VEC.OverSpeedOn Then - If VEC.LookAheadOn Then - ProgBarShare = 4 - ProgBarLACpart = 2 - Else - ProgBarShare = 2 - ProgBarLACpart = 0 '0=OFF - End If - Else - If VEC.LookAheadOn Then - ProgBarShare = 2 - ProgBarLACpart = 1 - Else - ProgBarShare = 0 - ProgBarLACpart = 0 '0=OFF - End If - End If - - Positions = New List(Of Short) - - If GBX.TCon Then - EngSideInertia = ENG.I_mot + GBX.TCinertia - Else - EngSideInertia = ENG.I_mot - End If - - 'Distance over time - dist.Add(0) - For i = 1 To MODdata.tDim - dist.Add(dist(i - 1) + Vh.V(i)) - Next - - - 'Generate Positions List - For i = 0 To MODdata.tDim - Positions.Add(0) - Next - - '*** Positions *** - '0... Normal (Cruise/Acc) - '1... Brake or Coasting - '2... Brake corrected with v(a) (.vacc file) - '3... Coasting - '4... Eco-Roll - - 'Overspeed / Eco-Roll Loop (Forward) - i = -1 - Do - i += 1 - - 'Check if cancellation pending - If VECTOworker.CancellationPending Then Return True - - Vact = Vh.V(i) - aact = Vh.a(i) - - 'Determine Driving-state ------------------------- - Pplus = False - Pminus = False - - If Vact < 0.0001 Then - VehState0 = tVehState.Stopped - Else - If aact >= 0.01 Then - VehState0 = tVehState.Acc - ElseIf aact < -0.01 Then - VehState0 = tVehState.Dec - Else - VehState0 = tVehState.Cruise - End If - End If - - - 'Wheel-Power - Pwheel = fPwheel(i, Vh.fGrad(dist(i))) - - Select Case Pwheel - Case Is > 0.0001 - Pplus = True - Case Is < -0.0001 - Pminus = True - Case Else - P = 0 - End Select - - 'Gear - If VehState0 = tVehState.Stopped Then - Gear = 0 - - 'Engine Speed - If RpmInput Then - nU = MODdata.nUvorg(i) - Else - nU = ENG.Nidle - End If - - Else - - If GearInput Then - Gear = Math.Min(Vh.GearVorg(i), GBX.GearCount) - Else - Gear = fFastGearCalc(Vact, Pwheel) - End If - - 'Engine Speed - If RpmInput Then - nU = MODdata.nUvorg(i) - Else - nU = fnU(Vact, Gear, False) - End If - - End If - - 'ICE-inertia - If i = 0 Then - PaMot = 0 - Else - PaMot = fPaMot(nU, LastnU) - End If - - - - 'AA-TB/RL - '********************* ADVANCED AUXILIARIES START ***************************** - - 'Dim ClutchEngaged As Boolean - 'Dim EngineDrivelinePower As Single - 'Dim EngineDrivelineTorque As Single - 'Dim EngineMotoringPower As Single - 'Dim EngineSpeed As Integer - 'Dim PreExistingAuxPower As Single - 'Dim Idle As Boolean - 'Dim InNeutral As Boolean - - - 'Calculate powertrain losses => power at clutch - If Pplus Or Pminus Then - PlossGB = fPlossGB(Pwheel, Vact, Gear, True) - PlossDiff = fPlossDiff(Pwheel, Vact, True) - PlossRt = fPlossRt(Vact, Gear) - PaGetr = fPaG(Vact, aact) - Pkup = Pwheel + PlossGB + PlossDiff + PaGetr + PlossRt - Else - Pkup = 0 - End If - - 'Clutch closed/engaged = True - AAUX_Gobal.ClutchEngaged = (Gear > 0) - - AAUX_Gobal.Idle = (Gear = 0 And Not Pplus And Not Pminus) - - AAUX_Gobal.InNeutral = (Gear = 0) - - 'Driveline Power = required power at clutch = power at wheels plus powertrain losses - '[kW] - AAUX_Gobal.EngineDrivelinePower = Pkup - - '[1/min] - AAUX_Gobal.EngineSpeed = nU - - '[Nm] (using Power => Torque conversion) - AAUX_Gobal.EngineDrivelineTorque = nPeToM(EngineSpeed, EngineDrivelinePower) - - 'Motoring power (< 0 !!!) - '[kW] - AAUX_Gobal.EngineMotoringPower = FLD(Gear).Pdrag(EngineSpeed) - - 'Additional aux power from driving cycle (optional user input) - '[kW] - AAUX_Gobal.PreExistingAuxPower = MODdata.Vh.Padd(t) - - - 'TODO: HOW TO ALTER HERE FOR CLASSIC or ADVANCED - 'Total aux power - '[kW] - Paux = PreExistingAuxPower + fPaux(t, EngineSpeed) - - 'Internal Engine Power (Pclutch plus Aux plus Inertia) - P = Pkup + Paux + PaMot - - 'AA-TB/RL************** ADVANCED AUXILIARIES END *************************** - - - - 'Full load / motoring - Pmin = FLD(Gear).Pdrag(nU) - - If Vact >= VEC.vMin / 3.6 Then - - If VEC.EcoRollOn Then - - 'Secondary Progressbar - ProgBarCtrl.ProgJobInt = CInt((100 / ProgBarShare) * i / MODdata.tDim) - - If Pwheel < 0 Or (i > 0 AndAlso Vh.EcoRoll(i - 1)) Then - - Vmax = MODdata.Vh.Vsoll(i) + VEC.OverSpeed / 3.6 - Vmin = Math.Max(0, MODdata.Vh.Vsoll(i) - VEC.UnderSpeed / 3.6) - vRollout = fRolloutSpeed(i, 1, Vh.fGrad(dist(i))) - - If vRollout < Vmin Then - - 'Eco-Roll deactivated - - ElseIf vRollout <= Vmax Then - - If 2 * vRollout - Vh.V0(i) > Vmax Then - Vh.SetSpeed0(i, Vmax) - ElseIf 2 * vRollout - Vh.V0(i) < Vmin Then - Vh.SetSpeed0(i, Vmin) - Else - Vh.SetSpeed(i, vRollout) - 'Vh.SetAcc(i, aRollout) - End If - - Positions(i) = 4 - - 'Mark position for Calc - Vh.EcoRoll(i) = True - - Else - - If 2 * Vmax - Vh.V0(i) >= Vmax Then - Vh.SetSpeed0(i, Vmax) - Else - Vh.SetSpeed(i, Vmax) - End If - - Positions(i) = 1 - - 'Do NOT mark position for Calc => Motoring NOT Idling - 'Vh.EcoRoll(i) = True - - End If - - - End If - - Else - - If P < Pmin Then - - If VEC.OverSpeedOn Then - - 'Secondary Progressbar - ProgBarCtrl.ProgJobInt = CInt((100 / ProgBarShare) * i / MODdata.tDim) - - vCoasting = fCoastingSpeed(i, dist(i), Gear) - Vmax = MODdata.Vh.Vsoll(i) + VEC.OverSpeed / 3.6 - - If vCoasting <= Vmax Then - - If 2 * vCoasting - Vh.V0(i) > Vmax Then - Vh.SetSpeed0(i, Vmax) - Else - Vh.SetSpeed(i, vCoasting) - End If - - Else - - If 2 * Vmax - Vh.V0(i) > Vmax Then - Vh.SetSpeed0(i, Vmax) - Else - Vh.SetSpeed(i, Vmax) - End If - - End If - - End If - - End If - - End If - - End If - - LastnU = nU - - Gears.Add(Gear) - - Loop Until i >= MODdata.tDim - - - 'Look Ahead & Limit Acc (Backward) - - 'Mark Brake Positions - For i = MODdata.tDim To 1 Step -1 - If Vh.V(i - 1) - Vh.V(i) > 0.0001 And Not Positions(i) = 4 Then Positions(i) = 1 - Next - - 'Look-Ahead Coasting - i = MODdata.tDim + 1 - Do - i -= 1 - - 'Secondary Progressbar - If ProgBarLACpart > 0 Then ProgBarCtrl.ProgJobInt = CInt((100 / ProgBarShare) * (MODdata.tDim - i) / MODdata.tDim + (ProgBarLACpart - 1) * (100 / ProgBarShare)) - - 'Check if cancellation pending - If VECTOworker.CancellationPending Then Return True - - If Positions(i) = 1 Then - vset2 = Vh.V(i) - For j = i To 0 Step -1 - If Positions(j) = 0 Or Positions(j) = 4 Then - vset1 = Vh.V(j) - Exit For - End If - Next - - 'Calc Coasting-Start time step - If VEC.LookAheadOn Then - Tlookahead = CInt((vset2 - vset1) / VEC.a_lookahead) - t = Math.Max(0, i - Tlookahead) - End If - - 'Check if target-speed change inside of Coasting Phase - For i0 = i To t Step -1 - If i0 = 0 Then Exit For - If Vh.Vsoll(i0) - Vh.Vsoll(i0 - 1) > 0.0001 Then - t = Math.Min(i0 + 1, i) - Exit For - End If - Next - - LookAheadDone = False - - 'Limit deceleration - adec = VEC.aDesMin(Vact) - If Vh.a(i) < adec Then Vh.SetMinAccBackw(i) - - i0 = i - - 'If vehicle stops too early reduce coasting time, i.e. set Coasting-Start later - If VEC.LookAheadOn Then - Do While i0 > t AndAlso fCoastingSpeed(t, dist(t), Gears(t), i0 - t) < Vh.V(i0) - t += 1 - Loop - End If - - - Do - i -= 1 - aact = Vh.a(i) - Vact = Vh.V(i) - adec = VEC.aDesMin(Vact) - - If aact < adec Then - Vh.SetMinAccBackw(i) - Positions(i) = 2 - Else - 'Coasting (Forward) - If VEC.LookAheadOn And Vact >= VEC.vMinLA / 3.6 Then - - For j = t To i0 - Vact = Vh.V(j) - vCoasting = fCoastingSpeed(j, dist(j), Gears(j)) - aCoasting = (2 * vCoasting - Vh.V0(j)) - Vh.V0(j) - If vCoasting < Vact And aCoasting >= VEC.aDesMin(Vact) Then - 'If Vrollout < Vist Then - Vh.SetSpeed(j, vCoasting) - Positions(j) = 3 - ' Vh.NoDistCorr(j) = True - Else - Exit For - End If - Next - - End If - - LookAheadDone = True - End If - - Loop Until LookAheadDone Or i = 0 - - i = i0 - - End If - - Loop Until i = 0 - - Return True - - End Function - - Public Function Calc() As Boolean - - Dim i As Integer - Dim M As Single - Dim nU As Single - Dim omega_p As Single - Dim omega1 As Single - Dim omega2 As Single - Dim nUx As Single - Dim PminX As Single - - Dim jz As Integer - - 'Start/Stop Control - Dim StStOff As Boolean - Dim StStTx As Single - Dim StStDelayTx As Integer - Dim StStPossible As Boolean - - Dim Vh As cVh - - Dim Gear As Integer - - Dim P As Single - Dim Pclutch As Single - Dim PaMot As Single - Dim PaGbx As Single - Dim Pmin As Single - Dim Pmax As Single - Dim Paux As Single - Dim Pbrake As Single - Dim PlossGB As Single - Dim PlossDiff As Single - Dim PlossRt As Single - Dim PlossTC As Single - Dim GVset As Boolean - Dim Vrollout As Single - Dim SecSpeedRed As Integer - Dim FirstSecItar As Boolean - Dim TracIntrIs As Single - Dim amax As Single - Dim ProgBarShare As Int16 - Dim LastPmax As Single - Dim dist As Double - Dim dist0 As Double - - Dim MsgSrc As String - - MsgSrc = "Power/Calc" - - 'Abort if no speed given - If Not DRI.Vvorg Then - WorkerMsg(tMsgID.Err, "Driving cycle is not valid! Vehicle Speed required.", MsgSrc) - Return False - End If - - 'Messages - If Not Cfg.DistCorr Then WorkerMsg(tMsgID.Warn, "Distance Correction is disabled!", MsgSrc) - - ' Initialize - Vh = MODdata.Vh - - If VEC.EcoRollOn Or VEC.OverSpeedOn Or VEC.LookAheadOn Then - ProgBarShare = 2 - Else - ProgBarShare = 1 - End If - - If GBX.TCon Then - EngSideInertia = ENG.I_mot + GBX.TCinertia - Else - EngSideInertia = ENG.I_mot - End If - - If Cfg.GnUfromCycle Then - GearInput = DRI.Gvorg - RpmInput = DRI.Nvorg - If Not Cfg.BatchMode Then - If GearInput Then WorkerMsg(tMsgID.Normal, "Using gears from driving cycle", MsgSrc) - If RpmInput Then WorkerMsg(tMsgID.Normal, "Using rpm from driving cycle", MsgSrc) - End If - Else - If (DRI.Gvorg Or DRI.Nvorg) And Not Cfg.BatchMode Then WorkerMsg(tMsgID.Warn, "Gears/rpm from driving cycle ignored.", MsgSrc) - GearInput = False - RpmInput = False - End If - StStOff = False - StStTx = 0 - StStDelayTx = 0 - SecSpeedRed = 0 - - If GBX.TracIntrSi < 0.001 Then - TracIntrI = 0 - Else - TracIntrI = CInt(Math.Max(1, Math.Round(GBX.TracIntrSi, 0, MidpointRounding.AwayFromZero))) - End If - TracIntrIx = 0 - TracIntrOn = False - TracIntrTurnOff = False - - ClutchNorm = 0.03 - ClutchEta = 1 - - - LastClutch = tEngClutch.Opened - - 'Theoretical maximum speed [m/s] - set to Speed ​​at 1.2 x Nominal-Revolutions in top-Gear - GVmax = 1.2 * ENG.Nrated * 2 * VEH.rdyn * Math.PI / (1000 * GBX.Igetr(0) * GBX.Igetr(GBX.GearCount) * 60) - - dist = 0 - dist0 = 0 - - jz = -1 - - '*********************************************************************************************** - '*********************************** Time-loop **************************************** - '*********************************************************************************************** - - Do - jz += 1 - - MODdata.ModErrors.ResetAll() - - GVset = False - FirstSecItar = True - - 'Secondary Progressbar - ProgBarCtrl.ProgJobInt = CInt((100 / ProgBarShare) * jz / MODdata.tDim + (100 - 100 / ProgBarShare)) - - - ' Determine State -lbGschw: - - 'Reset the second by second Errors - MODdata.ModErrors.GeschRedReset() - - 'Calculate Speed​/Acceleration ------------------- - 'Now through DRI-class - Vact = Vh.V(jz) - aact = Vh.a(jz) - - 'distance - dist = dist0 + Vact - - StStPossible = False - EngState0 = tEngState.Undef - - 'If Speed over Top theoretical Speed => Reduce - If Vact > GVmax + 0.0001 And Not GVset Then - Vh.SetSpeed0(jz, GVmax) - GVset = True - GoTo lbGschw - End If - - 'Check if Acceleration is too high - amax = VEC.aDesMax(Vact) - - If amax < 0.0001 Then - WorkerMsg(tMsgID.Err, "aDesMax(acc) invalid! v= " & Vact & ", aDesMax(acc) =" & amax, MsgSrc) - Return False - End If - - If aact > amax + 0.0001 Then - - 'Vh.SetSpeed0(jz, Vh.V0(jz) + amax) - Vh.SetMaxAcc(jz) - - GoTo lbGschw - - - ElseIf FirstSecItar Then 'this is necessary to avoid speed reduction failure - - 'Check whether Deceleration too high - amax = VEC.aDesMin(Vact) - If amax > -0.001 Then - WorkerMsg(tMsgID.Err, "aDesMax(dec) invalid! v= " & Vact & ", aDesMax(dec) =" & amax, MsgSrc) - Return False - End If - If aact < amax - 0.0001 And Not Vh.EcoRoll(jz) Then - Vh.SetSpeed0(jz, Vh.V0(jz) + amax) - GoTo lbGschw - End If - - - End If - - - 'From Power ----- - If aact < 0 Then - If (Vact < 0.025) Then - 'Vh.SetSpeed(jz, 0) - 'GoTo lbGschw - Vact = 0 - End If - End If - '--------------- - - 'Determine Driving-state ------------------------- - Pplus = False - Pminus = False - - If Vact < 0.0001 Then - VehState0 = tVehState.Stopped - Else - If aact >= 0.01 Then - VehState0 = tVehState.Acc - ElseIf aact < -0.01 Then - VehState0 = tVehState.Dec - Else - VehState0 = tVehState.Cruise - End If - End If - - Pwheel = fPwheel(jz, Vh.fGrad(dist)) - - Select Case Pwheel - Case Is > 0.0001 - Pplus = True - Case Is < -0.0001 - Pminus = True - End Select - - 'Eco-Roll Speed Correction (because PreRun speed profile might still be too high or speed might generally be too low) - If Vh.EcoRoll(jz) AndAlso Vact > MODdata.Vh.Vsoll(jz) - VEC.UnderSpeed / 3.6 AndAlso Not VehState0 = tVehState.Stopped AndAlso Pplus Then - If Not Vh.ReduceSpeed(jz, 0.9999) Then - WorkerMsg(tMsgID.Err, "Engine full load too low for vehicle start (speed reduction failed) !", MsgSrc & "/t= " & jz + 1) - Return False - End If - FirstSecItar = False - GoTo lbGschw - End If - - - '************************************ Gear selection ************************************ - If VehState0 = tVehState.Stopped Or TracIntrOn Then - - If TracIntrTurnOff And Not VehState0 = tVehState.Stopped Then - - Gear = TracIntrGear - - If Not GBX.TCon AndAlso fnn(Vact, Gear, False) < ClutchNorm And Pplus Then - Clutch = tEngClutch.Slipping - Else - Clutch = tEngClutch.Closed - End If - - Else - Gear = 0 - Clutch = tEngClutch.Opened - End If - - Else - - 'Check whether Clutch will slip (important for Gear-shifting model): - If Not GBX.TCon AndAlso fnn(Vact, 1, False) < ClutchNorm And Pplus Then - Clutch = tEngClutch.Slipping - Else - Clutch = tEngClutch.Closed - End If - - If GearInput Then - 'Gear-settings - Gear = Math.Min(Vh.GearVorg(jz), GBX.GearCount) - ElseIf RpmInput Then - 'Revolutions-setting - Gear = fGearByU(MODdata.nUvorg(jz), Vact) - ElseIf GBX.GearCount = 1 Then - Gear = 1 - Else - - 'Gear-shifting Model - If GBX.TCon Then - Gear = fGearTC(jz, Vh.fGrad(dist)) - Else - Gear = fGearVECTO(jz, Vh.fGrad(dist)) - End If - - 'Must be reset here because the Gear-shifting model may cause changes - MODdata.ModErrors.PxReset() - - End If - - 'Gear shifting-model / gear input can open Clutch - If Gear < 1 Then - - Clutch = tEngClutch.Opened - - Else - - If Not GBX.TCon AndAlso fnn(Vact, Gear, False) < ClutchNorm And Pplus And Not VehState0 = tVehState.Dec Then - Clutch = tEngClutch.Slipping - Else - Clutch = tEngClutch.Closed - End If - - End If - - End If - - If Gear = -1 Then - WorkerMsg(tMsgID.Err, "Error in Gear Shift Model!", MsgSrc & "/t= " & jz + 1) - Return False - End If - - 'Eco-Roll (triggers if Pwheel < 2 [kW]) - If Vh.EcoRoll(jz) AndAlso Pwheel <= 0 Then - Clutch = tEngClutch.Opened - Gear = 0 - End If - - If Gear = 1 And Pminus And Vact <= 5 / 3.6 Then - Clutch = tEngClutch.Opened - Gear = 0 - End If - - ' Important checks -lbCheck: - - 'Falls vor Gangwahl festgestellt wurde, dass nicht KupplSchleif, dann bei zu niedriger Drehzahl runterschalten: |@@| If before?(vor) Gear-shift is detected that Clutch does not Lock, then Downshift at too low Revolutions: - If Not GBX.TCon Then - If Clutch = tEngClutch.Closed Then - If fnn(Vact, Gear, False) < ClutchNorm And Not VehState0 = tVehState.Dec And Gear > 1 Then Gear -= 1 - End If - End If - - - 'Check whether idling although Power > 0 - ' if power at wheels > 0.2 [kW], then clutch in - If Clutch = tEngClutch.Opened Then - If Pwheel > 0.2 Then - - If TracIntrOn Then - Gear = TracIntrGear - Else - Gear = 1 - End If - - - If Not GBX.TCon AndAlso fnn(Vact, Gear, False) < ClutchNorm Then - Clutch = tEngClutch.Slipping - Else - Clutch = tEngClutch.Closed - End If - - GoTo lbCheck - - End If - End If - - '************************************ Revolutions ************************************ - - '*** If Revolutions specified then the next block is skipped *** - If RpmInput Then - - nU = MODdata.nUvorg(jz) - - 'If Start/Stop then it will be set at the same nn < -0.05 to nU = 0 - If VEC.StartStop And nU < ENG.Nidle - 100 Then - If Pplus Then - nU = ENG.Nidle - If FirstSecItar Then WorkerMsg(tMsgID.Warn, "target rpm < rpm_idle while power demand > 0", MsgSrc & "/t= " & jz + 1) - Else - nU = 0 - End If - End If - - If nU < ENG.Nidle - 100 And Not VEC.StartStop Then - If FirstSecItar Then WorkerMsg(tMsgID.Warn, "target rpm < rpm_idle (Start/Stop disabled)", MsgSrc & "/t= " & jz + 1) - End If - - GoTo lb_nOK - - End If - - 'Revolutions drop when decoupling - If Clutch = tEngClutch.Opened Then - If jz = 0 Then - nU = ENG.Nidle - Else - - If MODdata.nU(jz - 1) <= ENG.Nidle + 0.00001 Then - nU = MODdata.nU(jz - 1) - GoTo lb_nOK - End If - - - nUx = MODdata.nU(jz - 1) - omega1 = nUx * 2 * Math.PI / 60 - Pmin = 0 - nU = nUx - i = 0 - Do - PminX = Pmin - Pmin = FLD(Gear).Pdrag(nU) - - 'Limit Power-drop to 75% - P = (MODdata.Pe(jz - 1) - MODdata.PauxSum(jz - 1)) - 0.75 * ((MODdata.Pe(jz - 1) - MODdata.PauxSum(jz - 1)) - Pmin) - - M = -P * 1000 * 60 / (2 * Math.PI * nU) - omega_p = M / EngSideInertia - omega2 = omega1 - omega_p - nU = omega2 * 60 / (2 * Math.PI) - i += 1 - '01:10:12 Luz: Revolutions must not be higher than previously - If nU > nUx Then - nU = nUx - Exit Do - End If - Loop Until Math.Abs(Pmin - PminX) < 0.001 Or nU <= ENG.Nidle Or i = 999 - - 'If i = 999 Then WorkerMsg(tMsgID.Warn, "i=999", MsgSrc & "/t= " & jz + 1) - - nU = Math.Max(ENG.Nidle, nU) - - MODdata.ModErrors.FLDextrapol = "" - - End If - - Else - - If GBX.TCon And GBX.IsTCgear(Gear) Then - - PlossGB = fPlossGB(Pwheel, Vact, Gear, False) - PlossDiff = fPlossDiff(Pwheel, Vact, False) - PlossRt = fPlossRt(Vact, Gear) - PaGbx = fPaG(Vact, aact) - Pclutch = Pwheel + PlossGB + PlossDiff + PaGbx + PlossRt - - If jz = 0 Then - If Not GBX.TCiteration(Gear, fnUout(Vact, Gear), Pclutch, jz) Then - WorkerMsg(tMsgID.Err, "TC Iteration failed!", MsgSrc & "/t= " & jz + 1) - Return False - End If - Else - If Not GBX.TCiteration(Gear, fnUout(Vact, Gear), Pclutch, jz, MODdata.nU(jz - 1), MODdata.Pe(jz - 1)) Then - WorkerMsg(tMsgID.Err, "TC Iteration failed!", MsgSrc & "/t= " & jz + 1) - Return False - End If - End If - - If GBX.TCNeutral Then - Gear = 0 - Clutch = tEngClutch.Opened - GoTo lbCheck - End If - - If GBX.TCReduce Then - If Not Vh.ReduceSpeed(jz, 0.999) Then - WorkerMsg(tMsgID.Err, "Engine full load too low for vehicle start (speed reduction failed) !", MsgSrc & "/t= " & jz + 1) - Return False - End If - FirstSecItar = False - GoTo lbGschw - End If - - nU = GBX.TCnUin - - Else - - nU = fnU(Vact, Gear, Clutch = tEngClutch.Slipping) - - '*** Start: Revolutions Check - - 'Check whether Revolutions too high! => Speed Reduction - Do While Gear < GBX.GearCount AndAlso nU > 1.2 * (ENG.Nrated - ENG.Nidle) + ENG.Nidle - Gear += 1 - nU = fnU(Vact, Gear, Clutch = tEngClutch.Slipping) - Loop - - 'Check whether Revolutions too low with the Clutch closed - If Clutch = tEngClutch.Closed Then - If nU < ENG.Nidle + 0.0001 Then - Gear -= 1 - If Gear = 0 Then Clutch = tEngClutch.Opened - GoTo lbCheck - 'nU = fnU(Vact, Gear, Clutch = tEngClutch.Slipping) - End If - End If - - End If - - End If - - - - -lb_nOK: - - - '************************************ Determine Engine-state ************************************ - ' nU is final here! - - - - 'Power at clutch - Select Case Clutch - Case tEngClutch.Opened - Pclutch = 0 - PlossGB = 0 - PlossDiff = 0 - PlossRt = 0 - PlossTC = 0 - PaGbx = 0 - Case tEngClutch.Closed - - If GBX.TCon And GBX.IsTCgear(Gear) Then - - Pclutch = nMtoPe(nU, GBX.TCMin) - - If P >= 0 Then - PlossTC = Math.Abs(nMtoPe(GBX.TCnUin, GBX.TCMin) * (1 - GBX.TC_mu * GBX.TC_nu)) - Else - PlossTC = Math.Abs(nMtoPe(GBX.TCnUout, GBX.TCMout) * (1 - GBX.TC_mu * GBX.TC_nu)) - End If - - Else - - PlossGB = fPlossGB(Pwheel, Vact, Gear, False) - PlossDiff = fPlossDiff(Pwheel, Vact, False) - PlossRt = fPlossRt(Vact, Gear) - PlossTC = 0 - PaGbx = fPaG(Vact, aact) - Pclutch = Pwheel + PlossGB + PlossDiff + PaGbx + PlossRt - - End If - Case Else 'tEngClutch.Slipping: never in AT mode! - PlossGB = fPlossGB(Pwheel, Vact, Gear, False) - PlossDiff = fPlossDiff(Pwheel, Vact, False) - PlossRt = fPlossRt(Vact, Gear) - PlossTC = 0 - PaGbx = fPaG(Vact, aact) - Pclutch = (Pwheel + PlossGB + PlossDiff + PaGbx + PlossRt) / ClutchEta - End Select - - 'AA-TB/RL - '************************ ADVANCED AUXILIARIES STARTS ********************************************** - 'Clutch closed/engaged = True - 'Note: Slipping clutch is also considered enganged. - AAUX_Gobal.ClutchEngaged = (Clutch <> tEngClutch.Opened) - - 'Note: Vehicles with Start/Stop will stop engine at vehicle stop => EngState0 = tEngState.Stopped - AAUX_Gobal.Idle = (EngState0 = tEngState.Idle) - - AAUX_Gobal.InNeutral = (Gear = 0) - - 'Driveline Power = required power at clutch = power at wheels plus powertrain losses - '[kW] - AAUX_Gobal.EngineDrivelinePower = Pclutch - - '[1/min] - AAUX_Gobal.EngineSpeed = nU - - '[Nm] (using Power => Torque conversion) - AAUX_Gobal.EngineDrivelineTorque = nPeToM(EngineSpeed, EngineDrivelinePower) - - 'Motoring power (< 0 !!!) - '[kW] - AAUX_Gobal.EngineMotoringPower = FLD(Gear).Pdrag(EngineSpeed) - - 'Additional aux power from driving cycle (optional user input) - '[kW] - AAUX_Gobal.PreExistingAuxPower = MODdata.Vh.Padd(jz) - - - 'TODO: HOW TO ALTER HERE FOR CLASSIC or ADVANCED - 'Total aux power - '[kW] - Paux = PreExistingAuxPower + fPaux(jz, EngineSpeed) - '***************** ADVANCED AUXILIARIES END ******************************************************** - - 'ICE-inertia - If jz = 0 Then - PaMot = 0 - Else - 'Not optimal since jz-1 to jz not the right interval - PaMot = fPaMot(nU, MODdata.nU(jz - 1)) - End If - - 'Internal Engine Power (Pclutch plus Aux plus Inertia) - P = Pclutch + Paux + PaMot - - - 'EngState - If Clutch = tEngClutch.Opened Then - - 'Start/Stop >>> tEngState.Stopped - If VEC.StartStop AndAlso Vact <= VEC.StStV / 3.6 AndAlso Math.Abs(PaMot) < 0.0001 Then - StStPossible = True - If StStOff And jz > 0 Then - If MODdata.EngState(jz - 1) = tEngState.Stopped Then - P = 0 - EngState0 = tEngState.Stopped - End If - Else - P = 0 - EngState0 = tEngState.Stopped - End If - End If - - Select Case P - Case Is > 0.0001 'Antrieb - EngState0 = tEngState.Load - - Case Is < -0.0001 'Schlepp - EngState0 = tEngState.Drag - - Case Else 'Idle/Stop - If Not EngState0 = tEngState.Stopped Then EngState0 = tEngState.Idle - End Select - - Else - - If P < 0 Then - EngState0 = tEngState.Drag - Else - EngState0 = tEngState.Load - End If - - End If - - - - '*************** Leistungsverteilung usw. ****************** |@@| Power distribution, etc. ****************** - - 'Full-Load/Drag curve - If EngState0 = tEngState.Stopped Then - - Pmin = 0 - Pmax = 0 - - 'Revolutions Correction - nU = 0 - - Else - - Pmin = FLD(Gear).Pdrag(nU) - - If jz = 0 Then - Pmax = FLD(Gear).Pfull(nU) - Else - Pmax = FLD(Gear).Pfull(nU, MODdata.Pe(jz - 1)) - End If - - 'If Pmax < 0 or Pmin > 0 then Abort with Error! - If Pmin >= 0 And P < 0 Then - WorkerMsg(tMsgID.Err, "Pe_drag > 0! n= " & nU & " [1/min]", MsgSrc & "/t= " & jz + 1, FLD(Gear).FilePath) - Return False - ElseIf Pmax <= 0 And P > 0 Then - WorkerMsg(tMsgID.Err, "Pe_full < 0! n= " & nU & " [1/min]", MsgSrc & "/t= " & jz + 1, FLD(Gear).FilePath) - Return False - End If - - End If - - ' => Pbrake - If Clutch = tEngClutch.Opened Then - If Pwheel < -0.00001 Then - Pbrake = Pwheel - Else - Pbrake = 0 - End If - - If P < Pmin Then P = Pmin - - Else - If EngState0 = tEngState.Load Then - Pbrake = 0 - If GBX.TCon And GBX.IsTCgear(Gear) Then Pbrake = GBX.TC_PeBrake - If Math.Abs(P / Pmax - 1) < 0.02 Then EngState0 = tEngState.FullLoad - Else ' tEngState.Drag (tEngState.Idle, tEngState.Stopped kann's hier nicht geben weil Clutch <> Closed) - If P < Pmin Then - - 'Overspeed - 'If Not OvrSpeed AndAlso Not VehState0 = tVehState.Dec Then - - ' OvrSpeed = True - - ' If DEV.OverSpeedOn And (Pmin - P) / VEH.Pnenn > DEV.SpeedPeEps Then - - ' Vcoasting = fCoastingSpeed(jz, Gear) - - ' If Vcoasting <= MODdata.Vh.Vsoll(jz) + DEV.OverSpeed / 3.6 Then - ' Vh.SetSpeed(jz, Vcoasting) - ' GoTo lbGschw - ' ElseIf Vist < 0.999 * (MODdata.Vh.Vsoll(jz) + DEV.OverSpeed / 3.6) Then - ' Vh.SetSpeed(jz, MODdata.Vh.Vsoll(jz) + DEV.OverSpeed / 3.6) - ' GoTo lbGschw - ' End If - - ' End If - 'End If - - MODdata.ModErrors.TrLossMapExtr = "" - - 'VKM to Drag-curve - P = Pmin - - 'Forward-calculation to Wheel (PvorD) - Pclutch = P - Paux - PaMot - PaGbx = fPaG(Vact, aact) - PlossGB = fPlossGBfwd(Pclutch, Vact, Gear, False) - PlossRt = fPlossRt(Vact, Gear) - PlossDiff = fPlossDiffFwd(Pclutch - PlossGB - PlossRt, Vact, False) - - Pbrake = Pwheel - (Pclutch - PlossGB - PlossDiff - PaGbx - PlossRt) - - EngState0 = tEngState.FullDrag - Else - Pbrake = 0 - End If - End If - End If - - 'Check if cancellation pending (before Speed-reduce-iteration, otherwise it hangs) - If VECTOworker.CancellationPending Then Return True - - 'Check whether P above Full-load => Reduce Speed - If P > Pmax Then - If EngState0 = tEngState.Load Or EngState0 = tEngState.FullLoad Then - If Vact > 0.01 Then - Vh.ReduceSpeed(jz, 0.9999) - FirstSecItar = False - GoTo lbGschw - Else - 'ERROR: Speed Reduction brings nothing? ... - WorkerMsg(tMsgID.Err, "Speed reduction failed!", MsgSrc & "/t= " & jz + 1) - Return False - End If - Else 'tEngState.Idle, tEngState.Stopped, tEngState.Drag - 'ERROR: Engine not in Drivetrain ... can it be? - If FirstSecItar Then - If P > 0.1 Then WorkerMsg(tMsgID.Warn, "Pwheel > 0 but EngState undefined ?!", MsgSrc & "/t= " & jz + 1) - End If - End If - End If - - - 'Interruption of traction(Zugkraftunterbrechung) - If TracIntrI > 0 Then - - If Not TracIntrOn Then - - If jz > 0 AndAlso Gear > 0 AndAlso MODdata.Gear(jz - 1) > 0 AndAlso Gear <> MODdata.Gear(jz - 1) Then - - TracIntrGear = Gear - Gear = 0 - Clutch = tEngClutch.Opened - TracIntrIx = 0 - TracIntrOn = True - - If TracIntrIx + 1 = TracIntrI Then - TracIntrIs = GBX.TracIntrSi - CSng(TracIntrIx) - Else - TracIntrIs = 1 - End If - - Vrollout = fRolloutSpeed(jz, TracIntrIs, Vh.fGrad(dist)) - - If Vrollout < Vact Or VehState0 <> tVehState.Dec Then Vh.SetSpeed(jz, Vrollout) - - GoTo lbGschw - - End If - - End If - - End If - - '-------------------------------------------------------------------------------------------------- - '------------------------- PNR -------------------------------------------------------------------- - '-------------------------------------------------------------------------------------------------- - ' Finish Second - - 'distance - dist0 += Vact - - 'Start / Stop - Activation-Speed Control - If VEC.StartStop Then - If StStPossible Then - StStDelayTx += 1 - Else - StStDelayTx = 0 - End If - If StStOff Then - If Not EngState0 = tEngState.Stopped Then - StStTx += 1 - If StStTx > VEC.StStT And StStDelayTx >= VEC.StStDelay Then - StStTx = 1 - StStOff = False - End If - End If - Else - If EngState0 = tEngState.Stopped Or StStDelayTx < VEC.StStDelay Then StStOff = True - End If - End If - - 'Write Modal-values Fields - MODdata.Pe.Add(P) - MODdata.nU.Add(nU) - - MODdata.EngState.Add(EngState0) - - MODdata.Pa.Add(fPaFZ(MODdata.Vh.V(jz), MODdata.Vh.a(jz))) - MODdata.Pair.Add(fPair(MODdata.Vh.V(jz), jz)) - MODdata.Proll.Add(fPr(MODdata.Vh.V(jz), Vh.fGrad(dist))) - MODdata.Pstg.Add(fPs(MODdata.Vh.V(jz), Vh.fGrad(dist))) - MODdata.Pbrake.Add(Pbrake) - MODdata.Psum.Add(Pwheel) - MODdata.PauxSum.Add(Paux) - MODdata.Grad.Add(Vh.fGrad(dist)) - - For Each AuxID As String In VEC.AuxRefs.Keys - MODdata.Paux(AuxID).Add(VEC.Paux(AuxID, jz, Math.Max(nU, ENG.Nidle))) - Next - - MODdata.PlossGB.Add(PlossGB) - MODdata.PlossDiff.Add(PlossDiff) - MODdata.PlossRt.Add(PlossRt) - MODdata.PlossTC.Add(PlossTC) - MODdata.PaEng.Add(PaMot) - MODdata.PaGB.Add(PaGbx) - MODdata.Pclutch.Add(Pclutch) - - MODdata.VehState.Add(VehState0) - MODdata.Gear.Add(Gear) - - 'Torque Converter output - If GBX.TCon Then - If GBX.IsTCgear(Gear) Then - If nU = 0 Then - MODdata.TCnu.Add(0) - Else - MODdata.TCnu.Add(GBX.TCnUout / nU) - End If - If GBX.TCMin = 0 Then - MODdata.TCmu.Add(0) - Else - MODdata.TCmu.Add(GBX.TCMout / GBX.TCMin) - End If - MODdata.TCMout.Add(GBX.TCMout) - MODdata.TCnOut.Add(GBX.TCnUout) - Else - If Clutch = tEngClutch.Opened Then - MODdata.TCnu.Add(0) - MODdata.TCmu.Add(0) - MODdata.TCMout.Add(0) - MODdata.TCnOut.Add(0) - Else - MODdata.TCnu.Add(1) - MODdata.TCmu.Add(1) - MODdata.TCMout.Add(nPeToM(nU, Pclutch)) - MODdata.TCnOut.Add(nU) - End If - End If - End If - - Vh.DistCorrection(jz, VehState0) - - 'Traction Interruption - If TracIntrTurnOff Then - - TracIntrOn = False - TracIntrTurnOff = False - - ElseIf TracIntrOn Then - - TracIntrIx += 1 - - If TracIntrIx = TracIntrI Then - - TracIntrTurnOff = True - - ElseIf jz < MODdata.tDim Then - - If TracIntrIx + 1 = TracIntrI Then - TracIntrIs = GBX.TracIntrSi - CSng(TracIntrIx) - Else - TracIntrIs = 1 - End If - - Vrollout = fRolloutSpeed(jz + 1, TracIntrIs, Vh.fGrad(dist)) - If Vrollout < Vh.V(jz + 1) Or VehState0 <> tVehState.Dec Then Vh.SetSpeed(jz + 1, Vrollout) - - End If - - End If - - If Vh.Vsoll(jz) - Vact > 1.5 Then SecSpeedRed += 1 - - - LastGearChange = -1 - For i = jz - 1 To 0 Step -1 - If MODdata.Gear(i) <> 0 Then - If MODdata.Gear(i) <> Gear Then - LastGearChange = i - Exit For - End If - End If - Next - - - LastClutch = Clutch - - 'Messages - If MODdata.ModErrors.MsgOutputAbort(jz + 1, MsgSrc) Then Return False - - If Clutch = tEngClutch.Closed And RpmInput Then - If Math.Abs(nU - fnU(Vact, Gear, False)) > 0.2 * ENG.Nrated Then - WorkerMsg(tMsgID.Warn, "Target rpm =" & nU & ", calculated rpm(gear " & Gear & ")= " & fnU(Vact, Gear, False), MsgSrc & "/t= " & jz + 1) - End If - End If - - LastPmax = Pmax - - Loop Until jz >= MODdata.tDim - - '*********************************************************************************************** - '*********************************** Time loop END *********************************** - '*********************************************************************************************** - - 'Notify - If Cfg.DistCorr Then - If MODdata.tDim > MODdata.tDimOgl Then WorkerMsg(tMsgID.Normal, "Cycle extended by " & MODdata.tDim - MODdata.tDimOgl & " seconds to meet target distance.", MsgSrc) - - If Math.Abs(Vh.WegIst - Vh.WegSoll) > 80 Then - WorkerMsg(tMsgID.Warn, "Target distance= " & (Vh.WegSoll / 1000).ToString("#.000") & "[km], Actual distance= " & (Vh.WegIst / 1000).ToString("#.000") & "[km], Error= " & Math.Abs(Vh.WegIst - Vh.WegSoll).ToString("#.0") & "[m]", MsgSrc) - Else - WorkerMsg(tMsgID.Normal, "Target distance= " & (Vh.WegSoll / 1000).ToString("#.000") & "[km], Actual distance= " & (Vh.WegIst / 1000).ToString("#.000") & "[km], Error= " & Math.Abs(Vh.WegIst - Vh.WegSoll).ToString("#.0") & "[m]", MsgSrc) - End If - End If - - If SecSpeedRed > 0 Then WorkerMsg(tMsgID.Normal, "Speed reduction > 1.5 m/s in " & SecSpeedRed & " time steps.", MsgSrc) - - - 'CleanUp - Vh = Nothing - - Return True - - End Function - - Public Function Eng_Calc(ByVal NoWarnings As Boolean) As Boolean - - Dim Pmr As Single - Dim t As Integer - Dim t1 As Integer - Dim Pmin As Single - Dim Pmax As Single - Dim nUDRI As List(Of Double) - Dim PeDRI As List(Of Double) - Dim PcorCount As Integer - Dim MsgSrc As String - Dim Padd As Single - - MsgSrc = "Power/Eng_Calc" - - 'Abort if Power/Revolutions not given - If Not (DRI.Nvorg And DRI.Pvorg) Then - WorkerMsg(tMsgID.Err, "Load cycle is not valid! rpm and load required.", MsgSrc) - Return False - End If - - PcorCount = 0 - t1 = MODdata.tDim - nUDRI = DRI.Values(tDriComp.nU) - PeDRI = DRI.Values(tDriComp.Pe) - - 'Drehzahlen vorher weil sonst scheitert die Pmr-Berechnung bei MODdata.nU(t + 1) |@@| Revolutions previously, otherwise Pmr-calculation fails at MODdata.nU(t + 1) - For t = 0 To t1 - MODdata.nU.Add(Math.Max(0, nUDRI(t))) - Next - - 'Power calculation - For t = 0 To t1 - - 'Secondary Progressbar - ProgBarCtrl.ProgJobInt = CInt(100 * t / t1) - - 'Reset the second-by-second Errors - MODdata.ModErrors.ResetAll() - - 'OLD and wrong because not time shifted: P_mr(jz) = 0.001 * (I_mot * 0.0109662 * (n(jz) * nnrom) * nnrom * (n(jz) - n(jz - 1))) - If t > 0 And t < t1 Then - Pmr = 0.001 * (ENG.I_mot * (2 * Math.PI / 60) ^ 2 * ((MODdata.nU(t + 1) + MODdata.nU(t - 1)) / 2) * 0.5 * (MODdata.nU(t + 1) - MODdata.nU(t - 1))) - Else - Pmr = 0 - End If - - Padd = MODdata.Vh.Padd(t) - - 'Power = P_clutch + + Pa_eng + Padd - MODdata.Pe.Add(PeDRI(t) + (Pmr + Padd)) - - 'Revolutions of the Cycle => Determined in Cycle-init - 'If Revolutions under idle, assume Engine is stopped - If MODdata.nU(t) < ENG.Nidle - 100 Then - EngState0 = tEngState.Stopped - Else - Pmin = FLD(0).Pdrag(MODdata.nU(t)) - - If t = 0 Then - Pmax = FLD(0).Pfull(MODdata.nU(t)) - Else - Pmax = FLD(0).Pfull(MODdata.nU(t), MODdata.Pe(t - 1)) - End If - - 'If Pmax < 0 or Pmin > 0 then Abort with Error! - If Pmin >= 0 AndAlso MODdata.Pe(t) < 0 Then - WorkerMsg(tMsgID.Err, "Pe_drag > 0! n= " & MODdata.nU(t) & " [1/min]", MsgSrc & "/t= " & t + 1, FLD(0).FilePath) - Return False - ElseIf Pmax <= 0 AndAlso MODdata.Pe(t) > 0 Then - WorkerMsg(tMsgID.Err, "Pe_full < 0! n= " & MODdata.nU(t) & " [1/min]", MsgSrc & "/t= " & t + 1, FLD(0).FilePath) - Return False - End If - - 'FLD Check - If MODdata.Pe(t) > Pmax Then - If MODdata.Pe(t) / Pmax > 1.05 Then PcorCount += 1 - MODdata.Pe(t) = Pmax - ElseIf MODdata.Pe(t) < Pmin Then - If MODdata.Pe(t) / Pmin > 1.05 And MODdata.Pe(t) > -99999 Then PcorCount += 1 - MODdata.Pe(t) = Pmin - End If - - Select Case MODdata.Pe(t) - Case Is > 0.0001 'Antrieb - If Math.Abs(MODdata.Pe(t) / Pmax - 1) < 0.01 Then - EngState0 = tEngState.FullLoad - Else - EngState0 = tEngState.Load - End If - Case Is < -0.0001 'Schlepp - If Math.Abs(MODdata.Pe(t) / Pmin - 1) < 0.01 Then - EngState0 = tEngState.FullDrag - Else - EngState0 = tEngState.Drag - End If - Case Else - EngState0 = tEngState.Idle - End Select - End If - - MODdata.EngState.Add(EngState0) - MODdata.PaEng.Add(Pmr) - MODdata.Pclutch.Add(MODdata.Pe(t) - (Pmr + Padd)) - MODdata.PauxSum.Add(Padd) - - 'Notify - If MODdata.ModErrors.MsgOutputAbort(t + 1, MsgSrc) Then Return False - - Next - - If PcorCount > 0 And Not NoWarnings Then WorkerMsg(tMsgID.Warn, "Power corrected (>5%) in " & PcorCount & " time steps.", MsgSrc) - - Return True - - End Function - - Private Function fTracIntPower(ByVal t As Single, ByVal Gear As Integer) As Single - Dim PminX As Single - Dim P As Single - Dim M As Single - Dim Pmin As Single - Dim nU As Single - Dim omega_p As Single - Dim omega1 As Single - Dim omega2 As Single - Dim nUx As Single - Dim i As Integer - - - nUx = MODdata.nU(t - 1) - omega1 = nUx * 2 * Math.PI / 60 - Pmin = 0 - nU = nUx - i = 0 - - Do - PminX = Pmin - Pmin = FLD(Gear).Pdrag(nU) - 'Leistungsabfall limitieren auf Pe(t-1) minus 75% von (Pe(t-1) - Pschlepp) |@@| Limit Power-drop to Pe(t-1) minus 75% of (Pe(t-1) - Pdrag) - ' aus Auswertung ETC des Motors mit dem dynamische Volllast parametriert wurde |@@| of the evaluated ETC of the Enginges with the dynamic parametrized Full-load - ' Einfluss auf Beschleunigungsvermögen gering (Einfluss durch Pe(t-1) bei dynamischer Volllast mit PT1) |@@| Influence at low acceleration (influence dynamic Full-load through Pe(t-1) with PT1) - ' Luz/Rexeis 21.08.2012 - ' Iteration loop: 01.10.2012 - P = MODdata.Pe(t - 1) - 0.75 * (MODdata.Pe(t - 1) - Pmin) - M = -P * 1000 * 60 / (2 * Math.PI * nU) - 'original: M = -Pmin * 1000 * 60 / (2 * Math.PI * ((nU + nUx) / 2)) - omega_p = M / EngSideInertia - omega2 = omega1 - omega_p - nU = omega2 * 60 / (2 * Math.PI) - i += 1 - '01:10:12 Luz: Revolutions must not be higher than previously - If nU > nUx Then - nU = nUx - Exit Do - End If - Loop Until Math.Abs(Pmin - PminX) < 0.001 Or nU <= ENG.Nidle Or i = 999 - - Return P - - - End Function - - Private Function fRolloutSpeed(ByVal t As Integer, ByVal dt As Single, ByVal Grad As Single) As Single - - Dim vstep As Double - Dim vVorz As Integer - Dim PvD As Single - Dim a As Single - Dim v As Single - Dim eps As Single - Dim LastPvD As Single - Dim vMin As Single - - v = MODdata.Vh.V(t) - - vMin = (MODdata.Vh.V0(t) + 0) / 2 - - If v <= vMin Then Return vMin - - vstep = 0.1 - eps = 0.00005 - a = MODdata.Vh.a(t) - - PvD = fPwheel(t, v, a, Grad) - - If PvD > eps Then - vVorz = -1 - ElseIf PvD < -eps Then - vVorz = 1 - Else - Return v - End If - - LastPvD = PvD + 10 * eps - - Do While Math.Abs(PvD) > eps And Math.Abs(LastPvD - PvD) > eps - - If Math.Abs(LastPvD) < Math.Abs(PvD) Then - vVorz *= -1 - vstep *= 0.5 - - If vstep = 0 Then Exit Do - - End If - - v += vVorz * vstep - - If v < vMin Then - - LastPvD = 0 - v -= vVorz * vstep - - Else - - a = 2 * (v - MODdata.Vh.V0(t)) / dt - - LastPvD = PvD - - PvD = fPwheel(t, v, a, Grad) - - End If - - Loop - - Return v - - End Function - - Private Function fCoastingSpeed(ByVal t As Integer, ByVal s As Double, ByVal Gear As Integer) As Single - - Return fCoastingSpeed(t, s, Gear, MODdata.Vh.V(t), MODdata.Vh.a(t)) - - End Function - - Private Function fCoastingSpeed(ByVal t As Integer, ByVal s As Double, ByVal Gear As Integer, ByVal v As Single, ByVal a As Single, Optional ByVal v0 As Single? = Nothing) As Single - - Dim vstep As Double - Dim vSign As Integer - Dim Pe As Single - Dim Pwheel As Single - Dim LastDiff As Single - Dim Diff As Single - Dim nU As Single - Dim Pdrag As Single - Dim Grad As Single - - - vstep = 5 - nU = fnU(v, Gear, False) - Pdrag = FLD(Gear).Pdrag(nU) - - 'Do not allow positive road gradients - Grad = MODdata.Vh.fGrad(s) - - - Pwheel = fPwheel(t, v, a, Grad) - Pe = Pwheel + fPlossGB(Pwheel, v, Gear, True) + fPlossDiff(Pwheel, v, True) + fPaG(v, a) + fPlossRt(v, Gear) + fPaux(t, nU) + fPaMotSimple(t, Gear, v, a) - - Diff = Math.Abs(Pdrag - Pe) - - If Diff > 0.0001 Then - vSign = 1 - Else - Return v - End If - - LastDiff = Diff + 10 * 0.0001 - - Do While Diff > 0.0001 'And Math.Abs(LastDiff - Diff) > eps - - If LastDiff < Diff Or v + vSign * vstep <= 0.0001 Then - vSign *= -1 - vstep *= 0.5 - - If vstep < 0.00001 Then Exit Do - - End If - - v += vSign * vstep - - If v0 Is Nothing Then - a = 2 * (v - MODdata.Vh.V0(t)) / 1 'dt = 1[s] - Else - a = 2 * (v - v0) / 1 'dt = 1[s] - End If - - nU = fnU(v, Gear, False) - Pdrag = FLD(Gear).Pdrag(nU) - - LastDiff = Diff - - Pwheel = fPwheel(t, v, a, Grad) - Pe = Pwheel + fPlossGB(Pwheel, v, Gear, True) + fPlossDiff(Pwheel, v, True) + fPaG(v, a) + fPlossRt(v, Gear) + fPaux(t, nU) + fPaMotSimple(t, Gear, v, a) - - Diff = Math.Abs(Pdrag - Pe) - - Loop - - Return v - - End Function - - Private Function fCoastingSpeed(ByVal t As Integer, ByVal s As Double, ByVal Gear As Integer, ByVal dt As Integer) As Single - Dim a As Single - Dim v As Single - Dim vtemp As Single - Dim t0 As Integer - Dim v0 As Single - Dim v0p As Single - - v0 = MODdata.Vh.V0(t) - v = MODdata.Vh.V(t) - a = MODdata.Vh.a(t) - - If t + dt > MODdata.tDim - 1 Then - dt = MODdata.tDim - 1 - t - End If - - For t0 = t To t + dt - vtemp = fCoastingSpeed(t0, s, Gear, v, a, v0) - - If 2 * vtemp - v0 < 0 Then vtemp = v0 / 2 - - v0p = 2 * vtemp - v0 - a = v0p - v0 - - v = (MODdata.Vh.V0(t0 + 2) + v0p) / 2 - a = MODdata.Vh.V0(t0 + 2) - v0p - - v0 = v0p - - Next - - Return vtemp - - End Function - -#Region "Gear Shift Methods" - - Private Function fFastGearCalc(ByVal V As Single, ByVal Pe As Single) As Integer - Dim Gear As Integer - Dim Tq As Single - Dim nU As Single - Dim nUup As Single - Dim nUdown As Single - - For Gear = GBX.GearCount To 1 Step -1 - - nU = CSng(Vact * 60.0 * GBX.Igetr(0) * GBX.Igetr(Gear) / (2 * VEH.rdyn * Math.PI / 1000)) - - 'Current torque demand with previous gear - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - - 'Up/Downshift rpms - nUup = GBX.Shiftpolygons(Gear).fGSnUup(Tq) - nUdown = GBX.Shiftpolygons(Gear).fGSnUdown(Tq) - - If nU > nUdown Then Return Gear - - Next - - Return 1 - - End Function - - Private Function fStartGear(ByVal t As Integer, ByVal Grad As Single) As Integer - Dim Gear As Integer - Dim MsgSrc As String - Dim nU As Single - Dim nUup As Single - Dim nUdown As Single - Dim Tq As Single - Dim Pe As Single - Dim MdMax As Single - Dim Pmax As Single - - MsgSrc = "StartGear" - - If GBX.TCon Then Return 1 - - If t = 0 AndAlso VehState0 <> tVehState.Stopped Then - - 'Calculate gear when cycle starts with speed > 0 - For Gear = GBX.GearCount To 1 Step -1 - - 'rpm - nU = fnU(Vact, Gear, Clutch = tEngClutch.Slipping) - - 'full load - Pmax = FLD(Gear).Pfull(nU) - - 'power demand - cut at full load / drag so that fGSnnUp and fGSnnDown don't extrapolate - Pe = Math.Min(fPeGearMod(Gear, t, Grad), Pmax) - Pe = Math.Max(Pe, FLD(Gear).Pdrag(nU)) - - 'torque demand - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - - 'Up/Downshift rpms - nUup = GBX.Shiftpolygons(Gear).fGSnUup(Tq) - nUdown = GBX.Shiftpolygons(Gear).fGSnUdown(Tq) - - 'Max torque - MdMax = Pmax * 1000 / (nU * 2 * Math.PI / 60) - - 'Find highest gear with rpm below Upshift-rpm and with enough torque reserve - If nU < nUup And nU > nUdown And 1 - Tq / MdMax >= GBX.gs_TorqueResv / 100 Then - Exit For - ElseIf nU > nUup And Gear < GBX.GearCount Then - Return Gear + 1 - End If - - Next - - Else - - 'Calculate Start Gear - For Gear = GBX.GearCount To 1 Step -1 - - 'rpm at StartSpeed [m/s] - nU = GBX.gs_StartSpeed * 60.0 * GBX.Igetr(0) * GBX.Igetr(Gear) / (2 * VEH.rdyn * Math.PI / 1000) - - 'full load - Pmax = FLD(Gear).Pfull(nU) - - 'Max torque - MdMax = Pmax * 1000 / (nU * 2 * Math.PI / 60) - - 'power demand - Pe = Math.Min(fPeGearMod(Gear, t, GBX.gs_StartSpeed, GBX.gs_StartAcc, Grad), Pmax) - Pe = Math.Max(Pe, FLD(Gear).Pdrag(nU)) - - 'torque demand - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - - 'Up/Downshift rpms - nUup = GBX.Shiftpolygons(Gear).fGSnUup(Tq) - nUdown = GBX.Shiftpolygons(Gear).fGSnUdown(Tq) - - If nU > nUdown And nU >= ENG.Nidle And (1 - Tq / MdMax >= GBX.gs_TorqueResvStart / 100 Or Tq < 0) Then Exit For - - Next - - End If - - Return Gear - - - End Function - - Private Function fGearTC(ByVal t As Int16, ByVal Grad As Single) As Integer - Dim LastGear As Int16 - Dim tx As Int16 - Dim nU As Single - Dim nUup As Single - Dim nUdown As Single - Dim Tq As Single - Dim LastPe As Single - Dim nUnext As Single - Dim OutOfRpmRange As Boolean - Dim PlusGearLockUp As Boolean - Dim MinusGearTC As Boolean - Dim iRatio As Single - Dim n As Single - - 'First time step (for vehicles with TC always the first gear is used) - If t = 0 Then Return fStartGear(0, Grad) - - If MODdata.VehState(t - 1) = tVehState.Stopped Then Return 1 - - 'Previous Gear - tx = 1 - LastGear = 0 - Do While LastGear = 0 And t - tx > -1 - LastGear = MODdata.Gear(t - tx) - tx += 1 - Loop - - 'If idling (but no vehicle stop...?) then - If LastGear = 0 Then Return 1 - - If LastGear < GBX.GearCount Then - PlusGearLockUp = Not GBX.IsTCgear(LastGear + 1) - Else - PlusGearLockUp = False - End If - - If LastGear > 1 Then - MinusGearTC = GBX.IsTCgear(LastGear - 1) - Else - MinusGearTC = False - End If - - '2C-to-1C - If MinusGearTC And GBX.IsTCgear(LastGear) Then - If fnUout(Vact, LastGear) <= ENG.Nidle Then - Return LastGear - 1 - End If - End If - - If LastGear < GBX.GearCount AndAlso PlusGearLockUp Then - nUnext = Vact * 60.0 * GBX.Igetr(0) * GBX.Igetr(LastGear + 1) / (2 * VEH.rdyn * Math.PI / 1000) - Else - nUnext = 0 - End If - - 'nU - If GBX.IsTCgear(LastGear) Then - n = MODdata.TCnu(t - 1) - nU = (Vact * 60.0 * GBX.Igetr(0) * GBX.Igetr(LastGear) / (2 * VEH.rdyn * Math.PI / 1000)) / n - Else - nU = Vact * 60.0 * GBX.Igetr(0) * GBX.Igetr(LastGear) / (2 * VEH.rdyn * Math.PI / 1000) - OutOfRpmRange = (nU >= 1.2 * (ENG.Nrated - ENG.Nidle) + ENG.Nidle) Or nU < ENG.Nidle - 'No gear change 3s after last one -except rpm out of range - If Not OutOfRpmRange AndAlso t - LastGearChange <= GBX.gs_ShiftTime And t > GBX.gs_ShiftTime - 1 Then Return LastGear - End If - - 'previous power demand - LastPe = MODdata.Pe(t - 1) - 'Torque - Tq = LastPe * 1000 / (nU * 2 * Math.PI / 60) - - 'Up/Downshift rpms - nUup = GBX.Shiftpolygons(LastGear).fGSnUup(Tq) - nUdown = GBX.Shiftpolygons(LastGear).fGSnUdown(Tq) - - 'Upshift - If PlusGearLockUp Then - If nUnext > nUup AndAlso LastPe <= FLD(LastGear + 1).Pfull(nUnext) Then - Return LastGear + 1 - End If - Else - '1C-to-2C - If LastGear < GBX.GearCount Then - - iRatio = GBX.Igetr(LastGear + 1) / GBX.Igetr(LastGear) - - If fnUout(Vact, LastGear + 1) > Math.Min(900, iRatio * (FLD(LastGear).N95h - 150)) AndAlso FLD(LastGear + 1).Pfull(nU * iRatio, LastPe) > 0.7 * FLD(LastGear).Pfull(nU, LastPe) Then - Return LastGear + 1 - End If - End If - End If - - - 'Downshift - If MinusGearTC Then - If nU < ENG.Nidle Then - Return LastGear - 1 - End If - Else - If nU < nUdown Then - Return LastGear - 1 - End If - End If - - - - Return LastGear - - End Function - - Private Function fGearVECTO(ByVal t As Integer, ByVal Grad As Single) As Integer - Dim nU As Single - Dim nnUp As Single - Dim nnDown As Single - Dim Tq As Single - Dim Pe As Single - Dim LastGear As Int16 - Dim Gear As Int16 - Dim MdMax As Single - Dim LastPeNorm As Single - - Dim tx As Int16 - Dim OutOfRpmRange As Boolean - - 'First time step OR first time step after stand still - If t = 0 OrElse MODdata.VehState(t - 1) = tVehState.Stopped Then Return fStartGear(t, Grad) - - - '********* Gear Shift Polygon Model ********* - - 'Previous normalized engine power - LastPeNorm = MODdata.Pe(t - 1) - - 'Previous Gear - tx = 1 - LastGear = 0 - Do While LastGear = 0 And t - tx > -1 - LastGear = MODdata.Gear(t - tx) - tx += 1 - Loop - - 'First time step after stand still - If LastGear = 0 Then Return fStartGear(t, Grad) - - nU = CSng(Vact * 60.0 * GBX.Igetr(0) * GBX.Igetr(LastGear) / (2 * VEH.rdyn * Math.PI / 1000)) - - OutOfRpmRange = ((nU - ENG.Nidle) / (ENG.Nrated - ENG.Nidle) >= 1.2 Or nU < ENG.Nidle) - - 'No gear change 3s after last one -except rpm out of range - If Not OutOfRpmRange AndAlso t - LastGearChange <= GBX.gs_ShiftTime And t > GBX.gs_ShiftTime - 1 Then Return LastGear - - 'During start (clutch slipping) no gear shift - If LastClutch = tEngClutch.Slipping And VehState0 = tVehState.Acc Then Return LastGear - - ''Search for last Gear-change - 'itgangw = 0 - 'For i = t - 1 To 1 Step -1 - ' If MODdata.Gear(i) <> MODdata.Gear(i - 1) Then - ' itgangw = i - ' Exit For - ' End If - 'Next - - ''Maximum permissible Gear-shifts every 3 seconds: - 'If t - itgangw <= 3 And t > 2 Then - ' Return LastGear '<<< no further checks!!! - 'End If - - 'Current rpm with previous gear - nU = fnU(Vact, LastGear, Clutch = tEngClutch.Slipping) - - 'Current power demand with previous gear - Pe = Math.Min(fPeGearMod(LastGear, t, Grad), FLD(LastGear).Pfull(nU)) - Pe = Math.Max(Pe, FLD(LastGear).Pdrag(nU)) - - 'Current torque demand with previous gear - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - MdMax = FLD(LastGear).Pfull(nU, LastPeNorm) * 1000 / (nU * 2 * Math.PI / 60) - - 'Up/Downshift rpms - nnUp = GBX.Shiftpolygons(LastGear).fGSnUup(Tq) - nnDown = GBX.Shiftpolygons(LastGear).fGSnUdown(Tq) - - 'Compare rpm with Up/Downshift rpms - If nU <= nnDown And LastGear > 1 Then - - 'Shift DOWN - Gear = LastGear - 1 - - 'Skip Gears - If GBX.gs_SkipGears AndAlso Gear > 1 Then - - 'Calculate Shift-rpm for lower gear - nU = fnU(Vact, Gear - 1, False) - - 'Continue only if rpm (for lower gear) is above idling - If nU >= ENG.Nidle Then - Pe = Math.Min(fPeGearMod(Gear - 1, t, Grad), FLD(Gear - 1).Pfull(nU)) - Pe = Math.Max(Pe, FLD(Gear - 1).Pdrag(nU)) - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - nnUp = GBX.Shiftpolygons(Gear - 1).fGSnUup(Tq) - nnDown = GBX.Shiftpolygons(Gear - 1).fGSnUdown(Tq) - - 'Shift down as long as Gear > 1 and rpm is below UpShift-rpm - Do While Gear > 1 AndAlso nU < nnUp - - 'Shift DOWN - Gear -= 1 - - 'Continue only if Gear > 1 - If Gear = 1 Then Exit Do - - 'Calculate Shift-rpm for lower gear - nU = fnU(Vact, Gear - 1, False) - - 'Continue only if rpm (for lower gear) is above idling - If nU < ENG.Nidle Then Exit Do - - Pe = Math.Min(fPeGearMod(Gear - 1, t, Grad), FLD(Gear - 1).Pfull(nU)) - Pe = Math.Max(Pe, FLD(Gear - 1).Pdrag(nU)) - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - nnUp = GBX.Shiftpolygons(Gear - 1).fGSnUup(Tq) - nnDown = GBX.Shiftpolygons(Gear - 1).fGSnUdown(Tq) - - Loop - - End If - - End If - - ElseIf LastGear < GBX.GearCount And nU > nnUp Then - - 'Shift UP - Gear = LastGear + 1 - - 'Skip Gears - If GBX.gs_SkipGears AndAlso Gear < GBX.GearCount Then - - If GBX.TracIntrSi > 0.001 Then - LastPeNorm = fTracIntPower(t, Gear) - End If - - 'Calculate Shift-rpm for higher gear - nU = fnU(Vact, Gear + 1, False) - - Pe = Math.Min(fPeGearMod(Gear + 1, t, Grad), FLD(Gear + 1).Pfull(nU)) - Pe = Math.Max(Pe, FLD(Gear + 1).Pdrag(nU)) - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - nnUp = GBX.Shiftpolygons(Gear + 1).fGSnUup(Tq) - nnDown = GBX.Shiftpolygons(Gear + 1).fGSnUdown(Tq) - - 'Max Torque - MdMax = FLD(Gear + 1).Pfull(nU, LastPeNorm) * 1000 / (nU * 2 * Math.PI / 60) - - 'Shift up as long as Torque reserve is okay and Gear < Max-Gear and rpm is above DownShift-rpm - Do While Gear < GBX.GearCount AndAlso 1 - Tq / MdMax >= GBX.gs_TorqueResv / 100 AndAlso nU > nnDown '+ 0.1 * (nnUp - nnDown) - - 'Shift UP - Gear += 1 - - 'Continue only if Gear < Max-Gear - If Gear = GBX.GearCount Then Exit Do - - 'Calculate Shift-rpm for higher gear - nU = fnU(Vact, Gear + 1, False) - - 'Continue only if rpm (for higher gear) is below rated rpm - If nU > ENG.Nrated Then Exit Do - - Pe = Math.Min(fPeGearMod(Gear + 1, t, Grad), FLD(Gear + 1).Pfull(nU)) - Pe = Math.Max(Pe, FLD(Gear + 1).Pdrag(nU)) - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - nnUp = GBX.Shiftpolygons(Gear + 1).fGSnUup(Tq) - nnDown = GBX.Shiftpolygons(Gear + 1).fGSnUdown(Tq) - - 'Max Torque - MdMax = FLD(Gear + 1).Pfull(nU, LastPeNorm) * 1000 / (nU * 2 * Math.PI / 60) - - Loop - - End If - - Else - - 'Keep last gear - Gear = LastGear - - 'Shift UP inside shift polygons - If GBX.gs_ShiftInside And LastGear < GBX.GearCount Then - - 'Calculate Shift-rpm for higher gear - nU = fnU(Vact, Gear + 1, False) - - 'Continue only if rpm (for higher gear) is below rated rpm - If nU <= ENG.Nrated Then - Pe = Math.Min(fPeGearMod(Gear + 1, t, Grad), FLD(Gear + 1).Pfull(nU)) - Pe = Math.Max(Pe, FLD(Gear + 1).Pdrag(nU)) - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - nnUp = GBX.Shiftpolygons(Gear + 1).fGSnUup(Tq) - nnDown = GBX.Shiftpolygons(Gear + 1).fGSnUdown(Tq) - - 'Max Torque - MdMax = FLD(Gear + 1).Pfull(nU, LastPeNorm) * 1000 / (nU * 2 * Math.PI / 60) - - 'Shift up as long as Torque reserve is okay and Gear < Max-Gear and rpm is above DownShift-rpm - Do While Gear < GBX.GearCount AndAlso 1 - Tq / MdMax >= GBX.gs_TorqueResv / 100 AndAlso nU > nnDown '+ 0.1 * (nnUp - nnDown) - - 'Shift UP - Gear += 1 - - 'Continue only if Gear < Max-Gear - If Gear = GBX.GearCount Then Exit Do - - 'Calculate Shift-rpm for higher gear - nU = fnU(Vact, Gear + 1, False) - - 'Continue only if rpm (for higher gear) is below rated rpm - If nU > ENG.Nrated Then Exit Do - - Pe = Math.Min(fPeGearMod(Gear + 1, t, Grad), FLD(Gear + 1).Pfull(nU)) - Pe = Math.Max(Pe, FLD(Gear + 1).Pdrag(nU)) - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - nnUp = GBX.Shiftpolygons(Gear + 1).fGSnUup(Tq) - nnDown = GBX.Shiftpolygons(Gear + 1).fGSnUdown(Tq) - - 'Max Torque - MdMax = FLD(Gear + 1).Pfull(nU, LastPeNorm) * 1000 / (nU * 2 * Math.PI / 60) - - Loop - - - End If - - End If - - End If - -lb10: - '*** Error-Msg-Check *** - 'Current rpm - nU = fnU(Vact, Gear, Clutch = tEngClutch.Slipping) - 'Current power demand - Pe = Math.Min(fPeGearMod(Gear, t, Grad), FLD(Gear).Pfull(nU)) - Pe = Math.Max(Pe, FLD(Gear).Pdrag(nU)) - 'Current torque demand - Tq = Pe * 1000 / (nU * 2 * Math.PI / 60) - - 'If GearCorrection is OFF then return here - Return Gear - - End Function - - Private Function fGearByU(ByVal nU As Single, ByVal V As Single) As Integer - Dim Dif As Single - Dim DifMin As Single - Dim g As Int16 - Dim g0 As Integer - DifMin = 9999 - For g = 1 To GBX.GearCount - Dif = Math.Abs(GBX.Igetr(g) - nU * (2 * VEH.rdyn * Math.PI) / (1000 * V * 60.0 * GBX.Igetr(0))) - If Dif <= DifMin Then - g0 = g - DifMin = Dif - End If - Next - Return g0 - End Function - - 'Function calculating the Power easily for Gear-shift-model - Private Function fPeGearModvD(ByVal t As Integer, ByVal Grad As Single) As Single - Return fPwheel(t, Grad) - End Function - - Private Function fPeGearMod(ByVal Gear As Integer, ByVal t As Integer, ByVal V As Single, ByVal a As Single, ByVal Grad As Single) As Single - Dim PaM As Single - Dim nU As Single - Dim Pwheel As Single - - Pwheel = fPwheel(t, V, a, Grad) - - nU = fnU(V, Gear, False) - - If t = 0 Then - PaM = 0 - Else - PaM = fPaMot(nU, MODdata.nU(t - 1)) - End If - - - If Clutch = tEngClutch.Closed Then - Return (Pwheel + fPlossGB(Pwheel, V, Gear, True) + fPlossDiff(Pwheel, V, True) + fPaG(V, a) + fPaux(t, nU) + PaM) - Else 'Clutch = tEngClutch.Slipping - Return ((Pwheel + fPlossGB(Pwheel, V, Gear, True) + fPlossDiff(Pwheel, V, True) + fPaG(V, a)) / ClutchEta + fPaux(t, nU) + PaM) - End If - - End Function - - Private Function fPeGearMod(ByVal Gear As Integer, ByVal t As Integer, ByVal Grad As Single) As Single - Return fPeGearMod(Gear, t, MODdata.Vh.V(t), MODdata.Vh.a(t), Grad) - End Function - - -#End Region - -#Region "Engine Speed Calculation" - - Private Function fnn(ByVal V As Single, ByVal Gear As Integer, ByVal ClutchSlip As Boolean) As Single - Return (fnU(V, Gear, ClutchSlip) - ENG.Nidle) / (ENG.Nrated - ENG.Nidle) - End Function - - Private Function fnU(ByVal V As Single, ByVal Gear As Integer, ByVal ClutchSlip As Boolean) As Single - Dim akn As Single - Dim U As Single - U = CSng(V * 60.0 * GBX.Igetr(0) * GBX.Igetr(Gear) / (2 * VEH.rdyn * Math.PI / 1000)) - If U < ENG.Nidle Then U = ENG.Nidle - If ClutchSlip Then - akn = ClutchNorm / ((ENG.Nidle + ClutchNorm * (ENG.Nrated - ENG.Nidle)) / ENG.Nrated) - U = (akn * U / ENG.Nrated) * (ENG.Nrated - ENG.Nidle) + ENG.Nidle - End If - Return U - End Function - - Private Function fnUout(ByVal V As Single, ByVal Gear As Integer) As Single - Return V * 60.0 * GBX.Igetr(0) * GBX.Igetr(Gear) / (2 * VEH.rdyn * Math.PI / 1000) - End Function - -#End Region - -#Region "Power Calculation" - - '--------------Power before Diff = At Wheel ------------- - Private Function fPwheel(ByVal t As Integer, ByVal Grad As Single) As Single - Return fPr(MODdata.Vh.V(t), Grad) + fPair(MODdata.Vh.V(t), t) + fPaFZ(MODdata.Vh.V(t), MODdata.Vh.a(t)) + fPs(MODdata.Vh.V(t), Grad) - End Function - - Private Function fPwheel(ByVal t As Integer, ByVal v As Single, ByVal a As Single, ByVal Grad As Single) As Single - Return fPr(v, Grad) + fPair(v, t) + fPaFZ(v, a) + fPs(v, Grad) - End Function - - '----------------Rolling-resistance---------------- - Private Function fPr(ByVal v As Single, ByVal Grad As Single) As Single - Return CSng(Math.Cos(Math.Atan(Grad * 0.01)) * (VEH.Loading + VEH.Mass + VEH.MassExtra) * 9.81 * VEH.Fr0 * v * 0.001) - End Function - - '----------------Drag-resistance---------------- - Private Function fPair(ByVal v As Single, ByVal t As Integer) As Single - Dim vair As Single - Dim Cd As Single - - Select Case VEH.CdMode - - Case tCdMode.ConstCd0 - vair = v - Cd = VEH.Cd - - Case tCdMode.CdOfV - vair = v - Cd = VEH.Cd(v) - - Case Else 'tCdType.CdOfBeta - vair = MODdata.Vh.VairVres(t) - Cd = VEH.Cd(Math.Abs(MODdata.Vh.VairBeta(t))) - - End Select - - Return CSng((Cd * VEH.CrossSecArea * Cfg.AirDensity / 2 * ((vair) ^ 2)) * v * 0.001) - - End Function - - '--------Vehicle Acceleration-capability(Beschleunigungsleistung) -------- - Private Function fPaFZ(ByVal v As Single, ByVal a As Single) As Single - Return CSng(((VEH.Mass + VEH.MassExtra + VEH.m_red + VEH.Loading) * a * v) * 0.001) - End Function - - Private Function fPaMotSimple(ByVal t As Integer, ByVal Gear As Integer, ByVal v As Single, ByVal a As Single) As Single - Return ((ENG.I_mot * (GBX.Igetr(0) * GBX.Igetr(Gear) / (VEH.rdyn / 1000)) ^ 2) * a * v) * 0.001 - End Function - - Public Function fPaMot(ByVal nU As Single, ByVal nUBefore As Single) As Single - If GBX.TCon Then - Return ((ENG.I_mot + GBX.TCinertia) * (nU - nUBefore) * 0.01096 * ((nU + nUBefore) / 2)) * 0.001 - Else - Return (ENG.I_mot * (nU - nUBefore) * 0.01096 * ((nU + nUBefore) / 2)) * 0.001 - End If - End Function - - '----------------Slope resistance ---------------- - Private Function fPs(ByVal v As Single, ByVal Grad As Single) As Single - Return CSng(((VEH.Loading + VEH.Mass + VEH.MassExtra) * 9.81 * Math.Sin(Math.Atan(Grad * 0.01)) * v) * 0.001) - End Function - - '----------------Auxillaries(Nebenaggregate) ---------------- - Public Function fPaux(ByVal t As Integer, ByVal nU As Single) As Single - Return 'Implement your model here!! - End Function - - '-------------------Transmission(Getriebe)------------------- - Private Function fPlossGB(ByVal PvD As Single, ByVal V As Single, ByVal Gear As Integer, ByVal TrLossApprox As Boolean) As Single - Dim Pdiff As Single - Dim Prt As Single - Dim P As Single - Dim nU As Single - - If Gear = 0 Then Return 0 - - nU = (60 * V) / (2 * VEH.rdyn * Math.PI / 1000) * GBX.Igetr(0) * GBX.Igetr(Gear) - - 'Pdiff - Pdiff = fPlossDiff(PvD, V, TrLossApprox) - - If VEH.RtType = tRtType.Secondary Then - Prt = fPlossRt(V, Gear) - Else - Prt = 0 - End If - - '***Differential - ' Power before Transmission; after Differential and Retarder (if Type=Secondary) - P = PvD + Pdiff + Prt - - Return Math.Max(GBX.IntpolPeLoss(Gear, nU, P, TrLossApprox), 0) - - - End Function - - Private Function fPlossDiff(ByVal PvD As Single, ByVal V As Single, ByVal TrLossApprox As Boolean) As Single - - '***Differential - ' Power before Differential - Return Math.Max(GBX.IntpolPeLoss(0, (60 * V) / (2 * VEH.rdyn * Math.PI / 1000) * GBX.Igetr(0), PvD, TrLossApprox), 0) - - End Function - - Private Function fPlossGBfwd(ByVal PeICE As Single, ByVal V As Single, ByVal Gear As Integer, ByVal TrLossApprox As Boolean) As Single - Dim nU As Single - Dim Prt As Single - - If Gear = 0 Then Return 0 - - If VEH.RtType = tRtType.Primary Then - Prt = fPlossRt(V, Gear) - Else - Prt = 0 - End If - - nU = (60 * V) / (2 * VEH.rdyn * Math.PI / 1000) * GBX.Igetr(0) * GBX.Igetr(Gear) - - Return Math.Max(GBX.IntpolPeLossFwd(Gear, nU, PeICE + Prt, TrLossApprox), 0) - - End Function - - Private Function fPlossDiffFwd(ByVal PeIn As Single, ByVal V As Single, ByVal TrLossApprox As Boolean) As Single - Dim nU As Single - - nU = (60 * V) / (2 * VEH.rdyn * Math.PI / 1000) * GBX.Igetr(0) - - Return Math.Max(GBX.IntpolPeLossFwd(0, nU, PeIn, TrLossApprox), 0) - - End Function - - Private Function fPlossRt(ByVal Vist As Single, ByVal Gear As Integer) As Single - Return VEH.RtPeLoss(Vist, Gear) - End Function - - '----------------Gearbox inertia ---------------- - Private Function fPaG(ByVal V As Single, ByVal a As Single) As Single - Dim Mred As Single - Mred = GBX.GbxInertia * (GBX.Igetr(0) / (VEH.rdyn / 1000)) ^ 2 - Return (Mred * a * V) * 0.001 - End Function - -#End Region - - -End Class - - diff --git a/VECTO/MODcalc/cVh.vb b/VECTO/MODcalc/cVh.vb deleted file mode 100644 index c5c7955cf9253d71c93bb1258c331425339d6908..0000000000000000000000000000000000000000 --- a/VECTO/MODcalc/cVh.vb +++ /dev/null @@ -1,694 +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 - -Public Class cVh - 'From DRI file - Private lV As List(Of Single) 'Actual speed. intermediate in seconds - Private lV0ogl As List(Of Single) 'Original DRI - speed . Is not changed - Private lV0 As List(Of Single) 'DRI - speed . Speed ​​reduction at time step t in LV0 (t + 1) is reduced.. - 'DRI-Geschwindigkeit. Bei Geschw.-Reduktion in Zeitschritt t wird LV0(t+1) reduziert. - Private lGears As List(Of Short) - Private lPadd As List(Of Single) - Private lVairVres As List(Of Single) - Private lVairBeta As List(Of Single) - Public Pwheel As List(Of Single) - Public EcoRoll As List(Of Boolean) - - 'Calculated - Private la As List(Of Single) - - 'WegKor |@@| Route(Weg)Correct - Private dWegIst As Double - Public Weg As List(Of Double) - Private WegX As Integer - Private WegV As List(Of Single) - - Public NoDistCorr As List(Of Boolean) - - Private lAlt0 As List(Of Double) - Private ls0 As List(Of Single) - Private iAlt As Integer - Private iAltDim As Integer - - Public Sub Init() - lV = New List(Of Single) - lV0ogl = New List(Of Single) - lV0 = New List(Of Single) - lAlt0 = New List(Of Double) - ls0 = New List(Of Single) - lGears = New List(Of Short) - lPadd = New List(Of Single) - la = New List(Of Single) - Weg = New List(Of Double) - lVairVres = New List(Of Single) - lVairBeta = New List(Of Single) - Pwheel = New List(Of Single) - EcoRoll = New List(Of Boolean) - NoDistCorr = New List(Of Boolean) - iAlt = 1 - iAltDim = 0 - End Sub - - Public Sub CleanUp() - lV = Nothing - lV0ogl = Nothing - lV0 = Nothing - lAlt0 = Nothing - ls0 = Nothing - lGears = Nothing - lPadd = Nothing - la = Nothing - Weg = Nothing - lVairVres = Nothing - lVairBeta = Nothing - EcoRoll = Nothing - Pwheel = Nothing - NoDistCorr = Nothing - End Sub - - Public Sub VehCylceInit() - - Dim s As Integer - Dim sl As Integer - Dim L As List(Of Double) - Dim Val As Single - - 'Speed - If DRI.Vvorg Then - - L = DRI.Values(tDriComp.V) - For s = 0 To MODdata.tDim - lV0.Add(L(s)) - If Not DRI.Scycle Then lV0ogl.Add(L(s)) - lV.Add((L(s + 1) + L(s)) / 2) - If lV(s) < 0.001 Then lV(s) = 0 '<= aus Leistg - Next - - 'Original-speed is longer by 1 - lV0.Add(DRI.Values(tDriComp.V)(MODdata.tDim + 1)) - If DRI.Scycle Then - For s = 0 To MODdata.tDim + 1 - lV0ogl.Add(CSng(DRI.VoglS(s))) - Next - Else - lV0ogl.Add(DRI.Values(tDriComp.V)(MODdata.tDim + 1)) - End If - - 'Strecke (aus Zwischensekunden sonst passiert Fehler) |@@| Segment (from Intermediate-seconds, otherwise Error) - If Not DRI.Scycle Then - Weg.Add(lV(0)) - For s = 1 To MODdata.tDim - Weg.Add(Weg(s - 1) + lV(s)) - Next - End If - - End If - - 'Altitude / distance - If Not DRI.Scycle And DRI.Vvorg Then - L = DRI.Values(tDriComp.Alt) - lAlt0.Add(0) - ls0.Add(lV0(0)) - sl = 0 - For s = 1 To MODdata.tDim + 1 - If lV0(s) > 0 Then - sl += 1 - ls0.Add(ls0(sl - 1) + lV0(s)) - lAlt0.Add(L(s)) - End If - Next - iAltDim = ls0.Count - 1 - End If - - - 'Gear - but not Averaged, rather Gang(t) = DRI.Gear(t) - If DRI.Gvorg Then - L = DRI.Values(tDriComp.Gears) - For s = 0 To MODdata.tDim - 'lGears.Add(Math.Round((DRI.Values(tDriComp.Gears)(s + 1) + DRI.Values(tDriComp.Gears)(s)) / 2, 0, MidpointRounding.AwayFromZero)) - lGears.Add(L(s)) - Next - Else - For s = 0 To MODdata.tDim - lGears.Add(-1) - Next - End If - - 'Padd - If DRI.PaddVorg Then - L = DRI.Values(tDriComp.Padd) - For s = 0 To MODdata.tDim - lPadd.Add((L(s + 1) + L(s)) / 2) - Next - Else - For s = 0 To MODdata.tDim - lPadd.Add(0) - Next - End If - - 'Calculate Acceleration - If DRI.Vvorg Then - L = DRI.Values(tDriComp.V) - For s = 0 To MODdata.tDim - la.Add(L(s + 1) - L(s)) - Next - End If - - 'Vair specifications: Not in Intermediate-seconds! - If DRI.VairVorg Then - - L = DRI.Values(tDriComp.VairVres) - For s = 0 To MODdata.tDim - lVairVres.Add(L(s) / 3.6) - Next - - L = DRI.Values(tDriComp.VairBeta) - For s = 0 To MODdata.tDim - Val = Math.Abs(L(s)) - If Val > 180 Then Val -= 360 - lVairBeta.Add(Val) - Next - - End If - - If DRI.PwheelVorg Then - L = DRI.Values(tDriComp.Pwheel) - For s = 0 To MODdata.tDim - Pwheel.Add(L(s)) - Next - End If - - For s = 0 To MODdata.tDim - EcoRoll.Add(False) - NoDistCorr.Add(False) - Next - End Sub - - Public Sub EngCylceInit() - - Dim s As Integer - Dim L As List(Of Double) - - 'Speed - If DRI.Vvorg Then - - L = DRI.Values(tDriComp.V) - - For s = 0 To MODdata.tDim - lV0.Add(L(s)) - lV0ogl.Add(L(s)) - lV.Add(L(s)) - If lV(s) < 0.001 Then lV(s) = 0 '<= aus Leistg - Next - - 'Distance - Weg.Add(lV(0)) - For s = 1 To MODdata.tDim - Weg.Add(Weg(s - 1) + lV(s)) - Next - - End If - - 'Gear - not Averaged, rather Gear(t) = DRI.Gear(t) - If DRI.Gvorg Then - L = DRI.Values(tDriComp.Gears) - For s = 0 To MODdata.tDim - 'lGears.Add(Math.Round((DRI.Values(tDriComp.Gears)(s + 1) + DRI.Values(tDriComp.Gears)(s)) / 2, 0, MidpointRounding.AwayFromZero)) - lGears.Add(L(s)) - Next - Else - For s = 0 To MODdata.tDim - lGears.Add(-1) - Next - End If - - 'Padd - If DRI.PaddVorg Then - L = DRI.Values(tDriComp.Padd) - For s = 0 To MODdata.tDim - lPadd.Add(L(s)) - Next - Else - For s = 0 To MODdata.tDim - lPadd.Add(0) - Next - End If - - 'Calculate Acceleration - If DRI.Vvorg Then - la.Add(DRI.Values(tDriComp.V)(1) - DRI.Values(tDriComp.V)(0)) - For s = 1 To MODdata.tDim - 1 - la.Add((DRI.Values(tDriComp.V)(s + 1) - DRI.Values(tDriComp.V)(s - 1)) / 2) - Next - la.Add(DRI.Values(tDriComp.V)(MODdata.tDim) - DRI.Values(tDriComp.V)(MODdata.tDim - 1)) - End If - End Sub - - Public Sub SetSpeed0(ByVal t As Integer, ByVal v0 As Single) - lV0(t + 1) = v0 - lV(t) = (lV0(t + 1) + lV0(t)) / 2 - la(t) = lV0(t + 1) - lV0(t) - If t < MODdata.tDim Then - lV(t + 1) = (lV0(t + 2) + lV0(t + 1)) / 2 - la(t + 1) = lV0(t + 2) - lV0(t + 1) - End If - End Sub - - Public Sub SetSpeed(ByVal t As Integer, ByVal v As Single) - - If 2 * v - lV0(t) < 0 Then v = lV0(t) / 2 - - lV0(t + 1) = 2 * v - lV0(t) - lV(t) = v - la(t) = lV0(t + 1) - lV0(t) - If t < MODdata.tDim Then - lV(t + 1) = (lV0(t + 2) + lV0(t + 1)) / 2 - la(t + 1) = lV0(t + 2) - lV0(t + 1) - End If - End Sub - - Public Function ReduceSpeed(ByVal t As Integer, ByVal p As Single) As Boolean - - If lV0(t + 1) = 0 Then Return False - - lV0(t + 1) *= p - lV(t) = (lV0(t + 1) + lV0(t)) / 2 - la(t) = lV0(t + 1) - lV0(t) - If t < MODdata.tDim Then - lV(t + 1) = (lV0(t + 2) + lV0(t + 1)) / 2 - la(t + 1) = lV0(t + 2) - lV0(t + 1) - End If - - Return True - End Function - - - Public Sub SetMaxAcc(ByVal t As Integer) - Dim a As Single - Dim v As Single - Dim v0plus As Single - Dim a0 As Single - - v0plus = lV0(t + 1) - - v = (v0plus + lV0(t)) / 2 - a0 = VEC.aDesMax(v) - - v0plus = lV0(t) + a - v = (v0plus + lV0(t)) / 2 - a = VEC.aDesMax(v) - - Do While Math.Abs(a - a0) > 0.0001 - - a0 = a - - v0plus = lV0(t) + a - v = (v0plus + lV0(t)) / 2 - a = VEC.aDesMax(v) - - Loop - - la(t) = a - lV0(t + 1) = lV0(t) + a - lV(t) = (lV0(t + 1) + lV0(t)) / 2 - If t < MODdata.tDim Then - lV(t + 1) = (lV0(t + 2) + lV0(t + 1)) / 2 - la(t + 1) = lV0(t + 2) - lV0(t + 1) - End If - End Sub - - - Public Sub SetMinAccBackw(ByVal t As Integer) - Dim a As Single - Dim v As Single - Dim v0 As Single - Dim a0 As Single - - v0 = lV0(t) - - v = (lV0(t + 1) + v0) / 2 - a0 = VEC.aDesMin(v) - - v0 = lV0(t + 1) - a - v = (lV0(t + 1) + v0) / 2 - a = VEC.aDesMin(v) - - Do While Math.Abs(a - a0) > 0.0001 - - a0 = a - - v0 = lV0(t + 1) - a - v = (lV0(t + 1) + v0) / 2 - a = VEC.aDesMin(v) - - Loop - - la(t) = a - lV0(t) = lV0(t + 1) - a - lV(t) = (lV0(t + 1) + lV0(t)) / 2 - If t > 0 Then - lV(t - 1) = (lV0(t) + lV0(t - 1)) / 2 - la(t - 1) = lV0(t) - lV0(t - 1) - End If - End Sub - - Public Function DistCorrInit() As Boolean - Dim i As Int16 - - If Not Cfg.DistCorr Then Return True - - If Not DRI.Vvorg Then - WorkerMsg(tMsgID.Err, "Distance Correction not possible without speed input!", "DistCorrInit") - Return False - End If - - - WegX = 0 - dWegIst = 0 - - WegV = New List(Of Single) - - For i = 0 To MODdata.tDim + 1 - WegV.Add(lV0(i)) - Next - - Return True - End Function - - Public Function DistCorrection(ByVal t As Integer, ByVal VehState As tVehState) As Boolean - Dim v As Single - - If Not DRI.Vvorg Then Return False - - v = lV(t) - dWegIst += v - - If Not Cfg.DistCorr Then Return False - - If t + 1 > MODdata.tDim Then Return False - - - If WegX + 2 < MODdata.tDimOgl Then - - 'If repeating of current time-step is closer to the target distance => Repeat time-step - If Not NoDistCorr(t) AndAlso (Math.Abs(dWegIst + Vsoll(t) - Weg(WegX)) < Math.Abs(dWegIst - Weg(WegX))) And v > 1 _ - Then - - Duplicate(t + 1) - MODdata.tDim += 1 - 'Debug.Print("Duplicate," & t & "," & WegIst & "," & Weg(WegX)) - NoDistCorr(t + 1) = True - Return True - - 'If deleting the next time-step is closer to target distance => Delete Next Time-step - ElseIf _ - Not NoDistCorr(t) AndAlso WegX < MODdata.tDimOgl - 1 AndAlso t < MODdata.tDim - 1 AndAlso - Math.Abs(dWegIst - Weg(WegX + 1)) <= Math.Abs(dWegIst - Weg(WegX)) AndAlso v > 1 Then - - Cut(t + 1) - MODdata.tDim -= 1 - 'Debug.Print("Cut," & t & "," & WegIst & "," & Weg(WegX)) - NoDistCorr(t + 1) = True - WegX += 2 - Return True - - Else - - 'No correction - WegX += 1 - Return False - - End If - - End If - - Return False - End Function - - Private Sub Duplicate(ByVal t As Integer) - - lV0.Insert(t + 1, (WegV(t + 1) + WegV(t)) / 2) - WegV.Insert(t + 1, (WegV(t + 1) + WegV(t)) / 2) - - 'If t + 1 < MODdata.tDim Then - ' lV0.Insert(t + 1, (WegV(t + 1) + WegV(t + 2)) / 2) - ' WegV.Insert(t + 1, (WegV(t + 1) + WegV(t + 2)) / 2) - 'Else - ' lV0.Insert(t + 1, WegV(t + 1)) - ' WegV.Insert(t + 1, WegV(t + 1)) - 'End If - - lV0ogl.Insert(t + 1, lV0ogl(t + 1)) - lV.Insert(t, (lV0(t + 1) + lV0(t)) / 2) - la.Insert(t, lV0(t + 1) - lV0(t)) - - If t < MODdata.tDim Then - lV(t + 1) = (lV0(t + 2) + lV0(t + 1)) / 2 - la(t + 1) = lV0(t + 2) - lV0(t + 1) - End If - - lGears.Insert(t, lGears(t)) - lPadd.Insert(t, lPadd(t)) - EcoRoll.Insert(t, EcoRoll(t)) - If DRI.PwheelVorg Then Pwheel.Insert(t, Pwheel(t)) - NoDistCorr.Insert(t, NoDistCorr(t)) - - If DRI.VairVorg Then - lVairVres.Insert(t, lVairVres(t)) - lVairBeta.Insert(t, lVairBeta(t)) - End If - - MODdata.Px.Positions.Insert(t, MODdata.Px.Positions(t)) - - MODdata.Duplicate(t) - End Sub - - Public Sub DuplicatePreRun(ByVal t As Integer) - - lV0.Insert(t, lV0(t)) - - lV0ogl.Insert(t, lV0ogl(t)) - lV.Insert(t, (lV0(t + 1) + lV0(t)) / 2) - la.Insert(t, lV0(t + 1) - lV0(t)) - - If t > 0 Then - lV(t - 1) = (lV0(t) + lV0(t - 1)) / 2 - la(t - 1) = lV0(t) - lV0(t - 1) - End If - - lGears.Insert(t, lGears(t)) - lPadd.Insert(t, lPadd(t)) - EcoRoll.Insert(t, EcoRoll(t)) - If DRI.PwheelVorg Then Pwheel.Insert(t, Pwheel(t)) - NoDistCorr.Insert(t, NoDistCorr(t)) - - If DRI.VairVorg Then - lVairVres.Insert(t, lVairVres(t)) - lVairBeta.Insert(t, lVairBeta(t)) - End If - - MODdata.Duplicate(t) - End Sub - - Private Sub Cut(ByVal t As Integer) - - lV0.RemoveAt(t + 1) - lV0ogl.RemoveAt(t + 1) - WegV.RemoveAt(t + 1) - lV.RemoveAt(t) - la.RemoveAt(t) - - If t < MODdata.tDim Then - lV(t) = (lV0(t + 1) + lV0(t)) / 2 - la(t) = lV0(t + 1) - lV0(t) - End If - - If t < MODdata.tDim - 1 Then - lV(t + 1) = (lV0(t + 2) + lV0(t + 1)) / 2 - la(t + 1) = lV0(t + 2) - lV0(t + 1) - End If - - lGears.RemoveAt(t) - lPadd.RemoveAt(t) - EcoRoll.RemoveAt(t) - If DRI.PwheelVorg Then Pwheel.RemoveAt(t) - NoDistCorr.RemoveAt(t) - - If DRI.VairVorg Then - lVairVres.RemoveAt(t) - lVairBeta.RemoveAt(t) - End If - - MODdata.Px.Positions.RemoveAt(t) - - - MODdata.Cut(t) - End Sub - - Public ReadOnly Property Vsoll(ByVal t As Integer) As Single - Get - Return (lV0ogl(t + 1) + lV0ogl(t)) / 2 - End Get - End Property - - Public ReadOnly Property V(ByVal t As Integer) As Single - Get - Return lV(t) - End Get - End Property - - Public ReadOnly Property V0(ByVal t As Integer) As Single - Get - Return lV0(t) - End Get - End Property - - Public ReadOnly Property GearVorg(ByVal t As Integer) As Short - Get - Return lGears(t) - End Get - End Property - - - Public Sub SetAlt() - Dim Ls As List(Of Double) - Dim Lalt As List(Of Double) - Dim sl As Integer - Dim s As Integer - - 'Altitude / distance - Ls = DRI.Values(tDriComp.s) - Lalt = DRI.Values(tDriComp.Alt) - - lAlt0.Add(Lalt(0)) - ls0.Add(Ls(0)) - - sl = 0 - For s = 1 To DRI.tDim - If Ls(s) > ls0(sl) Then - sl += 1 - ls0.Add(Ls(s)) - lAlt0.Add(Lalt(s)) - End If - Next - iAltDim = ls0.Count - 1 - End Sub - - Public Function fGrad(ByVal s As Double) As Single - Dim i As Int32 - Dim dh As Single - Dim ds As Single - - If Not DRI.Vvorg Then Return 0 - - If ls0(0) >= s Then - i = 1 - GoTo lbInt - End If - - i = iAlt - - If ls0(i - 1) > s Then - - Do While ls0(i - 1) > s And i > 1 - i -= 1 - Loop - - Else - - Do While ls0(i) < s And i < iAltDim - i += 1 - Loop - - End If - - -lbInt: - iAlt = i - - ds = ls0(i) - ls0(i - 1) - dh = lAlt0(i) - lAlt0(i - 1) - Return (dh / ds) * 100 - End Function - - 'IndexInit = 0 ...Set iAlt to 1 - 'IndexInit = 0 ...Set iAlt - 'IndexInit > 0 ...Use IndexStart - Public Function AltIntp(ByVal s As Single, ByVal iAltReset As Boolean) As Single - Dim i As Int32 - - If ls0(0) >= s Then - i = 1 - GoTo lbInt - End If - - If iAltReset Then iAlt = 1 - - i = iAlt - - If ls0(i - 1) > s Then - - Do While ls0(i - 1) > s And i > 1 - i -= 1 - Loop - - Else - - Do While ls0(i) < s And i < iAltDim - i += 1 - Loop - - End If - -lbInt: - iAlt = i - - Return (s - ls0(i - 1)) * (lAlt0(i) - lAlt0(i - 1)) / (ls0(i) - ls0(i - 1)) + lAlt0(i - 1) - End Function - - - Public ReadOnly Property Padd(ByVal t As Integer) As Single - Get - Return lPadd(t) - End Get - End Property - - Public ReadOnly Property a(ByVal t As Integer) As Single - Get - Return la(t) - End Get - End Property - - Public ReadOnly Property VairVres(ByVal t As Integer) As Single - Get - Return lVairVres(t) - End Get - End Property - - Public ReadOnly Property VairBeta(ByVal t As Integer) As Single - Get - Return lVairBeta(t) - End Get - End Property - - Public ReadOnly Property WegIst As Double - Get - Return dWegIst - End Get - End Property - - Public ReadOnly Property WegSoll As Double - Get - Return Weg(WegX) - End Get - End Property -End Class diff --git a/VECTO/M_MAIN.vb b/VECTO/M_MAIN.vb index a6f835a4036a3b02a11c8dbc18a5e7f6374f94e8..11f49623f495c1177ccef0bd68026dc971e49c17 100644 --- a/VECTO/M_MAIN.vb +++ b/VECTO/M_MAIN.vb @@ -16,773 +16,16 @@ Imports System.Collections.Generic ''' <remarks></remarks> Module M_MAIN - Public JobFileList As List(Of String) - Public JobCycleList As List(Of String) + Public JobFileList As List(Of String) + Public JobCycleList As List(Of String) - Public JobFile As String - Public CycleFiles As New List(Of String) - Public CurrentCycleFile As String + Public JobFile As String + Public CycleFiles As New List(Of String) + Public CurrentCycleFile As String - Private iJob As Integer - Private iCycle As Integer - Private CyclesDim As Integer - Private FilesDim As Integer - Private jsubcycle As Integer - Private jsubcycleDim As Integer - Private SigFile As String - ''' <summary> - ''' Main calculation routine. Launched by VECTOworker via Mainform's Start button or command line - ''' </summary> - ''' <returns></returns> - ''' <remarks></remarks> - Public Function VECTO() As tCalcResult - - Dim MsgStrBuilder As System.Text.StringBuilder - - Dim i As Integer - Dim path0 As String - Dim JobAbortedByErr As Boolean - Dim CyclAbrtedByErr As Boolean - Dim MsgOut As Boolean - Dim MsgSrc As String - Dim loading As tLoading - Dim LoadList As New List(Of tLoading) - Dim iLoad As Integer - Dim iLoadDim As Integer - - - - MsgSrc = "Main" - - MsgStrBuilder = New System.Text.StringBuilder - - 'If there are any "unplanned" Aborts - VECTO = tCalcResult.Err - - 'Reset the fault - ''ClearErrors() - - 'Specify Mode and Notification-msg - If Cfg.BatchMode Then - WorkerMsg(tMsgID.Normal, "Starting VECTO Batch...", MsgSrc) - CyclesDim = JobCycleList.Count - 1 - Else - WorkerMsg(tMsgID.Normal, "Starting VECTO...", MsgSrc) - CyclesDim = 0 - End If - FilesDim = JobFileList.Count - 1 - - MsgOut = Not Cfg.BatchMode - - 'License check - - If Cfg.BatchMode Then - If Not Lic.LicFeature(1) Then - WorkerMsg(tMsgID.Err, "Your license does not support Batch Mode!", MsgSrc) - GoTo lbErrBefore - End If - End If - - If FilesDim = -1 Then - WorkerMsg(tMsgID.Err, "No Job Files defined.", MsgSrc) - GoTo lbErrBefore - End If - - If CyclesDim = -1 And Cfg.BatchMode Then - WorkerMsg(tMsgID.Err, "No Driving Cycles defined.", MsgSrc) - GoTo lbErrBefore - End If - - 'Create BATCH Output-folder if necessary - If Cfg.BatchMode Then - Select Case UCase(Cfg.BATCHoutpath) - Case sKey.JobPath - GoTo lbSkip0 - Case Else - path0 = Cfg.BATCHoutpath - End Select - If Not IO.Directory.Exists(path0) Then - Try - IO.Directory.CreateDirectory(path0) - Catch ex As Exception - WorkerMsg(tMsgID.Err, "Failed to create output directory " & path0 & " !", MsgSrc) - GoTo lbErrBefore - End Try - End If - End If -lbSkip0: - - 'MOD-Data class initialization - MODdata = New cMOD - - 'New signature file - Lic.FileSigning.NewFile() - - 'ERG-class initialization - WorkerMsg(tMsgID.Normal, "Analyzing input files", MsgSrc) - VSUM = New cVSUM - If Not VSUM.Init(JobFileList(0)) Then GoTo lbErrBefore - - SigFile = Left(VSUM.VSUMfile, VSUM.VSUMfile.Length - 5) & ".vsig" - - 'Warning on invalid/unrealistic settings - If Cfg.AirDensity > 2 Then WorkerMsg(tMsgID.Err, "Air Density = " & Cfg.AirDensity & " ?!", MsgSrc) - - If Cfg.DeclMode Then - LoadList.Add(tLoading.EmptyLoaded) - LoadList.Add(tLoading.RefLoaded) - LoadList.Add(tLoading.FullLoaded) - iLoadDim = 2 - Else - LoadList.Add(tLoading.UserDefLoaded) - iLoadDim = 0 - End If - - 'Progbar-Init - WorkerProgInit() - - '-------------------------------------------------------------------------------------------- - ' Calculation Loop for all Preset-cycles and Vehicles: - ' - '********************************************************************************************** - '**************************************** Job loop **************************************** - '********************************************************************************************** - For iJob = 0 To FilesDim - - iCycle = 0 '<= Damit NrOfRun stimmt - - - JobFile = fFileRepl(JobFileList(iJob)) - - WorkerMsg(tMsgID.NewJob, "Job: " & (iJob * (CyclesDim + 1) + iCycle + 1) & " / " & ((FilesDim + 1) * (CyclesDim + 1)) & " | " & fFILE(JobFile, True), MsgSrc) - WorkerStatus("Current Job: " & (iJob * (CyclesDim + 1) + iCycle + 1) & " / " & ((FilesDim + 1) * (CyclesDim + 1)) & " | " & fFILE(JobFile, True)) - WorkerJobStatus(iJob, "initialising... ", tJobStatus.Running) - - JobAbortedByErr = False - MSGwarn = 0 - MSGerror = 0 - - 'Check if Abort - If VECTOworker.CancellationPending Then GoTo lbAbort - - 'If error when read GEN - CurrentCycleFile = "" - - 'Reading the input files - WorkerMsg(tMsgID.Normal, "Reading input files", MsgSrc) - If Not ReadFiles() Then - JobAbortedByErr = True - GoTo lbNextJob - End If - - 'Initialise Report - If Cfg.DeclMode Then Declaration.ReportInit() - - - 'BATCH: Create Output-sub-folder - If Cfg.BatchMode And Cfg.ModOut And Cfg.BATCHoutSubD Then - Select Case UCase(Cfg.BATCHoutpath) - Case sKey.JobPath - path0 = fPATH(JobFile) - Case Else - path0 = Cfg.BATCHoutpath - End Select - path0 &= fFILE(JobFile, False) & "\" - If Not IO.Directory.Exists(path0) Then - Try - IO.Directory.CreateDirectory(path0) - Catch ex As Exception - WorkerMsg(tMsgID.Err, "Failed to create output directory " & path0 & " !", MsgSrc) - JobAbortedByErr = True - GoTo lbNextJob - End Try - End If - End If - - '********************************************************************************************** - '************************************** Cycle-loop **************************************** - '********************************************************************************************** - For iCycle = 0 To CyclesDim - - - CyclAbrtedByErr = False - - If Cfg.BatchMode Then - - 'ProgBar - ProgBarCtrl.ProgLock = True - ProgBarCtrl.ProgJobInt = 0 - ProgBarCtrl.ProgOverallStartInt = 100 * (iJob * (CyclesDim + 1) + iCycle) / ((FilesDim + 1) * (CyclesDim + 1)) - ProgBarCtrl.PgroOverallEndInt = 100 * (iJob * (CyclesDim + 1) + iCycle + 1) / ((FilesDim + 1) * (CyclesDim + 1)) - ProgBarCtrl.ProgLock = False - - - 'BATCH mode: Cycles from DRI list - CycleFiles.Clear() - CycleFiles.Add(fFileRepl(JobCycleList(iCycle))) - - 'Status - WorkerMsg(tMsgID.NewJob, "Cycle: " & (iJob * (CyclesDim + 1) + iCycle + 1) & " / " & ((FilesDim + 1) * (CyclesDim + 1)) & " | " & fFILE(JobFile, True) & " | " & fFILE(CycleFiles(0), True), MsgSrc) - WorkerStatus("Current Job: " & (iJob * (CyclesDim + 1) + iCycle + 1) & " / " & ((FilesDim + 1) * (CyclesDim + 1)) & " | " & fFILE(JobFile, True) & " | " & fFILE(CycleFiles(0), True)) - WorkerJobStatus(iJob, "running... " & iCycle + 1 & "/" & (CyclesDim + 1), tJobStatus.Running) - - 'Output name definition - Select Case UCase(Cfg.BATCHoutpath) - Case sKey.JobPath - path0 = fPATH(JobFile) - Case Else - path0 = Cfg.BATCHoutpath - End Select - - If Cfg.BATCHoutSubD Then - MODdata.ModOutpName = path0 & fFILE(JobFile, False) & "\" & fFILE(JobFile, False) & "_" & fFILE(CycleFiles(0), False) - Else - MODdata.ModOutpName = path0 & fFILE(JobFile, False) & "_" & fFILE(CycleFiles(0), False) - End If - - End If - - '****************************************************************************************** - '********************************** VECTO-Cycle-loop START ********************************** - '****************************************************************************************** - jsubcycleDim = CycleFiles.Count - 1 - - If jsubcycleDim = -1 Then - WorkerMsg(tMsgID.Err, "No driving cycle defined!", MsgSrc) - JobAbortedByErr = True - GoTo lbNextJob - End If - - jsubcycle = -1 - For Each CurrentCycleFile In CycleFiles - - - 'AA-TB - 'SET CURRENT CYCLE FILE BEING USED IN AAUX - mAAUX_Global.CurrentCycleFile= CurrentCycleFile - - jsubcycle += 1 - - ProgBarCtrl.ProgJobInt = 0 - - - If Not Cfg.BatchMode Then - MODdata.ModOutpName = fFileWoExt(JobFile) & "_" & fFILE(CurrentCycleFile, False) - WorkerMsg(tMsgID.NewJob, "Cycle: " & (jsubcycle + 1) & " / " & (jsubcycleDim + 1) & " | " & fFILE(CurrentCycleFile, True), MsgSrc) - End If - - If Cfg.DeclMode Then - - If Not Declaration.CalcInitCycle(jsubcycle) Then - JobAbortedByErr = True - GoTo lbNextJob - End If - - WorkerMsg(tMsgID.Normal, "WHTC Correction Factor: " & Declaration.WHTCcorrFactor, MsgSrc) - - Declaration.ReportAddCycle() - - End If - - - '************************************************************************************** - '***************************** VECTO-loading-loop START ******************************* - '************************************************************************************** - iLoad = -1 - For Each loading In LoadList - - iLoad += 1 - - 'ProgBar - If Not Cfg.BatchMode Then - ProgBarCtrl.ProgLock = True - ProgBarCtrl.ProgJobInt = 0 - ProgBarCtrl.ProgOverallStartInt = 100 * iJob / (FilesDim + 1) + 100 * jsubcycle / (jsubcycleDim + 1) * 1 / (FilesDim + 1) + 100 * iLoad / (iLoadDim + 1) * 1 / ((FilesDim + 1) * (jsubcycleDim + 1)) - ProgBarCtrl.PgroOverallEndInt = 100 * iJob / (FilesDim + 1) + 100 * jsubcycle / (jsubcycleDim + 1) * 1 / (FilesDim + 1) + 100 * (iLoad + 1) / (iLoadDim + 1) * 1 / ((FilesDim + 1) * (jsubcycleDim + 1)) - ProgBarCtrl.ProgLock = False - WorkerJobStatus(iJob, "running... " & (iLoad + 1) + jsubcycle * (iLoadDim + 1) & "/" & (jsubcycleDim + 1) * (iLoadDim + 1), tJobStatus.Running) - End If - - - If Cfg.DeclMode Then - - 'Results filename with loading - MODdata.ModOutpName = fFileWoExt(JobFile) & "_" & fFILE(CurrentCycleFile, False) & "_" & ConvLoading(loading) - - WorkerMsg(tMsgID.NewJob, "Loading: " & (iLoad + 1) & " / " & (iLoadDim + 1) & " | " & ConvLoading(loading), MsgSrc) - - If Not Declaration.CalcInitLoad(loading) Then - JobAbortedByErr = True - GoTo lbNextJob - End If - - WorkerStatus("Current Job: " & (iJob * (CyclesDim + 1) + iCycle + 1) & " / " & (FilesDim + 1) & " | " & fFILE(JobFile, True) & " | " & Declaration.CurrentMission.NameStr & " | " & ConvLoading(loading)) - - Else - - If Not Cfg.BatchMode Then WorkerStatus("Current Job: " & (iJob * (CyclesDim + 1) + iCycle + 1) & " / " & (FilesDim + 1) & " | " & fFILE(JobFile, True) & " | " & fFILE(CurrentCycleFile, True)) - - End If - - 'Clean up - MODdata.Init() - - 'Read cycle - DRI = New cDRI - DRI.FilePath = CurrentCycleFile - If Not DRI.ReadFile Then - CyclAbrtedByErr = True - GoTo lbAusg - End If - - 'Grad to Alt - DRI.GradToAlt() - - 'Convert v(s) into v(t) (optional) - If DRI.Scycle Then - - MODdata.Vh.SetAlt() - - - If MsgOut Then WorkerMsg(tMsgID.Normal, "Converting cycle (v(s) => v(t))", MsgSrc) - - If Not DRI.ConvStoT() Then - CyclAbrtedByErr = True - GoTo lbAusg - End If - End If - - 'If first time step is Zero then duplicate first values to start cycle with vehicle standing. - If DRI.Vvorg AndAlso DRI.tDim > 1 AndAlso DRI.Values(tDriComp.V)(0) < 0.0001 AndAlso DRI.Values(tDriComp.V)(1) >= 0.0001 Then - DRI.FirstZero() - End If - - 'Convert to 1Hz (optional) - does not apply to v(s) cycles because timestep is missing - If DRI.Tvorg Then - If MsgOut Then WorkerMsg(tMsgID.Normal, "Converting cycle to 1Hz", MsgSrc) - If Not DRI.ConvTo1Hz() Then - 'Error-notification in DRI.Convert() - CyclAbrtedByErr = True - GoTo lbAusg - End If - End If - - - '---------------------------------------------------------------------------- - '---------------------------------------------------------------------------- - - 'Initialize Cycle-specs (Speed, Accel, ...) - MODdata.CycleInit() - - If VEC.EngOnly Then - - If MsgOut Then WorkerMsg(tMsgID.Normal, "Engine Only Calc", MsgSrc) - - 'Rechne .npi-Leistung in Pe und P_clutch um |@@| Expect Npi-Power into Pe and P_clutch - If Not MODdata.Px.Eng_Calc(False) Then - CyclAbrtedByErr = True - GoTo lbAusg - End If - - Else - - 'Init auxiliaries - If Not VEC.AuxInit() Then - 'Error-notification within AuxInit() - JobAbortedByErr = True - GoTo lbNextJob - End If - - 'CAUTION: VehmodeInit() requires information from VECTO and DRI! - If Not VEH.VehmodeInit() Then - 'Error-notification within VehmodeInit() - JobAbortedByErr = True - GoTo lbNextJob - End If - - If GBX.TCon Then - If Not GBX.TCinit Then - 'Error-notification within TCinit() - JobAbortedByErr = True - GoTo lbNextJob - End If - End If - - - If MsgOut Then WorkerMsg(tMsgID.Normal, "Driving Cycle Preprocessing", MsgSrc) - If DRI.Vvorg Then - If Not MODdata.Px.PreRun Then - CyclAbrtedByErr = True - GoTo lbAusg - End If - End If - - If VECTOworker.CancellationPending Then GoTo lbAbort - - - - If MsgOut Then WorkerMsg(tMsgID.Normal, "Vehicle Calc", MsgSrc) - - If Not MODdata.Vh.DistCorrInit() Then - CyclAbrtedByErr = True - GoTo lbAusg - End If - - If Not MODdata.Px.Calc() Then - CyclAbrtedByErr = True - GoTo lbAusg - End If - - - If VECTOworker.CancellationPending Then GoTo lbAbort - - 'Calculate CycleKin (for erg/sum, etc.) - If DRI.Vvorg Then MODdata.CylceKin.Calc() - - End If - '---------------------------------------------------------------------------- - '---------------------------------------------------------------------------- - - - If MsgOut Then WorkerMsg(tMsgID.Normal, "FC Interpolation", MsgSrc) - - 'Calculate FC - MODdata.FCcalc(True) - - If VECTOworker.CancellationPending Then GoTo lbAbort - - '*** second-by-second output *** - If Cfg.ModOut Then - If MsgOut Then WorkerMsg(tMsgID.Normal, "Writing modal output", MsgSrc) - If Not MODdata.Output() Then - CyclAbrtedByErr = True - GoTo lbAusg - End If - - WorkerMsg(tMsgID.Normal, "Modal Results written to: " & fFILE(MODdata.ModOutpName & ".vmod", True), MsgSrc, MODdata.ModOutpName & ".vmod") - - End If - - -lbAusg: - - If VECTOworker.CancellationPending Then GoTo lbAbort - - 'Status-Update - ProgBarCtrl.ProgLock = True - If Cfg.BatchMode Then - WorkerProgJobEnd(100 * (iJob * (CyclesDim + 1) + iCycle + 1) / ((FilesDim + 1) * (CyclesDim + 1))) - Else - WorkerProgJobEnd(100 * iJob / (FilesDim + 1) + 100 * jsubcycle / (jsubcycleDim + 1) * 1 / (FilesDim + 1) + 100 * (iLoad + 1) / (iLoadDim + 1) * 1 / ((FilesDim + 1) * (jsubcycleDim + 1))) - End If - - If Cfg.DeclMode Then - Declaration.ReportAddResults() - End If - - 'VSUM Output (first Calculation - Initialization & Header) - If Not VSUM.WriteVSUM(iJob * (CyclesDim + 1) + iCycle + 1, fFILE(JobFile, True), fFILE(CurrentCycleFile, True), CyclAbrtedByErr) Then GoTo lbErrInJobLoop - - 'Data Cleanup - MODdata.CleanUp() - - Next - - '******************************************************************************** - '******************** END *** VECTO-loading loop *** END ************************ - '******************************************************************************** - - - Next - - '****************************************************************************************** - '************************* END *** VECTO Cycle-loop *** END ************************* - '****************************************************************************************** - - - Next - '********************************************************************************************** - '****************************** END *** Cycle-loop *** END ****************************** - '********************************************************************************************** - - If Cfg.DeclMode Then - WorkerMsg(tMsgID.Normal, "Writing report file", MsgSrc) - If Declaration.WriteReport() Then - WorkerMsg(tMsgID.Normal, "Report written to: " & fFILE(Declaration.Report.Filepath, True), MsgSrc, "<RUN>" & Declaration.Report.Filepath) - Else - WorkerMsg(tMsgID.Err, "Failed to write pdf report!", MsgSrc) - JobAbortedByErr = True - GoTo lbNextJob - End If - End If - -lbNextJob: - - If JobAbortedByErr Or (CyclAbrtedByErr And CyclesDim = 0) Then - - If JobAbortedByErr Then - If CInt(iJob * (CyclesDim + 1) + 1) = CInt((iJob + 1) * (CyclesDim + 1)) Then - VSUM.WriteVSUM(((iJob + 1) * (CyclesDim + 1)).ToString, fFILE(JobFile, True), "-", True) - Else - VSUM.WriteVSUM((iJob * (CyclesDim + 1) + 1).ToString & ".." & ((iJob + 1) * (CyclesDim + 1)).ToString, fFILE(JobFile, True), "-", True) - End If - End If - - WorkerJobStatus(iJob, "Aborted due to error!", tJobStatus.Err) - - Else - - MsgStrBuilder.Length = 0 - MsgStrBuilder.Append("done") - 'If GEN.irechwahl = tCalcMode.cmHEV Then MsgStrBuilder.Append(" (dSOC = " & SOC(MODdata.tDim) - SOC(0) & ")") - - 'Add input file list to signature list - If VEC.CreateFileList Then - For i = 0 To VEC.FileList.Count - 1 - Lic.FileSigning.AddFile(VEC.FileList(i)) - Next - Else - WorkerMsg(tMsgID.Err, "Could not create file list for signing!", MsgSrc) - End If - - If MSGwarn > 0 Then - MsgStrBuilder.Append(". " & MSGwarn & " Warning") - If MSGwarn > 1 Then MsgStrBuilder.Append("s") - End If - - If MSGerror > 0 Then - MsgStrBuilder.Append(". " & MSGerror & " Error") - If MSGerror > 1 Then MsgStrBuilder.Append("s") - End If - - If MSGerror > 0 Then - WorkerJobStatus(iJob, MsgStrBuilder.ToString & ".", tJobStatus.Warn) - Else - WorkerJobStatus(iJob, MsgStrBuilder.ToString & ".", tJobStatus.OK) - End If - - End If - - 'Check whether Abort - If VECTOworker.CancellationPending Then GoTo lbAbort - - Next - - '********************************************************************************************** - '******************************* END *** Job loop *** END ******************************* - '********************************************************************************************** - - WorkerMsg(tMsgID.Normal, "Summary Results written to: " & fFILE(VSUM.VSUMfile, True), MsgSrc, VSUM.VSUMfile) - - 'JSON Erg Output - If VSUM.WriteJSON() Then - WorkerMsg(tMsgID.Normal, "Summary Results (JSON) written to: " & fFILE(VSUM.VSUMfile & ".json", True), MsgSrc, VSUM.VSUMfile & ".json") - Else - WorkerMsg(tMsgID.Err, "Failed to write JSON Summary Results!", MsgSrc) - End If - - - 'Write file signatures - WorkerMsg(tMsgID.Normal, "Signing files", MsgSrc) - Lic.FileSigning.Mode = vectolic.cFileSigning.tMode.Auto - - If Lic.FileSigning.WriteSigFile(SigFile, LicSigAppCode) Then - WorkerMsg(tMsgID.Normal, "Files signed successfully: " & fFILE(SigFile, True), MsgSrc, "<GUI>" & SigFile) - Else - WorkerMsg(tMsgID.Err, "Failed to sign files! " & Lic.FileSigning.ErrorMsg, MsgSrc) - End If - - WorkerMsg(tMsgID.Normal, "done", MsgSrc) - VECTO = tCalcResult.Done - GoTo lbExit - - -lbErrBefore: '!!!!!!!!!! Abbruch bevor (!!!) der erste Job angefangen wurde !!!!!!!!!!! - WorkerMsg(tMsgID.Normal, "aborted", MsgSrc) - VECTO = tCalcResult.Err - - For i = 0 To FilesDim - WorkerJobStatus(i, "", tJobStatus.Undef) - Next - - GoTo lbExit - - -lbErrInJobLoop: - WorkerMsg(tMsgID.Normal, "aborted", MsgSrc) - WorkerJobStatus(iJob, "aborted", tJobStatus.Err) - VECTO = tCalcResult.Err - - For i = iJob + 1 To FilesDim - WorkerJobStatus(i, "", tJobStatus.Undef) - Next - - MODdata.CleanUp() - - GoTo lbExit - -lbAbort: - WorkerMsg(tMsgID.Normal, "aborted", MsgSrc) - WorkerJobStatus(iJob, "aborted", tJobStatus.Warn) - VECTO = tCalcResult.Abort - - For i = iJob + 1 To FilesDim - WorkerJobStatus(i, "", tJobStatus.Undef) - Next - - MODdata.CleanUp() - -lbExit: - VEC = Nothing - VEH = Nothing - MAP = Nothing - DRI = Nothing - MODdata = Nothing - VSUM = Nothing - - ENG = Nothing - GBX = Nothing - - End Function - - Public Function ReadFiles() As Boolean - Dim sb As cSubPath - Dim OtherModeString As String - - - Dim MsgSrc As String - - MsgSrc = "Main/ReadInp" - - If Cfg.DeclMode Then - OtherModeString = "Engineering" - Else - OtherModeString = "Declaration" - End If - - '----------------------------- ~VECTO~ ----------------------------- - 'Read Job file - If UCase(fEXT(JobFile)) <> ".VECTO" Then - WorkerMsg(tMsgID.Err, "Only .VECTO files are supported in this mode", MsgSrc) - Return False - End If - - VEC = New cVECTO - VEC.FilePath = JobFile - - Try - If Not VEC.ReadFile() Then - WorkerMsg(tMsgID.Err, "Cannot read .vecto file (" & JobFile & ")", MsgSrc) - Return False - End If - Catch ex As Exception - WorkerMsg(tMsgID.Err, "File read error! (" & JobFile & ")", MsgSrc, JobFile) - Return False - End Try - - 'Check if file was saved in different mode - If Cfg.DeclMode <> VEC.SavedInDeclMode Then WorkerMsg(tMsgID.Warn, "Job file was created in " & OtherModeString & " Mode! Some parameters might be missing and cause errors.", MsgSrc, "<GUI>" & JobFile) - - - '----------------------------- ~VEH~ ----------------------------- - VEH = New cVEH - - 'Read vehicle specifications - If Not VEC.EngOnly Then - VEH.FilePath = VEC.PathVEH - Try - If Not VEH.ReadFile Then Return False - Catch ex As Exception - WorkerMsg(tMsgID.Err, "File read error! (" & VEC.PathVEH & ")", MsgSrc, VEC.PathVEH) - Return False - End Try - - 'Check if file was saved in different mode - If Cfg.DeclMode <> VEH.SavedInDeclMode Then WorkerMsg(tMsgID.Warn, "Vehicle file was created in " & OtherModeString & " Mode! Some parameters might be missing and cause errors.", MsgSrc, "<GUI>" & VEC.PathVEH) - - If Not VEH.Validate Then Return False - - End If - - - If Cfg.DeclMode Then - If Not Declaration.SetRef() Then - WorkerMsg(tMsgID.Err, "Vehicle Configuration not found in Segment Table!", MsgSrc) - Return False - End If - End If - - - If Cfg.DeclMode Then - If Not VEC.DeclInit() Then Return False - End If - - - CycleFiles.Clear() - For Each sb In VEC.CycleFiles - CycleFiles.Add(sb.FullPath) - Next - - 'Error message in init() - If Not VEC.Init Then Return False - - - - '---------------------- ~ENG~ (incl. FLD, MAP) ---------------------- - ENG = New cENG - ENG.FilePath = VEC.PathENG - Try - If Not ENG.ReadFile Then Return False - Catch ex As Exception - WorkerMsg(tMsgID.Err, "File read error! (" & VEC.PathENG & ")", MsgSrc, VEC.PathENG) - Return False - End Try - - 'Check if file was saved in different mode - If Cfg.DeclMode <> ENG.SavedInDeclMode Then WorkerMsg(tMsgID.Warn, "Engine file was created in " & OtherModeString & " Mode! Some parameters might be missing and cause errors.", MsgSrc, "<GUI>" & VEC.PathENG) - - If Not ENG.Init() Then Return False - - - '----------------------------- ~GBX~ ----------------------------- - GBX = New cGBX - - If Not VEC.EngOnly Then - GBX.FilePath = VEC.PathGBX - Try - If Not GBX.ReadFile Then Return False - If Not GBX.GSinit Then Return False - Catch ex As Exception - WorkerMsg(tMsgID.Err, "File read error! (" & VEC.PathGBX & ")", MsgSrc, VEC.PathGBX) - Return False - End Try - - 'Check if file was saved in different mode - If Cfg.DeclMode <> GBX.SavedInDeclMode Then WorkerMsg(tMsgID.Warn, "Gearbox file was created in " & OtherModeString & " Mode! Some parameters might be missing and cause errors.", MsgSrc, "<GUI>" & VEC.PathGBX) - - End If - - 'Must be called after cENG.Init because FLD must be loaded - If Cfg.DeclMode Then - If Not ENG.DeclInit() Then Return False - End If - - - 'Must be after ENG.Init() - If Cfg.DeclMode Then - If Not GBX.DeclInit() Then Return False - End If - - - - - Return True - - End Function - - '--------------------------------------------------------------------------- + '--------------------------------------------------------------------------- End Module diff --git a/VECTO/VECTO.vbproj b/VECTO/VECTO.vbproj index 08875bd256ed54caa49ca070eeb382be20877eae..b5591551ea24fa8af37488393e6c7de8d6505646 100644 --- a/VECTO/VECTO.vbproj +++ b/VECTO/VECTO.vbproj @@ -228,7 +228,6 @@ <Compile Include="cDEV.vb" /> <Compile Include="File Browser\cFileBrowser.vb" /> <Compile Include="mAAUX_Global.vb" /> - <Compile Include="MODcalc\cVh.vb" /> <Compile Include="File Browser\FB_Dialog.designer.vb"> <DependentUpon>FB_Dialog.vb</DependentUpon> </Compile> @@ -241,8 +240,6 @@ <Compile Include="File Browser\FB_FavDlog.vb"> <SubType>Form</SubType> </Compile> - <Compile Include="MODcalc\cPower.vb" /> - <Compile Include="MODcalc\cMOD.vb" /> <Compile Include="Input Files\cFLD.vb" /> <Compile Include="Input Files\cMAP.vb" /> <Compile Include="Input Files\cDRI.vb" /> @@ -291,7 +288,6 @@ <SubType>Form</SubType> </Compile> <Compile Include="M_MAIN.vb" /> - <Compile Include="cVSUM.vb" /> <Compile Include="GUI\F_MAINForm.vb"> <SubType>Form</SubType> </Compile> @@ -300,7 +296,6 @@ <SubType>Form</SubType> </Compile> <Compile Include="File Browser\FB_Global.vb" /> - <Compile Include="cCycleKin.vb" /> <Compile Include="My Project\AssemblyInfo.vb" /> <Compile Include="My Project\Application.Designer.vb"> <AutoGen>True</AutoGen> @@ -1522,6 +1517,7 @@ <Content Include="Resources\up.ico" /> <Content Include="Resources\up.png" /> </ItemGroup> + <ItemGroup /> <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" /> <PropertyGroup> <PostBuildEvent> diff --git a/VECTO/VECTO_Global.vb b/VECTO/VECTO_Global.vb index 0f08bf71e00386cc4e455c7177dbedbc8c19dbab..e4dac8e2beee35bf9c9a5c93b03bd5f149a53be6 100644 --- a/VECTO/VECTO_Global.vb +++ b/VECTO/VECTO_Global.vb @@ -46,9 +46,9 @@ Public Module VECTO_Global Public GBX As cGBX Public MAP As cMAP Public DRI As cDRI - Public MODdata As cMOD + 'Public MODdata As cMOD Public Lic As cLicense - Public VSUM As cVSUM + 'Public VSUM As cVSUM Public DEV As cDEV Public Declaration As cDeclaration diff --git a/VECTO/cCycleKin.vb b/VECTO/cCycleKin.vb deleted file mode 100644 index e3ca0789b0b12c7cc34948caf6684a012314cb0a..0000000000000000000000000000000000000000 --- a/VECTO/cCycleKin.vb +++ /dev/null @@ -1,179 +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 - -Public Class cCycleKin - - Private Const aAccThres As Single = 0.125 '[m/s2] - Private Const aDecThres As Single = -0.125 '[m/s2] - Private Const vStopThres As Single = 0.1 '[m/s] - - 'Fahrzustände in Sekunden |@@| Driving-states in seconds - Private tStop0 As Integer - Private tAcc0 As Integer - Private tDec0 As Integer - Private tCruise0 As Integer - - 'Fahrzustands-Anteile |@@| Driving-state ratios - Private pStop0 As Single - Private pAcc0 As Single - Private pDec0 As Single - Private pCruise0 As Single - - 'Acceleration parameters - Private aAvg0 As Single - Private aPos0 As Single - Private aNeg0 As Single - Private AccNoise0 As Single - - Private MyVSUMentries As List(Of cVSUMentry) - - Public Sub New() - MyVSUMentries = New List(Of cVSUMentry) - MyVSUMentries.Add(New cVSUMentry("a", "[m/s^2]")) - MyVSUMentries.Add(New cVSUMentry("a_pos", "[m/s^2]")) - MyVSUMentries.Add(New cVSUMentry("a_neg", "[m/s^2]")) - MyVSUMentries.Add(New cVSUMentry("Acc.Noise", "[m/s^2]")) - MyVSUMentries.Add(New cVSUMentry("pAcc", "[%]")) - MyVSUMentries.Add(New cVSUMentry("pDec", "[%]")) - MyVSUMentries.Add(New cVSUMentry("pCruise", "[%]")) - MyVSUMentries.Add(New cVSUMentry("pStop", "[%]")) - End Sub - - Public Function ValLine() As String - Dim s As System.Text.StringBuilder - Dim Sepp As String = "," - - s = New System.Text.StringBuilder - - s.Append(aAvg0) - s.Append(Sepp & aPos0) - s.Append(Sepp & aNeg0) - s.Append(Sepp & AccNoise0) - s.Append(Sepp & pAcc0) - s.Append(Sepp & pDec0) - s.Append(Sepp & pCruise0) - s.Append(Sepp & pStop0) - - Return s.ToString - - End Function - - - Public Sub Calc() - Dim t As Integer - Dim t1 As Integer - Dim a3save() As Single - - t1 = MODdata.tDim - - aAvg0 = 0 - aPos0 = 0 - aNeg0 = 0 - AccNoise0 = 0 - tStop0 = 0 - tAcc0 = 0 - tDec0 = 0 - tCruise0 = 0 - pStop0 = 0 - pAcc0 = 0 - pDec0 = 0 - pCruise0 = 0 - ReDim a3save(t1) - - '3s-Accel - a3save(0) = MODdata.Vh.a(0) - For t = 1 To t1 - 1 - a3save(t) = (MODdata.Vh.a(t - 1) + MODdata.Vh.a(t) + MODdata.Vh.a(t + 1)) * (1.0 / 3.0) - Next - a3save(t1) = MODdata.Vh.a(t1) - - 't_apos, t_aneg, t_cruise, t_stop - For t = 0 To t1 - 'Driving-state ratios: Stop/Acc/Dec/Cruise - If MODdata.Vh.V(t) < vStopThres Then - tStop0 += 1 - Else - Select Case a3save(t) - Case Is > aAccThres - tAcc0 += 1 - aPos0 += a3save(t) - Case Is < aDecThres - tDec0 += 1 - aNeg0 += a3save(t) - Case Else - tCruise0 += 1 - End Select - End If - 'Average-Accel - aAvg0 += MODdata.Vh.a(t) - Next - - 'a - aAvg0 /= (t1 + 1) - - 'a-pos - If tAcc0 > 0 Then aPos0 /= tAcc0 - - 'a-neg - If tDec0 > 0 Then aNeg0 /= tDec0 - - 'Acc.Noise - For t = 0 To t1 - AccNoise0 += (MODdata.Vh.a(t) - aAvg0) ^ 2 - Next - AccNoise0 = (AccNoise0 / (t1 + 1)) ^ 0.5 - - pStop0 = tStop0 / (t1 + 1) - pAcc0 = tAcc0 / (t1 + 1) - pDec0 = tDec0 / (t1 + 1) - pCruise0 = tCruise0 / (t1 + 1) - - End Sub - - Public ReadOnly Property VSUMentries As List(Of cVSUMentry) - Get - Return MyVSUMentries - End Get - End Property - - Public ReadOnly Property GetValueString(ByVal key As String) As String - Get - Select Case key - Case "a" - Return aAvg0.ToString - Case "a_pos" - Return aPos0.ToString - Case "a_neg" - Return aNeg0.ToString - Case "Acc.Noise" - Return AccNoise0.ToString - Case "pAcc" - Return pAcc0.ToString - Case "pDec" - Return pDec0.ToString - Case "pCruise" - Return pCruise0.ToString - Case "pStop" - Return pStop0.ToString - Case Else - Return "ERROR - Unknown Key '" & key & "'" - End Select - End Get - End Property - - - -End Class - - - - diff --git a/VECTO/cDeclaration.vb b/VECTO/cDeclaration.vb index 2293ea8d29928eb47005c7a6fc7ffcbaa145e791..a8c7554dc35e9803409a3b889df115299bd8306c 100644 --- a/VECTO/cDeclaration.vb +++ b/VECTO/cDeclaration.vb @@ -885,51 +885,51 @@ lbInt: Report.MissionResults.Add(mr) End Sub - Public Sub ReportAddResults() - Dim lr As New cReport.cLoadingResults - Dim t1 As Integer - Dim t As Integer - Dim Vquer As Single - Dim sum As Double - Dim d As Double - - t1 = MODdata.tDim - - 'Average Speed calculation - sum = 0 - For t = 0 To t1 - sum += MODdata.Vh.V(t) - Next - Vquer = 3.6 * sum / (t1 + 1) - - With lr - - .Loading = VEH.Loading / 1000 - .Speed = Vquer - .FCkm = (100 * MODdata.FCavgFinal / Vquer) / (Cfg.FuelDens * 1000) - .CO2km = Cfg.CO2perFC * (MODdata.FCavgFinal / Vquer) - If VEH.Loading > 0 Then - .FCtkm = .FCkm / .Loading - .CO2tkm = .CO2km / .Loading - End If - .FCerror = MODdata.FCerror - - d = 0 - MODdata.Vh.AltIntp(d, True) - For t = 0 To t1 - .ActualSpeed.Add(MODdata.Vh.V(t) * 3.6) - .TargetSpeed.Add(MODdata.Vh.Vsoll(t) * 3.6) - d += MODdata.Vh.V(t) - .Distance.Add(CSng(d / 1000)) - .Alt.Add(MODdata.Vh.AltIntp(d, False)) - .nU.Add(MODdata.nU(t)) - .Tq.Add(nPeToM(MODdata.nU(t), MODdata.Pe(t))) - Next - - End With - - Report.CurrentMR.Results.Add(CurrentLoading, lr) - End Sub + 'Public Sub ReportAddResults() + ' Dim lr As New cReport.cLoadingResults + ' Dim t1 As Integer + ' Dim t As Integer + ' Dim Vquer As Single + ' Dim sum As Double + ' Dim d As Double + + ' t1 = MODdata.tDim + + ' 'Average Speed calculation + ' sum = 0 + ' For t = 0 To t1 + ' sum += MODdata.Vh.V(t) + ' Next + ' Vquer = 3.6 * sum / (t1 + 1) + + ' With lr + + ' .Loading = VEH.Loading / 1000 + ' .Speed = Vquer + ' .FCkm = (100 * MODdata.FCavgFinal / Vquer) / (Cfg.FuelDens * 1000) + ' .CO2km = Cfg.CO2perFC * (MODdata.FCavgFinal / Vquer) + ' If VEH.Loading > 0 Then + ' .FCtkm = .FCkm / .Loading + ' .CO2tkm = .CO2km / .Loading + ' End If + ' .FCerror = MODdata.FCerror + + ' d = 0 + ' MODdata.Vh.AltIntp(d, True) + ' For t = 0 To t1 + ' .ActualSpeed.Add(MODdata.Vh.V(t) * 3.6) + ' .TargetSpeed.Add(MODdata.Vh.Vsoll(t) * 3.6) + ' d += MODdata.Vh.V(t) + ' .Distance.Add(CSng(d / 1000)) + ' .Alt.Add(MODdata.Vh.AltIntp(d, False)) + ' .nU.Add(MODdata.nU(t)) + ' .Tq.Add(nPeToM(MODdata.nU(t), MODdata.Pe(t))) + ' Next + + ' End With + + ' Report.CurrentMR.Results.Add(CurrentLoading, lr) + 'End Sub Public Function WriteReport() As Boolean diff --git a/VECTO/cJSONparser.vb b/VECTO/cJSONparser.vb index e9c5fa55eb77a92866f259ea52939eb1955d30bd..6d4b57a11a30cefebc726cec7206bfbe4c25934f 100644 --- a/VECTO/cJSONparser.vb +++ b/VECTO/cJSONparser.vb @@ -102,89 +102,6 @@ Public Class JSON Private fullfile As String - Private Function ReadFileXXX(path As String) As Boolean - Dim file As TextFieldParser - - Content.Clear() - - 'check if file exists - If Not IO.File.Exists(path) Then Return False - - 'open file - Try - file = New TextFieldParser(path) - Catch ex As Exception - Return False - End Try - - 'Check if file is empty - If file.EndOfData Then - file.Close() - Return False - End If - - 'read file - fullfile = file.ReadToEnd - - 'close file - file.Close() - - 'trim spaces - fullfile = fullfile.Trim - - 'remove line breaks - fullfile = fullfile.Replace(vbCrLf, "") - - If Left(fullfile, 1) <> "{" Or Right(fullfile, 1) <> "}" Then Return False - - 'parse JSON to Dictionary - Try - Content = GetObject() - Catch ex As Exception - Return False - End Try - - - Return True - End Function - - - Private Function WriteFileXXX(path As String) As Boolean - Dim file As StreamWriter - Dim kv As KeyValuePair(Of String, Object) - Dim str As New StringBuilder - Dim First As Boolean = True - - If Content.Count = 0 Then Return False - - Try - str.AppendLine("{") - For Each kv In Content - If First Then - First = False - Else - str.AppendLine(",") - End If - str.Append(GetKeyValString(1, kv)) - Next - str.AppendLine() - str.AppendLine("}") - Catch ex As Exception - Return False - End Try - - Try - file = My.Computer.FileSystem.OpenTextFileWriter(path, False) - Catch ex As Exception - Return False - End Try - - file.Write(str.ToString) - - file.Close() - - Return True - End Function Private Function GetKeyValString(TabLvl As Integer, ByRef kv As KeyValuePair(Of String, Object)) As String Dim str As New StringBuilder @@ -301,123 +218,6 @@ Public Class JSON Return str End Function - Private Function GetObject() As Dictionary(Of String, Object) - Dim MyDic As Dictionary(Of String, Object) - Dim key As String - Dim obj As Object - Dim i As Integer - Dim i2 As Integer - Dim Valstr As String - Dim ValList As List(Of Object) = Nothing - Dim ArrayMode As Boolean = False - - 'remove { - fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim - - 'new list of key/value pairs - MyDic = New Dictionary(Of String, Object) - - - 'loop through key/value pairs -lb10: - If Left(fullfile, 1) <> ChrW(34) Then - Throw New Exception - Return Nothing - End If - - 'get key - i = fullfile.IndexOf(ChrW(34), 1) - key = Mid(fullfile, 2, i - 1) - fullfile = (Right(fullfile, Len(fullfile) - i - 1)).Trim - fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim - - If key = "" Then - Throw New Exception - Return Nothing - End If - - 'get value (object, number, boolean, array) - If Left(fullfile, 1) = "[" Then - ArrayMode = True - fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim - ValList = New List(Of Object) - End If - -lb20: - If Left(fullfile, 1) = "{" Then - obj = GetObject() - Else - If Left(fullfile, 1) = ChrW(34) Then - 'string - i = fullfile.IndexOf(ChrW(34), 1) - obj = Mid(fullfile, 2, i - 1) - fullfile = (Right(fullfile, Len(fullfile) - i - 1)).Trim - Else - 'number/boolean - i = fullfile.IndexOf(",", 1) - i2 = fullfile.IndexOf("}", 1) - - If i = -1 Then - If i2 = -1 Then - Valstr = Right(fullfile, Len(fullfile) - 1) - fullfile = "" - Else - Valstr = Mid(fullfile, 1, i2) - fullfile = (Right(fullfile, Len(fullfile) - i2)).Trim - End If - Else - If i2 = -1 Or i < i2 Then - Valstr = Mid(fullfile, 1, i) - fullfile = (Right(fullfile, Len(fullfile) - i)).Trim - Else - Valstr = Mid(fullfile, 1, i2) - fullfile = (Right(fullfile, Len(fullfile) - i2)).Trim - End If - End If - - If IsNumeric(Valstr) Then - obj = CDbl(Valstr) - ElseIf (UCase(Valstr)).Trim = "FALSE" Then - obj = False - ElseIf (UCase(Valstr)).Trim = "TRUE" Then - obj = True - ElseIf (UCase(Valstr)).Trim = "NULL" Then - obj = Nothing - Else - Throw New Exception - Return Nothing - End If - - End If - End If - - If ArrayMode Then - ValList.Add(obj) - If Left(fullfile, 1) = "]" Then - ArrayMode = False - fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim - MyDic.Add(key, ValList) - End If - Else - MyDic.Add(key, obj) - End If - - If Left(fullfile, 1) = "," Then - fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim - If ArrayMode Then - GoTo lb20 - Else - GoTo lb10 - End If - End If - - If Left(fullfile, 1) = "}" Then - fullfile = (Right(fullfile, Len(fullfile) - 1)).Trim - End If - - Return MyDic - End Function - #End Region End Class diff --git a/VECTO/cRegression.vb b/VECTO/cRegression.vb index 61241b661f6b4bd534718c1defbcb89ea5613637..b48141723f55224ebed2a8fe020bb8a35102acc7 100644 --- a/VECTO/cRegression.vb +++ b/VECTO/cRegression.vb @@ -40,17 +40,15 @@ Public Class cRegression Public PearsonsR As Double - Public t As Double + Public t As Double - Dim Residuals As ArrayList = New ArrayList + Public Overrides Function ToString() As String - Public Overrides Function ToString() As String + Dim ret As String = "SampleSize=" & Me.SampleSize & vbCrLf & "StandardError=" & Me.StandardError & vbCrLf & "y=" & Me.a & " + " & Me.b & "x" - Dim ret As String = "SampleSize=" & Me.SampleSize & vbCrLf & "StandardError=" & Me.StandardError & vbCrLf & "y=" & Me.a & " + " & Me.b & "x" + Return ret - Return ret - - End Function + End Function End Class diff --git a/VECTO/cVSUM.vb b/VECTO/cVSUM.vb deleted file mode 100644 index c1dbef4cbcb12289126a8ccfe336962c41f79b65..0000000000000000000000000000000000000000 --- a/VECTO/cVSUM.vb +++ /dev/null @@ -1,786 +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 - -Public Class cVSUM - - Private Const FormatVersion As Short = 1 - - Private VSUMpath As String - Private Fvsum As System.IO.StreamWriter - Private HeadInitialized As Boolean - - Private VSUMentries As Dictionary(Of String, cVSUMentry) - Private VSUMentryList As List(Of String) 'Wird benötigt weil Dictionary nicht sortiert ist - 'Needed because Dictionary is not sorted - - Private vsumJSON As JSON - Private ResList As List(Of Dictionary(Of String, Object)) - - - Public Sub New() - HeadInitialized = False - VSUMpath = "" - End Sub - - Public Function VSUMhead() As String - Dim s As New System.Text.StringBuilder - Dim key As String - Dim First As Boolean - - First = True - For Each key In VSUMentryList - If Not First Then s.Append(",") - If DEV.AdvFormat Then - s.Append(VSUMentries(key).Head) - Else - s.Append(VSUMentries(key).Head & " " & VSUMentries(key).Unit) - End If - First = False - Next - - Return s.ToString - - End Function - - Public Function VSUMunit() As String - Dim s As New System.Text.StringBuilder - Dim key As String - Dim First As Boolean - - First = True - For Each key In VSUMentryList - If Not First Then s.Append(",") - s.Append(VSUMentries(key).Unit) - First = False - Next - - Return s.ToString - - End Function - - Public Function VSUMline() As String - Dim VSUMentry As cVSUMentry - Dim s As New System.Text.StringBuilder - Dim t1 As Integer - Dim Vquer As Single - Dim Squer As Single - Dim sum As Double - Dim t As Integer - Dim key As String - Dim First As Boolean - - For Each VSUMentry In VSUMentries.Values - VSUMentry.ValueString = Nothing - Next - - t1 = MODdata.tDim - - 'Vehicle type-independent - VSUMentries("\\T").ValueString = (t1 + 1) - - 'Length, Speed, Slope - If Not VEC.EngOnly Then - - 'Average-Speed. calculation - If DRI.Vvorg Then - sum = 0 - For t = 0 To t1 - sum += MODdata.Vh.V(t) - Next - Vquer = 3.6 * sum / (t1 + 1) - Squer = (Vquer * (t1 + 1) / 3600) - - VSUMentries("\\S").ValueString = Squer - VSUMentries("\\V").ValueString = Vquer - - 'altitude change - VSUMentries("\\G").ValueString = MODdata.Vh.AltIntp(Vquer * (t1 + 1) / 3.6, False) - MODdata.Vh.AltIntp(0, False) - - End If - - 'Auxiliary energy consumption - If VEC.AuxDef Then - For Each key In VEC.AuxPaths.Keys - sum = 0 - For t = 0 To t1 - sum += MODdata.Paux(key)(t) - Next - VSUMentries("\\Eaux_" & UCase(key)).ValueString = sum / 3600 - Next - End If - - - End If - - 'FC - If MODdata.FCerror Then - - VSUMentries("FC_h").ValueString = "ERROR" - - If Not VEC.EngOnly Then VSUMentries("FC_km").ValueString = "ERROR" - - If MODdata.FCAUXcSet Then - VSUMentries("FC-AUXc_h").ValueString = "ERROR" - If Not VEC.EngOnly Then VSUMentries("FC-AUXc_km").ValueString = "ERROR" - End If - - If Cfg.DeclMode Then - VSUMentries("FC-WHTCc_h").ValueString = "ERROR" - If Not VEC.EngOnly Then VSUMentries("FC-WHTCc_km").ValueString = "ERROR" - End If - - Else - - VSUMentries("FC_h").ValueString = MODdata.FCavg - - If Not VEC.EngOnly And DRI.Vvorg Then - - - 'AA - Output Bus Auxiliary values to text files - If (Not VEC Is Nothing AndAlso VEC.AuxiliaryAssembly <> "CLASSIC") Then - Dim FCgKm As Single = MODdata.AA_TotalCycleFC_Grams(MODdata.AA_TotalCycleFC_Grams.Count - 1) / Squer '[g/km] - VSUMentries("FC_km").ValueString = FCgKm - VSUMentries("FC-Final_km").ValueString = FCgKm - - Dim FCFinallKm As Single = ((MODdata.AA_TotalCycleFC_Litres(MODdata.AA_TotalCycleFC_Litres.Count - 1) * 100) / Squer) '[l/100km] - VSUMentries("FCl_km").ValueString = FCFinallKm - - Dim CO2km As Single = Cfg.CO2perFC * FCgKm '[g/km] - VSUMentries("CO2_km").ValueString = CO2km - - If VEH.Loading > 0 Then - VSUMentries("CO2_tkm").ValueString = CO2km / (VEH.Loading / 1000) '[g/tkm] - VSUMentries("FCl_tkm").ValueString = FCFinallKm / (VEH.Loading / 1000) '[l/100tkm] - End If - - Else - - VSUMentries("FC_km").ValueString = (MODdata.FCavg / Vquer) - - VSUMentries("FCl_km").ValueString = (100 * MODdata.FCavgFinal / Vquer) / (Cfg.FuelDens * 1000) '[l/100km] - VSUMentries("CO2_km").ValueString = Cfg.CO2perFC * (MODdata.FCavgFinal / Vquer) '[g/km] - - If VEH.Loading > 0 Then - VSUMentries("CO2_tkm").ValueString = (Cfg.CO2perFC * (MODdata.FCavgFinal / Vquer)) / (VEH.Loading / 1000) '[g/tkm] - VSUMentries("FCl_tkm").ValueString = ((100 * MODdata.FCavgFinal / Vquer) / (Cfg.FuelDens * 1000)) / (VEH.Loading / 1000) '[l/100tkm] - End If - - VSUMentries("FC-Final_km").ValueString = (MODdata.FCavgFinal / Vquer) - - End If - - End If - - If MODdata.FCAUXcSet Then - VSUMentries("FC-AUXc_h").ValueString = MODdata.FCavgAUXc - If Not VEC.EngOnly Then VSUMentries("FC-AUXc_km").ValueString = (MODdata.FCavgAUXc / Vquer) - End If - - If Cfg.DeclMode Then - VSUMentries("FC-WHTCc_h").ValueString = MODdata.FCavgWHTCc - If Not VEC.EngOnly Then VSUMentries("FC-WHTCc_km").ValueString = (MODdata.FCavgWHTCc / Vquer) - End If - - End If - - 'Power, Revolutions - - 'Ppos - sum = 0 - For t = 0 To t1 - sum += Math.Max(0, MODdata.Pe(t)) - Next - VSUMentries("\\Ppos").ValueString = (sum / (t1 + 1)) - - 'Pneg - sum = 0 - For t = 0 To t1 - sum += Math.Min(0, MODdata.Pe(t)) - Next - VSUMentries("\\Pneg").ValueString = (sum / (t1 + 1)) - - - - 'Only Entire-vehicle (not EngOnly) - If Not VEC.EngOnly Then - - 'PwheelPos - sum = 0 - For t = 0 To t1 - sum += Math.Max(0, MODdata.Psum(t)) - Next - VSUMentries("\\PwheelPos").ValueString = (sum / (t1 + 1)) - - 'Pbrake-norm - sum = 0 - For t = 0 To t1 - sum += MODdata.Pbrake(t) - Next - VSUMentries("\\Pbrake").ValueString = (sum / (t1 + 1)) - - 'Eair - sum = 0 - For t = 0 To t1 - sum += MODdata.Pair(t) - Next - VSUMentries("\\Eair").ValueString = (-sum / 3600) - - 'Eroll - sum = 0 - For t = 0 To t1 - sum += MODdata.Proll(t) - Next - VSUMentries("\\Eroll").ValueString = (-sum / 3600) - - 'Egrad - sum = 0 - For t = 0 To t1 - sum += MODdata.Pstg(t) - Next - VSUMentries("\\Egrad").ValueString = (-sum / 3600) - - 'Eacc - sum = 0 - For t = 0 To t1 - sum += MODdata.Pa(t) + MODdata.PaGB(t) + MODdata.PaEng(t) - Next - VSUMentries("\\Eacc").ValueString = (-sum / 3600) - - 'Eaux - sum = 0 - For t = 0 To t1 - sum += MODdata.PauxSum(t) - Next - VSUMentries("\\Eaux").ValueString = (-sum / 3600) - - 'Ebrake - sum = 0 - For t = 0 To t1 - sum += MODdata.Pbrake(t) - Next - VSUMentries("\\Ebrake").ValueString = (sum / 3600) - - 'Etransm - sum = 0 - For t = 0 To t1 - sum += MODdata.PlossDiff(t) + MODdata.PlossGB(t) - Next - VSUMentries("\\Etransm").ValueString = (-sum / 3600) - - 'Retarder - sum = 0 - For t = 0 To t1 - sum += MODdata.PlossRt(t) - Next - VSUMentries("\\Eretarder").ValueString = (-sum / 3600) - - 'TC Losses - sum = 0 - For t = 0 To t1 - sum += MODdata.PlossTC(t) - Next - VSUMentries("\\Etorqueconv").ValueString = (-sum / 3600) - - - - 'Masse, Loading - VSUMentries("\\Mass").ValueString = (VEH.Mass + VEH.MassExtra) - VSUMentries("\\Loading").ValueString = VEH.Loading - - 'CylceKin - For Each VSUMentry In MODdata.CylceKin.VSUMentries - VSUMentries("\\" & VSUMentry.Head).ValueString = MODdata.CylceKin.GetValueString(VSUMentry.Head) - Next - - 'EposICE - sum = 0 - For t = 0 To t1 - sum += Math.Max(0, MODdata.Pe(t)) - Next - VSUMentries("\\EposICE").ValueString = (sum / 3600) - - 'EnegICE - sum = 0 - For t = 0 To t1 - sum += Math.Min(0, MODdata.Pe(t)) - Next - VSUMentries("\\EnegICE").ValueString = (sum / 3600) - - End If - - 'Create Output-string: - First = True - - For Each key In VSUMentryList - If Not First Then s.Append(",") - s.Append(VSUMentries(key).ValueString) - First = False - Next - - Return s.ToString - - End Function - - Private Function HeadInit() As Boolean - Dim MsgSrc As String - - MsgSrc = "SUMALL/Output" - - 'Open file - Try - Fvsum = My.Computer.FileSystem.OpenTextFileWriter(VSUMpath, True, FileFormat) - Fvsum.AutoFlush = True - Catch ex As Exception - WorkerMsg(tMsgID.Err, "Cannot access .vsum file (" & VSUMpath & ")", MsgSrc) - Return False - End Try - - '*** Header / Units - If DEV.AdvFormat Then - Fvsum.WriteLine("Job,Input File,Cycle," & VSUMhead()) - Fvsum.WriteLine("[-],[-],[-]," & VSUMunit()) - Else - Fvsum.WriteLine("Job [-],Input File [-],Cycle [-]," & VSUMhead()) - End If - - 'Close file (will open after each job) - Fvsum.Close() - - HeadInitialized = True - - Return True - - End Function - - Public Function WriteVSUM(ByVal NrOfRunStr As String, ByVal JobFilename As String, ByVal CycleFilename As String, ByVal AbortedByError As Boolean) As Boolean - Dim str As String - Dim MsgSrc As String - Dim dic As Dictionary(Of String, Object) - Dim dic0 As Dictionary(Of String, Object) - Dim dic1 As Dictionary(Of String, Object) - Dim ls0 As List(Of Dictionary(Of String, Object)) - Dim key As String - - MsgSrc = "SUMALL/Output" - - If Not HeadInitialized Then - If Not HeadInit() Then Return False - End If - - 'JSON - dic = New Dictionary(Of String, Object) - - 'Open file - Try - Fvsum = My.Computer.FileSystem.OpenTextFileWriter(VSUMpath, True, FileFormat) - Fvsum.AutoFlush = True - Catch ex As Exception - WorkerMsg(tMsgID.Err, "Cannot access .vsum file (" & VSUMpath & ")", MsgSrc) - Return False - End Try - - str = NrOfRunStr & "," & JobFilename & "," & CycleFilename & "," - dic.Add("Job", JobFilename) - - - If Cfg.DeclMode Then - If Not Declaration.CurrentMission Is Nothing Then dic.Add("Cycle", Declaration.CurrentMission.NameStr) - dic.Add("Loading", ConvLoading(Declaration.CurrentLoading)) - Else - dic.Add("Cycle", CycleFilename) - dic.Add("Loading", ConvLoading(tLoading.UserDefLoaded)) - End If - - - - If AbortedByError Then - Fvsum.WriteLine(str & "Aborted due to Error!") - dic.Add("AbortedByError", True) - Else - Fvsum.WriteLine(str & VSUMline()) - dic.Add("AbortedByError", False) - - dic1 = New Dictionary(Of String, Object) - For Each key In VSUMentryList - dic0 = New Dictionary(Of String, Object) - - dic0.Add("Value", VSUMentries(key).ValueString) - dic0.Add("Unit", VSUMentries(key).Unit) - - If VSUMentries(key).Multi Then - - If dic1.ContainsKey(VSUMentries(key).Head) Then - ls0 = dic1(VSUMentries(key).Head) - Else - ls0 = New List(Of Dictionary(Of String, Object)) - dic1.Add(VSUMentries(key).Head, ls0) - End If - - ls0.Add(dic0) - - Else - - dic1.Add(VSUMentries(key).Head, dic0) - - End If - - Next - dic.Add("Results", dic1) - - End If - - ResList.Add(dic) - - - 'Close file - Fvsum.Close() - Fvsum = Nothing - - Return True - - End Function - - Public Function WriteJSON() As Boolean - - vsumJSON.Content("Body").add("Results", ResList) - - Try - Return vsumJSON.WriteFile(VSUMpath & ".json") - Catch ex As Exception - Return False - End Try - - End Function - - Private Sub AddToVSUM(ByVal IDstring As String, ByVal Head As String, ByVal Unit As String, Optional Multi As Boolean = False) - If Not VSUMentries.ContainsKey(IDstring) Then - VSUMentries.Add(IDstring, New cVSUMentry(Head, Unit)) - VSUMentryList.Add(IDstring) - If Multi Then VSUMentries(IDstring).Multi = True - End If - End Sub - - - Public Function Init(ByVal JobFile As String) As Boolean - Dim JobFiles As New List(Of String) - Dim str As String - Dim str1 As String - Dim file As New cFile_V3 - Dim VEC0 As cVECTO - Dim MAP0 As cMAP - Dim ENG0 As cENG - Dim HEVorEVdone As Boolean - Dim EVdone As Boolean - Dim EngOnly As Boolean - Dim NonEngOnly As Boolean - Dim VSUMentry As cVSUMentry - Dim CylceKin As cCycleKin - Dim i1 As Integer - Dim i2 As Integer - Dim iDim As Integer - Dim dic As Dictionary(Of String, Object) - - - Dim MsgSrc As String - - MsgSrc = "SUMALL/Init" - - 'Check if file exists - If Not IO.File.Exists(JobFile) Then - WorkerMsg(tMsgID.Err, "Job file not found! (" & JobFile & ")", MsgSrc) - Return False - End If - - 'Define Output-path - If Cfg.BatchMode Then - Select Case UCase(Cfg.BATCHoutpath) - Case sKey.JobPath - VSUMpath = fFileWoExt(JobFile) & "_BATCH.vsum" - Case Else - VSUMpath = Cfg.BATCHoutpath & fFILE(JobFile, False) & "_BATCH.vsum" - End Select - Else - VSUMpath = fFileWoExt(JobFile) & ".v2.vsum" - End If - - 'Open file - Try - 'Open file - Fvsum = My.Computer.FileSystem.OpenTextFileWriter(VSUMpath, False, FileFormat) - Fvsum.AutoFlush = True - Catch ex As Exception - WorkerMsg(tMsgID.Err, "Cannot write to .vsum file (" & VSUMpath & ")", MsgSrc) - Return False - End Try - - 'JSON - vsumJSON = New JSON - - 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) - vsumJSON.Content.Add("Header", dic) - vsumJSON.Content.Add("Body", New Dictionary(Of String, Object)) - dic = New Dictionary(Of String, Object) - dic.Add("Air Density [kg/m3]", Cfg.AirDensity) - dic.Add("CO2/FC [-]", Cfg.CO2perFC) - dic.Add("Fuel Density [kg/l]", Cfg.FuelDens) - - dic.Add("Distance Correction", Cfg.DistCorr) - vsumJSON.Content("Body").add("Settings", dic) - - ResList = New List(Of Dictionary(Of String, Object)) - - 'Info - If DEV.AdvFormat Then - Fvsum.WriteLine("VECTO " & VECTOvers) - Fvsum.WriteLine(Now.ToUniversalTime().ToString("o")) - Fvsum.WriteLine("Input File: " & JobFile) - End If - - 'Close file (will open after each job) - Fvsum.Close() - - 'Add file to signing list - Lic.FileSigning.AddFile(VSUMpath) - Lic.FileSigning.AddFile(VSUMpath & ".json") - - - VSUMentries = New Dictionary(Of String, cVSUMentry) - VSUMentryList = New List(Of String) - - - For Each str In JobFileList - JobFiles.Add(fFileRepl(str)) - Next - - - '********************** Create VSUM-Entries '********************** - EVdone = False - HEVorEVdone = False - EngOnly = False - NonEngOnly = False - - 'Vehicle type-independent - AddToVSUM("\\T", "time", "[s]") - - For Each str In JobFiles - - VEC0 = New cVECTO - - VEC0.FilePath = str - - Try - If Not VEC0.ReadFile Then - WorkerMsg(tMsgID.Err, "Can't read .vecto file '" & str & "' !", MsgSrc) - Return False - End If - Catch ex As Exception - WorkerMsg(tMsgID.Err, "File read error! (" & str & ")", MsgSrc) - Return False - End Try - - If VEC0.EngOnly Then - - If Not EngOnly Then - - 'nothing... - - EngOnly = True - - End If - - Else - - If Not NonEngOnly Then - - AddToVSUM("\\S", "distance", "[km]") - AddToVSUM("\\V", "speed", "[km/h]") - AddToVSUM("\\G", "∆altitude", "[m]") - - NonEngOnly = True - - End If - - 'Auxiliary energy consumption - If VEC0.AuxDef Then - For Each str1 In VEC0.AuxPaths.Keys - AddToVSUM("\\Eaux_" & UCase(str1), "Eaux_" & str1, "[kWh]") - Next - End If - - End If - - 'Conventional vehicles ... - AddToVSUM("\\Ppos", "Ppos", "[kW]") - AddToVSUM("\\Pneg", "Pneg", "[kW]") - - 'From the Engine-Map - ENG0 = New cENG - ENG0.FilePath = VEC0.PathENG - - Try - If Not ENG0.ReadFile Then - WorkerMsg(tMsgID.Err, "File read error! (" & VEC0.PathENG & ")", MsgSrc) - Return False - End If - Catch ex As Exception - WorkerMsg(tMsgID.Err, "File read error! (" & VEC0.PathENG & ")", MsgSrc) - Return False - End Try - - MAP0 = New cMAP - MAP0.FilePath = ENG0.PathMAP - - Try - If Not MAP0.ReadFile(True) Then - WorkerMsg(tMsgID.Err, "File read error! (" & ENG0.PathMAP & ")", MsgSrc) - Return False - End If - Catch ex As Exception - WorkerMsg(tMsgID.Err, "File read error! (" & ENG0.PathMAP & ")", MsgSrc) - Return False - End Try - - AddToVSUM("FC_h", "FC-Map", "[g/h]", True) - AddToVSUM("FC-AUXc_h", "FC-AUXc", "[g/h]", True) - AddToVSUM("FC-WHTCc_h", "FC-WHTCc", "[g/h]", True) - - If Not VEC0.EngOnly Then - - AddToVSUM("FC_km", "FC-Map", "[g/km]", True) - AddToVSUM("FC-AUXc_km", "FC-AUXc", "[g/km]", True) - AddToVSUM("FC-WHTCc_km", "FC-WHTCc", "[g/km]", True) - - AddToVSUM("CO2_km", "CO2", "[g/km]", True) - AddToVSUM("CO2_tkm", "CO2", "[g/tkm]", True) - - AddToVSUM("FC-Final_km", "FC-Final", "[g/km]", True) - AddToVSUM("FCl_km", "FC-Final", "[l/100km]", True) - AddToVSUM("FCl_tkm", "FC-Final", "[l/100tkm]", True) - - End If - - Next - - - If EngOnly Then - - 'currently nothing - - End If - - If NonEngOnly Then - - 'Vehicle-related fields - AddToVSUM("\\PwheelPos", "PwheelPos", "[kW]") - AddToVSUM("\\Pbrake", "P_brake_loss", "[kW]") - AddToVSUM("\\EposICE", "EposICE", "[kWh]") - AddToVSUM("\\EnegICE", "EnegICE", "[kWh]") - AddToVSUM("\\Eair", "Eair", "[kWh]") - AddToVSUM("\\Eroll", "Eroll", "[kWh]") - AddToVSUM("\\Egrad", "Egrad", "[kWh]") - AddToVSUM("\\Eacc", "Eacc", "[kWh]") - AddToVSUM("\\Eaux", "Eaux", "[kWh]") - AddToVSUM("\\Ebrake", "Ebrake", "[kWh]") - AddToVSUM("\\Etransm", "Etransm", "[kWh]") - AddToVSUM("\\Eretarder", "Eretarder", "[kWh]") - AddToVSUM("\\Etorqueconv", "Etorqueconv", "[kWh]") - AddToVSUM("\\Mass", "Mass", "[kg]") - AddToVSUM("\\Loading", "Loading", "[kg]") - - 'CylceKin - CylceKin = New cCycleKin - For Each VSUMentry In CylceKin.VSUMentries - AddToVSUM("\\" & VSUMentry.Head, VSUMentry.Head, VSUMentry.Unit) - Next - - End If - - If (Not VEC Is Nothing AndAlso VEC.AuxiliaryAssembly <> "CLASSIC") Then - 'Advanced Auxiliaries I.E. Bus Auxiliaries. - AddToVSUM("\\AA_FC_LHR", "AA FC L/H", "L/R", False) - AddToVSUM("\\AA_FC_GHR", "AA FC G/H", "G/R", False) - - - - End If - - 'Sort - iDim = VSUMentryList.Count - 1 - - For i1 = 0 To iDim - 1 - str = VSUMentries(VSUMentryList(i1)).Head - For i2 = i1 + 1 To iDim - If VSUMentries(VSUMentryList(i2)).Head = str Then - VSUMentryList.Insert(i1 + 1, VSUMentryList(i2)) - VSUMentryList.RemoveAt(i2 + 1) - End If - Next - Next - - 'Sort Aux - For i1 = 0 To iDim - 1 - str = VSUMentries(VSUMentryList(i1)).Head - If str.Length > 4 AndAlso Left(str, 4) = "Eaux" Then - For i2 = i1 + 1 To iDim - If VSUMentries(VSUMentryList(i2)).Head.Length > 4 AndAlso Left(VSUMentries(VSUMentryList(i2)).Head, 4) = "Eaux" Then - VSUMentryList.Insert(i1 + 1, VSUMentryList(i2)) - VSUMentryList.RemoveAt(i2 + 1) - End If - Next - End If - Next - - Return True - - End Function - - Public ReadOnly Property VSUMfile As String - Get - Return VSUMpath - End Get - End Property - -End Class - -Public Class cVSUMentry - Public Head As String - Public Unit As String - Public MyVal As Object - Public Multi As Boolean - - Public Sub New(ByVal HeadStr As String, ByVal UnitStr As String) - Head = HeadStr - Unit = UnitStr - MyVal = Nothing - Multi = False - End Sub - - Public Property ValueString As Object - Get - If MyVal Is Nothing Then - Return "-" - Else - Return MyVal - End If - End Get - Set(value As Object) - MyVal = value - End Set - End Property - - - -End Class diff --git a/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs b/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs index 2d9e2b64cff5737b5f7a057f90922c3478f11403..774206ec8ea71fd6d095dc6525036973b5107ecc 100644 --- a/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs +++ b/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs @@ -203,6 +203,8 @@ namespace TUGraz.VectoCommon.InputData /// cf. VECTO Input Parameters.xlsx /// </summary> KilogramSquareMeter Inertia { get; } + + DataTable ShiftPolygon { get; } } public interface IEngineEngineeringInputData : IEngineDeclarationInputData diff --git a/VectoConsole/Properties/Version.cs b/VectoConsole/Properties/Version.cs index d42f246163c209244f0d00deaada820e1ee450eb..f964386e445f984f7b2cd9b399a8173d9f7a2fff 100644 --- a/VectoConsole/Properties/Version.cs +++ b/VectoConsole/Properties/Version.cs @@ -30,5 +30,5 @@ */ using System.Reflection; -[assembly: AssemblyVersion("3.0.3.565")] -[assembly: AssemblyFileVersion("3.0.3.565")] +[assembly: AssemblyVersion("3.0.3.606")] +[assembly: AssemblyFileVersion("3.0.3.606")] diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs index d76f25bf7338e7b934b7fbe1a6fbf45e85eec6b5..7c97f02e9c0be90199557b2ae06776b3b85e9505 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONGearboxData.cs @@ -29,19 +29,16 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System; using System.Collections.Generic; using System.Data; using System.Linq; using Newtonsoft.Json.Linq; -using Org.BouncyCastle.Asn1.Mozilla; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.Impl; using TUGraz.VectoCore.Models.Declaration; -using TUGraz.VectoCore.Models.Simulation.Data; namespace TUGraz.VectoCore.InputData.FileIO.JSON { @@ -68,6 +65,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON return resultGears; } } + + public override DataTable ShiftPolygon + { + get + { + return ReadTableData(Body.GetEx(JsonKeys.Gearbox_TorqueConverter) + .GetEx<string>("ShiftPolygon"), "TorqueConverter Shift Polygon"); + } + } } /// <summary> @@ -174,6 +180,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return Body.GetEx<double>(JsonKeys.Gearbox_Inertia).SI<KilogramSquareMeter>(); } } + public virtual DataTable ShiftPolygon + { + get + { + return ReadTableData(Body.GetEx(JsonKeys.Gearbox_Gears)[1].GetEx<string>("ShiftPolygon"), + "TorqueConverter Shift Polygon"); + } + } + public Second TractionInterruption { get { return Body.GetEx<double>(JsonKeys.Gearbox_TractionInterruption).SI<Second>(); } @@ -191,11 +206,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON var torqueConverter = gear.GetEx<bool>(JsonKeys.Gearbox_Gear_TCactive); if (torqueConverter) { - if (gears[i + 1].GetEx<bool>(JsonKeys.Gearbox_Gear_TCactive)) { - resultGears.Add(CreateGear(gearNr, gear)); - } else { - resultGears.Add(CreateTorqueConverterGear(gearNr, gear, gears[++i])); - } + resultGears.Add(gears[i + 1].GetEx<bool>(JsonKeys.Gearbox_Gear_TCactive) + ? CreateGear(gearNr, gear) + : CreateTorqueConverterGear(gearNr, gear, gears[++i])); } else { resultGears.Add(CreateGear(gearNr, gear)); } @@ -238,7 +251,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON return new TransmissionInputData { Gear = gearNumber, Ratio = gear.GetEx<double>(JsonKeys.Gearbox_Gear_Ratio), - MaxTorque = gear["MaxTorque"] != null ? gear["MaxTorque"].Value<double>().SI<NewtonMeter>() : null, + MaxTorque = + gear["MaxTorque"] != null && !string.IsNullOrEmpty(gear["MaxTorque"].ToString()) + ? gear["MaxTorque"].Value<double>().SI<NewtonMeter>() + : null, LossMap = gear[JsonKeys.Gearbox_Gear_LossMapFile] != null ? ReadTableData(gear.GetEx<string>(JsonKeys.Gearbox_Gear_LossMapFile), diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs index 6e2da668579e917d7b163eba6fcb4dc03103ad2f..5ffa57f7bb729ae233fee73fcf6cad847e7b1618 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs @@ -34,7 +34,6 @@ using System.Collections.Generic; using System.Data; using System.Linq; using Newtonsoft.Json.Linq; -using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/AccelerationCurveReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/AccelerationCurveReader.cs index 1319d7c684457f3e809edbc7884552c34d31edfe..90601b59d4604a8b4836e4569c56c401607945a3 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/AccelerationCurveReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/AccelerationCurveReader.cs @@ -6,9 +6,10 @@ using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Utils; -namespace TUGraz.VectoCore.Models.SimulationComponent.Data +namespace TUGraz.VectoCore.InputData.Reader.ComponentData { public class AccelerationCurveReader { @@ -43,7 +44,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data } LoggingObject.Logger<AccelerationCurveData>() .Warn("Acceleration Curve: Header Line is not valid. Expected: '{0}, {1}, {2}', Got: {3}", - Fields.Velocity, AccelerationCurveReader.Fields.Acceleration, + Fields.Velocity, Fields.Acceleration, Fields.Deceleration, ", ".Join(data.Columns.Cast<DataColumn>().Select(c => c.ColumnName))); return CreateFromColumnIndizes(data); diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/CrossWindCorrectionCurveReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/CrossWindCorrectionCurveReader.cs index d9ec305f2ce260a2315ad8be26d1a8eeff02934d..ee00eb678551d9cc4796eaa7f33031f73b79df83 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/CrossWindCorrectionCurveReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/CrossWindCorrectionCurveReader.cs @@ -38,7 +38,7 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Utils; -namespace TUGraz.VectoCore.Models.SimulationComponent.Data +namespace TUGraz.VectoCore.InputData.Reader.ComponentData { public class CrossWindCorrectionCurveReader : LoggingObject { diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/RetarderLossMapReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/RetarderLossMapReader.cs index d47c2d21e58d0d7299a7d672f120432f0be57599..851eff68b67ad650600a3d535efd4629293b631c 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/RetarderLossMapReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/RetarderLossMapReader.cs @@ -5,9 +5,10 @@ using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Utils; -namespace TUGraz.VectoCore.Models.SimulationComponent.Data +namespace TUGraz.VectoCore.InputData.Reader.ComponentData { public class RetarderLossMapReader { @@ -59,8 +60,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { return data.Rows.Cast<DataRow>() .Select(row => new RetarderLossMap.RetarderLossEntry { - RetarderSpeed = DataTableExtensionMethods.ParseDouble(row, (string)Fields.RetarderSpeed).RPMtoRad(), - TorqueLoss = DataTableExtensionMethods.ParseDouble(row, (string)Fields.TorqueLoss).SI<NewtonMeter>() + RetarderSpeed = row.ParseDouble(Fields.RetarderSpeed).RPMtoRad(), + TorqueLoss = row.ParseDouble(Fields.TorqueLoss).SI<NewtonMeter>() }).ToList(); } diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/TorqueConverterDataReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/TorqueConverterDataReader.cs index 2d628d8d3e8c30b7207be37f38ec09846591689e..c6a73dc2ec3091d45b3f4ab7b33a3e82f9beb0ee 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/TorqueConverterDataReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/TorqueConverterDataReader.cs @@ -35,9 +35,9 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData characteristicTorque = (from DataRow row in data.Rows select new TorqueConverterEntry() { - SpeedRatio = row.ParseDouble((string)Fields.SpeedRatio), - Torque = row.ParseDouble((string)Fields.CharacteristicTorque).SI<NewtonMeter>(), - TorqueRatio = row.ParseDouble((string)Fields.TorqueRatio) + SpeedRatio = row.ParseDouble(Fields.SpeedRatio), + Torque = row.ParseDouble(Fields.CharacteristicTorque).SI<NewtonMeter>(), + TorqueRatio = row.ParseDouble(Fields.TorqueRatio) }).ToList(); } else { characteristicTorque = (from DataRow row in data.Rows diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs index cfd08c4c2e6f933add7b332836a2b71430c84f35..1eb46333c138920babc1dae6717ff55b87abaf0a 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs @@ -5,9 +5,10 @@ using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; using TUGraz.VectoCore.Utils; -namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox +namespace TUGraz.VectoCore.InputData.Reader.ComponentData { public sealed class TransmissionLossMapReader { @@ -80,9 +81,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox private static bool HeaderIsValid(DataColumnCollection columns) { - return columns.Contains(TransmissionLossMapReader.Fields.InputSpeed) && - columns.Contains(TransmissionLossMapReader.Fields.InputTorque) && - columns.Contains(TransmissionLossMapReader.Fields.TorqeLoss); + return columns.Contains(Fields.InputSpeed) && + columns.Contains(Fields.InputTorque) && + columns.Contains(Fields.TorqeLoss); } private static List<TransmissionLossMap.GearLossMapEntry> CreateFromColumnNames(DataTable data) diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs index 84a9400174d98d17bf96920eed4df482af071c83..d4bcd9f7b9f67334c351ffee854aa80e2719ca8c 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs @@ -36,6 +36,7 @@ using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs index 49be92b05ad11f740c2ae76d78472d498807399f..4bb0ef3a468bf75b0d913cf96a40b652484935d2 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs @@ -37,6 +37,7 @@ using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data; diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index 3e0d12e355a8088300dd5325c1ee74fee9a771f1..c28599bbbba2995546767059d00a3e26a37d4417 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -36,7 +36,6 @@ using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; @@ -159,6 +158,9 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter } var fullLoadCurve = IntersectFullLoadCurves(engineData.FullLoadCurve, gear.MaxTorque); + if (gearbox.Type.AutomaticTransmission() && gear.ShiftPolygon == null) { + throw new VectoException("Shiftpolygons are required for AT Gearboxes!"); + } var shiftPolygon = gear.ShiftPolygon != null ? ShiftPolygonReader.Create(gear.ShiftPolygon) : DeclarationData.Gearbox.ComputeShiftPolygon((int)i, fullLoadCurve, gearbox.Gears, engineData, axlegearRatio, @@ -175,6 +177,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter // powersplit transmission: torque converter already contains ratio and losses gearData.TorqueConverterRatio = 1; gearData.TorqueConverterGearLossMap = TransmissionLossMapReader.Create(1, 1, string.Format("TCGear {0}", i + 1)); + gearData.TorqueConverterShiftPolygon = ShiftPolygonReader.Create(gearbox.TorqueConverter.ShiftPolygon); } } if (gearbox.Type == GearboxType.ATSerial) { @@ -182,12 +185,14 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter // torqueconverter is active in first gear - duplicate ratio and lossmap for torque converter mode gearData.TorqueConverterRatio = gearData.Ratio; gearData.TorqueConverterGearLossMap = gearData.LossMap; + gearData.TorqueConverterShiftPolygon = ShiftPolygonReader.Create(gearbox.TorqueConverter.ShiftPolygon); } if (i == 1 && gearDifferenceRatio >= DeclarationData.Gearbox.TorqueConverterSecondGearThreshold) { // ratio between first and second gear is above threshold, torqueconverter is active in second gear as well // -> duplicate ratio and lossmap for torque converter mode, remove locked transmission for previous gear gearData.TorqueConverterRatio = gearData.Ratio; gearData.TorqueConverterGearLossMap = gearData.LossMap; + gearData.TorqueConverterShiftPolygon = ShiftPolygonReader.Create(gearbox.TorqueConverter.ShiftPolygon); // NOTE: the lower gear in 'gears' dictionary has index i !! gears[i].Ratio = double.NaN; gears[i].LossMap = null; diff --git a/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs b/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs index f4fc790a2153fe369f75c6baad86caae12f4cf3b..2e02f9d19f44560597876892a57684003ef28f3c 100644 --- a/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs @@ -182,7 +182,7 @@ namespace TUGraz.VectoCore.InputData.Reader var altitude = current.Altitude; var lastTime = entries.First().Time; foreach (var drivingCycleEntry in entries) { - altitude += (drivingCycleEntry.VehicleTargetSpeed * (drivingCycleEntry.Time - lastTime)) * + altitude += drivingCycleEntry.VehicleTargetSpeed * (drivingCycleEntry.Time - lastTime) * drivingCycleEntry.RoadGradient; drivingCycleEntry.Altitude = altitude; lastTime = drivingCycleEntry.Time; diff --git a/VectoCore/VectoCore/InputData/Reader/FullLoadCurveReader.cs b/VectoCore/VectoCore/InputData/Reader/FullLoadCurveReader.cs index 9eb37c7934be5e3cde817029bd55406df3e624ee..71ebac1f3be020d79dad8fbff0041eb16c70dfb2 100644 --- a/VectoCore/VectoCore/InputData/Reader/FullLoadCurveReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/FullLoadCurveReader.cs @@ -112,7 +112,7 @@ namespace TUGraz.VectoCore.InputData.Reader select new FullLoadCurve.FullLoadCurveEntry { EngineSpeed = row.ParseDouble(Fields.EngineSpeed).RPMtoRad(), TorqueFullLoad = row.ParseDouble(Fields.TorqueFullLoad).SI<NewtonMeter>(), - TorqueDrag = (engineFld ? row.ParseDouble(Fields.TorqueDrag).SI<NewtonMeter>() : null) + TorqueDrag = engineFld ? row.ParseDouble(Fields.TorqueDrag).SI<NewtonMeter>() : null }).ToList(); } @@ -122,7 +122,7 @@ namespace TUGraz.VectoCore.InputData.Reader select new FullLoadCurve.FullLoadCurveEntry { EngineSpeed = row.ParseDouble(0).RPMtoRad(), TorqueFullLoad = row.ParseDouble(1).SI<NewtonMeter>(), - TorqueDrag = (engineFld ? row.ParseDouble(2).SI<NewtonMeter>() : null) + TorqueDrag = engineFld ? row.ParseDouble(2).SI<NewtonMeter>() : null }).ToList(); } diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs index f8bfff7cd58b5d448d1b9dd9901fd20610a5ea41..8220d9731d6fdf09cea324e94a5ae2060dafaa7e 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs @@ -34,6 +34,7 @@ using System.Linq; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; diff --git a/VectoCore/VectoCore/InputData/Reader/ShiftPolygonReader.cs b/VectoCore/VectoCore/InputData/Reader/ShiftPolygonReader.cs index 16d0b98001654e259a86b676e42d350badeaafb6..0abcc5e95e3e1194683f34e9bba0f5fc1df81290 100644 --- a/VectoCore/VectoCore/InputData/Reader/ShiftPolygonReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ShiftPolygonReader.cs @@ -36,7 +36,6 @@ using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Models; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; using TUGraz.VectoCore.Utils; @@ -84,14 +83,14 @@ namespace TUGraz.VectoCore.InputData.Reader private static bool HeaderIsValid(DataColumnCollection columns) { return columns.Contains(Fields.Torque) && columns.Contains(Fields.AngularSpeedUp) && - columns.Contains((Fields.AngularSpeedDown)); + columns.Contains(Fields.AngularSpeedDown); } private static List<ShiftPolygon.ShiftPolygonEntry> CreateFromColumnNames(DataTable data, string columnName) { return (from DataRow row in data.Rows select new ShiftPolygon.ShiftPolygonEntry { - Torque = DataTableExtensionMethods.ParseDouble(row, (string)Fields.Torque).SI<NewtonMeter>(), + Torque = row.ParseDouble(Fields.Torque).SI<NewtonMeter>(), AngularSpeed = row.ParseDouble(columnName).RPMtoRad(), }).ToList(); } diff --git a/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs b/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs index 7a42e99a468de9ba05e78010e737b6e6c95010ed..556d4524fa614dc0a0b5b9b61b714bb73efbb985 100644 --- a/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs +++ b/VectoCore/VectoCore/Models/Connector/Ports/Impl/Response.cs @@ -33,7 +33,6 @@ using System.Linq; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; -using TUGraz.VectoCore.Models.SimulationComponent.Impl; namespace TUGraz.VectoCore.Models.Connector.Ports.Impl { diff --git a/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs b/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs index 3dc38204ca63f0b23e93b9893343ac66fb3abdf4..c1f94c0cc4b27a410811a728acddbaec2c9ab632 100644 --- a/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs +++ b/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using TUGraz.VectoCommon.Models; using TUGraz.VectoCore.Configuration; diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index e899ddc1bdc60b7768311fb3f0e9959b7cda911a..bd968c9cb380c1db44c5f0f3f92d847ffa117f48 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -243,8 +243,9 @@ namespace TUGraz.VectoCore.Models.Declaration public static ShiftPolygon ComputeShiftPolygon(int gear, FullLoadCurve fullLoadCurve, IList<ITransmissionInputData> gears, CombustionEngineData engine, double axlegearRatio, Meter dynamicTyreRadius) { - if (gears.Count < 2) + if (gears.Count < 2) { throw new VectoException("ComputeShiftPolygon needs at least 2 gears. {0} gears given.", gears.Count); + } // ReSharper disable once InconsistentNaming var engineSpeed85kmhLastGear = ComputeEngineSpeed85kmh(gears[gears.Count - 1], axlegearRatio, dynamicTyreRadius); @@ -286,7 +287,7 @@ namespace TUGraz.VectoCore.Models.Declaration return new ShiftPolygon(downShift, upShift); } - var gearRatio = gears[(int)gear].Ratio / gears[(int)(gear + 1)].Ratio; + var gearRatio = gears[gear].Ratio / gears[gear + 1].Ratio; var rpmMarginFactor = 1 + ShiftPolygonRPMMargin / 100.0; // ReSharper disable InconsistentNaming @@ -353,7 +354,9 @@ namespace TUGraz.VectoCore.Models.Declaration { var intersections = new List<Point>(); // compute all intersection points between both line segments + // ReSharper disable once LoopCanBeConvertedToQuery foreach (var origLine in orig.Pairwise(Edge.Create)) { + // ReSharper disable once LoopCanBeConvertedToQuery foreach (var transformedLine in transformedDownshift.Pairwise(Edge.Create)) { var isect = VectoMath.Intersect(origLine, transformedLine); if (isect != null) { diff --git a/VectoCore/VectoCore/Models/Declaration/Segments.cs b/VectoCore/VectoCore/Models/Declaration/Segments.cs index 4ce4fe1ad153ca27f84177b7c044e91661bdd2ad..c95664d566e8009be2d9e57dfd56e22d2346e487 100644 --- a/VectoCore/VectoCore/Models/Declaration/Segments.cs +++ b/VectoCore/VectoCore/Models/Declaration/Segments.cs @@ -196,7 +196,7 @@ namespace TUGraz.VectoCore.Models.Declaration private static string GetMissionSuffix(MissionType missionType) { - return (missionType == MissionType.LongHaul ? "-longhaul" : "-other"); + return missionType == MissionType.LongHaul ? "-longhaul" : "-other"; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs b/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs index 6b68a67eecaf45500613c33e49eed4cf2d181cc3..d388216f1d38c77a35ee95855299e591f6d98432 100644 --- a/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs +++ b/VectoCore/VectoCore/Models/Simulation/DataBus/IDataBus.cs @@ -30,6 +30,7 @@ */ using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.SimulationComponent; namespace TUGraz.VectoCore.Models.Simulation.DataBus diff --git a/VectoCore/VectoCore/Models/Simulation/DataBus/IEngineInfo.cs b/VectoCore/VectoCore/Models/Simulation/DataBus/IEngineInfo.cs index ff40004e03237935706c7f85bda59f6bc1ce6391..811d85d59d5067959c6bc1bff0f03c8929f578de 100644 --- a/VectoCore/VectoCore/Models/Simulation/DataBus/IEngineInfo.cs +++ b/VectoCore/VectoCore/Models/Simulation/DataBus/IEngineInfo.cs @@ -54,5 +54,7 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus PerSecond EngineRatedSpeed { get; } PerSecond EngineN95hSpeed { get; } + + PerSecond EngineN80hSpeed { get; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Simulation/DataBus/IGearboxInfo.cs b/VectoCore/VectoCore/Models/Simulation/DataBus/IGearboxInfo.cs index c03e24c1ca8a3b3c33140a60c74ca9da94061e4f..c63e4e3fca179a1c596710eab8b31532443277cb 100644 --- a/VectoCore/VectoCore/Models/Simulation/DataBus/IGearboxInfo.cs +++ b/VectoCore/VectoCore/Models/Simulation/DataBus/IGearboxInfo.cs @@ -31,7 +31,6 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Models.SimulationComponent.Data; namespace TUGraz.VectoCore.Models.Simulation.DataBus { diff --git a/VectoCore/VectoCore/Models/Simulation/IVectoRun.cs b/VectoCore/VectoCore/Models/Simulation/IVectoRun.cs index d01da5ed023947f33afcd6895f9604a19bab3e50..e978f6f091a0bffa2638655db93e61a91bbabc52 100644 --- a/VectoCore/VectoCore/Models/Simulation/IVectoRun.cs +++ b/VectoCore/VectoCore/Models/Simulation/IVectoRun.cs @@ -29,9 +29,6 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System; -using System.ComponentModel; - namespace TUGraz.VectoCore.Models.Simulation { /// <summary> diff --git a/VectoCore/VectoCore/Models/Simulation/IVehicleContainer.cs b/VectoCore/VectoCore/Models/Simulation/IVehicleContainer.cs index a00df4971930282ae359b47b643678f65373c246..4534be8a1ea35b13f45917870354703b3b83c9ab 100644 --- a/VectoCore/VectoCore/Models/Simulation/IVehicleContainer.cs +++ b/VectoCore/VectoCore/Models/Simulation/IVehicleContainer.cs @@ -37,7 +37,6 @@ using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Models.SimulationComponent; using TUGraz.VectoCore.OutputData; -using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Simulation { diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/JobContainer.cs b/VectoCore/VectoCore/Models/Simulation/Impl/JobContainer.cs index 9e36e4a88041a853b149ed581e420646ca04f321..7d18e4f1948f64c47a08f266b6d01f95d83a59db 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/JobContainer.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/JobContainer.cs @@ -110,6 +110,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } else { var first = new Task(() => { }); var task = first; + // ReSharper disable once LoopCanBeConvertedToQuery foreach (var run in Runs) { var r = run; task = task.ContinueWith(t => r.RunWorkerAsync().Wait(), TaskContinuationOptions.OnlyOnRanToCompletion); diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs index 96478896ffa410e3fb4e0f024593f8ac956591e1..c3805b4f4ba256a0c44daa68f244d07a78721178 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs @@ -45,7 +45,6 @@ using TUGraz.VectoCore.InputData.Reader.Impl; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.OutputData.PDF; -using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Simulation.Impl { diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index db8744b4c095771924e7ab10dcf762b73c2ab72f..e7f0816225e9e50690560264fa26d7475530df30 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -174,6 +174,11 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl get { return Engine.EngineN95hSpeed; } } + public PerSecond EngineN80hSpeed + { + get { return Engine.EngineN80hSpeed; } + } + #endregion #region IVehicleCockpit diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/AccelerationCurve.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/AccelerationCurve.cs index e8053c20ea6c8d0c1a0da6dc932904effb42e7be..ad52bffd2940dc50b46252ddd1edfd6397fdd9bb 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/AccelerationCurve.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/AccelerationCurve.cs @@ -31,13 +31,9 @@ using System; using System.Collections.Generic; -using System.Data; using System.Diagnostics; -using System.IO; using System.Linq; -using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { @@ -54,7 +50,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { var index = FindIndex(key); - return new AccelerationCurveData.AccelerationEntry { + return new AccelerationEntry { Acceleration = VectoMath.Interpolate(_entries[index - 1].Key, _entries[index].Key, _entries[index - 1].Value.Acceleration, diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs index 68e96cfc5025a188041d0a1a0eba3e10cd5a37b5..2d1007314489659d49eb7a1e24e18893f6c5b83e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs @@ -33,7 +33,6 @@ using System.ComponentModel.DataAnnotations; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; -using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { @@ -105,7 +104,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data if (ReferenceEquals(this, obj)) { return true; } - if (obj.GetType() != this.GetType()) { + if (obj.GetType() != GetType()) { return false; } return Equals((CombustionEngineData)obj); @@ -119,9 +118,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data hashCode = (hashCode * 397) ^ (Displacement != null ? Displacement.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (IdleSpeed != null ? IdleSpeed.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Inertia != null ? Inertia.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (WHTCUrban.GetHashCode()); - hashCode = (hashCode * 397) ^ (WHTCRural.GetHashCode()); - hashCode = (hashCode * 397) ^ (WHTCMotorway.GetHashCode()); + hashCode = (hashCode * 397) ^ WHTCUrban.GetHashCode(); + hashCode = (hashCode * 397) ^ WHTCRural.GetHashCode(); + hashCode = (hashCode * 397) ^ WHTCMotorway.GetHashCode(); hashCode = (hashCode * 397) ^ (ConsumptionMap != null ? ConsumptionMap.GetHashCode() : 0); return hashCode; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionCdxALookup.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionCdxALookup.cs index 0c089b04af8c936f95e83a0aa172361735abb4e6..534657c750c0c374290ba99bc4724ad2d2a85a8b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionCdxALookup.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionCdxALookup.cs @@ -33,6 +33,7 @@ using System.Collections.Generic; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Utils; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs index b6627f1895eb89f309e66fd72c473218d9ac5900..cf8d3e0e6b0b13a562ccd3cf071687e803cbb07f 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs @@ -35,6 +35,7 @@ using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Utils; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs index b11b4cd5e40c393432bb3acf4f5b5605432120e7..1009b46606557d6567b2ed72d110b75ed3d4aecb 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/EngineFullLoadCurve.cs @@ -47,6 +47,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine private PerSecond _engineSpeedLo; // 55% of Pmax private PerSecond _engineSpeedHi; // 70% of Pmax private PerSecond _n95hSpeed; // 95% of Pmax + private PerSecond _n80hSpeed; // 80% of Pmax public static EngineFullLoadCurve ReadFromFile(string fileName, bool declarationMode = false) { @@ -94,6 +95,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine } } + public PerSecond N80hSpeed + { + get { return _n80hSpeed ?? (_n80hSpeed = FindEngineSpeedForPower(0.8 * MaxPower).Last()); } + } + public PerSecond N95hSpeed { get { return _n95hSpeed ?? (_n95hSpeed = FindEngineSpeedForPower(0.95 * MaxPower).Last()); } @@ -234,7 +240,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine if (ReferenceEquals(this, obj)) { return true; } - if (obj.GetType() != this.GetType()) { + if (obj.GetType() != GetType()) { return false; } return Equals((EngineFullLoadCurve)obj); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/FullLoadCurve.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/FullLoadCurve.cs index 26d4774ea74d6dcf7b0d65292b24eea8b72a4b82..deb69b72f7a4cd8eca9d4751bb89616ad2ea1b19 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/FullLoadCurve.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/FullLoadCurve.cs @@ -32,15 +32,12 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Data; using System.Diagnostics; using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.Declaration; -using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; -using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { @@ -223,7 +220,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public override int GetHashCode() { unchecked { - var hashCode = (EngineSpeed != null ? EngineSpeed.GetHashCode() : 0); + var hashCode = EngineSpeed != null ? EngineSpeed.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (TorqueFullLoad != null ? TorqueFullLoad.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TorqueDrag != null ? TorqueDrag.GetHashCode() : 0); return hashCode; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs index 2edf6ed42e49d70c45dfeb8faf9d8caeea858a5e..74f32811f09602dddc7985c154f4fd4a5bbf465c 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs @@ -68,5 +68,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox public TransmissionLossMap TorqueConverterGearLossMap { get; internal set; } public NewtonMeter MaxTorque { get; internal set; } + + public ShiftPolygon TorqueConverterShiftPolygon { get; set; } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs index e427d65f315ec4f607a1a561684bb4faa0b87d1d..21b5ae27b5dc6f20e1dbba193ca09ae1e7d213ef 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs @@ -33,12 +33,9 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel.DataAnnotations; -using System.Data; using System.Diagnostics; using System.Linq; -using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TorqueConverterData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TorqueConverterData.cs index 557e3ef5116017fb1ab137f5eed05df8dfd60bd2..170b2f50f0ced831e85f893b8236d1a41e396c97 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TorqueConverterData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TorqueConverterData.cs @@ -32,7 +32,6 @@ using System; using System.Collections.Generic; using System.Linq; -using iTextSharp.text.pdf.parser.clipper; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; @@ -161,6 +160,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox } var solutions = new List<double>(); + // ReSharper disable once LoopCanBeConvertedToQuery foreach (var edge in TorqueConverterEntries.Pairwise( (p1, p2) => Edge.Create(new Point(p1.SpeedRatio, p1.Torque.Value()), new Point(p2.SpeedRatio, p2.Torque.Value())))) { var x = (referenceTorque - edge.OffsetXY) / edge.SlopeXY; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs index 5c4160abecc0e3d3e9522a25f31fea8f6d1a49c5..83b07b0710f7aa3de8fba1fe9533e5b555e1016b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/GearboxData.cs @@ -32,7 +32,6 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; -using Newtonsoft.Json; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/RetarderLossMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/RetarderLossMap.cs index 319f5b3e948dfd2a3ea7a7ca6160c50b65e102e1..fbad43ba46d92040bcfc4e4a3b5eaff12415300a 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/RetarderLossMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/RetarderLossMap.cs @@ -29,14 +29,10 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Data; using System.Linq; -using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs index 12f3ceaf702bd75c18e7693b14ab84d00c37e7a8..fb83f206e53c627dd1a40812a6cabcdd00272efd 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs @@ -33,7 +33,6 @@ using System.ComponentModel.DataAnnotations; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs index 9dec7cddfa6007f1fb89c02ef18bc0a902cb7b09..4c6e6caed13a61e94fef99c578f30eaa96ad9e02 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/VehicleData.cs @@ -170,7 +170,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public static ValidationResult ValidateVehicleData(VehicleData vehicleData, ValidationContext validationContext) { - var mode = SimulationComponentData.GetExecutionMode(validationContext); + var mode = GetExecutionMode(validationContext); var weightShareSum = vehicleData.AxleData.Sum(axle => axle.AxleWeightShare); if (!weightShareSum.IsEqual(1.0, 1E-10)) { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/IClutch.cs b/VectoCore/VectoCore/Models/SimulationComponent/IClutch.cs index 7b38571e55eb7a9071b54282f76d050565e55855..0d9936cc9dbbec3154712a6b47929319c712a6e7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/IClutch.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/IClutch.cs @@ -29,8 +29,6 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using TUGraz.VectoCore.Models.Connector.Ports; - namespace TUGraz.VectoCore.Models.SimulationComponent { public enum ClutchState diff --git a/VectoCore/VectoCore/Models/SimulationComponent/IDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/IDriverStrategy.cs index d4354a0d056ae3a117f5e7c9fdd4c57394b2b227..de59438ba3e12b4d503e137017b1f656ce60799b 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/IDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/IDriverStrategy.cs @@ -31,7 +31,6 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Models.Simulation.DataBus; namespace TUGraz.VectoCore.Models.SimulationComponent { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/IShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/IShiftStrategy.cs index 2cb77d1e63c06d60e7da957ef2b7c2ee369b7649..f3de1d34b4e7eac28e218ad8142f132510fbc70e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/IShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/IShiftStrategy.cs @@ -30,7 +30,6 @@ */ using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Models.SimulationComponent.Impl; namespace TUGraz.VectoCore.Models.SimulationComponent { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs index 76b97e56b9957f243473fd8a4915c57b215d63db..5ecbcdbea42130319c53e0d9611be7d22c799a1d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/AMTShiftStrategy.cs @@ -180,7 +180,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl NextGear--; } - return (NextGear != gear); + return NextGear != gear; } protected virtual uint CheckUpshift(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs index 13e8e63da27126f0d49f5928e0f45f91bf7a1a09..2827c773913ec16b4eebddcd8eff047aca12e6bc 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATGearbox.cs @@ -1,5 +1,4 @@ -using System.CodeDom; -using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; @@ -14,24 +13,24 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { - public class ATGearbox : AbstractGearbox<ATGearbox.ATGearboxState>, IGearbox, ITnOutPort, ITnInPort, + public class ATGearbox : AbstractGearbox<ATGearbox.ATGearboxState>, IGearbox, ITnInPort, IClutchInfo { protected internal bool Disengaged = true; - protected internal readonly IShiftStrategy _strategy; + protected internal readonly IShiftStrategy Strategy; - protected TorqueConverter TorqueConverter; + protected internal TorqueConverter TorqueConverter; public Second LastShift { get; private set; } public ATGearbox(IVehicleContainer container, GearboxData gearboxModelData, IShiftStrategy strategy) : base(container, gearboxModelData) { - _strategy = strategy; - _strategy.Gearbox = this; + Strategy = strategy; + Strategy.Gearbox = this; LastShift = -double.MaxValue.SI<Second>(); - TorqueConverter = new TorqueConverter(this, _strategy, container, gearboxModelData.TorqueConverterData); + TorqueConverter = new TorqueConverter(this, Strategy, container, gearboxModelData.TorqueConverterData); } @@ -58,7 +57,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { if (Disengaged) { - Gear = _strategy.InitGear(0.SI<Second>(), Constants.SimulationSettings.TargetTimeInterval, outTorque, + Gear = Strategy.InitGear(0.SI<Second>(), Constants.SimulationSettings.TargetTimeInterval, outTorque, outAngularVelocity); } var inAngularVelocity = 0.SI<PerSecond>(); @@ -136,7 +135,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Debug("AT-Gearbox Power Request: torque: {0}, angularVelocity: {1}", outTorque, outAngularVelocity); if (DataBus.VehicleStopped && outAngularVelocity > 0) { - Gear = _strategy.InitGear(absTime, dt, outTorque, outAngularVelocity); + Gear = Strategy.InitGear(absTime, dt, outTorque, outAngularVelocity); LastShift = absTime; Disengaged = false; } @@ -156,7 +155,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl retVal.Switch() .Case<ResponseGearShift>(r => { loop = true; - Gear = _strategy.Engage(absTime, dt, outTorque, outAngularVelocity); + Gear = Strategy.Engage(absTime, dt, outTorque, outAngularVelocity); LastShift = absTime; }); } while (loop && ++count < 2); @@ -202,7 +201,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return TorqueConverter.Request(absTime, dt, inTorque, inAngularVelocity, dryRun); } if (!dryRun && - _strategy.ShiftRequired(absTime, dt, outTorque, outAngularVelocity, inTorque, inAngularVelocity, Gear, LastShift)) { + Strategy.ShiftRequired(absTime, dt, outTorque, outAngularVelocity, inTorque, inAngularVelocity, Gear, LastShift)) { return new ResponseGearShift() { Source = this }; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs index 72c73ccfee12940335d806669ad1f13b3a4c1fd5..da54ae418eed713017dafd70ff7ae83639ccad43 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ATShiftStrategy.cs @@ -141,7 +141,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (nextEngineSpeed.IsEqual(0)) { return false; } - if (IsAboveUpShiftCurve(gear, enginePower / nextEngineSpeed, nextEngineSpeed) && + if (IsAboveUpShiftCurve(gear, enginePower / nextEngineSpeed, nextEngineSpeed, _gearbox.TorqueConverterLocked) && enginePower.IsSmallerOrEqual(DataBus.EngineStationaryFullPower(nextEngineSpeed))) { NextGear.SetState(absTime, false, nextGear, true); return true; @@ -149,7 +149,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } if (!_gearbox.TorqueConverterLocked && Data.Gears.ContainsKey(gear + 1) && Data.Gears[gear + 1].HasTorqueConverter) { // C -> C upshift - // TODO! + var gearRatio = Data.Gears[gear + 1].Ratio / Data.Gears[gear].Ratio; + var minEnginseSpeed = VectoMath.Min(700.RPMtoRad(), gearRatio * (DataBus.EngineN80hSpeed - 150.RPMtoRad())); + var nextGbxInSpeed = outAngularVelocity * Data.Gears[gear + 1].Ratio; + var nextGbxInTorque = outTorque / Data.Gears[gear + 1].Ratio; + var tcOperatingPoint = _gearbox.TorqueConverter.FindOperatingPoint(nextGbxInTorque, nextGbxInSpeed); + if (tcOperatingPoint.InAngularVelocity.IsGreater(minEnginseSpeed) && + DataBus.EngineStationaryFullPower(tcOperatingPoint.InAngularVelocity) + .IsGreater(0.7 * DataBus.EngineStationaryFullPower(inAngularVelocity))) { + return true; + } } return false; } @@ -233,10 +242,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <param name="gear">The gear.</param> /// <param name="inTorque">The in torque.</param> /// <param name="inEngineSpeed">The in engine speed.</param> + /// <param name="torqueConverterLocked">if true, the regular shift polygon is used, otherwise the shift polygon for the torque converter is used</param> /// <returns><c>true</c> if the operating point is above the up-shift curve; otherwise, <c>false</c>.</returns> - protected virtual bool IsAboveUpShiftCurve(uint gear, NewtonMeter inTorque, PerSecond inEngineSpeed) + protected virtual bool IsAboveUpShiftCurve(uint gear, NewtonMeter inTorque, PerSecond inEngineSpeed, + bool torqueConverterLocked) { - return gear < Data.Gears.Keys.Max() && Data.Gears[gear].ShiftPolygon.IsAboveUpshiftCurve(inTorque, inEngineSpeed); + if (torqueConverterLocked) { + return gear < Data.Gears.Keys.Max() && Data.Gears[gear].ShiftPolygon.IsAboveUpshiftCurve(inTorque, inEngineSpeed); + } + return gear < Data.Gears.Keys.Max() && + Data.Gears[gear].TorqueConverterShiftPolygon.IsAboveUpshiftCurve(inTorque, inEngineSpeed); } protected class NextGearState diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs index de044761e86e2a76e1b04cc9ca7f93ba87922c48..43eada0b840117ad1ac86a061461526bc31c0e3e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs @@ -31,10 +31,8 @@ using System; using System.IO; -using System.Windows.Forms.VisualStyles; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; @@ -255,7 +253,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Auxiliaries.Signals.PreExistingAuxPower = AdditionalAux != null ? AdditionalAux.PowerDemand(absTime, dt, torquePowerTrain, torqueEngine, angularSpeed, dryRun) * avgAngularSpeed : 0.SI<Watt>(); - ; //mAAUX_Global.PreExistingAuxPower; + //mAAUX_Global.PreExistingAuxPower; Auxiliaries.Signals.Idle = DataBus.VehicleStopped; Auxiliaries.Signals.InNeutral = DataBus.Gear == 0; Auxiliaries.Signals.RunningCalc = true; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs index 3af177aabb8a955c1aad93a00002986feb9ebddb..18df85edb9788588482642d3782d058dcfc7ee44 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs @@ -159,7 +159,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var engineSpeed = VectoMath.Max(_idleSpeed, angularVelocity); angularVelocityIn = _clutchSpeedSlippingFactor * engineSpeed + _idleSpeed; - torqueIn = torque * effectiveAngularVelocity / ClutchEff / ((angularVelocityIn)); + torqueIn = torque * effectiveAngularVelocity / ClutchEff / angularVelocityIn; } else { _clutchState = ClutchState.ClutchClosed; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 36c30a9ffe5c6d98aaaca38447dcd0e83b665571..bca7a14a5f3893b80c523e8eec2116c76a37dd35 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -30,7 +30,6 @@ */ using System; -using System.Collections.Generic; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -39,7 +38,6 @@ using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; -using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.Utils; @@ -128,6 +126,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl get { return ModelData.FullLoadCurve.N95hSpeed; } } + public PerSecond EngineN80hSpeed + { + get { return ModelData.FullLoadCurve.N80hSpeed; } + } + public ICombustionEngineIdleController IdleController { get { return EngineIdleController ?? (EngineIdleController = new CombustionEngineIdleController(this)); } @@ -239,7 +242,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl maxTorque = VectoMath.Min(maxTorque, gearboxFullLoad); } - CurrentState.EngineTorque = VectoMath.Limit(totalTorqueDemand, minTorque, maxTorque); + CurrentState.EngineTorque = totalTorqueDemand.Limit(minTorque, maxTorque); CurrentState.EnginePower = CurrentState.EngineTorque * avgEngineSpeed; if (totalTorqueDemand.IsGreater(0) && diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs index 28ec611a54de1657a44231655f60751a17b63770..a0921ac24a12ad4fc3616d30b20969ae0ebe3384 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs @@ -29,12 +29,10 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System.Diagnostics; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; -using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; @@ -45,8 +43,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { - public class CycleGearbox : AbstractGearbox<GearboxState>, IGearbox, ITnOutPort, ITnInPort, - IClutchInfo + public class CycleGearbox : AbstractGearbox<GearboxState>, IGearbox, IClutchInfo { public CycleGearbox(IVehicleContainer container, GearboxData gearboxModelData) : base(container, gearboxModelData) {} @@ -100,7 +97,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var inTorque = outTorque / ModelData.Gears[Gear].Ratio - inTorqueLossResult.Value; if (!inAngularVelocity.IsEqual(0)) { - var alpha = (ModelData.Inertia.IsEqual(0)) + var alpha = ModelData.Inertia.IsEqual(0) ? 0.SI<PerSquareSecond>() : outTorque / ModelData.Inertia; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index b2b3f14f309ff09b2cd5858ce334fcd656c4267e..8359471720f383b0d84e1b233e0212be18dc8ba0 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -462,7 +462,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if ((Driver.DataBus.Distance + ds).IsSmaller(nextAction.TriggerDistance - newBrakingDistance)) { return response; } - newds = (nextAction.TriggerDistance - newBrakingDistance) - Driver.DataBus.Distance - + newds = nextAction.TriggerDistance - newBrakingDistance - Driver.DataBus.Distance - Constants.SimulationSettings.DriverActionDistanceTolerance / 2; break; default: @@ -583,11 +583,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }). Case<ResponseOverload>(r => { // limiting deceleration while coast may result in an overload => issue brakes to decelerate with driver's max deceleration - if (DataBus.ClutchClosed(absTime)) { - response = Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient); - } else { - response = Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); - } + response = DataBus.ClutchClosed(absTime) + ? Driver.DrivingActionAccelerate(absTime, ds, targetVelocity, gradient) + : Driver.DrivingActionRoll(absTime, ds, targetVelocity, gradient); //Phase = BrakingPhase.Brake; }). Case<ResponseDrivingCycleDistanceExceeded>(r => { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index f216e777b9eb816ffc915a124f548a474b5b3f30..eb55061f4b0ff5a45491b03569ab34a248051473 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -257,7 +257,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl leftSamplePoint.Altitude, rightSamplePoint.Altitude, PreviousState.Distance + ds); var gradient = VectoMath.InclinationToAngle(((CurrentState.Altitude - PreviousState.Altitude) / - (ds)).Value()); + ds).Value()); //return 0.SI<Radian>(); return gradient; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs index e1cb4c676688a37c6c46e9174ea40ec693c1e4ef..4f6e12dbf501f6d282ab3082f613ef0553019dbe 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Driver.cs @@ -30,7 +30,6 @@ */ using System; -using System.Windows.Forms.VisualStyles; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index 7a659136b693c63c374af1911cced14e7c72439f..4c047df1fff591e52d1d0e3c034c3e48ff662061 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -29,12 +29,10 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System.Diagnostics; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; -using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; @@ -119,7 +117,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var inTorque = outTorque / ModelData.Gears[gear].Ratio + torqueLossResult.Value; if (!inAngularVelocity.IsEqual(0)) { - var alpha = (ModelData.Inertia.IsEqual(0)) + var alpha = ModelData.Inertia.IsEqual(0) ? 0.SI<PerSquareSecond>() : outTorque / ModelData.Inertia; @@ -224,7 +222,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var shiftTimeExceeded = absTime.IsSmaller(_engageTime) && - _engageTime.IsSmaller(absTime + dt, Constants.SimulationSettings.LowerBoundTimeInterval); // allow 5% tolerance of shift time + _engageTime.IsSmaller(absTime + dt, Constants.SimulationSettings.LowerBoundTimeInterval); + // allow 5% tolerance of shift time if (shiftTimeExceeded) { return new ResponseFailTimeInterval { Source = this, @@ -278,11 +277,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (Disengaged && !outAngularVelocity.IsEqual(0)) { Disengaged = false; var lastGear = Gear; - if (DataBus.VehicleStopped) { - Gear = _strategy.InitGear(absTime, dt, outTorque, outAngularVelocity); - } else { - Gear = _strategy.Engage(absTime, dt, outTorque, outAngularVelocity); - } + Gear = DataBus.VehicleStopped + ? _strategy.InitGear(absTime, dt, outTorque, outAngularVelocity) + : _strategy.Engage(absTime, dt, outTorque, outAngularVelocity); if (Gear > lastGear) { LastUpshift = absTime; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MTShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MTShiftStrategy.cs index 7900f00107faf96d176838188c1427127a8247fe..2dc8dad844ee75a31fe97e05952ec3530681f8b3 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/MTShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/MTShiftStrategy.cs @@ -29,7 +29,6 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.SimulationComponent.Data; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs index a67cc3771a4d4a8ea818cdf61af9a3a63e6221fd..c2d195028f31115a2a14b4ff4f453c4f45cc1ac7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs @@ -438,13 +438,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl response.Switch() .Case<ResponseGearShift>(() => response = NextComponent.Request(absTime, dt, acceleration, gradient)) .Case<ResponseUnderload>(r => { + var acceleration1 = acceleration; DataBus.BrakePower = SearchAlgorithm.Search(DataBus.BrakePower, r.Delta, -r.Delta, getYValue: result => DataBus.ClutchClosed(absTime) ? ((ResponseDryRun)result).DeltaDragLoad : ((ResponseDryRun)result).GearboxPowerRequest, evaluateFunction: x => { DataBus.BrakePower = x; - return NextComponent.Request(absTime, dt, acceleration, gradient, true); + return NextComponent.Request(absTime, dt, acceleration1, gradient, true); }, criterion: y => DataBus.ClutchClosed(absTime) ? ((ResponseDryRun)y).DeltaDragLoad.Value() diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs index 261a7d10273ebe206c6c92c730dcdffa6d48020b..4d25a7d51f23594ef048e7d02554bf336583e317 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs @@ -29,14 +29,11 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System; -using System.Drawing.Design; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs index 049b07ec2d7e7ad9b073b72bea71c8641b2d1078..cbeb7b2d1ba1ad6fbe2c41455e6d1cf3ff34ecee 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/TorqueConverter.cs @@ -1,5 +1,4 @@ -using System; -using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; @@ -7,7 +6,6 @@ using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; -using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; using TUGraz.VectoCore.OutputData; @@ -108,11 +106,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } CurrentState.SetState(operatingPoint.InTorque, operatingPoint.InAngularVelocity, outTorque, outAngularVelocity); CurrentState.OperatingPoint = operatingPoint; - var retVal = NextComponent.Request(absTime, dt, operatingPoint.InTorque, operatingPoint.InAngularVelocity, dryRun); + var retVal = NextComponent.Request(absTime, dt, operatingPoint.InTorque, operatingPoint.InAngularVelocity); return retVal; } - protected TorqueConverterOperatingPoint FindOperatingPoint(NewtonMeter outTorque, PerSecond outAngularVelocity) + protected internal TorqueConverterOperatingPoint FindOperatingPoint(NewtonMeter outTorque, + PerSecond outAngularVelocity) { try { var operatingPoint = ModelData.FindOperatingPoint(outTorque, outAngularVelocity); diff --git a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs index 39cf24c121e3aabd53a57eccc8c522c73f36c7fc..dd02c872da1a2752b13e31479fd7de99e5025d16 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs @@ -310,7 +310,7 @@ namespace TUGraz.VectoCore.OutputData object[] remainingRow = null; var gearsList = new Dictionary<object, Second>(3); - var v_act = data.Rows.Cast<DataRow>().First().Field<MeterPerSecond>((int)ModalResultField.v_act); + var vAct = data.Rows.Cast<DataRow>().First().Field<MeterPerSecond>((int)ModalResultField.v_act); foreach (DataRow row in data.Rows) { var currentDt = row.Field<Second>((int)ModalResultField.simulationInterval); @@ -324,8 +324,8 @@ namespace TUGraz.VectoCore.OutputData var gear = row[(int)ModalResultField.Gear]; gearsList[gear] = gearsList.GetValueOrZero(gear) + diffDt; - distance += diffDt * v_act + diffDt * diffDt * (MeterPerSquareSecond)row[(int)ModalResultField.acc] / 2; - v_act += diffDt * (MeterPerSquareSecond)row[(int)ModalResultField.acc]; + distance += diffDt * vAct + diffDt * diffDt * (MeterPerSquareSecond)row[(int)ModalResultField.acc] / 2; + vAct += diffDt * (MeterPerSquareSecond)row[(int)ModalResultField.acc]; r.ItemArray = AddRow(remainingRow, MultiplyRow(row.ItemArray, diffDt)); absTime += diffDt; @@ -333,7 +333,7 @@ namespace TUGraz.VectoCore.OutputData r[(int)ModalResultField.simulationInterval] = 1.SI<Second>(); r[(int)ModalResultField.Gear] = gearsList.MaxBy(kv => kv.Value).Key; r[(int)ModalResultField.dist] = distance; - r[(int)ModalResultField.v_act] = v_act; + r[(int)ModalResultField.v_act] = vAct; gearsList.Clear(); results.Rows.Add(r); @@ -349,13 +349,13 @@ namespace TUGraz.VectoCore.OutputData var r = results.NewRow(); r.ItemArray = row.ItemArray; absTime += dt; - distance += dt * v_act + dt * dt * (MeterPerSquareSecond)row[(int)ModalResultField.acc] / 2; - v_act += dt * (MeterPerSquareSecond)row[(int)ModalResultField.acc]; + distance += dt * vAct + dt * dt * (MeterPerSquareSecond)row[(int)ModalResultField.acc] / 2; + vAct += dt * (MeterPerSquareSecond)row[(int)ModalResultField.acc]; r[(int)ModalResultField.time] = absTime; r[(int)ModalResultField.simulationInterval] = dt; r[(int)ModalResultField.dist] = distance; - r[(int)ModalResultField.v_act] = v_act; + r[(int)ModalResultField.v_act] = vAct; results.Rows.Add(r); } @@ -364,8 +364,8 @@ namespace TUGraz.VectoCore.OutputData var gear = row[(int)ModalResultField.Gear]; gearsList[gear] = gearsList.GetValueOrZero(gear) + currentDt; - distance += currentDt * v_act + currentDt * currentDt * (MeterPerSquareSecond)row[(int)ModalResultField.acc] / 2; - v_act += currentDt * (MeterPerSquareSecond)row[(int)ModalResultField.acc]; + distance += currentDt * vAct + currentDt * currentDt * (MeterPerSquareSecond)row[(int)ModalResultField.acc] / 2; + vAct += currentDt * (MeterPerSquareSecond)row[(int)ModalResultField.acc]; remainingRow = AddRow(remainingRow, MultiplyRow(row.ItemArray, currentDt)); remainingDt += currentDt; absTime += currentDt; @@ -383,15 +383,15 @@ namespace TUGraz.VectoCore.OutputData var r = results.NewRow(); r.ItemArray = MultiplyRow(remainingRow, 1 / remainingDt).ToArray(); - distance += remainingDt * v_act + + distance += remainingDt * vAct + remainingDt * remainingDt * (MeterPerSquareSecond)last[(int)ModalResultField.acc] / 2; - v_act += remainingDt * (MeterPerSquareSecond)last[(int)ModalResultField.acc]; + vAct += remainingDt * (MeterPerSquareSecond)last[(int)ModalResultField.acc]; r[(int)ModalResultField.time] = VectoMath.Ceiling(absTime); r[(int)ModalResultField.simulationInterval] = 1.SI<Second>(); r[(int)ModalResultField.Gear] = gearsList.MaxBy(kv => kv.Value).Key; r[(int)ModalResultField.dist] = distance; - r[(int)ModalResultField.v_act] = v_act; + r[(int)ModalResultField.v_act] = vAct; results.Rows.Add(r); } diff --git a/VectoCore/VectoCore/Properties/Version.cs b/VectoCore/VectoCore/Properties/Version.cs index 6d96b40242ac8fdb3018a167a07c1db321c5da74..8e0bea3277d42cc085510c8955bcf1d9f83e59ae 100644 --- a/VectoCore/VectoCore/Properties/Version.cs +++ b/VectoCore/VectoCore/Properties/Version.cs @@ -30,5 +30,5 @@ */ using System.Reflection; -[assembly: AssemblyVersion("3.0.4.565")] -[assembly: AssemblyFileVersion("3.0.4.565")] +[assembly: AssemblyVersion("3.0.4.606")] +[assembly: AssemblyFileVersion("3.0.4.606")] diff --git a/VectoCore/VectoCore/Utils/ProviderExtensions.cs b/VectoCore/VectoCore/Utils/ProviderExtensions.cs index 3e4dc0fb3ed93aaf13f8223e92e01b925e6dc537..5e67dcfb1528b25c98e34b75319fd4adff9f53ea 100644 --- a/VectoCore/VectoCore/Utils/ProviderExtensions.cs +++ b/VectoCore/VectoCore/Utils/ProviderExtensions.cs @@ -30,7 +30,6 @@ */ using System; -using System.Collections.Generic; using TUGraz.VectoCommon.Models; using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Simulation; diff --git a/VectoCore/VectoCore/Utils/SearchAlgorithm.cs b/VectoCore/VectoCore/Utils/SearchAlgorithm.cs index 0d3b6e9723ccb04bfce22dbb2f31777d75b8e248..23338fa88a3c2370a75cd60b5e3f8e7295039b45 100644 --- a/VectoCore/VectoCore/Utils/SearchAlgorithm.cs +++ b/VectoCore/VectoCore/Utils/SearchAlgorithm.cs @@ -35,7 +35,6 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Threading; -using System.Windows.Forms; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; diff --git a/VectoCore/VectoCore/Utils/VectoCSVFile.cs b/VectoCore/VectoCore/Utils/VectoCSVFile.cs index 33722c85ce398ee0ff45910f8b1524d82b8559fd..b4c9b429c3493251ab308041a842b78a2282b9d1 100644 --- a/VectoCore/VectoCore/Utils/VectoCSVFile.cs +++ b/VectoCore/VectoCore/Utils/VectoCSVFile.cs @@ -187,7 +187,7 @@ namespace TUGraz.VectoCore.Utils return; } var header = table.Columns.Cast<DataColumn>().Select(col => col.Caption ?? col.ColumnName); - writer.WriteLine(Delimiter.ToString().Join(header)); + writer.WriteLine(Delimiter.Join(header)); foreach (DataRow row in table.Rows) { var row1 = row; @@ -203,7 +203,7 @@ namespace TUGraz.VectoCore.Utils : string.Format(CultureInfo.InvariantCulture, "{0}", item); }); - writer.WriteLine(Delimiter.ToString().Join(formattedList)); + writer.WriteLine(Delimiter.Join(formattedList)); } } } diff --git a/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs index 2c2db8674cffacceb1e9eb161ce2222faaa628cf..464054a2ca1d8a72698ab166997e533d3e4ae7d3 100644 --- a/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/ATPowerTrain.cs @@ -106,6 +106,7 @@ namespace TUGraz.VectoCore.Tests.Integration ? TransmissionLossMapReader.Create(gbxType == GearboxType.ATPowerSplit ? 1.0 : 0.98, ratio, string.Format("Gear {0}", i)) : null, + TorqueConverterShiftPolygon = i == 0 ? ShiftPolygonReader.ReadFromFile(GearboxShiftPolygonFile) : null })) .ToDictionary(k => k.Item1 + 1, v => v.Item2), ShiftTime = 1.SI<Second>(), diff --git a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs index bc4a4b808f05bba1ffa6041bad8903d66800b8cf..00c7e0db53a10b7a25c05972b1c121b1876f0fef 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachAdvancedAuxPowertrain.cs @@ -35,6 +35,7 @@ using System.Linq; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.Reader; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; diff --git a/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs index b832d2801c6e6cb1f76dc3b58d024b4519e42c42..64c1b97472aac76c35d528608011d180627ffe12 100644 --- a/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/CoachPowerTrain.cs @@ -36,6 +36,7 @@ using System.Linq; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.Reader; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs index 3baaded391ea484826385b6185dc0f7b589a6a8a..42ecc227c3fb369b5709dc0d496e1d06db6e197d 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs @@ -38,6 +38,7 @@ using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.Reader; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs index 2eff2b8a78db57646d476f9506062348026a9ca2..58423bc151dc93968cd1c8f93c438f67e2d99f1d 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/MinimalPowertrain.cs @@ -35,6 +35,7 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.Reader; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; diff --git a/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs b/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs index 83d65c1a60c0f76486f3e68145a1db42343d28c9..c9802f412b3ba5d4eb9a49547d4b16a3ca8fa052 100644 --- a/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs +++ b/VectoCore/VectoCoreTest/Integration/Truck40tPowerTrain.cs @@ -36,6 +36,7 @@ using System.Linq; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.Reader; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; diff --git a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs index 89d2a3c987ac2ff9f0fcd669f3d15aff698f5e70..68efd7c76254a243cf5d0024cc5db522c0310be8 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs @@ -38,6 +38,7 @@ using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.JSON; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.InputData.Reader.Impl; using TUGraz.VectoCore.Models.Declaration; diff --git a/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs index 8d23f7038bc7b89b9ab78c73391511f22449f297..2846bea14641d849643f1bff9f4b1de2441b7b64 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/LossMapRangeValidationTest.cs @@ -39,6 +39,7 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.Reader; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; diff --git a/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs index b076d54fe87bbe20574d66b3256f11ed6a2c8f45..e434ef9292a3af0170c2e8c034bb15927829f1a1 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/MeasuredSpeedModeTest.cs @@ -38,6 +38,7 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.Reader; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs index ee0802a6b8afcd21a44b9dd6a759f3d557f3da47..d85fccb682164e5c077cd15bc99ac905b4bee932 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs @@ -169,6 +169,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent public PerSecond EngineIdleSpeed { get; set; } public PerSecond EngineRatedSpeed { get; set; } public PerSecond EngineN95hSpeed { get; set; } + public PerSecond EngineN80hSpeed { get; set; } protected override void DoWriteModalResults(IModalDataContainer container) { diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs index 11b4389ef1c66a7112dcf36058e14dc16e9834ad..565b4313ef3970cede30bf4c9c311a2f540d756d 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/DriverTest.cs @@ -35,6 +35,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Declaration; diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs index b8ad832394f5554711de0db6215a7bc8b832b3fc..8fcede0aed487fe85f923f6fcf318a51f8d626ad 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxTest.cs @@ -37,6 +37,7 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.Reader; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.DataBus; diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/RetarderTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/RetarderTest.cs index 43f559dc9c05bbd139155cd7c88f9e6cc417c29b..5635989fafd0da9def696e0552c731ece4e8e767 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/RetarderTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/RetarderTest.cs @@ -33,6 +33,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Impl; diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs index 90ea43e51ccd6a4eabdaae12ea79acd3c3f2f530..64d71bcb4f8b1bfe2ff5f8d4bf2a8eb44f37db32 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs @@ -34,6 +34,7 @@ using System.IO; using NUnit.Framework; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/AccelerationCurveTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/AccelerationCurveTest.cs index e05927a576d35002002ad32dfaf7f4c3ecc2377c..c04bc986b6ea80afbd29ae53ed6ce2250d23828c 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/AccelerationCurveTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/AccelerationCurveTest.cs @@ -31,6 +31,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.SimulationComponent.Data; namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs index cbb7c430a25dc70ccc1950c8c72bef7f4051bb06..7c672100e5d50a0591d8e36039ffd3ec827c28d7 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs @@ -36,6 +36,7 @@ using NLog.Config; using NLog.Targets; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs index e13422105359ab3efa6e5773f9d50f55fa68403d..25e65c5ef2001396fc2537f188d3224466506cb3 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs @@ -36,6 +36,7 @@ using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.Reader; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs index acef3487d4afd8ac6a2e2f40948c267771476796..b7d5740fb573b2eeac1c3e19654cd40329ae9c04 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs @@ -38,6 +38,7 @@ using System.Linq; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.Reader; +using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; diff --git a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/AT-Shift.vgbs b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/AT-Shift.vgbs index 91acd23a7a0e04d26fe81b57a3b972cf0975d976..4da1c5a5aedffae8d86fd20777c0e56b83b0bea2 100644 --- a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/AT-Shift.vgbs +++ b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/AT-Shift.vgbs @@ -1,4 +1,4 @@ -M_shift in Nm,n_down in rpm,n_up in rpm --200,600,800 -0,600,800 -3000,600,800 +engine torque [Nm],downshift rpm [1/min],upshift rpm [1/min] +-200,700,800 +0,700,800 +3000,700,800 diff --git a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/GearboxSerial.vgbx b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/GearboxSerial.vgbx index b42e6c26b583f4eec138759dc1efa347b63e1e8d..6f07657d51c3320fb729e1dd400c147d52ee4218 100644 --- a/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/GearboxSerial.vgbx +++ b/VectoCore/VectoCoreTest/TestData/Components/AT_GBX/GearboxSerial.vgbx @@ -18,37 +18,37 @@ { "Ratio": 3.4, "Efficiency": "0.98", - "ShiftPolygon": "<NOFILE>", + "ShiftPolygon": "AT-Shift.vgbs", "FullLoadCurve": "<NOFILE>" }, { "Ratio": 1.9, "Efficiency": "0.98", - "ShiftPolygon": "<NOFILE>", + "ShiftPolygon": "AT-Shift.vgbs", "FullLoadCurve": "<NOFILE>" }, { "Ratio": 1.42, "Efficiency": "0.98", - "ShiftPolygon": "<NOFILE>", + "ShiftPolygon": "AT-Shift.vgbs", "FullLoadCurve": "<NOFILE>" }, { "Ratio": 1.0, "Efficiency": "0.98", - "ShiftPolygon": "<NOFILE>", + "ShiftPolygon": "AT-Shift.vgbs", "FullLoadCurve": "<NOFILE>" }, { "Ratio": 0.7, "Efficiency": "0.98", - "ShiftPolygon": "<NOFILE>", + "ShiftPolygon": "AT-Shift.vgbs", "FullLoadCurve": "<NOFILE>" }, { "Ratio": 0.62, "Efficiency": "0.98", - "ShiftPolygon": "<NOFILE>", + "ShiftPolygon": "AT-Shift.vgbs", "FullLoadCurve": "<NOFILE>" } ], @@ -64,7 +64,8 @@ "Enabled": true, "File": "TorqueConverter.vtcc", "RefRPM": 1000.0, - "Inertia": 0.0 + "Inertia": 0.0, + "ShiftPolygon": "AT-Shift.vgbs" }, "DownshiftAferUpshiftDelay": 0.0, "UpshiftAfterDownshiftDelay": 0.0, diff --git a/VectoCore/VectoCoreTest/Utils/MockPorts.cs b/VectoCore/VectoCoreTest/Utils/MockPorts.cs index 2ab63efb9c8f1bfd49ba6304a72d3b9aa72ec5b1..05626ba5f44c2cc64f2f4c342ee0c9e0395893ff 100644 --- a/VectoCore/VectoCoreTest/Utils/MockPorts.cs +++ b/VectoCore/VectoCoreTest/Utils/MockPorts.cs @@ -126,6 +126,7 @@ namespace TUGraz.VectoCore.Tests.Utils } public PerSecond EngineN95hSpeed { get; set; } + public PerSecond EngineN80hSpeed { get; set; } } public class MockDrivingCycleOutPort : LoggingObject, IDrivingCycleOutPort diff --git a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs index f980c9ab65c980ebcac4daa7d6181b75c93e7fed..02668f175c0b311a20a8cc503b4844e52a4695ef 100644 --- a/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs +++ b/VectoCore/VectoCoreTest/Utils/MockVehicleContainer.cs @@ -92,6 +92,11 @@ namespace TUGraz.VectoCore.Tests.Utils get { return Engine.EngineN95hSpeed; } } + public PerSecond EngineN80hSpeed + { + get { return Engine.EngineN80hSpeed; } + } + public MeterPerSecond VehicleSpeed { get; set; } public Kilogram VehicleMass { get; set; } public Kilogram VehicleLoading { get; set; }