Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit b4286856 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

removed unnecessary checks for null and unnecessary initialisations

parent eba50bb6
No related branches found
No related tags found
No related merge requests found
Showing
with 105 additions and 149 deletions
......@@ -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>
......@@ -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;
......
......@@ -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
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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()
......
......@@ -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 ?? "")),
};
}
......
......@@ -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 ?? "")),
};
}
......
......@@ -6,7 +6,7 @@ namespace TUGraz.VectoCore.Utils
{
public class SchmittTrigger
{
protected int Value = 0;
protected int Value;
public SchmittTrigger(double thLow, double thHigh)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment