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

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
No related branches found
No related tags found
No related merge requests found
using System;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCore.Models.Connector.Ports.Impl;
using TUGraz.VectoCore.Models.Simulation.Data;
......@@ -24,11 +25,28 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl {
protected override IResponse DoSimulationStep()
{
CheckValidInput();
FinishedWithoutErrors = true;
_writeSumData(null);
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()
{
return new ResponseSuccess();
......
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