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

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

DrivingCycle Reader: add stop time for first entry if stop-time is 0,...

DrivingCycle Reader: add stop time for first entry if stop-time is 0, duplicate entries with stop-time = 0
parent 61d1c090
No related branches found
No related tags found
No related merge requests found
......@@ -213,6 +213,9 @@ namespace TUGraz.VectoCore.InputData.Reader
var altitude = current.Altitude;
for (var i = 0; i < entries.Count; i++) {
var entry = entries[i];
if (i == 0 && entry.VehicleTargetSpeed.IsEqual(0) && entry.StoppingTime.IsEqual(0)) {
entry.StoppingTime = 1.SI<Second>();
}
if (!entry.StoppingTime.IsEqual(0) && !entry.VehicleTargetSpeed.IsEqual(0)) {
throw new VectoException(
"Error in DrivingCycle: stop time specified but target-speed > 0! Distance: {0}, stop-time: {1}, target speed: {2}",
......@@ -233,7 +236,7 @@ namespace TUGraz.VectoCore.InputData.Reader
filtered.Add(entry);
current = entry;
}
if (!entry.StoppingTime.IsEqual(0) && entry.VehicleTargetSpeed.IsEqual(0)) {
if (entry.VehicleTargetSpeed.IsEqual(0)) {
// vehicle stops. duplicate current distance entry with 0 waiting time
var tmp = new DrivingCycleData.DrivingCycleEntry(entry) {
StoppingTime = 0.SI<Second>(),
......
......@@ -30,16 +30,16 @@
*/
using System;
using System.Collections.Generic;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public sealed class DrivingCycleEnumerator : IEnumerator<DrivingCycleData.DrivingCycleEntry>
{
private int _currentCycleIndex;
private readonly IDrivingCycleData _data;
using System.Collections.Generic;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public sealed class DrivingCycleEnumerator : IEnumerator<DrivingCycleData.DrivingCycleEntry>
{
private int _currentCycleIndex;
private readonly IDrivingCycleData _data;
public DrivingCycleEnumerator(IDrivingCycleData data)
{
_currentCycleIndex = 0;
......@@ -52,59 +52,59 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var retVal = new DrivingCycleEnumerator(_data);
retVal._currentCycleIndex = Math.Max(0, _currentCycleIndex - 1);
return retVal;
}
public DrivingCycleEnumerator Clone()
{
return new DrivingCycleEnumerator(_data) {
_currentCycleIndex = _currentCycleIndex,
LastEntry = LastEntry
};
}
public DrivingCycleData.DrivingCycleEntry Current
{
get { return LeftSample; }
}
public DrivingCycleData.DrivingCycleEntry LeftSample
{
get { return _data.Entries[_currentCycleIndex]; }
}
public DrivingCycleData.DrivingCycleEntry RightSample
{
get { return _currentCycleIndex + 1 >= _data.Entries.Count ? null : _data.Entries[_currentCycleIndex + 1]; }
}
public bool LastEntry { get; private set; }
object System.Collections.IEnumerator.Current
{
get { return LeftSample; }
}
public bool MoveNext()
{
// cycleIndex has to be max. next to last (so that rightSample is still valid.
if (_currentCycleIndex >= _data.Entries.Count - 2) {
LastEntry = true;
return false;
}
_currentCycleIndex++;
if (_currentCycleIndex == _data.Entries.Count - 2) {
LastEntry = true;
}
return true;
}
public void Reset()
{
_currentCycleIndex = 0;
LastEntry = false;
}
public void Dispose() {}
}
}
public DrivingCycleEnumerator Clone()
{
return new DrivingCycleEnumerator(_data) {
_currentCycleIndex = _currentCycleIndex,
LastEntry = LastEntry
};
}
public DrivingCycleData.DrivingCycleEntry Current
{
get { return LeftSample; }
}
public DrivingCycleData.DrivingCycleEntry LeftSample
{
get { return _data.Entries[_currentCycleIndex]; }
}
public DrivingCycleData.DrivingCycleEntry RightSample
{
get { return _currentCycleIndex + 1 >= _data.Entries.Count ? null : _data.Entries[_currentCycleIndex + 1]; }
}
public bool LastEntry { get; private set; }
object System.Collections.IEnumerator.Current
{
get { return LeftSample; }
}
public bool MoveNext()
{
// cycleIndex has to be max. next to last (so that rightSample is still valid.
if (_currentCycleIndex >= _data.Entries.Count - 2) {
LastEntry = true;
return false;
}
_currentCycleIndex++;
if (_currentCycleIndex == _data.Entries.Count - 2) {
LastEntry = true;
}
return true;
}
public void Reset()
{
_currentCycleIndex = 0;
LastEntry = false;
}
public void Dispose() {}
}
}
\ No newline at end of file
......@@ -79,8 +79,8 @@ namespace TUGraz.VectoCore.OutputData
public bool WriteAdvancedAux { get; set; }
public ModalDataContainer(string runName, FuelType fuel, IModalDataWriter writer, bool writeEngineOnly = false)
: this(0, runName, "", fuel, "", writer, _ => { }, writeEngineOnly) {}
public ModalDataContainer(string runName, FuelType fuel, IModalDataWriter writer, bool writeEngineOnly = false, params IModalDataFilter[] filters)
: this(0, runName, "", fuel, "", writer, _ => { }, writeEngineOnly, filters) {}
public ModalDataContainer(VectoRunData runData, IModalDataWriter writer, Action<ModalDataContainer> addReportResult,
bool writeEngineOnly, params IModalDataFilter[] filter)
......
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