From b5396d089f2f4f8a4a2e41b4e79230cd9cb15bb4 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Tue, 14 Jun 2016 11:08:26 +0200 Subject: [PATCH] if new lookahead parameters are not present in input files, use declaration defaults --- .../InputData/FileIO/JSON/JSONInputData.cs | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index 034dc18b32..2a91a6d920 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -42,6 +42,7 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.Impl; +using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Utils; using DriverData = TUGraz.VectoCore.Models.SimulationComponent.Data.DriverData; @@ -443,18 +444,32 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { var lac = Body.GetEx(JsonKeys.DriverData_LookaheadCoasting); + var distanceScalingFactor = lac["PreviewDistanceFactor"] != null + ? lac.GetEx<double>("PreviewDistanceFactor") + : DeclarationData.Driver.LookAhead.LookAheadDistanceFactor; + var lacDfOffset = lac["DF_offset"] != null + ? lac.GetEx<double>("DF_offset") + : DeclarationData.Driver.LookAhead.DecisionFactorCoastingOffset; + var lacDfScaling = lac["DF_scaling"] != null + ? lac.GetEx<double>("DF_scaling") + : DeclarationData.Driver.LookAhead.DecisionFactorCoastingScaling; + var speedDependentLookup = lac["DF_targetSpeedLookup"] != null + ? ReadTableData(lac.GetEx<string>("DF_targetSpeedLookup"), "Lookahead Coasting Decisionfactor - Target speed", + false) + : null; + var velocityDropLookup = lac["Df_velocityDropLookup"] != null + ? ReadTableData(lac.GetEx<string>("Df_velocityDropLookup"), + "Lookahead Coasting Decisionfactor - Velocity drop", false) + : null; return new LookAheadCoastingInputData() { Enabled = lac.GetEx<bool>(JsonKeys.DriverData_Lookahead_Enabled), Deceleration = lac.GetEx<double>(JsonKeys.DriverData_Lookahead_Deceleration).SI<MeterPerSquareSecond>(), MinSpeed = lac.GetEx<double>(JsonKeys.DriverData_Lookahead_MinSpeed).KMPHtoMeterPerSecond(), - LookaheadDistanceFactor = lac.GetEx<double>("PreviewDistanceFactor"), - CoastingDecisionFactorOffset = lac.GetEx<double>("DF_offset"), - CoastingDecisionFactorScaling = lac.GetEx<double>("DF_scaling"), - CoastingDecisionFactorTargetSpeedLookup = - ReadTableData(lac.GetEx<string>("DF_targetSpeedLookup"), "Lookahead Coasting Decisionfactor - Target speed", false), - CoastingDecisionFactorVelocityDropLookup = ReadTableData(lac.GetEx<string>("Df_velocityDropLookup"), - "Lookahead Coasting Decisionfactor - Velocity drop", - false) + LookaheadDistanceFactor = distanceScalingFactor, + CoastingDecisionFactorOffset = lacDfOffset, + CoastingDecisionFactorScaling = lacDfScaling, + CoastingDecisionFactorTargetSpeedLookup = speedDependentLookup, + CoastingDecisionFactorVelocityDropLookup = velocityDropLookup }; } } -- GitLab