Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

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

more readable implementation of VehicleContainer.AddComponent

parent e17c4309
No related branches found
No related tags found
No related merge requests found
......@@ -170,53 +170,18 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
{
Components.Add(component);
var engine = component as IEngineInfo;
if (engine != null) {
Engine = engine;
}
var driver = component as IDriverInfo;
if (driver != null) {
Driver = driver;
}
var gearbox = component as IGearboxInfo;
if (gearbox != null) {
Gearbox = gearbox;
}
var vehicle = component as IVehicleInfo;
if (vehicle != null) {
Vehicle = vehicle;
}
var cycle = component as ISimulationOutPort;
if (cycle != null) {
Cycle = cycle;
}
var milage = component as IMileageCounter;
if (milage != null) {
MilageCounter = milage;
}
var breaks = component as IBrakes;
if (breaks != null) {
Brakes = breaks;
}
var road = component as IRoadLookAhead;
if (road != null) {
Road = road;
}
var clutch = component as IClutchInfo;
if (clutch != null) {
Clutch = clutch;
}
component.Switch()
.If<IEngineInfo>(c => Engine = c)
.If<IDriverInfo>(c => Driver = c)
.If<IGearboxInfo>(c => Gearbox = c)
.If<IVehicleInfo>(c => Vehicle = c)
.If<ISimulationOutPort>(c => Cycle = c)
.If<IMileageCounter>(c => MilageCounter = c)
.If<IBrakes>(c => Brakes = c)
.If<IRoadLookAhead>(c => Road = c)
.If<IClutchInfo>(c => Clutch = c);
}
public void CommitSimulationStep(Second time, Second simulationInterval)
{
Log.Info("VehicleContainer committing simulation. time: {0}, dist: {1}, speed: {2}", time, Distance, VehicleSpeed);
......
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