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

modContainer extension methods: add default values for aggregates

parent c1c515b5
No related branches found
No related tags found
No related merge requests found
......@@ -152,7 +152,7 @@ namespace TUGraz.VectoCore.OutputData
{
var accelerationTimeShare = data.Data.Rows.Cast<DataRow>()
.Select(x => new {
a = x.Field<MeterPerSquareSecond>((int)ModalResultField.acc),
a = x.Field<MeterPerSquareSecond>((int)ModalResultField.acc).DefaultIfNull(0),
dt = x.Field<Second>((int)ModalResultField.simulationInterval)
})
.Sum(x => x.a > 0.125 ? x.dt : 0.SI<Second>()).DefaultIfNull(0);
......@@ -163,7 +163,7 @@ namespace TUGraz.VectoCore.OutputData
{
var decelerationTimeShare = data.Data.Rows.Cast<DataRow>()
.Select(x => new {
a = x.Field<MeterPerSquareSecond>((int)ModalResultField.acc),
a = x.Field<MeterPerSquareSecond>((int)ModalResultField.acc).DefaultIfNull(0),
dt = x.Field<Second>((int)ModalResultField.simulationInterval)
})
.Sum(x => x.a < -0.125 ? x.dt : 0.SI<Second>()).DefaultIfNull(0);
......@@ -174,8 +174,8 @@ namespace TUGraz.VectoCore.OutputData
{
var cruiseTime = data.Data.Rows.Cast<DataRow>()
.Select(x => new {
v = x.Field<MeterPerSecond>((int)ModalResultField.v_act),
a = x.Field<MeterPerSquareSecond>((int)ModalResultField.acc),
v = x.Field<MeterPerSecond>((int)ModalResultField.v_act).DefaultIfNull(0),
a = x.Field<MeterPerSquareSecond>((int)ModalResultField.acc).DefaultIfNull(0),
dt = x.Field<Second>((int)ModalResultField.simulationInterval)
})
.Sum(x => x.v >= 0.1.KMPHtoMeterPerSecond() && x.a.IsBetween(-0.125, 0.125) ? x.dt : 0.SI<Second>())
......@@ -187,7 +187,7 @@ namespace TUGraz.VectoCore.OutputData
{
var stopTime = data.Data.Rows.Cast<DataRow>()
.Select(x => new {
v = x.Field<MeterPerSecond>((int)ModalResultField.v_act),
v = x.Field<MeterPerSecond>((int)ModalResultField.v_act).DefaultIfNull(0),
dt = x.Field<Second>((int)ModalResultField.simulationInterval)
})
.Sum(x => x.v < 0.1.KMPHtoMeterPerSecond() ? x.dt : 0.SI<Second>()) ?? 0.SI<Second>();
......
......@@ -58,6 +58,7 @@ namespace TUGraz.VectoCore.Tests.Reports
for (var i = 0; i < 499; i++) {
modData[ModalResultField.simulationInterval] = 1.SI<Second>();
modData[ModalResultField.n_eng_avg] = 600.RPMtoRad();
modData[ModalResultField.v_act] = 20.KMPHtoMeterPerSecond();
modData[ModalResultField.drivingBehavior] = DrivingBehavior.Driving;
modData[ModalResultField.time] = i.SI<Second>();
modData[ModalResultField.dist] = i.SI<Meter>();
......@@ -119,6 +120,7 @@ namespace TUGraz.VectoCore.Tests.Reports
modData[ModalResultField.time] = i.SI<Second>();
modData[ModalResultField.dist] = i.SI<Meter>();
modData[ModalResultField.n_eng_avg] = 600.RPMtoRad();
modData[ModalResultField.v_act] = 20.KMPHtoMeterPerSecond();
modData[ModalResultField.drivingBehavior] = DrivingBehavior.Driving;
modData["FAN"] = powerDemand[i % powerDemand.Length];
modData[ModalResultField.P_air] = powerDemand[i % powerDemand.Length];
......
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