Simulation Time¶
|
API
|
Classes | |
| class | SimTime |
| int64_t-based, base-10 fixed-point simulation time. More... | |
Macros | |
| #define | SIMTIME_MAX omnetpp::SimTime::getMaxTime() |
| The maximum representable simulation time with the current resolution. | |
| #define | SIMTIME_ZERO omnetpp::SimTime::ZERO |
| Zero simulation time. | |
| #define | SIMTIME_STR(t) |
| Convert simtime_t to a C string. | |
| #define | SIMTIME_DBL(t) |
| Convert simtime_t to a double. This conversion incurs precision loss. | |
Typedefs | |
| typedef SimTime | simtime_t |
| Represents simulation time. | |
| typedef const simtime_t & | simtime_t_cref |
| Constant reference to a simtime_t. | |
| typedef const double | const_simtime_t |
| This type must be used for global variables representing simulation time. | |
Enumerations | |
| enum | SimTimeUnit |
| Enum for simulation time base-10 exponents. More... | |
Functions | |
| simtime_t | simTime () |
| Returns the current simulation time. | |
| const SimTime | floor (const SimTime &x) |
| simtime_t version of floor(double) from math.h. | |
| const SimTime | floor (const SimTime &x, const SimTime &unit, const SimTime &offset=SimTime()) |
| Generalized version of floor(), accepting a unit and an offset: floor(x,u,off) = floor((x-off)/u)*u + off. | |
| const SimTime | ceil (const SimTime &x) |
| simtime_t version of ceil(double) from math.h. | |
| const SimTime | ceil (const SimTime &x, const SimTime &unit, const SimTime &offset=SimTime()) |
| Generalized version of ceil(), accepting a unit and an offset: ceil(x,u,off) = ceil((x-off)/u)*u + off. | |
| const SimTime | fabs (const SimTime &x) |
| Returns the absolute value of the simulation time x. | |
| int64_t | div (const SimTime &x, const SimTime &y) |
| Computes the quotient of the simulation times x and y. The quotient is the algebraic quotient with any fractional part discarded (truncated towards zero). The function internally relies on the standard C/C++ integer division (/) operation. | |
| const SimTime | fmod (const SimTime &x, const SimTime &y) |
| Computes the remainder of the division of two simulation times. | |
| SIM_API int64_t | preciseDiv (int64_t x, const SimTime &y, int64_t &fractionNumerator, int64_t &fractionDenominator) |
| Precise division of an integer and a simulation time. | |
Description
The simulation kernel and models use simtime_t to represent simulation time. simtime_t is an alias to the SimTime class that is 64-bit fixed-point representation with a globally shared exponent. This group describes simtime_t, SimTime, and related types and macros.
Macro Definition Documentation
◆ SIMTIME_MAX
| #define SIMTIME_MAX omnetpp::SimTime::getMaxTime() |
The maximum representable simulation time with the current resolution.
◆ SIMTIME_ZERO
| #define SIMTIME_ZERO omnetpp::SimTime::ZERO |
Zero simulation time.
Using SIMTIME_ZERO can be more efficient than using the 0 constant, especially in non-optimized (debug) builds, because it spares the SimTime constructor call.
Referenced by cIdealChannel::calculateDuration(), SendOptions::finishTx(), cDelayChannel::getTransmissionFinishTime(), and cIdealChannel::getTransmissionFinishTime().
◆ SIMTIME_STR
| #define SIMTIME_STR | ( | t | ) |
Convert simtime_t to a C string.
◆ SIMTIME_DBL
| #define SIMTIME_DBL | ( | t | ) |
Convert simtime_t to a double. This conversion incurs precision loss.
Typedef Documentation
◆ simtime_t
◆ simtime_t_cref
| typedef const simtime_t& simtime_t_cref |
◆ const_simtime_t
| typedef const double const_simtime_t |
This type must be used for global variables representing simulation time.
The normal simtime_t type (i.e. SimTime) cannot be used for static variables, because the scale exponent is only available after the configuration has been read by the simulation program. This type is simply an alias of double.
Enumeration Type Documentation
◆ SimTimeUnit
| enum SimTimeUnit |
Enum for simulation time base-10 exponents.
Function Documentation
◆ simTime()
|
inline |
Returns the current simulation time.
References cSimulation::getActiveSimulation(), and cSimulation::getSimTime().
◆ floor() [1/2]
simtime_t version of floor(double) from math.h.
References SimTime::getScale(), SimTime::raw(), and SimTime::setRaw().
◆ floor() [2/2]
|
inline |
Generalized version of floor(), accepting a unit and an offset: floor(x,u,off) = floor((x-off)/u)*u + off.
Examples: floor(2.1234, 0.1) = 2.1; floor(2.1234, 0.1, 0.007) = 2.107; floor(2.1006, 0.1, 0.007) = 2.007.
References SimTime::raw(), and SimTime::setRaw().
◆ ceil() [1/2]
simtime_t version of ceil(double) from math.h.
References SimTime::getScale(), SimTime::raw(), and SimTime::setRaw().
◆ ceil() [2/2]
|
inline |
Generalized version of ceil(), accepting a unit and an offset: ceil(x,u,off) = ceil((x-off)/u)*u + off.
References SimTime::raw(), and SimTime::setRaw().
◆ fabs()
Returns the absolute value of the simulation time x.
References SimTime::raw().
◆ div()
Computes the quotient of the simulation times x and y. The quotient is the algebraic quotient with any fractional part discarded (truncated towards zero). The function internally relies on the standard C/C++ integer division (/) operation.
The handling of division by zero (i.e. when y==0) is platform dependent; on most platforms it causes a runtime error of some sort.
- See also
- fmod()
References SimTime::raw().
◆ fmod()
Computes the remainder of the division of two simulation times.
The function internally relies on the standard C/C++ integer modulo (%) operation. This has implications regarding the sign of the result: If both operands are nonnegative then the remainder is nonnegative; if not, the sign of the remainder is implementation-defined. However, the following is always true (substitute div() for / and fmod() for %): (x/y) * y + xy == x
The handling of division by zero (i.e. when y==0) is platform dependent; on most platforms it causes a runtime error of some sort.
- See also
- div()
References SimTime::raw(), and SimTime::setRaw().
◆ preciseDiv()
| SIM_API int64_t preciseDiv | ( | int64_t | x, |
| const SimTime & | y, | ||
| int64_t & | fractionNumerator, | ||
| int64_t & | fractionDenominator ) |
Precise division of an integer and a simulation time.
The result is returned as an integer part (in the return value) and a fraction (in the fractionNumerator, fractionDenominator output parameters).
- See also
- div()
Generated on for API by