diff --git a/VectoCore/VectoCore/Models/Declaration/AirDrag.cs b/VectoCore/VectoCore/Models/Declaration/AirDrag.cs index 780d6a1e9312604b0761aa7f00fe93c461884e8a..119d3bf3d44e59d7c49d8fb7c5926f2f053aaa89 100644 --- a/VectoCore/VectoCore/Models/Declaration/AirDrag.cs +++ b/VectoCore/VectoCore/Models/Declaration/AirDrag.cs @@ -37,9 +37,9 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class AirDrag : LookupData<string, AirDrag.AirDragEntry> + public sealed class AirDrag : LookupData<string, AirDrag.AirDragEntry> { - protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VCDV.parameters.csv"; + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VCDV.parameters.csv"; public AirDrag() { diff --git a/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs b/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs index 2b455f077a6d186f4471983e9b53a7e44b297eee..f183e9e5037932a2181b08dee8253d23cedf908d 100644 --- a/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs +++ b/VectoCore/VectoCore/Models/Declaration/ElectricSystem.cs @@ -38,18 +38,16 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class ElectricSystem : LookupData<MissionType, string[], Watt> + public sealed class ElectricSystem : LookupData<MissionType, string[], Watt> { private readonly Alternator _alternator = new Alternator(); + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.ES-Tech.csv"; private const string BaseLine = "Baseline electric power consumption"; private readonly Dictionary<Tuple<MissionType, string>, Watt> _data = new Dictionary<Tuple<MissionType, string>, Watt>(); - - protected string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.ES-Tech.csv"; - - + public ElectricSystem() { ParseData(ReadCsvResource(ResourceId)); @@ -86,16 +84,14 @@ namespace TUGraz.VectoCore.Models.Declaration return sum / _alternator.Lookup(missionType, null); } - private class Alternator : LookupData<MissionType, string, double> + private sealed class Alternator : LookupData<MissionType, string, double> { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.ALT-Tech.csv"; private const string Default = "Standard alternator"; private readonly Dictionary<Tuple<MissionType, string>, double> _data = new Dictionary<Tuple<MissionType, string>, double>(); - - protected string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.ALT-Tech.csv"; - - + public Alternator() { ParseData(ReadCsvResource(ResourceId)); diff --git a/VectoCore/VectoCore/Models/Declaration/Fan.cs b/VectoCore/VectoCore/Models/Declaration/Fan.cs index e9e43e1f4a726ffc9df0b2286762090300e95143..e3aa0a43a97d57fcd0f3d4ba88e92d9c0142f798 100644 --- a/VectoCore/VectoCore/Models/Declaration/Fan.cs +++ b/VectoCore/VectoCore/Models/Declaration/Fan.cs @@ -38,15 +38,14 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class Fan : LookupData<MissionType, string, Watt> + public sealed class Fan : LookupData<MissionType, string, Watt> { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.Fan-Tech.csv"; + private const string DefaultTechnology = "Crankshaft mounted - Electronically controlled visco clutch (Default)"; + private readonly Dictionary<Tuple<MissionType, string>, Watt> _data = new Dictionary<Tuple<MissionType, string>, Watt>(); - - private const string DefaultTechnology = "Crankshaft mounted - Electronically controlled visco clutch (Default)"; - - protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.Fan-Tech.csv"; - + public Fan() { ParseData(ReadCsvResource(ResourceId)); diff --git a/VectoCore/VectoCore/Models/Declaration/HVAC.cs b/VectoCore/VectoCore/Models/Declaration/HVAC.cs index acb6fc93fd71ba0950c9a3c01ea6c815a6e81e7d..a0a8201492a396b12f2384b124967d85c7791de2 100644 --- a/VectoCore/VectoCore/Models/Declaration/HVAC.cs +++ b/VectoCore/VectoCore/Models/Declaration/HVAC.cs @@ -38,13 +38,12 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class HeatingVentilationAirConditioning : LookupData<MissionType, VehicleClass, Watt> + public sealed class HeatingVentilationAirConditioning : LookupData<MissionType, VehicleClass, Watt> { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.HVAC-Table.csv"; private readonly Dictionary<Tuple<MissionType, VehicleClass>, Watt> _data = new Dictionary<Tuple<MissionType, VehicleClass>, Watt>(); - - protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.HVAC-Table.csv"; - + public HeatingVentilationAirConditioning() { ParseData(ReadCsvResource(ResourceId)); diff --git a/VectoCore/VectoCore/Models/Declaration/PT1.cs b/VectoCore/VectoCore/Models/Declaration/PT1.cs index b49fe0117a5f53d3637d087f4ea05721e9cae458..4aae13967b97b2653c79f6b757daf33df4a6af4f 100644 --- a/VectoCore/VectoCore/Models/Declaration/PT1.cs +++ b/VectoCore/VectoCore/Models/Declaration/PT1.cs @@ -38,12 +38,11 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class PT1 : LookupData<PerSecond, Second> + public sealed class PT1 : LookupData<PerSecond, Second> { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.PT1.csv"; private List<KeyValuePair<PerSecond, Second>> _entries; - - protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.PT1.csv"; - + public PT1() { ParseData(ReadCsvResource(ResourceId)); diff --git a/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs b/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs index 85dff29c258304e2e464c292585ec825db675344..3dbbfe6f2de33fe632be41abfe76b1a112c63b49 100644 --- a/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs +++ b/VectoCore/VectoCore/Models/Declaration/PneumaticSystem.cs @@ -38,13 +38,12 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class PneumaticSystem : LookupData<MissionType, VehicleClass, Watt> + public sealed class PneumaticSystem : LookupData<MissionType, VehicleClass, Watt> { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.PS-Table.csv"; private readonly Dictionary<Tuple<MissionType, VehicleClass>, Watt> _data = new Dictionary<Tuple<MissionType, VehicleClass>, Watt>(); - - protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.PS-Table.csv"; - + public PneumaticSystem() { ParseData(ReadCsvResource(ResourceId)); diff --git a/VectoCore/VectoCore/Models/Declaration/Segments.cs b/VectoCore/VectoCore/Models/Declaration/Segments.cs index 9ddc828128bb0c4a00000a44afcf50140d2a477f..03f5181a72a470d482d162a9059eb903303dc3bf 100644 --- a/VectoCore/VectoCore/Models/Declaration/Segments.cs +++ b/VectoCore/VectoCore/Models/Declaration/Segments.cs @@ -40,7 +40,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class Segments : LookupData<VehicleCategory, AxleConfiguration, Kilogram, Kilogram, Segment> + public sealed class Segments : LookupData<VehicleCategory, AxleConfiguration, Kilogram, Kilogram, Segment> { public Segments() { diff --git a/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs b/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs index 7f80fcd974cc6e0b0adf2e3e46944f116b217c74..4fbaf72c36eb87a08c36d975902cc3cc8fabf553 100644 --- a/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs +++ b/VectoCore/VectoCore/Models/Declaration/SteeringPump.cs @@ -39,15 +39,13 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class SteeringPump : LookupData<MissionType, VehicleClass, string, Watt> + public sealed class SteeringPump : LookupData<MissionType, VehicleClass, string, Watt> { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.SP-Table.csv"; private readonly SteeringPumpTechnologies _technologies = new SteeringPumpTechnologies(); - private readonly Dictionary<Tuple<MissionType, VehicleClass>, Watt[]> _data = new Dictionary<Tuple<MissionType, VehicleClass>, Watt[]>(); - - private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.SP-Table.csv"; - + public SteeringPump() { ParseData(ReadCsvResource(ResourceId)); @@ -87,7 +85,7 @@ namespace TUGraz.VectoCore.Models.Declaration } } - private class SteeringPumpTechnologies : LookupData<string, double[]> + private sealed class SteeringPumpTechnologies : LookupData<string, double[]> { private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.VAUX.SP-Tech.csv"; diff --git a/VectoCore/VectoCore/Models/Declaration/TorqueConverter.cs b/VectoCore/VectoCore/Models/Declaration/TorqueConverter.cs index 1458460b454dd04686ce0355b3b8bdd1bcd7ecfb..9aa9837f63135794a7a34dcb24ed659679b1d40c 100644 --- a/VectoCore/VectoCore/Models/Declaration/TorqueConverter.cs +++ b/VectoCore/VectoCore/Models/Declaration/TorqueConverter.cs @@ -36,19 +36,18 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class TorqueConverter : LookupData<double, TorqueConverter.TorqueConverterEntry> + public sealed class TorqueConverter : LookupData<double, TorqueConverter.TorqueConverterEntry> { - protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.DefaultTC.vtcc"; - - + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.DefaultTC.vtcc"; + public TorqueConverter() { ParseData(ReadCsvResource(ResourceId)); } - [Obsolete("Default Lookup not availabel. Use LookupMu or LookupTorque instead.", true)] - protected new TorqueConverterEntry Lookup(double key) + [Obsolete("Default Lookup not available. Use LookupMu or LookupTorque instead.", true)] + private new TorqueConverterEntry Lookup(double key) { throw new InvalidOperationException( "Default Lookup not available. Use TorqueConverter.LookupMu() or TorqueConverter.LookupTorque() instead."); diff --git a/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs b/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs index 652a10ca60fb55b41c9f57bd3118c98d9a9d8432..94a96663c4c72dba3a9fe8d550261d365995b2eb 100644 --- a/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs +++ b/VectoCore/VectoCore/Models/Declaration/WHTCCorrection.cs @@ -38,13 +38,12 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class WHTCCorrection : LookupData<MissionType, double, double, double, double> + public sealed class WHTCCorrection : LookupData<MissionType, double, double, double, double> { + private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.WHTC-Weighting-Factors.csv"; private readonly Dictionary<MissionType, WHTCCorrectionEntry> _data = new Dictionary<MissionType, WHTCCorrectionEntry>(); - - protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.WHTC-Weighting-Factors.csv"; - + public WHTCCorrection() { ParseData(ReadCsvResource(ResourceId)); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs index 6f907ef7137f98e6245f0777d3e4ba879f398382..d9169ad8d7d165a52b85a838830fc2eca7976ff2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/AuxiliaryData.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Data; @@ -44,7 +45,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { [CustomValidation(typeof(AuxiliaryData), "ValidateAuxMap")] - public class AuxiliaryData + public sealed class AuxiliaryData: IDisposable { [Required, Range(double.Epsilon, 1)] public double EfficiencyToSupply { get; set; } @@ -192,6 +193,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data } return ValidationResult.Success; } + + public void Dispose() + { + _map.Dispose(); + } } public class AdvancedAuxData diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs index c5395b4b4992dca8eea7c88c439e2e5f8660f0e6..32d9b6f27bd29aa2200e31a4d881b134a5dd3f5a 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs @@ -40,7 +40,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine { - public class PT1Curve : LookupData<PerSecond, Second> + public sealed class PT1Curve : LookupData<PerSecond, Second> { private List<KeyValuePair<PerSecond, Second>> _entries; @@ -54,12 +54,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine return new PT1Curve(data); } - protected PT1Curve(DataTable data) + private PT1Curve(DataTable data) { ParseData(data); } - protected PT1Curve(string file) + private PT1Curve(string file) { DataTable data; try { @@ -100,7 +100,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine } } - protected bool HeaderIsValid(DataColumnCollection columns) + private bool HeaderIsValid(DataColumnCollection columns) { return columns.Contains(Fields.EngineSpeed) && columns.Contains(Fields.PT1); } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs index 06e28994308b07be560a98cfd40fc15abfe67463..f37bfc525ec973088e595025929b1df30a499bee 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs @@ -38,12 +38,11 @@ using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox { - public class TransmissionLossMap : LoggingObject + public sealed class TransmissionLossMap : LoggingObject, IDisposable { [ValidateObject] private readonly List<GearLossMapEntry> _entries; @@ -67,7 +66,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox get { return _lossMap.Extrapolated; } } - public string GearName { get; protected set; } + public string GearName { get; private set; } public static TransmissionLossMap ReadFromFile(string fileName, double gearRatio, string gearName) @@ -224,5 +223,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox /// <summary>[-]</summary> public const string Efficiency = "Eff"; } + + public void Dispose() + { + _lossMap.Dispose(); + _invertedLossMap.Dispose(); + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index 9e63593692e31c1abe1b88959bc96304b7ccbad3..f0db6c2284e483b91d6f58712cb45fbd210510b1 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -50,26 +50,26 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <summary> /// Class representing one Distance Based Driving Cycle /// </summary> - public class DistanceBasedDrivingCycle : StatefulVectoSimulationComponent<DistanceBasedDrivingCycle.DrivingCycleState>, - IDrivingCycle, - ISimulationOutPort, IDrivingCycleInPort, IRoadLookAhead + public sealed class DistanceBasedDrivingCycle : + StatefulVectoSimulationComponent<DistanceBasedDrivingCycle.DrivingCycleState>, IDrivingCycle, ISimulationOutPort, + IDrivingCycleInPort, IRoadLookAhead, IDisposable { - protected const double LookaheadTimeSafetyMargin = 1.5; - protected readonly DrivingCycleData Data; + private const double LookaheadTimeSafetyMargin = 1.5; + private readonly DrivingCycleData _data; internal readonly DrivingCycleEnumerator CycleIntervalIterator; - protected IDrivingCycleOutPort NextComponent; + private IDrivingCycleOutPort _nextComponent; - protected bool IntervalProlonged; + private bool _intervalProlonged; public DistanceBasedDrivingCycle(IVehicleContainer container, DrivingCycleData cycle) : base(container) { - Data = cycle; - CycleIntervalIterator = new DrivingCycleEnumerator(Data); - CycleStartDistance = Data.Entries.Count > 0 ? Data.Entries.First().Distance : 0.SI<Meter>(); + _data = cycle; + CycleIntervalIterator = new DrivingCycleEnumerator(_data); + CycleStartDistance = _data.Entries.Count > 0 ? _data.Entries.First().Distance : 0.SI<Meter>(); - var first = Data.Entries.First(); + var first = _data.Entries.First(); PreviousState = new DrivingCycleState { AbsTime = 0.SI<Second>(), WaitTime = 0.SI<Second>(), @@ -99,16 +99,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #region IDrivingCycleInPort - void IDrivingCycleInPort.Connect(IDrivingCycleOutPort other) + public void Connect(IDrivingCycleOutPort other) { - NextComponent = other; + _nextComponent = other; } #endregion #region ISimulationOutPort - IResponse ISimulationOutPort.Request(Second absTime, Meter ds) + public IResponse Request(Second absTime, Meter ds) { var retVal = DoHandleRequest(absTime, ds); CurrentState.Response = retVal; @@ -159,13 +159,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var remainingDistance = nextSpeedChange - PreviousState.Distance - ds; var estimatedRemainingTime = remainingDistance / DataBus.VehicleSpeed; - if (IntervalProlonged || remainingDistance.IsEqual(0.SI<Meter>()) || + if (_intervalProlonged || remainingDistance.IsEqual(0.SI<Meter>()) || estimatedRemainingTime.IsGreater(Constants.SimulationSettings.LowerBoundTimeInterval)) { return DriveDistance(absTime, ds); } Log.Debug("Extending distance by {0} to next sample point. ds: {1} new ds: {2}", remainingDistance, ds, nextSpeedChange - PreviousState.Distance); - IntervalProlonged = true; + _intervalProlonged = true; return new ResponseDrivingCycleDistanceExceeded { Source = this, MaxDistance = nextSpeedChange - PreviousState.Distance @@ -187,7 +187,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.Gradient = ComputeGradient(0.SI<Meter>()); CurrentState.VehicleTargetSpeed = CycleIntervalIterator.LeftSample.VehicleTargetSpeed; - return NextComponent.Request(absTime, dt, CycleIntervalIterator.LeftSample.VehicleTargetSpeed, CurrentState.Gradient); + return _nextComponent.Request(absTime, dt, CycleIntervalIterator.LeftSample.VehicleTargetSpeed, CurrentState.Gradient); } private IResponse DriveDistance(Second absTime, Meter ds) @@ -208,12 +208,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CurrentState.VehicleTargetSpeed = CycleIntervalIterator.LeftSample.VehicleTargetSpeed; CurrentState.Gradient = ComputeGradient(ds); - var retVal = NextComponent.Request(absTime, ds, CurrentState.VehicleTargetSpeed, CurrentState.Gradient); + var retVal = _nextComponent.Request(absTime, ds, CurrentState.VehicleTargetSpeed, CurrentState.Gradient); retVal.Switch() .Case<ResponseFailTimeInterval>( r => { - retVal = NextComponent.Request(absTime, r.DeltaT, 0.SI<MeterPerSecond>(), CurrentState.Gradient); - retVal = NextComponent.Request(absTime, ds, CurrentState.VehicleTargetSpeed, CurrentState.Gradient); + retVal = _nextComponent.Request(absTime, r.DeltaT, 0.SI<MeterPerSecond>(), CurrentState.Gradient); + retVal = _nextComponent.Request(absTime, ds, CurrentState.VehicleTargetSpeed, CurrentState.Gradient); }); return retVal; } @@ -229,7 +229,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var leftSamplePoint = cycleIterator.LeftSample; var rightSamplePoint = cycleIterator.RightSample; - if (leftSamplePoint.Distance.IsEqual(rightSamplePoint.Distance)) { return leftSamplePoint.RoadGradient; } @@ -261,22 +260,22 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return null; } - IResponse ISimulationOutPort.Request(Second absTime, Second dt) + public IResponse Request(Second absTime, Second dt) { throw new NotImplementedException("Distance Based Driving Cycle does not support time requests."); } - IResponse ISimulationOutPort.Initialize() + public IResponse Initialize() { if (CycleIntervalIterator.LeftSample.VehicleTargetSpeed.IsEqual(0)) { - var retVal = NextComponent.Initialize(DataBus.StartSpeed, + var retVal = _nextComponent.Initialize(DataBus.StartSpeed, CycleIntervalIterator.LeftSample.RoadGradient, DataBus.StartAcceleration); if (!(retVal is ResponseSuccess)) { throw new UnexpectedResponseException("Couldn't find start gear.", retVal); } } - return NextComponent.Initialize(CycleIntervalIterator.LeftSample.VehicleTargetSpeed, + return _nextComponent.Initialize(CycleIntervalIterator.LeftSample.VehicleTargetSpeed, CycleIntervalIterator.LeftSample.RoadGradient); } @@ -284,9 +283,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { get { - return Data.Entries.Count > 0 - ? ((CurrentState.Distance - Data.Entries.First().Distance) / - (Data.Entries.Last().Distance - Data.Entries.First().Distance)).Value() + return _data.Entries.Count > 0 + ? ((CurrentState.Distance - _data.Entries.First().Distance) / + (_data.Entries.Last().Distance - _data.Entries.First().Distance)).Value() : 0; } } @@ -314,7 +313,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl PreviousState = CurrentState; CurrentState = CurrentState.Clone(); - IntervalProlonged = false; + _intervalProlonged = false; if (!CycleIntervalIterator.LeftSample.StoppingTime.IsEqual(0) && CycleIntervalIterator.LeftSample.StoppingTime.IsEqual(PreviousState.WaitTime)) { @@ -387,22 +386,22 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl CycleStartDistance = startDistance; } - public class DrivingCycleEnumerator : IEnumerator<DrivingCycleData.DrivingCycleEntry> + public sealed class DrivingCycleEnumerator : IEnumerator<DrivingCycleData.DrivingCycleEntry> { - protected int CurrentCycleIndex; - protected DrivingCycleData Data; + private int _currentCycleIndex; + private DrivingCycleData _data; public DrivingCycleEnumerator(DrivingCycleData data) { - CurrentCycleIndex = 0; - Data = data; + _currentCycleIndex = 0; + _data = data; LastEntry = false; } public DrivingCycleEnumerator Clone() { - return new DrivingCycleEnumerator(Data) { - CurrentCycleIndex = CurrentCycleIndex, + return new DrivingCycleEnumerator(_data) { + _currentCycleIndex = _currentCycleIndex, LastEntry = LastEntry }; } @@ -419,17 +418,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public DrivingCycleData.DrivingCycleEntry LeftSample { - get { return Data.Entries[CurrentCycleIndex]; } + get { return _data.Entries[_currentCycleIndex]; } } public DrivingCycleData.DrivingCycleEntry RightSample { - get { return CurrentCycleIndex + 1 >= Data.Entries.Count ? null : Data.Entries[CurrentCycleIndex + 1]; } + get { return _currentCycleIndex + 1 >= _data.Entries.Count ? null : _data.Entries[_currentCycleIndex + 1]; } } - public bool LastEntry { get; protected set; } - - public void Dispose() {} + public bool LastEntry { get; private set; } object System.Collections.IEnumerator.Current { @@ -439,12 +436,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public bool MoveNext() { // cycleIndex has to be max. next to last (so that rightSample is still valid. - if (CurrentCycleIndex >= Data.Entries.Count - 2) { + if (_currentCycleIndex >= _data.Entries.Count - 2) { LastEntry = true; return false; } - CurrentCycleIndex++; - if (CurrentCycleIndex == Data.Entries.Count - 2) { + _currentCycleIndex++; + if (_currentCycleIndex == _data.Entries.Count - 2) { LastEntry = true; } @@ -453,8 +450,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public void Reset() { - CurrentCycleIndex = 0; + _currentCycleIndex = 0; } + + public void Dispose() {} } public class DrivingCycleState @@ -490,5 +489,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public Meter SimulationDistance; } + + public void Dispose() + { + CycleIntervalIterator.Dispose(); + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Utils/DelaunayMap.cs b/VectoCore/VectoCore/Utils/DelaunayMap.cs index 57c98eb3120f32cfd7f012ad2fec971c58858c04..e65e6afc0cb4dd737b6bd7823e9539d6897b00a1 100644 --- a/VectoCore/VectoCore/Utils/DelaunayMap.cs +++ b/VectoCore/VectoCore/Utils/DelaunayMap.cs @@ -37,15 +37,13 @@ using System.IO; using System.Linq; using System.Threading; using System.Windows.Forms.DataVisualization.Charting; -using Newtonsoft.Json; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; namespace TUGraz.VectoCore.Utils { - [JsonObject(MemberSerialization.Fields)] - public class DelaunayMap : LoggingObject + public sealed class DelaunayMap : LoggingObject, IDisposable { internal readonly ICollection<Point> Points = new HashSet<Point>(); private List<Triangle> _triangles = new List<Triangle>(); @@ -281,7 +279,7 @@ namespace TUGraz.VectoCore.Utils #region Equality members - protected bool Equals(DelaunayMap other) + private bool Equals(DelaunayMap other) { return Points.SequenceEqual(other.Points) && _triangles.SequenceEqual(other._triangles); } @@ -308,6 +306,11 @@ namespace TUGraz.VectoCore.Utils } } + public void Dispose() + { + _extrapolated.Dispose(); + } + #endregion } } \ No newline at end of file