|
INET Framework for OMNeT++/OMNEST
|
#include <OscillatorBasedClock.h>
◆ ~OscillatorBasedClock()
| inet::OscillatorBasedClock::~OscillatorBasedClock |
( |
| ) |
|
|
virtual |
41 event->setClock(
nullptr);
◆ cancelClockEvent()
◆ computeClockTimeFromSimTime()
| clocktime_t inet::OscillatorBasedClock::computeClockTimeFromSimTime |
( |
simtime_t |
time | ) |
const |
|
overridevirtual |
Returns the clock time for the specified future simulation time according to the current state of the clock.
This method implements a monotonic function with respect to the simulation time argument. It's allowed to return a different value for the same argument value if the clock is set between calls. The time argument must be greater than or equal to the current simulation time, otherwise an error is raised. See SIMTIME_AS_CLOCKTIME macro for simple type conversion.
Implements inet::IClock.
76 ASSERT(t >= simTime());
◆ computeSimTimeFromClockTime()
| simtime_t inet::OscillatorBasedClock::computeSimTimeFromClockTime |
( |
clocktime_t |
time | ) |
const |
|
overridevirtual |
Returns the simulation time (first moment) for the specified future clock time according to the current state of the clock.
This method implements a monotonic function with respect to the clock time argument. It's allowed to return a different value for the same argument value if the clock is set between calls. The time argument must be greater or than equal to the current clock time, otherwise an error is raised. See CLOCKTIME_AS_SIMTIME macro for simple type conversion.
Implements inet::IClock.
Referenced by receiveSignal(), and inet::SettableClock::setClockTime().
◆ handleClockEvent()
| void inet::OscillatorBasedClock::handleClockEvent |
( |
ClockEvent * |
event | ) |
|
|
overridevirtual |
Called by the clock event to be executed in the context of this clock.
This method is primarily useful for clock implementations to update their internal data structures related to individual clock events.
Reimplemented from inet::ClockBase.
◆ initialize()
| void inet::OscillatorBasedClock::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::ClockBase.
Reimplemented in inet::SettableClock.
48 auto oscillatorModule = getSubmodule(
"oscillator");
49 oscillator = check_and_cast<IOscillator *>(oscillatorModule);
52 const char *roundingMode = par(
"roundingMode");
53 if (!strcmp(roundingMode,
"up"))
55 else if (!strcmp(roundingMode,
"down"))
57 else if (!strcmp(roundingMode,
"closer"))
59 else if (!strcmp(roundingMode,
"none"))
62 throw cRuntimeError(
"Unknown rounding mode");
67 simtime_t initialClockTime = par(
"initialClockTime");
69 throw cRuntimeError(
"Initial clock time must be a multiple of the oscillator nominal tick length");
Referenced by inet::SettableClock::initialize().
◆ receiveSignal()
| void inet::OscillatorBasedClock::receiveSignal |
( |
cComponent * |
source, |
|
|
int |
signal, |
|
|
cObject * |
obj, |
|
|
cObject * |
details |
|
) |
| |
|
overridevirtual |
136 simtime_t currentSimTime = simTime();
137 for (
auto event :
events) {
138 if (event->getRelative()) {
140 ASSERT(simTimeDelay >= 0);
141 cSimpleModule *targetModule = check_and_cast<cSimpleModule *>(event->getArrivalModule());
142 cContextSwitcher contextSwitcher(targetModule);
143 targetModule->rescheduleAfter(simTimeDelay, event);
146 clocktime_t arrivalClockTime =
event->getArrivalClockTime();
148 ASSERT(arrivalSimTime >= currentSimTime);
149 cSimpleModule *targetModule = check_and_cast<cSimpleModule *>(event->getArrivalModule());
150 cContextSwitcher contextSwitcher(targetModule);
151 targetModule->rescheduleAt(arrivalSimTime, event);
◆ resolveDirective()
| const char * inet::OscillatorBasedClock::resolveDirective |
( |
char |
directive | ) |
const |
|
overridevirtual |
Reimplemented from inet::ClockBase.
115 static std::string result;
126 return result.c_str();
◆ scheduleClockEventAfter()
Schedules an event to be delivered to the caller module (i.e.
the context module) after the given clock time delay has elapsed. The event is anchored to a specific clock time duration, so the actual simulation time when this event is executed is not affected if the clock time is set later. On the other hand, setting the clock drift still affects the simulation time of the event execution.
Reimplemented from inet::ClockBase.
◆ scheduleClockEventAt()
Schedules an event to be delivered to the caller module (i.e.
the context module) at the specified clock time. The event is anchored to a specific clock time value, so the actual simulation time when this event is executed will be affected if the clock time is set later.
Reimplemented from inet::ClockBase.
◆ events
| std::vector<ClockEvent *> inet::OscillatorBasedClock::events |
|
protected |
◆ originClockTick
| int64_t inet::OscillatorBasedClock::originClockTick = -1 |
|
protected |
◆ oscillator
| IOscillator* inet::OscillatorBasedClock::oscillator = nullptr |
|
protected |
◆ roundingFunction
| int64_t(* inet::OscillatorBasedClock::roundingFunction) (int64_t, int64_t) = nullptr |
|
protected |
The documentation for this class was generated from the following files:
virtual simtime_t computeSimTimeFromClockTime(clocktime_t t) const override
Returns the simulation time (first moment) for the specified future clock time according to the curre...
Definition: OscillatorBasedClock.cc:80
ClockTime clocktime_t
Definition: contract/ClockTime.h:25
IOscillator * oscillator
Definition: OscillatorBasedClock.h:19
static ClockTime from(SimTime t)
Convert from SimTime.
Definition: common/ClockTime.h:185
virtual ClockEvent * cancelClockEvent(ClockEvent *event) override
Cancels a previously scheduled clock event.
Definition: ClockBase.cc:72
#define CLOCKTIME_AS_SIMTIME(x)
Definition: contract/ClockTime.h:19
static simsignal_t timeChangedSignal
Definition: ClockBase.h:21
void remove(std::vector< T > &v, const Tk &a)
Definition: stlutils.h:107
virtual const char * resolveDirective(char directive) const override
Definition: ClockBase.cc:87
#define ClockTime
Definition: contract/ClockTime.h:18
virtual void scheduleClockEventAt(clocktime_t time, ClockEvent *event) override
Schedules an event to be delivered to the caller module (i.e.
Definition: ClockBase.cc:47
std::vector< ClockEvent * > events
Definition: OscillatorBasedClock.h:23
virtual clocktime_t getClockTime() const override
Returns the current clock time.
Definition: ClockBase.cc:42
virtual void initialize(int stage) override
Definition: ClockBase.cc:14
static simsignal_t postOscillatorStateChangedSignal
Definition: IOscillator.h:22
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
virtual void scheduleClockEventAfter(clocktime_t time, ClockEvent *event) override
Schedules an event to be delivered to the caller module (i.e.
Definition: ClockBase.cc:58
int64_t originClockTick
Definition: OscillatorBasedClock.h:22
int64_t(* roundingFunction)(int64_t, int64_t)
Definition: OscillatorBasedClock.h:20
virtual void handleClockEvent(ClockEvent *event) override
Called by the clock event to be executed in the context of this clock.
Definition: ClockBase.cc:79
#define Enter_Method(...)
Definition: SelfDoc.h:71
virtual simtime_t getComputationOrigin() const =0
Returns the oscillator computation origin from which the ticks are measured.
virtual simtime_t getNominalTickLength() const =0
Returns the nominal time interval between subsequent ticks.
static simsignal_t preOscillatorStateChangedSignal
Definition: IOscillator.h:21
INET_API InitStage INITSTAGE_CLOCK
Initialization of clocks.
virtual simtime_t computeIntervalForTicks(int64_t numTicks) const =0
Returns the smallest simulation time interval for the specified number of ticks measured from the osc...
virtual int64_t computeTicksForInterval(simtime_t timeInterval) const =0
Returns the number of ticks in the specified time interval measured from the oscillator computation o...