diff --git a/VectoCore/Models/Simulation/SimulationContainer.cs b/VectoCore/Models/Simulation/SimulationContainer.cs new file mode 100644 index 0000000000000000000000000000000000000000..37bb253ecdf22a742bba679840223d7e1e5bd8fc --- /dev/null +++ b/VectoCore/Models/Simulation/SimulationContainer.cs @@ -0,0 +1,56 @@ +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using TUGraz.VectoCore.Models.SimulationComponent; + +namespace TUGraz.VectoCore.Models.Simulation +{ + public class SimulationContainer + { + private IList<VectoSimulationComponent> _components = new List<VectoSimulationComponent>(); + + private ICombustionEngine _engine = null; + private IGearbox _gearbox = null; + + public void AddComponent(VectoSimulationComponent component) + { + DoAddComponent(component); + } + + public void Addcomponent<T>(T engine) where T : VectoSimulationComponent, ICombustionEngine + { + _engine = engine; + DoAddComponent(engine); + } + + public void AddComponent<T>(T gearbox) where T : VectoSimulationComponent, IGearbox + { + _gearbox = gearbox; + DoAddComponent(gearbox); + } + + public IReadOnlyCollection<VectoSimulationComponent> SimulationComponents() + { + return new ReadOnlyCollection<VectoSimulationComponent>(_components); + } + + public ICombustionEngine CombustionEngine() + { + return _engine; + } + + public IGearbox Gearbox() + { + return _gearbox; + } + + + + protected void DoAddComponent(VectoSimulationComponent component) + { + _components.Add(component); + } + + + } +} diff --git a/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 21d625f55545d998fc6c0a0d665fc5cc130f6065..900cb6a92ff6c782701ceb1a884de784582bbab1 100644 --- a/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -164,7 +164,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var deltaEngineSpeed = engineSpeed - _previousState.EngineSpeed; var avgEngineSpeed = (_previousState.EngineSpeed + engineSpeed) / 2.0; - return _data.Inertia*VectoMath.RpmTpAngularVelocity(deltaEngineSpeed)*VectoMath.RpmTpAngularVelocity(avgEngineSpeed); + return _data.Inertia * VectoMath.RpmTpAngularVelocity(deltaEngineSpeed) * VectoMath.RpmTpAngularVelocity(avgEngineSpeed); } // accelleration los rotation engine diff --git a/VectoCore/VectoCore.csproj b/VectoCore/VectoCore.csproj index a7df0b44cb1cdfba8800e6db4fa355f7d35194af..774194d972d015f21d8e5e26edfbb2091c807d4e 100644 --- a/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore.csproj @@ -84,6 +84,7 @@ <Compile Include="Models\SimulationComponent\IWheels.cs" /> <Compile Include="Models\SimulationComponent\SimulationComponentData.cs" /> <Compile Include="Models\SimulationComponent\VectoSimulationComponent.cs" /> + <Compile Include="Models\Simulation\SimulationContainer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Utils\DataRowExtensionMethods.cs" /> <Compile Include="Utils\VectoMath.cs" /> diff --git a/VectoCoreTest/Models/UnitTest1.cs b/VectoCoreTest/Models/UnitTest1.cs new file mode 100644 index 0000000000000000000000000000000000000000..30b495ad2b2b1b40bbe2d99bf5cea2f4100de9c0 --- /dev/null +++ b/VectoCoreTest/Models/UnitTest1.cs @@ -0,0 +1,25 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using TUGraz.VectoCore.Models.Simulation; +using TUGraz.VectoCore.Models.SimulationComponent; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Models.SimulationComponent.Impl; + +namespace TUGraz.VectoCore.Tests.Models +{ + [TestClass] + public class UnitTest1 + { + [TestMethod] + public void TestMethod1() + { + var engine = new CombustionEngine(new CombustionEngineData()); + + var simulationcontainer = new SimulationContainer(); + + simulationcontainer.Addcomponent(engine); + + Assert.IsInstanceOfType(simulationcontainer.CombustionEngine(), typeof(ICombustionEngine)); + } + } +} diff --git a/VectoCoreTest/VectoCoreTest.csproj b/VectoCoreTest/VectoCoreTest.csproj index 5f4ac6c100d0d388e729182d241cea3c81e015cf..b65fc503b778e0fa86d7f270afef3e4c3551da80 100644 --- a/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCoreTest/VectoCoreTest.csproj @@ -69,6 +69,7 @@ <ItemGroup> <Compile Include="Models\SimulationComponentData\FullLoadCurveTest.cs" /> <Compile Include="Models\SimulationComponent\CombustionEngineTest.cs" /> + <Compile Include="Models\UnitTest1.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\Settings.Designer.cs"> <AutoGen>True</AutoGen>