Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 3e3bfb15 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

construction of powertrain works for engineering and engine-only mode

parent 419eac70
No related branches found
No related tags found
No related merge requests found
Showing
with 19513 additions and 158 deletions
......@@ -113,6 +113,7 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
switch (fileInfo.Version) {
case 5:
Vehicle = JsonConvert.DeserializeObject<VehicleFileV5Declaration>(json);
Vehicle.BasePath = Path.GetDirectoryName(file);
break;
default:
throw new UnsupportedFileVersionException("Unsupported Version of vehicle-file. Got version " + fileInfo.Version);
......@@ -128,6 +129,7 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
switch (fileInfo.Version) {
case 2:
Engine = JsonConvert.DeserializeObject<EngineFileV2Declaration>(json);
Engine.BasePath = Path.GetDirectoryName(file);
break;
default:
throw new UnsupportedFileVersionException("Unsopported Version of engine-file. Got version " + fileInfo.Version);
......
......@@ -54,35 +54,17 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
switch (fileInfo.Version) {
case 5:
Vehicle = JsonConvert.DeserializeObject<VehicleFileV5Engineering>(json);
Vehicle.BasePath = Path.GetDirectoryName(file);
break;
default:
throw new UnsupportedFileVersionException("Unsupported Version of .vveh file. Got Version " + fileInfo.Version);
}
}
internal VehicleData CreateVehicleData(VehicleFileV5Engineering vehicle)
{
var data = vehicle.Body;
var retVal = SetCommonVehicleData(vehicle);
retVal.BasePath = vehicle.BasePath;
retVal.CurbWeigthExtra = data.CurbWeightExtra.SI<Kilogram>();
retVal.Loading = data.Loading.SI<Kilogram>();
retVal.DynamicTyreRadius = data.DynamicTyreRadius.SI().Milli.Meter.Cast<Meter>();
retVal.AxleData = data.AxleConfig.Axles.Select(axle => new Axle {
Inertia = DoubleExtensionMethods.SI<KilogramSquareMeter>(axle.Inertia),
TwinTyres = axle.TwinTyres,
RollResistanceCoefficient = axle.RollResistanceCoefficient,
AxleWeightShare = axle.AxleWeightShare,
TyreTestLoad = DoubleExtensionMethods.SI<Newton>(axle.TyreTestLoad),
//Wheels = axle.WheelsStr
}).ToList();
return retVal;
}
/// <summary>
/// Iterate over all cycles defined in the JobFile and create a container with all data required for creating a simulation run
/// </summary>
/// <returns>VectoRunData instance for initializing the powertrain.</returns>
public override IEnumerable<VectoRunData> NextRun()
{
var job = Job as VectoJobFileV2Engineering;
......@@ -95,6 +77,10 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
BasePath = job.BasePath,
JobFileName = job.JobFile,
EngineData = CreateEngineData((dynamic) Engine),
GearboxData = CreateGearboxData((dynamic) Gearbox),
VehicleData = CreateVehicleData((dynamic) Vehicle),
//DriverData = new DriverData(),
//Aux =
Cycle = DrivingCycleData.ReadFromFile(Path.Combine(job.BasePath, cycle), DrivingCycleData.CycleType.DistanceBased),
IsEngineOnly = false
};
......@@ -102,26 +88,43 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
}
}
/// <summary>
/// create VehicleData instance directly from a file
/// </summary>
/// <param name="file">filename</param>
/// <returns>VehicleData instance</returns>
public static VehicleData CreateVehicleDataFromFile(string file)
{
var data = DoReadVehicleFile(file);
return new EngineeringModeSimulationDataReader().CreateVehicleData((dynamic) data);
}
/// <summary>
/// Create CombustionEngineData instance directly from a file
/// </summary>
/// <param name="file">filename</param>
/// <returns>CombustionengineData instance</returns>
public static CombustionEngineData CreateEngineDataFromFile(string file)
{
var data = DoReadEngineFile(file);
return new EngineeringModeSimulationDataReader().CreateEngineData((dynamic) data);
}
/// <summary>
/// Create gearboxdata instance directly from a file
/// </summary>
/// <param name="file">filename</param>
/// <returns>GearboxData instance</returns>
public static GearboxData CreateGearboxDataFromFile(string file)
{
var data = DoReadGearboxFile(file);
return new EngineeringModeSimulationDataReader().CreateGearboxData((dynamic) data);
}
/// <summary>
/// initialize Job member (deserialize Job-file)
/// </summary>
/// <param name="file">file</param>
protected override void ReadJobFile(string file)
{
var json = File.ReadAllText(file);
......@@ -139,16 +142,29 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
}
}
/// <summary>
/// initialize Engine member (deserialize Engine-file)
/// </summary>
/// <param name="file"></param>
protected override void ReadEngine(string file)
{
Engine = DoReadEngineFile(file);
}
/// <summary>
/// initialize Gearbox member (deserialize Gearbox-file)
/// </summary>
/// <param name="file"></param>
protected override void ReadGearbox(string file)
{
Gearbox = DoReadGearboxFile(file);
}
/// <summary>
/// De-serialize engine-file (JSON)
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
protected static VectoEngineFile DoReadEngineFile(string file)
{
var json = File.ReadAllText(file);
......@@ -165,6 +181,11 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
}
}
/// <summary>
/// De-serialize gearbox-file (JSON)
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
protected static VectoGearboxFile DoReadGearboxFile(string file)
{
var json = File.ReadAllText(file);
......@@ -181,6 +202,11 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
}
}
/// <summary>
/// De-serialize vehicle-file (JSON)
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
protected static VectoVehicleFile DoReadVehicleFile(string file)
{
var json = File.ReadAllText(file);
......@@ -197,7 +223,40 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
}
}
/// <summary>
/// convert datastructure representing file-contents into internal datastructure
/// Vehicle, file-format version 5
/// </summary>
/// <param name="vehicle">VehicleFileV5 container</param>
/// <returns>VehicleData instance</returns>
internal VehicleData CreateVehicleData(VehicleFileV5Engineering vehicle)
{
var data = vehicle.Body;
var retVal = SetCommonVehicleData(vehicle);
retVal.BasePath = vehicle.BasePath;
retVal.CurbWeigthExtra = data.CurbWeightExtra.SI<Kilogram>();
retVal.Loading = data.Loading.SI<Kilogram>();
retVal.DynamicTyreRadius = data.DynamicTyreRadius.SI().Milli.Meter.Cast<Meter>();
retVal.AxleData = data.AxleConfig.Axles.Select(axle => new Axle {
Inertia = DoubleExtensionMethods.SI<KilogramSquareMeter>(axle.Inertia),
TwinTyres = axle.TwinTyres,
RollResistanceCoefficient = axle.RollResistanceCoefficient,
AxleWeightShare = axle.AxleWeightShare,
TyreTestLoad = DoubleExtensionMethods.SI<Newton>(axle.TyreTestLoad),
//Wheels = axle.WheelsStr
}).ToList();
return retVal;
}
/// <summary>
/// convert datastructure representing the file-contents into internal data structure
/// Engine, file-format version 2
/// </summary>
/// <param name="engine">Engin-Data file (Engineering mode)</param>
/// <returns></returns>
internal CombustionEngineData CreateEngineData(EngineFileV2Engineering engine)
{
var retVal = SetCommonCombustionEngineData(engine);
......@@ -209,6 +268,13 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
return retVal;
}
/// <summary>
/// convert datastructure representing the file-contents into internal data structure
/// Gearbox, File-format Version 4
/// </summary>
/// <param name="gearbox"></param>
/// <returns></returns>
internal GearboxData CreateGearboxData(GearboxFileV4Engineering gearbox)
{
var retVal = SetCommonGearboxData(gearbox.Body);
......
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.SimulationComponent;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
......@@ -15,15 +17,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
{
private readonly bool _engineOnly;
private readonly VehicleContainer _container;
//private ICombustionEngine _engine;
//private IGearbox _gearBox;
//private IVehicle _vehicle;
//private IWheels _wheels;
//private IDriver _driver;
//private readonly Dictionary<string, AuxiliaryData> _auxDict = new Dictionary<string, AuxiliaryData>();
//private IPowerTrainComponent _retarder;
//private IClutch _clutch;
//private IPowerTrainComponent _axleGear;
public PowertrainBuilder(IModalDataWriter dataWriter, ISummaryDataWriter sumWriter, bool engineOnly)
{
......@@ -38,49 +32,98 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
private VehicleContainer BuildFullPowertrain(VectoRunData data)
{
//throw new NotImplementedException("FullPowertrain is not fully implemented yet.");
//todo: make distinction between time based and distance based driving cycle!
var cycle = new TimeBasedDrivingCycle(_container, data.Cycle);
var axleGear = new AxleGear(data.GearboxData.AxleGearData);
var wheels = new Wheels(_container, data.VehicleData.DynamicTyreRadius);
var driver = new Driver(_container, data.DriverData);
var vehicle = new Vehicle(_container, data.VehicleData);
var gearBox = new Gearbox(_container, data.GearboxData);
var clutch = new Clutch(_container, data.EngineData);
var retarder = new Retarder(_container, data.VehicleData.Retarder.LossMap);
var engine = new CombustionEngine(_container, data.EngineData);
var cycle = new DistanceBasedDrivingCycle(_container, data.Cycle);
// connect cycle --> driver --> vehicle --> wheels --> axleGear --> gearBox --> retarder --> clutch
cycle.InShaft().Connect(driver.OutShaft());
driver.InShaft().Connect(vehicle.OutShaft());
vehicle.InPort().Connect(wheels.OutPort());
wheels.InShaft().Connect(axleGear.OutShaft());
axleGear.InShaft().Connect(gearBox.OutShaft());
gearBox.InShaft().Connect(retarder.OutShaft());
retarder.InShaft().Connect(clutch.OutShaft());
dynamic tmp = AddComponent(cycle, new Driver(_container, data.DriverData));
tmp = AddComponent(tmp, new Vehicle(_container, data.VehicleData));
tmp = AddComponent(tmp, new Wheels(_container, data.VehicleData.DynamicTyreRadius));
tmp = AddComponent(tmp, new AxleGear(_container, data.GearboxData.AxleGearData));
switch (data.VehicleData.Retarder.Type) {
case RetarderData.RetarderType.Primary:
tmp = AddComponent(tmp, new Retarder(_container, data.VehicleData.Retarder.LossMap));
tmp = AddComponent(tmp, GetGearbox(_container, data.GearboxData));
break;
case RetarderData.RetarderType.Secondary:
tmp = AddComponent(tmp, GetGearbox(_container, data.GearboxData));
tmp = AddComponent(tmp, new Retarder(_container, data.VehicleData.Retarder.LossMap));
break;
case RetarderData.RetarderType.None:
tmp = AddComponent(tmp, GetGearbox(_container, data.GearboxData));
break;
}
tmp = AddComponent(tmp, new Clutch(_container, data.EngineData));
// connect cluch --> aux --> ... --> aux_XXX --> directAux
if (data.Aux != null) {
foreach (var auxData in data.Aux) {
var auxCycleData = new AuxiliaryCycleDataAdapter(data.Cycle, auxData.ID);
IAuxiliary auxiliary = new MappingAuxiliary(_container, auxCycleData, auxData.Data);
tmp = AddComponent(tmp, auxiliary);
}
}
// connect directAux --> engine
IAuxiliary directAux = new DirectAuxiliary(_container, new AuxiliaryCycleDataAdapter(data.Cycle));
directAux.InShaft().Connect(engine.OutShaft());
// connect aux --> ... --> aux_XXX --> directAux
var previousAux = directAux;
foreach (var auxData in data.Aux) {
var auxCycleData = new AuxiliaryCycleDataAdapter(data.Cycle, auxData.ID);
IAuxiliary auxiliary = new MappingAuxiliary(_container, auxCycleData, auxData.Data);
auxiliary.InShaft().Connect(previousAux.OutShaft());
previousAux = auxiliary;
}
tmp = AddComponent(tmp, directAux);
// connect clutch --> aux
clutch.InShaft().Connect(previousAux.OutShaft());
AddComponent(tmp, new CombustionEngine(_container, data.EngineData));
return _container;
}
protected IGearbox GetGearbox(VehicleContainer container, GearboxData data)
{
switch (data.Type) {
case GearboxData.GearboxType.AT:
throw new VectoSimulationException("Unsupported Geabox type: Automatic Transmission (AT)");
case GearboxData.GearboxType.Custom:
throw new VectoSimulationException("Custom Gearbox not supported");
default:
return new Gearbox(container, data);
}
}
protected virtual IDriver AddComponent(IDrivingCycleDemandDrivingCycle prev, IDriver next)
{
prev.InShaft().Connect(next.OutShaft());
return next;
}
protected virtual IVehicle AddComponent(IDriver prev, IVehicle next)
{
prev.InShaft().Connect(next.OutShaft());
return next;
}
protected virtual IWheels AddComponent(IRoadPortInProvider prev, IWheels next)
{
prev.InPort().Connect(next.OutPort());
return next;
}
protected virtual IPowerTrainComponent AddComponent(IWheels prev, IPowerTrainComponent next)
{
prev.InShaft().Connect(next.OutShaft());
return next;
}
protected virtual IPowerTrainComponent AddComponent(IPowerTrainComponent prev, IPowerTrainComponent next)
{
prev.InShaft().Connect(next.OutShaft());
return next;
}
protected virtual void AddComponent(IPowerTrainComponent prev, IOutShaft next)
{
prev.InShaft().Connect(next.OutShaft());
}
private VehicleContainer BuildEngineOnly(VectoRunData data)
{
var cycle = new EngineOnlyDrivingCycle(_container, data.Cycle);
......@@ -96,72 +139,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
cycle.InShaft().Connect(gearBox.OutShaft());
return _container;
//var simulator = new VectoRun(_container, cycle);
//return simulator;
}
// public void AddCycle(string cycleFile) {}
// public void AddEngine(CombustionEngineData data)
// {
// _engine = new CombustionEngine(_container, data);
// AddClutch(data);
// }
// public void AddClutch(CombustionEngineData engineData)
// {
// _clutch = new Clutch(_container, engineData);
// }
public IGearbox AddGearbox(GearboxData gearboxData)
{
//_axleGear = new AxleGear(gearboxData.AxleGearData);
switch (gearboxData.Type) {
case GearboxData.GearboxType.MT:
return new Gearbox(_container, gearboxData);
case GearboxData.GearboxType.AMT:
return new Gearbox(_container, gearboxData);
/* case GearboxData.GearboxType.AT:
_dataWriter.HasTorqueConverter = gearboxData.HasTorqueConverter;
break;
*/
default:
throw new VectoException(String.Format("Gearboxtype {0} not implemented", gearboxData.Type));
}
}
// public void AddAuxiliary(string auxFileName, string auxID)
// {
// _auxDict[auxID] = AuxiliaryData.ReadFromFile(auxFileName);
// }
// public void AddDriver(VectoRunData.StartStopData startStop,
// VectoRunData.OverSpeedEcoRollData overSpeedEcoRoll,
// VectoRunData.LACData lookAheadCoasting, string accelerationLimitingFile)
// {
// if (_engineOnly) {
// return;
// }
// var driverData = new DriverData(startStop, overSpeedEcoRoll, lookAheadCoasting, accelerationLimitingFile);
// _driver = new Driver(driverData);
// }
// public void AddVehicle(VehicleData data)
// {
// if (_engineOnly) {
// return;
// }
// _vehicle = new Vehicle(_container, data);
// }
// public void AddRetarder(string retarderFile)
// {
// var retarderData = RetarderLossMap.ReadFromFile(retarderFile);
// _retarder = new Retarder(_container, retarderData);
// }
}
}
\ No newline at end of file
......@@ -2,8 +2,8 @@
namespace TUGraz.VectoCore.Models.SimulationComponent
{
/// <summary>
/// Defines interfaces for auxiliary components.
/// </summary>
public interface IAuxiliary : IInShaft, IOutShaft {}
/// <summary>
/// Defines interfaces for auxiliary components.
/// </summary>
public interface IAuxiliary : IPowerTrainComponent {}
}
\ No newline at end of file
......@@ -3,8 +3,8 @@ using TUGraz.VectoCore.Models.Simulation.Cockpit;
namespace TUGraz.VectoCore.Models.SimulationComponent
{
/// <summary>
/// Defines interfaces for a gearbox.
/// </summary>
public interface IGearbox : IInShaft, IOutShaft, IGearboxCockpit {}
/// <summary>
/// Defines interfaces for a gearbox.
/// </summary>
public interface IGearbox : IPowerTrainComponent, IGearboxCockpit {}
}
\ No newline at end of file
......@@ -4,8 +4,4 @@ using TUGraz.VectoCore.Models.Simulation.Cockpit;
namespace TUGraz.VectoCore.Models.SimulationComponent
{
public interface IVehicle : IRoadPortInProvider, IDriverDemandOutProvider, IVehicleCockpit {}
}
/// </summary>
// public interface IVehicle : IDriverDemandOutProvider, IRoadPortInProvider {}
//}
\ No newline at end of file
}
\ No newline at end of file
using System;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.Simulation.Impl;
using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public class AxleGear : IPowerTrainComponent, ITnInPort, ITnOutPort
public class AxleGear : VectoSimulationComponent, IPowerTrainComponent, ITnInPort, ITnOutPort
{
private ITnOutPort _nextComponent;
private readonly GearData _gearData;
public AxleGear(GearData gearData)
public AxleGear(VehicleContainer container, GearData gearData) : base(container)
{
_gearData = gearData;
}
......@@ -36,5 +38,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
_gearData.LossMap.GearboxInTorque(angularVelocity * _gearData.Ratio, torque),
angularVelocity * _gearData.Ratio);
}
public override void CommitSimulationStep(IModalDataWriter writer)
{
// nothing to commit
}
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ using System;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.Simulation.Impl;
using TUGraz.VectoCore.Models.SimulationComponent;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils;
......@@ -9,19 +10,21 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public class Driver : VectoSimulationComponent, IDriver, IDrivingCycleDemandOutPort, IDriverDemandInPort
{
protected IDriverDemandOutPort _other;
public Driver(VehicleContainer container, DriverData driverData) : base(container)
{
throw new NotImplementedException();
//throw new NotImplementedException();
}
public IDriverDemandInPort InShaft()
{
throw new NotImplementedException();
return this;
}
public void Connect(IDriverDemandOutPort other)
{
throw new NotImplementedException();
_other = other;
}
public IResponse Request(TimeSpan absTime, TimeSpan dt, MeterPerSecond velocity, Radian gradient)
......@@ -37,7 +40,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public IDrivingCycleDemandOutPort OutShaft()
{
throw new NotImplementedException();
return this;
}
public override void CommitSimulationStep(IModalDataWriter writer) {}
......
......@@ -10,6 +10,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public class Gearbox : VectoSimulationComponent, IGearbox, ITnOutPort, ITnInPort
{
protected ITnOutPort Next;
protected GearboxData Data;
public Gearbox(IVehicleContainer container, GearboxData gearboxData) : base(container)
......@@ -21,7 +23,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public ITnInPort InShaft()
{
throw new NotImplementedException();
return this;
}
#endregion
......@@ -30,7 +32,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public ITnOutPort OutShaft()
{
throw new NotImplementedException();
return this;
}
#endregion
......@@ -57,7 +59,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
void ITnInPort.Connect(ITnOutPort other)
{
throw new NotImplementedException();
Next = other;
}
#endregion
......
......@@ -22,7 +22,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
var vehicle = new VehicleContainer();
var gbxData = EngineeringModeSimulationDataReader.CreateGearboxDataFromFile(GearboxDataFile);
//GearData gearData = new GearData();
var axleGear = new AxleGear(gbxData.AxleGearData);
var axleGear = new AxleGear(vehicle, gbxData.AxleGearData);
var mockPort = new MockTnOutPort();
axleGear.InShaft().Connect(mockPort);
......
This diff is collapsed.
......@@ -11,9 +11,7 @@
"EngineFile": "../Components/24t Coach.veng",
"GearboxFile": "../Components/24t Coach.vgbx",
"Cycles": [
"TestData/Cycles/Engine Only1.vdri",
"TestData/Cycles/Engine Only2.vdri",
"TestData/Cycles/Engine Only3.vdri"
"../Cycles/Coach_24t_xshort.vdri"
],
"VACC": "TestData/Components/Coach.vacc",
"EngineOnlyMode": true,
......
......@@ -163,6 +163,9 @@
<None Include="TestData\Components\Retarder.vrlm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Cycles\Coach_24t_xshort.vdri">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Cycles\LOT2_rural Engine Only.vmod">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......
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