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

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

new search method to look up auxiliary power demand

parent 16d62572
No related branches found
No related tags found
No related merge requests found
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using Common.Logging;
......@@ -10,14 +11,21 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public class AuxiliariesDemandAdapter
{
private readonly DrivingCycleData _drivingCycle;
private IEnumerator<DrivingCycleData.DrivingCycleEntry> _nextCycleEntry;
private readonly string _auxiliaryId;
protected DrivingCycleData.DrivingCycleEntry CurrentCycleEntry { get; set; }
//protected DrivingCycleData.DrivingCycleEntry NextCycleEntry { get { return _nextCycleEntry.Current; } }
private ILog Log;
public AuxiliariesDemandAdapter(DrivingCycleData inputData, string column = null)
{
Log = LogManager.GetLogger(this.GetType());
_drivingCycle = inputData;
_nextCycleEntry = _drivingCycle.Entries.GetEnumerator();
_nextCycleEntry.MoveNext();
CurrentCycleEntry = _drivingCycle.Entries.First();
_auxiliaryId = column;
if (_auxiliaryId != null && !_drivingCycle.Entries.First().AuxiliarySupplyPower.ContainsKey(_auxiliaryId)) {
Log.ErrorFormat("driving cycle data does not contain column {0}", column);
......@@ -27,12 +35,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public Watt GetPowerDemand(TimeSpan absTime, TimeSpan dt)
{
//var entry = _drivingCycle.Entries.FindLastIndex(x => x.Time <= absTime.TotalSeconds);
/* if (entry == -1) {
Log.ErrorFormat("time: {0} could not find power demand for auxiliary {1}", absTime.TotalSeconds, _auxiliaryId);
throw new VectoSimulationException(String.Format("time: {0} could not find power demand for auxiliary {1}", absTime.TotalSeconds, _auxiliaryId));
} */
return 0.SI<Watt>(); //_auxiliaryId == null ? _drivingCycle.Entries[entry].AdditionalAuxPowerDemand : _drivingCycle.Entries[entry].AuxiliarySupplyPower[_auxiliaryId];
if (_nextCycleEntry.Current.Time <= absTime.TotalSeconds) {
CurrentCycleEntry = _nextCycleEntry.Current;
_nextCycleEntry.MoveNext();
}
return String.IsNullOrEmpty(_auxiliaryId) ? CurrentCycleEntry.AdditionalAuxPowerDemand : CurrentCycleEntry.AuxiliarySupplyPower[_auxiliaryId];
}
}
......
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