SyDEVS  v0.6.7
Multiscale Simulation and Systems Modeling Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sydevs::systems::real_time_simulation< Node > Class Template Reference

A class template for running simulations in real time. More...

#include <real_time_simulation.h>

Inherits sydevs::systems::simulation< Node >.

Public Member Functions

 real_time_simulation (const time_point &start_t, const time_point &end_t, bool can_end_early, int64 seed, std::ostream &stream)
 Constructs a real_time_simulation with the full set of configuration options. More...
 
 real_time_simulation (duration total_dt, int64 seed, std::ostream &stream)
 Constructs a real_time_simulation with a reduced set of configuration options. More...
 
virtual ~real_time_simulation ()=default
 Destructor. More...
 
Node::injection_type & injection ()
 Returns a reference to the injection object that supports communication into the interactive system node. More...
 
const Node::observation_type & observation ()
 Returns a reference to the observation object that supports communication from the interactive system node. More...
 
float64 time_advancement_rate () const
 Returns the time advancement rate. More...
 
float64 time_synchronization_rate () const
 Returns the time synchronization rate. More...
 
void update_time_advancement_rate (float64 t_adv_rate)
 Updates the time advancement rate. More...
 
void update_time_synchronization_rate (float64 t_syn_rate)
 Updates the time synchonization rate. More...
 
time_point synchronization_time () const
 Returns the simulated time of the synchronization reference point. More...
 
clock_time synchronization_clock_time () const
 Returns the wallclock time of the synchronization reference point. More...
 
void update_synchronization_time (const time_point &sim_t, const clock_time &clk_t)
 Updates the synchonization reference point. More...
 
int64 frame_index () const
 Returns the index of the most recently processed frame of the simulation. More...
 
time_point frame_time () const
 Returns the simulated time point of the most recently processed frame of the simulation. More...
 
clock_time frame_clock_time () const
 Returns the wallclock time point of the most recently processed frame of the simulation. More...
 
int64 process_frame_if_time_reached ()
 If a sufficent amount of wallclock time has elapsed, processes all events until the frame index has advanced. More...
 
- Public Member Functions inherited from sydevs::systems::simulation< Node >
 simulation (const time_point &start_t, const time_point &end_t, bool can_end_early, int64 seed, std::ostream &stream)
 Constructs a simulation with the full set of configuration options. More...
 
 simulation (duration total_dt, int64 seed, std::ostream &stream)
 Constructs a simulation with a reduced set of configuration options. More...
 
 simulation (const simulation &)=delete
 No copy constructor. More...
 
simulationoperator= (const simulation &)=delete
 No copy assignment. More...
 
 simulation (simulation &&)=delete
 No move constructor. More...
 
simulationoperator= (simulation &&)=delete
 No move assignment. More...
 
virtual ~simulation ()=default
 Destructor. More...
 
const time_pointstart_time () const
 Returns the start time of the simulation. More...
 
const time_pointend_time () const
 Returns the end time of the simulation. More...
 
bool can_end_early () const
 Returns true if the simulation can end before the specified end time. More...
 
bool started () const
 Returns true if the simulation has started. More...
 
bool finishing () const
 Returns true if all events are finished except finalization. More...
 
bool finished () const
 Returns true if the simulation has finished. More...
 
const discrete_event_timetime () const
 Returns the current point in discrete event time. More...
 
duration imminent_duration () const
 Returns the duration until the imminent event. More...
 
void process_next_event ()
 Runs the next event of the topmost system node. More...
 
int64 process_next_events ()
 Runs all events until simulated time advances; returns the number of processed events. More...
 
int64 process_events_until (const time_point &t)
 Runs all events until simulated time advances at least to t; returns the number of processed events. More...
 
int64 process_remaining_events ()
 Runs simulation until completion; returns the number of processed events. More...
 
const timerevent_timer () const
 Returns the object that accumulated wallclock event durations. More...
 

Additional Inherited Members

- Public Attributes inherited from sydevs::systems::simulation< Node >
Node top
 The topmost system node. More...
 

Detailed Description

template<typename Node>
class sydevs::systems::real_time_simulation< Node >

A class template for running simulations in real time.

