diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs b/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs index 17b9bfb1a31c0dfe7589a9b22254e3622fae3a0c..d1b158c5c72de5acf6818c82f64a924f66ca1549 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/DistanceRun.cs @@ -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!"); }