From 2150fad5d8fc72147d39823be389d9d1003af1a4 Mon Sep 17 00:00:00 2001
From: Michael Krisper <michael.krisper@tugraz.at>
Date: Fri, 11 Nov 2016 15:20:13 +0100
Subject: [PATCH] CombustionEngineData: Added Warning when Inertia is 0

---
 .../SimulationComponent/Data/CombustionEngineData.cs  | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs
index 843925cacf..238da75a9e 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs
@@ -31,12 +31,14 @@
 
 using System;
 using System.ComponentModel.DataAnnotations;
+using TUGraz.VectoCommon.Models;
 using TUGraz.VectoCommon.Utils;
 using TUGraz.VectoCore.Configuration;
 using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine;
 
 namespace TUGraz.VectoCore.Models.SimulationComponent.Data
 {
+	[CustomValidation(typeof(CombustionEngineData), "ValidateData")]
 	public class CombustionEngineData : SimulationComponentData
 	{
 		[Required, SIRange(1000 * 1E-6, 20000 * 1E-6)]
@@ -89,5 +91,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
 				WHTCCorrectionFactor = WHTCCorrectionFactor,
 			};
 		}
+
+		// ReSharper disable once UnusedMember.Global -- used in CustomValidation
+		public static ValidationResult ValidateData(CombustionEngineData data, ValidationContext context)
+		{
+			if (data.Inertia.IsEqual(0)) {
+				LogManager.GetLogger(typeof(CombustionEngineData).FullName).Error("Warning: Engine Inertia is 0!");
+			}
+			return ValidationResult.Success;
+		}
 	}
 }
\ No newline at end of file
-- 
GitLab