NRP Core  1.4.1
fti_loop.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 FTI_LOOP_H
23 #define FTI_LOOP_H
24 
26 
28 
30 
34 class FTILoop
35  : public PtrTemplates<FTILoop>
36 {
37  public:
38 
39  FTILoop() = default;
41 
45  void initLoop();
46 
50  void resetLoop();
51 
55  void shutdownLoop();
56 
60  void waitForEngines();
61 
66  void runLoop(SimulationTime runLoopTime);
67 
72  inline SimulationTime getSimTime() const
73  { return this->_simTime; }
74 
75  private:
79  jsonSharedPtr _config;
80 
85 
86  using engine_queue_t = std::multimap<SimulationTime, EngineClientInterfaceSharedPtr>;
87 
91  engine_queue_t _engineQueue;
92 
96  SimulationTime _simTime = SimulationTime::zero();
97 
98  unsigned long _simIteration = 0;
99 
103  std::unique_ptr<DataPackProcessor> _devHandler;
104 
105 
107 };
108 
111 
112 #endif // FTI_LOOP_H
FTILoopConstSharedPtr
FTILoop::const_shared_ptr FTILoopConstSharedPtr
Definition: fti_loop.h:110
FTILoop::FTILoopTest_InitTFManager_Test
friend class FTILoopTest_InitTFManager_Test
Definition: fti_loop.h:106
PtrTemplates< FTILoop >::const_shared_ptr
std::shared_ptr< const FTILoop > const_shared_ptr
Definition: ptr_templates.h:32
engine_client_interface.h
FTILoop::shutdownLoop
void shutdownLoop()
Shutdown engines.
Definition: fti_loop.cpp:148
jsonSharedPtr
std::shared_ptr< nlohmann::json > jsonSharedPtr
Definition: json_schema_utils.h:35
PtrTemplates
Definition: ptr_templates.h:28
FTILoopSharedPtr
FTILoop::shared_ptr FTILoopSharedPtr
Definition: fti_loop.h:109
FTILoop::runLoop
void runLoop(SimulationTime runLoopTime)
Runs simulation for a total of runLoopTime (in s)
Definition: fti_loop.cpp:165
FTILoop::FTILoop
FTILoop()=default
SimulationDataManager
Manages all simulation data.
Definition: simulation_data_manager.h:53
json_schema_utils.h
PtrTemplates< FTILoop >::shared_ptr
std::shared_ptr< FTILoop > shared_ptr
Definition: ptr_templates.h:31
datapack_handle.h
FTILoop::getSimTime
SimulationTime getSimTime() const
Get Simulation Time (in seconds)
Definition: fti_loop.h:72
FTILoop
Manages simulation loop. Runs physics and brain interface, and synchronizes them via Transfer Functio...
Definition: fti_loop.h:34
FTILoop::resetLoop
void resetLoop()
Reset engines of the loop.
Definition: fti_loop.cpp:98
SimulationTime
std::chrono::nanoseconds SimulationTime
Definition: time_utils.h:31
FTILoop::initLoop
void initLoop()
Initialize engines before running loop.
Definition: fti_loop.cpp:74
FTILoop::waitForEngines
void waitForEngines()
Blocks until all running Engines finishe their execution.
Definition: fti_loop.cpp:259
DataPackProcessor::engine_interfaces_t
std::vector< EngineClientInterfaceSharedPtr > engine_interfaces_t
Definition: datapack_handle.h:38