From 69c0ce96b6a72cd19f4c636a2831302f31672fb7 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Fri, 8 Jul 2016 13:49:54 +0200
Subject: [PATCH] add check for size of aux demand map

---
 .../Reader/DataObjectAdapter/EngineeringDataAdapter.cs | 10 +++++++---
 VectoCore/VectoCore/Properties/AssemblyInfo.cs         |  1 +
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs
index 8bd1a0e5d1..8fbeb94159 100644
--- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs
+++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs
@@ -145,11 +145,11 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper
 
 			retVal.Gears = gears.Select((gear, i) => {
 				TransmissionLossMap lossMap;
-				if (gear.LossMap != null)
+				if (gear.LossMap != null) {
 					lossMap = TransmissionLossMap.Create(gear.LossMap, gear.Ratio, string.Format("Gear {0}", i + 1));
-				else if (useEfficiencyFallback)
+				} else if (useEfficiencyFallback) {
 					lossMap = TransmissionLossMap.Create(gear.Efficiency, gear.Ratio, string.Format("Gear {0}", i + 1));
-				else {
+				} else {
 					throw new InvalidFileFormatException("Gear {0} LossMap or Efficiency missing.", i + 1);
 				}
 				var gearFullLoad = gear.FullLoadCurve != null
@@ -185,6 +185,10 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper
 				if (a.DemandMap == null) {
 					throw new VectoSimulationException("Demand Map for auxiliary {0} {1} required", a.ID, a.Technology);
 				}
+				if (a.DemandMap.Columns.Count != 3 || a.DemandMap.Rows.Count < 4) {
+					throw new VectoSimulationException(
+						"Demand Map for auxiliary {0} {1} has to contain exactly 3 columns and at least 4 rows", a.ID, a.Technology);
+				}
 				return new VectoRunData.AuxData {
 					ID = a.ID,
 					Technology = a.Technology,
diff --git a/VectoCore/VectoCore/Properties/AssemblyInfo.cs b/VectoCore/VectoCore/Properties/AssemblyInfo.cs
index 26acbf3162..0dae924fd1 100644
--- a/VectoCore/VectoCore/Properties/AssemblyInfo.cs
+++ b/VectoCore/VectoCore/Properties/AssemblyInfo.cs
@@ -43,6 +43,7 @@ using System.Runtime.InteropServices;
 [assembly: ComVisible(false)]
 [assembly: Guid("b843f4c2-660b-4a3e-a336-c1f9c20aa993")]
 [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("VectoAPI")]
+[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("VectoEngineeringAPI")]
 [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("VECTO")]
 [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("VectoCoreTest")]
 [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("VectoAPITest")]
\ No newline at end of file
-- 
GitLab