63 using Callback = std::function<void(
const std::string&,
int,
int)>;
77 void report(
const std::string& msg,
int current,
int total)
81 std::scoped_lock lock(_mutex);
82 _callback(msg, current, total);
109 std::string output_dir, std::shared_ptr<OutputMetadataCollector> metadata_collector =
nullptr);
181 const std::vector<radar::Transmitter*>& cw_sources)
const;
187 void initializeFinalizers();
194 void routeResponse(
radar::Receiver* rx, std::unique_ptr<serial::Response> response)
const;
199 void updateProgress();
208 std::shared_ptr<ProgressReporter> _reporter;
209 std::vector<std::jthread> _finalizer_threads;
210 std::shared_ptr<OutputMetadataCollector> _metadata_collector;
212 std::chrono::steady_clock::time_point _last_report_time;
213 int _last_reported_percent = -1;
215 std::string _output_dir;
232 const std::function<
void(
const std::string&,
int,
int)>& progress_callback,
233 const std::string& output_dir);
A thread-safe wrapper for the simulation progress callback.
ProgressReporter(Callback cb)
Constructs a ProgressReporter with the given callback.
std::function< void(const std::string &, int, int)> Callback
Defines the signature for the progress reporting callback function.
void report(const std::string &msg, int current, int total)
Safely reports progress to the underlying callback.
Encapsulates the state and logic of the event-driven simulation loop.
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.
void handleRxCwStart(radar::Receiver *rx)
Handles a continuous-wave receiver starting to record.
void handleRxPulsedWindowEnd(radar::Receiver *rx, RealType t_event)
Handles the closing of a pulsed receiver's listening window, triggering finalization.
void handleTxCwEnd(radar::Transmitter *tx)
Handles a continuous-wave transmitter turning off.
void handleTxCwStart(radar::Transmitter *tx)
Handles a continuous-wave transmitter turning on.
void handleRxPulsedWindowStart(radar::Receiver *rx, RealType t_event)
Handles the opening of a pulsed receiver's listening window.
void run()
Starts and runs the main simulation loop until completion.
void processEvent(const Event &event)
Dispatches a discrete simulation event to its specific handler.
void processCwPhysics(RealType t_event)
Advances the time-stepped inner loop for active continuous-wave (CW) systems.
void handleRxCwEnd(radar::Receiver *rx)
Handles a continuous-wave receiver stopping recording.
void handleTxPulsedStart(radar::Transmitter *tx, RealType t_event)
Handles the start of a pulsed transmission.
The World class manages the simulator environment.
A simple thread pool implementation.
Manages radar signal reception and response processing.
Represents a radar transmitter system.
Global configuration file for the project.
double RealType
Type for real numbers.
std::complex< RealType > ComplexType
Type for complex numbers.
OutputMetadata runEventDrivenSim(World *world, pool::ThreadPool &pool, const std::function< void(const std::string &, int, int)> &progress_callback, const std::string &output_dir)
Runs the unified, event-driven radar simulation.
Defines the core structures for the event-driven simulation engine.
Represents a single event in the simulation's time-ordered queue.