diff --git a/VECTO/GUI/VectoJobForm.Designer.vb b/VECTO/GUI/VectoJobForm.Designer.vb index 4db9c77fceee89485d16b9decf1b37e9092fd95b..50a73e7bac56520f6c5136830c25d4c4f2322155 100644 --- a/VECTO/GUI/VectoJobForm.Designer.vb +++ b/VECTO/GUI/VectoJobForm.Designer.vb @@ -28,6 +28,9 @@ Partial Class VectoJobForm Me.components = New System.ComponentModel.Container() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(VectoJobForm)) Me.TabPgGen = New System.Windows.Forms.TabPage() + Me.TbShiftStrategyParams = New System.Windows.Forms.TextBox() + Me.BtnShiftParamsForm = New System.Windows.Forms.Button() + Me.BtnShiftStrategyParams = New System.Windows.Forms.Button() Me.GrCycles = New System.Windows.Forms.GroupBox() Me.Label2 = New System.Windows.Forms.Label() Me.LvCycles = New System.Windows.Forms.ListView() @@ -129,9 +132,8 @@ Partial Class VectoJobForm Me.TbMass = New System.Windows.Forms.TextBox() Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components) Me.lblEngineCharacteristics = New System.Windows.Forms.Label() - Me.TbShiftStrategyParams = New System.Windows.Forms.TextBox() - Me.BtnShiftParamsForm = New System.Windows.Forms.Button() - Me.BtnShiftStrategyParams = New System.Windows.Forms.Button() + Me.GroupBox3 = New System.Windows.Forms.GroupBox() + Me.cbGearshiftStrategy = New System.Windows.Forms.ComboBox() Me.TabPgGen.SuspendLayout Me.GrCycles.SuspendLayout Me.GrAux.SuspendLayout @@ -150,6 +152,7 @@ Partial Class VectoJobForm Me.CmOpenFile.SuspendLayout CType(Me.PicVehicle,System.ComponentModel.ISupportInitialize).BeginInit CType(Me.PicBox,System.ComponentModel.ISupportInitialize).BeginInit + Me.GroupBox3.SuspendLayout Me.SuspendLayout ' 'TabPgGen @@ -176,6 +179,36 @@ Partial Class VectoJobForm Me.TabPgGen.Text = "General" Me.TabPgGen.UseVisualStyleBackColor = true ' + 'TbShiftStrategyParams + ' + Me.TbShiftStrategyParams.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles) + Me.TbShiftStrategyParams.Location = New System.Drawing.Point(85, 87) + Me.TbShiftStrategyParams.Name = "TbShiftStrategyParams" + Me.TbShiftStrategyParams.Size = New System.Drawing.Size(411, 20) + Me.TbShiftStrategyParams.TabIndex = 12 + ' + 'BtnShiftParamsForm + ' + Me.BtnShiftParamsForm.Location = New System.Drawing.Point(7, 87) + Me.BtnShiftParamsForm.Name = "BtnShiftParamsForm" + Me.BtnShiftParamsForm.Size = New System.Drawing.Size(72, 21) + Me.BtnShiftParamsForm.TabIndex = 11 + Me.BtnShiftParamsForm.TabStop = false + Me.BtnShiftParamsForm.Text = "Shift Parameters" + Me.BtnShiftParamsForm.UseVisualStyleBackColor = true + ' + 'BtnShiftStrategyParams + ' + Me.BtnShiftStrategyParams.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles) + Me.BtnShiftStrategyParams.Image = CType(resources.GetObject("BtnShiftStrategyParams.Image"),System.Drawing.Image) + Me.BtnShiftStrategyParams.Location = New System.Drawing.Point(497, 85) + Me.BtnShiftStrategyParams.Name = "BtnShiftStrategyParams" + Me.BtnShiftStrategyParams.Size = New System.Drawing.Size(24, 24) + Me.BtnShiftStrategyParams.TabIndex = 13 + Me.BtnShiftStrategyParams.TabStop = false + Me.BtnShiftStrategyParams.UseVisualStyleBackColor = true + ' 'GrCycles ' Me.GrCycles.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ @@ -533,13 +566,14 @@ Partial Class VectoJobForm ' 'TabPgDriver ' + Me.TabPgDriver.Controls.Add(Me.GroupBox3) Me.TabPgDriver.Controls.Add(Me.GrVACC) Me.TabPgDriver.Controls.Add(Me.GrLAC) Me.TabPgDriver.Controls.Add(Me.GroupBox1) Me.TabPgDriver.Location = New System.Drawing.Point(4, 22) Me.TabPgDriver.Name = "TabPgDriver" Me.TabPgDriver.Padding = New System.Windows.Forms.Padding(3) - Me.TabPgDriver.Size = New System.Drawing.Size(527, 487) + Me.TabPgDriver.Size = New System.Drawing.Size(527, 512) Me.TabPgDriver.TabIndex = 7 Me.TabPgDriver.Text = "Driver Model" Me.TabPgDriver.UseVisualStyleBackColor = true @@ -1160,35 +1194,23 @@ Partial Class VectoJobForm Me.lblEngineCharacteristics.Size = New System.Drawing.Size(0, 13) Me.lblEngineCharacteristics.TabIndex = 37 ' - 'TbShiftStrategyParams + 'GroupBox3 ' - Me.TbShiftStrategyParams.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ - Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles) - Me.TbShiftStrategyParams.Location = New System.Drawing.Point(85, 87) - Me.TbShiftStrategyParams.Name = "TbShiftStrategyParams" - Me.TbShiftStrategyParams.Size = New System.Drawing.Size(411, 20) - Me.TbShiftStrategyParams.TabIndex = 12 + Me.GroupBox3.Controls.Add(Me.cbGearshiftStrategy) + Me.GroupBox3.Location = New System.Drawing.Point(9, 347) + Me.GroupBox3.Name = "GroupBox3" + Me.GroupBox3.Size = New System.Drawing.Size(514, 50) + Me.GroupBox3.TabIndex = 4 + Me.GroupBox3.TabStop = false + Me.GroupBox3.Text = "Gearshift Strategy" ' - 'BtnShiftParamsForm + 'cbGearshiftStrategy ' - Me.BtnShiftParamsForm.Location = New System.Drawing.Point(7, 87) - Me.BtnShiftParamsForm.Name = "BtnShiftParamsForm" - Me.BtnShiftParamsForm.Size = New System.Drawing.Size(72, 21) - Me.BtnShiftParamsForm.TabIndex = 11 - Me.BtnShiftParamsForm.TabStop = false - Me.BtnShiftParamsForm.Text = "Shift Parameters" - Me.BtnShiftParamsForm.UseVisualStyleBackColor = true - ' - 'BtnShiftStrategyParams - ' - Me.BtnShiftStrategyParams.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right),System.Windows.Forms.AnchorStyles) - Me.BtnShiftStrategyParams.Image = CType(resources.GetObject("BtnShiftStrategyParams.Image"),System.Drawing.Image) - Me.BtnShiftStrategyParams.Location = New System.Drawing.Point(497, 85) - Me.BtnShiftStrategyParams.Name = "BtnShiftStrategyParams" - Me.BtnShiftStrategyParams.Size = New System.Drawing.Size(24, 24) - Me.BtnShiftStrategyParams.TabIndex = 13 - Me.BtnShiftStrategyParams.TabStop = false - Me.BtnShiftStrategyParams.UseVisualStyleBackColor = true + Me.cbGearshiftStrategy.FormattingEnabled = true + Me.cbGearshiftStrategy.Location = New System.Drawing.Point(6, 19) + Me.cbGearshiftStrategy.Name = "cbGearshiftStrategy" + Me.cbGearshiftStrategy.Size = New System.Drawing.Size(270, 21) + Me.cbGearshiftStrategy.TabIndex = 0 ' 'VectoJobForm ' @@ -1248,6 +1270,7 @@ Partial Class VectoJobForm Me.CmOpenFile.ResumeLayout(false) CType(Me.PicVehicle,System.ComponentModel.ISupportInitialize).EndInit CType(Me.PicBox,System.ComponentModel.ISupportInitialize).EndInit + Me.GroupBox3.ResumeLayout(false) Me.ResumeLayout(false) Me.PerformLayout @@ -1357,4 +1380,6 @@ End Sub Friend WithEvents TbShiftStrategyParams As TextBox Friend WithEvents BtnShiftParamsForm As Button Friend WithEvents BtnShiftStrategyParams As Button + Friend WithEvents GroupBox3 As GroupBox + Friend WithEvents cbGearshiftStrategy As ComboBox End Class diff --git a/VECTO/GUI/VectoJobForm.vb b/VECTO/GUI/VectoJobForm.vb index 1998fae9e982f8eb59fe6b01925857b5635dfb96..b76a1597af3ca77386aa0d97c2432ecfdbd6d120 100644 --- a/VECTO/GUI/VectoJobForm.vb +++ b/VECTO/GUI/VectoJobForm.vb @@ -24,6 +24,7 @@ Imports TUGraz.VectoCommon.Utils Imports TUGraz.VectoCore.InputData.FileIO.JSON Imports TUGraz.VectoCore.InputData.Reader Imports TUGraz.VectoCore.Models.Declaration +Imports TUGraz.VectoCore.Models.Simulation.Impl Imports TUGraz.VectoCore.Models.SimulationComponent.Data Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Engine Imports TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox @@ -94,6 +95,9 @@ Public Class VectoJobForm 'AA-TB PopulateAdvancedAuxiliaries() + cbGearshiftStrategy.DataSource = PowertrainBuilder.GetRegisteredShiftStrategies(Nothing).Select(Function(entry) New With {.Value = entry.Item1, .Label = entry.Item2}).ToList() + cbGearshiftStrategy.DisplayMember = "Label" + cbGearshiftStrategy.ValueMember = "Value" 'Attempt to select that found in Config End Sub @@ -443,7 +447,11 @@ Public Class VectoJobForm TbVEH.Text = GetRelativePath(inputData.JobInputData.Vehicle.Source, _basePath) TbENG.Text = GetRelativePath(inputData.JobInputData.Vehicle.EngineInputData.Source, _basePath) TbGBX.Text = GetRelativePath(inputData.JobInputData.Vehicle.GearboxInputData.Source, _basePath) - TbShiftStrategyParams.Text = GetRelativePath(inputData.GearshiftInputData.Source, _basePath) + if (inputData.GearshiftInputData Is Nothing) Then + TbShiftStrategyParams.Text = "" + else + TbShiftStrategyParams.Text = GetRelativePath(inputData.GearshiftInputData.Source, _basePath) + End If 'Start/Stop Dim driver As IDriverEngineeringInputData = inputData.DriverInputData @@ -545,6 +553,12 @@ Public Class VectoJobForm End If '------------------------------------------------------------- + cbGearshiftStrategy.DataSource = PowertrainBuilder.GetRegisteredShiftStrategies(inputData.JobInputData.Vehicle.GearboxInputData.Type).Select(Function(entry) New With {.Value = entry.Item1, .Label = entry.Item2}).ToList() + cbGearshiftStrategy.DisplayMember = "Label" + cbGearshiftStrategy.ValueMember = "Value" + cbGearshiftStrategy.SelectedValue = inputData.JobInputData.ShiftStrategy + + DeclInit() @@ -617,6 +631,7 @@ Public Class VectoJobForm vectoJob.PathGbx = TbGBX.Text vectoJob.PathShiftParams = TbShiftStrategyParams.Text + vectoJob.ShiftStrategy = cbGearshiftStrategy.SelectedValue.ToString() 'a_DesMax vectoJob.DesMaxFile = TbDesMaxFile.Text diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index 597f830cfe644a1d9d03dcb0ae4daa0295aef926..5ec6881029d041fd6b7681d8bf7d3a6603fde3af 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -38,6 +38,7 @@ using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.SimulationComponent; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Impl; @@ -55,6 +56,17 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl private readonly IModalDataContainer _modData; private readonly WriteSumData _sumWriter; + private static List<Tuple<List<GearboxType>, string, string, Func<VectoRunData, IVehicleContainer, BaseShiftStrategy>>> ShiftStrategies = new List<Tuple<List<GearboxType>, string, string, Func<VectoRunData, IVehicleContainer, BaseShiftStrategy>>> + { + Tuple.Create<List<GearboxType>, string, string, Func<VectoRunData, IVehicleContainer, BaseShiftStrategy>>(new List<GearboxType> {GearboxType.MT}, typeof(MTShiftStrategy).FullName, MTShiftStrategy.Name, (r, c) => new MTShiftStrategy(r, c)), + Tuple.Create<List<GearboxType>, string, string, Func<VectoRunData, IVehicleContainer, BaseShiftStrategy>>( new List<GearboxType> {GearboxType.AMT}, typeof(AMTShiftStrategy).FullName,AMTShiftStrategy.Name, (r, c) => new AMTShiftStrategy(r, c)), + Tuple.Create<List<GearboxType>, string, string, Func<VectoRunData, IVehicleContainer, BaseShiftStrategy>>( new List<GearboxType> {GearboxType.AMT}, typeof(AMTShiftStrategyOptimized).FullName, AMTShiftStrategyOptimized.Name, (r, c) => new AMTShiftStrategyOptimized(r, c)), + Tuple.Create<List<GearboxType>, string, string, Func<VectoRunData, IVehicleContainer, BaseShiftStrategy>>( new List<GearboxType> {GearboxType.AMT}, typeof(AMTShiftStrategyV2).FullName, AMTShiftStrategyV2.Name, (r, c) => new AMTShiftStrategyV2(r, c)), + Tuple.Create<List<GearboxType>, string, string, Func<VectoRunData, IVehicleContainer, BaseShiftStrategy>>( new List<GearboxType> {GearboxType.ATPowerSplit, GearboxType.ATSerial}, typeof(ATShiftStrategy).FullName, ATShiftStrategy.Name, (r, c) => new ATShiftStrategy(r, c)), + }; + + + public PowertrainBuilder(IModalDataContainer modData, WriteSumData sumWriter = null) { if (modData == null) { @@ -383,28 +395,40 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl private static IGearbox GetGearbox(IVehicleContainer container, VectoRunData runData) { IShiftStrategy strategy; + strategy = GetShiftStrategy(runData, container); switch (runData.GearboxData.Type) { case GearboxType.AMT: -#if CLASSIC_TCU - strategy = new AMTShiftStrategy(runData, container); - -#else - strategy = runData.GearshiftParameters == null - ? (IShiftStrategy)new AMTShiftStrategy(runData, container) - : new AMTShiftStrategyV2(runData, container); -#endif - break; case GearboxType.MT: - strategy = new MTShiftStrategy(runData, container); - break; + return new Gearbox(container, strategy, runData); case GearboxType.ATPowerSplit: case GearboxType.ATSerial: - strategy = new ATShiftStrategy(runData.GearboxData, container); return new ATGearbox(container, strategy, runData); default: throw new ArgumentOutOfRangeException("Unknown Gearbox Type", runData.GearboxData.Type.ToString()); } - return new Gearbox(container, strategy, runData); + } + + private static IShiftStrategy GetShiftStrategy(VectoRunData runData, IVehicleContainer container) + { + if (string.IsNullOrWhiteSpace(runData.ShiftStrategy)) { + switch (runData.GearboxData.Type) { + case GearboxType.AMT: + return new AMTShiftStrategy(runData, container); + case GearboxType.MT: + return new MTShiftStrategy(runData, container); + case GearboxType.ATPowerSplit: + case GearboxType.ATSerial: + return new ATShiftStrategy(runData, container); + default: + throw new ArgumentOutOfRangeException("GearboxType", "Unknown Gearbox Type {0}", runData.GearboxData.Type.ToString()); + } + } + + var selected = ShiftStrategies.FirstOrDefault(x => x.Item1.Contains(runData.GearboxData.Type) && x.Item2.Equals(runData.ShiftStrategy, StringComparison.InvariantCultureIgnoreCase)); + if (selected == null) { + throw new ArgumentOutOfRangeException("ShiftStrategy", "Unknown Shiftstrategy {0} for Gearbox Type {1}", runData.GearboxData.Type.ToString()); + } + return selected.Item4(runData, container); } private static IGearbox GetSimpleGearbox(IVehicleContainer container, VectoRunData runData) @@ -414,5 +438,13 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } return new Gearbox(container, null, runData); } + + public static IEnumerable<Tuple<string, string>> GetRegisteredShiftStrategies(GearboxType? type) + { + if (!type.HasValue) { + return new List<Tuple<string, string>>(); + } + return ShiftStrategies.Where(x => x.Item1.Contains(type.Value)).Select(x => Tuple.Create(x.Item2, x.Item3)).ToList(); + } } } \ No newline at end of file