22#ifndef MODELS_SUPPORT_LATENCY_UTIL_H
23#define MODELS_SUPPORT_LATENCY_UTIL_H
59 int start(
int latency = 0, T start_val = T());
71 int step(T input_value, T &output_value);
99 int step_size = std::ceil((
double)latency / ((
double)
_exc.rate().asMilliseconds()));
105 for(
int i = 0; i < step_size; i++) {
110 if (not (std::abs(std::fmod((
double)latency,
_exc.rate().asMilliseconds())) < 1e-10)) {
117 template <
typename T>
122 _exc.time().step_end_time().subtract(
_exc.time().step_start_time(), current_rate);
129 std::string error =
"LatencyUtil: Simulation rate has changed from "
132 _exc.os().sysLog(0.0,
"", error.c_str(), error.size());
154 template <
typename T>
158 for (
typename std::queue<T>::size_type i = 0; i <
_latency_queue.size(); ++i) {
Wrapper to manage and convert time as timespce.
Definition Time.h:53
floating_point asFloatingPoint() const
Definition Time.h:80
floating_point asFrequency()
Function to convert time to frequency in Hz.
Definition Time.cpp:36
bool _first_run
Tracks the first time the model is stepped.
Definition LatencyUtil.hpp:82
SimulationExecutive & _exc
Reference to the simulation executive.
Definition LatencyUtil.hpp:79
clockwerk::Time _lat_sim_rate
Simulation rate in milliseconds.
Definition LatencyUtil.hpp:80
int step(T input_value, T &output_value)
Step the latency model.
Definition LatencyUtil.hpp:118
int reset()
Function for reseting the latency queue.
Definition LatencyUtil.hpp:155
int start(int latency=0, T start_val=T())
Starting the latency model.
Definition LatencyUtil.hpp:87
LatencyUtil(SimulationExecutive &exc)
Definition LatencyUtil.hpp:47
T _default_value
Default value to fill the queue with.
Definition LatencyUtil.hpp:81
std::queue< T > _latency_queue
Buffer to hold latency values.
Definition LatencyUtil.hpp:78
Implementation of the executive class for simulation.
Definition SimulationExecutive.h:64
#define ERROR_STEP_OVERRUN
Error in the case where dynamics model overruns steps or gets out of whack.
Definition clockwerkerrors.h:153
#define ERROR_QUEUE_EMPTY
Error in case the queue is empty.
Definition clockwerkerrors.h:198
#define ERROR_INVALID_RANGE
Definition clockwerkerrors.h:53
#define ERROR_DIVIDE_BY_ZERO
Error code in the case where some fool tried to divide by zero.
Definition clockwerkerrors.h:49
#define WARNING_POORLY_MATCHED_RATES
Warning when certain a simulation and model rate don't match well and may cause issues.
Definition clockwerkerrors.h:169
Class to propagate CR3BP dynamics in characteristic units.
Definition statistics.hpp:22
int16 start() override
Class to execute logging.
const int NO_ERROR
Definition simlicense.cpp:30