Delay template class, implementing a circular buffer containing values of specified type.
More...
|
void | initialize (const double timeDelay, const double Ts, const T initValue) |
| Initialize delay buffer size based on timeDelay and timestep, Td/Ts must be multiple of 1 and >= 1. More...
|
|
void | initialize (const int delaySteps, const T initValue) |
| Initialize delay size based on known number of delay steps. More...
|
|
T | update (const T newValue) |
| Updates delay with a new value, "pop old", "push new". You should likely run this at the end of each time step. More...
|
|
T | getOldest () const |
| Get the oldest value in the buffer. More...
|
|
T | getNewest () const |
| Get the newest value in the buffer. More...
|
|
T | getIdx (const size_t i) const |
| Returns a specific value, 0=newest, 1=nextnewest, 2=nextnextnewest and so on, no range check is performed. More...
|
|
T | getOldIdx (const size_t i) const |
| Returns a specific value, 0=oldest, 1=nextoldest, 2=nextnextoldest and so on, no range check is performed. More...
|
|
size_t | getSize () const |
| Get the size of the delay buffer (the number of buffer elements) More...
|
|
void | clear () |
| Clear the delay buffer, deleting all data.
|
|
template<typename T>
class hopsan::DelayTemplate< T >
Delay template class, implementing a circular buffer containing values of specified type.
◆ getIdx()
T getIdx |
( |
const size_t |
i | ) |
const |
|
inline |
Returns a specific value, 0=newest, 1=nextnewest, 2=nextnextnewest and so on, no range check is performed.
- Parameters
-
[in] | i | Index of value to return |
- Returns
- Value at specified index
◆ getNewest()
Get the newest value in the buffer.
- Returns
- The newest value in the buffer
◆ getOldest()
Get the oldest value in the buffer.
- Returns
- The oldest value in the buffer
◆ getOldIdx()
T getOldIdx |
( |
const size_t |
i | ) |
const |
|
inline |
Returns a specific value, 0=oldest, 1=nextoldest, 2=nextnextoldest and so on, no range check is performed.
- Parameters
-
[in] | i | Index of value to return |
- Returns
- Value at specified index
◆ getSize()
Get the size of the delay buffer (the number of buffer elements)
- Returns
- The size of the delay buffer
◆ initialize() [1/2]
void initialize |
( |
const double |
timeDelay, |
|
|
const double |
Ts, |
|
|
const T |
initValue |
|
) |
| |
|
inline |
Initialize delay buffer size based on timeDelay and timestep, Td/Ts must be multiple of 1 and >= 1.
- Parameters
-
[in] | timeDelay | The total time delay for a value to come out on the other side of the circle buffer |
[in] | Ts | The timestep between each call |
[in] | initValue | The initial value of all buffer elements |
◆ initialize() [2/2]
void initialize |
( |
const int |
delaySteps, |
|
|
const T |
initValue |
|
) |
| |
|
inline |
Initialize delay size based on known number of delay steps.
- Parameters
-
[in] | delaySteps | The number of delay steps, must be >= 1 |
[in] | initValue | The initial value of all buffer elements |
◆ update()
T update |
( |
const T |
newValue | ) |
|
|
inline |
Updates delay with a new value, "pop old", "push new". You should likely run this at the end of each time step.
- Parameters
-
[in] | newValue | The new value to insert into delay buffer |
- Returns
- The oldest value in the delay buffer (After update, this value has been overwritten in the buffer)