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 567b349e authored by Markus Quaritsch's avatar Markus Quaritsch Committed by Stefanos DOUMPOULAKIS
Browse files

bugfix: abort complete bus simulation in case an error occurs during a primary simulation run

parent c427addd
Branches
Tags
No related merge requests found
......@@ -1018,6 +1018,7 @@ lbFound:
'list of finished runs
Dim finishedRuns As List(Of Integer) = New List(Of Integer)
For Each jobFile As String In JobFileList
Try
sender.ReportProgress(0,
......@@ -1058,10 +1059,6 @@ lbFound:
End Using
End Select
End Select
......@@ -1073,9 +1070,6 @@ lbFound:
Continue For
End If
Dim runsFactory As ISimulatorFactory = SimulatorFactory.CreateSimulatorFactory(mode, input, fileWriter)
'Remove
......@@ -1085,8 +1079,6 @@ lbFound:
runsFactory.ActualModalData = cbActVmod.Checked
runsFactory.SerializeVectoRunData = cbSaveVectoRunData.Checked
For Each run as integer In jobContainer.AddRuns(runsFactory)
fileWriters.Add(run, fileWriter)
Next
......@@ -1170,6 +1162,7 @@ lbFound:
For Each job As String In JobFileList
dim w as FileOutputWriter = new FileOutputWriter(GetOutputDirectory(job))
For Each entry as KeyValuePair(Of string, string) In _
new Dictionary(Of string, string) _
from {{w.XMLFullReportName, "XML Manufacturer Report"}, {w.XMLCustomerReportName, "XML Customer Report"},
......
using System;
using System.Collections.Generic;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCore.InputData.FileIO.XML;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Impl;
using TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory;
using TUGraz.VectoCore.OutputData;
using TUGraz.VectoCore.OutputData.XML;
......@@ -31,10 +33,10 @@ namespace TUGraz.VectoMockup.Simulation.SimulatorFactory
#region Overrides of InterimAfterPrimaryFactoryCreator
public override ISimulatorFactory GetNextFactory()
public override ISimulatorFactory GetNextFactory(IDictionary<int, JobContainer.ProgressEntry> progressEntries)
{
//throw new NotImplementedException();
return base.GetNextFactory();
return base.GetNextFactory(progressEntries);
}
#endregion
......@@ -60,9 +62,9 @@ namespace TUGraz.VectoMockup.Simulation.SimulatorFactory
#region Overrides of CompletedAfterInterimPrimaryFactoryCreator
public override ISimulatorFactory GetNextFactory()
public override ISimulatorFactory GetNextFactory(IDictionary<int, JobContainer.ProgressEntry> progressEntries)
{
return base.GetNextFactory();
return base.GetNextFactory(progressEntries);
}
#endregion
......
......@@ -33,6 +33,7 @@ using System;
using System.Collections.Generic;
using TUGraz.VectoCore.InputData;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.Simulation.Impl;
using TUGraz.VectoCore.OutputData;
namespace TUGraz.VectoCore.Models.Simulation
......@@ -47,7 +48,7 @@ namespace TUGraz.VectoCore.Models.Simulation
SummaryDataContainer SumData { get; set; }
int JobNumber { get; set; }
IVectoRunDataFactory RunDataFactory { get; }
ISimulatorFactory FollowUpSimulatorFactory { get; }
ISimulatorFactory FollowUpSimulatorFactory(IDictionary<int, JobContainer.ProgressEntry> progressEntries);
IOutputDataWriter ReportWriter { get; }
bool SerializeVectoRunData { get; set; }
......
......@@ -37,6 +37,7 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.OutputData;
......@@ -99,7 +100,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
}
[MethodImpl(MethodImplOptions.Synchronized)]
public ISimulatorFactory GetFollowUpSimulatorFactory()
public ISimulatorFactory GetFollowUpSimulatorFactory(IDictionary<int, ProgressEntry> progressEntries)
{
try {
if (followUpSimulatorFactoryFetched || !AllCompleted()) {
......@@ -107,7 +108,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
}
followUpSimulatorFactoryFetched = true;
var factory = _simulatorFactory.FollowUpSimulatorFactory;
var factory = _simulatorFactory.FollowUpSimulatorFactory(progressEntries);
if (factory != null) {
factory.SerializeVectoRunData = _simulatorFactory.SerializeVectoRunData;
}
......@@ -356,8 +357,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
_runContainerMap.TryGetValue(runContainerId, out var runContainer);
runContainer?.JobCompleted(runId);
try {
// may throw an exception in case not all simulation runs are finished successfully
AddFollowUpSimulatorFactories(runContainerId);
} finally {
try {
_runsRwLock.EnterWriteLock();
//_unfinishedRuns.Remove(runId);
......@@ -373,17 +376,17 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
_runsRwLock.ExitWriteLock();
}
}
}
private void AddFollowUpSimulatorFactories(int runContainerId)
{
try {
_runContainerMap.TryGetValue(runContainerId, out var runContainer);
var additionalSimulatorFactory = runContainer?.GetFollowUpSimulatorFactory();
var additionalSimulatorFactory = runContainer?.GetFollowUpSimulatorFactory(GetProgress());
if (additionalSimulatorFactory == null) {
return;
}
AddRuns(additionalSimulatorFactory);
Execute(_multithreaded);
} catch (Exception ex) {
......@@ -465,6 +468,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
}
[DebuggerDisplay("{RunName}{RunSuffix}: {Progress} done: {Done} Success: {Success} ")]
public class ProgressEntry
{
// unique identifier of the simulation run
......
using System.Diagnostics;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Xml;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
......@@ -16,7 +19,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory
{
public interface IFollowUpSimulatorFactoryCreator
{
ISimulatorFactory GetNextFactory();
ISimulatorFactory GetNextFactory(IDictionary<int, JobContainer.ProgressEntry> progressEntries);
IOutputDataWriter CurrentStageOutputDataWriter { get; }
......@@ -38,7 +41,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory
#region Implementation of IFollowUpSimulatorFactoryCreator
public abstract ISimulatorFactory GetNextFactory();
public abstract ISimulatorFactory GetNextFactory(IDictionary<int, JobContainer.ProgressEntry> progressEntries);
public abstract IOutputDataWriter CurrentStageOutputDataWriter { get; }
public abstract IDeclarationReport CurrentStageDeclarationReport { get; }
public abstract IInputDataProvider CurrentStageInputData { get; }
......@@ -85,8 +88,12 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory
#region Implementation of IFollowUpSimulatorFactoryCreator
public override ISimulatorFactory GetNextFactory()
public override ISimulatorFactory GetNextFactory(IDictionary<int, JobContainer.ProgressEntry> progressEntries)
{
var aborted = progressEntries.Where(e => e.Value.Error != null).ToArray();
if (aborted.Any()) {
throw new VectoException("Not all primary simulation runs finished successfully!");
}
//Prepare inputdata for next simulation step
var primaryInputData = _inputDataReader.CreateDeclaration(_currentStageOutputDataWriter
.GetDocument(ReportType.DeclarationReportPrimaryVehicleXML).CreateReader()) as IMultistepBusInputDataProvider;
......@@ -137,7 +144,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory
_xmlInputDataReader = inputDataReader;
}
public override ISimulatorFactory GetNextFactory()
public override ISimulatorFactory GetNextFactory(IDictionary<int, JobContainer.ProgressEntry> progressEntries)
{
if (!_originalInputData.SimulateResultingVIF) {
return null;
......
......@@ -68,22 +68,16 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory
public ISimulatorFactory FollowUpSimulatorFactory
public ISimulatorFactory FollowUpSimulatorFactory(IDictionary<int, JobContainer.ProgressEntry> progressEntries)
{
get
{
var factory = _followUpSimulatorFactoryCreator?.GetNextFactory();
var factory = _followUpSimulatorFactoryCreator?.GetNextFactory(progressEntries);
if (factory != null) {
factory.WriteModalResults = this.WriteModalResults;
//factory.SerializeVectoRunData = this.SerializeVectoRunData;
}
return factory;
}
}
public bool CreateFollowUpSimulatorFactory { get; set; } = false;
protected readonly ExecutionMode _mode;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment