|
FERS 1.0.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) | |
| Constructs the simulation engine. | |
| void | run () |
| Starts and runs the main simulation loop until completion. | |
| void | processCwPhysics (RealType t_event) |
| Advances the time-stepped inner loop for active continuous-wave (CW) 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 | handleTxCwStart (radar::Transmitter *tx) |
| Handles a continuous-wave transmitter turning on. | |
| void | handleTxCwEnd (radar::Transmitter *tx) |
| Handles a continuous-wave transmitter turning off. | |
| void | handleRxCwStart (radar::Receiver *rx) |
| Handles a continuous-wave receiver starting to record. | |
| void | handleRxCwEnd (radar::Receiver *rx) |
| Handles a continuous-wave receiver stopping recording. | |
| ComplexType | calculateCwSample (radar::Receiver *rx, RealType t_step, const std::vector< radar::Transmitter * > &cw_sources) const |
| Calculates the total complex I/Q sample for a receiver at a specific time step. | |
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 98 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 |
||
| ) |
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 44 of file sim_threading.cpp.
| ComplexType core::SimulationEngine::calculateCwSample | ( | radar::Receiver * | rx, |
| RealType | t_step, | ||
| const std::vector< radar::Transmitter * > & | cw_sources | ||
| ) | const |
Calculates the total complex I/Q sample for a receiver at a specific time step.
| rx | Pointer to the receiving radar object. |
| t_step | The exact simulation time for the sample. |
| cw_sources | A list of currently active continuous-wave transmitters. |
Definition at line 123 of file sim_threading.cpp.
References simulation::calculateDirectPathContribution(), simulation::calculateReflectedPathContribution(), radar::Receiver::checkFlag(), and core::World::getTargets().
Referenced by processCwPhysics().
Here is the call graph for this function:
Here is the caller graph for this function:| void core::SimulationEngine::handleRxCwEnd | ( | radar::Receiver * | rx | ) |
Handles a continuous-wave receiver stopping recording.
| rx | Pointer to the receiving radar object. |
Definition at line 250 of file sim_threading.cpp.
References radar::Receiver::setActive().
Referenced by processEvent().
Here is the call graph for this function:
Here is the caller graph for this function:| void core::SimulationEngine::handleRxCwStart | ( | radar::Receiver * | rx | ) |
Handles a continuous-wave receiver starting to record.
| rx | Pointer to the receiving radar object. |
Definition at line 248 of file sim_threading.cpp.
References radar::Receiver::setActive().
Referenced by processEvent().
Here is the call graph for this function:
Here is the caller graph for this function:| 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 217 of file sim_threading.cpp.
References core::SimulationState::active_cw_transmitters, radar::Receiver::drainInbox(), params::endTime(), radar::Receiver::enqueueFinalizerJob(), core::World::getEventQueue(), radar::Receiver::getNextWindowTime(), core::World::getSimulationState(), radar::Receiver::getWindowLength(), radar::Receiver::getWindowPrf(), core::RenderingJob::ideal_start_time, core::RX_PULSED_WINDOW_START, and radar::Receiver::setActive().
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 211 of file sim_threading.cpp.
References core::World::getEventQueue(), radar::Receiver::getWindowLength(), core::RX_PULSED_WINDOW_END, and radar::Receiver::setActive().
Referenced by processEvent().
Here is the call graph for this function:
Here is the caller graph for this function:| void core::SimulationEngine::handleTxCwEnd | ( | radar::Transmitter * | tx | ) |
Handles a continuous-wave transmitter turning off.
| tx | Pointer to the transmitting radar object. |
Definition at line 242 of file sim_threading.cpp.
References core::SimulationState::active_cw_transmitters, and core::World::getSimulationState().
Referenced by processEvent().
Here is the call graph for this function:
Here is the caller graph for this function:| void core::SimulationEngine::handleTxCwStart | ( | radar::Transmitter * | tx | ) |
Handles a continuous-wave transmitter turning on.
| tx | Pointer to the transmitting radar object. |
Definition at line 237 of file sim_threading.cpp.
References core::SimulationState::active_cw_transmitters, and core::World::getSimulationState().
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 187 of file sim_threading.cpp.
References simulation::calculateResponse(), params::endTime(), core::World::getEventQueue(), radar::Transmitter::getNextPulseTime(), radar::Transmitter::getPrf(), core::World::getReceivers(), radar::Transmitter::getSignal(), core::World::getTargets(), 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::processCwPhysics | ( | RealType | t_event | ) |
Advances the time-stepped inner loop for active continuous-wave (CW) systems.
| t_event | The timestamp of the next discrete event to process up to. |
Definition at line 95 of file sim_threading.cpp.
References calculateCwSample(), core::World::getReceivers(), core::World::getSimulationState(), params::oversampleRatio(), params::rate(), and params::startTime().
Referenced by run().
Here is the call graph for this function:
Here is the caller graph for this function:| void core::SimulationEngine::processEvent | ( | const Event & | event | ) |
Dispatches a discrete simulation event to its specific handler.
| event | The event to process. |
Definition at line 141 of file sim_threading.cpp.
References handleRxCwEnd(), handleRxCwStart(), handleRxPulsedWindowEnd(), handleRxPulsedWindowStart(), handleTxCwEnd(), handleTxCwStart(), handleTxPulsedStart(), core::RX_CW_END, core::RX_CW_START, core::RX_PULSED_WINDOW_END, core::RX_PULSED_WINDOW_START, core::Event::source_object, core::Event::timestamp, core::TX_CW_END, core::TX_CW_START, core::TX_PULSED_START, and core::Event::type.
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 52 of file sim_threading.cpp.
References params::endTime(), core::World::getEventQueue(), core::World::getSimulationState(), LOG, processCwPhysics(), and processEvent().
Referenced by core::runEventDrivenSim().
Here is the call graph for this function:
Here is the caller graph for this function: