NRP Core  1.4.1
simulation_manager_fti.h
Go to the documentation of this file.
1 /* * NRP Core - Backend infrastructure to synchronize simulations
2  *
3  * Copyright 2020-2023 NRP Team
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * This project has received funding from the European Union’s Horizon 2020
18  * Framework Programme for Research and Innovation under the Specific Grant
19  * Agreement No. 945539 (Human Brain Project SGA3).
20  */
21 
22 #ifndef SIMULATION_MANAGER_FTI_H
23 #define SIMULATION_MANAGER_FTI_H
24 
29 
34  : public SimulationManager
35 {
36  public:
37 
44  FTILoopSimManager(const jsonSharedPtr &simulationConfig, const EngineLauncherManagerConstSharedPtr &engineLauncherManager,
45  const MainProcessLauncherManager::const_shared_ptr &processLauncherManager);
46 
51 
52  bool hasSimulationTimedOut() const override;
53 
54  private:
55 
56  // Callback functions for the different simulation control requests.
57  void initializeCB() override;
58  bool resetCB() override;
59  void stopCB() override;
60  bool runUntilDoneOrTimeoutCB() override;
61  bool runCB(unsigned numIterations) override;
62  void shutdownCB() override;
63 
65  EngineLauncherManagerConstSharedPtr _engineLauncherManager;
67  MainProcessLauncherManager::const_shared_ptr _processLauncherManager;
69  FTILoopSharedPtr _loop;
71  SimulationTime _timeStep;
73  std::atomic<bool> _stopLoop;
74 
78  FTILoop createSimLoop();
79 
83  void runSimulationOnce();
84 
91  bool runSimulationUntilCondition(std::function<bool ()> condition);
92 
99  bool hasSimTimedOut(const SimulationTime &simTime, const SimulationTime &simTimeout);
100 };
101 
102 #endif
SimulationManager
Manages simulation execution.
Definition: simulation_manager.h:47
EngineLauncherManagerConstSharedPtr
EngineLauncherManager::const_shared_ptr EngineLauncherManagerConstSharedPtr
Definition: engine_launcher_manager.h:59
FTILoopSimManager::hasSimulationTimedOut
bool hasSimulationTimedOut() const override
Definition: simulation_manager_fti.cpp:56
PtrTemplates< ProcessLauncherManager< PROCESS_LAUNCHERS... > >::const_shared_ptr
std::shared_ptr< const ProcessLauncherManager< PROCESS_LAUNCHERS... > > const_shared_ptr
Definition: ptr_templates.h:32
process_launcher_manager.h
jsonSharedPtr
std::shared_ptr< nlohmann::json > jsonSharedPtr
Definition: json_schema_utils.h:35
engine_launcher_manager.h
FTILoopSharedPtr
FTILoop::shared_ptr FTILoopSharedPtr
Definition: fti_loop.h:109
FTILoopSimManager::FTILoopSimManager
FTILoopSimManager(const jsonSharedPtr &simulationConfig, const EngineLauncherManagerConstSharedPtr &engineLauncherManager, const MainProcessLauncherManager::const_shared_ptr &processLauncherManager)
Constructor.
Definition: simulation_manager_fti.cpp:37
fti_loop.h
FTILoop
Manages simulation loop. Runs physics and brain interface, and synchronizes them via Transfer Functio...
Definition: fti_loop.h:34
FTILoopSimManager::~FTILoopSimManager
~FTILoopSimManager()
Destructor. Will shutdown the simulation if it was initialized.
Definition: simulation_manager_fti.cpp:45
simulation_manager.h
SimulationTime
std::chrono::nanoseconds SimulationTime
Definition: time_utils.h:31
FTILoopSimManager
Implementation of SimulationManager which manages an FTILoop.
Definition: simulation_manager_fti.h:33