From 47af8af576e6971369e7792b3d7f63b19b2fc104 Mon Sep 17 00:00:00 2001 From: Michael Krisper <michael.krisper@tugraz.at> Date: Thu, 17 Jun 2021 16:26:14 +0200 Subject: [PATCH] inlined out variables --- .../ViewModel/HashComponentDataViewModel.cs | 3 +-- .../ViewModel/UserControl/XMLFileSelector.cs | 3 +-- .../Utils/EnumerableExtensionMethods.cs | 3 +-- .../ComponentData/TransmissionLossMapReader.cs | 6 +++--- .../Models/Declaration/AuxiliaryTypeHelper.cs | 3 +-- .../Models/Declaration/TruckSegments.cs | 3 +-- .../Models/Simulation/Impl/SimulatorFactory.cs | 4 +--- .../Data/CrosswindCorrectionVAirBeta.cs | 4 ++-- .../Models/SimulationComponent/Impl/Clutch.cs | 5 +---- .../Impl/DefaultDriverStrategy.cs | 3 +-- .../VectoCore/OutputData/ModalDataContainer.cs | 6 ++---- .../Factory/EngineeringWriterFactory.cs | 3 +-- .../Utils/DataTableExtensionMethods.cs | 3 +-- .../Utils/DateTimeFallbackDeserializer.cs | 3 +-- .../Utils/DictionaryExtensionMethods.cs | 6 ++---- .../BusAuxiliaries/AuxDemandTest.cs | 6 ++---- .../BusAuxiliaries/BusAdapterTest.cs | 12 ++++-------- .../Models/Declaration/ShiftPolygonTest.cs | 12 ++++-------- .../CombustionEngineTest.cs | 18 +++--------------- .../GearboxShiftLossesTest.cs | 10 ++-------- VectoCore/VectoCoreTest/Utils/VectoMathTest.cs | 6 ++---- 21 files changed, 37 insertions(+), 85 deletions(-) diff --git a/HashingTool/ViewModel/HashComponentDataViewModel.cs b/HashingTool/ViewModel/HashComponentDataViewModel.cs index fe6ab69fce..250f91d82a 100644 --- a/HashingTool/ViewModel/HashComponentDataViewModel.cs +++ b/HashingTool/ViewModel/HashComponentDataViewModel.cs @@ -94,8 +94,7 @@ namespace HashingTool.ViewModel private void SaveDocument() { - string filename; - var stream = IoService.SaveData(null, ".xml", "VECTO XML file|*.xml", out filename); + var stream = IoService.SaveData(null, ".xml", "VECTO XML file|*.xml", out var filename); if (stream == null) { return; } diff --git a/HashingTool/ViewModel/UserControl/XMLFileSelector.cs b/HashingTool/ViewModel/UserControl/XMLFileSelector.cs index 4db604806c..17cadc6c8c 100644 --- a/HashingTool/ViewModel/UserControl/XMLFileSelector.cs +++ b/HashingTool/ViewModel/UserControl/XMLFileSelector.cs @@ -188,9 +188,8 @@ namespace HashingTool.ViewModel.UserControl private async void BrowseXMLFile() { - string filename; try { - using (var stream = IoService.OpenFileDialog(null, ".xml", "VECTO XML file|*.xml", out filename)) { + using (var stream = IoService.OpenFileDialog(null, ".xml", "VECTO XML file|*.xml", out var filename)) { if (stream == null) { return; } diff --git a/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs b/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs index 91fc0e370f..71ce8990d5 100644 --- a/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs +++ b/VectoCommon/VectoCommon/Utils/EnumerableExtensionMethods.cs @@ -163,8 +163,7 @@ namespace TUGraz.VectoCommon.Utils /// <example>GetSection(data => data.X < searchedX); //returns the pair where first < searchedX and second >= searchedX</example>> public static Tuple<T, T> GetSection<T>(this IEnumerable<T> self, Func<T, bool> predicate, string message = null) { - int unused; - return self.GetSection(predicate, out unused, message); + return self.GetSection(predicate, out var unused, message); } public static TSource MinBy<TSource>(this IEnumerable<TSource> source, diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs index 148820f493..2ca923c591 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/TransmissionLossMapReader.cs @@ -157,9 +157,9 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData if (speedBucket.Value.Count < 2) { continue; } - double k, d, r; - VectoMath.LeastSquaresFitting(speedBucket.Value, x => x.InputTorque.Value(), x => x.TorqueLoss.Value(), out k, out d, - out r); + + VectoMath.LeastSquaresFitting(speedBucket.Value, x => x.InputTorque.Value(), x => x.TorqueLoss.Value(), out var k, out var d, + out var r); for (var i = 2; i <= DeclarationData.LossMapExtrapolationFactor; i++) { var inTq = i * maxTorque; diff --git a/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs b/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs index be9d3aed49..4d9216c12f 100644 --- a/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs +++ b/VectoCore/VectoCore/Models/Declaration/AuxiliaryTypeHelper.cs @@ -60,8 +60,7 @@ namespace TUGraz.VectoCore.Models.Declaration public static AuxiliaryType Parse(string s) { - AuxiliaryType aux; - return StrToAux.TryGetValue(s, out aux) ? aux : AuxiliaryType.Fan; + return StrToAux.TryGetValue(s, out var aux) ? aux : AuxiliaryType.Fan; } public static AuxiliaryType ParseKey(string s) diff --git a/VectoCore/VectoCore/Models/Declaration/TruckSegments.cs b/VectoCore/VectoCore/Models/Declaration/TruckSegments.cs index 7c78137936..623c4f7af9 100644 --- a/VectoCore/VectoCore/Models/Declaration/TruckSegments.cs +++ b/VectoCore/VectoCore/Models/Declaration/TruckSegments.cs @@ -194,10 +194,9 @@ namespace TUGraz.VectoCore.Models.Declaration var payloads = row.Field<string>(missionType.ToString()); - Kilogram refLoad, lowLoad; var weight = grossVehicleWeight; GetLoadings( - out lowLoad, out refLoad, payloads, (p, l) => GetLoading(p, weight, vehicleWeight, trailers, l), maxLoad); + out var lowLoad, out var refLoad, payloads, (p, l) => GetLoading(p, weight, vehicleWeight, trailers, l), maxLoad); var mission = new Mission { MissionType = missionType, diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs index bddcacb7b1..3f301f8510 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs @@ -73,9 +73,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ModWriter = writer; Validate = validate; - int workerThreads; - int completionThreads; - ThreadPool.GetMinThreads(out workerThreads, out completionThreads); + ThreadPool.GetMinThreads(out var workerThreads, out var completionThreads); if (workerThreads < 12) { workerThreads = 12; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs index dfcfbfbd5e..0e63c8286c 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/CrosswindCorrectionVAirBeta.cs @@ -95,8 +95,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data if (beta > AirDragEntries.Last().Beta) { throw new VectoSimulationException("Beta / CdxA Lookup table does not cover beta={0}", beta); } - int index; - AirDragEntries.GetSection(x => x.Beta < beta, out index); + + AirDragEntries.GetSection(x => x.Beta < beta, out var index); return index + 1; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs index ea68172d45..e8a0b34f8e 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs @@ -173,16 +173,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected virtual IResponse HandleClutchClosed(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun) { - NewtonMeter torqueIn; - PerSecond angularVelocityIn; - var startClutch = DataBus.VehicleInfo.VehicleStopped || !PreviousState.ClutchLoss.IsEqual(0, 1e-3) || (outAngularVelocity.IsSmaller(DataBus.EngineInfo.EngineSpeed, 1e-3) && !DataBus.EngineInfo.EngineOn); // || (PreviousState.ClutchLoss.IsEqual(0) && outAngularVelocity.IsSmaller(DataBus.EngineInfo.EngineIdleSpeed)); var slippingClutchWhenDriving = (DataBus.GearboxInfo.Gear.Gear <= 2 && DataBus.DriverInfo.DriverBehavior != DrivingBehavior.Braking); var slippingClutchDuringBraking = DataBus.GearboxInfo.Gear.Gear == 1 && DataBus.DriverInfo.DriverBehavior == DrivingBehavior.Braking && outTorque > 0 && DataBus.Brakes.BrakePower.IsEqual(0); //var slippingClutchWhenDriving = (DataBus.Gear == 1 && outTorque > 0); AddClutchLoss(outTorque, outAngularVelocity, slippingClutchWhenDriving || slippingClutchDuringBraking || startClutch || outAngularVelocity.IsEqual(0), - out torqueIn, out angularVelocityIn); + out var torqueIn, out var angularVelocityIn); Log.Debug("to Engine: torque: {0}, angularVelocity: {1}, power {2}", torqueIn, angularVelocityIn, Formulas.TorqueToPower(torqueIn, angularVelocityIn)); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index ad284fb5ad..219dfb3514 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -804,8 +804,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return response; } - Meter newds; - response = CheckRequestDoesNotExceedNextAction(absTime, ds, targetVelocity, gradient, response, out newds); + response = CheckRequestDoesNotExceedNextAction(absTime, ds, targetVelocity, gradient, response, out var newds); if (ds.IsEqual(newds, 1e-3.SI<Meter>())) { return response; diff --git a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs index 4010b4f04b..69b0902db8 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs @@ -201,7 +201,6 @@ namespace TUGraz.VectoCore.OutputData return _engLine[fuel.FuelType]; } - double k, d, r; VectoMath.LeastSquaresFitting( GetValues( x => x.Field<bool>(ModalResultField.ICEOn.GetName()) @@ -209,7 +208,7 @@ namespace TUGraz.VectoCore.OutputData x.Field<SI>(ModalResultField.P_ice_fcmap.GetName()).Value(), x.Field<SI>(GetColumnName(fuel, ModalResultField.FCFinal)).Value()) : null).Where(x => x != null && x.Y > 0), - out k, out d, out r); + out var k, out var d, out var r); if (double.IsInfinity(k) || double.IsNaN(k)) { LogManager.GetLogger(typeof(ModalDataContainer).FullName).Warn("could not calculate engine correction line - k: {0}", k); k = 0; @@ -226,7 +225,6 @@ namespace TUGraz.VectoCore.OutputData } if (Data.AsEnumerable().Any(r => r.Field<SI>(ModalResultField.P_wheel_in.GetName()) != null)) { - double k, d, r; VectoMath.LeastSquaresFitting( GetValues( row => row.Field<bool>(ModalResultField.ICEOn.GetName()) @@ -234,7 +232,7 @@ namespace TUGraz.VectoCore.OutputData row.Field<SI>(ModalResultField.P_wheel_in.GetName()).Value(), row.Field<SI>(GetColumnName(fuel, ModalResultField.FCFinal)).Value()) : null) - .Where(x => x != null && x.X > 0 && x.Y > 0), out k, out d, out r); + .Where(x => x != null && x.X > 0 && x.Y > 0), out var k, out var d, out var r); if (double.IsInfinity(k) || double.IsNaN(k)) { LogManager.GetLogger(typeof(ModalDataContainer).FullName).Warn("could not calculate vehicle correction line - k: {0}", k); k = 0; diff --git a/VectoCore/VectoCore/OutputData/XML/Engineering/Factory/EngineeringWriterFactory.cs b/VectoCore/VectoCore/OutputData/XML/Engineering/Factory/EngineeringWriterFactory.cs index 2bfc8b0288..a352fea41f 100644 --- a/VectoCore/VectoCore/OutputData/XML/Engineering/Factory/EngineeringWriterFactory.cs +++ b/VectoCore/VectoCore/OutputData/XML/Engineering/Factory/EngineeringWriterFactory.cs @@ -112,8 +112,7 @@ namespace TUGraz.VectoCore.OutputData.XML.Engineering.Factory var bindings = Kernel.GetBindings(writerType).ToArray(); if (bindings.Any()) { var mostRecent = bindings.MaxBy(b => { - double retVal; - var success = double.TryParse(b.Metadata.Name, NumberStyles.Float, CultureInfo.InvariantCulture, out retVal); + var success = double.TryParse(b.Metadata.Name, NumberStyles.Float, CultureInfo.InvariantCulture, out var retVal); return success ? retVal : -1; }).Metadata.Name; return GetEngineeringWriter(inputDataType, mostRecent, writerType, xmlEngineeringWriter); diff --git a/VectoCore/VectoCore/Utils/DataTableExtensionMethods.cs b/VectoCore/VectoCore/Utils/DataTableExtensionMethods.cs index 3df85156f2..2c2813ab4a 100644 --- a/VectoCore/VectoCore/Utils/DataTableExtensionMethods.cs +++ b/VectoCore/VectoCore/Utils/DataTableExtensionMethods.cs @@ -44,8 +44,7 @@ namespace TUGraz.VectoCore.Utils double defaultValue = default(double)) { if (row.Table.Columns.Contains(columnName)) { - double result; - if (double.TryParse(row.Field<string>(columnName), NumberStyles.Any, CultureInfo.InvariantCulture, out result)) { + if (double.TryParse(row.Field<string>(columnName), NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } } diff --git a/VectoCore/VectoCore/Utils/DateTimeFallbackDeserializer.cs b/VectoCore/VectoCore/Utils/DateTimeFallbackDeserializer.cs index ee28f9a925..0a88875261 100644 --- a/VectoCore/VectoCore/Utils/DateTimeFallbackDeserializer.cs +++ b/VectoCore/VectoCore/Utils/DateTimeFallbackDeserializer.cs @@ -48,12 +48,11 @@ namespace TUGraz.VectoCore.Utils { public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - DateTime dateTime; if (reader.TokenType == JsonToken.Date) { return reader.Value; } if (DateTime.TryParseExact((string)reader.Value, new[] { "d.M.yyyy HH:mm:ss", "M/d/yyyy HH:mm:ss tt" }, - CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) { + CultureInfo.InvariantCulture, DateTimeStyles.None, out var dateTime)) { return DateTime.SpecifyKind(dateTime, DateTimeKind.Utc); } diff --git a/VectoCore/VectoCore/Utils/DictionaryExtensionMethods.cs b/VectoCore/VectoCore/Utils/DictionaryExtensionMethods.cs index 1261eff951..c4949b7be8 100644 --- a/VectoCore/VectoCore/Utils/DictionaryExtensionMethods.cs +++ b/VectoCore/VectoCore/Utils/DictionaryExtensionMethods.cs @@ -39,15 +39,13 @@ namespace TUGraz.VectoCore.Utils { public static object GetValueOrNull<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key) { - TValue value; - return dictionary.TryGetValue(key, out value) ? (object)value : DBNull.Value; + return dictionary.TryGetValue(key, out var value) ? (object)value : DBNull.Value; } public static TValue GetValueOrZero<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key) where TValue : SIBase<TValue> { - TValue value; - return dictionary.TryGetValue(key, out value) ? value : 0.SI<TValue>(); + return dictionary.TryGetValue(key, out var value) ? value : 0.SI<TValue>(); } } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs index 980c220ad3..3d12cc8479 100644 --- a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs +++ b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs @@ -67,8 +67,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries public void AuxDemandtest(double vehicleWeight, double engineSpeedRpm, double driveLinePower, double internalPower, double expectedPowerDemand) { - MockDriver driver; - var busAux = CreateBusAuxAdapterForTesting(vehicleWeight, out driver); + var busAux = CreateBusAuxAdapterForTesting(vehicleWeight, out var driver); var engineDrivelinePower = (driveLinePower * 1000).SI<Watt>(); var engineSpeed = engineSpeedRpm.RPMtoRad(); @@ -86,8 +85,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries var engineSpeedRpm = 1256; var internalPower = 148; - MockDriver driver; - var busAux = CreateBusAuxAdapterForTesting(12000, out driver); + var busAux = CreateBusAuxAdapterForTesting(12000, out var driver); var engineDrivelinePower = (driveLinePower * 1000).SI<Watt>(); var engineSpeed = engineSpeedRpm.RPMtoRad(); diff --git a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs index 235238dfcb..97edc78a58 100644 --- a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs +++ b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs @@ -61,8 +61,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries public void TestNoSmartAuxDuringDrive(double vehicleWeight, double engineSpeedRpm, double driveLinePower, double internalPower, double expectedPowerDemand) { - MockDriver driver; - var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out driver); + var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out var driver); driver.DriverBehavior = DrivingBehavior.Driving; driver.DrivingAction = DrivingAction.Accelerate; @@ -93,8 +92,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries // this test is to make sure that the aux power-demand does not jump between average and smart power demand // when searching for the operating point for coasting (i.e. power demand (internal Power) is close to the motoring curve, // intependent of power demand of power train) - MockDriver driver; - var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out driver); + var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out var driver); driver.DriverBehavior = DrivingBehavior.Coasting; driver.DrivingAction = DrivingAction.Coast; @@ -116,8 +114,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries public void TestSmartAuxDuringBrake(double vehicleWeight, double engineSpeedRpm, double driveLinePower, double internalPower, double expectedPowerDemand) { - MockDriver driver; - var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out driver); + var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out var driver); driver.DriverBehavior = DrivingBehavior.Braking; driver.DrivingAction = DrivingAction.Brake; @@ -135,8 +132,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries TestCase(19000)] public void AuxDemandContinuityTest(double vehicleWeight) { - MockDriver driver; - var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out driver); + var busAux = AuxDemandTest.CreateBusAuxAdapterForTesting(vehicleWeight, out var driver); driver.DriverBehavior = DrivingBehavior.Driving; diff --git a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs index 9da5f36fb6..c6d4382d70 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs @@ -576,10 +576,9 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration shiftPolygons.Add(DeclarationData.Gearbox.ComputeShiftPolygon(GearboxType.AMT, i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, engineData, axlegearRatio, rdyn, null)); - List<Point> tmp1, tmp2, tmp3; ShiftPolygonComparison.ComputShiftPolygonPoints(i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, - engineData, axlegearRatio, rdyn, out tmp1, out tmp2, out tmp3); + engineData, axlegearRatio, rdyn, out var tmp1, out var tmp2, out var tmp3); upshiftOrig.Add(tmp1); downshiftTransformed.Add(tmp2); downshiftOrig.Add(tmp3); @@ -636,10 +635,9 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration shiftPolygons.Add(DeclarationData.Gearbox.ComputeShiftPolygon(GearboxType.AMT, i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, engineData, axlegearRatio, rdyn, null)); - List<Point> tmp1, tmp2, tmp3; ShiftPolygonComparison.ComputShiftPolygonPoints(i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, - engineData, axlegearRatio, rdyn, out tmp1, out tmp2, out tmp3); + engineData, axlegearRatio, rdyn, out var tmp1, out var tmp2, out var tmp3); upshiftOrig.Add(tmp1); downshiftTransformed.Add(tmp2); downshiftOrig.Add(tmp3); @@ -739,9 +737,8 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration DeclarationData.Gearbox.ComputeShiftPolygon(gearboxData.Type, i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, engineData, axlegearRatio, rdyn.SI<Meter>(), null) ); - List<Point> tmp1, tmp2, tmp3; ComputShiftPolygonPoints(i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, - engineData, axlegearRatio, rdyn.SI<Meter>(), out tmp1, out tmp2, out tmp3); + engineData, axlegearRatio, rdyn.SI<Meter>(), out var tmp1, out var tmp2, out var tmp3); upshiftOrig.Add(tmp1); downshiftTransformed.Add(tmp2); } @@ -897,9 +894,8 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration DeclarationData.Gearbox.ComputeShiftPolygon(gearboxData.Type, i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, engineData, axlegearRatio, rdyn, null) ); - List<Point> tmp1, tmp2, tmp3; ComputShiftPolygonPoints(i, fullLoadCurves[(uint)(i + 1)], gearboxData.Gears, - engineData, axlegearRatio, rdyn, out tmp1, out tmp2, out tmp3); + engineData, axlegearRatio, rdyn, out var tmp1, out var tmp2, out var tmp3); upshiftOrig.Add(tmp1); downshiftTransformed.Add(tmp2); } diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs index b0c6c9d4d8..a5c6c0c3da 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/CombustionEngineTest.cs @@ -349,11 +349,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent [TestCase] public void EngineIdleControllerTestCoach() { - VehicleContainer container; - CombustionEngine engine; - ITnOutPort requestPort; - MockGearbox gearbox; - VehicleContainer(CoachEngine, out container, out engine, out requestPort, out gearbox); + VehicleContainer(CoachEngine, out var container, out var engine, out var requestPort, out var gearbox); var absTime = 0.SI<Second>(); var dt = Constants.SimulationSettings.TargetTimeInterval; @@ -404,11 +400,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent [TestCase] public void EngineIdleControllerTestTruck() { - VehicleContainer container; - CombustionEngine engine; - ITnOutPort requestPort; - MockGearbox gearbox; - VehicleContainer(TruckEngine, out container, out engine, out requestPort, out gearbox); + VehicleContainer(TruckEngine, out var container, out var engine, out var requestPort, out var gearbox); //var dataWriter = new ModalDataWriter("EngineIdle.vmod"); //container.DataWriter = dataWriter; @@ -458,11 +450,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent [TestCase] public void EngineIdleControllerTest2Truck() { - VehicleContainer container; - CombustionEngine engine; - ITnOutPort requestPort; - MockGearbox gearbox; - VehicleContainer(TruckEngine, out container, out engine, out requestPort, out gearbox); + VehicleContainer(TruckEngine, out var container, out var engine, out var requestPort, out var gearbox); //var dataWriter = new ModalDataWriter("EngienIdle.vmod"); //container.DataWriter = dataWriter; diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxShiftLossesTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxShiftLossesTest.cs index cf51cae361..08dbcfdcd5 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxShiftLossesTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/GearboxShiftLossesTest.cs @@ -86,11 +86,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent public void TestShiftLossComputation(double torqueDemand, uint gear, double preShiftRpm, double postShiftRpm, double expectedShiftLoss, double expectedShiftLossEnergy) { - AxleGear axleGear; - ATGearbox gbx; - CombustionEngine engine; var cycleDataStr = "0, 0, 0, 2\n100, 20, 0, 0\n1000, 50, 0, 0"; - var container = CreateVehicle(cycleDataStr, preShiftRpm, out axleGear, out gbx, out engine); + var container = CreateVehicle(cycleDataStr, preShiftRpm, out var axleGear, out var gbx, out var engine); new ATClutchInfo(container); gbx.Gear = new GearshiftPosition(gear, true); @@ -138,11 +135,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent public void TestSplittingShiftLossesTwoIntervals(double torqueDemand, uint gear, double preShiftRpm, double postShiftRpm, double expectedShiftLoss, double expectedShiftLossEnergy) { - AxleGear axleGear; - ATGearbox gbx; - CombustionEngine engine; var cycleDataStr = "0, 0, 0, 2\n100, 20, 0, 0\n1000, 50, 0, 0"; - var container = CreateVehicle(cycleDataStr, preShiftRpm, out axleGear, out gbx, out engine); + var container = CreateVehicle(cycleDataStr, preShiftRpm, out var axleGear, out var gbx, out var engine); var modData = new MockModalDataContainer(); gbx.Gear = new GearshiftPosition(gear, true); diff --git a/VectoCore/VectoCoreTest/Utils/VectoMathTest.cs b/VectoCore/VectoCoreTest/Utils/VectoMathTest.cs index 4b9113905d..57988c3f48 100644 --- a/VectoCore/VectoCoreTest/Utils/VectoMathTest.cs +++ b/VectoCore/VectoCoreTest/Utils/VectoMathTest.cs @@ -140,8 +140,7 @@ namespace TUGraz.VectoCore.Tests.Utils new { X = 20, Y = 12 } }; - double k, d, r; - VectoMath.LeastSquaresFitting(entries, x => x.X, x => x.Y, out k, out d, out r); + VectoMath.LeastSquaresFitting(entries, x => x.X, x => x.Y, out var k, out var d, out var r); Assert.AreEqual(4, d, 1e-6); Assert.AreEqual(0.4, k, 1e-6); @@ -164,8 +163,7 @@ namespace TUGraz.VectoCore.Tests.Utils new { X = 11, Y = 30.55 }, }; - double k, d, r; - VectoMath.LeastSquaresFitting(entries, x => x.X, x => x.Y, out k, out d, out r); + VectoMath.LeastSquaresFitting(entries, x => x.X, x => x.Y, out var k, out var d, out var r); Assert.AreEqual(27.003529, d, 1e-6); Assert.AreEqual(0.431535, k, 1e-6); -- GitLab