diff --git a/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs b/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs index 0bbb7cbc80192844bf3ab3fc955710e75f7305f5..0b7def405135caeb627585e41dcde7ffe9c5bed4 100644 --- a/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs +++ b/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs @@ -68,8 +68,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data /// </summary> public SI Displacement { - get { return _data.Body.Displacement.SI().Cubic.Centi.Meter.To().Cubic.Meter.Value(); } - protected set { _data.Body.Displacement = (double) value.To().Cubic.Centi.Meter; } + get { return _data.Body.Displacement.SI().Cubic.Centi.Meter.ConvertTo().Cubic.Meter.Value(); } + protected set { _data.Body.Displacement = (double) value.ConvertTo().Cubic.Centi.Meter; } } /// <summary> @@ -78,7 +78,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data public RadianPerSecond IdleSpeed { get { return _data.Body.IdleSpeed.RPMtoRad(); } - protected set { _data.Body.IdleSpeed = (double) value.To().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 SI Inertia { get { return _data.Body.Inertia.SI().Kilo.Gramm.Square.Meter; } - protected set { _data.Body.Inertia = (double) value.To().Kilo.Gramm.Square.Meter; } + protected set { _data.Body.Inertia = (double) value.ConvertTo().Kilo.Gramm.Square.Meter; } } /// <summary> @@ -95,8 +95,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data /// </summary> public SI WHTCUrban { - get { return _data.Body.WHTCUrban.SI().Gramm.Per.Kilo.Watt.Hour.To().Kilo.Gramm.Per.Watt.Second.Value(); } - protected set { _data.Body.WHTCUrban = (double) value.To().Gramm.Per.Kilo.Watt.Hour; } + 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; } } /// <summary> @@ -104,8 +104,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data /// </summary> public SI WHTCRural { - get { return _data.Body.WHTCRural.SI().Gramm.Per.Kilo.Watt.Hour.To().Kilo.Gramm.Per.Watt.Second.Value(); } - protected set { _data.Body.WHTCRural = (double) value.To().Gramm.Per.Kilo.Watt.Hour; } + 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; } } /// <summary> @@ -116,9 +116,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data get { return - _data.Body.WHTCMotorway.SI().Gramm.Per.Kilo.Watt.Hour.To().Kilo.Gramm.Per.Watt.Second.Value(); + _data.Body.WHTCMotorway.SI().Gramm.Per.Kilo.Watt.Hour.ConvertTo().Kilo.Gramm.Per.Watt.Second.Value(); } - protected set { _data.Body.WHTCMotorway = (double) value.To().Gramm.Per.Kilo.Watt.Hour; } + protected set { _data.Body.WHTCMotorway = (double) value.ConvertTo().Gramm.Per.Kilo.Watt.Hour; } } [DataMember] diff --git a/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs b/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs index 60cd5cf6b4b99016635982ad9d5f78e23920fbe3..056f46fde552ec3d6e6cb83851745af54fc1dc89 100644 --- a/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs +++ b/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs @@ -232,7 +232,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data return row.Table.Columns.Cast<DataColumn>(). Where(col => col.ColumnName.StartsWith(Fields.AuxiliarySupplyPower)). ToDictionary(col => col.ColumnName.Substring(Fields.AuxiliarySupplyPower.Length - 1), - col => row.ParseDouble(col).SI().Kilo.Watt.As<Watt>()); + col => row.ParseDouble(col).SI().Kilo.Watt.Cast<Watt>()); } } @@ -244,17 +244,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data return table.Rows.Cast<DataRow>().Select(row => new DrivingCycleEntry { Distance = row.ParseDouble(Fields.Distance), - VehicleSpeed = row.ParseDouble(Fields.VehicleSpeed).SI().Kilo.Meter.Per.Hour.As<MeterPerSecond>(), + VehicleSpeed = row.ParseDouble(Fields.VehicleSpeed).SI().Kilo.Meter.Per.Hour.Cast<MeterPerSecond>(), RoadGradient = row.ParseDoubleOrGetDefault(Fields.RoadGradient), AdditionalAuxPowerDemand = - row.ParseDoubleOrGetDefault(Fields.AdditionalAuxPowerDemand).SI().Kilo.Watt.As<Watt>(), + row.ParseDoubleOrGetDefault(Fields.AdditionalAuxPowerDemand).SI().Kilo.Watt.Cast<Watt>(), EngineSpeed = - row.ParseDoubleOrGetDefault(Fields.EngineSpeed).SI().Rounds.Per.Minute.As<RadianPerSecond>(), + row.ParseDoubleOrGetDefault(Fields.EngineSpeed).SI().Rounds.Per.Minute.Cast<RadianPerSecond>(), Gear = row.ParseDoubleOrGetDefault(Fields.Gear), AirSpeedRelativeToVehicle = row.ParseDoubleOrGetDefault(Fields.AirSpeedRelativeToVehicle) .SI() - .Kilo.Meter.Per.Hour.As<MeterPerSecond>(), + .Kilo.Meter.Per.Hour.Cast<MeterPerSecond>(), WindYawAngle = row.ParseDoubleOrGetDefault(Fields.WindYawAngle), AuxiliarySupplyPower = AuxSupplyPowerReader.Read(row) }); @@ -305,17 +305,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data var entries = table.Rows.Cast<DataRow>().Select((row, index) => new DrivingCycleEntry { Time = row.ParseDoubleOrGetDefault(Fields.Time, index), - VehicleSpeed = row.ParseDouble(Fields.VehicleSpeed).SI().Kilo.Meter.Per.Hour.As<MeterPerSecond>(), + VehicleSpeed = row.ParseDouble(Fields.VehicleSpeed).SI().Kilo.Meter.Per.Hour.Cast<MeterPerSecond>(), RoadGradient = row.ParseDoubleOrGetDefault(Fields.RoadGradient), AdditionalAuxPowerDemand = - row.ParseDoubleOrGetDefault(Fields.AdditionalAuxPowerDemand).SI().Kilo.Watt.As<Watt>(), + row.ParseDoubleOrGetDefault(Fields.AdditionalAuxPowerDemand).SI().Kilo.Watt.Cast<Watt>(), Gear = row.ParseDoubleOrGetDefault(Fields.Gear), EngineSpeed = - row.ParseDoubleOrGetDefault(Fields.EngineSpeed).SI().Rounds.Per.Minute.As<RadianPerSecond>(), + row.ParseDoubleOrGetDefault(Fields.EngineSpeed).SI().Rounds.Per.Minute.Cast<RadianPerSecond>(), AirSpeedRelativeToVehicle = row.ParseDoubleOrGetDefault(Fields.AirSpeedRelativeToVehicle) .SI() - .Kilo.Meter.Per.Hour.As<MeterPerSecond>(), + .Kilo.Meter.Per.Hour.Cast<MeterPerSecond>(), WindYawAngle = row.ParseDoubleOrGetDefault(Fields.WindYawAngle), AuxiliarySupplyPower = AuxSupplyPowerReader.Read(row) }).ToArray(); @@ -365,9 +365,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data foreach (DataRow row in table.Rows) { var entry = new DrivingCycleEntry { EngineSpeed = - row.ParseDoubleOrGetDefault(Fields.EngineSpeed).SI().Rounds.Per.Minute.As<RadianPerSecond>(), + row.ParseDoubleOrGetDefault(Fields.EngineSpeed).SI().Rounds.Per.Minute.Cast<RadianPerSecond>(), AdditionalAuxPowerDemand = - row.ParseDoubleOrGetDefault(Fields.AdditionalAuxPowerDemand).SI().Kilo.Watt.As<Watt>(), + row.ParseDoubleOrGetDefault(Fields.AdditionalAuxPowerDemand).SI().Kilo.Watt.Cast<Watt>(), AuxiliarySupplyPower = AuxSupplyPowerReader.Read(row) }; if (row.Table.Columns.Contains(Fields.EngineTorque)) { @@ -381,7 +381,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data entry.Drag = true; } else { entry.EngineTorque = - Formulas.PowerToTorque(row.ParseDouble(Fields.EnginePower).SI().Kilo.Watt.As<Watt>(), + Formulas.PowerToTorque(row.ParseDouble(Fields.EnginePower).SI().Kilo.Watt.Cast<Watt>(), entry.EngineSpeed); } } diff --git a/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs b/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs index 572e7a78b2ff04c431814a7215da80dcbc409f30..cf39c70c9908d34f8237f2da12d26dc1e5181b65 100644 --- a/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs +++ b/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs @@ -26,10 +26,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine try { var entry = new FuelConsumptionEntry { EngineSpeed = - row.ParseDouble(Fields.EngineSpeed).SI().Rounds.Per.Minute.As<RadianPerSecond>(), + row.ParseDouble(Fields.EngineSpeed).SI().Rounds.Per.Minute.Cast<RadianPerSecond>(), Torque = row.ParseDouble(Fields.Torque).SI<NewtonMeter>(), FuelConsumption = - row.ParseDouble(Fields.FuelConsumption).SI().Gramm.Per.Hour.To().Kilo.Gramm.Per.Second + row.ParseDouble(Fields.FuelConsumption).SI().Gramm.Per.Hour.ConvertTo().Kilo.Gramm.Per.Second }; // todo Contract.Assert @@ -65,7 +65,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine { // delauney map needs is initialised with rpm, therefore the engineSpeed has to be converted. return - _fuelMap.Interpolate((double) torque, (double) engineSpeed.To().Rounds.Per.Minute) + _fuelMap.Interpolate((double) torque, (double) engineSpeed.ConvertTo().Rounds.Per.Minute) .SI() .Kilo.Gramm.Per.Second; } diff --git a/VectoCore/Models/SimulationComponent/Data/Engine/FullLoadCurve.cs b/VectoCore/Models/SimulationComponent/Data/Engine/FullLoadCurve.cs index a819fe67e71988b479df921a3bc2fe3a82cd5802..c78dd738df4dac7cb84255575b81fc82884fb326 100644 --- a/VectoCore/Models/SimulationComponent/Data/Engine/FullLoadCurve.cs +++ b/VectoCore/Models/SimulationComponent/Data/Engine/FullLoadCurve.cs @@ -157,7 +157,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine int idx; if (engineSpeed < _entries[0].EngineSpeed) { Log.ErrorFormat("requested rpm below minimum rpm in FLD curve - extrapolating. n: {0}, rpm_min: {1}", - engineSpeed.To().Rounds.Per.Minute, _entries[0].EngineSpeed.To().Rounds.Per.Minute); + engineSpeed.ConvertTo().Rounds.Per.Minute, _entries[0].EngineSpeed.ConvertTo().Rounds.Per.Minute); idx = 1; } else { idx = _entries.FindIndex(x => x.EngineSpeed > engineSpeed); diff --git a/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 9c0f7220613bfb66312ba09f2562ed83b586a48b..4894579229b0440ea7870a21e5af3ac7101b5190 100644 --- a/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -122,13 +122,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl writer[ModalResultField.Tq_drag] = (double) _currentState.FullDragTorque; writer[ModalResultField.Tq_full] = (double) _currentState.DynamicFullLoadTorque; writer[ModalResultField.Tq_eng] = (double) _currentState.EngineTorque; - writer[ModalResultField.n] = (double) _currentState.EngineSpeed.To().Rounds.Per.Minute; + writer[ModalResultField.n] = (double) _currentState.EngineSpeed.ConvertTo().Rounds.Per.Minute; try { writer[ModalResultField.FC] = (double) _data.ConsumptionMap.GetFuelConsumption(_currentState.EngineTorque, _currentState.EngineSpeed) - .To() + .ConvertTo() .Gramm.Per.Hour; } catch (VectoException ex) { Log.WarnFormat("t: {0} - {1} n: {2} Tq: {3}", _currentState.AbsTime.TotalSeconds, ex.Message, @@ -152,11 +152,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (_currentState.FullDragPower >= 0 && requestedEnginePower < 0) { throw new VectoSimulationException(String.Format("t: {0} P_engine_drag > 0! n: {1} [1/min] ", - _currentState.AbsTime, _currentState.EngineSpeed.To().Rounds.Per.Minute)); + _currentState.AbsTime, _currentState.EngineSpeed.ConvertTo().Rounds.Per.Minute)); } if (_currentState.DynamicFullLoadPower <= 0 && requestedEnginePower > 0) { throw new VectoSimulationException(String.Format("t: {0} P_engine_full < 0! n: {1} [1/min] ", - _currentState.AbsTime, _currentState.EngineSpeed.To().Rounds.Per.Minute)); + _currentState.AbsTime, _currentState.EngineSpeed.ConvertTo().Rounds.Per.Minute)); } } @@ -267,7 +267,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var deltaEngineSpeed = engineSpeed - _previousState.EngineSpeed; var avgEngineSpeed = (_previousState.EngineSpeed + engineSpeed) / 2.0.SI<Second>(); var result = _data.Inertia * deltaEngineSpeed * avgEngineSpeed; - return result.As<Watt>(); + return result.Cast<Watt>(); } public class EngineState diff --git a/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs b/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs index cd02a3a85977d572eda1869e005ad8434fbd9712..ad01e68fe628a215ea5b18f64bc62480dc3e0c31 100644 --- a/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs @@ -51,7 +51,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } return _outPort.Request(absTime, dt, Data.Entries[index].VehicleSpeed, - Data.Entries[index].RoadGradient.SI().GradientPercent.As<Radian>()); + Data.Entries[index].RoadGradient.SI().GradientPercent.Cast<Radian>()); } #endregion diff --git a/VectoCore/Utils/DoubleExtensionMethods.cs b/VectoCore/Utils/DoubleExtensionMethods.cs index c65aa8dd404128502dcd34c46e7bf9779e483eba..3d4fed8e9d20c51f5604469c45614639291774b3 100644 --- a/VectoCore/Utils/DoubleExtensionMethods.cs +++ b/VectoCore/Utils/DoubleExtensionMethods.cs @@ -50,7 +50,7 @@ namespace TUGraz.VectoCore.Utils /// <returns></returns> public static RadianPerSecond RPMtoRad(this double d) { - return d.SI().Rounds.Per.Minute.To().Radian.Per.Second.As<RadianPerSecond>(); + return d.SI().Rounds.Per.Minute.ConvertTo().Radian.Per.Second.Cast<RadianPerSecond>(); } /// <summary> diff --git a/VectoCore/Utils/SI.cs b/VectoCore/Utils/SI.cs index b2f67acce29017f45bf933a4f23354e20287811e..34bd0cc54a862da1387a4afffccd9bd84086a0c3 100644 --- a/VectoCore/Utils/SI.cs +++ b/VectoCore/Utils/SI.cs @@ -29,12 +29,12 @@ namespace TUGraz.VectoCore.Utils public static RadianPerSecond operator /(Watt watt, NewtonMeter newtonMeter) { - return ((watt as SI) / newtonMeter).As<RadianPerSecond>(); + return ((watt as SI) / newtonMeter).Cast<RadianPerSecond>(); } public static NewtonMeter operator /(Watt watt, RadianPerSecond radianPerSecond) { - return ((watt as SI) / radianPerSecond).As<NewtonMeter>(); + return ((watt as SI) / radianPerSecond).Cast<NewtonMeter>(); } } @@ -44,7 +44,7 @@ namespace TUGraz.VectoCore.Utils public static Watt operator *(RadianPerSecond radianPerSecond, NewtonMeter newtonMeter) { - return ((radianPerSecond as SI) * newtonMeter).As<Watt>(); + return ((radianPerSecond as SI) * newtonMeter).Cast<Watt>(); } } @@ -59,12 +59,12 @@ namespace TUGraz.VectoCore.Utils public static Watt operator *(NewtonMeter newtonMeter, RadianPerSecond radianPerSecond) { - return ((newtonMeter as SI) * radianPerSecond).As<Watt>(); + return ((newtonMeter as SI) * radianPerSecond).Cast<Watt>(); } public static Second operator /(NewtonMeter newtonMeter, Watt watt) { - return ((newtonMeter as SI) / watt).As<Second>(); + return ((newtonMeter as SI) / watt).Cast<Second>(); } } @@ -87,7 +87,7 @@ namespace TUGraz.VectoCore.Utils public static T operator +(SIBase<T> si1, SI si2) { - return ((si1 as SI) + si2).As<T>(); + return ((si1 as SI) + si2).Cast<T>(); } public static T operator +(SI si1, SIBase<T> si2) @@ -97,7 +97,7 @@ namespace TUGraz.VectoCore.Utils public static T operator +(SIBase<T> si1, double d) { - return ((si1 as SI) + d).As<T>(); + return ((si1 as SI) + d).Cast<T>(); } public static T operator +(double d, SIBase<T> si) @@ -117,17 +117,17 @@ namespace TUGraz.VectoCore.Utils public static T operator -(SI si1, SIBase<T> si2) { - return (si1 - (si2 as SI)).As<T>(); + return (si1 - (si2 as SI)).Cast<T>(); } public static T operator -(SIBase<T> si, double d) { - return ((si as SI) - d).As<T>(); + return ((si as SI) - d).Cast<T>(); } public static T operator -(double d, SIBase<T> si) { - return (d - (si as SI)).As<T>(); + return (d - (si as SI)).Cast<T>(); } public static T operator *(double d, SIBase<T> si) @@ -137,7 +137,7 @@ namespace TUGraz.VectoCore.Utils public static T operator *(SIBase<T> si, double d) { - return ((si as SI) * d).As<T>(); + return ((si as SI) * d).Cast<T>(); } public static T operator /(double d, SIBase<T> si) @@ -147,7 +147,7 @@ namespace TUGraz.VectoCore.Utils public static T operator /(SIBase<T> si, double d) { - return ((si as SI) / d).As<T>(); + return ((si as SI) / d).Cast<T>(); } #endregion @@ -262,13 +262,13 @@ namespace TUGraz.VectoCore.Utils } /// <summary> - /// Converts the SI unit to another SI unit, defined by term(s) following after the To(). + /// Converts the SI unit to another SI unit, defined by term(s) following after the ConvertTo(). /// The Conversion Mode is active until an arithmetic operator is used (+,-,*,/), - /// or the .Value-Method, or the .As-Method were called. - /// ATTENTION: Before returning an SI Unit, ensure to cancel Conversion Mode (with .Value or .As). + /// or the .Value-Method, or the .Cast-Method were called. + /// ATTENTION: Before returning an SI Unit, ensure to cancel Conversion Mode (with .Value or .Cast). /// </summary> /// <returns></returns> - public SI To() + public SI ConvertTo() { return new SI(Linear, reciproc: false, reverse: true); } @@ -278,7 +278,7 @@ namespace TUGraz.VectoCore.Utils /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> - public T As<T>() where T : SIBase<T> + public T Cast<T>() where T : SIBase<T> { var t = (T) Activator.CreateInstance(typeof (T), Val); Contract.Assert(HasEqualUnit(t), string.Format("SI Unit Conversion failed: From {0} to {1}", this, t)); @@ -321,9 +321,9 @@ namespace TUGraz.VectoCore.Utils } /// <summary> - /// Gets the basic scalar value. + /// Gets the basic double value. /// </summary> - protected double ScalarValue() + public double Double() { return Val; } diff --git a/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs b/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs index b5ce5b48aaf2a77b18e592388a51d2d0ecd35186..eee3b16b6b6b9d9d1bdf570aa92078ed4de97217 100644 --- a/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs +++ b/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs @@ -66,7 +66,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation Assert.AreEqual(absTime, outPort.AbsTime); Assert.AreEqual(dt, outPort.Dt); Assert.AreEqual(0.0.SI<MeterPerSecond>(), outPort.Velocity); - Assert.AreEqual((-0.020237973).SI().GradientPercent.As<Radian>(), outPort.Gradient); + Assert.AreEqual((-0.020237973).SI().GradientPercent.Cast<Radian>(), outPort.Gradient); } [TestMethod] diff --git a/VectoCoreTest/Models/SimulationComponentData/FuelConsumptionMapTest.cs b/VectoCoreTest/Models/SimulationComponentData/FuelConsumptionMapTest.cs index b8de40ea4edef01fff7c11d74b20cb5b16e5a5e1..965f39a46cf39a3dbd150c770b95f39bc0af5f2d 100644 --- a/VectoCoreTest/Models/SimulationComponentData/FuelConsumptionMapTest.cs +++ b/VectoCoreTest/Models/SimulationComponentData/FuelConsumptionMapTest.cs @@ -34,7 +34,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData 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.To().Kilo.Gramm.Per.Second, + 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])); diff --git a/VectoCoreTest/Utils/SITest.cs b/VectoCoreTest/Utils/SITest.cs index 23362db676a402f64eb71d7ccd4f5f6d65601b81..f14296368771e870f3426150a79ad36f87f7a3bd 100644 --- a/VectoCoreTest/Utils/SITest.cs +++ b/VectoCoreTest/Utils/SITest.cs @@ -4,65 +4,65 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Tests.Utils { - [TestClass] - public class SITest - { - public static void AssertException<T>(Action func, string message) where T : Exception - { - try { - func(); - Assert.Fail(); - } catch (T ex) { - Assert.AreEqual(message, ex.Message); - } - } + [TestClass] + public class SITest + { + public static void AssertException<T>(Action func, string message) where T : Exception + { + try { + func(); + Assert.Fail(); + } catch (T ex) { + Assert.AreEqual(message, ex.Message); + } + } - [TestMethod] - public void TestSI() - { - var si = new SI(); - Assert.AreEqual(0.0, (double) si); - Assert.AreEqual("0 [-]", si.ToString()); - Assert.IsTrue(si.HasEqualUnit(new SI())); + [TestMethod] + public void TestSI() + { + var si = new SI(); + Assert.AreEqual(0.0, (double) si); + Assert.AreEqual("0 [-]", si.ToString()); + Assert.IsTrue(si.HasEqualUnit(new SI())); - var si2 = 5.0.SI().Watt; - Assert.AreEqual("5 [W]", si2.ToString()); + var si2 = 5.0.SI().Watt; + Assert.AreEqual("5 [W]", si2.ToString()); - var si3 = 2.SI().Radian.Per.Second; - Assert.AreEqual("2 [rad/s]", si3.ToString()); + var si3 = 2.SI().Radian.Per.Second; + Assert.AreEqual("2 [rad/s]", si3.ToString()); - var si4 = si2 * si3; - Assert.AreEqual("10 [W/s]", si4.ToString()); - Assert.IsTrue(si4.HasEqualUnit(new SI().Watt.Per.Second)); - Assert.AreEqual("10 [kgmm/ssss]", si4.ToBasicUnits().ToString()); + var si4 = si2 * si3; + Assert.AreEqual("10 [W/s]", si4.ToString()); + Assert.IsTrue(si4.HasEqualUnit(new SI().Watt.Per.Second)); + Assert.AreEqual("10 [kgmm/ssss]", si4.ToBasicUnits().ToString()); - var kg = 5.0.SI().Kilo.Gramm; - Assert.AreEqual(5.0, (double) kg); - Assert.AreEqual("5 [kg]", kg.ToString()); + var kg = 5.0.SI().Kilo.Gramm; + Assert.AreEqual(5.0, (double) kg); + Assert.AreEqual("5 [kg]", kg.ToString()); - kg = kg.To().Kilo.Gramm.Value(); - Assert.AreEqual(5.0, (double) kg); - Assert.AreEqual("5 [kg]", kg.ToString()); + kg = kg.ConvertTo().Kilo.Gramm.Value(); + Assert.AreEqual(5.0, (double) kg); + Assert.AreEqual("5 [kg]", kg.ToString()); - kg = kg.To().Gramm.Value(); - Assert.AreEqual(5000, (double) kg); - Assert.AreEqual("5000 [g]", kg.ToString()); + kg = kg.ConvertTo().Gramm.Value(); + Assert.AreEqual(5000, (double) kg); + Assert.AreEqual("5000 [g]", kg.ToString()); - var x = 5.SI(); - Assert.AreEqual((2.0 / 5.0).SI(), 2 / x); - Assert.AreEqual((5.0 / 2.0).SI(), x / 2); - Assert.AreEqual((2.0 * 5.0).SI(), 2 * x); - Assert.AreEqual((5.0 * 2.0).SI(), x * 2); + var x = 5.SI(); + Assert.AreEqual((2.0 / 5.0).SI(), 2 / x); + Assert.AreEqual((5.0 / 2.0).SI(), x / 2); + Assert.AreEqual((2.0 * 5.0).SI(), 2 * x); + Assert.AreEqual((5.0 * 2.0).SI(), x * 2); - Assert.AreEqual((2.0 / 5.0).SI(), 2.0 / x); - Assert.AreEqual((5.0 / 2.0).SI(), x / 2.0); - Assert.AreEqual((2 * 5).SI(), 2.0 * x); - Assert.AreEqual((5 * 2).SI(), x * 2.0); + Assert.AreEqual((2.0 / 5.0).SI(), 2.0 / x); + Assert.AreEqual((5.0 / 2.0).SI(), x / 2.0); + Assert.AreEqual((2 * 5).SI(), 2.0 * x); + Assert.AreEqual((5 * 2).SI(), x * 2.0); - var y = 2.SI(); - Assert.AreEqual((2 * 5).SI(), y * x); - } - } + var y = 2.SI(); + Assert.AreEqual((2 * 5).SI(), y * x); + } + } } \ No newline at end of file