Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit ecb4d65b authored by Harald Martini's avatar Harald Martini
Browse files

added short version of failing P1 testcase

parent c03f28c5
No related branches found
No related tags found
No related merge requests found
...@@ -168,7 +168,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -168,7 +168,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
var ex = new VectoSimulationException("{6} ({7} {8}) - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}, f_equiv:{9}", var ex = new VectoSimulationException("{6} ({7} {8}) - absTime: {0}, distance: {1}, dt: {2}, v: {3}, Gear: {4} | {5}, f_equiv:{9}",
e, AbsTime, Container.MileageCounter.Distance, dt, Container.VehicleInfo.VehicleSpeed, e, AbsTime, Container.MileageCounter.Distance, dt, Container.VehicleInfo.VehicleSpeed,
TryCatch(() => Container.GearboxInfo.Gear), e.Message, RunIdentifier, CycleName, RunSuffix, TryCatch(() => Container.RunData.HybridStrategyParameters.EquivalenceFactor)); TryCatch(() => Container.GearboxInfo.Gear), e.Message, RunIdentifier, CycleName, RunSuffix, TryCatch(() => Container.RunData.HybridStrategyParameters.EquivalenceFactor) ?? "-");
Container.FinishSimulationRun(ex); Container.FinishSimulationRun(ex);
throw ex; throw ex;
} }
......
 // #define FULL_SIMULATIONS