The real_time_simulation class template represents a simulation run in real time based on an interactive_system class specified as a template parameter. Member functions allow the represented simulation to be performed one frame at a time, where each frame includes however many events need to be processed to advance the macro level of the interactive_system instance by its planned duration.

A real time simulation is performed by repeatedly calling the process_frame_if_time_reached member function. If the resulting event count is zero, nothing happened because not enough wallclock time is deemed to have passed. If the resulting event count is greater than zero, then the simulation has advanced by one frame. It may then be time to observe data from the simulation using the observation member function, or inject data into the simulation using the injection member function.

Constructor & Destructor Documentation

template<typename Node >
sydevs::systems::real_time_simulation< Node >::real_time_simulation ( const time_point start_t,
const time_point end_t,
bool  can_end_early,
int64  seed,
std::ostream &  stream 
)
inline

Constructs a real_time_simulation with the full set of configuration options.

Parameters
start_tThe starting point in simulated time.
end_tThe end point in simulated time; only finalization events can occur at this time.
can_end_earlyFlag indicating that the simulation will end before the specified end time if all events are exhausted.
seedThe integer used to seed the random number generator.
streamThe output steam onto which printed results are directed.
Template Parameters
NodeThe port-free interactive_system node on which the simulation is based.
template<typename Node >
sydevs::systems::real_time_simulation< Node >::real_time_simulation ( duration  total_dt,
int64  seed,
std::ostream &  stream 
)
inline

Constructs a real_time_simulation with a reduced set of configuration options.

Parameters
total_dtThe duration of the simulation in simulated time; the simulation starts at time zero and does not end early.
seedThe integer used to seed the random number generator.
streamThe output steam onto which printed results are directed.
Template Parameters
NodeThe port-free interactive_system node on which the simulation is based.
template<typename Node >
virtual sydevs::systems::real_time_simulation< Node >::~real_time_simulation ( )
virtualdefault

Destructor.

Member Function Documentation

template<typename Node >
clock_time sydevs::systems::real_time_simulation< Node >::frame_clock_time ( ) const

Returns the wallclock time point of the most recently processed frame of the simulation.

template<typename Node >
int64 sydevs::systems::real_time_simulation< Node >::frame_index ( ) const
inline

Returns the index of the most recently processed frame of the simulation.

template<typename Node >
time_point sydevs::systems::real_time_simulation< Node >::frame_time ( ) const

Returns the simulated time point of the most recently processed frame of the simulation.

template<typename Node >
Node::injection_type & sydevs::systems::real_time_simulation< Node >::injection ( )
inline

Returns a reference to the injection object that supports communication into the interactive system node.

template<typename Node >
const Node::observation_type & sydevs::systems::real_time_simulation< Node >::observation ( )
inline

Returns a reference to the observation object that supports communication from the interactive system node.

template<typename Node >
int64 sydevs::systems::real_time_simulation< Node >::process_frame_if_time_reached ( )
inline

If a sufficent amount of wallclock time has elapsed, processes all events until the frame index has advanced.

template<typename Node >
clock_time sydevs::systems::real_time_simulation< Node >::synchronization_clock_time ( ) const
inline

Returns the wallclock time of the synchronization reference point.

template<typename Node >
time_point sydevs::systems::real_time_simulation< Node >::synchronization_time ( ) const
inline

Returns the simulated time of the synchronization reference point.

template<typename Node >
float64 sydevs::systems::real_time_simulation< Node >::time_advancement_rate ( ) const
inline

Returns the time advancement rate.

template<typename Node >
float64 sydevs::systems::real_time_simulation< Node >::time_synchronization_rate ( ) const
inline

Returns the time synchronization rate.

template<typename Node >
void sydevs::systems::real_time_simulation< Node >::update_synchronization_time ( const time_point sim_t,
const clock_time clk_t 
)
inline

Updates the synchonization reference point.

template<typename Node >
void sydevs::systems::real_time_simulation< Node >::update_time_advancement_rate ( float64  t_adv_rate)
inline

Updates the time advancement rate.

template<typename Node >
void sydevs::systems::real_time_simulation< Node >::update_time_synchronization_rate ( float64  t_syn_rate)
inline

Updates the time synchonization rate.


The documentation for this class was generated from the following file: