From 7bf815c48bfa2cc9dff0ad972ad5860730059ff3 Mon Sep 17 00:00:00 2001
From: Michael Krisper <michael.krisper@tugraz.at>
Date: Tue, 10 May 2016 12:01:48 +0200
Subject: [PATCH] moved distance check from vehicle to driving cycle (due to
 changed commit order)

---
 .../Impl/DistanceBasedDrivingCycle.cs                | 11 +++++++++++
 .../Models/SimulationComponent/Impl/Vehicle.cs       | 12 ++----------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs
index f0db6c2284..318d48794a 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs
@@ -298,6 +298,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 
 		protected override void DoWriteModalResults(IModalDataContainer container)
 		{
+			// sanity check: is the vehicle in step with the cycle?
+			if (container[ModalResultField.dist] == DBNull.Value) {
+				Log.Warn("Distance field is not set!");
+			} else {
+				var distance = (SI)container[ModalResultField.dist];
+				if (!distance.IsEqual(CurrentState.Distance)) {
+					Log.Warn("Vehicle Distance diverges from Cycle by {0} [m]. Distance: {1}",
+						(distance - CurrentState.Distance).Value(), distance);
+				}
+			}
+
 			container[ModalResultField.dist] = CurrentState.Distance; // (CurrentState.Distance + PreviousState.Distance) / 2.0;
 			container[ModalResultField.simulationDistance] = CurrentState.SimulationDistance;
 			container[ModalResultField.v_targ] = CurrentState.VehicleTargetSpeed;
diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs
index 1b691725ab..6e0a47dbc8 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs
@@ -173,16 +173,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 			container[ModalResultField.P_air] = CurrentState.AirDragResistance * averageVelocity;
 			container[ModalResultField.P_slope] = CurrentState.SlopeResistance * averageVelocity;
 			container[ModalResultField.P_trac] = CurrentState.VehicleTractionForce * averageVelocity;
-			// sanity check: is the vehicle in step with the cycle?
-			if (container[ModalResultField.dist] == DBNull.Value) {
-				Log.Warn("Distance field is not set!");
-			} else {
-				var distance = (SI)container[ModalResultField.dist];
-				if (!distance.IsEqual(CurrentState.Distance)) {
-					Log.Warn("Vehicle Distance diverges from Cycle by {0} [m]. Distance: {1}",
-						(distance - CurrentState.Distance).Value(), distance);
-				}
-			}
+
+			container[ModalResultField.dist] = CurrentState.Distance;
 		}
 
 		protected override void DoCommitSimulationStep()
-- 
GitLab