|
FERS 0.1.0
The Flexible Extensible Radar Simulator
|
Encapsulates the state and logic of the event-driven simulation loop. More...
#include "sim_threading.h"
Public Member Functions | |
| SimulationEngine (World *world, pool::ThreadPool &pool, std::shared_ptr< ProgressReporter > reporter, std::string output_dir, std::shared_ptr< OutputMetadataCollector > metadata_collector=nullptr, ReceiverOutputSink *output_sink=nullptr, std::function< bool()> cancel_callback=nullptr, bool eager_context_stream_open=false) | |
| Constructs the simulation engine. | |
| void | run () |
| Starts and runs the main simulation loop until completion. | |
| bool | cancelled () const noexcept |
| Returns true after cooperative cancellation has been requested. | |
| void | processStreamingPhysics (RealType t_event) |
| Advances the time-stepped inner loop for active streaming systems. | |
| void | processEvent (const Event &event) |
| Dispatches a discrete simulation event to its specific handler. | |
| void | handleTxPulsedStart (radar::Transmitter *tx, RealType t_event) |
| Handles the start of a pulsed transmission. | |
| void | handleRxPulsedWindowStart (radar::Receiver *rx, RealType t_event) |
| Handles the opening of a pulsed receiver's listening window. | |
| void | handleRxPulsedWindowEnd (radar::Receiver *rx, RealType t_event) |
| Handles the closing of a pulsed receiver's listening window, triggering finalization. | |
| void | handleTxStreamingStart (const ActiveStreamingSource &source) |
| Handles a streaming transmitter turning on. | |
| void | handleTxStreamingEnd (radar::Transmitter *tx) |
| Handles a streaming transmitter turning off. | |
| void | handleRxStreamingStart (radar::Receiver *rx) |
| Handles a streaming receiver starting to record. | |
| void | handleRxStreamingEnd (radar::Receiver *rx) |
| Handles a streaming receiver stopping recording. | |
Encapsulates the state and logic of the event-driven simulation loop.
Breaking the simulation loop into this class allows for easily testable, focused functions with low cyclomatic complexity.
Definition at line 109 of file sim_threading.h.
| core::SimulationEngine::SimulationEngine | ( | World * | world, |
| pool::ThreadPool & | pool, | ||
| std::shared_ptr< ProgressReporter > | reporter, | ||
| std::string | output_dir, | ||
| std::shared_ptr< OutputMetadataCollector > | metadata_collector = nullptr, |
||
| ReceiverOutputSink * | output_sink = nullptr, |
||
| std::function< bool()> | cancel_callback = nullptr, |
||
| bool | eager_context_stream_open = false |
||
| ) |
Constructs the simulation engine.
| world | Pointer to the simulation world containing all entities. |
| pool | Reference to the thread pool for asynchronous tasks. |
| reporter | Shared pointer to the thread-safe progress reporter. |
| output_dir | Output directory for the simulation files. |
Definition at line 754 of file sim_threading.cpp.
References core::World::getReceivers(), max, and params::startTime().
Here is the call graph for this function:
|
noexcept |
Returns true after cooperative cancellation has been requested.
Definition at line 130 of file sim_threading.h.
| void core::SimulationEngine::handleRxPulsedWindowEnd | ( | radar::Receiver * | rx, |
| RealType | t_event | ||
| ) |
Handles the closing of a pulsed receiver's listening window, triggering finalization.
| rx | Pointer to the receiving radar object. |
| t_event | The timestamp of the window closing event. |
Definition at line 1796 of file sim_threading.cpp.
References params::endTime(), core::World::getEventQueue(), max, and core::RX_PULSED_WINDOW_START.
Referenced by processEvent().
Here is the call graph for this function:
Here is the caller graph for this function:| void core::SimulationEngine::handleRxPulsedWindowStart | ( | radar::Receiver * | rx, |
| RealType | t_event | ||
| ) |
Handles the opening of a pulsed receiver's listening window.
| rx | Pointer to the receiving radar object. |
| t_event | The timestamp of the window opening event. |
Definition at line 1790 of file sim_threading.cpp.
References core::World::getEventQueue(), max, and core::RX_PULSED_WINDOW_END.
Referenced by processEvent().
Here is the call graph for this function:
Here is the caller graph for this function:| void core::SimulationEngine::handleRxStreamingEnd | ( | radar::Receiver * | rx | ) |
Handles a streaming receiver stopping recording.
| rx | Pointer to the receiving radar object. |
Definition at line 1852 of file sim_threading.cpp.
References core::ReceiverOutputSink::closeStream(), params::endTime(), core::World::getReceivers(), core::World::getSimulationState(), max, and core::SimulationState::t_current.
Referenced by processEvent().
Here is the call graph for this function:
Here is the caller graph for this function:| void core::SimulationEngine::handleRxStreamingStart | ( | radar::Receiver * | rx | ) |
Handles a streaming receiver starting to record.
| rx | Pointer to the receiving radar object. |
Definition at line 1831 of file sim_threading.cpp.
References core::World::getReceivers(), core::World::getSimulationState(), max, and core::SimulationState::t_current.
Referenced by processEvent().
Here is the call graph for this function:
Here is the caller graph for this function:| void core::SimulationEngine::handleTxPulsedStart | ( | radar::Transmitter * | tx, |
| RealType | t_event | ||
| ) |
Handles the start of a pulsed transmission.
| tx | Pointer to the transmitting radar object. |
| t_event | The timestamp of the transmission event. |
Definition at line 1766 of file sim_threading.cpp.
References simulation::calculateResponse(), params::endTime(), core::World::getEventQueue(), core::World::getReceivers(), core::World::getTargets(), max, and core::TX_PULSED_START.
Referenced by processEvent().
Here is the call graph for this function:
Here is the caller graph for this function:| void core::SimulationEngine::handleTxStreamingEnd | ( | radar::Transmitter * | tx | ) |
Handles a streaming transmitter turning off.
| tx | Pointer to the transmitting radar object. |
Definition at line 1823 of file sim_threading.cpp.
References core::World::getSimulationState(), max, and core::SimulationState::t_current.
Referenced by processEvent().
Here is the call graph for this function:
Here is the caller graph for this function:| void core::SimulationEngine::handleTxStreamingStart | ( | const ActiveStreamingSource & | source | ) |
Handles a streaming transmitter turning on.
| tx | Pointer to the transmitting radar object. |
Definition at line 1817 of file sim_threading.cpp.
References core::SimulationState::active_streaming_transmitters, and core::World::getSimulationState().
Referenced by processEvent().
Here is the call graph for this function:
Here is the caller graph for this function:Dispatches a discrete simulation event to its specific handler.
| event | The event to process. |
Definition at line 1715 of file sim_threading.cpp.
References handleRxPulsedWindowEnd(), handleRxPulsedWindowStart(), handleRxStreamingEnd(), handleRxStreamingStart(), handleTxPulsedStart(), handleTxStreamingEnd(), handleTxStreamingStart(), max, core::RX_PULSED_WINDOW_END, core::RX_PULSED_WINDOW_START, core::RX_STREAMING_END, core::RX_STREAMING_START, core::Event::source_object, core::Event::timestamp, core::TX_PULSED_START, core::TX_STREAMING_END, core::TX_STREAMING_START, and core::Event::type.
Referenced by run().
Here is the call graph for this function:
Here is the caller graph for this function:Advances the time-stepped inner loop for active streaming systems.
| t_event | The timestamp of the next discrete event to process up to. |
Definition at line 998 of file sim_threading.cpp.
References core::World::getSimulationState(), max, params::oversampleRatio(), and params::rate().
Referenced by run().
Here is the call graph for this function:
Here is the caller graph for this function:| void core::SimulationEngine::run | ( | ) |
Starts and runs the main simulation loop until completion.
Definition at line 790 of file sim_threading.cpp.
References core::World::getEventQueue(), core::World::getReceivers(), core::World::getSimulationState(), LOG, core::logSimulationMemoryProjection(), max, processEvent(), processStreamingPhysics(), and receiver.
Here is the call graph for this function: