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

Skip to content
Snippets Groups Projects
Commit a5a45aff authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

refactor reading whr data from xml, throw exception in case something is mission

parent 5cf08466
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,15 @@ namespace TUGraz.VectoCommon.Exceptions
}
}
public class VectoXMLException : VectoException
{
protected VectoXMLException(SerializationInfo info, StreamingContext context) : base(info, context) { }
public VectoXMLException(string message) : base(message) { }
public VectoXMLException(string message, Exception innerException) : base(message, innerException) { }
public VectoXMLException(string message, params object[] args) : base(message, args) { }
public VectoXMLException(string message, Exception inner, params object[] args) : base(message, inner, args) { }
}
/// <summary>
/// Exception when an Input/Output related error occured.
/// </summary>
......
......@@ -300,9 +300,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider
return WHRData ?? (WHRData = ReadWHRData(
GetNodes(
new[] {
XMLNames.Engine_FuelModes_Fuel, XMLNames.Engine_WHRCorrectionFactors,
XMLNames.Engine_WHRCorrectionFactors,
XMLNames.Engine_WHRCorrectionFactors_Electrical
}),
}, GetNode(XMLNames.Engine_FuelModes_Fuel)),
XMLNames.Engine_FuelConsumptionMap_WHRElPower_Attr)
);
}
......@@ -314,9 +314,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider
return WHRData ?? (WHRData = ReadWHRData(
GetNodes(
new[] {
XMLNames.Engine_FuelModes_Fuel, XMLNames.Engine_WHRCorrectionFactors,
XMLNames.Engine_WHRCorrectionFactors,
XMLNames.Engine_WHRCorrectionFactors_Mechanical
}),
}, GetNode(XMLNames.Engine_FuelModes_Fuel)),
XMLNames.Engine_FuelConsumptionMap_WHRMechPower_Attr));
}
}
......@@ -327,25 +327,26 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider
{
var whrPwrNodes = GetNodes(
new[] {
XMLNames.Engine_FuelModes_Fuel, XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry
})
.Cast<XmlNode>().All(x => x.Attributes?[fcMapAttr] == null);
if (correctionFactorNodes.Count == 0) {
if (whrPwrNodes) {
Warn("WHR correction factors provided but no {0} power defined - ignoring WHR.", fcMapAttr);
XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry
}, GetNode(XMLNames.Engine_FuelModes_Fuel))
.Cast<XmlNode>().All(x => x.Attributes?[fcMapAttr] != null);
if (correctionFactorNodes.Count > 0) {
if (!whrPwrNodes) {
throw new VectoXMLException("WHR correction factors provided but no {0} power defined.", fcMapAttr);
}
return new XMLDeclarationWHRData();
//return new XMLDeclarationWHRData();
}
if (correctionFactorNodes.Count > 1) {
throw new VectoException("WHRData (correction factors) can only be defined for one fuel!");
throw new VectoXMLException("WHRData (correction factors) can only be defined for one fuel!");
}
if (whrPwrNodes) {
if (correctionFactorNodes.Count == 0) {
Warn("WHR electric power provided but no correction factors found - ignoring WHR.");
throw new VectoXMLException("WHR electric power provided but no correction factors found.");
}
return new XMLDeclarationWHRData();
//return new XMLDeclarationWHRData();
}
var fuelNodes = GetNodes(XMLNames.Engine_FuelModes_Fuel);
......
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