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 23f66f7f authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

allow reading adas parameters from file also in declaration mode

parent 222e55d9
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,7 @@ using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TUGraz.VectoCommon.BusAuxiliaries;
using TUGraz.VectoCommon.Exceptions;
......@@ -345,6 +346,25 @@ namespace TUGraz.VectoCore.Models.Declaration
public static class Driver
{
internal static JObject adasParams;
static Driver()
{
ReadAdasConfig();
}
// TODO: MQ 2019-11-26 remove, once the parameters are fixed! make fields above read-only or const
internal static void ReadAdasConfig()
{
var expectedFile = @"Declaration\ADASParameters.json";
if (!File.Exists(expectedFile)) {
return;
}
using (var reader = File.OpenText(expectedFile)) {
adasParams = (JObject)(JToken.ReadFrom(new JsonTextReader(reader)).GetEx(JsonKeys.JsonBody));
}
}
public static class LookAhead
{
public const bool Enabled = true;
......@@ -380,6 +400,34 @@ namespace TUGraz.VectoCore.Models.Declaration
public static class PCC
{
// TODO: MQ 2019-11-26 remove, once the parameters are fixed! make fields above read-only or const
static PCC()
{
ReadAdasConfig();
if (adasParams == null) {
return;
}
if (adasParams["PCCEnableSpeed"] != null) {
PCCEnableSpeed = adasParams.GetEx<double>("PCCEnableSpeed").KMPHtoMeterPerSecond();
}
if (adasParams["MinSpeed"] != null) {
MinSpeed = adasParams.GetEx<double>("MinSpeed").KMPHtoMeterPerSecond();
}
if (adasParams["PreviewDistanceUseCase1"] != null) {
PreviewDistanceUseCase1 = adasParams.GetEx<double>("PreviewDistanceUseCase1").SI<Meter>();
}
if (adasParams["PreviewDistanceUseCase2"] != null) {
PreviewDistanceUseCase2 = adasParams.GetEx<double>("PreviewDistanceUseCase2").SI<Meter>();
}
if (adasParams["Underspeed"] != null) {
Underspeed = adasParams.GetEx<double>("Underspeed").KMPHtoMeterPerSecond();
}
if (adasParams["OverspeedUseCase3"] != null) {
OverspeedUseCase3 = adasParams.GetEx<double>("OverspeedUseCase3").KMPHtoMeterPerSecond();
}
}
public static readonly MeterPerSecond PCCEnableSpeed = 80.KMPHtoMeterPerSecond();
public static readonly MeterPerSecond MinSpeed = 50.KMPHtoMeterPerSecond();
public static readonly Meter PreviewDistanceUseCase1 = 1500.SI<Meter>();
......
{
"Header": {
"FileVersion": 1
},
"Body": {
"PCCEnableSpeed": 80,
"MinSpeed": 50,
"PreviewDistanceUseCase1": 1500,
"PreviewDistanceUseCase2": 1000,
"Underspeed": 8,
"OverspeedUseCase3": 5
}
}
\ No newline at end of file
......@@ -76,7 +76,8 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>CERTIFICATION_RELEASE</DefineConstants>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
......@@ -822,6 +823,7 @@
<EmbeddedResource Include="Resources\Declaration\VAUXBus\SP-AxleFactor.csv" />
<EmbeddedResource Include="Resources\Declaration\VAUXBus\SP-Axles_Bus.csv" />
<EmbeddedResource Include="Resources\Declaration\VAUXBus\SP-Factors_Bus.csv" />
<None Include="Resources\Declaration\ADASParameters.json" />
<None Include="Resources\Declaration\EffShiftParameters.vtcu" />
<None Include="Utils\VectoVersionCore.tt">
<Generator>TextTemplatingFileGenerator</Generator>
......
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