Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 94040d6b authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

cleanup standardbodies, adapt reading input data; segment creation: adapt to...

cleanup standardbodies, adapt reading input data; segment creation: adapt to new structure of missions
parent ecb5a263
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ using TUGraz.VectoCommon.Exceptions; ...@@ -37,6 +37,7 @@ using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils; using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.OutputData;
using TUGraz.VectoCore.Utils; using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Models.Declaration namespace TUGraz.VectoCore.Models.Declaration
...@@ -125,14 +126,27 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -125,14 +126,27 @@ namespace TUGraz.VectoCore.Models.Declaration
foreach (var missionType in missionTypes.Where(m => row.Field<string>(m.ToString()) != "-")) { foreach (var missionType in missionTypes.Where(m => row.Field<string>(m.ToString()) != "-")) {
var body = DeclarationData.StandardBodies.Lookup(row.Field<string>("body")); var body = DeclarationData.StandardBodies.Lookup(row.Field<string>("body"));
var trailerIsUsed = ShouldTrailerBeUsed(row, missionType); var maxGVW = Constants.SimulationSettings.MaximumGrossVehicleWeight;
var trailerField = row.Field<string>("trailer"); var trailers = new List<MissionTrailer>();
var trailerType = trailerIsUsed && !string.IsNullOrWhiteSpace(trailerField) if (missionType.IsEMS()) {
? trailerField.ParseEnum<TrailerType>() maxGVW = Constants.SimulationSettings.MaximumGrossVehicleWeightEMS;
: TrailerType.None; var trailerList = row.Field<string>("ems").Split('+');
var trailer = trailerIsUsed var trailerWeightShares = row.Field<string>("traileraxles" + GetMissionSuffix(missionType)).Split('/');
? DeclarationData.StandardBodies.Lookup(trailerField) if (trailerList.Length != trailerWeightShares.Length) {
: StandardBodies.Empty; throw new VectoException(
"Error in segmentation table: number of trailers and list of weight shares does not match!");
}
trailers.AddRange(trailerWeightShares.Select((t, i) => CreateTrailer(trailerList[i], t.ToDouble() / 100.0, i == 0)));
} else {
if (ShouldTrailerBeUsed(row, missionType)) {
var trailerValue = row.Field<string>("trailer");
if (string.IsNullOrWhiteSpace(trailerValue)) {
throw new VectoException("Error in segmentation table: trailer weight share is defined but not trailer type!");
}
trailers.Add(CreateTrailer(trailerValue, GetTrailerAxleWeightDistribution(row, missionType), true));
}
}
//var semiTrailerField = row.Field<string>("semitrailer"); //var semiTrailerField = row.Field<string>("semitrailer");
//var semiTrailer = !string.IsNullOrWhiteSpace(semiTrailerField) //var semiTrailer = !string.IsNullOrWhiteSpace(semiTrailerField)
...@@ -142,15 +156,19 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -142,15 +156,19 @@ namespace TUGraz.VectoCore.Models.Declaration
//trailer += semiTrailer; //trailer += semiTrailer;
// limit gvw to MaxGVW (40t) // limit gvw to MaxGVW (40t)
var gvw = VectoMath.Min(grossVehicleWeight + trailer.GrossVehicleWeight, var gvw =
Constants.SimulationSettings.MaximumGrossVehicleWeight); VectoMath.Min(
var maxLoad = gvw - curbWeight - body.CurbWeight - trailer.CurbWeight; grossVehicleWeight + trailers.Sum(t => t.TrailerGrossVehicleWeight).DefaultIfNull(0),
maxGVW);
var maxLoad = gvw - curbWeight - body.CurbWeight -
trailers.Sum(t => t.TrailerCurbWeight).DefaultIfNull(0);
var refLoadValue = row.ParseDoubleOrGetDefault(missionType.ToString(), double.NaN); var refLoadValue = row.ParseDoubleOrGetDefault(missionType.ToString(), double.NaN);
Kilogram refLoad; Kilogram refLoad;
if (double.IsNaN(refLoadValue)) { if (double.IsNaN(refLoadValue)) {
refLoad = DeclarationData.GetPayloadForGrossVehicleWeight(grossVehicleWeight, missionType) + refLoad = DeclarationData.GetPayloadForGrossVehicleWeight(grossVehicleWeight, missionType) +
DeclarationData.GetPayloadForTrailerWeight(trailer.GrossVehicleWeight, trailer.CurbWeight); trailers.Sum(t => DeclarationData.GetPayloadForTrailerWeight(t.TrailerGrossVehicleWeight, t.TrailerCurbWeight))
.DefaultIfNull(0);
} else { } else {
refLoad = refLoadValue.SI<Kilogram>(); refLoad = refLoadValue.SI<Kilogram>();
} }
...@@ -159,24 +177,20 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -159,24 +177,20 @@ namespace TUGraz.VectoCore.Models.Declaration
var mission = new Mission { var mission = new Mission {
MissionType = missionType, MissionType = missionType,
CrossWindCorrectionParameters = row.Field<string>("crosswindcorrection" + GetMissionSuffix(missionType)), CrossWindCorrectionParameters = row.Field<string>("crosswindcorrection" + GetMissionSuffix(missionType, true)),
CycleFile = CycleFile =
RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." + missionType + RessourceHelper.ReadStream(DeclarationData.DeclarationDataResourcePrefix + ".MissionCycles." +
missionType.ToString().Replace("EMS", "") +
Constants.FileExtensions.CycleFile), Constants.FileExtensions.CycleFile),
AxleWeightDistribution = GetAxleWeightDistribution(row, missionType), AxleWeightDistribution = GetAxleWeightDistribution(row, missionType),
CurbWeight = curbWeight, CurbWeight = curbWeight,
BodyCurbWeight = body.CurbWeight, BodyCurbWeight = body.CurbWeight,
BodyGrossVehicleWeight = grossVehicleWeight, BodyGrossVehicleWeight = grossVehicleWeight,
TrailerType = trailerType, Trailer = trailers,
TrailerCurbWeight = trailer.CurbWeight,
TrailerGrossVehicleWeight = trailer.GrossVehicleWeight,
TrailerWheels = trailer.Wheels,
TrailerAxleWeightShare = GetTrailerAxleWeightDistribution(row, missionType),
DeltaCdA = trailer.DeltaCrossWindArea,
MinLoad = 0.SI<Kilogram>(), MinLoad = 0.SI<Kilogram>(),
MaxLoad = maxLoad, MaxLoad = maxLoad,
RefLoad = refLoad, RefLoad = refLoad,
CargoVolume = body.CargoVolume + trailer.CargoVolume, TotalCargoVolume = body.CargoVolume + trailers.Sum(t => t.CargoVolume).DefaultIfNull(0),
}; };
missions.Add(mission); missions.Add(mission);
} }
...@@ -208,9 +222,25 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -208,9 +222,25 @@ namespace TUGraz.VectoCore.Models.Declaration
.Split('/').ToDouble().Select(x => x / 100.0).ToArray(); .Split('/').ToDouble().Select(x => x / 100.0).ToArray();
} }
private static string GetMissionSuffix(MissionType missionType) private static string GetMissionSuffix(MissionType missionType, bool ignoreEMS = false)
{ {
return missionType == MissionType.LongHaul ? "-longhaul" : "-other"; return (missionType.GetNonEMSMissionType() == MissionType.LongHaul ? "-longhaul" : "-other") +
(!ignoreEMS && missionType.IsEMS() ? "ems" : "");
}
private static MissionTrailer CreateTrailer(string trailerValue, double axleWeightShare, bool firstTrailer)
{
var trailerType = TrailterTypeHelper.Parse(trailerValue);
var trailer = DeclarationData.StandardBodies.Lookup(trailerType.ToString());
return new MissionTrailer {
TrailerType = trailerType,
TrailerWheels = trailer.Wheels,
TrailerAxleWeightShare = axleWeightShare,
TrailerCurbWeight = trailer.CurbWeight,
TrailerGrossVehicleWeight = trailer.GrossVehicleWeight,
DeltaCdA = trailer.DeltaCrossWindArea[firstTrailer ? 0 : 1],
CargoVolume = trailer.CargoVolume
};
} }
} }
} }
\ No newline at end of file
...@@ -42,7 +42,7 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -42,7 +42,7 @@ namespace TUGraz.VectoCore.Models.Declaration
{ {
public Kilogram CurbWeight; public Kilogram CurbWeight;
public Kilogram GrossVehicleWeight; public Kilogram GrossVehicleWeight;
public SquareMeter DeltaCrossWindArea; public SquareMeter[] DeltaCrossWindArea;
public string Name; public string Name;
public List<Wheels.Entry> Wheels; public List<Wheels.Entry> Wheels;
public CubicMeter CargoVolume; public CubicMeter CargoVolume;
...@@ -52,12 +52,12 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -52,12 +52,12 @@ namespace TUGraz.VectoCore.Models.Declaration
get { return GrossVehicleWeight - CurbWeight; } get { return GrossVehicleWeight - CurbWeight; }
} }
public StandardBody(string name, Kilogram curbWeight, Kilogram grossVehicleWeight, SquareMeter deltaCrossWindArea, public StandardBody(string name, Kilogram curbWeight, Kilogram grossVehicleWeight, SquareMeter[] deltaCrossWindArea,
Wheels.Entry wheels, int axleCount, CubicMeter volume) : Wheels.Entry wheels, int axleCount, CubicMeter volume) :
this(name, curbWeight, grossVehicleWeight, deltaCrossWindArea, this(name, curbWeight, grossVehicleWeight, deltaCrossWindArea,
wheels == null ? new List<Wheels.Entry>() : Enumerable.Repeat(wheels, axleCount).ToList(), volume) {} wheels == null ? new List<Wheels.Entry>() : Enumerable.Repeat(wheels, axleCount).ToList(), volume) {}
private StandardBody(string name, Kilogram curbWeight, Kilogram grossVehicleWeight, SquareMeter deltaCrossWindArea, private StandardBody(string name, Kilogram curbWeight, Kilogram grossVehicleWeight, SquareMeter[] deltaCrossWindArea,
List<Wheels.Entry> wheels, CubicMeter volume) List<Wheels.Entry> wheels, CubicMeter volume)
{ {
Name = name; Name = name;
...@@ -68,15 +68,15 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -68,15 +68,15 @@ namespace TUGraz.VectoCore.Models.Declaration
CargoVolume = volume; CargoVolume = volume;
} }
public static StandardBody operator +(StandardBody first, StandardBody second) //public static StandardBody operator +(StandardBody first, StandardBody second)
{ //{
var wheels = new List<Wheels.Entry>(first.Wheels); // var wheels = new List<Wheels.Entry>(first.Wheels);
wheels.AddRange(second.Wheels); // wheels.AddRange(second.Wheels);
return new StandardBody(first.Name + second.Name, first.CurbWeight + second.CurbWeight, // return new StandardBody(first.Name + second.Name, first.CurbWeight + second.CurbWeight,
first.GrossVehicleWeight + second.GrossVehicleWeight, // first.GrossVehicleWeight + second.GrossVehicleWeight,
first.DeltaCrossWindArea + second.DeltaCrossWindArea, // first.DeltaCrossWindArea + second.DeltaCrossWindArea,
wheels, first.CargoVolume + second.CargoVolume); // wheels, first.CargoVolume + second.TotalCargoVolume);
} //}
} }
/// <summary> /// <summary>
...@@ -90,8 +90,8 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -90,8 +90,8 @@ namespace TUGraz.VectoCore.Models.Declaration
/// </summary> /// </summary>
public sealed class StandardBodies : LookupData<string, StandardBody> public sealed class StandardBodies : LookupData<string, StandardBody>
{ {
public static readonly StandardBody Empty = new StandardBody("", 0.SI<Kilogram>(), 0.SI<Kilogram>(), //public static readonly StandardBody Empty = new StandardBody("", 0.SI<Kilogram>(), 0.SI<Kilogram>(),
0.SI<SquareMeter>(), null, 0, 0.SI<CubicMeter>()); // new[] { 0.SI<SquareMeter>(), 0.SI<SquareMeter>() }, null, 0, 0.SI<CubicMeter>());
protected override string ResourceId protected override string ResourceId
{ {
...@@ -103,23 +103,30 @@ namespace TUGraz.VectoCore.Models.Declaration ...@@ -103,23 +103,30 @@ namespace TUGraz.VectoCore.Models.Declaration
get { return "StandardWeigths Lookup Error: No value found for ID '{0}'"; } get { return "StandardWeigths Lookup Error: No value found for ID '{0}'"; }
} }
public override StandardBody Lookup(string id) //public override StandardBody Lookup(string id)
{ //{
return string.IsNullOrWhiteSpace(id) ? Empty : base.Lookup(id); // return string.IsNullOrWhiteSpace(id) ? Empty : base.Lookup(id);
} //}
protected override void ParseData(DataTable table) protected override void ParseData(DataTable table)
{ {
Data = table.Rows.Cast<DataRow>().Select(k => new StandardBody( Data = table.Rows.Cast<DataRow>().Select(k => {
var deltaCdxAStr = k.Field<string>("deltacdxafortraileroperationinlonghaul");
var deltaCdxA = new[] { 0.SI<SquareMeter>(), 0.SI<SquareMeter>() };
if (!deltaCdxAStr.Equals("-")) {
deltaCdxA = deltaCdxAStr.Split('/').Select(x => x.ToDouble().SI<SquareMeter>()).ToArray();
}
return new StandardBody(
k.Field<string>("name"), k.Field<string>("name"),
k.ParseDoubleOrGetDefault("curbmass").SI<Kilogram>(), k.ParseDoubleOrGetDefault("curbmass").SI<Kilogram>(),
k.ParseDoubleOrGetDefault("maxgrossmass").SI<Kilogram>(), k.ParseDoubleOrGetDefault("maxgrossmass").SI<Kilogram>(),
k.ParseDoubleOrGetDefault("deltacdxafortraileroperationinlonghaul").SI<SquareMeter>(), deltaCdxA,
!string.IsNullOrWhiteSpace(k.Field<string>("wheels")) !string.IsNullOrWhiteSpace(k.Field<string>("wheels"))
? DeclarationData.Wheels.Lookup(k.Field<string>("wheels")) ? DeclarationData.Wheels.Lookup(k.Field<string>("wheels"))
: null, : null,
Int32.Parse(k.Field<string>("axlecount")), Int32.Parse(k.Field<string>("axlecount")),
k.ParseDouble("cargovolume").SI<CubicMeter>())) k.ParseDouble("cargovolume").SI<CubicMeter>());
})
.ToDictionary(kv => kv.Name); .ToDictionary(kv => kv.Name);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment