diff --git a/VECTO/GUI/F_MAINForm.vb b/VECTO/GUI/F_MAINForm.vb index c4b38410cf9ce8f282b7a72eb22a78bd212456a3..5f686447e2cf9ce3829024f876c3506983a23e79 100644 --- a/VECTO/GUI/F_MAINForm.vb +++ b/VECTO/GUI/F_MAINForm.vb @@ -1564,15 +1564,15 @@ lbFound: Dim sumWriter As SummaryDataContainer = New SummaryDataContainer(fileWriter) Dim jobContainer As JobContainer = New JobContainer(sumWriter) - Dim mode As SimulatorFactory.FactoryMode + Dim mode As ExecutionMode If Cfg.DeclMode Then - mode = SimulatorFactory.FactoryMode.DeclarationMode + mode = ExecutionMode.Declaration Else - mode = SimulatorFactory.FactoryMode.EngineeringMode + mode = ExecutionMode.Engineering End If - Dim doneProcesses As List(Of UInteger) = New List(Of UInteger) + Dim doneProcesses As List(Of UInteger) = New List(Of UInteger) For Each jobFile As String In JobFileList Try @@ -1590,7 +1590,7 @@ lbFound: sender.ReportProgress(0, New _ With {.Target = "ListBox", - .Message = _ + .Message = String.Format("Starting Simulation ({0} Jobs, {1} Runs)", JobFileList.Count, jobContainer.GetProgress().Count)}) @@ -1604,13 +1604,13 @@ lbFound: Return End If - Dim progress As Dictionary(Of UInteger, JobContainer.ProgressEntry) = jobContainer.GetProgress() + Dim progress As Dictionary(Of UInteger, JobContainer.ProgressEntry) = jobContainer.GetProgress() Dim sumProgress As Double = progress.Sum(Function(pair) pair.Value.Progress) Dim duration As Double = (DateTime.Now() - start).TotalSeconds sender.ReportProgress(Int((sumProgress * 100.0) / progress.Count), - New With {.Target = "Status", .Message = _ + New With {.Target = "Status", .Message = String.Format("Duration: {0:0}s, Current Progress: {1:P} ({2})", duration, sumProgress / progress.Count, String.Join(", ", @@ -1619,31 +1619,31 @@ lbFound: String.Format("{0,4:P}", pair.Value.Progress))))}) - For Each p As KeyValuePair(Of UInteger, JobContainer.ProgressEntry) In progress - If p.Value.Done And Not doneProcesses.Contains(p.Key) Then - Dim modFilename As String = fileWriter.GetModDataFileName(p.Value.RunName, p.Value.CycleName, - p.Value.RunSuffix) - Dim runName As String = String.Format("{0} {1} {2}", p.Value.RunName, p.Value.CycleName, p.Value.RunSuffix) - sender.ReportProgress(0, - New _ - With {.Target = "ListBox", - .Message = String.Format("Finished Run {0}", runName)}) - If Not p.Value.Error Is Nothing Then - sender.ReportProgress(0, New With {.Target = "ListBox", - .Message = _ - String.Format("ERROR {0}: {1}", runName, p.Value.Error.Message), _ - .Link = p.Value.ModFileName}) - End If - 'If Not Cfg.DeclMode Then - sender.ReportProgress(0, New With {.Target = "ListBox", - .Message = _ - String.Format("Run {0}: Modal Results written to {1}", runName, modFilename), _ - .Link = modFilename}) - 'End If - - doneProcesses.Add(p.Key) - End If - Next + For Each p As KeyValuePair(Of UInteger, JobContainer.ProgressEntry) In progress + If p.Value.Done And Not doneProcesses.Contains(p.Key) Then + Dim modFilename As String = fileWriter.GetModDataFileName(p.Value.RunName, p.Value.CycleName, + p.Value.RunSuffix) + Dim runName As String = String.Format("{0} {1} {2}", p.Value.RunName, p.Value.CycleName, p.Value.RunSuffix) + sender.ReportProgress(0, + New _ + With {.Target = "ListBox", + .Message = String.Format("Finished Run {0}", runName)}) + If Not p.Value.Error Is Nothing Then + sender.ReportProgress(0, New With {.Target = "ListBox", + .Message = + String.Format("ERROR {0}: {1}", runName, p.Value.Error.Message), + .Link = modFilename}) + End If + 'If Not Cfg.DeclMode Then + sender.ReportProgress(0, New With {.Target = "ListBox", + .Message = + String.Format("Run {0}: Modal Results written to {1}", runName, modFilename), + .Link = modFilename}) + 'End If + + doneProcesses.Add(p.Key) + End If + Next Thread.Sleep(500) End While @@ -1670,38 +1670,32 @@ lbFound: Next End If - For Each progressEntry As KeyValuePair(Of UInteger, JobContainer.ProgressEntry) In jobContainer.GetProgress() - Dim runName As String = String.Format("{0} {1} {2}", progressEntry.Value.RunName, progressEntry.Value.CycleName, progressEntry.Value.RunSuffix) - sender.ReportProgress(100, - New _ - With {.Target = "ListBox", - .Message = String.Format("{0,-60} {1,8:P} {2,10:F2}s - {3}", - runName, progressEntry.Value.Progress, - progressEntry.Value.ExecTime / 1000.0, - IIf(progressEntry.Value.Success, "Success", "Aborted"))}) - If (Not progressEntry.Value.Success) Then - sender.ReportProgress(100, New With {.Target = "ListBox", .Message = progressEntry.Value.Error.Message}) - End If + For Each progressEntry As KeyValuePair(Of UInteger, JobContainer.ProgressEntry) In jobContainer.GetProgress() + Dim runName As String = String.Format("{0} {1} {2}", progressEntry.Value.RunName, progressEntry.Value.CycleName, progressEntry.Value.RunSuffix) + sender.ReportProgress(100, + New _ + With {.Target = "ListBox", + .Message = String.Format("{0,-60} {1,8:P} {2,10:F2}s - {3}", + runName, progressEntry.Value.Progress, + progressEntry.Value.ExecTime / 1000.0, + IIf(progressEntry.Value.Success, "Success", "Aborted"))}) + If (Not progressEntry.Value.Success) Then + sender.ReportProgress(100, New With {.Target = "ListBox", .Message = progressEntry.Value.Error.Message}) + End If - Next + Next sender.ReportProgress(100, New With {.Target = "ListBox", .Message = "Simulation Finished"}) End Sub Private Sub VectoWorkerV3_OnProgressChanged(sender As Object, e As ProgressChangedEventArgs) ToolStripProgBarOverall.Value = e.ProgressPercentage - - Dim messageType As tMsgID = tMsgID.Normal - If Not e.UserState.GetType().GetProperty("MessageType") Is Nothing Then - messageType = e.UserState.MessageType - End If - Select Case e.UserState.Target Case "ListBox" If e.UserState.GetType().GetProperty("Link") Is Nothing Then - MSGtoForm(messageType, e.UserState.Message, "", "") + MSGtoForm(tMsgID.Normal, e.UserState.Message, "", "") Else - MSGtoForm(messageType, e.UserState.Message, "", e.UserState.Link) + MSGtoForm(tMsgID.Normal, e.UserState.Message, "", e.UserState.Link) End If Case "Status" Status(e.UserState.Message) diff --git a/VectoConsole/Program.cs b/VectoConsole/Program.cs index fbec0173e625c6bd2053055611a6d7ce1efbd77e..1ec0eaadb69c8ed5cbf8dbfe0383a8eec33b8dda 100644 --- a/VectoConsole/Program.cs +++ b/VectoConsole/Program.cs @@ -133,9 +133,9 @@ Examples: var sumWriter = new SummaryDataContainer(fileWriter); jobContainer = new JobContainer(sumWriter); - var mode = SimulatorFactory.FactoryMode.DeclarationMode; + var mode = ExecutionMode.Declaration; if (args.Contains("-eng")) { - mode = SimulatorFactory.FactoryMode.EngineeringMode; + mode = ExecutionMode.Engineering; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine( "Switching to Engineering Mode. Make sure the job-file is saved in engineering mode!"); diff --git a/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs b/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs index 5b91b08e3ed07074d47e745baf84b2a312a04bd7..f135f6193d3990a24f0ecc9f590c09da9758fcdc 100644 --- a/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs +++ b/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs @@ -25,6 +25,10 @@ using TUGraz.VectoCore.InputData; using TUGraz.VectoCore.InputData.Reader.Impl; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.OutputData; +using TUGraz.VectoCore.OutputData.PDF; +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Simulation.Impl { @@ -41,7 +45,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl private readonly ExecutionMode _mode; - public SimulatorFactory(FactoryMode mode, IInputDataProvider dataProvider, IOutputDataWriter writer) + public SimulatorFactory(ExecutionMode mode, IInputDataProvider dataProvider, IOutputDataWriter writer) { Log.Fatal("########## VectoCore Version {0} ##########", Assembly.GetExecutingAssembly().GetName().Version); JobNumber = Interlocked.Increment(ref _jobNumberCounter); @@ -66,11 +70,11 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl //DataReader.SetJobFile(jobFile); } - public ISimulationDataReader DataReader { get; private set; } + public IVectoRunDataFactory DataReader { get; } public SummaryDataContainer SumData { get; set; } - public IOutputDataWriter ModWriter { get; private set; } + public IOutputDataWriter ModWriter { get; } public int JobNumber { get; set; } @@ -85,7 +89,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl { var i = 0; foreach (var data in DataReader.NextRun()) { - CheckLossMapRangeForFullLoadCurves(data.GearboxData, data.EngineData); + CheckLossMapRangeForFullLoadCurves(data.GearboxData, data.EngineData, data.AxleGearData); //var modFileName = Path.Combine(data.BasePath, // data.JobName.Replace(Constants.FileExtensions.VectoJobFile, "") + "_{0}{1}" + @@ -119,7 +123,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } } - internal static void CheckLossMapRangeForFullLoadCurves(GearboxData gearboxData, CombustionEngineData engineData) + internal static void CheckLossMapRangeForFullLoadCurves(GearboxData gearboxData, CombustionEngineData engineData, + AxleGearData axleGearData) { foreach (var gear in gearboxData.Gears) { for (var angularVelocity = engineData.IdleSpeed; @@ -139,7 +144,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl var axleAngularVelocity = angularVelocity / gear.Value.Ratio; try { - gearboxData.AxleGearData.LossMap.GetOutTorque(axleAngularVelocity, axleTorque); + axleGearData.LossMap.GetOutTorque(axleAngularVelocity, axleTorque); } catch (VectoException ex) { throw new VectoException( string.Format("Interpolation of LossMap failed for AxleGear with torque={0} and angularSpeed={1}", diff --git a/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index 8b804a4c93a38d40b431788f0a78e9d633e9e70f..01e101d880381bd130907fa65c4ec4ea5f0be1a9 100644 --- a/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -146,10 +146,12 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl #endregion - public VehicleContainer(IModalDataContainer modData = null, WriteSumData writeSumData = null) + public VehicleContainer(IModalDataContainer modData = null, WriteSumData writeSumData = null, + ExecutionMode executionMode = ExecutionMode.Declaration) { ModData = modData; - WriteSumData = writeSumData ?? delegate { }; + WriteSumData = writeSumData ?? delegate {}; + ExecutionMode = executionMode; } #region IVehicleContainer @@ -299,5 +301,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } public VectoRunData RunData { get; set; } + public ExecutionMode ExecutionMode { get; set; } } } \ No newline at end of file diff --git a/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/OutputData/ModalDataContainer.cs index d7cb9da8ae4c5b5891d0ab451452a0e5f1170746..3af87e853889900ea1e1da1eaa36e9d4bd24a05b 100644 --- a/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/OutputData/ModalDataContainer.cs @@ -28,7 +28,7 @@ namespace TUGraz.VectoCore.OutputData { public class ModalDataContainer : IModalDataContainer { - private readonly SimulatorFactory.FactoryMode _mode; + private readonly ExecutionMode _mode; private readonly Action<ModalDataContainer> _addReportResult; private ModalResults Data { get; set; } private DataRow CurrentRow { get; set; } @@ -44,15 +44,15 @@ namespace TUGraz.VectoCore.OutputData public VectoRun.Status RunStatus { get; protected set; } public ModalDataContainer(string runName, IModalDataWriter writer, - SimulatorFactory.FactoryMode mode = SimulatorFactory.FactoryMode.EngineeringMode) + ExecutionMode mode = ExecutionMode.Engineering) : this(runName, "", "", writer, _ => {}, mode) {} public ModalDataContainer(VectoRunData runData, IModalDataWriter writer, Action<ModalDataContainer> addReportResult, - SimulatorFactory.FactoryMode mode = SimulatorFactory.FactoryMode.EngineeringMode) + ExecutionMode mode = ExecutionMode.Engineering) : this(runData.JobName, runData.Cycle.Name, runData.ModFileSuffix, writer, addReportResult, mode) {} protected ModalDataContainer(string runName, string cycleName, string runSuffix, IModalDataWriter writer, - Action<ModalDataContainer> addReportResult, SimulatorFactory.FactoryMode mode) + Action<ModalDataContainer> addReportResult, ExecutionMode mode) { HasTorqueConverter = false; @@ -83,7 +83,7 @@ namespace TUGraz.VectoCore.OutputData RunStatus = runStatus; - if (_mode != SimulatorFactory.FactoryMode.EngineOnlyMode) { + if (_mode != ExecutionMode.EngineOnly) { dataColumns.AddRange(new[] { ModalResultField.simulationInterval, ModalResultField.dist, @@ -108,7 +108,7 @@ namespace TUGraz.VectoCore.OutputData ModalResultField.Paux }); - if (_mode != SimulatorFactory.FactoryMode.EngineOnlyMode) { + if (_mode != ExecutionMode.EngineOnly) { dataColumns.AddRange(new[] { ModalResultField.Gear, ModalResultField.PlossGB, @@ -137,13 +137,13 @@ namespace TUGraz.VectoCore.OutputData .Concat((Auxiliaries.Values.Select(c => c.ColumnName))) .Concat(new[] { ModalResultField.FCMap, ModalResultField.FCAUXc, ModalResultField.FCWHTCc }.Select(x => x.GetName())); - if (_mode != SimulatorFactory.FactoryMode.DeclarationMode || WriteModalResults) { + if (_mode != ExecutionMode.Declaration || WriteModalResults) { //VectoCSVFile.Write(_modWriter, new DataView(Data).ToTable(false, strCols.ToArray())); _writer.WriteModData(RunName, CycleName, RunSuffix, new DataView(Data).ToTable(false, strCols.ToArray())); } - if (_mode == SimulatorFactory.FactoryMode.DeclarationMode) { + if (_mode == ExecutionMode.Declaration) { _addReportResult(this); } } diff --git a/VectoCore/VectoCore.csproj b/VectoCore/VectoCore.csproj index c69f72a919f083ee93c10612f836538c38d5e9ee..4d9033dbdbd8e5906a714fc566b672063de7d0c1 100644 --- a/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore.csproj @@ -251,9 +251,7 @@ <Compile Include="Models\SimulationComponent\IWheels.cs" /> <Compile Include="Models\SimulationComponent\VectoSimulationComponent.cs" /> <Compile Include="Models\SimulationComponent\Impl\EngineOnlyDrivingCycle.cs" /> - <Compile Include="Models\Simulation\Data\ModalResult.cs"> - <SubType>Component</SubType> - </Compile> + <Compile Include="Models\Simulation\Data\ModalResult.cs" /> <Compile Include="Models\Simulation\IVectoRun.cs" /> <Compile Include="Models\Simulation\Impl\SimulatorFactory.cs" /> <Compile Include="Models\Simulation\Impl\VectoRun.cs" /> diff --git a/VectoCoreTest/Integration/DeclarationReportTest.cs b/VectoCoreTest/Integration/DeclarationReportTest.cs index 7858b3839a2364435f594dc16379713100e117d6..bdc07bd4d577994c4d97dba1b60ed34688a86dd0 100644 --- a/VectoCoreTest/Integration/DeclarationReportTest.cs +++ b/VectoCoreTest/Integration/DeclarationReportTest.cs @@ -45,7 +45,7 @@ namespace TUGraz.VectoCore.Tests.Integration var sumData = new SummaryDataContainer(fileWriter); var jobContainer = new JobContainer(sumData); var inputData = JSONInputDataFactory.ReadJsonJob(jobFile); - var factory = new SimulatorFactory(SimulatorFactory.FactoryMode.DeclarationMode, inputData, fileWriter); + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, fileWriter); jobContainer.AddRuns(factory); jobContainer.Execute(); diff --git a/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs b/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs index 3d099829cb0e7ebee18faaa804d6d380fddff9d0..c0526c80c9ea17cbdb20cf5182a9d873d03ea010 100644 --- a/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs +++ b/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs @@ -64,7 +64,7 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle var modFile = Path.GetFileNameWithoutExtension(Path.GetRandomFileName()); // + ".vmod"; var fileWriter = new FileOutputWriter(modFile, ""); - var modData = new ModalDataContainer(modFile, fileWriter, SimulatorFactory.FactoryMode.EngineOnlyMode); + var modData = new ModalDataContainer(modFile, fileWriter, ExecutionMode.EngineOnly); foreach (var cycleEntry in data.Entries) { var response = port.Request(absTime, dt, cycleEntry.EngineTorque, cycleEntry.EngineSpeed); diff --git a/VectoCoreTest/Integration/FullCycleDeclarationTest.cs b/VectoCoreTest/Integration/FullCycleDeclarationTest.cs index 97630ffb0b7cf263365dde72641f3bd8b5dffac2..9b69bea77f4e1915fbfe492ab8bf3e56ee21e1b4 100644 --- a/VectoCoreTest/Integration/FullCycleDeclarationTest.cs +++ b/VectoCoreTest/Integration/FullCycleDeclarationTest.cs @@ -18,12 +18,8 @@ using System.IO; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using NLog; -using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.FileIO.JSON; -using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; -using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.Models.SimulationComponent.Impl; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.OutputData.FileIO; using TUGraz.VectoCore.Utils; @@ -34,7 +30,7 @@ namespace TUGraz.VectoCore.Tests.Integration public class FullCycleDeclarationTest { public const string TruckDeclarationJob = - @"TestData\Integration\Declaration\40t Truck\40t_Long_Haul_Truck.vecto"; + @"TestData\Integration\Declaration\40t Truck\40t_Long_Haul_Truck.vecto"; [TestMethod] @@ -145,7 +141,7 @@ namespace TUGraz.VectoCore.Tests.Integration var inputData = JSONInputDataFactory.ReadJsonJob(TruckDeclarationJob); var fileWriter = new FileOutputWriter(Path.GetFileNameWithoutExtension(TruckDeclarationJob), Path.GetDirectoryName(TruckDeclarationJob)); - var factory = new SimulatorFactory(SimulatorFactory.FactoryMode.DeclarationMode, TruckDeclarationJob); + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, fileWriter) { WriteModalResults = true }; var sumData = new SummaryDataContainer(fileWriter); @@ -166,7 +162,7 @@ namespace TUGraz.VectoCore.Tests.Integration const string jobFile = @"c:\Users\Technik\Downloads\40t Long Haul Truck\40t_Long_Haul_Truck.vecto"; var inputData = JSONInputDataFactory.ReadJsonJob(jobFile); var fileWriter = new FileOutputWriter(jobFile); - var factory = new SimulatorFactory(ExecutionMode.Declaration, + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, fileWriter) { WriteModalResults = true, SumData = new SummaryDataContainer(fileWriter) @@ -187,7 +183,7 @@ namespace TUGraz.VectoCore.Tests.Integration var fileWriter = new FileOutputWriter(jobFile); // TODO: fails due to interpolaion failure in Gear 4 - var factory = new SimulatorFactory(SimulatorFactory.FactoryMode.DeclarationMode, + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, fileWriter) { WriteModalResults = true, SumData = new SummaryDataContainer(fileWriter) }; @@ -200,22 +196,21 @@ namespace TUGraz.VectoCore.Tests.Integration } [TestMethod, Ignore] - public void Truck12t_UrbanDeliveryCycle_RefLoad_Declaration() + public + void Truck12t_UrbanDeliveryCycle_RefLoad_Declaration() { var jobFile = @"c:\Users\Technik\Downloads\12t Delivery Truck\12t Delivery Truck.vecto"; var inputData = JSONInputDataFactory.ReadJsonJob(jobFile); var fileWriter = new FileOutputWriter(jobFile); // TODO: fails due to interpolaion failure in Gear 4 - var factory = new SimulatorFactory(SimulatorFactory.FactoryMode.DeclarationMode, + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, fileWriter) { WriteModalResults = true, SumData = new SummaryDataContainer(fileWriter) }; var runs = factory.SimulationRuns().ToArray(); - var run = runs[7]; run.Run(); - Assert.IsTrue(run.FinishedWithoutErrors); } } diff --git a/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs b/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs index 6c8c8edece282c7c7c18713730fd6e5ea95bc1fc..3bda7a5d81be62e600f953ee47fd4460d94c1911 100644 --- a/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs +++ b/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs @@ -90,7 +90,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns response = cyclePort.Request(absTime, ds); response.Switch(). Case<ResponseDrivingCycleDistanceExceeded>(r => ds = r.MaxDistance). - Case<ResponseCycleFinished>(r => { }). + Case<ResponseCycleFinished>(r => {}). Case<ResponseSuccess>(r => { container.CommitSimulationStep(absTime, r.SimulationInterval); absTime += r.SimulationInterval; @@ -163,8 +163,10 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns response.Switch(). Case<ResponseDrivingCycleDistanceExceeded>(r => ds = r.MaxDistance). - Case<ResponseCycleFinished>(r => { }). - Case<ResponseGearShift>(r => { Log.Debug("Gearshift"); }). + Case<ResponseCycleFinished>(r => {}). + Case<ResponseGearShift>(r => { + Log.Debug("Gearshift"); + }). Case<ResponseSuccess>(r => { container.CommitSimulationStep(absTime, r.SimulationInterval); absTime += r.SimulationInterval; @@ -236,8 +238,10 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns response.Switch(). Case<ResponseDrivingCycleDistanceExceeded>(r => ds = r.MaxDistance). - Case<ResponseCycleFinished>(r => { }). - Case<ResponseGearShift>(r => { Log.Debug("Gearshift"); }). + Case<ResponseCycleFinished>(r => {}). + Case<ResponseGearShift>(r => { + Log.Debug("Gearshift"); + }). Case<ResponseSuccess>(r => { container.CommitSimulationStep(absTime, r.SimulationInterval); absTime += r.SimulationInterval; @@ -268,7 +272,7 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns var jobContainer = new JobContainer(sumData); var inputData = JSONInputDataFactory.ReadJsonJob(jobFile); - var factory = new SimulatorFactory(SimulatorFactory.FactoryMode.EngineeringMode, @"TestData\job.vecto"); + var factory = new SimulatorFactory(ExecutionMode.Engineering, inputData, fileWriter); jobContainer.AddRuns(factory); jobContainer.Execute(); diff --git a/VectoCoreTest/Models/Simulation/AuxTests.cs b/VectoCoreTest/Models/Simulation/AuxTests.cs index 02894e888befa3528cca7706ffac7041048e0fad..dc916c86de7562eaeeb2f8c8020a5bcc40261a44 100644 --- a/VectoCoreTest/Models/Simulation/AuxTests.cs +++ b/VectoCoreTest/Models/Simulation/AuxTests.cs @@ -297,7 +297,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var jobContainer = new JobContainer(sumData); var inputData = JSONInputDataFactory.ReadJsonJob(@"TestData\Jobs\40t_Long_Haul_Truck.vecto"); - var runsFactory = new SimulatorFactory(SimulatorFactory.FactoryMode.DeclarationMode, + var runsFactory = new SimulatorFactory(ExecutionMode.Declaration, inputData, fileWriter); jobContainer.AddRuns(runsFactory); @@ -315,7 +315,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var jobContainer = new JobContainer(sumData); var inputData = JSONInputDataFactory.ReadJsonJob(@"TestData\Jobs\24t Coach.vecto"); - var runsFactory = new SimulatorFactory(SimulatorFactory.FactoryMode.EngineeringMode, + var runsFactory = new SimulatorFactory(ExecutionMode.Engineering, inputData, fileWriter); jobContainer.AddRuns(runsFactory); diff --git a/VectoCoreTest/Models/Simulation/FactoryTest.cs b/VectoCoreTest/Models/Simulation/FactoryTest.cs index 1e520cea1773f8289bbb558e8ce5e33455dd78ee..accce0968a4118e87dcb18d02b83939f8b398f8d 100644 --- a/VectoCoreTest/Models/Simulation/FactoryTest.cs +++ b/VectoCoreTest/Models/Simulation/FactoryTest.cs @@ -39,7 +39,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var fileWriter = new FileOutputWriter(DeclarationJobFile); var inputData = JSONInputDataFactory.ReadJsonJob(DeclarationJobFile); - var factory = new SimulatorFactory(SimulatorFactory.FactoryMode.DeclarationMode, inputData, fileWriter); + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, fileWriter); //factory.DataReader.SetJobFile(DeclarationJobFile); @@ -86,7 +86,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var fileWriter = new FileOutputWriter(EngineeringJobFile); var inputData = JSONInputDataFactory.ReadJsonJob(EngineeringJobFile); - var factory = new SimulatorFactory(SimulatorFactory.FactoryMode.EngineeringMode, inputData, fileWriter); + var factory = new SimulatorFactory(ExecutionMode.Engineering, inputData, fileWriter); var run = factory.SimulationRuns().First(); diff --git a/VectoCoreTest/Models/Simulation/SimulationTests.cs b/VectoCoreTest/Models/Simulation/SimulationTests.cs index ecd97df862600fbbb35f07c10213beac79b2225d..5e7395e3d359d968fcf237c2cf5c85bc7dbaec15 100644 --- a/VectoCoreTest/Models/Simulation/SimulationTests.cs +++ b/VectoCoreTest/Models/Simulation/SimulationTests.cs @@ -91,11 +91,11 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation //var sumFileName = resultFileName.Substring(0, resultFileName.Length - 5) + Constants.FileExtensions.SumFile; var fileWriter = new FileOutputWriter(resultFileName, ""); - var modData = new ModalDataContainer(resultFileName, fileWriter, SimulatorFactory.FactoryMode.EngineOnlyMode); + var modData = new ModalDataContainer(resultFileName, fileWriter, ExecutionMode.EngineOnly); var sumWriter = new SummaryDataContainer(fileWriter); var inputData = JSONInputDataFactory.ReadJsonJob(EngineOnlyJob); - var factory = new SimulatorFactory(SimulatorFactory.FactoryMode.EngineOnlyMode, inputData, fileWriter) { + var factory = new SimulatorFactory(ExecutionMode.EngineOnly, inputData, fileWriter) { SumData = sumWriter }; @@ -111,7 +111,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var jobContainer = new JobContainer(sumWriter); var inputData = JSONInputDataFactory.ReadJsonJob(jobFile); - var runsFactory = new SimulatorFactory(SimulatorFactory.FactoryMode.EngineOnlyMode, + var runsFactory = new SimulatorFactory(ExecutionMode.EngineOnly, inputData, fileWriter); jobContainer.AddRuns(runsFactory); diff --git a/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs b/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs index eaed809ec99b7aa2137d59625a4ab191f3c8262e..fed818a2556cbca86cccb6f1ecd55b5476fb5ba0 100644 --- a/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs +++ b/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs @@ -164,8 +164,14 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData Ratio = 1 }; + var axleGearData = new AxleGearData() { + Ratio = 1, + LossMap = TransmissionLossMap.ReadFromFile(@"TestData\Components\limited.vtlm", 1, "1"), + }; + + AssertHelper.Exception<VectoException>( - () => SimulatorFactory.CheckLossMapRangeForFullLoadCurves(gearboxData, engineData)); + () => SimulatorFactory.CheckLossMapRangeForFullLoadCurves(gearboxData, engineData, axleGearData)); } } } \ No newline at end of file diff --git a/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs b/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs index 54a835de6c46e9b0c3e6e99fa2f45336600540e9..9deae32904c210dc2875e6d8d2d75cf9b48e46aa 100644 --- a/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs +++ b/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs @@ -73,7 +73,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData var angSpeed = SpeedToAngularSpeed(speed, rdyn) * axleData.Ratio; if (TestContext.DataRow["Gear"].ToString() == "A") { - torqueFromEngine = axleData.LossMap.GearboxInTorque(angSpeed, torqueToWheels); + torqueFromEngine = axleData.LossMap.GetInTorque(angSpeed, torqueToWheels); } var powerEngine = Formulas.TorqueToPower(torqueFromEngine, angSpeed);