From e8060f96550f4fc40e02f0aec7e5619d851ce70c Mon Sep 17 00:00:00 2001 From: Michael Krisper <michael.krisper@tugraz.at> Date: Wed, 8 Jul 2015 12:33:13 +0200 Subject: [PATCH] code formatting: replace spaces by tabs --- VectoCore/Models/Connector/Ports/IFvPort.cs | 48 +-- VectoCore/Models/Connector/Ports/ITnPort.cs | 48 +-- .../Models/Connector/Ports/Impl/Response.cs | 46 +-- .../Simulation/Cockpit/IEngineCockpit.cs | 2 +- .../Data/CombustionEngineData.cs | 32 +- .../Data/DrivingCycleData.cs | 4 +- .../Data/Engine/FuelConsumptionMap.cs | 322 +++++++++--------- .../Data/Engine/FullLoadCurve.cs | 4 +- .../Models/SimulationComponent/IAuxiliary.cs | 8 +- .../SimulationComponent/ICombustionEngine.cs | 8 +- .../IDriverDemandDrivingCycle.cs | 8 +- .../IEngineOnlyDrivingCycle.cs | 8 +- .../Models/SimulationComponent/IGearbox.cs | 8 +- .../Models/SimulationComponent/IWheels.cs | 8 +- .../Impl/TimeBasedDrivingCycle.cs | 2 +- .../VectoSimulationComponent.cs | 50 +-- VectoCore/Utils/StringExtensionMethods.cs | 16 +- VectoCore/Utils/VectoCSVFile.cs | 6 +- .../FuelConsumptionMapTest.cs | 68 ++-- 19 files changed, 348 insertions(+), 348 deletions(-) diff --git a/VectoCore/Models/Connector/Ports/IFvPort.cs b/VectoCore/Models/Connector/Ports/IFvPort.cs index 1155a32776..ac85d7d342 100644 --- a/VectoCore/Models/Connector/Ports/IFvPort.cs +++ b/VectoCore/Models/Connector/Ports/IFvPort.cs @@ -3,29 +3,29 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Connector.Ports { - /// <summary> - /// Defines a connect method to connect the inport to an outport. - /// </summary> - public interface IFvInPort - { - /// <summary> - /// Connects the inport to another outport. - /// </summary> - void Connect(IFvOutPort other); - } + /// <summary> + /// Defines a connect method to connect the inport to an outport. + /// </summary> + public interface IFvInPort + { + /// <summary> + /// Connects the inport to another outport. + /// </summary> + void Connect(IFvOutPort other); + } - /// <summary> - /// Defines a request method for a Fv-Out-Port. - /// </summary> - public interface IFvOutPort - { - /// <summary> - /// Requests the Outport with the given force [N] and vehicle velocity [m/s]. - /// </summary> - /// <param name="absTime">[s]</param> - /// <param name="dt">[s]</param> - /// <param name="force">[N]</param> - /// <param name="velocity">[m/s]</param> - IResponse Request(TimeSpan absTime, TimeSpan dt, Newton force, MeterPerSecond velocity); - } + /// <summary> + /// Defines a request method for a Fv-Out-Port. + /// </summary> + public interface IFvOutPort + { + /// <summary> + /// Requests the Outport with the given force [N] and vehicle velocity [m/s]. + /// </summary> + /// <param name="absTime">[s]</param> + /// <param name="dt">[s]</param> + /// <param name="force">[N]</param> + /// <param name="velocity">[m/s]</param> + IResponse Request(TimeSpan absTime, TimeSpan dt, Newton force, MeterPerSecond velocity); + } } \ No newline at end of file diff --git a/VectoCore/Models/Connector/Ports/ITnPort.cs b/VectoCore/Models/Connector/Ports/ITnPort.cs index 0d6ddba5b8..9c8d4d8e1a 100644 --- a/VectoCore/Models/Connector/Ports/ITnPort.cs +++ b/VectoCore/Models/Connector/Ports/ITnPort.cs @@ -3,29 +3,29 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Connector.Ports { - /// <summary> - /// Defines a connect method to connect the inport to an outport. - /// </summary> - public interface ITnInPort - { - /// <summary> - /// Connects the inport to another outport. - /// </summary> - void Connect(ITnOutPort other); - } + /// <summary> + /// Defines a connect method to connect the inport to an outport. + /// </summary> + public interface ITnInPort + { + /// <summary> + /// Connects the inport to another outport. + /// </summary> + void Connect(ITnOutPort other); + } - /// <summary> - /// Defines a request method for a Tn-Out-Port. - /// </summary> - public interface ITnOutPort - { - /// <summary> - /// Requests the Outport with the given torque [Nm] and angularVelocity [rad/s]. - /// </summary> - /// <param name="absTime">[s]</param> - /// <param name="dt">[s]</param> - /// <param name="torque">[Nm]</param> - /// <param name="angularVelocity">[rad/s]</param> - IResponse Request(TimeSpan absTime, TimeSpan dt, NewtonMeter torque, PerSecond angularVelocity); - } + /// <summary> + /// Defines a request method for a Tn-Out-Port. + /// </summary> + public interface ITnOutPort + { + /// <summary> + /// Requests the Outport with the given torque [Nm] and angularVelocity [rad/s]. + /// </summary> + /// <param name="absTime">[s]</param> + /// <param name="dt">[s]</param> + /// <param name="torque">[Nm]</param> + /// <param name="angularVelocity">[rad/s]</param> + IResponse Request(TimeSpan absTime, TimeSpan dt, NewtonMeter torque, PerSecond angularVelocity); + } } \ No newline at end of file diff --git a/VectoCore/Models/Connector/Ports/Impl/Response.cs b/VectoCore/Models/Connector/Ports/Impl/Response.cs index 1e6c0cc929..4931c543c7 100644 --- a/VectoCore/Models/Connector/Ports/Impl/Response.cs +++ b/VectoCore/Models/Connector/Ports/Impl/Response.cs @@ -2,30 +2,30 @@ using System; namespace TUGraz.VectoCore.Models.Connector.Ports.Impl { - /// <summary> - /// Response when the Cycle is finished. - /// </summary> - public class ResponseCycleFinished : IResponse {} + /// <summary> + /// Response when the Cycle is finished. + /// </summary> + public class ResponseCycleFinished : IResponse {} - /// <summary> - /// Response when a request was successful. - /// </summary> - public class ResponseSuccess : IResponse {} + /// <summary> + /// Response when a request was successful. + /// </summary> + public class ResponseSuccess : IResponse {} - /// <summary> - /// Response when the request resulted in an engine overload. - /// </summary> - public class ResponseFailOverload : IResponse - { - public double Delta { get; set; } - public double Gradient { get; set; } - } + /// <summary> + /// Response when the request resulted in an engine overload. + /// </summary> + public class ResponseFailOverload : IResponse + { + public double Delta { get; set; } + public double Gradient { get; set; } + } - /// <summary> - /// Response when the request should have another time interval. - /// </summary> - public class ResponseFailTimeInterval : IResponse - { - public TimeSpan DeltaT { get; set; } - } + /// <summary> + /// Response when the request should have another time interval. + /// </summary> + public class ResponseFailTimeInterval : IResponse + { + public TimeSpan DeltaT { get; set; } + } } \ No newline at end of file diff --git a/VectoCore/Models/Simulation/Cockpit/IEngineCockpit.cs b/VectoCore/Models/Simulation/Cockpit/IEngineCockpit.cs index 27c6a58672..cbe86bb426 100644 --- a/VectoCore/Models/Simulation/Cockpit/IEngineCockpit.cs +++ b/VectoCore/Models/Simulation/Cockpit/IEngineCockpit.cs @@ -10,6 +10,6 @@ namespace TUGraz.VectoCore.Models.Simulation.Cockpit /// <summary> /// [rad/s] The current engine speed. /// </summary> - PerSecond EngineSpeed(); + PerSecond EngineSpeed(); } } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs b/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs index ce53411e44..9c2c14dca9 100644 --- a/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs +++ b/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs @@ -69,7 +69,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public SI Displacement { get { return _data.Body.Displacement.SI().Cubic.Centi.Meter.ConvertTo().Cubic.Meter.Value(); } - protected set { _data.Body.Displacement = (double) value.ConvertTo().Cubic.Centi.Meter; } + protected set { _data.Body.Displacement = (double)value.ConvertTo().Cubic.Centi.Meter; } } /// <summary> @@ -78,7 +78,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public PerSecond IdleSpeed { get { return _data.Body.IdleSpeed.RPMtoRad(); } - protected set { _data.Body.IdleSpeed = (double) value.ConvertTo().Rounds.Per.Minute; } + protected set { _data.Body.IdleSpeed = (double)value.ConvertTo().Rounds.Per.Minute; } } /// <summary> @@ -87,7 +87,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public KilogramSquareMeter Inertia { get { return _data.Body.Inertia.SI<KilogramSquareMeter>(); } - protected set { _data.Body.Inertia = (double) value.ConvertTo().Kilo.Gramm.Square.Meter; } + protected set { _data.Body.Inertia = (double)value.ConvertTo().Kilo.Gramm.Square.Meter; } } /// <summary> @@ -96,7 +96,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public SI WHTCUrban { get { return _data.Body.WHTCUrban.SI().Gramm.Per.Kilo.Watt.Hour.ConvertTo().Kilo.Gramm.Per.Watt.Second.Value(); } - protected set { _data.Body.WHTCUrban = (double) value.ConvertTo().Gramm.Per.Kilo.Watt.Hour; } + protected set { _data.Body.WHTCUrban = (double)value.ConvertTo().Gramm.Per.Kilo.Watt.Hour; } } /// <summary> @@ -105,7 +105,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public SI WHTCRural { get { return _data.Body.WHTCRural.SI().Gramm.Per.Kilo.Watt.Hour.ConvertTo().Kilo.Gramm.Per.Watt.Second.Value(); } - protected set { _data.Body.WHTCRural = (double) value.ConvertTo().Gramm.Per.Kilo.Watt.Hour; } + protected set { _data.Body.WHTCRural = (double)value.ConvertTo().Gramm.Per.Kilo.Watt.Hour; } } /// <summary> @@ -114,7 +114,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public SI WHTCMotorway { get { return _data.Body.WHTCMotorway.SI().Gramm.Per.Kilo.Watt.Hour.ConvertTo().Kilo.Gramm.Per.Watt.Second.Value(); } - protected set { _data.Body.WHTCMotorway = (double) value.ConvertTo().Gramm.Per.Kilo.Watt.Hour; } + protected set { _data.Body.WHTCMotorway = (double)value.ConvertTo().Gramm.Per.Kilo.Watt.Hour; } } [DataMember] @@ -260,7 +260,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data if (obj.GetType() != GetType()) { return false; } - return Equals((DataFullLoadCurve) obj); + return Equals((DataFullLoadCurve)obj); } public override int GetHashCode() @@ -301,7 +301,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data if (obj.GetType() != GetType()) { return false; } - return Equals((DataBody) obj); + return Equals((DataBody)obj); } public override int GetHashCode() @@ -342,7 +342,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data if (obj.GetType() != GetType()) { return false; } - return Equals((Data) obj); + return Equals((Data)obj); } public override int GetHashCode() @@ -359,18 +359,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { - return sourceType == typeof (string) || base.CanConvertFrom(context, sourceType); + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { - return value.GetType() == typeof (string) - ? new Range((string) value) + return value.GetType() == typeof(string) + ? new Range((string)value) : base.ConvertFrom(context, culture, value); } } - [TypeConverter(typeof (RangeConverter))] + [TypeConverter(typeof(RangeConverter))] private class Range { private readonly uint _end; @@ -413,13 +413,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data if (obj.GetType() != GetType()) { return false; } - return Equals((Range) obj); + return Equals((Range)obj); } public override int GetHashCode() { unchecked { - return (int) ((_start * 397) ^ _end); + return (int)((_start * 397) ^ _end); } } @@ -447,7 +447,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data if (obj.GetType() != GetType()) { return false; } - return Equals((CombustionEngineData) obj); + return Equals((CombustionEngineData)obj); } public override int GetHashCode() diff --git a/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs b/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs index c793463df4..be9eb2b061 100644 --- a/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs +++ b/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs @@ -103,7 +103,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public const string EngineSpeed = "n"; /// <summary> - /// [-] Gear input. Overwrites the gear shift model. + /// [-] Gear input. Overwrites the gear shift model. /// </summary> public const string Gear = "gear"; @@ -181,7 +181,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public PerSecond EngineSpeed { get; set; } /// <summary> - /// [-] Gear input. Overwrites the gear shift model. + /// [-] Gear input. Overwrites the gear shift model. /// </summary> public double Gear { get; set; } diff --git a/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs b/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs index 2923e1e1a1..1bc5286a2f 100644 --- a/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs +++ b/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs @@ -9,165 +9,165 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine { - [JsonObject(MemberSerialization.Fields)] - public class FuelConsumptionMap : SimulationComponentData - { - private readonly IList<FuelConsumptionEntry> _entries = new List<FuelConsumptionEntry>(); - private readonly DelauneyMap _fuelMap = new DelauneyMap(); - private FuelConsumptionMap() {} - - public static FuelConsumptionMap ReadFromFile(string fileName) - { - var fuelConsumptionMap = new FuelConsumptionMap(); - var data = VectoCSVFile.Read(fileName); - - try { - foreach (DataRow row in data.Rows) { - try { - var entry = new FuelConsumptionEntry { - EngineSpeed = - row.ParseDouble(Fields.EngineSpeed).SI().Rounds.Per.Minute.Cast<PerSecond>(), - Torque = row.ParseDouble(Fields.Torque).SI<NewtonMeter>(), - FuelConsumption = - row.ParseDouble(Fields.FuelConsumption).SI().Gramm.Per.Hour.ConvertTo().Kilo.Gramm.Per.Second - }; - - // todo Contract.Assert - if (entry.FuelConsumption < 0) { - throw new ArgumentOutOfRangeException("FuelConsumption", "FuelConsumption < 0 not allowed."); - } - - fuelConsumptionMap._entries.Add(entry); - - // Delauney map works only as expected, when the engineSpeed is in rpm. - fuelConsumptionMap._fuelMap.AddPoint((double) entry.Torque, row.ParseDouble(Fields.EngineSpeed), - (double) entry.FuelConsumption); - } catch (Exception e) { - throw new VectoException(string.Format("Line {0}: {1}", data.Rows.IndexOf(row), e.Message), e); - } - } - } catch (Exception e) { - throw new VectoException(string.Format("File {0}: {1}", fileName, e.Message), e); - } - - fuelConsumptionMap._fuelMap.Triangulate(); - return fuelConsumptionMap; - } - - /// <summary> - /// [kg/s] Calculates the fuel consumption based on the given fuel map, - /// the engineSpeed [rad/s] and the torque [Nm]. - /// </summary> - /// <param name="engineSpeed">[rad/sec]</param> - /// <param name="torque">[Nm]</param> - /// <returns>[kg/s]</returns> - public SI GetFuelConsumption(NewtonMeter torque, PerSecond engineSpeed) - { - // delauney map needs is initialised with rpm, therefore the engineSpeed has to be converted. - return - _fuelMap.Interpolate(torque.Double(), engineSpeed.ConvertTo().Rounds.Per.Minute.Double()).SI().Kilo.Gramm.Per.Second; - } - - private static class Fields - { - /// <summary> - /// [rpm] - /// </summary> - public const string EngineSpeed = "engine speed"; - - /// <summary> - /// [Nm] - /// </summary> - public const string Torque = "torque"; - - /// <summary> - /// [g/h] - /// </summary> - public const string FuelConsumption = "fuel consumption"; - }; - - private class FuelConsumptionEntry - { - /// <summary> - /// engine speed [rad/s] - /// </summary> - public PerSecond EngineSpeed { get; set; } - - /// <summary> - /// Torque [Nm] - /// </summary> - public NewtonMeter Torque { get; set; } - - /// <summary> - /// Fuel consumption [kg/s] - /// </summary> - public SI FuelConsumption { get; set; } - - #region Equality members - - private bool Equals(FuelConsumptionEntry other) - { - Contract.Requires(other != null); - return EngineSpeed.Equals(other.EngineSpeed) && Torque.Equals(other.Torque) && - FuelConsumption.Equals(other.FuelConsumption); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) { - return false; - } - if (ReferenceEquals(this, obj)) { - return true; - } - if (obj.GetType() != GetType()) { - return false; - } - return Equals((FuelConsumptionEntry) obj); - } - - public override int GetHashCode() - { - unchecked { - var hashCode = EngineSpeed.GetHashCode(); - hashCode = (hashCode * 397) ^ Torque.GetHashCode(); - hashCode = (hashCode * 397) ^ FuelConsumption.GetHashCode(); - return hashCode; - } - } - - #endregion - } - - #region Equality members - - protected bool Equals(FuelConsumptionMap other) - { - return _entries.SequenceEqual(other._entries) && Equals(_fuelMap, other._fuelMap); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) { - return false; - } - if (ReferenceEquals(this, obj)) { - return true; - } - if (obj.GetType() != GetType()) { - return false; - } - return Equals((FuelConsumptionMap) obj); - } - - public override int GetHashCode() - { - unchecked { - return ((_entries != null ? _entries.GetHashCode() : 0) * 397) ^ - (_fuelMap != null ? _fuelMap.GetHashCode() : 0); - } - } - - #endregion - } + [JsonObject(MemberSerialization.Fields)] + public class FuelConsumptionMap : SimulationComponentData + { + private readonly IList<FuelConsumptionEntry> _entries = new List<FuelConsumptionEntry>(); + private readonly DelauneyMap _fuelMap = new DelauneyMap(); + private FuelConsumptionMap() {} + + public static FuelConsumptionMap ReadFromFile(string fileName) + { + var fuelConsumptionMap = new FuelConsumptionMap(); + var data = VectoCSVFile.Read(fileName); + + try { + foreach (DataRow row in data.Rows) { + try { + var entry = new FuelConsumptionEntry { + EngineSpeed = + row.ParseDouble(Fields.EngineSpeed).SI().Rounds.Per.Minute.Cast<PerSecond>(), + Torque = row.ParseDouble(Fields.Torque).SI<NewtonMeter>(), + FuelConsumption = + row.ParseDouble(Fields.FuelConsumption).SI().Gramm.Per.Hour.ConvertTo().Kilo.Gramm.Per.Second + }; + + // todo Contract.Assert + if (entry.FuelConsumption < 0) { + throw new ArgumentOutOfRangeException("FuelConsumption", "FuelConsumption < 0 not allowed."); + } + + fuelConsumptionMap._entries.Add(entry); + + // Delauney map works only as expected, when the engineSpeed is in rpm. + fuelConsumptionMap._fuelMap.AddPoint((double)entry.Torque, row.ParseDouble(Fields.EngineSpeed), + (double)entry.FuelConsumption); + } catch (Exception e) { + throw new VectoException(string.Format("Line {0}: {1}", data.Rows.IndexOf(row), e.Message), e); + } + } + } catch (Exception e) { + throw new VectoException(string.Format("File {0}: {1}", fileName, e.Message), e); + } + + fuelConsumptionMap._fuelMap.Triangulate(); + return fuelConsumptionMap; + } + + /// <summary> + /// [kg/s] Calculates the fuel consumption based on the given fuel map, + /// the engineSpeed [rad/s] and the torque [Nm]. + /// </summary> + /// <param name="engineSpeed">[rad/sec]</param> + /// <param name="torque">[Nm]</param> + /// <returns>[kg/s]</returns> + public SI GetFuelConsumption(NewtonMeter torque, PerSecond engineSpeed) + { + // delauney map needs is initialised with rpm, therefore the engineSpeed has to be converted. + return + _fuelMap.Interpolate(torque.Double(), engineSpeed.ConvertTo().Rounds.Per.Minute.Double()).SI().Kilo.Gramm.Per.Second; + } + + private static class Fields + { + /// <summary> + /// [rpm] + /// </summary> + public const string EngineSpeed = "engine speed"; + + /// <summary> + /// [Nm] + /// </summary> + public const string Torque = "torque"; + + /// <summary> + /// [g/h] + /// </summary> + public const string FuelConsumption = "fuel consumption"; + }; + + private class FuelConsumptionEntry + { + /// <summary> + /// engine speed [rad/s] + /// </summary> + public PerSecond EngineSpeed { get; set; } + + /// <summary> + /// Torque [Nm] + /// </summary> + public NewtonMeter Torque { get; set; } + + /// <summary> + /// Fuel consumption [kg/s] + /// </summary> + public SI FuelConsumption { get; set; } + + #region Equality members + + private bool Equals(FuelConsumptionEntry other) + { + Contract.Requires(other != null); + return EngineSpeed.Equals(other.EngineSpeed) && Torque.Equals(other.Torque) && + FuelConsumption.Equals(other.FuelConsumption); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) { + return false; + } + if (ReferenceEquals(this, obj)) { + return true; + } + if (obj.GetType() != GetType()) { + return false; + } + return Equals((FuelConsumptionEntry)obj); + } + + public override int GetHashCode() + { + unchecked { + var hashCode = EngineSpeed.GetHashCode(); + hashCode = (hashCode * 397) ^ Torque.GetHashCode(); + hashCode = (hashCode * 397) ^ FuelConsumption.GetHashCode(); + return hashCode; + } + } + + #endregion + } + + #region Equality members + + protected bool Equals(FuelConsumptionMap other) + { + return _entries.SequenceEqual(other._entries) && Equals(_fuelMap, other._fuelMap); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) { + return false; + } + if (ReferenceEquals(this, obj)) { + return true; + } + if (obj.GetType() != GetType()) { + return false; + } + return Equals((FuelConsumptionMap)obj); + } + + public override int GetHashCode() + { + unchecked { + return ((_entries != null ? _entries.GetHashCode() : 0) * 397) ^ + (_fuelMap != null ? _fuelMap.GetHashCode() : 0); + } + } + + #endregion + } } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/Data/Engine/FullLoadCurve.cs b/VectoCore/Models/SimulationComponent/Data/Engine/FullLoadCurve.cs index 8c431e0abf..9e8596e69a 100644 --- a/VectoCore/Models/SimulationComponent/Data/Engine/FullLoadCurve.cs +++ b/VectoCore/Models/SimulationComponent/Data/Engine/FullLoadCurve.cs @@ -277,7 +277,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine if (ReferenceEquals(this, obj)) { return true; } - return obj.GetType() == GetType() && Equals((FullLoadCurveEntry)obj); + return obj.GetType() == GetType() && Equals((FullLoadCurveEntry) obj); } public override int GetHashCode() @@ -307,7 +307,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine if (ReferenceEquals(this, obj)) { return true; } - return obj.GetType() == GetType() && Equals((FullLoadCurve)obj); + return obj.GetType() == GetType() && Equals((FullLoadCurve) obj); } public override int GetHashCode() diff --git a/VectoCore/Models/SimulationComponent/IAuxiliary.cs b/VectoCore/Models/SimulationComponent/IAuxiliary.cs index 480f5de651..8c41f88f17 100644 --- a/VectoCore/Models/SimulationComponent/IAuxiliary.cs +++ b/VectoCore/Models/SimulationComponent/IAuxiliary.cs @@ -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 : IInShaft, IOutShaft {} } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/ICombustionEngine.cs b/VectoCore/Models/SimulationComponent/ICombustionEngine.cs index 92b3a6fdff..afb7be9d04 100644 --- a/VectoCore/Models/SimulationComponent/ICombustionEngine.cs +++ b/VectoCore/Models/SimulationComponent/ICombustionEngine.cs @@ -3,8 +3,8 @@ using TUGraz.VectoCore.Models.Simulation.Cockpit; namespace TUGraz.VectoCore.Models.SimulationComponent { - /// <summary> - /// Defines Interfaces for a combustion engine. - /// </summary> - public interface ICombustionEngine : IOutShaft, IEngineCockpit {} + /// <summary> + /// Defines Interfaces for a combustion engine. + /// </summary> + public interface ICombustionEngine : IOutShaft, IEngineCockpit {} } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/IDriverDemandDrivingCycle.cs b/VectoCore/Models/SimulationComponent/IDriverDemandDrivingCycle.cs index adc97eabc4..6d8656334e 100644 --- a/VectoCore/Models/SimulationComponent/IDriverDemandDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/IDriverDemandDrivingCycle.cs @@ -2,8 +2,8 @@ using TUGraz.VectoCore.Models.Connector.Ports; namespace TUGraz.VectoCore.Models.SimulationComponent { - /// <summary> - /// Defines interfaces for a driver demand driving cycle. - /// </summary> - public interface IDrivingCycleDemandDrivingCycle : IDrivingCycleOutProvider, IDrivingCycleDemandInProvider {} + /// <summary> + /// Defines interfaces for a driver demand driving cycle. + /// </summary> + public interface IDrivingCycleDemandDrivingCycle : IDrivingCycleOutProvider, IDrivingCycleDemandInProvider {} } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/IEngineOnlyDrivingCycle.cs b/VectoCore/Models/SimulationComponent/IEngineOnlyDrivingCycle.cs index 9d496e763d..ac196bd5fa 100644 --- a/VectoCore/Models/SimulationComponent/IEngineOnlyDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/IEngineOnlyDrivingCycle.cs @@ -2,8 +2,8 @@ using TUGraz.VectoCore.Models.Connector.Ports; namespace TUGraz.VectoCore.Models.SimulationComponent { - /// <summary> - /// Defines interfaces for a engine only driving cycle. - /// </summary> - public interface IEngineOnlyDrivingCycle : IDrivingCycleOutProvider, IInShaft {} + /// <summary> + /// Defines interfaces for a engine only driving cycle. + /// </summary> + public interface IEngineOnlyDrivingCycle : IDrivingCycleOutProvider, IInShaft {} } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/IGearbox.cs b/VectoCore/Models/SimulationComponent/IGearbox.cs index f0741cdb09..b5ddff375d 100644 --- a/VectoCore/Models/SimulationComponent/IGearbox.cs +++ b/VectoCore/Models/SimulationComponent/IGearbox.cs @@ -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 : IInShaft, IOutShaft, IGearboxCockpit {} } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/IWheels.cs b/VectoCore/Models/SimulationComponent/IWheels.cs index d5727dd0f1..354f551e2e 100644 --- a/VectoCore/Models/SimulationComponent/IWheels.cs +++ b/VectoCore/Models/SimulationComponent/IWheels.cs @@ -2,8 +2,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent { - /// <summary> - /// Defines interfaces for a wheels component. - /// </summary> - public interface IWheels : IRoadPortOutProvider, IInShaft {} + /// <summary> + /// Defines interfaces for a wheels component. + /// </summary> + public interface IWheels : IRoadPortOutProvider, IInShaft {} } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs b/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs index 4237148953..52838a1cf5 100644 --- a/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs @@ -46,7 +46,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl IResponse IDrivingCycleOutPort.Request(TimeSpan absTime, TimeSpan dt) { //todo: change to variable time steps - var index = (int) Math.Floor(absTime.TotalSeconds); + var index = (int)Math.Floor(absTime.TotalSeconds); if (index >= Data.Entries.Count) { return new ResponseCycleFinished(); } diff --git a/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs b/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs index 65acf8428d..85ae6769dd 100644 --- a/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs +++ b/VectoCore/Models/SimulationComponent/VectoSimulationComponent.cs @@ -6,32 +6,32 @@ using TUGraz.VectoCore.Models.Simulation.Data; namespace TUGraz.VectoCore.Models.SimulationComponent { - /// <summary> - /// Base class for all vecto simulation components. - /// </summary> - public abstract class VectoSimulationComponent - { - [NonSerialized] protected ICockpit Cockpit; - [NonSerialized] protected ILog Log; + /// <summary> + /// Base class for all vecto simulation components. + /// </summary> + public abstract class VectoSimulationComponent + { + [NonSerialized] protected ICockpit Cockpit; + [NonSerialized] protected ILog Log; - /// <summary> - /// Constructor. Registers the component in the cockpit. - /// </summary> - /// <param name="cockpit">The vehicle container</param> - protected VectoSimulationComponent(IVehicleContainer cockpit) - { - Cockpit = cockpit; - Log = LogManager.GetLogger(GetType()); + /// <summary> + /// Constructor. Registers the component in the cockpit. + /// </summary> + /// <param name="cockpit">The vehicle container</param> + protected VectoSimulationComponent(IVehicleContainer cockpit) + { + Cockpit = cockpit; + Log = LogManager.GetLogger(GetType()); - cockpit.AddComponent(this); - } + cockpit.AddComponent(this); + } - /// <summary> - /// Commits the simulation step. - /// Writes the moddata into the data writer. - /// Commits the internal state of the object if needed. - /// </summary> - /// <param name="writer">a data writer to write the data into.</param> - public abstract void CommitSimulationStep(IModalDataWriter writer); - } + /// <summary> + /// Commits the simulation step. + /// Writes the moddata into the data writer. + /// Commits the internal state of the object if needed. + /// </summary> + /// <param name="writer">a data writer to write the data into.</param> + public abstract void CommitSimulationStep(IModalDataWriter writer); + } } \ No newline at end of file diff --git a/VectoCore/Utils/StringExtensionMethods.cs b/VectoCore/Utils/StringExtensionMethods.cs index d0eeff2c14..f120770506 100644 --- a/VectoCore/Utils/StringExtensionMethods.cs +++ b/VectoCore/Utils/StringExtensionMethods.cs @@ -10,13 +10,13 @@ namespace TUGraz.VectoCore.Utils return double.Parse(self, CultureInfo.InvariantCulture); } - public static string Slice(this string s, int from = 0, int to = int.MaxValue) - { - from = Math.Min(Math.Max(from, -s.Length), s.Length); - from = from < 0 ? from + s.Length : from; - to = Math.Min(Math.Max(to, -s.Length), s.Length); - to = to < 0 ? to + s.Length : to; - return s.Substring(from, Math.Max(to - from, 0)); - } + public static string Slice(this string s, int from = 0, int to = int.MaxValue) + { + from = Math.Min(Math.Max(from, -s.Length), s.Length); + from = from < 0 ? from + s.Length : from; + to = Math.Min(Math.Max(to, -s.Length), s.Length); + to = to < 0 ? to + s.Length : to; + return s.Substring(from, Math.Max(to - from, 0)); + } } } \ No newline at end of file diff --git a/VectoCore/Utils/VectoCSVFile.cs b/VectoCore/Utils/VectoCSVFile.cs index 25de5f7453..8535d32004 100644 --- a/VectoCore/Utils/VectoCSVFile.cs +++ b/VectoCore/Utils/VectoCSVFile.cs @@ -78,7 +78,7 @@ namespace TUGraz.VectoCore.Utils // Valid Columns found => header was valid => skip header line lines = lines.Skip(1).ToArray(); } else { - var log = LogManager.GetLogger(typeof (VectoCSVFile)); + var log = LogManager.GetLogger(typeof(VectoCSVFile)); log.Warn("No valid Data Header found. Interpreting the first line as data line."); // set the validColumns to: {"0", "1", "2", "3", ...} for all columns in first line. validColumns = GetColumns(lines.First()).Select((_, index) => index.ToString()).ToArray(); @@ -92,13 +92,13 @@ namespace TUGraz.VectoCore.Utils for (var i = 0; i < lines.Length; i++) { var line = lines[i]; - var cells = line.Split(Delimiter); + var cells = line.Split(Delimiter); if (!ignoreEmptyColumns && cells.Length != table.Columns.Count) { throw new CSVReadException(string.Format("Line {0}: The number of values is not correct.", i)); } try { - table.Rows.Add(line.Split(Delimiter)); + table.Rows.Add(line.Split(Delimiter)); } catch (InvalidCastException e) { throw new CSVReadException( string.Format("Line {0}: The data format of a value is not correct. {1}", i, e.Message), e); diff --git a/VectoCoreTest/Models/SimulationComponentData/FuelConsumptionMapTest.cs b/VectoCoreTest/Models/SimulationComponentData/FuelConsumptionMapTest.cs index 965f39a46c..2fbb805e92 100644 --- a/VectoCoreTest/Models/SimulationComponentData/FuelConsumptionMapTest.cs +++ b/VectoCoreTest/Models/SimulationComponentData/FuelConsumptionMapTest.cs @@ -8,41 +8,41 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData { - [TestClass] - public class FuelConsumptionMapTest - { - private const double Tolerance = 0.0001; + [TestClass] + public class FuelConsumptionMapTest + { + private const double Tolerance = 0.0001; - [TestMethod] - public void TestFuelConsumption_FixedPoints() - { - var map = FuelConsumptionMap.ReadFromFile(@"TestData\Components\24t Coach.vmap"); - var lines = File.ReadAllLines(@"TestData\Components\24t Coach.vmap").Skip(1).ToArray(); - AssertMapValuesEqual(lines, map); - } + [TestMethod] + public void TestFuelConsumption_FixedPoints() + { + var map = FuelConsumptionMap.ReadFromFile(@"TestData\Components\24t Coach.vmap"); + var lines = File.ReadAllLines(@"TestData\Components\24t Coach.vmap").Skip(1).ToArray(); + AssertMapValuesEqual(lines, map); + } - [TestMethod] - public void TestFuelConsumption_InterpolatedPoints() - { - var map = FuelConsumptionMap.ReadFromFile(@"TestData\Components\24t Coach.vmap"); - var lines = File.ReadAllLines(@"TestData\Components\24t CoachInterpolated.vmap").Skip(1).ToArray(); - AssertMapValuesEqual(lines, map); - } + [TestMethod] + public void TestFuelConsumption_InterpolatedPoints() + { + var map = FuelConsumptionMap.ReadFromFile(@"TestData\Components\24t Coach.vmap"); + var lines = File.ReadAllLines(@"TestData\Components\24t CoachInterpolated.vmap").Skip(1).ToArray(); + AssertMapValuesEqual(lines, map); + } - private static void AssertMapValuesEqual(string[] lines, FuelConsumptionMap map) - { - for (var i = 1; i < lines.Count(); i++) { - var entry = lines[i].Split(',').Select(x => double.Parse(x, CultureInfo.InvariantCulture)).ToArray(); - try { - Assert.AreEqual((double) entry[2].SI().Gramm.Per.Hour.ConvertTo().Kilo.Gramm.Per.Second, - (double) map.GetFuelConsumption(entry[1].SI<NewtonMeter>(), entry[0].RPMtoRad()), - Tolerance, - string.Format("Line: {0}, n={1}, T={2}", (i + 2), entry[0].SI().Rounds.Per.Minute, entry[1])); - } catch (VectoException ex) { - throw new VectoException(string.Format("Row {0}: Error in ConsumptionMap n={1}, T={2}: {3}", - i + 2, entry[0], entry[1], ex.Message)); - } - } - } - } + private static void AssertMapValuesEqual(string[] lines, FuelConsumptionMap map) + { + for (var i = 1; i < lines.Count(); i++) { + var entry = lines[i].Split(',').Select(x => double.Parse(x, CultureInfo.InvariantCulture)).ToArray(); + try { + Assert.AreEqual((double)entry[2].SI().Gramm.Per.Hour.ConvertTo().Kilo.Gramm.Per.Second, + (double)map.GetFuelConsumption(entry[1].SI<NewtonMeter>(), entry[0].RPMtoRad()), + Tolerance, + string.Format("Line: {0}, n={1}, T={2}", (i + 2), entry[0].SI().Rounds.Per.Minute, entry[1])); + } catch (VectoException ex) { + throw new VectoException(string.Format("Row {0}: Error in ConsumptionMap n={1}, T={2}: {3}", + i + 2, entry[0], entry[1], ex.Message)); + } + } + } + } } \ No newline at end of file -- GitLab