Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

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

make vecto exception with message, inner and params public, json parser:...

make vecto exception with message, inner and params public, json parser: aggregate exception messages, engineering data adapter: check if demand map for auxiliary is given
parent 3819e395
Branches
Tags
No related merge requests found
......@@ -60,7 +60,7 @@ namespace TUGraz.VectoCommon.Exceptions
LogManager.Flush();
}
protected VectoException(string message, Exception inner, params object[] args)
public VectoException(string message, Exception inner, params object[] args)
: base(string.Format(message, args), inner)
{
LogManager.Flush();
......
......@@ -209,31 +209,22 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
if (!EmptyOrInvalidFileName(gearboxFile)) {
Gearbox = JSONInputDataFactory.ReadGearbox(Path.Combine(BasePath, gearboxFile));
}
} catch (Exception e) {
throw new VectoException("Failed to read Gearbox file.", e);
}
try {
var axleGear = Gearbox as IAxleGearInputData;
if (axleGear != null) {
AxleGear = axleGear;
}
} catch (Exception e) {
throw new VectoException("Failed to read AxleGear file.", e);
}
try {
Engine = JSONInputDataFactory.ReadEngine(
Path.Combine(BasePath, Body.GetEx(JsonKeys.Vehicle_EngineFile).Value<string>()));
} catch (Exception e) {
throw new VectoException("Failed to read Engine file.", e);
}
try {
var vehicleFile = Body.GetEx(JsonKeys.Vehicle_VehicleFile).Value<string>();
if (!EmptyOrInvalidFileName(vehicleFile)) {
VehicleData = JSONInputDataFactory.ReadJsonVehicle(
Path.Combine(BasePath, vehicleFile));
}
} catch (Exception e) {
throw new VectoException("Failed to read Vehicle file.", e);
throw new VectoException("Failed to read input data: {0}", e, e.Message);
}
var retarder = VehicleData as IRetarderInputData;
if (retarder != null) {
......@@ -265,7 +256,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public virtual IVehicleEngineeringInputData VehicleInputData
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
get
{
if (VehicleData == null) {
......@@ -277,7 +269,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public virtual IGearboxEngineeringInputData GearboxInputData
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
get
{
if (Gearbox == null) {
......@@ -289,7 +282,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public virtual IAxleGearInputData AxleGearInputData
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
get
{
if (AxleGear == null) {
......@@ -306,7 +300,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public virtual IEngineEngineeringInputData EngineInputData
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
get
{
if (Engine == null) {
......@@ -333,7 +328,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public virtual IRetarderInputData RetarderInputData
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
get
{
if (Retarder == null) {
......@@ -359,7 +355,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public virtual IList<ICycleData> Cycles
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
get
{
var retVal = new List<ICycleData>();
......@@ -467,7 +464,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public virtual DataTable AccelerationCurve
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design",
"CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
get
{
var acceleration = Body[JsonKeys.DriverData_AccelerationCurve];
......
......@@ -173,12 +173,17 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdaper
WarnEngineeringMode("AuxData");
}
return auxInputData.Auxiliaries.Select(a => new VectoRunData.AuxData {
return auxInputData.Auxiliaries.Select(a => {
if (a.DemandMap == null) {
throw new VectoSimulationException("Demand Map for auxiliary {0} {1} required", a.ID, a.Technology);
}
return new VectoRunData.AuxData {
ID = a.ID,
Technology = a.Technology,
TechList = a.TechList.DefaultIfNull(Enumerable.Empty<string>()).ToArray(),
DemandType = AuxiliaryDemandType.Mapping,
Data = new AuxiliaryData(a, a.ID) //AuxiliaryData.Create(a.DemandMap)
};
}).Concat(new VectoRunData.AuxData { ID = "", DemandType = AuxiliaryDemandType.Direct }.ToEnumerable()).ToList();
}
......
......@@ -86,7 +86,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
(internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed);
Assert.AreEqual(6086.9321, (torque * engineSpeed).Value(), 1e-3);
busAux.CommitSimulationStep(modalData);
busAux.DoWriteModalResults(modalData);
}
Assert.AreEqual(79.303, ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001);
......@@ -98,7 +98,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
(internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed);
Assert.AreEqual(8954.1396, (torque * engineSpeed).Value(), 1e-3);
busAux.CommitSimulationStep(modalData);
busAux.DoWriteModalResults(modalData);
}
Assert.AreEqual(82.5783, ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001);
......@@ -110,7 +110,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
(internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed);
Assert.AreEqual(6086.9321, (torque * engineSpeed).Value(), 1e-3);
busAux.CommitSimulationStep(modalData);
busAux.DoWriteModalResults(modalData);
}
Assert.AreEqual(162.4654, ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment