diff --git a/VECTO.sln.DotSettings b/VECTO.sln.DotSettings index b88df5f54adc0cd3df4011af2e8cb3ecf61a7574..9120d918fa2c54fc29bba36829eeb35fdc6fe211 100644 --- a/VECTO.sln.DotSettings +++ b/VECTO.sln.DotSettings @@ -110,9 +110,12 @@ <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EJavaScript_002ECodeStyle_002ESettingsUpgrade_002EJsWrapperSettingsUpgrader/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EVB_002ECodeStyle_002ESettingsUpgrade_002EVBSpaceAfterUnaryMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EXml_002ECodeStyle_002EFormatSettingsUpgrade_002EXmlMoveToCommonFormatterSettingsUpgrade/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=acmp/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=actuations/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=aenv/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Airdrag/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Angledrive/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=apac/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Axlegear/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=fullyelectric/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Graz/@EntryIndexedValue">True</s:Boolean> @@ -123,8 +126,11 @@ <s:Boolean x:Key="/Default/UserDictionary/Words/=Pwheel/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=RESS/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Sumfile/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=Tyres/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Underload/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=Upshift/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=vair/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/UserDictionary/Words/=VAUX/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=vdri/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Vecto/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=visco/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index 17c2e2d4c0fb2aae0a2c7aac7751c9a2e7efc9c3..f7fafe7b7f6e770834b3aa91db813194ab9c4f48 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -640,8 +640,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public class JSONVTPInputDataV4 : JSONFile, IVTPEngineeringInputDataProvider, IVTPEngineeringJobInputData, IVTPDeclarationInputDataProvider, IManufacturerReport { - private IDictionary<VectoComponents, IList<string>> _componentDigests = null; - private DigestData _jobDigest = null; + private IDictionary<VectoComponents, IList<string>> _componentDigests; + private DigestData _jobDigest; private IXMLInputDataReader _inputReader; private IResultsInputData _manufacturerResults; private Meter _vehicleLenght; diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONSubComponent.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONSubComponent.cs index c9bb727f7934148ccae6d662147c7868ac0e95b0..891a9ce8995a969ef646f08da1e56f983d06e919 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONSubComponent.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONSubComponent.cs @@ -497,7 +497,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { var maxAlternatorPower = - Body["Aux"]?["ElectricSupply"]?.GetEx<double>("MaxAlternatorPower").SI<Watt>() ?? null; + Body["Aux"]?["ElectricSupply"]?.GetEx<double>("MaxAlternatorPower").SI<Watt>(); if (maxAlternatorPower == null) { return null; @@ -512,7 +512,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { get { - var batteryCapacity = Body["Aux"]?["ElectricSupply"]?.GetEx<double>("ElectricStorageCapacity").SI(Unit.SI.Watt.Hour).Cast<WattSecond>() ?? null; + var batteryCapacity = Body["Aux"]?["ElectricSupply"]?.GetEx<double>("ElectricStorageCapacity").SI(Unit.SI.Watt.Hour).Cast<WattSecond>(); if (batteryCapacity == null) { return null; } @@ -538,7 +538,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public virtual bool SmartElectrics => Body["Aux"]?["ElectricSupply"]?.GetEx<bool>("SmartElectrics") ?? false; - public WattSecond ElectricStorageCapacity => Body["Aux"]?["ElectricSupply"]?.GetEx<double>("ElectricStorageCapacity").SI(Unit.SI.Watt.Hour).Cast<WattSecond>() ?? null; + public WattSecond ElectricStorageCapacity => Body["Aux"]?["ElectricSupply"]?.GetEx<double>("ElectricStorageCapacity").SI(Unit.SI.Watt.Hour).Cast<WattSecond>(); #endregion diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationMultistageInputReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationMultistageInputReader.cs index 8653c85b2a86c069b247e0e249d790b68ee53748..9a92f71668ad51fe25098d0cc0ad4d611e3ca91a 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationMultistageInputReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationMultistageInputReader.cs @@ -309,8 +309,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl protected readonly IEnumerable<IManufacturingStageInputData> _manufacturingStages; private string _invalidEntry; protected IList<string> _invalidEntries = new List<string>(); - protected bool _fullChecked = false; - protected bool _checked = false; + protected bool _fullChecked; + protected bool _checked; protected bool _isComplete = true; protected string InvalidEntry diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs index 6fcb5dbe8ee91e83f0b4ab28b7017176131289c5..fbb87fe47c3ff59881ace770e82d6c13902be35b 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/WHRPowerReader.cs @@ -25,8 +25,8 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData public static WHRPowerMap Create(TableData data, WHRType type) { - string whrColumn = null; - type = type & (WHRType.ElectricalOutput | WHRType.MechanicalOutputDrivetrain); + string whrColumn; + type &= WHRType.ElectricalOutput | WHRType.MechanicalOutputDrivetrain; switch (type) { case WHRType.MechanicalOutputDrivetrain: whrColumn = Fields.MechanicalPower; @@ -62,7 +62,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData var torque = row.ParseDouble(Fields.Torque).SI<NewtonMeter>(); var electricPower = row.ParseDouble(whrColumn).SI<Watt>(); - delaunayMap?.AddPoint(torque.Value(), engineSpeed.Value(), electricPower.Value()); + delaunayMap.AddPoint(torque.Value(), engineSpeed.Value(), electricPower.Value()); } catch (Exception e) { throw new VectoException($"WHR Map - Line {data.Rows.IndexOf(row)}: {e.Message}", e); } diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs index de50e17655d4aac76abd5f5c3b731a0f3b1b9ea3..2396dc4666747cef8a6f87dabe369bc0ad23c876 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs @@ -97,6 +97,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl AngledriveData angledriveData = null; if (electricMachinesData.Any(x => x.Item1 == PowertrainPosition.BatteryElectricE2)) { // gearbox required! + // todo mk-2021-08-26 angleDrive will always be null!! gearshiftParams = dao.CreateGearshiftData( InputDataProvider.JobInputData.Vehicle.Components.GearboxInputData.Type, InputDataProvider.DriverInputData.GearshiftInputData, axlegearData.AxleGear.Ratio * (angledriveData?.Angledrive.Ratio ?? 1.0), null); diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index d0a44a5fd412ceca9acb5a6de68f09f7b83d8053..b3528b041d0a53adfffd225a2e8ddb5f527e348d 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -31,10 +31,8 @@ using System; using System.Collections.Generic; -using System.Data; using System.IO; using System.Linq; -using System.Runtime.CompilerServices; using Newtonsoft.Json.Linq; using TUGraz.VectoCommon.BusAuxiliaries; using TUGraz.VectoCommon.Exceptions; @@ -44,12 +42,7 @@ using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.Reader.ComponentData; -using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Electrics; -using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC; -using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.Pneumatics; -using TUGraz.VectoCore.Models.Simulation.Data; -using TUGraz.VectoCore.Models.SimulationComponent; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data.ElectricMotor; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; @@ -112,13 +105,11 @@ namespace TUGraz.VectoCore.Models.Declaration /// </summary> public static Kilogram GetPayloadForGrossVehicleWeight(Kilogram grossVehicleWeight, string equationName) { - if (equationName.ToLower().StartsWith("pc10")) - { + if (equationName.ToLower().StartsWith("pc10")) { return Payloads.Lookup10Percent(grossVehicleWeight); } - if (equationName.ToLower().StartsWith("pc75")) - { + if (equationName.ToLower().StartsWith("pc75")) { return Payloads.Lookup75Percent(grossVehicleWeight); } @@ -138,14 +129,14 @@ namespace TUGraz.VectoCore.Models.Declaration grossVehicleWeight - curbWeight).Value() / 100, 0) * 100).SI<Kilogram>(); } - - + + public static class BusAuxiliaries { //private static ISSMInputs ssmInputs = null; - private static IEnvironmentalConditionsMap envMap = null; + private static IEnvironmentalConditionsMap envMap; //private static AuxiliaryConfig busAuxConfig = null; private static ElectricalConsumerList elUserConfig; @@ -166,25 +157,7 @@ namespace TUGraz.VectoCore.Models.Declaration public static ICompressorMap GetCompressorMap(string compressorSize, string clutchType) { - var resource = ""; - switch (compressorSize) { - case "Small": - resource = "DEFAULT_1-Cylinder_1-Stage_393ccm.acmp"; - break; - case "Medium Supply 1-stage": - resource = "DEFAULT_1-Cylinder_1-Stage_393ccm.acmp"; - break; - case "Medium Supply 2-stage": - resource = "DEFAULT_2-Cylinder_1-Stage_650ccm.acmp"; - break; - case "Large Supply 1-stage": - resource = "DEFAULT_2-Cylinder_2-Stage_398ccm.acmp"; - break; - case "Large Supply 2-stage": - resource = "DEFAULT_3-Cylinder_2-Stage_598ccm.acmp"; - break; - default: throw new ArgumentException($"unkown compressor size {compressorSize}", compressorSize); - } + var resource = GetCompressorResourceForSize(compressorSize); var dragCurveFactorClutch = 1.0; switch (clutchType) { @@ -200,6 +173,18 @@ namespace TUGraz.VectoCore.Models.Declaration RessourceHelper.ReadStream(DeclarationDataResourcePrefix + ".VAUXBus." + resource), dragCurveFactorClutch, $"{compressorSize} - {clutchType}"); } + private static string GetCompressorResourceForSize(string compressorSize) + { + switch (compressorSize) { + case "Small": return "DEFAULT_1-Cylinder_1-Stage_393ccm.acmp"; + case "Medium Supply 1-stage": return "DEFAULT_1-Cylinder_1-Stage_393ccm.acmp"; + case "Medium Supply 2-stage": return "DEFAULT_2-Cylinder_1-Stage_650ccm.acmp"; + case "Large Supply 1-stage": return "DEFAULT_2-Cylinder_2-Stage_398ccm.acmp"; + case "Large Supply 2-stage": return "DEFAULT_3-Cylinder_2-Stage_598ccm.acmp"; + default: throw new ArgumentException($"unknown compressor size {compressorSize}", compressorSize); + } + } + public static BusAlternatorTechnologies AlternatorTechnologies = new BusAlternatorTechnologies(); private static HVACCoolingPower hvacMaxCoolingPower; @@ -226,23 +211,23 @@ namespace TUGraz.VectoCore.Models.Declaration { switch (hvacSystemConfig) { - - case BusHVACSystemConfiguration.Configuration1: + + case BusHVACSystemConfiguration.Configuration1: case BusHVACSystemConfiguration.Configuration2: return Constants.BusAuxiliaries.SteadyStateModel.LowVentilation; - - case BusHVACSystemConfiguration.Configuration3: - case BusHVACSystemConfiguration.Configuration4: - case BusHVACSystemConfiguration.Configuration5: - case BusHVACSystemConfiguration.Configuration6: - case BusHVACSystemConfiguration.Configuration7: - case BusHVACSystemConfiguration.Configuration8: + + case BusHVACSystemConfiguration.Configuration3: + case BusHVACSystemConfiguration.Configuration4: + case BusHVACSystemConfiguration.Configuration5: + case BusHVACSystemConfiguration.Configuration6: + case BusHVACSystemConfiguration.Configuration7: + case BusHVACSystemConfiguration.Configuration8: case BusHVACSystemConfiguration.Configuration9: case BusHVACSystemConfiguration.Configuration10: return heating ? Constants.BusAuxiliaries.SteadyStateModel.HighVentilationHeating : Constants.BusAuxiliaries.SteadyStateModel.HighVentilation; - + default: throw new ArgumentOutOfRangeException(nameof(hvacSystemConfig), hvacSystemConfig, null); } } @@ -258,11 +243,11 @@ namespace TUGraz.VectoCore.Models.Declaration ? Constants.BusParameters.VehicleWidthHigh : busWidth; } - + public static Meter CalculateInternalLength(Meter vehicleLength, VehicleCode? vehicleCode, double numPassSeatsLowerDeck) - { - if (vehicleCode.GetFloorType() == FloorType.LowFloor) { + { + if (vehicleCode.GetFloorType() == FloorType.LowFloor) { return vehicleCode.IsDoubleDeckerBus() ? 2 * vehicleLength : vehicleLength; } @@ -292,13 +277,13 @@ namespace TUGraz.VectoCore.Models.Declaration case FloorType.LowFloor: return bodyHeight; case FloorType.HighFloor: - if ((registrationClass == RegistrationClass.II_III && bodyHeight > 3.1.SI<Meter>()) || + if ((registrationClass == RegistrationClass.II_III && bodyHeight > 3.1.SI<Meter>()) || registrationClass == RegistrationClass.III || registrationClass == RegistrationClass.B) { return Constants.BusParameters.InternalHeightDoubleDecker; } return bodyHeight - Constants.BusParameters.HeightLuggageCompartment; } - + throw new VectoException("Internal height for vehicle floor type '{0}' {1} not defined", vehicleCode.GetFloorType().ToString(), vehicleCode.IsDoubleDeckerBus() ? "double decker" : "single decker"); } @@ -500,61 +485,48 @@ namespace TUGraz.VectoCore.Models.Declaration { //#if RELEASE_CANDIDATE var expectedFile = @"Declaration\EffShiftParameters.vtcu"; - if (!File.Exists(expectedFile)) - { + if (!File.Exists(expectedFile)) { return; } var tcuData = JSONInputDataFactory.ReadShiftParameters(expectedFile, true); - if (tcuData.RatingFactorCurrentGear.HasValue) - { + if (tcuData.RatingFactorCurrentGear.HasValue) { RatingFactorCurrentGear = tcuData.RatingFactorCurrentGear.Value; RatingFactorCurrentGearAT = tcuData.RatingFactorCurrentGear.Value; } - if (tcuData.RatioEarlyDownshiftFC.HasValue) - { + if (tcuData.RatioEarlyDownshiftFC.HasValue) { RatioEarlyDownshiftFC = tcuData.RatioEarlyDownshiftFC.Value; } - if (tcuData.RatioEarlyUpshiftFC.HasValue) - { + if (tcuData.RatioEarlyUpshiftFC.HasValue) { RatioEarlyUpshiftFC = tcuData.RatioEarlyUpshiftFC.Value; } - if (tcuData.AllowedGearRangeFC.HasValue) - { + if (tcuData.AllowedGearRangeFC.HasValue) { AllowedGearRangeFCAMT = tcuData.AllowedGearRangeFC.Value; AllowedGearRangeFCAT = tcuData.AllowedGearRangeFC.Value; } - if (tcuData.VeloictyDropFactor.HasValue) - { + if (tcuData.VeloictyDropFactor.HasValue) { VelocityDropFactor = tcuData.VeloictyDropFactor.Value; } - if (tcuData.AccelerationFactor.HasValue) - { + if (tcuData.AccelerationFactor.HasValue) { AccelerationFactor = tcuData.AccelerationFactor.Value; } - if (tcuData.ATLookAheadTime != null) - { + if (tcuData.ATLookAheadTime != null) { ATLookAheadTime = tcuData.ATLookAheadTime; } - if (tcuData.LoadStageThresholdsDown != null && LoadStageThresoldsDown.Length > 0) - { + if (tcuData.LoadStageThresholdsDown != null && LoadStageThresoldsDown.Length > 0) { LoadStageThresoldsDown = tcuData.LoadStageThresholdsDown.ToArray(); } - if (tcuData.LoadStageThresholdsUp != null && LoadStageThresholdsUp.Length > 0) - { + if (tcuData.LoadStageThresholdsUp != null && LoadStageThresholdsUp.Length > 0) { LoadStageThresholdsUp = tcuData.LoadStageThresholdsUp.ToArray(); } - if (tcuData.ShiftSpeedsTCToLocked != null && ShiftSpeedsTCToLocked.Length > 0) - { + if (tcuData.ShiftSpeedsTCToLocked != null && ShiftSpeedsTCToLocked.Length > 0) { ShiftSpeedsTCToLocked = tcuData.ShiftSpeedsTCToLocked; } - if (tcuData.MinEngineSpeedPostUpshift != null) - { + if (tcuData.MinEngineSpeedPostUpshift != null) { MinEngineSpeedPostUpshift = tcuData.MinEngineSpeedPostUpshift; } var tmp = tcuData as JSONFile; - if (tmp != null && tmp.Body["ShiftStrategy"] != null) - { + if (tmp != null && tmp.Body["ShiftStrategy"] != null) { DefaultShiftStrategy = tmp.Body["ShiftStrategy"].Value<string>(); } //#endif @@ -593,17 +565,17 @@ namespace TUGraz.VectoCore.Models.Declaration /// <param name="engine">engine data</param> /// <param name="axlegearRatio"></param> /// <param name="dynamicTyreRadius"></param> + /// <param name="electricMotorData"></param> /// <returns></returns> public static ShiftPolygon ComputeShiftPolygon( GearboxType type, int gearIdx, EngineFullLoadCurve fullLoadCurve, - IList<ITransmissionInputData> gears, CombustionEngineData engine, double axlegearRatio, Meter dynamicTyreRadius,ElectricMotorData electricMotorData) + IList<ITransmissionInputData> gears, CombustionEngineData engine, double axlegearRatio, Meter dynamicTyreRadius, ElectricMotorData electricMotorData) { - switch (type) - { + switch (type) { case GearboxType.AMT: - // TODO MQ: 2020-10-14: compute for AMT with ICE and AMT with EM differently - return ComputeEfficiencyShiftPolygon(gearIdx, fullLoadCurve, gears, engine, axlegearRatio, dynamicTyreRadius); - case GearboxType.MT: + // TODO MQ: 2020-10-14: compute for AMT with ICE and AMT with EM differently + return ComputeEfficiencyShiftPolygon(gearIdx, fullLoadCurve, gears, engine, axlegearRatio, dynamicTyreRadius); + case GearboxType.MT: return ComputeManualTransmissionShiftPolygon( gearIdx, fullLoadCurve, gears, engine, axlegearRatio, dynamicTyreRadius); case GearboxType.ATSerial: @@ -642,7 +614,7 @@ namespace TUGraz.VectoCore.Models.Declaration return new ShiftPolygon(downShift, upShift); } - upShift.Add(new ShiftPolygon.ShiftPolygonEntry(fullLoadCurve.MaxGenerationTorque * 1.1, fullLoadCurve.MaxSpeed * 0.9)); + upShift.Add(new ShiftPolygon.ShiftPolygonEntry(fullLoadCurve.MaxGenerationTorque * 1.1, fullLoadCurve.MaxSpeed * 0.9)); upShift.Add(new ShiftPolygon.ShiftPolygonEntry(fullLoadCurve.MaxDriveTorque * 1.1, fullLoadCurve.MaxSpeed * 0.9)); return new ShiftPolygon(downShift, upShift); } @@ -671,7 +643,7 @@ namespace TUGraz.VectoCore.Models.Declaration new ShiftPolygon.ShiftPolygonEntry( fullLoadCurve.FullLoadDriveTorque(nMin) * ShiftPolygonEngineFldMargin, nMin)); - + } else { retVal.Add( new ShiftPolygon.ShiftPolygonEntry( @@ -767,8 +739,7 @@ namespace TUGraz.VectoCore.Models.Declaration var downShift = new List<ShiftPolygon.ShiftPolygonEntry>(); - if (gearIdx > 0) - { + if (gearIdx > 0) { var downShiftPoints = fullLoadCurve .FullLoadEntries.Where(fldEntry => fldEntry.EngineSpeed >= p2.X && fldEntry.EngineSpeed <= p3.X) .Select( @@ -798,8 +769,7 @@ namespace TUGraz.VectoCore.Models.Declaration downShiftPoints.Select( x => new ShiftPolygon.ShiftPolygonEntry( x.Y.SI<NewtonMeter>() * ShiftPolygonEngineFldMargin, x.X.SI<PerSecond>()))); - if (downShiftPoints.Max(x => x.X) < p3.X) - { + if (downShiftPoints.Max(x => x.X) < p3.X) { downShift.Add( new ShiftPolygon.ShiftPolygonEntry( fullLoadCurve.FullLoadStationaryTorque(p3.X.SI<PerSecond>()) * ShiftPolygonEngineFldMargin, @@ -809,8 +779,7 @@ namespace TUGraz.VectoCore.Models.Declaration downShift.Add(new ShiftPolygon.ShiftPolygonEntry(fullLoadCurve.MaxTorque * 1.1, p3.X.SI<PerSecond>())); } var upShift = new List<ShiftPolygon.ShiftPolygonEntry>(); - if (gearIdx >= gears.Count - 1) - { + if (gearIdx >= gears.Count - 1) { return new ShiftPolygon(downShift, upShift); } @@ -824,8 +793,7 @@ namespace TUGraz.VectoCore.Models.Declaration int gearIdx, EngineFullLoadCurve fullLoadCurve, IList<ITransmissionInputData> gears, CombustionEngineData engine, double axlegearRatio, Meter dynamicTyreRadius) { - if (gears.Count < 2) - { + if (gears.Count < 2) { throw new VectoException("ComputeShiftPolygon needs at least 2 gears. {0} gears given.", gears.Count); } @@ -854,8 +822,7 @@ namespace TUGraz.VectoCore.Models.Declaration var downshiftCorr = MoveDownshiftBelowFld(Edge.Create(p6, p3), fldMargin, 1.1 * fullLoadCurve.MaxTorque); var downShift = new List<ShiftPolygon.ShiftPolygonEntry>(); - if (gearIdx > 0) - { + if (gearIdx > 0) { downShift = new[] { p2, downshiftCorr.P1, downshiftCorr.P2 }.Select( point => new ShiftPolygon.ShiftPolygonEntry(point.Y.SI<NewtonMeter>(), point.X.SI<PerSecond>())) @@ -864,8 +831,7 @@ namespace TUGraz.VectoCore.Models.Declaration downShift[0].Torque = maxDragTorque; } var upShift = new List<ShiftPolygon.ShiftPolygonEntry>(); - if (gearIdx >= gears.Count - 1) - { + if (gearIdx >= gears.Count - 1) { return new ShiftPolygon(downShift, upShift); } @@ -882,8 +848,7 @@ namespace TUGraz.VectoCore.Models.Declaration // ReSharper restore InconsistentNaming var upShiftPts = IntersectTakeHigherShiftLine(new[] { p4, p7, p5 }, new[] { p2p, p6p, p3pExt }); - if (gears[gearIdx].MaxInputSpeed != null) - { + if (gears[gearIdx].MaxInputSpeed != null) { var maxSpeed = gears[gearIdx].MaxInputSpeed.Value(); upShiftPts = IntersectTakeLowerShiftLine( upShiftPts, @@ -953,14 +918,12 @@ namespace TUGraz.VectoCore.Models.Declaration // line sweeping from max_X to 0: select point with lowest Y coordinate, abort if a point has Y = 0 var shiftPolygon = new List<Point>(); - foreach (var xCoord in pointSet.Select(pt => pt.X).Distinct().OrderBy(x => x).Reverse()) - { + foreach (var xCoord in pointSet.Select(pt => pt.X).Distinct().OrderBy(x => x).Reverse()) { var coord = xCoord; var xPoints = pointSet.Where(pt => pt.X.IsEqual(coord) && !pt.Y.IsEqual(0)).ToList(); shiftPolygon.Add(xPoints.MinBy(pt => pt.Y)); var tmp = pointSet.Where(pt => pt.X.IsEqual(coord)).Where(pt => pt.Y.IsEqual(0)).ToList(); - if (!tmp.Any()) - { + if (!tmp.Any()) { continue; } @@ -970,16 +933,13 @@ namespace TUGraz.VectoCore.Models.Declaration // find and remove colinear points var toRemove = new List<Point>(); - for (var i = 0; i < shiftPolygon.Count - 2; i++) - { + for (var i = 0; i < shiftPolygon.Count - 2; i++) { var edge = new Edge(shiftPolygon[i], shiftPolygon[i + 2]); - if (edge.ContainsXY(shiftPolygon[i + 1])) - { + if (edge.ContainsXY(shiftPolygon[i + 1])) { toRemove.Add(shiftPolygon[i + 1]); } } - foreach (var point in toRemove) - { + foreach (var point in toRemove) { shiftPolygon.Remove(point); } @@ -990,8 +950,7 @@ namespace TUGraz.VectoCore.Models.Declaration internal static Point[] IntersectTakeLowerShiftLine(Point[] upShiftPts, Point[] upperLimit) { var intersections = Intersect(upShiftPts, upperLimit); - if (!intersections.Any()) - { + if (!intersections.Any()) { return upShiftPts[0].X < upperLimit[0].X ? upShiftPts : upperLimit; } @@ -1002,24 +961,20 @@ namespace TUGraz.VectoCore.Models.Declaration pointSet.AddRange(ProjectPointsToLineSegments(upperLimit, upShiftPts, true)); var shiftPolygon = new List<Point>(); - foreach (var yCoord in pointSet.Select(pt => pt.Y).Distinct().OrderBy(y => y).Reverse()) - { + foreach (var yCoord in pointSet.Select(pt => pt.Y).Distinct().OrderBy(y => y).Reverse()) { var yPoints = pointSet.Where(pt => pt.Y.IsEqual(yCoord)).ToList(); shiftPolygon.Add(yPoints.MinBy(pt => pt.X)); } // find and remove colinear points var toRemove = new List<Point>(); - for (var i = 0; i < shiftPolygon.Count - 2; i++) - { + for (var i = 0; i < shiftPolygon.Count - 2; i++) { var edge = new Edge(shiftPolygon[i], shiftPolygon[i + 2]); - if (edge.ContainsXY(shiftPolygon[i + 1])) - { + if (edge.ContainsXY(shiftPolygon[i + 1])) { toRemove.Add(shiftPolygon[i + 1]); } } - foreach (var point in toRemove) - { + foreach (var point in toRemove) { shiftPolygon.Remove(point); } @@ -1033,14 +988,11 @@ namespace TUGraz.VectoCore.Models.Declaration // compute all intersection points between both line segments // ReSharper disable once LoopCanBeConvertedToQuery - foreach (var origLine in orig.Pairwise(Edge.Create)) - { + foreach (var origLine in orig.Pairwise(Edge.Create)) { // ReSharper disable once LoopCanBeConvertedToQuery - foreach (var transformedLine in transformedDownshift.Pairwise(Edge.Create)) - { + foreach (var transformedLine in transformedDownshift.Pairwise(Edge.Create)) { var isect = VectoMath.Intersect(origLine, transformedLine); - if (isect != null) - { + if (isect != null) { intersections.Add(isect); } } @@ -1054,12 +1006,9 @@ namespace TUGraz.VectoCore.Models.Declaration bool projectToVertical = false) { var pointSet = new List<Point>(); - foreach (var segment in lineSegments.Pairwise(Edge.Create)) - { - if (segment.P1.X.IsEqual(segment.P2.X)) - { - if (projectToVertical) - { + foreach (var segment in lineSegments.Pairwise(Edge.Create)) { + if (segment.P1.X.IsEqual(segment.P2.X)) { + if (projectToVertical) { pointSet.AddRange( points.Select(point => new Point(segment.P1.X, point.Y)) .Where(pt => pt.Y.IsBetween(segment.P1.Y, segment.P2.Y))); @@ -1126,8 +1075,7 @@ namespace TUGraz.VectoCore.Models.Declaration Torque = -4 * first.Torque }, }; - foreach (var torqueConverterEntry in characteristicTorque) - { + foreach (var torqueConverterEntry in characteristicTorque) { torqueConverterEntry.SpeedRatio = torqueConverterEntry.SpeedRatio * ratio; torqueConverterEntry.TorqueRatio = torqueConverterEntry.TorqueRatio / ratio; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs index 74ff0a61d47b4e92360100eedae1bfd84c17bfc8..76e6eb88e0dcaca03570d5d558edb35a20da7e65 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DefaultDriverStrategy.cs @@ -92,6 +92,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl DrivingModes.Add(DrivingMode.DrivingModeBrake, new DriverModeBrake() { DriverStrategy = this }); CurrentDrivingMode = DrivingMode.DrivingModeDrive; + // todo mk-2021-08-26 container is never null (otherwise previous lines would have already crashed): conditional access is not necessary VehicleCategory = container?.RunData.VehicleData.VehicleCategory ?? VehicleCategory.Unknown; var data = container?.RunData; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTODriveAuxiliary.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTODriveAuxiliary.cs index 54460292977b11a67260e3736e818131614c687b..74da2deff37925c0034abef0bf27cb2c7f2581f7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTODriveAuxiliary.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PTODriveAuxiliary.cs @@ -14,9 +14,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { protected IDataBus DataBus; protected IDrivingCycleData Cycle; - protected Second PTOActivityStart = null; + protected Second PTOActivityStart; - protected Meter PTOCycleDistanceStart = null; + protected Meter PTOCycleDistanceStart; public PTODriveAuxiliary(IVehicleContainer container, IDrivingCycleData cycle) { diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReport.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReport.cs index fe28253da5cb0804ecdf0e6e294f4e4247a3cad1..9d5c5a935cab08a8b8162f4d37539cc080a9da7e 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReport.cs @@ -69,7 +69,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation protected KilogramPerMeter _weightedCo2 = 0.SI<KilogramPerMeter>(); protected Kilogram _weightedPayload = 0.SI<Kilogram>(); - protected double _passengerCount = 0; + protected double _passengerCount; public XMLCustomerReport() diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReportCompletedBus.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReportCompletedBus.cs index 32480f8721668c4f5414054c7e7fcb8dfb65e583..13d7ef317cbce2574043c6b702ba4624fcd41a4d 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReportCompletedBus.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/CustomerInformationFile/XMLCustomerReportCompletedBus.cs @@ -19,7 +19,7 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation { public class XMLCustomerReportCompletedBus : XMLCustomerReport { - private int _resultCount = 0; + private int _resultCount; protected TankSystem? _tankSystem; public IPrimaryVehicleInformationInputDataProvider PrimaryVehicleRecordFile { get; set; } @@ -110,8 +110,8 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.CustomerInformation if (genericResult.Status == VectoRun.Status.Canceled || genericResult.Status == VectoRun.Status.Aborted || specificResult.Status == VectoRun.Status.Canceled || specificResult.Status == VectoRun.Status.Aborted) { content = new object[] { - new XElement(tns + XMLNames.Report_Results_Error, genericResult.Error ?? "" + Environment.NewLine + specificResult.Error ?? ""), - new XElement(tns + XMLNames.Report_Results_ErrorDetails, genericResult.StackTrace ?? "" + Environment.NewLine + specificResult.StackTrace ?? ""), + new XElement(tns + XMLNames.Report_Results_Error, (genericResult.Error ?? "") + Environment.NewLine + (specificResult.Error ?? "")), + new XElement(tns + XMLNames.Report_Results_ErrorDetails, (genericResult.StackTrace ?? "") + Environment.NewLine + (specificResult.StackTrace ?? "")), }; } diff --git a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportCompletedBus.cs b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportCompletedBus.cs index 3d239820881826f16ddd84545c5da1f504210ef1..fa5e1da48332c2b45a6b24cc0bf433e84d7be142 100644 --- a/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportCompletedBus.cs +++ b/VectoCore/VectoCore/OutputData/XML/DeclarationReports/ManufacturerReport/XMLManufacturerReportCompletedBus.cs @@ -107,8 +107,8 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.ManufacturerReport if (genericResult.Status == VectoRun.Status.Canceled || genericResult.Status == VectoRun.Status.Aborted || specificResult.Status == VectoRun.Status.Canceled || specificResult.Status == VectoRun.Status.Aborted) { content = new object[] { - new XElement(tns + XMLNames.Report_Results_Error, genericResult.Error ?? "" + Environment.NewLine + specificResult.Error ?? ""), - new XElement(tns + XMLNames.Report_Results_ErrorDetails, genericResult.StackTrace ?? "" + Environment.NewLine + specificResult.StackTrace ?? ""), + new XElement(tns + XMLNames.Report_Results_Error, (genericResult.Error ?? "") + Environment.NewLine + (specificResult.Error ?? "")), + new XElement(tns + XMLNames.Report_Results_ErrorDetails, (genericResult.StackTrace ?? "") + Environment.NewLine + (specificResult.StackTrace ?? "")), }; } diff --git a/VectoCore/VectoCore/Utils/SchmittTrigger.cs b/VectoCore/VectoCore/Utils/SchmittTrigger.cs index 97b5406652804729573a0fe54862111d531dd7d6..351996a8d3553ae184af2459d741694a3ce82d39 100644 --- a/VectoCore/VectoCore/Utils/SchmittTrigger.cs +++ b/VectoCore/VectoCore/Utils/SchmittTrigger.cs @@ -6,7 +6,7 @@ namespace TUGraz.VectoCore.Utils { public class SchmittTrigger { - protected int Value = 0; + protected int Value; public SchmittTrigger(double thLow, double thHigh) {