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

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

replaced switch case in CreateSimulatorFactory with call to ISimulatorFactoryFactory

parent dfc5965b
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,7 @@ Imports TUGraz.VectoCommon.Resources
Imports TUGraz.VectoCommon.Utils
Imports TUGraz.VectoCore
Imports TUGraz.VectoCore.InputData.FileIO.XML
Imports TUGraz.VectoCore.Models.Simulation
Imports TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory
Imports TUGraz.VectoCore.Models.SimulationComponent.Data
Imports TUGraz.VectoCore.OutputData
......@@ -1024,7 +1025,7 @@ lbFound:
Dim outFile As String = GetOutputDirectory(jobFile)
Dim fileWriter As FileOutputWriter = New FileOutputWriter(outFile)
Dim runsFactory As SimulatorFactory = SimulatorFactory.CreateSimulatorFactory(mode, input, fileWriter)
Dim runsFactory As ISimulatorFactory = SimulatorFactory.CreateSimulatorFactory(mode, input, fileWriter)
runsFactory.WriteModalResults = Cfg.ModOut
runsFactory.ModalResults1Hz = Cfg.Mod1Hz
runsFactory.Validate = cbValidateRunData.Checked
......
......@@ -47,6 +47,9 @@ namespace TUGraz.VectoCore.Models.Simulation
IVectoRunDataFactory DataReader { get; }
ISimulatorFactory FollowUpSimulatorFactory { get; }
IOutputDataWriter ReportWriter { get; }
bool SerializeVectoRunData { get; set; }
bool CreateFollowUpSimulatorFactory { get; set; }
/// <summary>
/// Creates powertrain and initializes it with the component's data.
......
......@@ -41,7 +41,8 @@ namespace TUGraz.VectoCore.Models.Simulation
ExecutionMode mode, IInputDataProvider dataProvider,
IOutputDataWriter writer);
ISimulatorFactory Factory(IInputDataProvider dataProvider,
ISimulatorFactory Factory(ExecutionMode mode,
IInputDataProvider dataProvider,
IOutputDataWriter writer,
IDeclarationReport declarationReport = null,
IVTPReport vtpReport = null,
......
......@@ -71,30 +71,29 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory
{
get => CreateFollowUpSimulatorFactory ? _followingSimulatorFactoryCreator?.Invoke() : null;
}
public bool CreateFollowUpSimulatorFactory = false;
public bool CreateFollowUpSimulatorFactory { get; set; } = false;
protected readonly ExecutionMode _mode;
#region Constructors and Factory Methods to instantiate Instances of SimulatorFactory without NInject (should only be used in Testcases that are not updated yet)
[Obsolete("Creation of new SimulatorFactories should be done with SimulatorFactoryFactory NInject Factory", false)]
public static SimulatorFactory CreateSimulatorFactory(ExecutionMode mode, IInputDataProvider dataProvider, IOutputDataWriter writer, IDeclarationReport declarationReport = null, IVTPReport vtpReport=null, bool validate = true)
public static ISimulatorFactory CreateSimulatorFactory(ExecutionMode mode, IInputDataProvider dataProvider, IOutputDataWriter writer, IDeclarationReport declarationReport = null, IVTPReport vtpReport=null, bool validate = true)
{
switch (mode)
{
case ExecutionMode.Declaration:
ISimulatorFactoryFactory simFactoryFactory =
new StandardKernel(new VectoNinjectModule()).Get<ISimulatorFactoryFactory>();
return new SimulatorFactoryDeclaration(dataProvider, writer, declarationReport, vtpReport, validate);
case ExecutionMode.Engineering:
return new SimulatorFactoryEngineering(dataProvider, writer, validate);
default:
throw new VectoException("Unkown factory mode in SimulatorFactory: {0}", mode);
}
return new StandardKernel(new VectoNinjectModule()).Get<ISimulatorFactoryFactory>().Factory(mode, dataProvider, writer, declarationReport, vtpReport, validate);
//switch (mode)
//{
// case ExecutionMode.Declaration:
// return new SimulatorFactoryDeclaration(dataProvider, writer, declarationReport, vtpReport, validate);
// case ExecutionMode.Engineering:
// return new SimulatorFactoryEngineering(dataProvider, writer, validate);
// default:
// throw new VectoException("Unkown factory mode in SimulatorFactory: {0}", mode);
//}
}
[Obsolete("Creation of new SimulatorFactories should be done with SimulatorFactoryFactory NInject Factory", false)]
public static SimulatorFactory CreateSimulatorFactory(ExecutionMode mode, IInputDataProvider dataProvider, IOutputDataWriter writer)
public static ISimulatorFactory CreateSimulatorFactory(ExecutionMode mode, IInputDataProvider dataProvider, IOutputDataWriter writer)
{
return CreateSimulatorFactory(mode, dataProvider, writer, null, null, true);
}
......
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