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 ca12ee19 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

split driver data into engineering and declaration, separate engineerign and...

split driver data into engineering and declaration, separate engineerign and declaration input data provider (top level)
parent c131c1e7
No related branches found
No related tags found
No related merge requests found
Showing with 96 additions and 40 deletions
......@@ -173,8 +173,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
/// }
/// }
/// </code>
public class JSONInputDataV2 : JSONFile, IEngineeringInputDataProvider, IEngineeringJobInputData, IDriverInputData,
IAuxiliariesEngineeringInputData
public class JSONInputDataV2 : JSONFile, IEngineeringInputDataProvider, IDeclarationInputDataProvider,
IEngineeringJobInputData, IDriverEngineeringInputData, IAuxiliariesEngineeringInputData
{
protected IGearboxEngineeringInputData Gearbox;
......@@ -304,6 +304,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
return this;
}
IDriverEngineeringInputData IEngineeringInputDataProvider.DriverInputData
{
get { return this; }
}
IAuxiliariesDeclarationInputData IDeclarationInputDataProvider.AuxiliaryInputData()
{
return AuxiliaryInputData();
......@@ -320,7 +325,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
}
}
public virtual IDriverInputData DriverInputData
public virtual IDriverDeclarationInputData DriverInputData
{
get { return this; }
}
......@@ -383,7 +388,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
#region DriverInputData
public virtual IStartStopInputData StartStop
public virtual IStartStopEngineeringInputData StartStop
{
get
{
......@@ -397,6 +402,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
}
}
IOverSpeedEcoRollDeclarationInputData IDriverDeclarationInputData.OverSpeedEcoRoll
{
get
{
var overspeed = Body.GetEx(JsonKeys.DriverData_OverspeedEcoRoll);
return new OverSpeedEcoRollInputData() {
Mode = DriverData.ParseDriverMode(overspeed.GetEx<string>(JsonKeys.DriverData_OverspeedEcoRoll_Mode))
};
}
}
public virtual ILookaheadCoastingInputData Lookahead
{
get
......@@ -410,7 +426,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
}
}
public virtual IOverSpeedEcoRollInputData OverSpeedEcoRoll
IStartStopDeclarationInputData IDriverDeclarationInputData.StartStop
{
get { return StartStop; }
}
public virtual IOverSpeedEcoRollEngineeringInputData OverSpeedEcoRoll
{
get
{
......
......@@ -35,7 +35,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
}
}
public static IEngineeringInputDataProvider ReadJsonJob(string filename)
public static IInputDataProvider ReadJsonJob(string filename)
{
var json = ReadFile(filename);
var version = ReadVersion(json);
......
......@@ -39,26 +39,26 @@ namespace TUGraz.VectoCore.InputData
IRetarderInputData RetarderInputData { get; }
IDriverInputData DriverInputData { get; }
IDriverDeclarationInputData DriverInputData { get; }
}
public interface IEngineeringInputDataProvider : IDeclarationInputDataProvider
public interface IEngineeringInputDataProvider : IInputDataProvider
{
new IEngineeringJobInputData JobInputData();
IEngineeringJobInputData JobInputData();
new IVehicleEngineeringInputData VehicleInputData { get; }
IVehicleEngineeringInputData VehicleInputData { get; }
new IGearboxEngineeringInputData GearboxInputData { get; }
IGearboxEngineeringInputData GearboxInputData { get; }
//IAxleGearInputData AxleGearInputData { get; }
IAxleGearInputData AxleGearInputData { get; }
new IEngineEngineeringInputData EngineInputData { get; }
IEngineEngineeringInputData EngineInputData { get; }
new IAuxiliariesEngineeringInputData AuxiliaryInputData();
IAuxiliariesEngineeringInputData AuxiliaryInputData();
//IRetarderInputData RetarderInputData { get; }
IRetarderInputData RetarderInputData { get; }
//IDriverInputData DriverInputData { get; }
IDriverEngineeringInputData DriverInputData { get; }
}
}
\ No newline at end of file
......@@ -32,7 +32,7 @@ namespace TUGraz.VectoCore.InputData.Impl
public DataTable CycleData { get; internal set; }
}
public class StartStopInputData : IStartStopInputData
public class StartStopInputData : IStartStopEngineeringInputData
{
public bool Enabled { get; internal set; }
......@@ -52,7 +52,7 @@ namespace TUGraz.VectoCore.InputData.Impl
public MeterPerSecond MinSpeed { get; internal set; }
}
public class OverSpeedEcoRollInputData : IOverSpeedEcoRollInputData
public class OverSpeedEcoRollInputData : IOverSpeedEcoRollEngineeringInputData
{
public DriverData.DriverMode Mode { get; internal set; }
......
......@@ -472,29 +472,41 @@ namespace TUGraz.VectoCore.InputData
DataTable CycleData { get; }
}
public interface IDriverInputData
public interface IDriverDeclarationInputData
{
bool SavedInDeclarationMode { get; }
IStartStopInputData StartStop { get; }
ILookaheadCoastingInputData Lookahead { get; }
IOverSpeedEcoRollInputData OverSpeedEcoRoll { get; }
IStartStopDeclarationInputData StartStop { get; }
IOverSpeedEcoRollDeclarationInputData OverSpeedEcoRoll { get; }
}
public interface IDriverEngineeringInputData : IDriverDeclarationInputData
{
new IStartStopEngineeringInputData StartStop { get; }
new IOverSpeedEcoRollEngineeringInputData OverSpeedEcoRoll { get; }
/// <summary>
/// P009; P033, P034, P035
/// cf. VECTO Input Parameters.xlsx
/// </summary>
DataTable AccelerationCurve { get; }
ILookaheadCoastingInputData Lookahead { get; }
}
public interface IOverSpeedEcoRollInputData
public interface IOverSpeedEcoRollDeclarationInputData
{
/// <summary>
/// P015
/// cf. VECTO Input Parameters.xlsx
/// </summary>
DriverData.DriverMode Mode { get; }
}
public interface IOverSpeedEcoRollEngineeringInputData : IOverSpeedEcoRollDeclarationInputData
{
/// <summary>
/// P016
/// cf. VECTO Input Parameters.xlsx
......@@ -535,14 +547,17 @@ namespace TUGraz.VectoCore.InputData
MeterPerSecond MinSpeed { get; }
}
public interface IStartStopInputData
public interface IStartStopDeclarationInputData
{
/// <summary>
/// P010 StartStop - enabled
/// cf. VECTO Input Parameters.xlsx
/// </summary>
bool Enabled { get; }
}
public interface IStartStopEngineeringInputData : IStartStopDeclarationInputData
{
/// <summary>
/// P011 StartStop - Max speed
/// cf. VECTO Input Parameters.xlsx
......
......@@ -33,7 +33,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper
{
public class DeclarationDataAdapter : AbstractSimulationDataAdapter
{
public DriverData CreateDriverData(IDriverInputData data)
public DriverData CreateDriverData(IDriverDeclarationInputData data)
{
if (!data.SavedInDeclarationMode) {
WarnDeclarationMode("DriverData");
......
......@@ -159,7 +159,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper
}).Concat(new VectoRunData.AuxData { ID = "", DemandType = AuxiliaryDemandType.Direct }.ToEnumerable()).ToList();
}
internal DriverData CreateDriverData(IDriverInputData driver)
internal DriverData CreateDriverData(IDriverEngineeringInputData driver)
{
if (driver.SavedInDeclarationMode) {
WarnEngineeringMode("DriverData");
......
......@@ -77,9 +77,8 @@ namespace TUGraz.VectoCore.Tests.FileIO
var json = (JObject)JToken.ReadFrom(new JsonTextReader(File.OpenText(TestJobFile)));
((JObject)json["Body"]).Property("Cycles").Remove();
AssertHelper.Exception<InvalidFileFormatException>(() => {
var tmp = new JSONInputDataV2(json, TestJobFile).Cycles;
}, "Key Cycles not found");
AssertHelper.Exception<InvalidFileFormatException>(
() => { var tmp = new JSONInputDataV2(json, TestJobFile).Cycles; }, "Key Cycles not found");
}
[TestMethod]
......@@ -100,7 +99,8 @@ namespace TUGraz.VectoCore.Tests.FileIO
((JObject)json["Body"]).Property("VACC").Remove();
AssertHelper.Exception<VectoException>(() => {
var tmp = new JSONInputDataV2(json, TestJobFile).DriverInputData.AccelerationCurve;
IEngineeringInputDataProvider input = new JSONInputDataV2(json, TestJobFile);
var tmp = input.DriverInputData.AccelerationCurve;
}, "AccelerationCurve (VACC) required");
}
......@@ -111,7 +111,8 @@ namespace TUGraz.VectoCore.Tests.FileIO
var json = (JObject)JToken.ReadFrom(new JsonTextReader(File.OpenText(TestJobFile)));
json["Body"]["VACC"] = "Truck";
var tmp = new JSONInputDataV2(json, TestJobFile).DriverInputData.AccelerationCurve;
IEngineeringInputDataProvider input = new JSONInputDataV2(json, TestJobFile);
var tmp = input.DriverInputData.AccelerationCurve;
Assert.IsNotNull(tmp);
}
......@@ -121,8 +122,10 @@ namespace TUGraz.VectoCore.Tests.FileIO
var json = (JObject)JToken.ReadFrom(new JsonTextReader(File.OpenText(TestJobFile)));
((JObject)json["Body"]).Property("LAC").Remove();
AssertHelper.Exception<VectoException>(() => {
var tmp = new JSONInputDataV2(json, TestJobFile).DriverInputData.Lookahead;
AssertHelper.Exception<VectoException>(
() => {
IEngineeringInputDataProvider input = new JSONInputDataV2(json, TestJobFile);
var tmp = input.DriverInputData.Lookahead;
}, "Key LAC not found");
}
......@@ -132,9 +135,9 @@ namespace TUGraz.VectoCore.Tests.FileIO
var json = (JObject)JToken.ReadFrom(new JsonTextReader(File.OpenText(TestJobFile)));
((JObject)json["Body"]).Property("OverSpeedEcoRoll").Remove();
AssertHelper.Exception<VectoException>(() => {
var tmp = new JSONInputDataV2(json, TestJobFile).DriverInputData.OverSpeedEcoRoll;
}, "Key OverSpeedEcoRoll not found");
AssertHelper.Exception<VectoException>(
() => { var tmp = new JSONInputDataV2(json, TestJobFile).DriverInputData.OverSpeedEcoRoll; },
"Key OverSpeedEcoRoll not found");
}
}
......
......@@ -19,6 +19,8 @@
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.InputData;
using TUGraz.VectoCore.InputData.FileIO.JSON;
using TUGraz.VectoCore.InputData.Reader.Impl;
using TUGraz.VectoCore.Models.Declaration;
......@@ -37,7 +39,11 @@ namespace TUGraz.VectoCore.Tests.FileIO
public void ReadDeclarationJobFile()
{
var dataProvider = JSONInputDataFactory.ReadJsonJob(DeclarationJob);
var reader = new DeclarationModeVectoRunDataFactory(dataProvider, null);
var declarationProvider = dataProvider as IDeclarationInputDataProvider;
if (declarationProvider == null) {
throw new VectoException("Failed to cas to Engineering InputDataProvider");
}
var reader = new DeclarationModeVectoRunDataFactory(declarationProvider, null);
//reader.SetJobFile(DeclarationJob);
var runData = reader.NextRun().First();
......
......@@ -18,6 +18,8 @@
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.InputData;
using TUGraz.VectoCore.InputData.FileIO.JSON;
using TUGraz.VectoCore.InputData.Reader.Impl;
using TUGraz.VectoCore.Models.Connector.Ports;
......@@ -37,7 +39,11 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
public void BuildFullPowerTrainTest()
{
var dataProvider = JSONInputDataFactory.ReadJsonJob(JobFile);
var reader = new EngineeringModeVectoRunDataFactory(dataProvider);
var engineeringProvider = dataProvider as IEngineeringInputDataProvider;
if (engineeringProvider == null) {
throw new VectoException("Failed to cas to Engineering InputDataProvider");
}
var reader = new EngineeringModeVectoRunDataFactory(engineeringProvider);
var runData = reader.NextRun().First();
var writer = new MockModalDataContainer();
......
......@@ -16,6 +16,7 @@
* limitations under the Licence.
*/
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.InputData;
using TUGraz.VectoCore.InputData.FileIO.JSON;
using TUGraz.VectoCore.InputData.Reader.DataObjectAdaper;
......@@ -71,8 +72,12 @@ namespace TUGraz.VectoCore.Tests.Utils
public static DriverData CreateDriverDataFromFile(string driverDataFile)
{
var jobInput = JSONInputDataFactory.ReadJsonJob(driverDataFile);
var engineeringJob = jobInput as IEngineeringInputDataProvider;
if (engineeringJob == null) {
throw new VectoException("Failed to cas to Engineering InputDataProvider");
}
var dao = new EngineeringDataAdapter();
return dao.CreateDriverData(jobInput.DriverInputData);
return dao.CreateDriverData(engineeringJob.DriverInputData);
}
}
}
\ 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