#define FULL_SIMULATIONS
...@@ -90,6 +88,22 @@ public class PrimaryBusSimulation ...@@ -90,6 +88,22 @@ public class PrimaryBusSimulation
return missionFilter; return missionFilter;
} }
private TestDeclarationCycleFactoryStartPoint StartPointCycleFactory()
{
#if !FULL_SIMULATIONS
Kernel.Rebind<IDeclarationCycleFactory>().To<TestDeclarationCycleFactoryStartPoint>().InSingletonScope();
#endif
var missionFilter = Kernel.Get<IDeclarationCycleFactory>() as TestDeclarationCycleFactoryStartPoint;
#if FULL_SIMULATIONS
Assert.Null(missionFilter);
TestContext.Progress.WriteLine("Running full cycle");
#else
Assert.NotNull(missionFilter);
#endif
return missionFilter;
}
[ [
TestCase(@"PrimaryBus/Conventional/primary_heavyBus group41_nonSmart.xml", 0, TestName = "2nd Amendment PrimaryBus Conventional"), TestCase(@"PrimaryBus/Conventional/primary_heavyBus group41_nonSmart.xml", 0, TestName = "2nd Amendment PrimaryBus Conventional"),
...@@ -134,7 +148,7 @@ public class PrimaryBusSimulation ...@@ -134,7 +148,7 @@ public class PrimaryBusSimulation
TestCase(@"FactorMethod\PEV\P31_32_E2_AMT_FESG.xml", 0, TestName = "2nd Amendment PrimaryBus FM PEV E2 FESG"), TestCase(@"FactorMethod\PEV\P31_32_E2_AMT_FESG.xml", 0, TestName = "2nd Amendment PrimaryBus FM PEV E2 FESG"),
TestCase(@"FactorMethod\P-HEV\P1-HEV\P31_32_P1_HEV_AT_nonSmart_ES_elec_SP_elec_PS.xml", 0, TestName = "2nd Amendment PrimaryBus FM P-HEV P1 nonSmartES_elFan_elPS"), TestCase(@"FactorMethod\P-HEV\P1-HEV\P31_32_P1_HEV_AT_nonSmart_ES_elec_SP_elec_PS.xml", 0, TestName = "2nd Amendment PrimaryBus FM P-HEV P1 nonSmartES_elFan_elPS"),
TestCase(@"FactorMethod\P-HEV\P1-HEV\P31_32_P1_HEV_AT_nonSmart_ES_mech_Aux.xml", 0, TestName = "2nd Amendment PrimaryBus FM P-HEV P1 nonSmartES_mechAux"), TestCase(@"FactorMethod\P-HEV\P1-HEV\P31_32_P1_HEV_AT_nonSmart_ES_mech_Aux.xml", -1, TestName = "2nd Amendment PrimaryBus FM P-HEV P1 nonSmartES_mechAux"),
TestCase(@"FactorMethod\P-HEV\P1-HEV\P31_32_P1_HEV_AT_Smart_ES_elec_SP_elec_PS.xml", 0, TestName = "2nd Amendment PrimaryBus FM P-HEV P1 SmartES_elPS_elSteer"), TestCase(@"FactorMethod\P-HEV\P1-HEV\P31_32_P1_HEV_AT_Smart_ES_elec_SP_elec_PS.xml", 0, TestName = "2nd Amendment PrimaryBus FM P-HEV P1 SmartES_elPS_elSteer"),
TestCase(@"FactorMethod\P-HEV\P2-HEV\P31_32_P2_HEV_nonSmartES_elec_SP_elec_Fan.xml", 0, TestName = "2nd Amendment PrimaryBus FM P-HEV P2 nonSmartES_elFan_elSteer"), TestCase(@"FactorMethod\P-HEV\P2-HEV\P31_32_P2_HEV_nonSmartES_elec_SP_elec_Fan.xml", 0, TestName = "2nd Amendment PrimaryBus FM P-HEV P2 nonSmartES_elFan_elSteer"),
...@@ -450,11 +464,11 @@ public class PrimaryBusSimulation ...@@ -450,11 +464,11 @@ public class PrimaryBusSimulation
return fileWriter.GetWrittenFiles()[ReportType.DeclarationReportMultistageVehicleXML]; return fileWriter.GetWrittenFiles()[ReportType.DeclarationReportMultistageVehicleXML];
} }
public void RunSimulationPrimary(string jobFile, int runIdx) public void RunSimulationPrimary(string jobFile, int runIdx, params Action<VectoRunData>[] runDataModifier)
{ {
RunSimulationPrimary(jobFile, runIdx, out var _); RunSimulationPrimary(jobFile, runIdx, out var _);
} }
public void RunSimulationPrimary(string jobFile, int runIdx, out string vifFile) public void RunSimulationPrimary(string jobFile, int runIdx, out string vifFile, params Action<VectoRunData>[] runDataModifier)
{ {
var filePath = Path.Combine(BASE_DIR, jobFile); var filePath = Path.Combine(BASE_DIR, jobFile);
var dataProvider = _xmlReader.CreateDeclaration(filePath); var dataProvider = _xmlReader.CreateDeclaration(filePath);
...@@ -462,14 +476,22 @@ public class PrimaryBusSimulation ...@@ -462,14 +476,22 @@ public class PrimaryBusSimulation
var simFactory = Kernel.Get<ISimulatorFactoryFactory>(); var simFactory = Kernel.Get<ISimulatorFactoryFactory>();
var runsFactory = simFactory.Factory(ExecutionMode.Declaration, dataProvider, fileWriter, null, null); var runsFactory = simFactory.Factory(ExecutionMode.Declaration, dataProvider, fileWriter, null, null);
runsFactory.WriteModalResults = true; runsFactory.WriteModalResults = true;
runsFactory.SerializeVectoRunData = true; //runsFactory.SerializeVectoRunData = true;
var jobContainer = new JobContainer(new SummaryDataContainer(fileWriter)) { }; var jobContainer = new JobContainer(new SummaryDataContainer(fileWriter)) { };
//var jobContainer = new JobContainer(new MockSumWriter()) { }; //var jobContainer = new JobContainer(new MockSumWriter()) { };
var runs = runsFactory.SimulationRuns();
foreach (var vectoRun in runs) {
foreach (var action in runDataModifier) {
action(vectoRun.GetContainer().RunData);
}
}
if (runIdx < 0) { if (runIdx < 0) {
jobContainer.AddRuns(runsFactory); foreach (var run in runs) {
jobContainer.AddRun(run);
}
//jobContainer.AddRuns(runsFactory);
} else { } else {
var run = runsFactory.SimulationRuns().Skip(runIdx).First(); var run = runs.Skip(runIdx).First();
jobContainer.AddRun(run); jobContainer.AddRun(run);
TestContext.Progress.WriteLine($"{run.CycleName} - {run.RunSuffix}"); TestContext.Progress.WriteLine($"{run.CycleName} - {run.RunSuffix}");
var expectedResults = 1; var expectedResults = 1;
...@@ -596,4 +618,36 @@ public class PrimaryBusSimulation ...@@ -596,4 +618,36 @@ public class PrimaryBusSimulation
TestContext.AddTestAttachment(keyValuePair.Value, keyValuePair.Key.ToString()); TestContext.AddTestAttachment(keyValuePair.Value, keyValuePair.Key.ToString());
} }
} }
[TestCase(@"PrimaryBus/P-HEV/PrimaryCityBus_P1_HEV_Base_AT.xml",
MissionType.Interurban,
LoadingType.ReferenceLoad,
53800,
0.1,
TestName = "2nd Amendment PrimaryBus P-HEV P1, Interurban selected section")]
public void PrimaryBusCycleSection(string primaryFile, MissionType cycle, LoadingType loading,
double startDistance_m, double f_equiv)
{
var missionFilter = TestMissionFilter();
missionFilter.SetMissions((cycle, loading));
var cycleFactory = StartPointCycleFactory();
cycleFactory.SetStartPoint(startDistance_m.SI<Meter>());
RunSimulationPrimary(primaryFile, -1, runData => {
if (runData.HybridStrategyParameters != null) {
var factorCharge = runData.HybridStrategyParameters.EquivalenceFactorCharge /
runData.HybridStrategyParameters.EquivalenceFactor;
var factorDischarge = runData.HybridStrategyParameters.EquivalenceFactorDischarge /
runData.HybridStrategyParameters.EquivalenceFactor;
runData.HybridStrategyParameters.EquivalenceFactor = f_equiv;
runData.HybridStrategyParameters.EquivalenceFactorDischarge = f_equiv * factorDischarge;
runData.HybridStrategyParameters.EquivalenceFactorCharge = f_equiv * factorCharge;
}
});
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment