Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit cfaaf2c3 authored by Markus QUARITSCH's avatar Markus QUARITSCH
Browse files

Merge pull request #750 in VECTO/vecto-sim from...

Merge pull request #750 in VECTO/vecto-sim from ~EMQUARIMA/vecto-sim:bugfix/VECTO-950-error-when-loading-engine-full-load-curve to develop

* commit '1caa8840':
  correcting type
  throw exception in case an engine speed occurs multiple times
  adding testcase for engine FLD with multiple entries for same engine speed
parents 7df0703e 1caa8840
No related branches found
No related tags found
No related merge requests found
......@@ -159,7 +159,7 @@ Public Class Engine
Dim messages As IEnumerable(Of String) =
validationResults.Select(Function(r) r.ErrorMessage + String.Join(", ", r.MemberNames.Distinct()))
MsgBox("Invalid input." + Environment.NewLine + String.Join(Environment.NewLine, messages), MsgBoxStyle.OkOnly,
"Failed to save gearbox")
"Failed to save engine")
Return False
End If
......
......@@ -84,6 +84,12 @@ namespace TUGraz.VectoCore.InputData.Reader
tmp = data.Columns.Count > 3 ? new PT1(data) : new PT1();
}
entriesFld.Sort((entry1, entry2) => entry1.EngineSpeed.Value().CompareTo(entry2.EngineSpeed.Value()));
var duplicates = entriesFld.Select(x => x.EngineSpeed.AsRPM).GroupBy(x => x).Where(g => g.Count() > 1)
.Select(g => g.Key).ToList();
if (duplicates.Count > 0) {
throw new VectoException(
"Error reading full-load curve: multiple entries for engine speeds {0}", string.Join(", ", duplicates));
}
return new EngineFullLoadCurve(entriesFld, tmp);
}
......
......@@ -341,5 +341,29 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData
Assert.AreEqual(1352, fldCurve.FullLoadStationaryTorque(2000.RPMtoRad()).Value(), Tolerance);
Assert.AreEqual(1231, fldCurve.FullLoadStationaryTorque(580.RPMtoRad()).Value(), Tolerance);
}
[TestCase]
public void TestDuplicateEntries()
{
var fldData = new[] {
"560,1180,-149,0.6",
"600,1282,-148,0.6",
"800,1791,-149,0.6",
"1000,2300,-160,0.6",
"1200,2400,-179,0.6",
"1400,2300,-203,0.6",
"1600,2079,-235,0.49",
"1800,1857,-264,0.25",
"2000,1352,-301,0.25",
"2100,1100,-320,0.25",
"1200,2410,-180,0.6",
};
var fldEntries = InputDataHelper.InputDataAsStream("n [U/min],Mfull [Nm],Mdrag [Nm],<PT1> [s] ", fldData);
AssertHelper.Exception<VectoException>(
() => {
var fldCurve = FullLoadCurveReader.Create(VectoCSVFile.ReadStream(fldEntries));
}, messageContains: "Error reading full-load curve: multiple entries for engine speeds 1200");
}
}
}
\ No newline at end of file
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