From 60c4eebf5bd8230e834ed3ceb8301f525b5ce64d Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Thu, 16 Jun 2016 14:30:36 +0200 Subject: [PATCH] remove redundant property RoadGradientPercent, add getter that derives this value from RoadGradient if needed --- Tools/DeclarationCycleZip/Program.cs | 2 +- .../VectoCore/InputData/Reader/DrivingCycleDataReader.cs | 2 -- .../Models/SimulationComponent/Data/DrivingCycleData.cs | 6 +++++- .../SimulationComponent/Impl/PowertrainDrivingCycle.cs | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Tools/DeclarationCycleZip/Program.cs b/Tools/DeclarationCycleZip/Program.cs index f9f3216132..4ffa9847a2 100644 --- a/Tools/DeclarationCycleZip/Program.cs +++ b/Tools/DeclarationCycleZip/Program.cs @@ -65,7 +65,7 @@ namespace DeclarationCycleZip var row = table.NewRow(); row["<s>"] = x.Distance.Value().ToString(CultureInfo.InvariantCulture); row["<v>"] = x.VehicleTargetSpeed.ConvertTo().Kilo.Meter.Per.Hour.Value().ToString(CultureInfo.InvariantCulture); - row["<grad>"] = x.RoadGradientPercent.ToString(CultureInfo.InvariantCulture); + row["<grad>"] = x.RoadGradientPercent.Value().ToString(CultureInfo.InvariantCulture); row["<stop>"] = x.StoppingTime.Value().ToString(CultureInfo.InvariantCulture); table.Rows.Add(row); lastDistance = x.Distance; diff --git a/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs b/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs index 7ddcaab7d6..59005eaa90 100644 --- a/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs @@ -205,7 +205,6 @@ namespace TUGraz.VectoCore.InputData.Reader var tmp = new DrivingCycleData.DrivingCycleEntry(entry) { StoppingTime = 0.SI<Second>(), RoadGradient = entry.RoadGradient, - RoadGradientPercent = entry.RoadGradientPercent, VehicleTargetSpeed = i < entries.Count - 1 ? entries[i + 1].VehicleTargetSpeed : 0.SI<MeterPerSecond>() }; filtered.Add(tmp); @@ -362,7 +361,6 @@ namespace TUGraz.VectoCore.InputData.Reader return table.Rows.Cast<DataRow>().Select(row => new DrivingCycleData.DrivingCycleEntry { Distance = row.ParseDouble(Fields.Distance).SI<Meter>(), VehicleTargetSpeed = row.ParseDouble(Fields.VehicleSpeed).KMPHtoMeterPerSecond(), - RoadGradientPercent = row.ParseDoubleOrGetDefault(Fields.RoadGradient), RoadGradient = VectoMath.InclinationToAngle(row.ParseDoubleOrGetDefault(Fields.RoadGradient) / 100.0), StoppingTime = row.ParseDouble(Fields.StoppingTime).SI<Second>(), AdditionalAuxPowerDemand = row.ParseDoubleOrGetDefault(Fields.AdditionalAuxPowerDemand).SI().Kilo.Watt.Cast<Watt>(), diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs index 49f72e7e5d..28f7540235 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.Collections.Generic; using System.Diagnostics; using TUGraz.VectoCommon.Utils; @@ -101,7 +102,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data /// <summary> /// [%] Optional. /// </summary> - public double RoadGradientPercent { get; set; } + public Scalar RoadGradientPercent + { + get { return (Math.Tan(RoadGradient.Value()) * 100).SI<Scalar>(); } + } /// <summary> /// relative altitude of the driving cycle over distance diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs index b475517770..959aaf2822 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.Collections.Generic; using System.Linq; using TUGraz.VectoCommon.Exceptions; @@ -519,7 +520,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl container[ModalResultField.dist] = CurrentState.Distance; container[ModalResultField.simulationDistance] = CurrentState.SimulationDistance; container[ModalResultField.v_targ] = CurrentState.VehicleSpeed; - container[ModalResultField.grad] = LeftSample.Current.RoadGradientPercent.SI(); + container[ModalResultField.grad] = LeftSample.Current.RoadGradientPercent; container[ModalResultField.altitude] = LeftSample.Current.Altitude; container[ModalResultField.acc] = CurrentState.Acceleration; } -- GitLab