diff --git a/VECTO/GUI/F_Settings.Designer.vb b/VECTO/GUI/F_Settings.Designer.vb index c12d88b76a8d029ff56d3ac5a09c143dbea78ec9..716218d0b4597e8c157e6eaff22aa4ee29617fa3 100644 --- a/VECTO/GUI/F_Settings.Designer.vb +++ b/VECTO/GUI/F_Settings.Designer.vb @@ -22,296 +22,296 @@ Partial Class F_Settings 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() - Me.ButtonOK = New System.Windows.Forms.Button() - Me.ButtonCancel = New System.Windows.Forms.Button() - Me.GroupBox3 = New System.Windows.Forms.GroupBox() - Me.GroupBox5 = New System.Windows.Forms.GroupBox() - Me.TbOpenCmdName = New System.Windows.Forms.TextBox() - Me.Label7 = New System.Windows.Forms.Label() - Me.TbOpenCmd = New System.Windows.Forms.TextBox() - Me.Label12 = New System.Windows.Forms.Label() - Me.TextBoxLogSize = New System.Windows.Forms.TextBox() - Me.Label16 = New System.Windows.Forms.Label() - Me.TabControl1 = New System.Windows.Forms.TabControl() - Me.TabPage2 = New System.Windows.Forms.TabPage() - Me.GrCalc = New System.Windows.Forms.GroupBox() - Me.Label11 = New System.Windows.Forms.Label() - Me.Label9 = New System.Windows.Forms.Label() - Me.Label3 = New System.Windows.Forms.Label() - Me.TbCO2toFC = New System.Windows.Forms.TextBox() - Me.Label10 = New System.Windows.Forms.Label() - Me.TbFuelDens = New System.Windows.Forms.TextBox() - Me.Label8 = New System.Windows.Forms.Label() - Me.TbAirDensity = New System.Windows.Forms.TextBox() - Me.Label2 = New System.Windows.Forms.Label() - Me.ButReset = New System.Windows.Forms.Button() - Me.BtHelp = New System.Windows.Forms.Button() - Me.GroupBox3.SuspendLayout() - Me.GroupBox5.SuspendLayout() - Me.TabControl1.SuspendLayout() - Me.TabPage2.SuspendLayout() - Me.GrCalc.SuspendLayout() - Me.SuspendLayout() - ' - 'ButtonOK - ' - Me.ButtonOK.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.ButtonOK.Location = New System.Drawing.Point(347, 287) - Me.ButtonOK.Name = "ButtonOK" - Me.ButtonOK.Size = New System.Drawing.Size(75, 26) - Me.ButtonOK.TabIndex = 2 - Me.ButtonOK.Text = "OK" - Me.ButtonOK.UseVisualStyleBackColor = True - ' - 'ButtonCancel - ' - Me.ButtonCancel.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.ButtonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel - Me.ButtonCancel.Location = New System.Drawing.Point(428, 287) - Me.ButtonCancel.Name = "ButtonCancel" - Me.ButtonCancel.Size = New System.Drawing.Size(75, 26) - Me.ButtonCancel.TabIndex = 3 - Me.ButtonCancel.Text = "Cancel" - Me.ButtonCancel.UseVisualStyleBackColor = True - ' - 'GroupBox3 - ' - Me.GroupBox3.Controls.Add(Me.GroupBox5) - Me.GroupBox3.Controls.Add(Me.TextBoxLogSize) - Me.GroupBox3.Controls.Add(Me.Label16) - Me.GroupBox3.Location = New System.Drawing.Point(5, 6) - Me.GroupBox3.Name = "GroupBox3" - Me.GroupBox3.Size = New System.Drawing.Size(489, 124) - Me.GroupBox3.TabIndex = 0 - Me.GroupBox3.TabStop = False - Me.GroupBox3.Text = "Interface" - ' - 'GroupBox5 - ' - Me.GroupBox5.Controls.Add(Me.TbOpenCmdName) - Me.GroupBox5.Controls.Add(Me.Label7) - Me.GroupBox5.Controls.Add(Me.TbOpenCmd) - Me.GroupBox5.Controls.Add(Me.Label12) - Me.GroupBox5.Location = New System.Drawing.Point(230, 19) - Me.GroupBox5.Name = "GroupBox5" - Me.GroupBox5.Size = New System.Drawing.Size(253, 96) - Me.GroupBox5.TabIndex = 1 - Me.GroupBox5.TabStop = False - Me.GroupBox5.Text = "File Open Command" - ' - 'TbOpenCmdName - ' - Me.TbOpenCmdName.Location = New System.Drawing.Point(66, 19) - Me.TbOpenCmdName.Name = "TbOpenCmdName" - Me.TbOpenCmdName.Size = New System.Drawing.Size(174, 20) - Me.TbOpenCmdName.TabIndex = 0 - ' - 'Label7 - ' - Me.Label7.AutoSize = True - Me.Label7.Location = New System.Drawing.Point(6, 48) - Me.Label7.Name = "Label7" - Me.Label7.Size = New System.Drawing.Size(54, 13) - Me.Label7.TabIndex = 12 - Me.Label7.Text = "Command" - ' - 'TbOpenCmd - ' - Me.TbOpenCmd.Location = New System.Drawing.Point(66, 45) - Me.TbOpenCmd.Name = "TbOpenCmd" - Me.TbOpenCmd.Size = New System.Drawing.Size(174, 20) - Me.TbOpenCmd.TabIndex = 1 - ' - 'Label12 - ' - Me.Label12.AutoSize = True - Me.Label12.Location = New System.Drawing.Point(25, 22) - Me.Label12.Name = "Label12" - Me.Label12.Size = New System.Drawing.Size(35, 13) - Me.Label12.TabIndex = 12 - Me.Label12.Text = "Name" - ' - 'TextBoxLogSize - ' - Me.TextBoxLogSize.Location = New System.Drawing.Point(134, 38) - Me.TextBoxLogSize.Name = "TextBoxLogSize" - Me.TextBoxLogSize.Size = New System.Drawing.Size(36, 20) - Me.TextBoxLogSize.TabIndex = 0 - ' - 'Label16 - ' - Me.Label16.AutoSize = True - Me.Label16.Location = New System.Drawing.Point(18, 41) - Me.Label16.Name = "Label16" - Me.Label16.Size = New System.Drawing.Size(110, 13) - Me.Label16.TabIndex = 10 - Me.Label16.Text = "Logfile Size Limit [MB]" - ' - 'TabControl1 - ' - Me.TabControl1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ - Or System.Windows.Forms.AnchorStyles.Left) _ - Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.TabControl1.Controls.Add(Me.TabPage2) - Me.TabControl1.Location = New System.Drawing.Point(3, 3) - Me.TabControl1.Name = "TabControl1" - Me.TabControl1.SelectedIndex = 0 - Me.TabControl1.Size = New System.Drawing.Size(508, 278) - Me.TabControl1.TabIndex = 12 - ' - 'TabPage2 - ' - Me.TabPage2.Controls.Add(Me.GrCalc) - Me.TabPage2.Controls.Add(Me.GroupBox3) - Me.TabPage2.Location = New System.Drawing.Point(4, 22) - Me.TabPage2.Name = "TabPage2" - Me.TabPage2.Padding = New System.Windows.Forms.Padding(3) - Me.TabPage2.Size = New System.Drawing.Size(500, 252) - Me.TabPage2.TabIndex = 0 - Me.TabPage2.Text = "VECTO" - Me.TabPage2.UseVisualStyleBackColor = True - ' - 'GrCalc - ' - Me.GrCalc.Controls.Add(Me.Label11) - Me.GrCalc.Controls.Add(Me.Label9) - Me.GrCalc.Controls.Add(Me.Label3) - Me.GrCalc.Controls.Add(Me.TbCO2toFC) - Me.GrCalc.Controls.Add(Me.Label10) - Me.GrCalc.Controls.Add(Me.TbFuelDens) - Me.GrCalc.Controls.Add(Me.Label8) - Me.GrCalc.Controls.Add(Me.TbAirDensity) - Me.GrCalc.Controls.Add(Me.Label2) - Me.GrCalc.Location = New System.Drawing.Point(6, 136) - Me.GrCalc.Name = "GrCalc" - Me.GrCalc.Size = New System.Drawing.Size(488, 103) - Me.GrCalc.TabIndex = 1 - Me.GrCalc.TabStop = False - Me.GrCalc.Text = "Calculation" - ' - 'Label11 - ' - Me.Label11.AutoSize = True - Me.Label11.Location = New System.Drawing.Point(164, 66) - Me.Label11.Name = "Label11" - Me.Label11.Size = New System.Drawing.Size(77, 13) - Me.Label11.TabIndex = 16 - Me.Label11.Text = "[kgCO2/KgFC]" - ' - 'Label9 - ' - Me.Label9.AutoSize = True - Me.Label9.Location = New System.Drawing.Point(309, 22) - Me.Label9.Name = "Label9" - Me.Label9.Size = New System.Drawing.Size(32, 13) - Me.Label9.TabIndex = 16 - Me.Label9.Text = "[kg/l]" - ' - 'Label3 - ' - Me.Label3.AutoSize = True - Me.Label3.Location = New System.Drawing.Point(130, 22) - Me.Label3.Name = "Label3" - Me.Label3.Size = New System.Drawing.Size(41, 13) - Me.Label3.TabIndex = 16 - Me.Label3.Text = "[kg/m²]" - ' - 'TbCO2toFC - ' - Me.TbCO2toFC.Location = New System.Drawing.Point(108, 63) - Me.TbCO2toFC.Name = "TbCO2toFC" - Me.TbCO2toFC.Size = New System.Drawing.Size(50, 20) - Me.TbCO2toFC.TabIndex = 2 - ' - 'Label10 - ' - Me.Label10.AutoSize = True - Me.Label10.Location = New System.Drawing.Point(11, 66) - Me.Label10.Name = "Label10" - Me.Label10.Size = New System.Drawing.Size(91, 13) - Me.Label10.TabIndex = 14 - Me.Label10.Text = "CO2-to-Fuel Ratio" - ' - 'TbFuelDens - ' - Me.TbFuelDens.Location = New System.Drawing.Point(253, 19) - Me.TbFuelDens.Name = "TbFuelDens" - Me.TbFuelDens.Size = New System.Drawing.Size(50, 20) - Me.TbFuelDens.TabIndex = 1 - ' - 'Label8 - ' - Me.Label8.AutoSize = True - Me.Label8.Location = New System.Drawing.Point(184, 22) - Me.Label8.Name = "Label8" - Me.Label8.Size = New System.Drawing.Size(63, 13) - Me.Label8.TabIndex = 14 - Me.Label8.Text = "Fuel density" - ' - 'TbAirDensity - ' - Me.TbAirDensity.Location = New System.Drawing.Point(74, 19) - Me.TbAirDensity.Name = "TbAirDensity" - Me.TbAirDensity.Size = New System.Drawing.Size(50, 20) - Me.TbAirDensity.TabIndex = 0 - ' - 'Label2 - ' - Me.Label2.AutoSize = True - Me.Label2.Location = New System.Drawing.Point(11, 22) - Me.Label2.Name = "Label2" - Me.Label2.Size = New System.Drawing.Size(57, 13) - Me.Label2.TabIndex = 14 - Me.Label2.Text = "Air Density" - ' - 'ButReset - ' - Me.ButReset.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) - Me.ButReset.Location = New System.Drawing.Point(35, 287) - Me.ButReset.Name = "ButReset" - Me.ButReset.Size = New System.Drawing.Size(108, 26) - Me.ButReset.TabIndex = 1 - Me.ButReset.Text = "Reset All Settings" - Me.ButReset.UseVisualStyleBackColor = True - ' - 'BtHelp - ' - Me.BtHelp.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) - Me.BtHelp.Image = Global.VECTO.My.Resources.Resources.Help_icon - Me.BtHelp.Location = New System.Drawing.Point(3, 287) - Me.BtHelp.Name = "BtHelp" - Me.BtHelp.Size = New System.Drawing.Size(26, 26) - Me.BtHelp.TabIndex = 0 - Me.BtHelp.UseVisualStyleBackColor = True - ' - 'F_Settings - ' - Me.AcceptButton = Me.ButtonOK - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.CancelButton = Me.ButtonCancel - Me.ClientSize = New System.Drawing.Size(515, 325) - Me.Controls.Add(Me.BtHelp) - Me.Controls.Add(Me.ButReset) - Me.Controls.Add(Me.TabControl1) - Me.Controls.Add(Me.ButtonCancel) - Me.Controls.Add(Me.ButtonOK) - Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow - Me.MaximizeBox = False - Me.MinimizeBox = False - Me.Name = "F_Settings" - Me.Text = "Settings" - Me.GroupBox3.ResumeLayout(False) - Me.GroupBox3.PerformLayout() - Me.GroupBox5.ResumeLayout(False) - Me.GroupBox5.PerformLayout() - Me.TabControl1.ResumeLayout(False) - Me.TabPage2.ResumeLayout(False) - Me.GrCalc.ResumeLayout(False) - Me.GrCalc.PerformLayout() - Me.ResumeLayout(False) + Me.ButtonOK = New System.Windows.Forms.Button() + Me.ButtonCancel = New System.Windows.Forms.Button() + Me.GroupBox3 = New System.Windows.Forms.GroupBox() + Me.GroupBox5 = New System.Windows.Forms.GroupBox() + Me.TbOpenCmdName = New System.Windows.Forms.TextBox() + Me.Label7 = New System.Windows.Forms.Label() + Me.TbOpenCmd = New System.Windows.Forms.TextBox() + Me.Label12 = New System.Windows.Forms.Label() + Me.TextBoxLogSize = New System.Windows.Forms.TextBox() + Me.Label16 = New System.Windows.Forms.Label() + Me.TabControl1 = New System.Windows.Forms.TabControl() + Me.TabPage2 = New System.Windows.Forms.TabPage() + Me.GrCalc = New System.Windows.Forms.GroupBox() + Me.Label11 = New System.Windows.Forms.Label() + Me.Label9 = New System.Windows.Forms.Label() + Me.Label3 = New System.Windows.Forms.Label() + Me.TbCO2toFC = New System.Windows.Forms.TextBox() + Me.Label10 = New System.Windows.Forms.Label() + Me.TbFuelDens = New System.Windows.Forms.TextBox() + Me.Label8 = New System.Windows.Forms.Label() + Me.TbAirDensity = New System.Windows.Forms.TextBox() + Me.Label2 = New System.Windows.Forms.Label() + Me.ButReset = New System.Windows.Forms.Button() + Me.BtHelp = New System.Windows.Forms.Button() + Me.GroupBox3.SuspendLayout() + Me.GroupBox5.SuspendLayout() + Me.TabControl1.SuspendLayout() + Me.TabPage2.SuspendLayout() + Me.GrCalc.SuspendLayout() + Me.SuspendLayout() + ' + 'ButtonOK + ' + Me.ButtonOK.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ButtonOK.Location = New System.Drawing.Point(347, 287) + Me.ButtonOK.Name = "ButtonOK" + Me.ButtonOK.Size = New System.Drawing.Size(75, 26) + Me.ButtonOK.TabIndex = 2 + Me.ButtonOK.Text = "OK" + Me.ButtonOK.UseVisualStyleBackColor = True + ' + 'ButtonCancel + ' + Me.ButtonCancel.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ButtonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.ButtonCancel.Location = New System.Drawing.Point(428, 287) + Me.ButtonCancel.Name = "ButtonCancel" + Me.ButtonCancel.Size = New System.Drawing.Size(75, 26) + Me.ButtonCancel.TabIndex = 3 + Me.ButtonCancel.Text = "Cancel" + Me.ButtonCancel.UseVisualStyleBackColor = True + ' + 'GroupBox3 + ' + Me.GroupBox3.Controls.Add(Me.GroupBox5) + Me.GroupBox3.Controls.Add(Me.TextBoxLogSize) + Me.GroupBox3.Controls.Add(Me.Label16) + Me.GroupBox3.Location = New System.Drawing.Point(5, 6) + Me.GroupBox3.Name = "GroupBox3" + Me.GroupBox3.Size = New System.Drawing.Size(489, 124) + Me.GroupBox3.TabIndex = 0 + Me.GroupBox3.TabStop = False + Me.GroupBox3.Text = "Interface" + ' + 'GroupBox5 + ' + Me.GroupBox5.Controls.Add(Me.TbOpenCmdName) + Me.GroupBox5.Controls.Add(Me.Label7) + Me.GroupBox5.Controls.Add(Me.TbOpenCmd) + Me.GroupBox5.Controls.Add(Me.Label12) + Me.GroupBox5.Location = New System.Drawing.Point(230, 19) + Me.GroupBox5.Name = "GroupBox5" + Me.GroupBox5.Size = New System.Drawing.Size(253, 96) + Me.GroupBox5.TabIndex = 1 + Me.GroupBox5.TabStop = False + Me.GroupBox5.Text = "File Open Command" + ' + 'TbOpenCmdName + ' + Me.TbOpenCmdName.Location = New System.Drawing.Point(66, 19) + Me.TbOpenCmdName.Name = "TbOpenCmdName" + Me.TbOpenCmdName.Size = New System.Drawing.Size(174, 20) + Me.TbOpenCmdName.TabIndex = 0 + ' + 'Label7 + ' + Me.Label7.AutoSize = True + Me.Label7.Location = New System.Drawing.Point(6, 48) + Me.Label7.Name = "Label7" + Me.Label7.Size = New System.Drawing.Size(54, 13) + Me.Label7.TabIndex = 12 + Me.Label7.Text = "Command" + ' + 'TbOpenCmd + ' + Me.TbOpenCmd.Location = New System.Drawing.Point(66, 45) + Me.TbOpenCmd.Name = "TbOpenCmd" + Me.TbOpenCmd.Size = New System.Drawing.Size(174, 20) + Me.TbOpenCmd.TabIndex = 1 + ' + 'Label12 + ' + Me.Label12.AutoSize = True + Me.Label12.Location = New System.Drawing.Point(25, 22) + Me.Label12.Name = "Label12" + Me.Label12.Size = New System.Drawing.Size(35, 13) + Me.Label12.TabIndex = 12 + Me.Label12.Text = "Name" + ' + 'TextBoxLogSize + ' + Me.TextBoxLogSize.Location = New System.Drawing.Point(134, 38) + Me.TextBoxLogSize.Name = "TextBoxLogSize" + Me.TextBoxLogSize.Size = New System.Drawing.Size(36, 20) + Me.TextBoxLogSize.TabIndex = 0 + ' + 'Label16 + ' + Me.Label16.AutoSize = True + Me.Label16.Location = New System.Drawing.Point(18, 41) + Me.Label16.Name = "Label16" + Me.Label16.Size = New System.Drawing.Size(110, 13) + Me.Label16.TabIndex = 10 + Me.Label16.Text = "Logfile Size Limit [MB]" + ' + 'TabControl1 + ' + Me.TabControl1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.TabControl1.Controls.Add(Me.TabPage2) + Me.TabControl1.Location = New System.Drawing.Point(3, 3) + Me.TabControl1.Name = "TabControl1" + Me.TabControl1.SelectedIndex = 0 + Me.TabControl1.Size = New System.Drawing.Size(508, 278) + Me.TabControl1.TabIndex = 12 + ' + 'TabPage2 + ' + Me.TabPage2.Controls.Add(Me.GrCalc) + Me.TabPage2.Controls.Add(Me.GroupBox3) + Me.TabPage2.Location = New System.Drawing.Point(4, 22) + Me.TabPage2.Name = "TabPage2" + Me.TabPage2.Padding = New System.Windows.Forms.Padding(3) + Me.TabPage2.Size = New System.Drawing.Size(500, 252) + Me.TabPage2.TabIndex = 0 + Me.TabPage2.Text = "VECTO" + Me.TabPage2.UseVisualStyleBackColor = True + ' + 'GrCalc + ' + Me.GrCalc.Controls.Add(Me.Label11) + Me.GrCalc.Controls.Add(Me.Label9) + Me.GrCalc.Controls.Add(Me.Label3) + Me.GrCalc.Controls.Add(Me.TbCO2toFC) + Me.GrCalc.Controls.Add(Me.Label10) + Me.GrCalc.Controls.Add(Me.TbFuelDens) + Me.GrCalc.Controls.Add(Me.Label8) + Me.GrCalc.Controls.Add(Me.TbAirDensity) + Me.GrCalc.Controls.Add(Me.Label2) + Me.GrCalc.Location = New System.Drawing.Point(6, 136) + Me.GrCalc.Name = "GrCalc" + Me.GrCalc.Size = New System.Drawing.Size(488, 103) + Me.GrCalc.TabIndex = 1 + Me.GrCalc.TabStop = False + Me.GrCalc.Text = "Calculation" + ' + 'Label11 + ' + Me.Label11.AutoSize = True + Me.Label11.Location = New System.Drawing.Point(164, 66) + Me.Label11.Name = "Label11" + Me.Label11.Size = New System.Drawing.Size(77, 13) + Me.Label11.TabIndex = 16 + Me.Label11.Text = "[kgCO2/KgFC]" + ' + 'Label9 + ' + Me.Label9.AutoSize = True + Me.Label9.Location = New System.Drawing.Point(309, 22) + Me.Label9.Name = "Label9" + Me.Label9.Size = New System.Drawing.Size(32, 13) + Me.Label9.TabIndex = 16 + Me.Label9.Text = "[kg/l]" + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(130, 22) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(41, 13) + Me.Label3.TabIndex = 16 + Me.Label3.Text = "[kg/m³]" + ' + 'TbCO2toFC + ' + Me.TbCO2toFC.Location = New System.Drawing.Point(108, 63) + Me.TbCO2toFC.Name = "TbCO2toFC" + Me.TbCO2toFC.Size = New System.Drawing.Size(50, 20) + Me.TbCO2toFC.TabIndex = 2 + ' + 'Label10 + ' + Me.Label10.AutoSize = True + Me.Label10.Location = New System.Drawing.Point(11, 66) + Me.Label10.Name = "Label10" + Me.Label10.Size = New System.Drawing.Size(91, 13) + Me.Label10.TabIndex = 14 + Me.Label10.Text = "CO2-to-Fuel Ratio" + ' + 'TbFuelDens + ' + Me.TbFuelDens.Location = New System.Drawing.Point(253, 19) + Me.TbFuelDens.Name = "TbFuelDens" + Me.TbFuelDens.Size = New System.Drawing.Size(50, 20) + Me.TbFuelDens.TabIndex = 1 + ' + 'Label8 + ' + Me.Label8.AutoSize = True + Me.Label8.Location = New System.Drawing.Point(184, 22) + Me.Label8.Name = "Label8" + Me.Label8.Size = New System.Drawing.Size(63, 13) + Me.Label8.TabIndex = 14 + Me.Label8.Text = "Fuel density" + ' + 'TbAirDensity + ' + Me.TbAirDensity.Location = New System.Drawing.Point(74, 19) + Me.TbAirDensity.Name = "TbAirDensity" + Me.TbAirDensity.Size = New System.Drawing.Size(50, 20) + Me.TbAirDensity.TabIndex = 0 + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(11, 22) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(57, 13) + Me.Label2.TabIndex = 14 + Me.Label2.Text = "Air Density" + ' + 'ButReset + ' + Me.ButReset.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.ButReset.Location = New System.Drawing.Point(35, 287) + Me.ButReset.Name = "ButReset" + Me.ButReset.Size = New System.Drawing.Size(108, 26) + Me.ButReset.TabIndex = 1 + Me.ButReset.Text = "Reset All Settings" + Me.ButReset.UseVisualStyleBackColor = True + ' + 'BtHelp + ' + Me.BtHelp.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.BtHelp.Image = Global.VECTO.My.Resources.Resources.Help_icon + Me.BtHelp.Location = New System.Drawing.Point(3, 287) + Me.BtHelp.Name = "BtHelp" + Me.BtHelp.Size = New System.Drawing.Size(26, 26) + Me.BtHelp.TabIndex = 0 + Me.BtHelp.UseVisualStyleBackColor = True + ' + 'F_Settings + ' + Me.AcceptButton = Me.ButtonOK + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.CancelButton = Me.ButtonCancel + Me.ClientSize = New System.Drawing.Size(515, 325) + Me.Controls.Add(Me.BtHelp) + Me.Controls.Add(Me.ButReset) + Me.Controls.Add(Me.TabControl1) + Me.Controls.Add(Me.ButtonCancel) + Me.Controls.Add(Me.ButtonOK) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "F_Settings" + Me.Text = "Settings" + Me.GroupBox3.ResumeLayout(False) + Me.GroupBox3.PerformLayout() + Me.GroupBox5.ResumeLayout(False) + Me.GroupBox5.PerformLayout() + Me.TabControl1.ResumeLayout(False) + Me.TabPage2.ResumeLayout(False) + Me.GrCalc.ResumeLayout(False) + Me.GrCalc.PerformLayout() + Me.ResumeLayout(False) - End Sub + End Sub Friend WithEvents ButtonOK As System.Windows.Forms.Button Friend WithEvents ButtonCancel As System.Windows.Forms.Button Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox diff --git a/VECTO/Input Files/cGBX.vb b/VECTO/Input Files/cGBX.vb index 55ed4606e5df35088106a675473cb6db2dd825bf..abd1335fecf263037ab906d848ada0d0868c1777 100644 --- a/VECTO/Input Files/cGBX.vb +++ b/VECTO/Input Files/cGBX.vb @@ -11,1333 +11,1318 @@ Imports System.Collections.Generic Public Class cGBX + Private Const FormatVersion As Short = 4 + Private FileVersion As Short - Private Const FormatVersion As Short = 4 - Private FileVersion As Short + Private MyPath As String + Private sFilePath As String - Private MyPath As String - Private sFilePath As String + Public ModelName As String + Public GbxInertia As Single + Public TracIntrSi As Single - Public ModelName As String - Public GbxInertia As Single - Public TracIntrSi As Single + Public Igetr As List(Of Single) + Public GetrMaps As List(Of cSubPath) + Public IsTCgear As List(Of Boolean) - Public Igetr As List(Of Single) - Public GetrMaps As List(Of cSubPath) - Public IsTCgear As List(Of Boolean) + Private MyGBmaps As List(Of cDelaunayMap) + Private GetrEffDef As List(Of Boolean) + Private GetrEff As List(Of Single) - Private MyGBmaps As List(Of cDelaunayMap) - Private GetrEffDef As List(Of Boolean) - Private GetrEff As List(Of Single) + 'Gear shift polygons + Public gs_files As List(Of cSubPath) + Public Shiftpolygons As List(Of cShiftPolygon) - 'Gear shift polygons - Public gs_files As List(Of cSubPath) - Public Shiftpolygons As List(Of cShiftPolygon) + Public gs_TorqueResv As Single + Public gs_SkipGears As Boolean + Public gs_ShiftTime As Integer + Public gs_TorqueResvStart As Single + Public gs_StartSpeed As Single + Public gs_StartAcc As Single + Public gs_ShiftInside As Boolean - Public gs_TorqueResv As Single - Public gs_SkipGears As Boolean - Public gs_ShiftTime As Integer - Public gs_TorqueResvStart As Single - Public gs_StartSpeed As Single - Public gs_StartAcc As Single - Public gs_ShiftInside As Boolean + Public gs_Type As tGearbox - Public gs_Type As tGearbox + 'Torque Converter Input + Public TCon As Boolean + Public TCrefrpm As Single + Private TC_file As New cSubPath + Public TCinertia As Single - 'Torque Converter Input - Public TCon As Boolean - Public TCrefrpm As Single - Private TC_file As New cSubPath - Public TCinertia As Single + Private TCnu As New List(Of Single) + Private TCmu As New List(Of Single) + Private TCtorque As New List(Of Single) + Private TCdim As Integer - Private TCnu As New List(Of Single) - Private TCmu As New List(Of Single) - Private TCtorque As New List(Of Single) - Private TCdim As Integer + 'Torque Converter Iteration Results + Public TCMin As Single + Public TCnUin As Single + Public TC_PeBrake As Single + Public TCMout As Single + Public TCnUout As Single + Public TCReduce As Boolean + Public TCNeutral As Boolean + Public TC_mu As Single + Public TC_nu As Single + Private TCnuMax As Single - 'Torque Converter Iteration Results - Public TCMin As Single - Public TCnUin As Single - Public TC_PeBrake As Single - Public TCMout As Single - Public TCnUout As Single - Public TCReduce As Boolean - Public TCNeutral As Boolean - Public TC_mu As Single - Public TC_nu As Single - Private TCnuMax As Single + Private MyFileList As List(Of String) + Public SavedInDeclMode As Boolean - Private MyFileList As List(Of String) - Public SavedInDeclMode As Boolean + Public Function CreateFileList() As Boolean + Dim i As Integer - Public Function CreateFileList() As Boolean - Dim i As Integer + MyFileList = New List(Of String) - MyFileList = New List(Of String) + 'Transm. Loss Maps + For i = 0 To GearCount() - 1 + If Not IsNumeric(Me.GetrMap(i, True)) Then + If Not MyFileList.Contains(Me.GetrMap(i)) Then MyFileList.Add(Me.GetrMap(i)) + End If - 'Transm. Loss Maps - For i = 0 To GearCount() - 1 - If Not IsNumeric(Me.GetrMap(i, True)) Then - If Not MyFileList.Contains(Me.GetrMap(i)) Then MyFileList.Add(Me.GetrMap(i)) - End If + '.vgbs + If Not Cfg.DeclMode Then + If i > 0 AndAlso Not MyFileList.Contains(Me.gs_files(i).FullPath) Then MyFileList.Add(Me.gs_files(i).FullPath) + End If - '.vgbs - If Not Cfg.DeclMode Then - If i > 0 AndAlso Not MyFileList.Contains(Me.gs_files(i).FullPath) Then MyFileList.Add(Me.gs_files(i).FullPath) - End If + Next - Next + 'Torque Converter + If Me.TCon Then MyFileList.Add(TCfile) - 'Torque Converter - If Me.TCon Then MyFileList.Add(TCfile) + Return True + End Function - Return True - End Function + Public Sub New() + MyPath = "" + sFilePath = "" + SetDefault() + End Sub + Private Sub SetDefault() - Public Sub New() - MyPath = "" - sFilePath = "" - SetDefault() - End Sub + ModelName = "" + GbxInertia = 0 + TracIntrSi = 0 - Private Sub SetDefault() + Igetr = New List(Of Single) + IsTCgear = New List(Of Boolean) + GetrMaps = New List(Of cSubPath) + gs_files = New List(Of cSubPath) - ModelName = "" - GbxInertia = 0 - TracIntrSi = 0 + GetrEffDef = New List(Of Boolean) + GetrEff = New List(Of Single) - Igetr = New List(Of Single) - IsTCgear = New List(Of Boolean) - GetrMaps = New List(Of cSubPath) - gs_files = New List(Of cSubPath) + MyGBmaps = Nothing - GetrEffDef = New List(Of Boolean) - GetrEff = New List(Of Single) + gs_TorqueResv = 0 + gs_SkipGears = False + gs_ShiftTime = 0 + gs_TorqueResvStart = 0 + gs_StartSpeed = 0 + gs_StartAcc = 0 + gs_ShiftInside = False - MyGBmaps = Nothing + gs_Type = tGearbox.Manual - gs_TorqueResv = 0 - gs_SkipGears = False - gs_ShiftTime = 0 - gs_TorqueResvStart = 0 - gs_StartSpeed = 0 - gs_StartAcc = 0 - gs_ShiftInside = False + TCon = False + TCrefrpm = 0 + TC_file.Clear() - gs_Type = tGearbox.Manual + TCinertia = 0 - TCon = False - TCrefrpm = 0 - TC_file.Clear() + SavedInDeclMode = False + End Sub - TCinertia = 0 + Public Function SaveFile() As Boolean + Dim i As Integer + Dim JSON As New cJSON + Dim dic As Dictionary(Of String, Object) + Dim dic0 As Dictionary(Of String, Object) + Dim ls As List(Of Object) - SavedInDeclMode = False + 'Header + dic = New Dictionary(Of String, Object) + dic.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") + dic.Add("Date", Now.ToString) + dic.Add("AppVersion", VECTOvers) + dic.Add("FileVersion", FormatVersion) + JSON.Content.Add("Header", dic) - End Sub + 'Body + dic = New Dictionary(Of String, Object) - Public Function SaveFile() As Boolean - Dim i As Integer - Dim JSON As New cJSON - Dim dic As Dictionary(Of String, Object) - Dim dic0 As Dictionary(Of String, Object) - Dim ls As List(Of Object) + dic.Add("SavedInDeclMode", Cfg.DeclMode) + SavedInDeclMode = Cfg.DeclMode - 'Header - dic = New Dictionary(Of String, Object) - dic.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") - dic.Add("Date", Now.ToString) - dic.Add("AppVersion", VECTOvers) - dic.Add("FileVersion", FormatVersion) - JSON.Content.Add("Header", dic) + dic.Add("ModelName", ModelName) - 'Body - dic = New Dictionary(Of String, Object) + dic.Add("Inertia", GbxInertia) + dic.Add("TracInt", TracIntrSi) - dic.Add("SavedInDeclMode", Cfg.DeclMode) - SavedInDeclMode = Cfg.DeclMode + ls = New List(Of Object) + For i = 0 To Igetr.Count - 1 + dic0 = New Dictionary(Of String, Object) + dic0.Add("Ratio", Igetr(i)) + If IsNumeric(Me.GetrMap(i, True)) Then + dic0.Add("Efficiency", GetrMaps(i).PathOrDummy) + Else + dic0.Add("LossMap", GetrMaps(i).PathOrDummy) + End If + If i > 0 Then + dic0.Add("TCactive", IsTCgear(i)) + dic0.Add("ShiftPolygon", gs_files(i).PathOrDummy) + End If + + ls.Add(dic0) + Next + dic.Add("Gears", ls) + + dic.Add("TqReserve", gs_TorqueResv) + dic.Add("SkipGears", gs_SkipGears) + dic.Add("ShiftTime", gs_ShiftTime) + dic.Add("EaryShiftUp", gs_ShiftInside) + + dic.Add("StartTqReserve", gs_TorqueResvStart) + dic.Add("StartSpeed", gs_StartSpeed) + dic.Add("StartAcc", gs_StartAcc) + + dic.Add("GearboxType", GearboxConv(gs_Type)) + + dic0 = New Dictionary(Of String, Object) + dic0.Add("Enabled", TCon) + dic0.Add("File", TC_file.PathOrDummy) + dic0.Add("RefRPM", TCrefrpm) + dic0.Add("Inertia", TCinertia) + dic.Add("TorqueConverter", dic0) + + JSON.Content.Add("Body", dic) + + Return JSON.WriteFile(sFilePath) + End Function + + Public Function ReadFile(Optional ByVal ShowMsg As Boolean = True) As Boolean + Dim i As Integer + Dim MsgSrc As String + Dim JSON As New cJSON + Dim dic As Object + + MsgSrc = "GBX/ReadFile" + + SetDefault() + + If Not JSON.ReadFile(sFilePath) Then Return False + + Try + + FileVersion = JSON.Content("Header")("FileVersion") + + If FileVersion > 3 Then + SavedInDeclMode = JSON.Content("Body")("SavedInDeclMode") + Else + SavedInDeclMode = Cfg.DeclMode + End If + + ModelName = JSON.Content("Body")("ModelName") + GbxInertia = JSON.Content("Body")("Inertia") + TracIntrSi = JSON.Content("Body")("TracInt") + + i = - 1 + For Each dic In JSON.Content("Body")("Gears") + i += 1 + + Igetr.Add(dic("Ratio")) + GetrMaps.Add(New cSubPath) + + If dic("Efficiency") Is Nothing Then + GetrMaps(i).Init(MyPath, dic("LossMap")) + Else + GetrMaps(i).Init(MyPath, dic("Efficiency")) + End If + + + gs_files.Add(New cSubPath) + + If i = 0 Then + IsTCgear.Add(False) + gs_files(i).Init(MyPath, sKey.NoFile) + Else + IsTCgear.Add(dic("TCactive")) + If FileVersion < 2 Then + gs_files(i).Init(MyPath, JSON.Content("Body")("ShiftPolygons")) + Else + gs_files(i).Init(MyPath, dic("ShiftPolygon")) + End If + End If + + Next + + gs_TorqueResv = JSON.Content("Body")("TqReserve") + gs_SkipGears = JSON.Content("Body")("SkipGears") + gs_ShiftTime = JSON.Content("Body")("ShiftTime") + gs_TorqueResvStart = JSON.Content("Body")("StartTqReserve") + gs_StartSpeed = JSON.Content("Body")("StartSpeed") + gs_StartAcc = JSON.Content("Body")("StartAcc") + gs_ShiftInside = JSON.Content("Body")("EaryShiftUp") + + gs_Type = GearboxConv(JSON.Content("Body")("GearboxType").ToString) + + If JSON.Content("Body")("TorqueConverter") Is Nothing Then + TCon = False + Else + 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") + 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 + + Public Function DeclInit() As Boolean + Dim MsgSrc As String + Dim i As Int16 + + MsgSrc = "GBX/DeclInit" + + If gs_Type = tGearbox.Custom Or gs_Type = tGearbox.Automatic Then + WorkerMsg(tMsgID.Err, "Invalid gearbox type for Declaration Mode!", MsgSrc) + Return False + End If + + GbxInertia = cDeclaration.GbInertia + TracIntrSi = Declaration.TracInt(gs_Type) + gs_SkipGears = Declaration.SkipGears(gs_Type) + gs_ShiftTime = Declaration.ShiftTime(gs_Type) + gs_ShiftInside = Declaration.ShiftInside(gs_Type) + gs_TorqueResv = cDeclaration.TqResv + gs_TorqueResvStart = cDeclaration.TqResvStart + gs_StartSpeed = cDeclaration.StartSpeed + gs_StartAcc = cDeclaration.StartAcc + + TCon = (gs_Type = tGearbox.Automatic) + + For i = 1 To GearCount() + Shiftpolygons(i).SetGenericShiftPoly() + Next + + + Return True + End Function + + Public Function TCinit() As Boolean + Dim file As New cFile_V3 + Dim MsgSrc As String + Dim line() As String + + MsgSrc = "GBX/TCinit" + + If Not file.OpenRead(TC_file.FullPath) Then + WorkerMsg(tMsgID.Err, "Torque Converter file not found! (" & TC_file.FullPath & ")", MsgSrc) + Return False + End If + + 'Skip Header + file.ReadLine() + + If TCrefrpm <= 0 Then + WorkerMsg(tMsgID.Err, "Torque converter reference torque invalid! (" & TCrefrpm & ")", MsgSrc) + Return False + End If + + TCnu.Clear() + TCmu.Clear() + TCtorque.Clear() + TCdim = - 1 + + Try + Do While Not file.EndOfFile + line = file.ReadLine + If CSng(line(0)) < 1 Then + TCnu.Add(CSng(line(0))) + TCmu.Add(CSng(line(1))) + TCtorque.Add(CSng(line(2))) + TCdim += 1 + End If + Loop + Catch ex As Exception + WorkerMsg(tMsgID.Err, "Error while reading Torque Converter file! (" & ex.Message & ")", MsgSrc) + Return False + End Try + + file.Close() + + 'Check if more then one point + If TCdim < 1 Then + WorkerMsg(tMsgID.Err, "More points in Torque Converter file needed!", MsgSrc) + Return False + End If + + TCnuMax = TCnu(TCdim) + + + 'Add default values for nu>1 + If Not file.OpenRead(MyDeclPath & "DefaultTC.vtcc") Then + WorkerMsg(tMsgID.Err, "Default Torque Converter file not found!", MsgSrc) + Return False + End If + + 'Skip Header + file.ReadLine() + + Try + Do While Not file.EndOfFile + line = file.ReadLine + TCnu.Add(CSng(line(0))) + TCmu.Add(CSng(line(1))) + TCtorque.Add(CSng(line(2))) + TCdim += 1 + Loop + Catch ex As Exception + WorkerMsg(tMsgID.Err, "Error while reading Default Torque Converter file! (" & ex.Message & ")", MsgSrc) + Return False + End Try + + file.Close() + + 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 MsgSrc As String + + MsgSrc = "GBX/TCiteration/t= " & t + 1 + + TC_PeBrake = 0 + TCReduce = False + nuStep = 0.001 + Brake = False + TCNeutral = False + + + '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/DEV.TClimit, 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 + Do While (nuMax - nuMin)/nuStep < 10 And nuStep > 0.0001 + nuStep *= 0.1 + Loop + + FirstDone = False + nu = nuMin - nuStep + iDim = - 1 + 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 + + '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) - dic.Add("ModelName", ModelName) + 'Min + Min = Mout/mu - dic.Add("Inertia", GbxInertia) - dic.Add("TracInt", TracIntrSi) + 'Check if Min is too high + If Min > MinMax Then Continue Do - ls = New List(Of Object) - For i = 0 To Igetr.Count - 1 - dic0 = New Dictionary(Of String, Object) - dic0.Add("Ratio", Igetr(i)) - If IsNumeric(Me.GetrMap(i, True)) Then - dic0.Add("Efficiency", GetrMaps(i).PathOrDummy) - Else - dic0.Add("LossMap", GetrMaps(i).PathOrDummy) - End If - If i > 0 Then - dic0.Add("TCactive", IsTCgear(i)) - dic0.Add("ShiftPolygon", gs_files(i).PathOrDummy) - End If + 'Calculated input and output torque for given mu + MinCalc = fTCtorque(nu, nUin) + MoutCalc = MinCalc*mu - ls.Add(dic0) - Next - dic.Add("Gears", ls) + 'Add to lists + nuList.Add(nu) + McalcRatio.Add(MoutCalc/Mout) + iDim += 1 - dic.Add("TqReserve", gs_TorqueResv) - dic.Add("SkipGears", gs_SkipGears) - dic.Add("ShiftTime", gs_ShiftTime) - dic.Add("EaryShiftUp", gs_ShiftInside) + 'Calc smallest error for each mu value + If FirstDone Then + If Math.Abs(1 - McalcRatio(i)) < ErrMin Then + ErrMin = Math.Abs(1 - McalcRatio(i)) + iMin = i + End If + If McalcRatio(i) > McalcRatMax Then McalcRatMax = McalcRatio(i) + Else + FirstDone = True + ErrMin = Math.Abs(1 - McalcRatio(i)) + iMin = i + McalcRatMax = McalcRatio(i) + 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 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 - dic.Add("StartTqReserve", gs_TorqueResvStart) - dic.Add("StartSpeed", gs_StartSpeed) - dic.Add("StartAcc", gs_StartAcc) + '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 - dic.Add("GearboxType", GearboxConv(gs_Type)) + i = 0 + Do While TCnu(i) < nu And i < TCdim + i += 1 + Loop - dic0 = New Dictionary(Of String, Object) - dic0.Add("Enabled", TCon) - dic0.Add("File", TC_file.PathOrDummy) - dic0.Add("RefRPM", TCrefrpm) - dic0.Add("Inertia", TCinertia) - dic.Add("TorqueConverter", dic0) + 'Extrapolation for x > x(imax) + If TCnu(i) < nu Then + MODdata.ModErrors.TCextrapol = "nu= " & nu & " [n_out/n_in]" + End If - JSON.Content.Add("Body", dic) + lbInt: + 'Interpolation + M0 = (nu - TCnu(i - 1))*(TCtorque(i) - TCtorque(i - 1))/(TCnu(i) - TCnu(i - 1)) + TCtorque(i - 1) - Return JSON.WriteFile(sFilePath) + Return M0*(nUin/TCrefrpm)^2 + End Function + + Public Function GSinit() As Boolean + Dim i As Integer - End Function + 'Set Gearbox Type-specific settings + If gs_Type <> tGearbox.Custom Then - Public Function ReadFile(Optional ByVal ShowMsg As Boolean = True) As Boolean - Dim i As Integer - Dim MsgSrc As String - Dim JSON As New cJSON - Dim dic As Object + gs_ShiftInside = Declaration.ShiftInside(gs_Type) + TCon = (gs_Type = tGearbox.Automatic) + gs_SkipGears = Declaration.SkipGears(gs_Type) - MsgSrc = "GBX/ReadFile" + End If - SetDefault() + 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 - If Not JSON.ReadFile(sFilePath) Then Return False + Return True + End Function - Try - - FileVersion = JSON.Content("Header")("FileVersion") - - If FileVersion > 3 Then - SavedInDeclMode = JSON.Content("Body")("SavedInDeclMode") - Else - SavedInDeclMode = Cfg.DeclMode - End If - - ModelName = JSON.Content("Body")("ModelName") - GbxInertia = JSON.Content("Body")("Inertia") - TracIntrSi = JSON.Content("Body")("TracInt") - - i = -1 - For Each dic In JSON.Content("Body")("Gears") - i += 1 - - Igetr.Add(dic("Ratio")) - GetrMaps.Add(New cSubPath) - - If dic("Efficiency") Is Nothing Then - GetrMaps(i).Init(MyPath, dic("LossMap")) - Else - GetrMaps(i).Init(MyPath, dic("Efficiency")) - End If - - - gs_files.Add(New cSubPath) - - If i = 0 Then - IsTCgear.Add(False) - gs_files(i).Init(MyPath, sKey.NoFile) - Else - IsTCgear.Add(dic("TCactive")) - If FileVersion < 2 Then - gs_files(i).Init(MyPath, JSON.Content("Body")("ShiftPolygons")) - Else - gs_files(i).Init(MyPath, dic("ShiftPolygon")) - End If - End If - - Next - - gs_TorqueResv = JSON.Content("Body")("TqReserve") - gs_SkipGears = JSON.Content("Body")("SkipGears") - gs_ShiftTime = JSON.Content("Body")("ShiftTime") - gs_TorqueResvStart = JSON.Content("Body")("StartTqReserve") - gs_StartSpeed = JSON.Content("Body")("StartSpeed") - gs_StartAcc = JSON.Content("Body")("StartAcc") - gs_ShiftInside = JSON.Content("Body")("EaryShiftUp") - - gs_Type = GearboxConv(JSON.Content("Body")("GearboxType").ToString) - - If JSON.Content("Body")("TorqueConverter") Is Nothing Then - TCon = False - Else - 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") - 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 - - Public Function DeclInit() As Boolean - Dim MsgSrc As String - Dim i As Int16 - - MsgSrc = "GBX/DeclInit" - - If gs_Type = tGearbox.Custom Or gs_Type = tGearbox.Automatic Then - WorkerMsg(tMsgID.Err, "Invalid gearbox type for Declaration Mode!", MsgSrc) - Return False - End If - - GbxInertia = cDeclaration.GbInertia - TracIntrSi = Declaration.TracInt(gs_Type) - gs_SkipGears = Declaration.SkipGears(gs_Type) - gs_ShiftTime = Declaration.ShiftTime(gs_Type) - gs_ShiftInside = Declaration.ShiftInside(gs_Type) - gs_TorqueResv = cDeclaration.TqResv - gs_TorqueResvStart = cDeclaration.TqResvStart - gs_StartSpeed = cDeclaration.StartSpeed - gs_StartAcc = cDeclaration.StartAcc - - TCon = (gs_Type = tGearbox.Automatic) - - For i = 1 To GearCount() - Shiftpolygons(i).SetGenericShiftPoly() - Next - - - Return True - - End Function - - Public Function TCinit() As Boolean - Dim file As New cFile_V3 - Dim MsgSrc As String - Dim line() As String - - MsgSrc = "GBX/TCinit" - - If Not file.OpenRead(TC_file.FullPath) Then - WorkerMsg(tMsgID.Err, "Torque Converter file not found! (" & TC_file.FullPath & ")", MsgSrc) - Return False - End If - - 'Skip Header - file.ReadLine() - - If TCrefrpm <= 0 Then - WorkerMsg(tMsgID.Err, "Torque converter reference torque invalid! (" & TCrefrpm & ")", MsgSrc) - Return False - End If - - TCnu.Clear() - TCmu.Clear() - TCtorque.Clear() - TCdim = -1 - - Try - Do While Not file.EndOfFile - line = file.ReadLine - If CSng(line(0)) < 1 Then - TCnu.Add(CSng(line(0))) - TCmu.Add(CSng(line(1))) - TCtorque.Add(CSng(line(2))) - TCdim += 1 - End If - Loop - Catch ex As Exception - WorkerMsg(tMsgID.Err, "Error while reading Torque Converter file! (" & ex.Message & ")", MsgSrc) - Return False - End Try - - file.Close() - - 'Check if more then one point - If TCdim < 1 Then - WorkerMsg(tMsgID.Err, "More points in Torque Converter file needed!", MsgSrc) - Return False - End If - - TCnuMax = TCnu(TCdim) - - - 'Add default values for nu>1 - If Not file.OpenRead(MyDeclPath & "DefaultTC.vtcc") Then - WorkerMsg(tMsgID.Err, "Default Torque Converter file not found!", MsgSrc) - Return False - End If - - 'Skip Header - file.ReadLine() - - Try - Do While Not file.EndOfFile - line = file.ReadLine - TCnu.Add(CSng(line(0))) - TCmu.Add(CSng(line(1))) - TCtorque.Add(CSng(line(2))) - TCdim += 1 - Loop - Catch ex As Exception - WorkerMsg(tMsgID.Err, "Error while reading Default Torque Converter file! (" & ex.Message & ")", MsgSrc) - Return False - End Try - - file.Close() - - 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 MsgSrc As String - - MsgSrc = "GBX/TCiteration/t= " & t + 1 - - TC_PeBrake = 0 - TCReduce = False - nuStep = 0.001 - Brake = False - TCNeutral = False - - - '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 / DEV.TClimit, 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 - Do While (nuMax - nuMin) / nuStep < 10 And nuStep > 0.0001 - nuStep *= 0.1 - Loop - - FirstDone = False - nu = nuMin - nuStep - iDim = -1 - 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 - - '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(i)) < ErrMin Then - ErrMin = Math.Abs(1 - McalcRatio(i)) - iMin = i - End If - If McalcRatio(i) > McalcRatMax Then McalcRatMax = McalcRatio(i) - Else - FirstDone = True - ErrMin = Math.Abs(1 - McalcRatio(i)) - iMin = i - McalcRatMax = McalcRatio(i) - 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 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 - - 'Set Gearbox Type-specific settings - If gs_Type <> tGearbox.Custom Then - - gs_ShiftInside = Declaration.ShiftInside(gs_Type) - TCon = (gs_Type = tGearbox.Automatic) - gs_SkipGears = Declaration.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 - - Return True - - End Function - - Public Function GearCount() As Integer - Return Me.Igetr.Count - 1 - 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 + 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 - MsgSrc = "VEH/TrLossMapInit/G" & i + 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 - 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 + Dim MinG As Single + Dim plossG As Single - If GetrEffDef(i) Then + Dim MsgSrc As String - If GetrEff(i) > 1 Or GetrEff(i) <= 0 Then - WorkerMsg(tMsgID.Err, "Gearboy efficiency '" & GetrEff(i) & "' invalid!", MsgSrc) - Return False - End If + MyGBmaps = New List(Of cDelaunayMap) + file = New cFile_V3 - MyGBmaps.Add(Nothing) + For i = 0 To GBX.GearCount - Else + MsgSrc = "VEH/TrLossMapInit/G" & i - path = GetrMaps(i).FullPath + 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 Not file.OpenRead(path) Then - WorkerMsg(tMsgID.Err, "Cannot read file '" & path & "'!", MsgSrc) - MyGBmaps = Nothing - Return False - End If + If GetrEffDef(i) Then - 'Skip header - file.ReadLine() + If GetrEff(i) > 1 Or GetrEff(i) <= 0 Then + WorkerMsg(tMsgID.Err, "Gearboy efficiency '" & GetrEff(i) & "' invalid!", MsgSrc) + Return False + End If - GBmap0 = New cDelaunayMap - GBmap0.DualMode = True + MyGBmaps.Add(Nothing) - l = 0 'Nur für Fehler-Ausgabe - Do While Not file.EndOfFile - l += 1 - line = file.ReadLine - Try + Else - nU = CDbl(line(0)) - M_in = CDbl(line(1)) - M_loss = CDbl(line(2)) + path = GetrMaps(i).FullPath - M_out = M_in - M_loss + If Not file.OpenRead(path) Then + WorkerMsg(tMsgID.Err, "Cannot read file '" & path & "'!", MsgSrc) + MyGBmaps = Nothing + Return False + End If - '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 + 'Skip header + file.ReadLine() - file.Close() + GBmap0 = New cDelaunayMap + GBmap0.DualMode = True - If Not GBmap0.Triangulate Then - WorkerMsg(tMsgID.Err, "Map triangulation failed! File: " & path, MsgSrc, path) - MyGBmaps = Nothing - Return False - End If + l = 0 'Nur für Fehler-Ausgabe + Do While Not file.EndOfFile + l += 1 + line = file.ReadLine + Try - MyGBmaps.Add(GBmap0) + nU = CDbl(line(0)) + M_in = CDbl(line(1)) + M_loss = CDbl(line(2)) - 'Calculate average efficiency for fast approx. calculation - If i > 0 Then + M_out = M_in - M_loss - If GBX.IsTCgear(i) Then + '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 - GetrEff(i) = -1 + file.Close() - Else + If Not GBmap0.Triangulate Then + WorkerMsg(tMsgID.Err, "Map triangulation failed! File: " & path, MsgSrc, path) + MyGBmaps = Nothing + Return False + End If - EffSum = 0 - Anz = 0 + MyGBmaps.Add(GBmap0) - dnU = (2 / 3) * (ENG.Nrated - ENG.Nidle) / 10 - nU = ENG.Nidle + dnU + 'Calculate average efficiency for fast approx. calculation + If i > 0 Then - Do While nU <= ENG.Nrated + If GBX.IsTCgear(i) Then - dM = nPeToM(nU, (2 / 3) * FLD(i).Pfull(nU) / 10) - M_in = nPeToM(nU, (1 / 3) * FLD(i).Pfull(nU)) + GetrEff(i) = - 1 - Do While M_in <= nPeToM(nU, FLD(i).Pfull(nU)) + Else - P_In = nMtoPe(nU, M_in) + EffSum = 0 + Anz = 0 - P_Loss = IntpolPeLossFwd(i, nU, P_In, False) + dnU = (2/3)*(ENG.Nrated - ENG.Nidle)/10 + nU = ENG.Nidle + dnU - EffSum += (P_In - P_Loss) / P_In - Anz += 1 + 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)) - plossG = P_Loss - MinG = M_in + Do While M_in <= nPeToM(nU, FLD(i).Pfull(nU)) + P_In = nMtoPe(nU, 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 + P_Loss = IntpolPeLossFwd(i, nU, P_In, False) - 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 + EffSum += (P_In - P_Loss)/P_In + Anz += 1 - M_in += dM - Loop + plossG = P_Loss + MinG = M_in - nU += dnU - Loop - If Anz = 0 Then - WorkerMsg(tMsgID.Err, "Failed to calculate approx. transmission losses!", MsgSrc) - Return False - End If + '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 - GetrEff(i) = EffSum / Anz + 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 - End If + M_in += dM + Loop - End If + nU += dnU + Loop - End If + If Anz = 0 Then + WorkerMsg(tMsgID.Err, "Failed to calculate approx. transmission losses!", MsgSrc) + Return False + End If - Next + GetrEff(i) = EffSum/Anz - If Not GetrEffDef(0) Then - GetrEff(0) = EffDiffSum / AnzDiff - End If + End If + End If - Return True - End Function + End If - Public Function IntpolPeLoss(ByVal Gear As Integer, ByVal nU As Double, ByVal PeOut As Double, ByVal Approx As Boolean) As Double + Next - 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 + If Not GetrEffDef(0) Then + GetrEff(0) = EffDiffSum/AnzDiff + End If - Dim MsgSrc As String - MsgSrc = "VEH/TrLossMapInterpol/G" & Gear + Return True + End Function - If Gear = 0 Then - GrTxt = "A" - Else - GrTxt = Gear.ToString - End If + Public Function IntpolPeLoss(ByVal Gear As Integer, ByVal nU As Double, ByVal PeOut As Double, ByVal Approx As Boolean) _ + As Double - If GetrEffDef(Gear) Or (Approx AndAlso GetrEff(Gear) > 0) Then + 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 - If PeOut > 0 Then - PeIn = PeOut / GetrEff(Gear) - Else - PeIn = PeOut * GetrEff(Gear) - End If - Ploss = PeIn - PeOut + Dim MsgSrc As String - Else + MsgSrc = "VEH/TrLossMapInterpol/G" & Gear - GBmap = MyGBmaps(Gear) + If Gear = 0 Then + GrTxt = "A" + Else + GrTxt = Gear.ToString + End If + If GetrEffDef(Gear) Or (Approx AndAlso GetrEff(Gear) > 0) Then - 'Interpolate with Original Values - PeIn = nMtoPe(nU, GBmap.Intpol(nU, nPeToM(nU, PeOut))) + If PeOut > 0 Then + PeIn = PeOut/GetrEff(Gear) + Else + PeIn = PeOut*GetrEff(Gear) + End If + Ploss = PeIn - PeOut - If GBmap.ExtrapolError Then + Else - 'If error: try extrapolation + GBmap = MyGBmaps(Gear) - '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) + 'Interpolate with Original Values + PeIn = nMtoPe(nU, GBmap.Intpol(nU, nPeToM(nU, PeOut))) - 'Efficiency - If PeOutX > 0 Then - If PeIn > 0 Then + If GBmap.ExtrapolError Then - WG = PeOutX / PeIn - PeIn = PeOut / WG - Ploss = PeIn - PeOut + 'If error: try extrapolation - Else + '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 - '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 + PeOutX = nMtoPe(nU, GBmap.ptList(iMin).Y) + PeIn = nMtoPe(nU, GBmap.ptList(iMin).Z) - End If + 'Efficiency + If PeOutX > 0 Then + If PeIn > 0 Then - ElseIf PeOutX < 0 Then + WG = PeOutX/PeIn + PeIn = PeOut/WG + Ploss = PeIn - PeOut - If PeIn > 0 Then + Else - WG = (PeIn - (PeIn - PeOutX)) / PeIn - PeIn = PeOut / WG - Ploss = PeIn - PeOut + '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 - ElseIf PeIn < 0 Then + End If - WG = PeIn / PeOutX - PeIn = PeOut * WG - Ploss = PeIn - PeOut + ElseIf PeOutX < 0 Then - Else + If PeIn > 0 Then - Ploss = Math.Abs(PeOut) + WG = (PeIn - (PeIn - PeOutX))/PeIn + PeIn = PeOut/WG + Ploss = PeIn - PeOut - End If + ElseIf PeIn < 0 Then + WG = PeIn/PeOutX + PeIn = PeOut*WG + Ploss = PeIn - PeOut - Else + Else - If PeIn > 0 Then + Ploss = Math.Abs(PeOut) - Ploss = PeIn + End If - 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 + Else - Ploss = Math.Abs(PeOut) + If PeIn > 0 Then - End If + Ploss = PeIn - End If + ElseIf PeIn < 0 Then - MODdata.ModErrors.TrLossMapExtr = "Gear= " & GrTxt & ", nU= " & nU.ToString("0.00") & " [1/min], MeOut=" & nPeToM(nU, PeOut).ToString("0.00") & " [Nm]" + '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 - Else + Ploss = Math.Abs(PeOut) - Ploss = PeIn - PeOut + End If + End If - End If + MODdata.ModErrors.TrLossMapExtr = "Gear= " & GrTxt & ", nU= " & nU.ToString("0.00") & " [1/min], MeOut=" & + nPeToM(nU, PeOut).ToString("0.00") & " [Nm]" - End If + Else - Return Math.Max(Ploss, 0) + Ploss = PeIn - PeOut - End Function + End If - Public Function IntpolPeLossFwd(ByVal Gear As Integer, ByVal nU As Double, ByVal PeIn As Double, ByVal Approx As Boolean) As Double + End If - 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 + Return Math.Max(Ploss, 0) + End Function - Dim MsgSrc As String + Public Function IntpolPeLossFwd(ByVal Gear As Integer, ByVal nU As Double, ByVal PeIn As Double, + ByVal Approx As Boolean) As Double - MsgSrc = "VEH/TrLossMapInterpolFwd/G" & Gear + 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 - If Gear = 0 Then - GrTxt = "A" - Else - GrTxt = Gear.ToString - End If + Dim MsgSrc As String - If GetrEffDef(Gear) Or (Approx AndAlso GetrEff(Gear) > 0) Then + MsgSrc = "VEH/TrLossMapInterpolFwd/G" & Gear - If PeIn > 0 Then - PeOut = PeIn * GetrEff(Gear) - Else - PeOut = PeIn / GetrEff(Gear) - End If + If Gear = 0 Then + GrTxt = "A" + Else + GrTxt = Gear.ToString + End If - Else + If GetrEffDef(Gear) Or (Approx AndAlso GetrEff(Gear) > 0) Then - GBmap = MyGBmaps(Gear) + If PeIn > 0 Then + PeOut = PeIn*GetrEff(Gear) + Else + PeOut = PeIn/GetrEff(Gear) + End If + Else - 'Interpolate with original values - PeOut = nMtoPe(nU, GBmap.IntpolXZ(nU, nPeToM(nU, PeIn))) + GBmap = MyGBmaps(Gear) - If GBmap.ExtrapolError Then - 'If error: try extrapolation + 'Interpolate with original values + PeOut = nMtoPe(nU, GBmap.IntpolXZ(nU, nPeToM(nU, PeIn))) - '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 + If GBmap.ExtrapolError Then - PeInX = nMtoPe(nU, GBmap.ptList(iMin).Z) - PeOut = nMtoPe(nU, GBmap.ptList(iMin).Y) + 'If error: try extrapolation - 'Efficiency - If PeOut > 0 Then - If PeInX > 0 Then + '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 - 'Drivetrain => Drivetrain - WG = PeOut / PeInX + PeInX = nMtoPe(nU, GBmap.ptList(iMin).Z) + PeOut = nMtoPe(nU, GBmap.ptList(iMin).Y) - Else + 'Efficiency + If PeOut > 0 Then + If PeInX > 0 Then - '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 + 'Drivetrain => Drivetrain + WG = PeOut/PeInX - End If + Else - Else - If PeInX > 0 Then + '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 - 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 + End If - Else + Else + If PeInX > 0 Then - 'Drag => Drag - WG = PeInX / PeOut + 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 - End If - End If + 'Drag => Drag + WG = PeInX/PeOut - '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 - End If + 'Calculate efficiency with PeIn for original PeOut + PeOut = PeIn*WG - End If + MODdata.ModErrors.TrLossMapExtr = "Gear= " & GrTxt & ", nU= " & nU.ToString("0.00") & " [1/min], MeIn=" & + nPeToM(nU, PeIn).ToString("0.00") & " [Nm] (fwd)" - Return Math.Max(PeIn - PeOut, 0) + End If - End Function + End If + Return Math.Max(PeIn - PeOut, 0) + End Function #End Region - Public ReadOnly Property FileList As List(Of String) - Get - Return MyFileList - End Get - End Property - - 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 GetrMap(ByVal x As Short, Optional ByVal Original As Boolean = False) As String - Get - If Original Then - Return GetrMaps(x).OriginalPath - Else - Return GetrMaps(x).FullPath - End If - End Get - Set(ByVal value As String) - GetrMaps(x).Init(MyPath, value) - End Set - End Property - - Public Property gsFile(ByVal x As Short, Optional ByVal Original As Boolean = False) As String - Get - If Original Then - Return gs_files(x).OriginalPath - Else - Return gs_files(x).FullPath - End If - End Get - Set(value As String) - gs_files(x).Init(MyPath, value) - End Set - End Property - - - - Public Property TCfile(Optional ByVal Original As Boolean = False) As String - Get - If Original Then - Return TC_file.OriginalPath - Else - Return TC_file.FullPath - End If - End Get - Set(value As String) - TC_file.Init(MyPath, value) - End Set - End Property - - - Public Class cShiftPolygon - - Private Filepath As String - Public MyGear As Integer - - Public gs_TqUp As New List(Of Single) - Public gs_TqDown As New List(Of Single) - Public gs_nUup As New List(Of Single) - Public gs_nUdown As New List(Of Single) - Private gs_Dup As Integer = -1 - Private gs_Ddown As Integer = -1 - - Public Sub New(ByVal Path As String, ByVal Gear As Integer) - Filepath = Path - MyGear = Gear - End Sub - - Public Function ReadFile() As Boolean - Dim file As cFile_V3 - Dim line As String() - - Dim MsgSrc As String - - MsgSrc = "GBX/GSinit/ShiftPolygon.Init" - - 'Check if file exists - If Not IO.File.Exists(Filepath) Then - WorkerMsg(tMsgID.Err, "Gear Shift Polygon File not found! '" & Filepath & "'", MsgSrc) - Return False - End If - - 'Init file instance - file = New cFile_V3 - - 'Open file - If Not file.OpenRead(Filepath) Then - WorkerMsg(tMsgID.Err, "Failed to load Gear Shift Polygon File! '" & Filepath & "'", MsgSrc) - Return False - End If - - 'Skip Header - file.ReadLine() - - 'Clear lists - gs_TqUp.Clear() - gs_TqDown.Clear() - gs_nUdown.Clear() - gs_nUup.Clear() - gs_Dup = -1 - - 'Read file - Try - Do While Not file.EndOfFile - line = file.ReadLine - gs_Dup += 1 - gs_TqUp.Add(CSng(line(0))) - gs_TqDown.Add(CSng(line(0))) - gs_nUdown.Add(CSng(line(1))) - gs_nUup.Add(CSng(line(2))) - Loop - Catch ex As Exception - WorkerMsg(tMsgID.Err, "Error while reading Gear Shift Polygon File! (" & ex.Message & ")", MsgSrc) - Return False - End Try - - 'Check if more then one point - If gs_Dup < 1 Then - WorkerMsg(tMsgID.Err, "More points in Gear Shift Polygon File needed!", MsgSrc) - Return False - End If - - gs_Ddown = gs_Dup - - Return True - - End Function - - - Public Sub SetGenericShiftPoly(Optional ByRef fld0 As cFLD = Nothing, Optional ByVal nidle As Single = -1) - Dim Tmax As Single - - 'Clear lists - gs_TqUp.Clear() - gs_TqDown.Clear() - gs_nUdown.Clear() - gs_nUup.Clear() - - If fld0 Is Nothing Then fld0 = FLD(MyGear) - If nidle < 0 Then nidle = ENG.Nidle - - Tmax = fld0.Tmax - - gs_nUdown.Add(nidle) - gs_nUdown.Add(nidle) - gs_nUdown.Add((fld0.Npref + fld0.Nlo) / 2) - - gs_TqDown.Add(0) - gs_TqDown.Add(Tmax * nidle / (fld0.Npref + fld0.Nlo - nidle)) - gs_TqDown.Add(Tmax) - - gs_nUup.Add(fld0.Npref) - gs_nUup.Add(fld0.Npref) - gs_nUup.Add(fld0.N95h) - - gs_TqUp.Add(0) - gs_TqUp.Add(Tmax * (fld0.Npref - nidle) / (fld0.N95h - nidle)) - gs_TqUp.Add(Tmax) - - gs_Ddown = 2 - gs_Dup = 2 - - End Sub - - Public Function fGSnUdown(ByVal Tq As Single) As Single - Dim i As Int32 - - 'Extrapolation for x < x(1) - If gs_TqDown(0) >= Tq Then - i = 1 - GoTo lbInt - End If - - i = 0 - Do While gs_TqDown(i) < Tq And i < gs_Ddown - i += 1 - Loop - - -lbInt: - 'Interpolation - Return (Tq - gs_TqDown(i - 1)) * (gs_nUdown(i) - gs_nUdown(i - 1)) / (gs_TqDown(i) - gs_TqDown(i - 1)) + gs_nUdown(i - 1) - - End Function - - Public Function fGSnUup(ByVal Tq As Single) As Single - Dim i As Int32 - - 'Extrapolation for x < x(1) - If gs_TqUp(0) >= Tq Then - i = 1 - GoTo lbInt - End If - - i = 0 - Do While gs_TqUp(i) < Tq And i < gs_Dup - i += 1 - Loop - - -lbInt: - 'Interpolation - Return (Tq - gs_TqUp(i - 1)) * (gs_nUup(i) - gs_nUup(i - 1)) / (gs_TqUp(i) - gs_TqUp(i - 1)) + gs_nUup(i - 1) - - End Function - - - - End Class - - - + Public ReadOnly Property FileList As List(Of String) + Get + Return MyFileList + End Get + End Property + + 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 GetrMap(ByVal x As Short, Optional ByVal Original As Boolean = False) As String + Get + If Original Then + Return GetrMaps(x).OriginalPath + Else + Return GetrMaps(x).FullPath + End If + End Get + Set(ByVal value As String) + GetrMaps(x).Init(MyPath, value) + End Set + End Property + + Public Property gsFile(ByVal x As Short, Optional ByVal Original As Boolean = False) As String + Get + If Original Then + Return gs_files(x).OriginalPath + Else + Return gs_files(x).FullPath + End If + End Get + Set(value As String) + gs_files(x).Init(MyPath, value) + End Set + End Property + + + Public Property TCfile(Optional ByVal Original As Boolean = False) As String + Get + If Original Then + Return TC_file.OriginalPath + Else + Return TC_file.FullPath + End If + End Get + Set(value As String) + TC_file.Init(MyPath, value) + End Set + End Property + + + Public Class cShiftPolygon + Private Filepath As String + Public MyGear As Integer + + Public gs_TqUp As New List(Of Single) + Public gs_TqDown As New List(Of Single) + Public gs_nUup As New List(Of Single) + Public gs_nUdown As New List(Of Single) + Private gs_Dup As Integer = - 1 + Private gs_Ddown As Integer = - 1 + + Public Sub New(ByVal Path As String, ByVal Gear As Integer) + Filepath = Path + MyGear = Gear + End Sub + + Public Function ReadFile() As Boolean + Dim file As cFile_V3 + Dim line As String() + + Dim MsgSrc As String + + MsgSrc = "GBX/GSinit/ShiftPolygon.Init" + + 'Check if file exists + If Not IO.File.Exists(Filepath) Then + WorkerMsg(tMsgID.Err, "Gear Shift Polygon File not found! '" & Filepath & "'", MsgSrc) + Return False + End If + + 'Init file instance + file = New cFile_V3 + + 'Open file + If Not file.OpenRead(Filepath) Then + WorkerMsg(tMsgID.Err, "Failed to load Gear Shift Polygon File! '" & Filepath & "'", MsgSrc) + Return False + End If + + 'Skip Header + file.ReadLine() + + 'Clear lists + gs_TqUp.Clear() + gs_TqDown.Clear() + gs_nUdown.Clear() + gs_nUup.Clear() + gs_Dup = - 1 + + 'Read file + Try + Do While Not file.EndOfFile + line = file.ReadLine + gs_Dup += 1 + gs_TqUp.Add(CSng(line(0))) + gs_TqDown.Add(CSng(line(0))) + gs_nUdown.Add(CSng(line(1))) + gs_nUup.Add(CSng(line(2))) + Loop + Catch ex As Exception + WorkerMsg(tMsgID.Err, "Error while reading Gear Shift Polygon File! (" & ex.Message & ")", MsgSrc) + Return False + End Try + + 'Check if more then one point + If gs_Dup < 1 Then + WorkerMsg(tMsgID.Err, "More points in Gear Shift Polygon File needed!", MsgSrc) + Return False + End If + + gs_Ddown = gs_Dup + + Return True + End Function + + + Public Sub SetGenericShiftPoly(Optional ByRef fld0 As cFLD = Nothing, Optional ByVal nidle As Single = - 1) + Dim Tmax As Single + + 'Clear lists + gs_TqUp.Clear() + gs_TqDown.Clear() + gs_nUdown.Clear() + gs_nUup.Clear() + + If fld0 Is Nothing Then fld0 = FLD(MyGear) + If nidle < 0 Then nidle = ENG.Nidle + + Tmax = fld0.Tmax + + gs_nUdown.Add(nidle) + gs_nUdown.Add(nidle) + gs_nUdown.Add((fld0.Npref + fld0.Nlo)/2) + + gs_TqDown.Add(0) + gs_TqDown.Add(Tmax*nidle/(fld0.Npref + fld0.Nlo - nidle)) + gs_TqDown.Add(Tmax) + + gs_nUup.Add(fld0.Npref) + gs_nUup.Add(fld0.Npref) + gs_nUup.Add(fld0.N95h) + + gs_TqUp.Add(0) + gs_TqUp.Add(Tmax*(fld0.Npref - nidle)/(fld0.N95h - nidle)) + gs_TqUp.Add(Tmax) + + gs_Ddown = 2 + gs_Dup = 2 + End Sub + + Public Function fGSnUdown(ByVal Tq As Single) As Single + Dim i As Int32 + + 'Extrapolation for x < x(1) + If gs_TqDown(0) >= Tq Then + i = 1 + GoTo lbInt + End If + + i = 0 + Do While gs_TqDown(i) < Tq And i < gs_Ddown + i += 1 + Loop + + + lbInt: + 'Interpolation + Return (Tq - gs_TqDown(i - 1))*(gs_nUdown(i) - gs_nUdown(i - 1))/(gs_TqDown(i) - gs_TqDown(i - 1)) + gs_nUdown(i - 1) + End Function + + Public Function fGSnUup(ByVal Tq As Single) As Single + Dim i As Int32 + + 'Extrapolation for x < x(1) + If gs_TqUp(0) >= Tq Then + i = 1 + GoTo lbInt + End If + + i = 0 + Do While gs_TqUp(i) < Tq And i < gs_Dup + i += 1 + Loop + + + lbInt: + 'Interpolation + Return (Tq - gs_TqUp(i - 1))*(gs_nUup(i) - gs_nUup(i - 1))/(gs_TqUp(i) - gs_TqUp(i - 1)) + gs_nUup(i - 1) + End Function + End Class End Class diff --git a/VECTO/MODcalc/cMOD.vb b/VECTO/MODcalc/cMOD.vb index 4fb1cff2d3f642fb1b2af46db9d4d2d369a05181..0cd97831c6e825bfa4d9d07717ea901ff0f47f31 100644 --- a/VECTO/MODcalc/cMOD.vb +++ b/VECTO/MODcalc/cMOD.vb @@ -11,905 +11,874 @@ 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) + + 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 + + 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 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) - - 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 - - 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 + 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 - Gear = Nothing - VehState = Nothing + If DRI.AuxDef Then + For Each AuxKV In DRI.AuxComponents + AuxKV.Value.Insert(t, AuxKV.Value(t)) + Next + End If + End Sub - TCnu = Nothing - TCmu = Nothing - TCMout = Nothing - TCnOut = Nothing + Public Sub Cut(ByVal t As Integer) + Dim AuxKV As KeyValuePair(Of String, List(Of Single)) - CylceKin = Nothing - ModErrors = Nothing - bInit = False - End If - End Sub + If DRI.Nvorg Then + nUvorg.RemoveAt(t) + End If - Public Sub Duplicate(ByVal t As Integer) - Dim AuxKV As KeyValuePair(Of String, List(Of Single)) + If DRI.AuxDef Then + For Each AuxKV In DRI.AuxComponents + AuxKV.Value.RemoveAt(t) + Next + End If + End Sub - 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 + Public Sub CycleInit() - End Sub + If VEC.EngOnly Then + EngCycleInit() + Else + VehCycleInit() + End If - Public Sub Cut(ByVal t As Integer) - Dim AuxKV As KeyValuePair(Of String, List(Of Single)) + tDimOgl = tDim + End Sub - If DRI.Nvorg Then - nUvorg.RemoveAt(t) - End If + 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 - If DRI.AuxDef Then - For Each AuxKV In DRI.AuxComponents - AuxKV.Value.RemoveAt(t) - Next - End If + 'Define Cycle-length (shorter by 1sec than original because of Interim-seconds) + tDim = DRI.tDim - 1 - End Sub + 'Here the actual cycle is read: + Vh.VehCylceInit() + 'Revolutions-setting + If DRI.Nvorg Then + MODdata.nUvorg = New List(Of Single) - Public Sub CycleInit() + L = DRI.Values(tDriComp.nU) - If VEC.EngOnly Then - EngCycleInit() - Else - VehCycleInit() - End If + 'Revolutions + For s = 0 To tDim + MODdata.nUvorg.Add(((L(s + 1) + L(s)) / 2)) + Next - tDimOgl = tDim + End If - End Sub + 'Specify average Aux and Aux-lists, when Aux present in DRI and VEH + If Cfg.DeclMode Then - 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 + For Each st In VEC.AuxPaths.Keys + MODdata.Paux.Add(st, New List(Of Single)) + Next - 'Define Cycle-length (shorter by 1sec than original because of Interim-seconds) - tDim = DRI.tDim - 1 + Else - 'Here the actual cycle is read: - Vh.VehCylceInit() + If DRI.AuxDef Then + For Each AuxKV In DRI.AuxComponents - 'Revolutions-setting - If DRI.Nvorg Then + For s = 0 To tDim + AuxKV.Value(s) = (AuxKV.Value(s + 1) + AuxKV.Value(s)) / 2 + Next - MODdata.nUvorg = New List(Of Single) + If VEC.AuxPaths.ContainsKey(AuxKV.Key) Then MODdata.Paux.Add(AuxKV.Key, New List(Of Single)) - L = DRI.Values(tDriComp.nU) + Next + End If - 'Revolutions - For s = 0 To tDim - MODdata.nUvorg.Add(((L(s + 1) + L(s)) / 2)) - Next + End If + End Sub - End If + Private Sub EngCycleInit() + Dim s As Integer + Dim L As List(Of Double) - 'Specify average Aux and Aux-lists, when Aux present in DRI and VEH - If Cfg.DeclMode Then + '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 - For Each st In VEC.AuxPaths.Keys - MODdata.Paux.Add(st, New List(Of Single)) - Next + Vh.EngCylceInit() - Else + 'Revolutions-setting + If DRI.Nvorg Then - If DRI.AuxDef Then - For Each AuxKV In DRI.AuxComponents + MODdata.nUvorg = New List(Of Single) - For s = 0 To tDim - AuxKV.Value(s) = (AuxKV.Value(s + 1) + AuxKV.Value(s)) / 2 - Next + L = DRI.Values(tDriComp.nU) - If VEC.AuxPaths.ContainsKey(AuxKV.Key) Then MODdata.Paux.Add(AuxKV.Key, New List(Of Single)) + 'Revolutions + For s = 0 To MODdata.tDim + MODdata.nUvorg.Add(L(s)) + Next - Next - End If + End If + End Sub - End If + 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" - End Sub + FCerror = False + Result = True + LostEnergy = 0 + EngOnTime = 0 + rx = New List(Of Double) + ry = New List(Of Double) - Private Sub EngCycleInit() - Dim s As Integer - Dim L As List(Of Double) + For i = 0 To MODdata.tDim - '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 + Select Case MODdata.EngState(i) - Vh.EngCylceInit() + Case tEngState.Stopped - 'Revolutions-setting - If DRI.Nvorg Then + lFC.Add(0) + LostEnergy += MODdata.PauxSum(i) / 3600 - MODdata.nUvorg = New List(Of Single) + Case Else '<= Idle / Drag / FullLoad-Unterscheidung...? - L = DRI.Values(tDriComp.nU) - 'Revolutions - For s = 0 To MODdata.tDim - MODdata.nUvorg.Add(L(s)) - Next + 'Delaunay + v = MAP.fFCdelaunay_Intp(MODdata.nU(i), nPeToM(MODdata.nU(i), MODdata.Pe(i))) - End If + If v < 0 And v > -999 Then v = 0 - End Sub + 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 - 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 + Next - Dim MsgSrc As String + 'Calc average FC + sum = 0 + For Each x In lFC + sum += x + Next + FCavg = CSng(sum / lFC.Count) + FCavgFinal = FCavg - MsgSrc = "MAP/FC_Intp" + 'Start/Stop-Aux - Correction + If Result AndAlso LostEnergy > 0 Then - FCerror = False - Result = True - LostEnergy = 0 - EngOnTime = 0 - rx = New List(Of Double) - ry = New List(Of Double) + 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) - For i = 0 To MODdata.tDim + If EngOnTime < 1 Then + WorkerMsg(tMsgID.Err, " > ERROR: Engine-On Time = 0!", MsgSrc) + FCerror = True + Exit Sub + End If - Select Case MODdata.EngState(i) + 'Linear regression of FC=f(Pe) + reg = New cRegression - Case tEngState.Stopped + info = reg.Regress(rx.ToArray, ry.ToArray) + rR2 = info.PearsonsR ^ 2 + rA = info.a + rB = info.b + rSE = info.StandardError - lFC.Add(0) - LostEnergy += MODdata.PauxSum(i) / 3600 + If rB <= 0 Then + WorkerMsg(tMsgID.Err, " > ERROR in linear regression ( b=" & rB & ")!", MsgSrc) + FCerror = True + Exit Sub + End If - Case Else '<= Idle / Drag / FullLoad-Unterscheidung...? + '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) - 'Delaunay - v = MAP.fFCdelaunay_Intp(MODdata.nU(i), nPeToM(MODdata.nU(i), MODdata.Pe(i))) + 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 - If v < 0 And v > -999 Then v = 0 + 'average + sum = 0 + For Each x In lFCAUXc + sum += x + Next + FCavgAUXc = CSng(sum / lFC.Count) - If Result Then - If v < -999 Then Result = False - End If - lFC.Add(v) + FCAUXcSet = True - EngOnTime += 1 - rx.Add(MODdata.Pe(i)) - ry.Add(v) + FCavgFinal = FCavgAUXc - End Select - Next + End If - 'Calc average FC - sum = 0 - For Each x In lFC - sum += x - Next - FCavg = CSng(sum / lFC.Count) - FCavgFinal = FCavg + 'WHTC Correction + If Cfg.DeclMode Then - 'Start/Stop-Aux - Correction - If Result AndAlso LostEnergy > 0 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 - 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) + sum = 0 + For Each x In lFCWHTCc + sum += x + Next + FCavgWHTCc = CSng(sum / lFC.Count) - If EngOnTime < 1 Then - WorkerMsg(tMsgID.Err, " > ERROR: Engine-On Time = 0!", MsgSrc) - FCerror = True - Exit Sub - End If + FCavgFinal = FCavgWHTCc - 'Linear regression of FC=f(Pe) - reg = New cRegression + End If - info = reg.Regress(rx.ToArray, ry.ToArray) - rR2 = info.PearsonsR ^ 2 - rA = info.a - rB = info.b - rSE = info.StandardError + If Not Result Then FCerror = True + End Sub - 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) + Public Function Output() As Boolean - WorkerMsg(tMsgID.Normal, " > Additional engine load: " & AddEngLoad.ToString("0.000") & " [kW]", MsgSrc) + 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 - 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 + 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 - 'average - sum = 0 - For Each x In lFCAUXc - sum += x - Next - FCavgAUXc = CSng(sum / lFC.Count) + 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 - FCAUXcSet = True - FCavgFinal = FCavgAUXc + If DEV.AdvFormat Then + f.WriteLine("VECTO " & VECTOvers) + f.WriteLine(Now.ToString) + f.WriteLine("Input File: " & JobFile) + End If + + '*********************************************************************************************** + '*********************************************************************************************** + '*********************************************************************************************** + '*** Header & Units **************************************************************************** - End If + s.Length = 0 - '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 + HeaderList.Add(New String() {"time", "s"}) - sum = 0 - For Each x In lFCWHTCc - sum += x - Next - FCavgWHTCc = CSng(sum / lFC.Count) + 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 - FCavgFinal = FCavgWHTCc + 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() {"Pe_eng", "kW"}) + HeaderList.Add(New String() {"Pe_full", "kW"}) + HeaderList.Add(New String() {"Pe_drag", "kW"}) + HeaderList.Add(New String() {"Pe_clutch", "kW"}) + HeaderList.Add(New String() {"Pa Eng", "kW"}) + HeaderList.Add(New String() {"Paux", "kW"}) - End If + If Not VEC.EngOnly Then - If Not Result Then FCerror = True + 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"}) - End Sub + 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 + End If - Public Function Output() As Boolean + HeaderList.Add(New String() {"FC", "g/h"}) + HeaderList.Add(New String() {"FC-AUXc", "g/h"}) + HeaderList.Add(New String() {"FC-WHTCc", "g/h"}) - 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 + '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 - Dim StrKey As String - Dim AuxList As New List(Of String) + '*********************************************************************************************** + '*********************************************************************************************** + '*********************************************************************************************** + '*** Values ************************************************************************************* - Dim HeaderList As New List(Of String()) + With MODdata - Dim Gear As Integer + For t = 0 To t1 - MsgSrc = "MOD/Output" + 'Predefine Gear for FLD assignment + If VEC.EngOnly Then + Gear = 0 + Else + Gear = .Gear(t) + End If - '*********** Initialization / Open File ************** - If ModOutpName = "" Then - WorkerMsg(tMsgID.Err, "Invalid output path!", MsgSrc) - Return False - End If - f = New cFile_V3 + s.Length = 0 - path = ModOutpName & ".vmod" + 'Time + s.Append(t + DRI.t0 + tdelta) - If Not f.OpenWrite(path, ",", False) Then - WorkerMsg(tMsgID.Err, "Can't write to " & path, MsgSrc) - Return False - End If + If Not VEC.EngOnly Then - s = New System.Text.StringBuilder + If DRI.Vvorg Then - '*********** Settings ************** - Sepp = "," - t1 = MODdata.tDim - If VEC.EngOnly Then - tdelta = 0 - Else - tdelta = 0.5 - End If + 'distance + dist += .Vh.V(t) + s.Append(Sepp & dist) + 'Actual-speed. + s.Append(Sepp & .Vh.V(t) * 3.6) - '********** Aux-List ************ - For Each StrKey In VEC.AuxRefs.Keys 'Wenn Engine Only dann wird das garnicht verwendet - AuxList.Add(StrKey) - Next + 'Target-speed + s.Append(Sepp & .Vh.Vsoll(t) * 3.6) + 'Acc. + s.Append(Sepp & .Vh.a(t)) - If DEV.AdvFormat Then - f.WriteLine("VECTO " & VECTOvers) - f.WriteLine(Now.ToString) - f.WriteLine("Input File: " & JobFile) - End If + Else + 'distance + s.Append(Sepp & "-") - '*********************************************************************************************** - '*********************************************************************************************** - '*********************************************************************************************** - '*** Header & Units **************************************************************************** + 'Actual-speed. + s.Append(Sepp & "-") - s.Length = 0 + 'Target-speed + s.Append(Sepp & "-") + 'Acc. + s.Append(Sepp & "-") - HeaderList.Add(New String() {"time", "s"}) + End If - 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() {"Pe_eng", "kW"}) - HeaderList.Add(New String() {"Pe_full", "kW"}) - HeaderList.Add(New String() {"Pe_drag", "kW"}) - HeaderList.Add(New String() {"Pe_clutch", "kW"}) - HeaderList.Add(New String() {"Pa", "Eng", "kW"}) - HeaderList.Add(New String() {"Paux", "kW"}) + 'Slope + s.Append(Sepp & .Grad(t)) - If Not VEC.EngOnly Then + End If - 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"}) + 'Revolutions + s.Append(Sepp & .nU(t)) - 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 + If Math.Abs(2 * Math.PI * .nU(t) / 60) < 0.00001 Then + s.Append(Sepp & "0" & Sepp & "0" & Sepp & "0" & Sepp & "0") + Else - 'Auxiliaries - For Each StrKey In AuxList - HeaderList.Add(New String() {"Paux_" & StrKey, "kW"}) - Next + 'Torque + s.Append(Sepp & nPeToM(.nU(t), .Pe(t))) - End If + 'Torque at clutch + s.Append(Sepp & nPeToM(.nU(t), .Pclutch(t))) - HeaderList.Add(New String() {"FC", "g/h"}) - HeaderList.Add(New String() {"FC-AUXc", "g/h"}) - HeaderList.Add(New String() {"FC-WHTCc", "g/h"}) + 'Full-load and Drag torque + If .EngState(t) = tEngState.Stopped Then + s.Append(Sepp & "0" & Sepp & "0") + Else + If t = 0 Then + s.Append(Sepp & nPeToM(.nU(t), FLD(Gear).Pfull(.nU(t))) & Sepp & nPeToM(.nU(t), FLD(Gear).Pdrag(.nU(t)))) + Else + s.Append( + Sepp & nPeToM(.nU(t), FLD(Gear).Pfull(.nU(t), .Pe(t - 1))) & Sepp & nPeToM(.nU(t), FLD(Gear).Pdrag(.nU(t)))) + End If + End If + End If - '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 - + '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 t = 0 Then + s.Append(Sepp & FLD(Gear).Pfull(.nU(t)) & Sepp & FLD(Gear).Pdrag(.nU(t))) + Else + s.Append(Sepp & FLD(Gear).Pfull(.nU(t), .Pe(t - 1)) & Sepp & FLD(Gear).Pdrag(.nU(t))) + End If + End If + 'Power at Clutch + s.Append(Sepp & .Pclutch(t)) - '*********************************************************************************************** - '*********************************************************************************************** - '*********************************************************************************************** - '*** Values ************************************************************************************* + 'PaEng + s.Append(Sepp & .PaEng(t)) - With MODdata + 'Aux.. + s.Append(Sepp & .PauxSum(t)) - For t = 0 To t1 - 'Predefine Gear for FLD assignment - If VEC.EngOnly Then - Gear = 0 - Else - Gear = .Gear(t) - End If + If Not VEC.EngOnly Then + 'Gear + s.Append(Sepp & .Gear(t)) - 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 t = 0 Then - s.Append(Sepp & nPeToM(.nU(t), FLD(Gear).Pfull(.nU(t))) & Sepp & nPeToM(.nU(t), FLD(Gear).Pdrag(.nU(t)))) - Else - s.Append(Sepp & nPeToM(.nU(t), FLD(Gear).Pfull(.nU(t), .Pe(t - 1))) & Sepp & nPeToM(.nU(t), FLD(Gear).Pdrag(.nU(t)))) - 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 t = 0 Then - s.Append(Sepp & FLD(Gear).Pfull(.nU(t)) & Sepp & FLD(Gear).Pdrag(.nU(t))) - Else - s.Append(Sepp & FLD(Gear).Pfull(.nU(t), .Pe(t - 1)) & Sepp & FLD(Gear).Pdrag(.nU(t))) - 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 - - 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 + '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 + + 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 index 7991eda4a389efc35df9714e2f220800dcbf254b..035f8ab5cc1db25d4751bba5b6b38eab7634092b 100644 --- a/VECTO/MODcalc/cPower.vb +++ b/VECTO/MODcalc/cPower.vb @@ -1,2444 +1,2471 @@ -' 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 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 - - 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 - - - - '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 = 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 Tq As Single - Dim LastGear As Integer - - Dim MsgSrc As String - - MsgSrc = "Power/Calc" - - '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 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 - - Tq = 0 - 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 - - - 'From Power ----- - If aact < 0 Then - If (Vact < 0.025) Then - 'Vh.SetSpeed(jz, 0) - 'GoTo lbGschw - Vact = 0 - 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 - - If jz > 0 Then Tq = nPeToM(fnU(Vact, LastGear, False), fPeGearMod(LastGear, jz, Vh.fGrad(dist))) - - Gear = fGearTC(jz, Vh.fGrad(dist), Tq) - 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: - - '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 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 - Tq = nPeToM(nU, P) - - '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 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 = GBX.GearCount Then - ' Debug.Print(jz + 1 & ",-") - 'Else - ' Debug.Print(jz + 1 & "," & fnU(Vact, Gear + 1, False)) - '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 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 - - 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, ByVal Tq 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 Pe 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 - - Pe = Tq * (nU * 2 * Math.PI / 60) / 1000 - - 'Up/Downshift rpms - nUup = GBX.Shiftpolygons(LastGear).fGSnUup(Tq) - nUdown = GBX.Shiftpolygons(LastGear).fGSnUdown(Tq) - - 'Upshift - If PlusGearLockUp Then - If nUnext > nUup AndAlso Pe <= 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).N80h - 150)) AndAlso FLD(LastGear + 1).Pfull(nU * iRatio) > 0.7 * FLD(LastGear).Pfull(nU) 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 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 * 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 - 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 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 CSng(MODdata.Vh.Padd(t) + VEC.PauxSum(t, nU)) - 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 - +' 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 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 + + 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 + + + '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 = 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 Tq As Single + Dim LastGear As Integer + + Dim MsgSrc As String + + MsgSrc = "Power/Calc" + + '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 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 + 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 + 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 + + Tq = 0 + 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 + + + 'From Power ----- + If aact < 0 Then + If (Vact < 0.025) Then + 'Vh.SetSpeed(jz, 0) + 'GoTo lbGschw + Vact = 0 + 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 + + If jz > 0 Then Tq = nPeToM(fnU(Vact, LastGear, False), fPeGearMod(LastGear, jz, Vh.fGrad(dist))) + + Gear = fGearTC(jz, Vh.fGrad(dist), Tq) + 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: + + '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 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 + Tq = nPeToM(nU, P) + + '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 + + + If False AndAlso jz = 53 Then + 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 = GBX.GearCount Then + ' Debug.Print(jz + 1 & ",-") + 'Else + ' Debug.Print(jz + 1 & "," & fnU(Vact, Gear + 1, False)) + '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 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 + + 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, ByVal Tq 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 Pe 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 + + Pe = Tq*(nU*2*Math.PI/60)/1000 + + 'Up/Downshift rpms + nUup = GBX.Shiftpolygons(LastGear).fGSnUup(Tq) + nUdown = GBX.Shiftpolygons(LastGear).fGSnUdown(Tq) + + 'Upshift + If PlusGearLockUp Then + If nUnext > nUup AndAlso Pe <= 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).N80h - 150)) AndAlso + FLD(LastGear + 1).Pfull(nU*iRatio) > 0.7*FLD(LastGear).Pfull(nU) 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 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*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 + 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 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 CSng(MODdata.Vh.Padd(t) + VEC.PauxSum(t, nU)) + 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 +