diff --git a/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index a876e1b194a0d01c37fd13078e3088a2eaa6a090..85ba72ed618998e7ec189d15c6b58f73c11bcd1e 100644 --- a/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -14,30 +14,30 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl { public class VehicleContainer : IVehicleContainer { - internal readonly IList<VectoSimulationComponent> _components = new List<VectoSimulationComponent>(); - internal IEngineInfo _engine; - internal IGearboxInfo _gearbox; - internal IVehicleInfo _vehicle; + internal readonly IList<VectoSimulationComponent> Components = new List<VectoSimulationComponent>(); + internal IEngineInfo Engine; + internal IGearboxInfo Gearbox; + internal IVehicleInfo Vehicle; - internal IMileageCounter _milageCounter; + internal IMileageCounter MilageCounter; - internal IRoadLookAhead _road; + internal IRoadLookAhead Road; - internal ISimulationOutPort _cycle; + internal ISimulationOutPort Cycle; - internal ISummaryDataWriter _sumWriter; - internal IModalDataWriter _dataWriter; + internal ISummaryDataWriter SumWriter; + internal IModalDataWriter DataWriter; - private ILog _logger; + private readonly ILog _logger; #region IGearCockpit public uint Gear() { - if (_gearbox == null) { + if (Gearbox == null) { throw new VectoException("no gearbox available!"); } - return _gearbox.Gear(); + return Gearbox.Gear(); } #endregion @@ -46,10 +46,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public PerSecond EngineSpeed() { - if (_engine == null) { + if (Engine == null) { throw new VectoException("no engine available!"); } - return _engine.EngineSpeed(); + return Engine.EngineSpeed(); } #endregion @@ -58,22 +58,22 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public MeterPerSecond VehicleSpeed() { - return _vehicle != null ? _vehicle.VehicleSpeed() : 0.SI<MeterPerSecond>(); + return Vehicle != null ? Vehicle.VehicleSpeed() : 0.SI<MeterPerSecond>(); } public Kilogram VehicleMass() { - return _vehicle != null ? _vehicle.VehicleMass() : 0.SI<Kilogram>(); + return Vehicle != null ? Vehicle.VehicleMass() : 0.SI<Kilogram>(); } public Kilogram VehicleLoading() { - return _vehicle != null ? _vehicle.VehicleLoading() : 0.SI<Kilogram>(); + return Vehicle != null ? Vehicle.VehicleLoading() : 0.SI<Kilogram>(); } public Kilogram TotalMass() { - return _vehicle != null ? _vehicle.TotalMass() : 0.SI<Kilogram>(); + return Vehicle != null ? Vehicle.TotalMass() : 0.SI<Kilogram>(); } #endregion @@ -81,49 +81,49 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public VehicleContainer(IModalDataWriter dataWriter = null, ISummaryDataWriter sumWriter = null) { _logger = LogManager.GetLogger(GetType()); - _dataWriter = dataWriter; - _sumWriter = sumWriter; + DataWriter = dataWriter; + SumWriter = sumWriter; } #region IVehicleContainer public ISimulationOutPort GetCycleOutPort() { - return _cycle; + return Cycle; } public virtual void AddComponent(VectoSimulationComponent component) { - _components.Add(component); + Components.Add(component); var engine = component as IEngineInfo; if (engine != null) { - _engine = engine; + Engine = engine; } var gearbox = component as IGearboxInfo; if (gearbox != null) { - _gearbox = gearbox; + Gearbox = gearbox; } var vehicle = component as IVehicleInfo; if (vehicle != null) { - _vehicle = vehicle; + Vehicle = vehicle; } var cycle = component as ISimulationOutPort; if (cycle != null) { - _cycle = cycle; + Cycle = cycle; } var milage = component as IMileageCounter; if (milage != null) { - _milageCounter = milage; + MilageCounter = milage; } var road = component as IRoadLookAhead; if (road != null) { - _road = road; + Road = road; } } @@ -131,45 +131,45 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public void CommitSimulationStep(Second time, Second simulationInterval) { _logger.Info("VehicleContainer committing simulation."); - foreach (var component in _components) { - component.CommitSimulationStep(_dataWriter); + foreach (var component in Components) { + component.CommitSimulationStep(DataWriter); } - if (_dataWriter != null) { - _dataWriter[ModalResultField.time] = time + simulationInterval / 2; - _dataWriter[ModalResultField.simulationInterval] = simulationInterval; - _dataWriter.CommitSimulationStep(); + if (DataWriter != null) { + DataWriter[ModalResultField.time] = time + simulationInterval / 2; + DataWriter[ModalResultField.simulationInterval] = simulationInterval; + DataWriter.CommitSimulationStep(); } } public void FinishSimulation() { _logger.Info("VehicleContainer finishing simulation."); - _dataWriter.Finish(); + DataWriter.Finish(); - _sumWriter.Write(_dataWriter, VehicleMass(), VehicleLoading()); + SumWriter.Write(DataWriter, VehicleMass(), VehicleLoading()); } #endregion public IReadOnlyCollection<VectoSimulationComponent> SimulationComponents() { - return new ReadOnlyCollection<VectoSimulationComponent>(_components); + return new ReadOnlyCollection<VectoSimulationComponent>(Components); } public Meter Distance() { - return _milageCounter.Distance(); + return MilageCounter.Distance(); } public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter distance) { - return _road.LookAhead(distance); + return Road.LookAhead(distance); } public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Second time) { - return _road.LookAhead(time); + return Road.LookAhead(time); } } } \ No newline at end of file diff --git a/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs b/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs index e1b8d72b408a76e4fb7b8cace30c6cbb10c4ed8c..5574868b630f12aea3e5a0ed0720911ce696411f 100644 --- a/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs +++ b/VectoCoreTest/Models/Simulation/PowerTrainBuilderTest.cs @@ -28,12 +28,12 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var powerTrain = builder.Build(runData); Assert.IsInstanceOfType(powerTrain, typeof(IVehicleContainer)); - Assert.AreEqual(10, powerTrain._components.Count); + Assert.AreEqual(10, powerTrain.Components.Count); - Assert.IsInstanceOfType(powerTrain._engine, typeof(CombustionEngine)); - Assert.IsInstanceOfType(powerTrain._gearbox, typeof(Gearbox)); - Assert.IsInstanceOfType(powerTrain._cycle, typeof(ISimulationOutPort)); - Assert.IsInstanceOfType(powerTrain._vehicle, typeof(Vehicle)); + Assert.IsInstanceOfType(powerTrain.Engine, typeof(CombustionEngine)); + Assert.IsInstanceOfType(powerTrain.Gearbox, typeof(Gearbox)); + Assert.IsInstanceOfType(powerTrain.Cycle, typeof(ISimulationOutPort)); + Assert.IsInstanceOfType(powerTrain.Vehicle, typeof(Vehicle)); } } } \ No newline at end of file