NRP Core  1.4.1
simulation_manager_event_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 SIMULATION_MANAGER_EVENT_LOOP_H
23 #define SIMULATION_MANAGER_EVENT_LOOP_H
24 
30 
35  : public SimulationManager
36 {
37  public:
38 
45  EventLoopSimManager(const jsonSharedPtr &simulationConfig, const EngineLauncherManagerConstSharedPtr &engineLauncherManager,
46  const MainProcessLauncherManager::const_shared_ptr &processLauncherManager);
47 
48 
49  ~EventLoopSimManager() = default;
50 
51  bool hasSimulationTimedOut() const override
52  {
53  // TODO Not sure how to implement this...
54  return false;
55  }
56 
57  private:
58 
59  // Callback functions for the different simulation control requests.
60  void initializeCB() override;
61  bool resetCB() override;
62  void stopCB() override;
63  bool runUntilDoneOrTimeoutCB() override;
64  bool runCB(unsigned numIterations) override;
65  void shutdownCB() override;
66 
67  bool runUntilMilliseconds(const std::chrono::milliseconds& eTout);
68 
70  std::shared_ptr<FTILoopSimManager> _fTILoopSimManager;
72  EngineLauncherManagerConstSharedPtr _engineLauncherManager;
74  MainProcessLauncherManager::const_shared_ptr _processLauncherManager;
75 
77  std::shared_ptr<EventLoop> _loop;
78  std::chrono::milliseconds _timeout;
79  std::chrono::milliseconds _timestep;
80 };
81 
82 #endif
EventLoopSimManager
Implementation of SimulationManager which manages an EventLoop.
Definition: simulation_manager_event_loop.h:34
SimulationManager
Manages simulation execution.
Definition: simulation_manager.h:47
EngineLauncherManagerConstSharedPtr
EngineLauncherManager::const_shared_ptr EngineLauncherManagerConstSharedPtr
Definition: engine_launcher_manager.h:59
event_loop.h
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
simulation_manager_fti.h
EventLoopSimManager::EventLoopSimManager
EventLoopSimManager(const jsonSharedPtr &simulationConfig, const EngineLauncherManagerConstSharedPtr &engineLauncherManager, const MainProcessLauncherManager::const_shared_ptr &processLauncherManager)
Constructor.
Definition: simulation_manager_event_loop.cpp:37
EventLoopSimManager::hasSimulationTimedOut
bool hasSimulationTimedOut() const override
Definition: simulation_manager_event_loop.h:51
EventLoopSimManager::~EventLoopSimManager
~EventLoopSimManager()=default
simulation_manager.h