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

Skip to content
Snippets Groups Projects
Commit 9e519f0d authored by Michael KRISPER's avatar Michael KRISPER
Browse files

replaced switch in DistanceRun

parent 8249676b
No related branches found
No related tags found
No related merge requests found
......@@ -61,24 +61,27 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
Container.Brakes.BrakePower = 0.SI<Watt>();
response = CyclePort.Request(AbsTime, ds);
response.Switch().
Case<ResponseSuccess>(r => { dt = r.SimulationInterval; }).
Case<ResponseDrivingCycleDistanceExceeded>(r => {
switch (response) {
case ResponseSuccess r:
dt = r.SimulationInterval;
break;
case ResponseDrivingCycleDistanceExceeded r:
if (r.MaxDistance.IsSmallerOrEqual(0)) {
throw new VectoSimulationException("DistanceExceeded, MaxDistance is invalid: {0}", r.MaxDistance);
}
ds = r.MaxDistance;
}).
Case<ResponseCycleFinished>(r => {
break;
case ResponseCycleFinished _:
FinishedWithoutErrors = true;
Log.Info("========= Driving Cycle Finished");
}).
Case<ResponseBatteryEmpty>(
r => {
FinishedWithoutErrors = true;
Log.Info("========= REESS empty");
}).
Default(r => { throw new VectoException("DistanceRun got an unexpected response: {0}", r); });
break;
case ResponseBatteryEmpty _:
FinishedWithoutErrors = true;
Log.Info("========= REESS empty");
break;
default:
throw new VectoException("DistanceRun got an unexpected response: {0}", response);
}
if (loopCount++ > Constants.SimulationSettings.MaximumIterationCountForSimulationStep) {
throw new VectoSimulationException("Maximum iteration count for a single simulation interval reached! Aborting!");
}
......
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