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 5f7fcba1 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

add check of input data to exempted run. throw exeption in case of invalid input data

parent e86cc60c
Branches
Tags
No related merge requests found
using System; using System;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Models;
using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Connector.Ports.Impl;
using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Data;
...@@ -24,11 +25,28 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl { ...@@ -24,11 +25,28 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl {
protected override IResponse DoSimulationStep() protected override IResponse DoSimulationStep()
{ {
CheckValidInput();
FinishedWithoutErrors = true; FinishedWithoutErrors = true;
_writeSumData(null); _writeSumData(null);
return new ResponseCycleFinished(); return new ResponseCycleFinished();
} }
private void CheckValidInput()
{
var vehicleData = Container.RunData.VehicleData;
if (vehicleData.ZeroEmissionVehicle && vehicleData.DualFuelVehicle) {
throw new VectoException("Invalid input: ZE-HDV and DualFuelVehicle are mutually exclusive!");
}
if (!vehicleData.ZeroEmissionVehicle && !vehicleData.HybridElectricHDV && !vehicleData.DualFuelVehicle) {
throw new VectoException("Invalid input: at least one option of ZE-HDV, He-HDV, and DualFuelVehicle has to be set for an exempted vehicle!");
}
if (vehicleData.HybridElectricHDV && (vehicleData.MaxNetPower1 == null || vehicleData.MaxNetPower2 == null)) {
throw new VectoException("For He-HDV both MaxNetPower1 and MaxNetPower2 have to be provided!");
}
}
protected override IResponse Initialize() protected override IResponse Initialize()
{ {
return new ResponseSuccess(); return new ResponseSuccess();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment