diff --git a/VECTO.sln.DotSettings b/VECTO.sln.DotSettings index d635c0c1a281f74cd84a345469585faabfb8a897..1e16474b715987ab4268bc61cdefb4c9b02b2768 100644 --- a/VECTO.sln.DotSettings +++ b/VECTO.sln.DotSettings @@ -15,6 +15,7 @@ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ELSE_ON_NEW_LINE/@EntryValue">False</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FINALLY_ON_NEW_LINE/@EntryValue">False</s:Boolean> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SIMPLE_EMBEDDED_STATEMENT_STYLE/@EntryValue">LINE_BREAK</s:String> + <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AROUND_MULTIPLICATIVE_OP/@EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_TYPEOF_PARENTHESES/@EntryValue">False</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean> diff --git a/VectoCore/Models/Declaration/Axle.cs b/VectoCore/Models/Declaration/Axle.cs index 2a9706ade6e91b6d8ad82559ca97b7ec0e1e60c7..6e06fdb374367a12aa4d47a9baf3a0933f5fca8f 100644 --- a/VectoCore/Models/Declaration/Axle.cs +++ b/VectoCore/Models/Declaration/Axle.cs @@ -1,6 +1,6 @@ using TUGraz.VectoCore.Utils; -namespace TUGraz.VectoCore.Models.SimulationComponent.Data +namespace TUGraz.VectoCore.Models.Declaration { public class Axle { diff --git a/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/Models/Declaration/DeclarationData.cs index 1e2a7369ddcaaf95ac3f0fb1b69f39d501b13e5f..e12fc5d2534a63c8c8769bb7163dcb08af5e9166 100644 --- a/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/Models/Declaration/DeclarationData.cs @@ -9,7 +9,7 @@ private PT1 _pt1; private ElectricSystem _electricSystem; private Fan _fan; - private HVAC _hvac; + private HeatingVentilationAirConditioning _heatingVentilationAirConditioning; private PneumaticSystem _pneumaticSystem; private SteeringPump _steeringPump; @@ -43,9 +43,13 @@ get { return Instance()._fan ?? (Instance()._fan = new Fan()); } } - public static HVAC HVAC + public static HeatingVentilationAirConditioning HeatingVentilationAirConditioning { - get { return Instance()._hvac ?? (Instance()._hvac = new HVAC()); } + get + { + return Instance()._heatingVentilationAirConditioning ?? + (Instance()._heatingVentilationAirConditioning = new HeatingVentilationAirConditioning()); + } } public static PneumaticSystem PneumaticSystem diff --git a/VectoCore/Models/Declaration/HVAC.cs b/VectoCore/Models/Declaration/HVAC.cs index 1abe9195dbbee57345dacc6756d933a4c6d55c90..16859b6635ddeef130e9637e6f26ba59c0d74271 100644 --- a/VectoCore/Models/Declaration/HVAC.cs +++ b/VectoCore/Models/Declaration/HVAC.cs @@ -5,7 +5,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration { - public class HVAC : LookupData<MissionType, string, Watt> + public class HeatingVentilationAirConditioning : LookupData<MissionType, string, Watt> { private readonly Dictionary<Tuple<MissionType, string>, Watt> _data = new Dictionary<Tuple<MissionType, string>, Watt>(); diff --git a/VectoCore/Models/Declaration/MissionType.cs b/VectoCore/Models/Declaration/MissionType.cs index 3c53bfa23ded85720db1cccdf81de6f46b71e087..eb1604b9ca26411adde7609f01890e1383c2e91d 100644 --- a/VectoCore/Models/Declaration/MissionType.cs +++ b/VectoCore/Models/Declaration/MissionType.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace TUGraz.VectoCore.Models +namespace TUGraz.VectoCore.Models.Declaration { public enum MissionType { diff --git a/VectoCore/Models/Declaration/Segment.cs b/VectoCore/Models/Declaration/Segment.cs index 2e34c439aeac65f7cda75da62f36cc0d2f02cc2c..8db815f6bf55223762a9745da392f5daff6efe3b 100644 --- a/VectoCore/Models/Declaration/Segment.cs +++ b/VectoCore/Models/Declaration/Segment.cs @@ -1,5 +1,4 @@ using System.IO; -using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration @@ -11,7 +10,7 @@ namespace TUGraz.VectoCore.Models.Declaration public Kilogram GrossVehicleWeightMin { get; set; } public Kilogram GrossVehicleWeightMax { get; set; } - public string HDVClass { get; internal set; } + public string VehicleClass { get; internal set; } public Stream AccelerationFile { get; internal set; } public Mission[] Missions { get; internal set; } } diff --git a/VectoCore/Models/Declaration/Segments.cs b/VectoCore/Models/Declaration/Segments.cs index 766bf0af89b24eaae6f1040842317abac4cf8c2e..3eeff6b8cc44efd8947b464ab0e360c49f9eb796 100644 --- a/VectoCore/Models/Declaration/Segments.cs +++ b/VectoCore/Models/Declaration/Segments.cs @@ -38,7 +38,7 @@ namespace TUGraz.VectoCore.Models.Declaration GrossVehicleWeightMax = row.ParseDouble("gvw_max").SI().Ton.Cast<Kilogram>(), VehicleCategory = vehicleCategory, AxleConfiguration = axleConfiguration, - HDVClass = row.Field<string>("hdv_class"), + VehicleClass = row.Field<string>("hdv_class"), AccelerationFile = RessourceHelper.ReadStream(ResourceNamespace + "VACC." + row.Field<string>("vacc")), Missions = CreateMissions(grossVehicleMassRating, curbWeight, row).ToArray() }; diff --git a/VectoCore/Models/Declaration/Wheels.cs b/VectoCore/Models/Declaration/Wheels.cs index 2122d792e33bce835a66d12ed19fe3ba7fe975a7..85ec531bc1600f3dccfe24b98211915ba9cea982 100644 --- a/VectoCore/Models/Declaration/Wheels.cs +++ b/VectoCore/Models/Declaration/Wheels.cs @@ -1,5 +1,4 @@ -using System; -using System.Data; +using System.Data; using System.Linq; using TUGraz.VectoCore.Utils; @@ -19,7 +18,7 @@ namespace TUGraz.VectoCore.Models.Declaration WheelType = row[0].ToString(), Inertia = row.ParseDouble(1).SI<KilogramSquareMeter>(), DynamicTyreRadius = row.ParseDouble(2).SI().Milli.Meter.Cast<Meter>(), - SizeClass = Int32.Parse(row[3].ToString()) + SizeClass = int.Parse(row[3].ToString()) }).ToDictionary(e => e.WheelType); } diff --git a/VectoCore/Models/Simulation/Data/IModalDataWriter.cs b/VectoCore/Models/Simulation/Data/IModalDataWriter.cs index fa3c9c3a9d945c27cb7dd97f8d36dcf050b72cff..de07839879157cc97db67818e1a1efe638322d3a 100644 --- a/VectoCore/Models/Simulation/Data/IModalDataWriter.cs +++ b/VectoCore/Models/Simulation/Data/IModalDataWriter.cs @@ -1,6 +1,4 @@ -using System; using System.Collections.Generic; -using System.Data; namespace TUGraz.VectoCore.Models.Simulation.Data { @@ -22,7 +20,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Data void Finish(); - Object Compute(string expression, string filter); + object Compute(string expression, string filter); IEnumerable<T> GetValues<T>(ModalResultField key); } diff --git a/VectoCore/Models/Simulation/Data/ModalDataWriter.cs b/VectoCore/Models/Simulation/Data/ModalDataWriter.cs index 4e947fed36e13510b4a5bebd3784ccf1c6dff8ae..7bffe3fe1f9fca8364678b2b45f145b5d4430773 100644 --- a/VectoCore/Models/Simulation/Data/ModalDataWriter.cs +++ b/VectoCore/Models/Simulation/Data/ModalDataWriter.cs @@ -1,6 +1,6 @@ -using System.Data; +using System.Collections.Generic; +using System.Data; using System.Linq; -using System.Collections.Generic; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Simulation.Data diff --git a/VectoCore/Models/Simulation/Data/SummaryFileWriter.cs b/VectoCore/Models/Simulation/Data/SummaryFileWriter.cs index 1ec8730c7ce03efb7a83a2964e0dc90a210ce69e..6c73bc5ff520b402381e739fa53badac3998837e 100644 --- a/VectoCore/Models/Simulation/Data/SummaryFileWriter.cs +++ b/VectoCore/Models/Simulation/Data/SummaryFileWriter.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; -using TUGraz.VectoCore.Utils; -using System.Linq; using System.Data; +using System.Linq; using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Simulation.Data { diff --git a/VectoCore/Models/Simulation/Data/VectoJobData.cs b/VectoCore/Models/Simulation/Data/VectoJobData.cs index feb6ba377ec33ad778cf54a14412f0cc619111cd..d36e84b740da2f83a371a61807ca8c8f2513b33c 100644 --- a/VectoCore/Models/Simulation/Data/VectoJobData.cs +++ b/VectoCore/Models/Simulation/Data/VectoJobData.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.IO; using System.Runtime.Serialization; using Newtonsoft.Json; diff --git a/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs b/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs index cf5426ad35b5fe8f8e1074db591f213f64461e65..ce390b99472424bc4c293e3175f67548ac6d1474 100644 --- a/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs +++ b/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs @@ -1,5 +1,5 @@ -using System.IO; using System.Collections.Generic; +using System.IO; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.SimulationComponent; using TUGraz.VectoCore.Models.SimulationComponent.Data; diff --git a/VectoCore/Models/Simulation/Impl/VectoRun.cs b/VectoCore/Models/Simulation/Impl/VectoRun.cs index 52c9c13a89f472fbf71a96b182f508f563413beb..8e496ebde54cf28f8e449240f20ff19ccab169bd 100644 --- a/VectoCore/Models/Simulation/Impl/VectoRun.cs +++ b/VectoCore/Models/Simulation/Impl/VectoRun.cs @@ -1,6 +1,4 @@ using System; -using System.Data; -using System.IO; using Common.Logging; using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Connector.Ports.Impl; diff --git a/VectoCore/Models/SimulationComponent/Data/AuxiliaryCycleDataAdapter.cs b/VectoCore/Models/SimulationComponent/Data/AuxiliaryCycleDataAdapter.cs index e7d6d2be3dc5db857b0f8faf552f7d9eb6350747..3bcf89c03e8286439eabb474a390ff9d3cbabf9b 100644 --- a/VectoCore/Models/SimulationComponent/Data/AuxiliaryCycleDataAdapter.cs +++ b/VectoCore/Models/SimulationComponent/Data/AuxiliaryCycleDataAdapter.cs @@ -25,7 +25,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data _auxiliaryId = column; if (_auxiliaryId != null && !_drivingCycle.Entries.First().AuxiliarySupplyPower.ContainsKey(_auxiliaryId)) { Log.ErrorFormat("driving cycle data does not contain column {0}", column); - throw new VectoException(String.Format("driving cycle does not contain column {0}", column)); + throw new VectoException(string.Format("driving cycle does not contain column {0}", column)); } } @@ -37,7 +37,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data CurrentCycleEntry = _nextCycleEntry.Current; _nextCycleEntry.MoveNext(); } - return String.IsNullOrEmpty(_auxiliaryId) + return string.IsNullOrEmpty(_auxiliaryId) ? CurrentCycleEntry.AdditionalAuxPowerDemand : CurrentCycleEntry.AuxiliarySupplyPower[_auxiliaryId]; } diff --git a/VectoCore/Models/SimulationComponent/Data/Engine/FullLoadCurve.cs b/VectoCore/Models/SimulationComponent/Data/Engine/FullLoadCurve.cs index 0d8ceaeca3ab5fde889224a590fb1ce96e363170..8c431e0abfbd6cf48884379b5912ac4011ccfd63 100644 --- a/VectoCore/Models/SimulationComponent/Data/Engine/FullLoadCurve.cs +++ b/VectoCore/Models/SimulationComponent/Data/Engine/FullLoadCurve.cs @@ -6,7 +6,6 @@ using System.Linq; using Common.Logging; using Newtonsoft.Json; using TUGraz.VectoCore.Exceptions; -using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine diff --git a/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs b/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs index 87ef6a9b307b60ee0774e1408d28f8318269ef11..8ed6c349220f54ddf980fb8a8fe61fff87d060b6 100644 --- a/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs +++ b/VectoCore/Models/SimulationComponent/Data/Gearbox/GearData.cs @@ -12,7 +12,7 @@ public double AverageEfficiency { get; set; } - public GearData(TransmissionLossMap lossMap, Gearbox.ShiftPolygon shiftPolygon, double ratio, + public GearData(TransmissionLossMap lossMap, ShiftPolygon shiftPolygon, double ratio, bool torqueconverterActive) { LossMap = lossMap; diff --git a/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs b/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs index 07f5d5f0902c7d41fa07135347b02acae72c283d..df2df5c26151eb38e15b1775743ea3358656b3b4 100644 --- a/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs +++ b/VectoCore/Models/SimulationComponent/Data/Gearbox/ShiftPolygon.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Data; using System.Linq; -using System.Runtime.Remoting.Messaging; using Common.Logging; using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Utils; diff --git a/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs b/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs index 8a5b759a3d0f1bbe43684d81873cfcf3f1bcd7ad..a3665d84445df8ff0c0b22c3d2f4e6a06328c82d 100644 --- a/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs +++ b/VectoCore/Models/SimulationComponent/Data/Gearbox/TransmissionLossMap.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using System.Data; using System.Linq; -using System.Runtime.InteropServices; -using System.Runtime.Remoting.Messaging; using Common.Logging; using Newtonsoft.Json; using TUGraz.VectoCore.Exceptions; @@ -63,7 +61,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox TorqueLoss = row.ParseDouble(Fields.TorqeLoss).SI<NewtonMeter>(), Efficiency = (!hasEfficiency || row[Fields.Efficiency] == DBNull.Value || row[Fields.Efficiency] != null) - ? Double.NaN + ? double.NaN : row.ParseDouble(Fields.Efficiency) }).ToList(); } @@ -109,7 +107,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox 0.SI<NewtonMeter>()); } catch (Exception e) { throw new VectoSimulationException( - String.Format("Failed to interpolate in TransmissionLossMap. angularVelocity: {0}, torque: {1}", angularVelocity, + string.Format("Failed to interpolate in TransmissionLossMap. angularVelocity: {0}, torque: {1}", angularVelocity, gbxOutTorque), e); } } @@ -117,8 +115,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox /// <summary> /// Compute the available torque at the output of the gear(box) (towards wheels) /// </summary> - /// <param name="angularVelocity">[1/s] angular speed of the shaft</param> - /// <param name="gbxInTorque">[Nm] torque provided by the engine at the gearbox' input shaft</param> /// <returns>[Nm] torque provided to the next component (towards the wheels)</returns> //public NewtonMeter GearboxOutTorque(PerSecond angularVelocity, NewtonMeter gbxInTorque) //{ diff --git a/VectoCore/Models/SimulationComponent/Data/GearboxData.cs b/VectoCore/Models/SimulationComponent/Data/GearboxData.cs index 525e86da4ae2888b9ade2e688de50949fe073c36..08dbb96ddf491165ad66498ce8342776cd974c1f 100644 --- a/VectoCore/Models/SimulationComponent/Data/GearboxData.cs +++ b/VectoCore/Models/SimulationComponent/Data/GearboxData.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Runtime.Serialization; using Newtonsoft.Json; @@ -100,7 +98,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data var lossMapPath = Path.Combine(basePath, gearSettings.LossMap); TransmissionLossMap lossMap = TransmissionLossMap.ReadFromFile(lossMapPath, gearSettings.Ratio); - var shiftPolygon = !String.IsNullOrEmpty(gearSettings.ShiftPolygon) + var shiftPolygon = !string.IsNullOrEmpty(gearSettings.ShiftPolygon) ? ShiftPolygon.ReadFromFile(Path.Combine(basePath, gearSettings.ShiftPolygon)) : null; diff --git a/VectoCore/Models/SimulationComponent/Data/JsonDataHeader.cs b/VectoCore/Models/SimulationComponent/Data/JsonDataHeader.cs index db169b94b8cd884dd43ca3f9776361a988e9cfea..bbfac2a44cf2bf9c4b82572dd8be72e629d87570 100644 --- a/VectoCore/Models/SimulationComponent/Data/JsonDataHeader.cs +++ b/VectoCore/Models/SimulationComponent/Data/JsonDataHeader.cs @@ -1,5 +1,4 @@ -using System; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { diff --git a/VectoCore/Models/SimulationComponent/Data/RetarderData.cs b/VectoCore/Models/SimulationComponent/Data/RetarderData.cs index bb1c46cf100862aed2781f410b852b42e1863d88..bab160a1833a09ceb321ca82cede5c215afbaa51 100644 --- a/VectoCore/Models/SimulationComponent/Data/RetarderData.cs +++ b/VectoCore/Models/SimulationComponent/Data/RetarderData.cs @@ -1,5 +1,4 @@ using System.IO; -using System.Runtime.InteropServices; using Newtonsoft.Json; namespace TUGraz.VectoCore.Models.SimulationComponent.Data diff --git a/VectoCore/Models/SimulationComponent/Data/RetarderLossMap.cs b/VectoCore/Models/SimulationComponent/Data/RetarderLossMap.cs index d3feadd3cd6b399cdcafac5015aaa4b185dd38d1..e610c1ca8a98c3120e01b8457bb401a63aed77a6 100644 --- a/VectoCore/Models/SimulationComponent/Data/RetarderLossMap.cs +++ b/VectoCore/Models/SimulationComponent/Data/RetarderLossMap.cs @@ -3,7 +3,6 @@ using System.Data; using System.Linq; using Common.Logging; using TUGraz.VectoCore.Exceptions; -using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data diff --git a/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs b/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs index ea6d458a1ff133e8055a43e6fee94ef5242bf3ff..9cb621a200dde8a5fd9f235bfd85efebb64ad254 100644 --- a/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs +++ b/VectoCore/Models/SimulationComponent/Data/SimulationComponentData.cs @@ -16,8 +16,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data protected static Tuple<int, bool> GetFileVersion(string jsonStr) { dynamic json = JsonConvert.DeserializeObject(jsonStr); - return new Tuple<int, bool>(Int32.Parse(json.Header.FileVersion.ToString()), - Boolean.Parse(json.Body.SavedInDeclMode.ToString())); + return new Tuple<int, bool>(int.Parse(json.Header.FileVersion.ToString()), + bool.Parse(json.Body.SavedInDeclMode.ToString())); } } } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/Factories/EngineeringModeFactory.cs b/VectoCore/Models/SimulationComponent/Factories/EngineeringModeFactory.cs index 786d0279312d8689a384b5fc0afa7d5054186ce3..af2c8e0e53b49c08a6d18eb29feea0e39f708a31 100644 --- a/VectoCore/Models/SimulationComponent/Factories/EngineeringModeFactory.cs +++ b/VectoCore/Models/SimulationComponent/Factories/EngineeringModeFactory.cs @@ -3,6 +3,7 @@ using System.Linq; using Newtonsoft.Json; using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.FileIO; +using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Utils; diff --git a/VectoCore/Models/SimulationComponent/IClutch.cs b/VectoCore/Models/SimulationComponent/IClutch.cs index 953f3f613f46ff46fb5384e0b5d09f1a97c6ee18..1ffff0489c72f4e203a1275faf39de6c61b33a67 100644 --- a/VectoCore/Models/SimulationComponent/IClutch.cs +++ b/VectoCore/Models/SimulationComponent/IClutch.cs @@ -1,6 +1,4 @@ -using TUGraz.VectoCore.Models.Connector.Ports; - -namespace TUGraz.VectoCore.Models.SimulationComponent +namespace TUGraz.VectoCore.Models.SimulationComponent { public interface IClutch : IPowerTrainComponent {} } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/IVehicle.cs b/VectoCore/Models/SimulationComponent/IVehicle.cs index 5a1a336c122eeedf4f3cf4dbbcfa4fb8a05dd725..de6646fbf092bf8ec27045f09bcd262cc849a77b 100644 --- a/VectoCore/Models/SimulationComponent/IVehicle.cs +++ b/VectoCore/Models/SimulationComponent/IVehicle.cs @@ -3,8 +3,4 @@ namespace TUGraz.VectoCore.Models.SimulationComponent { public interface IVehicle : IRoadPortInProvider, IDriverDemandOutProvider, IFvInPort, IDriverDemandOutPort {} -} - -/// </summary> -// public interface IVehicle : IDriverDemandOutProvider, IRoadPortInProvider {} -//} \ No newline at end of file +} \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index b7b1ce901b5ed5b55925d18d425cd0b63361532d..3a161c68b6373a28eff21966ba18fb20376ed7b2 100644 --- a/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Diagnostics.Contracts; -using NLog.LayoutRenderers; using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Connector.Ports.Impl; @@ -84,7 +83,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _currentState.EnginePowerLoss = InertiaPowerLoss(torque, engineSpeed); var requestedEnginePower = requestedPower + _currentState.EnginePowerLoss; - if (engineSpeed < (double) _data.IdleSpeed - EngineIdleSpeedStopThreshold) { + if (engineSpeed < (double)_data.IdleSpeed - EngineIdleSpeedStopThreshold) { _currentState.OperationMode = EngineOperationMode.Stopped; //todo: _currentState.EnginePowerLoss = enginePowerLoss; } @@ -116,15 +115,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override void CommitSimulationStep(IModalDataWriter writer) { - writer[ModalResultField.PaEng] = (double) _currentState.EnginePowerLoss; - writer[ModalResultField.Pe_drag] = (double) _currentState.FullDragPower; - writer[ModalResultField.Pe_full] = (double) _currentState.DynamicFullLoadPower; - writer[ModalResultField.Pe_eng] = (double) _currentState.EnginePower; + writer[ModalResultField.PaEng] = (double)_currentState.EnginePowerLoss; + writer[ModalResultField.Pe_drag] = (double)_currentState.FullDragPower; + writer[ModalResultField.Pe_full] = (double)_currentState.DynamicFullLoadPower; + writer[ModalResultField.Pe_eng] = (double)_currentState.EnginePower; - 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.ConvertTo().Rounds.Per.Minute; + 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.ConvertTo().Rounds.Per.Minute; try { writer[ModalResultField.FC] = @@ -135,7 +134,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } catch (VectoException ex) { Log.WarnFormat("t: {0} - {1} n: {2} Tq: {3}", _currentState.AbsTime.TotalSeconds, ex.Message, _currentState.EngineSpeed, _currentState.EngineTorque); - writer[ModalResultField.FC] = Double.NaN; + writer[ModalResultField.FC] = double.NaN; } _previousState = _currentState; @@ -153,11 +152,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Contract.Requires(requestedEnginePower.HasEqualUnit(new SI().Watt)); if (_currentState.FullDragPower >= 0 && requestedEnginePower < 0) { - throw new VectoSimulationException(String.Format("t: {0} P_engine_drag > 0! n: {1} [1/min] ", + throw new VectoSimulationException(string.Format("t: {0} P_engine_drag > 0! n: {1} [1/min] ", _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] ", + throw new VectoSimulationException(string.Format("t: {0} P_engine_full < 0! n: {1} [1/min] ", _currentState.AbsTime, _currentState.EngineSpeed.ConvertTo().Rounds.Per.Minute)); } } @@ -360,7 +359,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public override int GetHashCode() { unchecked { - var hashCode = (int) OperationMode; + var hashCode = (int)OperationMode; hashCode = (hashCode * 397) ^ (EnginePower != null ? EnginePower.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (EngineSpeed != null ? EngineSpeed.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (EnginePowerLoss != null ? EnginePowerLoss.GetHashCode() : 0); @@ -382,7 +381,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (ReferenceEquals(this, obj)) { return true; } - return obj.GetType() == GetType() && Equals((CombustionEngine) obj); + return obj.GetType() == GetType() && Equals((CombustionEngine)obj); } protected bool Equals(CombustionEngine other) diff --git a/VectoCore/Models/SimulationComponent/Impl/DirectAuxiliary.cs b/VectoCore/Models/SimulationComponent/Impl/DirectAuxiliary.cs index 368ecfb6173dd82975299c998bf9fd1d47195832..eb7a7deddf795453ff94770361ac41ed49177a14 100644 --- a/VectoCore/Models/SimulationComponent/Impl/DirectAuxiliary.cs +++ b/VectoCore/Models/SimulationComponent/Impl/DirectAuxiliary.cs @@ -1,11 +1,10 @@ using System; -using TUGraz.VectoCore.Utils; using TUGraz.VectoCore.Exceptions; -using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Connector.Ports; +using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data; - +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { @@ -55,7 +54,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (_outPort == null) { Log.ErrorFormat("{0} cannot handle incoming request - no outport available", absTime); throw new VectoSimulationException( - String.Format("{0} cannot handle incoming request - no outport available", + string.Format("{0} cannot handle incoming request - no outport available", absTime.TotalSeconds)); } diff --git a/VectoCore/Models/SimulationComponent/Impl/EngineOnlyGearbox.cs b/VectoCore/Models/SimulationComponent/Impl/EngineOnlyGearbox.cs index 50b9421f52c7595b79f39f4cf072af8a843999bd..d6b997ae048d5c2a834fb8f7080cb4cddbf59274 100644 --- a/VectoCore/Models/SimulationComponent/Impl/EngineOnlyGearbox.cs +++ b/VectoCore/Models/SimulationComponent/Impl/EngineOnlyGearbox.cs @@ -8,67 +8,66 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { - public class EngineOnlyGearbox : VectoSimulationComponent, IGearbox, ITnInPort, ITnOutPort - { - private ITnOutPort _outPort; - public EngineOnlyGearbox(IVehicleContainer cockpit) : base(cockpit) {} + public class EngineOnlyGearbox : VectoSimulationComponent, IGearbox, ITnInPort, ITnOutPort + { + private ITnOutPort _outPort; + public EngineOnlyGearbox(IVehicleContainer cockpit) : base(cockpit) {} - #region IInShaft + #region IInShaft - public ITnInPort InShaft() - { - return this; - } + public ITnInPort InShaft() + { + return this; + } - #endregion IOutShaft + #endregion IOutShaft - #region IOutShaft + #region IOutShaft - public ITnOutPort OutShaft() - { - return this; - } + public ITnOutPort OutShaft() + { + return this; + } - #endregion + #endregion - #region IGearboxCockpit + #region IGearboxCockpit - uint IGearboxCockpit.Gear() - { - return 0; - } + uint IGearboxCockpit.Gear() + { + return 0; + } - #endregion + #endregion - #region ITnInPort + #region ITnInPort - void ITnInPort.Connect(ITnOutPort other) - { - _outPort = other; - } + void ITnInPort.Connect(ITnOutPort other) + { + _outPort = other; + } - #endregion + #endregion + #region ITnOutPort - #region ITnOutPort + IResponse ITnOutPort.Request(TimeSpan absTime, TimeSpan dt, NewtonMeter torque, PerSecond engineSpeed) + { + if (_outPort == null) { + Log.ErrorFormat("{0} cannot handle incoming request - no outport available", absTime); + throw new VectoSimulationException( + string.Format("{0} cannot handle incoming request - no outport available", + absTime.TotalSeconds)); + } + return _outPort.Request(absTime, dt, torque, engineSpeed); + } - IResponse ITnOutPort.Request(TimeSpan absTime, TimeSpan dt, NewtonMeter torque, PerSecond engineSpeed) - { - if (_outPort == null) { - Log.ErrorFormat("{0} cannot handle incoming request - no outport available", absTime); - throw new VectoSimulationException( - String.Format("{0} cannot handle incoming request - no outport available", - absTime.TotalSeconds)); - } - return _outPort.Request(absTime, dt, torque, engineSpeed); - } + #endregion - #endregion + #region VectoSimulationComponent - #region VectoSimulationComponent + public override void CommitSimulationStep(IModalDataWriter writer) {} - public override void CommitSimulationStep(IModalDataWriter writer) {} - - #endregion - } + #endregion + } } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/Impl/MappingAuxiliary.cs b/VectoCore/Models/SimulationComponent/Impl/MappingAuxiliary.cs index 1182205cb286d676e8ae3e713a308cac467468ac..36425689203ff93362ad92ab08cd44948a414281 100644 --- a/VectoCore/Models/SimulationComponent/Impl/MappingAuxiliary.cs +++ b/VectoCore/Models/SimulationComponent/Impl/MappingAuxiliary.cs @@ -73,7 +73,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl if (_outPort == null) { Log.ErrorFormat("{0} cannot handle incoming request - no outport available", absTime); throw new VectoSimulationException( - String.Format("{0} cannot handle incoming request - no outport available", + string.Format("{0} cannot handle incoming request - no outport available", absTime.TotalSeconds)); } diff --git a/VectoCore/Utils/DoubleExtensionMethods.cs b/VectoCore/Utils/DoubleExtensionMethods.cs index 439afc2820fbdfe39d8fffb301dace08d3a3e5a6..813c467d955da1a563f6c49f501a2c6d97f62b80 100644 --- a/VectoCore/Utils/DoubleExtensionMethods.cs +++ b/VectoCore/Utils/DoubleExtensionMethods.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; diff --git a/VectoCore/Utils/RessourceHelper.cs b/VectoCore/Utils/RessourceHelper.cs index 5aa9a5e8bc8400355da839e2c8c26d1b304919c6..d91325e9233281882e640d6e40e8725850fbde96 100644 --- a/VectoCore/Utils/RessourceHelper.cs +++ b/VectoCore/Utils/RessourceHelper.cs @@ -1,7 +1,7 @@ using System.IO; using System.Reflection; -namespace TUGraz.VectoCore.Models +namespace TUGraz.VectoCore.Utils { public static class RessourceHelper { diff --git a/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs b/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs index 847731dcca8d27df69bcc2f18b1584f51cce2f52..6285c37b9462b0f972d1da605da3cf267a6d9942 100644 --- a/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs +++ b/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs @@ -1,6 +1,5 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; -using Microsoft.VisualStudio.TestTools.UnitTesting.Web; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Models.SimulationComponent.Data; @@ -65,25 +64,25 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle for (var j = 0; j < results.Length; j++) { var field = results[j]; // if (!Double.IsNaN(dataWriter.GetDouble(field))) - Assert.AreEqual((double) row[field.GetName()], dataWriter.GetDouble(field), + Assert.AreEqual((double)row[field.GetName()], dataWriter.GetDouble(field), 0.0001, - String.Format("t: {0} field: {1}", i, field)); + string.Format("t: {0} field: {1}", i, field)); } if (row[ModalResultField.FC.GetName()] is double && - !Double.IsNaN(Double.Parse(row[ModalResultField.FC.GetName()].ToString()))) { - Assert.AreEqual((double) row[ModalResultField.FC.GetName()], + !double.IsNaN(double.Parse(row[ModalResultField.FC.GetName()].ToString()))) { + Assert.AreEqual((double)row[ModalResultField.FC.GetName()], dataWriter.GetDouble(ModalResultField.FC), 0.01, "t: {0} field: {1}", i, ModalResultField.FC); } else { - Assert.IsTrue(Double.IsNaN(dataWriter.GetDouble(ModalResultField.FC)), - String.Format("t: {0}", i)); + Assert.IsTrue(double.IsNaN(dataWriter.GetDouble(ModalResultField.FC)), + string.Format("t: {0}", i)); } } dataWriter.CommitSimulationStep(absTime, dt); absTime += dt; } - dataWriter.Data.WriteToFile(String.Format("result_{0}.csv", TestContext.DataRow["TestName"].ToString())); + dataWriter.Data.WriteToFile(string.Format("result_{0}.csv", TestContext.DataRow["TestName"].ToString())); } [TestMethod] diff --git a/VectoCoreTest/Models/DeclarationDataTest.cs b/VectoCoreTest/Models/DeclarationDataTest.cs index c743d912163a4d532ea535e94383f5441bd0c49e..80820c564cb6663972a811bc36cca4c5247c73cc 100644 --- a/VectoCoreTest/Models/DeclarationDataTest.cs +++ b/VectoCoreTest/Models/DeclarationDataTest.cs @@ -4,9 +4,9 @@ using System.IO; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using TUGraz.VectoCore.Exceptions; -using TUGraz.VectoCore.Models; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Tests.Utils; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Tests.Models @@ -16,19 +16,6 @@ namespace TUGraz.VectoCore.Tests.Models { public const double Tolerance = 0.0001; - public static void AssertException<T>(Action func, string message = null) where T : Exception - { - try { - func(); - Assert.Fail("Expected an exception."); - } catch (T ex) { - if (!string.IsNullOrEmpty(message)) { - Assert.AreEqual(message, ex.Message); - } - } - } - - [TestMethod] public void WheelDataTest() { @@ -83,8 +70,8 @@ namespace TUGraz.VectoCore.Tests.Models // EXTRAPOLATE Assert.AreEqual(0.11, pt1.Lookup(3000.RPMtoRad()).Double(), Tolerance); - AssertException<VectoException>(() => pt1.Lookup(200.RPMtoRad())); - AssertException<VectoException>(() => pt1.Lookup(0.RPMtoRad())); + AssertHelper.Exception<VectoException>(() => pt1.Lookup(200.RPMtoRad())); + AssertHelper.Exception<VectoException>(() => pt1.Lookup(0.RPMtoRad())); } @@ -95,7 +82,7 @@ namespace TUGraz.VectoCore.Tests.Models } [TestMethod] - public void AuxESTechTest() + public void AuxElectricSystemTest() { var es = DeclarationData.ElectricSystem; @@ -115,10 +102,10 @@ namespace TUGraz.VectoCore.Tests.Models foreach (var expectation in expected) { var baseConsumption = es.Lookup(expectation.Mission, technologies: new string[] { }); - var withLEDs = es.Lookup(expectation.Mission, technologies: new[] { "LED lights" }); + var leds = es.Lookup(expectation.Mission, technologies: new[] { "LED lights" }); Assert.AreEqual(expectation.Base, baseConsumption.Double(), Tolerance); - Assert.AreEqual(expectation.LED, withLEDs.Double(), Tolerance); + Assert.AreEqual(expectation.LED, leds.Double(), Tolerance); } } @@ -188,9 +175,9 @@ namespace TUGraz.VectoCore.Tests.Models } [TestMethod] - public void AuxHVACTest() + public void AuxHeatingVentilationAirConditionTest() { - var hvac = DeclarationData.HVAC; + var hvac = DeclarationData.HeatingVentilationAirConditioning; var expected = new Dictionary<string, int[]> { { "1", new[] { 0, 150, 150, 0, 0, 0, 0, 0, 0, 0 } }, @@ -225,7 +212,7 @@ namespace TUGraz.VectoCore.Tests.Models } [TestMethod] - public void AuxPSTest() + public void AuxPneumaticSystemTest() { var ps = DeclarationData.PneumaticSystem; @@ -262,7 +249,7 @@ namespace TUGraz.VectoCore.Tests.Models } [TestMethod] - public void AuxSPTest() + public void AuxSteeringPumpTest() { var sp = DeclarationData.SteeringPump; @@ -357,7 +344,7 @@ namespace TUGraz.VectoCore.Tests.Models vehicleData.GrossVehicleMassRating, vehicleData.CurbWeight); - Assert.AreEqual("2", segment.HDVClass); + Assert.AreEqual("2", segment.VehicleClass); var data = AccelerationCurveData.ReadFromStream(segment.AccelerationFile); TestAcceleration(data); diff --git a/VectoCoreTest/Models/Simulation/SimulationTests.cs b/VectoCoreTest/Models/Simulation/SimulationTests.cs index a2c60c1abff0342097ed05cfdb608ba814200774..57899da5086e85e91fadf92294ff7a0925036b68 100644 --- a/VectoCoreTest/Models/Simulation/SimulationTests.cs +++ b/VectoCoreTest/Models/Simulation/SimulationTests.cs @@ -4,8 +4,8 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; -using TUGraz.VectoCore.Utils; using TUGraz.VectoCore.Tests.Utils; +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Tests.Models.Simulation { diff --git a/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs b/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs index 948f42e378784a6f39477f2690410d2e328aab5f..8282b61b20c270f3592c8a4a638ea89bd9b6a76d 100644 --- a/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs +++ b/VectoCoreTest/Models/SimulationComponent/ClutchTest.cs @@ -1,6 +1,5 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; -using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Impl; @@ -34,22 +33,22 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent gearbox.CurrentGear = 1; clutchOutPort.Request(new TimeSpan(), new TimeSpan(), 100.SI<NewtonMeter>(), 30.SI<PerSecond>()); - Assert.AreEqual(48.293649, (double) outPort.Torque, 0.001); - Assert.AreEqual(62.119969, (double) outPort.AngularVelocity, 0.001); + Assert.AreEqual(48.293649, (double)outPort.Torque, 0.001); + Assert.AreEqual(62.119969, (double)outPort.AngularVelocity, 0.001); //Test - Clutch opened gearbox.CurrentGear = 0; clutchOutPort.Request(new TimeSpan(), new TimeSpan(), 100.SI<NewtonMeter>(), 30.SI<PerSecond>()); - Assert.AreEqual(0, (double) outPort.Torque, 0.001); - Assert.AreEqual((double) engineData.IdleSpeed, (double) outPort.AngularVelocity, 0.001); + Assert.AreEqual(0, (double)outPort.Torque, 0.001); + Assert.AreEqual((double)engineData.IdleSpeed, (double)outPort.AngularVelocity, 0.001); //Test - Clutch closed gearbox.CurrentGear = 1; clutchOutPort.Request(new TimeSpan(), new TimeSpan(), 100.SI<NewtonMeter>(), 80.SI<PerSecond>()); - Assert.AreEqual(100.0, (double) outPort.Torque, 0.001); - Assert.AreEqual(80.0, (double) outPort.AngularVelocity, 0.001); + Assert.AreEqual(100.0, (double)outPort.Torque, 0.001); + Assert.AreEqual(80.0, (double)outPort.AngularVelocity, 0.001); } } } \ No newline at end of file diff --git a/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs b/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs index d463a857787ea1f1b59e97eb24ffa1336f4fe93e..1c41b67f463a96fe837dec8858891d106c47d083 100644 --- a/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs +++ b/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Reflection; using Microsoft.VisualStudio.TestTools.UnitTesting; -using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Models.SimulationComponent.Data; @@ -25,24 +24,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent AppDomain.CurrentDomain.SetData("DataDirectory", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); } - /// <summary> - /// Assert an expected Exception. - /// </summary> - /// <typeparam name="T"></typeparam> - /// <param name="func"></param> - /// <param name="message"></param> - public static void AssertException<T>(Action func, string message = null) where T : Exception - { - try { - func(); - Assert.Fail("Expected Exception {0}, but no exception occured.", typeof(T)); - } catch (T ex) { - if (message != null) { - Assert.AreEqual(message, ex.Message); - } - } - } - [TestMethod] public void TestEngineHasOutPort() { @@ -79,7 +60,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent var vehicle = new VehicleContainer(); var engineData = CombustionEngineData.ReadFromFile(CoachEngine); var engine = new CombustionEngine(vehicle, engineData); - var gearbox = new EngineOnlyGearbox(vehicle); + new EngineOnlyGearbox(vehicle); var port = engine.OutShaft(); var absTime = new TimeSpan(seconds: 0, minutes: 0, hours: 0); @@ -108,7 +89,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent absTime += dt; var power = new[] { 569.3641, 4264.177 }; - ; for (var i = 0; i < 2; i++) { port.Request(absTime, dt, Formulas.PowerToTorque(power[i].SI<Watt>(), engineSpeed), engineSpeed); engine.CommitSimulationStep(dataWriter); @@ -131,7 +111,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent Assert.AreEqual(-7108.32, dataWriter.GetDouble(ModalResultField.PaEng), 0.001); dataWriter.CommitSimulationStep(absTime, dt); - absTime += dt; dataWriter.Data.WriteToFile(@"test1.csv"); } @@ -156,9 +135,9 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent //var modalData = new ModalDataWriter(string.Format("load_jump_{0}.csv", TestContext.DataRow["TestName"].ToString())); var modalData = new TestModalDataWriter(); - var idlePower = Double.Parse(TestContext.DataRow["initialIdleLoad"].ToString()).SI<Watt>(); + var idlePower = double.Parse(TestContext.DataRow["initialIdleLoad"].ToString()).SI<Watt>(); - var angularSpeed = Double.Parse(TestContext.DataRow["rpm"].ToString()).RPMtoRad(); + var angularSpeed = double.Parse(TestContext.DataRow["rpm"].ToString()).RPMtoRad(); var t = TimeSpan.FromSeconds(0); var dt = TimeSpan.FromSeconds(0.1); @@ -172,7 +151,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent // dt = TimeSpan.FromSeconds(double.Parse(TestContext.DataRow["dt"].ToString(), CultureInfo.InvariantCulture)); // dt = TimeSpan.FromSeconds(expectedResults.Rows[i].ParseDouble(0)) - t; var engineLoadPower = engineData.GetFullLoadCurve(0).FullLoadStationaryPower(angularSpeed); - idlePower = Double.Parse(TestContext.DataRow["finalIdleLoad"].ToString()).SI<Watt>(); + idlePower = double.Parse(TestContext.DataRow["finalIdleLoad"].ToString()).SI<Watt>(); for (; t.TotalSeconds < 25; t += dt, i++) { dt = TimeSpan.FromSeconds(expectedResults.Rows[i + 1].ParseDouble(0) - expectedResults.Rows[i].ParseDouble(0)); if (t >= TimeSpan.FromSeconds(10)) { @@ -185,7 +164,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent // todo: compare results... Assert.AreEqual(expectedResults.Rows[i].ParseDouble(0), t.TotalSeconds, 0.001, "Time"); Assert.AreEqual(expectedResults.Rows[i].ParseDouble(1), modalData.GetDouble(ModalResultField.Pe_full), 0.1, - String.Format("Load in timestep {0}", t)); + string.Format("Load in timestep {0}", t)); modalData.CommitSimulationStep(); } modalData.Finish(); @@ -257,9 +236,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent Assert.AreEqual(58.6430628670095, idle.Double(), 0.000001); Assert.IsTrue(idle.HasEqualUnit(0.SI<PerSecond>())); - var flc0 = engineData.GetFullLoadCurve(0); - - AssertException<KeyNotFoundException>(() => { var flc10000 = engineData.GetFullLoadCurve(1000); }); + engineData.GetFullLoadCurve(0); + AssertHelper.Exception<KeyNotFoundException>(() => engineData.GetFullLoadCurve(1000)); } } } \ No newline at end of file diff --git a/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs b/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs index 30c5ea32495d94fa710064c44a1c316250b36053..508dee2cba7bfe4a2ef3e33aef2830b369c1641b 100644 --- a/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs +++ b/VectoCoreTest/Models/SimulationComponent/VehicleTest.cs @@ -1,7 +1,6 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using TUGraz.VectoCore.Models.Simulation.Impl; -using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Factories; using TUGraz.VectoCore.Models.SimulationComponent.Impl; using TUGraz.VectoCore.Tests.Utils; diff --git a/VectoCoreTest/Models/SimulationComponent/WheelsTest.cs b/VectoCoreTest/Models/SimulationComponent/WheelsTest.cs index 9a874c5931e895f3ed3d28f4b77cd8b164b4424f..e5ad1d5947c938a0b3fe62815f68706eb28d6ec2 100644 --- a/VectoCoreTest/Models/SimulationComponent/WheelsTest.cs +++ b/VectoCoreTest/Models/SimulationComponent/WheelsTest.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Models.SimulationComponent; -using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Factories; using TUGraz.VectoCore.Models.SimulationComponent.Impl; using TUGraz.VectoCore.Tests.Utils; diff --git a/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs b/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs index 7e66f3f63f80cd46db6a6cdb02101b793e7c3369..53eb73c7d6c92632f79aa4350f9dfa297554194f 100644 --- a/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs +++ b/VectoCoreTest/Models/SimulationComponentData/FullLoadCurveTest.cs @@ -1,7 +1,7 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; +using TUGraz.VectoCore.Tests.Utils; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData @@ -77,12 +77,9 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData [TestMethod] public void Test_FileRead_WrongFileFormat_InsufficientColumns() { - try { - var curve = FullLoadCurve.ReadFromFile(@"TestData\Components\FullLoadCurve insufficient columns.vfld"); - Assert.Fail("this should not be reached."); - } catch (VectoException ex) { - Assert.AreEqual("FullLoadCurve Data File must consist of 4 columns.", ex.Message); - } + AssertHelper.Exception<VectoException>( + () => FullLoadCurve.ReadFromFile(@"TestData\Components\FullLoadCurve insufficient columns.vfld"), + "FullLoadCurve Data File must consist of 4 columns."); } /// <summary> @@ -112,14 +109,9 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData [TestMethod] public void Test_FileRead_InsufficientEntries() { - try { - FullLoadCurve.ReadFromFile(@"TestData\Components\FullLoadCurve insufficient entries.vfld"); - Assert.Fail("this should not be reached."); - } catch (VectoException ex) { - Assert.AreEqual( - "FullLoadCurve must consist of at least two lines with numeric values (below file header)", - ex.Message); - } + AssertHelper.Exception<VectoException>( + () => FullLoadCurve.ReadFromFile(@"TestData\Components\FullLoadCurve insufficient entries.vfld"), + "FullLoadCurve must consist of at least two lines with numeric values (below file header)"); } } } \ No newline at end of file diff --git a/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs b/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs index b244798b843cf63a5c8c4041ad548620cf1d811e..976ce6a40b0672ce065282f401ad6b019c6c9716 100644 --- a/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs +++ b/VectoCoreTest/Models/SimulationComponentData/GearboxDataTest.cs @@ -3,6 +3,7 @@ using System.Globalization; using Microsoft.VisualStudio.TestTools.UnitTesting; using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Tests.Utils; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData @@ -46,8 +47,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData var gbxData = GearboxData.ReadFromFile(TestContext.DataRow["GearboxDataFile"].ToString()); - - var PvD = Double.Parse(TestContext.DataRow["PowerGbxOut"].ToString(), CultureInfo.InvariantCulture).SI<Watt>(); + var PvD = double.Parse(TestContext.DataRow["PowerGbxOut"].ToString(), CultureInfo.InvariantCulture).SI<Watt>(); var torqueToWheels = Formulas.PowerToTorque(PvD, SpeedToAngularSpeed(speed, rdyn)); var torqueFromEngine = 0.SI<NewtonMeter>(); @@ -60,7 +60,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData var powerEngine = Formulas.TorqueToPower(torqueFromEngine, angSpeed); var loss = powerEngine - PvD; - Assert.AreEqual(Double.Parse(TestContext.DataRow["GbxPowerLoss"].ToString(), CultureInfo.InvariantCulture), + Assert.AreEqual(double.Parse(TestContext.DataRow["GbxPowerLoss"].ToString(), CultureInfo.InvariantCulture), loss.Double(), 0.1, TestContext.DataRow["TestName"].ToString()); } @@ -70,43 +70,17 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData { var gbxData = GearboxData.ReadFromFile(GearboxFile); + AssertHelper.Exception<VectoSimulationException>( + () => gbxData.AxleGearData.LossMap.GearboxInTorque(2700.RPMtoRad(), 100.SI<NewtonMeter>())); - var angSpeed = 2700.RPMtoRad(); - var torqueToWheels = 100.SI<NewtonMeter>(); - - try { - gbxData.AxleGearData.LossMap.GearboxInTorque(angSpeed, torqueToWheels); - Assert.Fail("angular Speed too high"); - } catch (Exception e) { - Assert.IsInstanceOfType(e, typeof(VectoSimulationException), "angular speed too high"); - } + AssertHelper.Exception<VectoSimulationException>( + () => gbxData.AxleGearData.LossMap.GearboxInTorque(1000.RPMtoRad(), 50000.SI<NewtonMeter>())); - angSpeed = 1000.RPMtoRad(); - torqueToWheels = 50000.SI<NewtonMeter>(); - try { - gbxData.AxleGearData.LossMap.GearboxInTorque(angSpeed, torqueToWheels); - Assert.Fail("torque too high"); - } catch (Exception e) { - Assert.IsInstanceOfType(e, typeof(VectoSimulationException), "torque too high"); - } + AssertHelper.Exception<VectoSimulationException>( + () => gbxData.AxleGearData.LossMap.GearboxInTorque(1000.RPMtoRad(), -10000.SI<NewtonMeter>())); - angSpeed = 1000.RPMtoRad(); - torqueToWheels = -10000.SI<NewtonMeter>(); - try { - gbxData.AxleGearData.LossMap.GearboxInTorque(angSpeed, torqueToWheels); - Assert.Fail("torque too low"); - } catch (Exception e) { - Assert.IsInstanceOfType(e, typeof(VectoSimulationException), "torque too low"); - } - - angSpeed = -1000.RPMtoRad(); - torqueToWheels = 500.SI<NewtonMeter>(); - try { - gbxData.AxleGearData.LossMap.GearboxInTorque(angSpeed, torqueToWheels); - Assert.Fail("negative angular speed"); - } catch (Exception e) { - Assert.IsInstanceOfType(e, typeof(VectoSimulationException), "negative angular speed"); - } + AssertHelper.Exception<VectoSimulationException>( + () => gbxData.AxleGearData.LossMap.GearboxInTorque(-1000.RPMtoRad(), 500.SI<NewtonMeter>())); } protected PerSecond SpeedToAngularSpeed(double v, double r) diff --git a/VectoCoreTest/Utils/AssertHelper.cs b/VectoCoreTest/Utils/AssertHelper.cs new file mode 100644 index 0000000000000000000000000000000000000000..7236d9bf6e77d9e8634a18b3d44c54bf5782e067 --- /dev/null +++ b/VectoCoreTest/Utils/AssertHelper.cs @@ -0,0 +1,24 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace TUGraz.VectoCore.Tests.Utils +{ + public class AssertHelper + { + /// <summary> + /// Assert an expected Exception. + /// </summary> + public static void Exception<T>(Action func, string message = null) where T : Exception + { + try { + func(); + Assert.Fail("Expected Exception {0}, but no exception occured.", typeof(T)); + } catch (T ex) { + if (!string.IsNullOrEmpty(message)) { + Assert.AreEqual(message, ex.Message, + string.Format("Expected Exception message: {0}, but got message: {}", message, ex.Message)); + } + } + } + } +} \ No newline at end of file diff --git a/VectoCoreTest/Utils/DummyGearbox.cs b/VectoCoreTest/Utils/DummyGearbox.cs index fd22e802a5d16901885b302aa53e7a6fbb0ff039..e1e361018671d4a4e5e2f302c80707a4c81e06bf 100644 --- a/VectoCoreTest/Utils/DummyGearbox.cs +++ b/VectoCoreTest/Utils/DummyGearbox.cs @@ -1,5 +1,4 @@ using System; -using TUGraz.VectoCore.Exceptions; using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Simulation; using TUGraz.VectoCore.Models.Simulation.Data; diff --git a/VectoCoreTest/Utils/ResultFileHelper.cs b/VectoCoreTest/Utils/ResultFileHelper.cs index 3658b316ca073787a1d4174a1f50b11f8dbeb02a..6983a3a49b6a933da100811ec0553c0edb8a8f4b 100644 --- a/VectoCoreTest/Utils/ResultFileHelper.cs +++ b/VectoCoreTest/Utils/ResultFileHelper.cs @@ -1,8 +1,8 @@ using System; -using System.IO; +using System.Collections.Generic; using System.Data; +using System.IO; using System.Linq; -using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; using TUGraz.VectoCore.Models.Simulation.Data; diff --git a/VectoCoreTest/Utils/TestSumWriter.cs b/VectoCoreTest/Utils/TestSumWriter.cs index 803f01004a12cf920625bbcb5d4f4f89a8d6549e..d24cf56fa9caea27e382d782e3d775add50649e1 100644 --- a/VectoCoreTest/Utils/TestSumWriter.cs +++ b/VectoCoreTest/Utils/TestSumWriter.cs @@ -1,6 +1,6 @@ using TUGraz.VectoCore.Models.Simulation.Data; -namespace TUGraz.VectoCore.Tests.Models.Simulation +namespace TUGraz.VectoCore.Tests.Utils { public class TestSumWriter : SummaryFileWriter, ISummaryDataWriter { diff --git a/VectoCoreTest/VectoCoreTest.csproj b/VectoCoreTest/VectoCoreTest.csproj index d7ae801e174635e2ac088b74ba9ae0d47ba2936d..4986286459103404c35b2f53099ab0e063d1bd1f 100644 --- a/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCoreTest/VectoCoreTest.csproj @@ -83,6 +83,7 @@ <Compile Include="Models\SimulationComponent\WheelsTest.cs" /> <Compile Include="Models\SimulationComponent\VehicleTest.cs" /> <Compile Include="Models\Simulation\DrivingCycleTests.cs" /> + <Compile Include="Utils\AssertHelper.cs" /> <Compile Include="Utils\ResultFileHelper.cs" /> <Compile Include="Utils\MockPorts.cs" /> <Compile Include="Models\Simulation\SimulationTests.cs" />