5 #include <SimulationStepLoop.h>
6 #include <PulseTaskDropper.h>
7 #include <PulseThreadPoolInterface.h>
8 #include <FullWaveformPulseRunnable.h>
9 #include <SimulationCycleCallback.h>
11 #include <PySimulationCycleCallback.h>
14 #include <dataanalytics/HDA_StateJSONReporter.h>
16 #include <SimulationReporter.h>
26 friend class helios::analytics::HDA_StateJSONReporter;
87 std::shared_ptr<std::unique_lock<std::mutex>>
pauseLock =
nullptr;
151 std::shared_ptr<SimulationCycleCallback> callback =
nullptr;
166 std::shared_ptr<PulseThreadPoolInterface> pulseThreadPoolInterface,
198 void stop() {this->mStopped =
true;}
246 void setScanner(std::shared_ptr<Scanner> scanner);
Class implementing a task dropper to deal with pulse tasks.
Definition: PulseTaskDropper.h:27
Class to handle reports related to simulation.
Definition: SimulationReporter.h:13
Class extending LinearVoidStepLoop to support main simulation loop.
Definition: SimulationStepLoop.h:15
std::size_t getFrequency() const
Definition: SimulationStepLoop.h:42
void setFrequency(std::size_t const frequency)
Definition: SimulationStepLoop.h:46
Class representing a simulation.
Definition: Simulation.h:23
double currentGpsTime_ns
Time corresponding to simulation start (currentGpsTime in nanoseconds)
Definition: Simulation.h:109
void setSimSpeedFactor(double factor)
Set the simulation speed factor.
Definition: Simulation.cpp:236
size_t getCallbackFrequency() const
Get the callback frequency. It is, how many steps must elapse between consecutive callbacks.
Definition: Simulation.h:287
std::mutex mutex
Mutex to handle simulation pause and iterations on a multi threading context.
Definition: Simulation.h:76
void shutdown()
Handle simulation shutdown.
Definition: Simulation.cpp:104
void setSimFrequency(size_t const simFrequency)
Set simulation frequency.
Definition: Simulation.h:278
virtual void prepareSimulation(int simFrequency_hz)
Prepare the simulation before starting its main loop.
Definition: Simulation.cpp:48
std::shared_ptr< Scanner > mScanner
Scanner used by the simulation.
Definition: Simulation.h:58
PulseTaskDropper taskDropper
Pulse task dropper.
Definition: Simulation.h:47
std::shared_ptr< PulseThreadPoolInterface > threadPool
Pulse thread pool.
Definition: Simulation.h:42
int parallelizationStrategy
Specify the parallelization strategy.
Definition: Simulation.h:35
virtual void doSimStep()
Perform computations for current simulation step.
Definition: Simulation.cpp:70
unsigned int mCurrentLegIndex
Index of leg at current simulation stage.
Definition: Simulation.h:134
bool mStopped
Flag specifying if the simulation has been stopped (true) or not (false)
Definition: Simulation.h:93
bool mPaused
Flag specifying if the simulation has been paused (true) or not (false)
Definition: Simulation.h:98
size_t callbackFrequency
The callback frequency. It specifies how many steps must elapse between consecutive callbacks.
Definition: Simulation.h:70
double mSimSpeedFactor
Simulation speed factor.
Definition: Simulation.h:52
bool isPaused() const
Check if simulation is paused (true) or not (false)
Definition: Simulation.h:260
SimulationStepLoop stepLoop
The handler for simulation steps, it also contains the discrete time object that hanldes simulation f...
Definition: Simulation.h:64
virtual void onLegComplete()=0
Handle leg completion.
bool exportToFile
Flag specifying if simulation output must be exported to a file (true) or not (false)
Definition: Simulation.h:140
size_t getSimFrequency() const
Obtain simulation frequency.
Definition: Simulation.h:272
bool exitAtEnd
Flag specifying if simulation must end when current leg has been completed (true) or not (false)
Definition: Simulation.h:145
bool isStopped() const
Check if simulation is stopped (true) or not (false)
Definition: Simulation.h:266
void setCallbackFrequency(size_t const callbackFrequency)
Set the new callback frequency.
Definition: Simulation.h:295
std::chrono::nanoseconds timeStart_ns
Time corresponding to simulation start (nanoseconds)
Definition: Simulation.h:103
SimulationStepLoop & getStepLoop()
Get the simulation step loop of the simulation.
Definition: Simulation.h:303
std::shared_ptr< std::unique_lock< std::mutex > > pauseLock
Shared pointer to the lock used to handle the mutex for simulation pause purposes.
Definition: Simulation.h:87
double stepGpsTime_ns
The time step for GPS time (in nanoseconds)
Definition: Simulation.h:114
std::shared_ptr< Scanner > getScanner()
Obtain simulation scanner.
Definition: Simulation.h:252
std::condition_variable condvar
Condition variable tu handle simulation iterations on a multi threading context.
Definition: Simulation.h:81
std::string fixedGpsTimeStart
Given fixed time start for GPS time as a string.
Definition: Simulation.h:123
SimulationReporter reporter
The report to generate reports about simulation.
Definition: Simulation.h:128
double getSimSpeedFactor() const
Obtain simulation speed factor.
Definition: Simulation.h:239
void start()
Start the simmulation.
Definition: Simulation.cpp:118
void setScanner(std::shared_ptr< Scanner > scanner)
Set scanner for the simulation.
Definition: Simulation.cpp:252
bool finished
Flag specifying if simulation has finished (true) or not (false)
Definition: Simulation.h:149
void pause(bool pause)
Pause or unpause the simulation.
Definition: Simulation.cpp:90
Simulation(int const parallelizationStrategy, std::shared_ptr< PulseThreadPoolInterface > pulseThreadPoolInterface, int const chunkSize, std::string fixedGpsTimeStart="")
Simulation constructor.
Definition: Simulation.cpp:28
void stop()
Stop the simulation.
Definition: Simulation.h:198
double calcCurrentGpsTime()
Compute the current GPS time (nanoseconds)
Definition: Simulation.cpp:196