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

Merge pull request #323 in VECTO/vecto-sim from...

Merge pull request #323 in VECTO/vecto-sim from ~EMQUARIMA/vecto-sim:feature/VECTO-384-code-for-running-doe-batch-from to develop

* commit '50e6e5b1':
  cleanin up memory after simulation
  clear mod-data when simulation is done and sum-entry is written
parents 45c9cc24 50e6e5b1
No related branches found
No related tags found
No related merge requests found
Showing
with 235 additions and 167 deletions
......@@ -439,7 +439,9 @@ Public Class Gearbox
Return PSShiftTime.SI (Of Second)()
End Get
End Property
Public ReadOnly Property PowerShiftInertiaFactor As Double Implements IGearboxEngineeringInputData.PowerShiftInertiaFactor
Public ReadOnly Property PowerShiftInertiaFactor As Double _
Implements IGearboxEngineeringInputData.PowerShiftInertiaFactor
Get
Return PSInertiaFactor
End Get
......
......@@ -253,7 +253,10 @@ Public Class VectoJob
RessourceHelper.ReadStream(
DeclarationData.DeclarationDataResourcePrefix + ".VACC." + _driverAccelerationFile.OriginalPath +
VectoCore.Configuration.Constants.FileExtensions.DriverAccelerationCurve)
Return VectoCSVFile.ReadStream(cycleDataRes)
Return _
VectoCSVFile.ReadStream(cycleDataRes,
source:=DeclarationData.DeclarationDataResourcePrefix + ".VACC." + _driverAccelerationFile.OriginalPath +
VectoCore.Configuration.Constants.FileExtensions.DriverAccelerationCurve)
Catch ex As Exception
Return Nothing
End Try
......@@ -617,10 +620,10 @@ Public Class VectoJob
cycleData = VectoCSVFile.Read(cycleFile.FullPath)
Else
Try
Dim cycleDataRes As Stream =
RessourceHelper.ReadStream(
DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + cycleFile.OriginalPath + ".vdri")
cycleData = VectoCSVFile.ReadStream(cycleDataRes)
Dim resourceName As String = DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." +
cycleFile.OriginalPath + TUGraz.VectoCore.Configuration.Constants.FileExtensions.CycleFile
Dim cycleDataRes As Stream = RessourceHelper.ReadStream(resourceName)
cycleData = VectoCSVFile.ReadStream(cycleDataRes, source:=resourceName)
Catch ex As Exception
Throw New VectoException("Driving Cycle could not be read: " + cycleFile.OriginalPath)
End Try
......
......@@ -35,9 +35,9 @@ namespace TUGraz.VectoCommon.InputData
{
public class TableData : DataTable
{
public TableData(string fileName)
public TableData(string fileName, DataSourceType sourceType = DataSourceType.CSVFile)
{
SourceType = DataSourceType.CSVFile;
SourceType = sourceType;
Source = fileName;
}
......
......@@ -277,10 +277,10 @@ Examples:
Environment.ExitCode = Environment.ExitCode != 0 ? Environment.ExitCode : 1;
}
#if DEBUG
//#if DEBUG
Console.WriteLine("done.");
Console.ReadKey();
#endif
//#endif
return Environment.ExitCode;
}
......
......@@ -30,5 +30,5 @@
*/
using System.Reflection;
[assembly: AssemblyVersion("3.1.0.683")]
[assembly: AssemblyFileVersion("3.1.0.683")]
[assembly: AssemblyVersion("3.1.0.718")]
[assembly: AssemblyFileVersion("3.1.0.718")]
......@@ -343,10 +343,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
cycleData = VectoCSVFile.Read(cycleFile);
} else {
try {
var cycleDataRes =
RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." +
cycle.Value<string>() + ".vdri");
cycleData = VectoCSVFile.ReadStream(cycleDataRes);
var resourceName = DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." +
cycle.Value<string>() + Constants.FileExtensions.CycleFile;
cycleData = VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceName), source: resourceName);
} catch {
Log.Debug("Driving Cycle could not be read: " + cycleFile);
throw new VectoException("Driving Cycle could not be read: " + cycleFile);
......@@ -483,11 +482,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
} catch (VectoException e) {
Log.Warn("Could not find file for acceleration curve. Trying lookup in declaration data.");
try {
var cycleDataRes =
RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".VACC." +
var resourceName = DeclarationData.DeclarationDataResourcePrefix + ".VACC." +
acceleration.Value<string>() +
Constants.FileExtensions.DriverAccelerationCurve);
return VectoCSVFile.ReadStream(cycleDataRes);
Constants.FileExtensions.DriverAccelerationCurve;
return VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceName), source: resourceName);
} catch (Exception) {
throw new VectoException("Failed to read Driver Acceleration Curve: " + e.Message, e);
}
......
......@@ -52,9 +52,9 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl
protected IDeclarationInputDataProvider InputDataProvider;
protected DeclarationReport Report;
protected IDeclarationReport Report;
internal DeclarationModeVectoRunDataFactory(IDeclarationInputDataProvider dataProvider, DeclarationReport report)
internal DeclarationModeVectoRunDataFactory(IDeclarationInputDataProvider dataProvider, IDeclarationReport report)
{
InputDataProvider = dataProvider;
Report = report;
......@@ -112,7 +112,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl
AngledriveData = angledriveData,
Aux = dao.CreateAuxiliaryData(InputDataProvider.AuxiliaryInputData(), mission.MissionType,
segment.VehicleClass),
Cycle = cycle,
Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()),
Retarder = retarderData,
DriverData = driverdata,
ExecutionMode = ExecutionMode.Declaration,
......@@ -123,7 +123,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl
};
simulationRunData.EngineData.WHTCCorrectionFactor = DeclarationData.WHTCCorrection.Lookup(mission.MissionType,
engineData.WHTCRural, engineData.WHTCUrban, engineData.WHTCMotorway) * engineData.ColdHotCorrectionFactor;
simulationRunData.Cycle.Name = mission.MissionType.ToString();
//simulationRunData.Cycle.Name = mission.MissionType.ToString();
simulationRunData.VehicleData.VehicleClass = segment.VehicleClass;
yield return simulationRunData;
}
......
using System.Collections.Generic;
using System.Linq;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
namespace TUGraz.VectoCore.InputData.Reader.Impl
{
public class DrivingCycleProxy : IDrivingCycleData
{
public DrivingCycleProxy(DrivingCycleData cycle, string name)
{
Name = name;
CycleType = cycle.CycleType;
Entries = cycle.Entries;
}
public List<DrivingCycleData.DrivingCycleEntry> Entries { get; private set; }
public string Name { get; private set; }
public CycleType CycleType { get; private set; }
public void Finish()
{
Entries = new List<DrivingCycleData.DrivingCycleEntry>() {
Entries.First(),
Entries.Last()
};
}
}
}
\ No newline at end of file
......@@ -53,7 +53,9 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl
var simulationRunData = new VectoRunData {
JobName = InputDataProvider.JobInputData().JobName,
EngineData = dao.CreateEngineData(InputDataProvider.EngineInputData, null),
Cycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, CycleType.EngineOnly, cycle.Name, false),
Cycle =
new DrivingCycleProxy(
DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, CycleType.EngineOnly, cycle.Name, false), cycle.Name),
ExecutionMode = ExecutionMode.Engineering
};
yield return simulationRunData;
......
......@@ -44,8 +44,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl
{
public class EngineeringModeVectoRunDataFactory : LoggingObject, IVectoRunDataFactory
{
// todo mk-2016-10-11: field is never used. Delete?
protected DriverData Driver;
private static readonly Dictionary<string, DrivingCycleData> CyclesCache = new Dictionary<string, DrivingCycleData>();
protected readonly IEngineeringInputDataProvider InputDataProvider;
......@@ -74,7 +73,15 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl
var angledriveData = dao.CreateAngledriveData(InputDataProvider.AngledriveInputData, useEfficiencyFallback: true);
var ptoTransmissionData = dao.CreatePTOTransmissionData(InputDataProvider.PTOTransmissionInputData);
return InputDataProvider.JobInputData().Cycles.Select(cycle => new VectoRunData {
return InputDataProvider.JobInputData().Cycles.Select(cycle => {
DrivingCycleData drivingCycle;
if (CyclesCache.ContainsKey(cycle.CycleData.Source)) {
drivingCycle = CyclesCache[cycle.CycleData.Source];
} else {
drivingCycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, crossWindRequired);
CyclesCache.Add(cycle.CycleData.Source, drivingCycle);
}
return new VectoRunData {
JobName = InputDataProvider.JobInputData().JobName,
EngineData = engineData,
GearboxData = gearboxData,
......@@ -86,8 +93,9 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl
AdvancedAux = dao.CreateAdvancedAuxData(InputDataProvider.AuxiliaryInputData()),
Retarder = dao.CreateRetarderData(InputDataProvider.RetarderInputData),
PTO = ptoTransmissionData,
Cycle = DrivingCycleDataReader.ReadFromDataTable(cycle.CycleData, cycle.Name, crossWindRequired),
Cycle = new DrivingCycleProxy(drivingCycle, cycle.Name),
ExecutionMode = ExecutionMode.Engineering
};
});
}
}
......
......@@ -449,7 +449,7 @@ namespace TUGraz.VectoCore.Models.Declaration
public static IEnumerable<TorqueConverterEntry> GetTorqueConverterDragCurve(double ratio)
{
var resourceId = DeclarationData.DeclarationDataResourcePrefix + ".TorqueConverter.csv";
var data = VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceId));
var data = VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceId), source: resourceId);
var characteristicTorque = (from DataRow row in data.Rows
select
new TorqueConverterEntry() {
......
......@@ -56,7 +56,7 @@ namespace TUGraz.VectoCore.Models.Declaration
protected static DataTable ReadCsvResource(string resourceId)
{
return VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceId));
return VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceId), source: resourceId);
}
protected static void NormalizeTable(DataTable table)
......
......@@ -105,7 +105,9 @@ namespace TUGraz.VectoCore.Models.Declaration
VehicleCategory = vehicleCategory,
AxleConfiguration = axleConfiguration,
VehicleClass = VehicleClassHelper.Parse(row.Field<string>("hdvclass")),
AccelerationFile = RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".VACC." + row.Field<string>(".vaccfile")),
AccelerationFile =
RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".VACC." +
row.Field<string>(".vaccfile")),
Missions = CreateMissions(ref grossVehicleMassRating, curbWeight, row),
GrossVehicleMassRating = grossVehicleMassRating
};
......@@ -155,7 +157,9 @@ namespace TUGraz.VectoCore.Models.Declaration
var mission = new Mission {
MissionType = missionType,
CrossWindCorrection = row.Field<string>("crosswindcorrection" + GetMissionSuffix(missionType)),
CycleFile = RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + missionType + ".vdri"),
CycleFile =
RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + missionType +
Constants.FileExtensions.CycleFile),
AxleWeightDistribution = GetAxleWeightDistribution(row, missionType),
CurbWeight = curbWeight,
BodyCurbWeight = body.CurbWeight,
......
......@@ -62,17 +62,13 @@ namespace TUGraz.VectoCore.Models.Simulation.Data
public AngledriveData AngledriveData { get; internal set; }
[Required, ValidateObject]
public DrivingCycleData Cycle { get; internal set; }
public IDrivingCycleData Cycle { get; internal set; }
[ValidateObject]
public IEnumerable<AuxData> Aux { get; internal set; }
public AdvancedAuxData AdvancedAux { get; internal set; }
// todo mk 2016-08-30: property is never used. Delete?
[ValidateObject]
public string AccelerationLimitingFile { get; internal set; }
[ValidateObject]
public RetarderData Retarder { get; internal set; }
......@@ -90,7 +86,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Data
public string ModFileSuffix { get; set; }
[ValidateObject]
public DeclarationReport Report { get; set; }
public IDeclarationReport Report { get; set; }
[Required, ValidateObject]
public LoadingType Loading { get; set; }
......@@ -141,8 +137,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Data
for (var angularVelocity = engineData.IdleSpeed;
angularVelocity < engineData.FullLoadCurve.RatedSpeed;
angularVelocity += 2.0 / 3.0 * (engineData.FullLoadCurve.RatedSpeed - engineData.IdleSpeed) / 10.0) {
if (!gear.Value.HasLockedGear)
if (!gear.Value.HasLockedGear) {
continue;
}
var velocity = angularVelocity / gear.Value.Ratio / angledriveRatio / axlegearRatio * dynamicTyreRadius;
......@@ -195,9 +192,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Data
}
if (runData.Cycle != null && runData.Cycle.Entries.Any(e => e.PTOActive)) {
if (runData.PTO == null || runData.PTO.PTOCycle == null)
if (runData.PTO == null || runData.PTO.PTOCycle == null) {
return new ValidationResult("PTOCycle is used in DrivingCycle, but is not defined in Vehicle-Data.");
}
}
return ValidationResult.Success;
}
......
......@@ -71,6 +71,6 @@ namespace TUGraz.VectoCore.Models.Simulation
/// <summary>
/// Finishes the simulation.
/// </summary>
void FinishSimulation();
new void FinishSimulation();
}
}
\ No newline at end of file
......@@ -57,7 +57,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
private readonly bool _engineOnlyMode;
public SimulatorFactory(ExecutionMode mode, IInputDataProvider dataProvider, IOutputDataWriter writer,
DeclarationReport declarationReport = null)
IDeclarationReport declarationReport = null)
{
Log.Info("########## VectoCore Version {0} ##########", Assembly.GetExecutingAssembly().GetName().Version);
JobNumber = Interlocked.Increment(ref _jobNumberCounter);
......@@ -125,6 +125,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
foreach (var data in DataReader.NextRun()) {
var d = data;
if (d.Report != null) {
d.Report.PrepareResult(d.Loading, d.Mission);
}
Action<ModalDataContainer> addReportResult = writer => {
if (d.Report != null) {
d.Report.AddResult(d.Loading, d.Mission, writer);
......@@ -174,7 +177,5 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
yield return run;
}
}
}
}
\ No newline at end of file
......@@ -318,6 +318,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
ModData.Finish(RunStatus);
WriteSumData(ModData, VehicleMass, VehicleLoading);
ModData.FinishSimulation();
DrivingCycle.FinishSimulation();
}
public VectoRun.Status RunStatus { get; set; }
......
......@@ -58,8 +58,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
}
}
public interface IDrivingCycleData
{
List<DrivingCycleData.DrivingCycleEntry> Entries { get; }
string Name { get; }
CycleType CycleType { get; }
void Finish();
}
[CustomValidation(typeof(DrivingCycleData), "ValidateCycleData")]
public class DrivingCycleData : SimulationComponentData
public class DrivingCycleData : SimulationComponentData, IDrivingCycleData
{
internal DrivingCycleData() {}
......@@ -69,6 +77,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public CycleType CycleType { get; internal set; }
public void Finish() {}
// ReSharper disable once UnusedMember.Global -- used by Validation
public static ValidationResult ValidateCycleData(DrivingCycleData cycleData, ValidationContext validationContext)
{
......
......@@ -61,5 +61,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent
IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance);
IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Second time);
void FinishSimulation();
}
}
\ No newline at end of file
......@@ -54,7 +54,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
IDrivingCycle, ISimulationOutPort, IDrivingCycleInPort, IDisposable
{
private const double LookaheadTimeSafetyMargin = 1.5;
private readonly DrivingCycleData _data;
private readonly IDrivingCycleData _data;
internal readonly DrivingCycleEnumerator CycleIntervalIterator;
private bool _intervalProlonged;
internal IdleControllerSwitcher IdleController;
......@@ -69,7 +69,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
get { return CycleIntervalIterator.RightSample; }
}
public DistanceBasedDrivingCycle(IVehicleContainer container, DrivingCycleData cycle) : base(container)
public DistanceBasedDrivingCycle(IVehicleContainer container, IDrivingCycleData cycle) : base(container)
{
_data = cycle;
CycleIntervalIterator = new DrivingCycleEnumerator(_data);
......@@ -282,8 +282,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if (!stopTime.IsEqual(0) && stopTime.IsEqual(PreviousState.WaitTime)) {
// we needed to stop at the current interval in the cycle and have already waited enough time, move on..
if (IdleController != null)
if (IdleController != null) {
IdleController.ActivateIdle();
}
CycleIntervalIterator.MoveNext();
}
......@@ -303,8 +304,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
} else {
if (stopTime.IsEqual(PreviousState.WaitTime)) {
// we needed to stop at the current interval in the cycle and have already waited enough time, move on..
if (IdleController != null)
if (IdleController != null) {
IdleController.ActivateIdle();
}
CycleIntervalIterator.MoveNext();
}
}
......@@ -408,6 +410,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return LookAhead(LookaheadTimeSafetyMargin * DataBus.VehicleSpeed * time);
}
public void FinishSimulation()
{
_data.Finish();
}
public CycleData CycleData
{
get
......@@ -480,9 +487,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public sealed class DrivingCycleEnumerator : IEnumerator<DrivingCycleData.DrivingCycleEntry>
{
private int _currentCycleIndex;
private readonly DrivingCycleData _data;
private readonly IDrivingCycleData _data;
public DrivingCycleEnumerator(DrivingCycleData data)
public DrivingCycleEnumerator(IDrivingCycleData data)
{
_currentCycleIndex = 0;
_data = data;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment