Code development platform for open source projects from the European Union institutions

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

added constructor overload for distance run and vecto run

parent c2536c6c
No related branches found
No related tags found
No related merge requests found
......@@ -34,14 +34,15 @@ using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Models.Connector.Ports.Impl;
using TUGraz.VectoCore.Models.SimulationComponent;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Simulation.Impl
{
public class DistanceRun : VectoRun
{
public DistanceRun(IVehicleContainer container, IFollowUpRunCreator followUpCreator) : base(container, followUpCreator) {}
public DistanceRun(IVehicleContainer container) : base(container) {}
protected override IResponse DoSimulationStep()
{
IterationStatistics.StartIteration();
......
......@@ -50,6 +50,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
protected Second AbsTime = 0.SI<Second>();
protected Second dt = 1.SI<Second>();
private bool _cancelled;
private readonly IFollowUpRunCreator _followUpCreator;
protected ISimulationOutPort CyclePort { get; set; }
[Required, ValidateObject]
......@@ -59,6 +60,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
public int RunIdentifier { get; protected set; }
public virtual string RunName => Container.RunData.JobName;
public virtual string CycleName => Container.RunData.Cycle.Name;
......@@ -79,6 +81,11 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
WritingResultsDone = false;
}
protected VectoRun(IVehicleContainer container, IFollowUpRunCreator followUpCreator) : this(container)
{
_followUpCreator = followUpCreator;
}
public IVehicleContainer GetContainer() => Container;
public void Run()
......@@ -171,8 +178,18 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
Container.RunStatus = response is ResponseBatteryEmpty ? Status.REESSEmpty : Status.Aborted;
else
Container.RunStatus = Status.Success;
Container.FinishSimulationRun();
WritingResultsDone = true;
var runAgain = _followUpCreator.RunAgain(Run,
this,
() => Container.FinishSingleSimulationRun());
if (!runAgain) {
Container.FinishSimulationRun();
WritingResultsDone = true;
}
if (Progress.IsSmaller(1, 1e-9)) {
if (response is ResponseBatteryEmpty) {
throw new VectoSimulationException("{3} ({4} {5}) REESS was empty before cycle could be finished. Progress: {6:P1} - absTime: {0:F1}, distance: {1:F1}, dt: {2:F1}",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment