|
INET Framework for OMNeT++/OMNEST
|
#include <SettableClock.h>
◆ getOverdueClockEventHandlingMode()
◆ handleOverdueClockEvent()
| simtime_t inet::SettableClock::handleOverdueClockEvent |
( |
ClockEvent * |
event, |
|
|
simtime_t |
t |
|
) |
| |
|
protectedvirtual |
46 EV_WARN <<
"Scheduling overdue clock event " <<
event->getName() <<
" to current simulation time.\n";
49 EV_WARN <<
"Skipping overdue clock event " <<
event->getName() <<
".\n";
53 throw cRuntimeError(
"Clock event is overdue");
55 throw cRuntimeError(
"Unknown overdue clock event handling mode");
Referenced by setClockTime().
◆ initialize()
| void inet::SettableClock::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::OscillatorBasedClock.
21 const char *text = par(
"defaultOverdueClockEventHandlingMode");
22 if (!strcmp(text,
"execute"))
24 else if (!strcmp(text,
"skip"))
26 else if (!strcmp(text,
"error"))
29 throw cRuntimeError(
"Unknown defaultOverdueClockEventHandlingMode parameter value");
◆ processCommand()
| void inet::SettableClock::processCommand |
( |
const cXMLElement & |
node | ) |
|
|
overrideprotectedvirtual |
Called by ScenarioManager whenever a script command needs to be carried out by the module.
The command is represented by the XML element or element tree. The command name can be obtained as:
const char *command = node->getTagName()
Parameters are XML attributes, e.g. a "neighbour" parameter can be retrieved as:
const char *attr = node->getAttribute("neighbour")
More complex input can be passed in child elements.
- See also
- cXMLElement
Implements inet::IScriptable.
99 if (!strcmp(node.getTagName(),
"set-clock")) {
105 throw cRuntimeError(
"Invalid command: %s", node.getTagName());
◆ setClockTime()
| void inet::SettableClock::setClockTime |
( |
clocktime_t |
time, |
|
|
bool |
resetOscillator = true |
|
) |
| |
|
virtual |
63 if (newClockTime != oldClockTime) {
65 if (resetOscillator) {
66 if (
auto constantDriftOscillator =
dynamic_cast<ConstantDriftOscillator *
>(
oscillator))
67 constantDriftOscillator->setTickOffset(0);
69 simtime_t currentSimTime = simTime();
70 EV_DEBUG <<
"Setting clock time from " << oldClockTime <<
" to " << newClockTime <<
" at simtime " << currentSimTime <<
".\n";
74 clocktime_t clockDelta = newClockTime - oldClockTime;
75 for (
auto event :
events) {
76 if (event->getRelative())
78 event->setArrivalClockTime(event->getArrivalClockTime() + clockDelta);
80 clocktime_t arrivalClockTime =
event->getArrivalClockTime();
81 bool isOverdue = arrivalClockTime < newClockTime;
83 if (isOverdue || arrivalSimTime < currentSimTime)
85 if (event->isScheduled()) {
86 cSimpleModule *targetModule = check_and_cast<cSimpleModule *>(event->getArrivalModule());
87 cContextSwitcher contextSwitcher(targetModule);
88 targetModule->rescheduleAt(arrivalSimTime, event);
Referenced by processCommand().
◆ defaultOverdueClockEventHandlingMode
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
virtual void initialize(int stage) override
Definition: OscillatorBasedClock.cc:44
ClockTime clocktime_t
Definition: contract/ClockTime.h:25
IOscillator * oscillator
Definition: OscillatorBasedClock.h:19
static simsignal_t timeChangedSignal
Definition: ClockBase.h:21
@ EXECUTE
Definition: ClockEvent_m.h:60
static const ClockTime parse(const char *s)
Converts the given string to simulation time.
Definition: common/ClockTime.h:315
std::vector< ClockEvent * > events
Definition: OscillatorBasedClock.h:23
virtual simtime_t handleOverdueClockEvent(ClockEvent *event, simtime_t t)
Definition: SettableClock.cc:42
virtual clocktime_t getClockTime() const override
Returns the current clock time.
Definition: ClockBase.cc:42
@ UNSPECIFIED
Definition: ClockEvent_m.h:59
virtual OverdueClockEventHandlingMode getOverdueClockEventHandlingMode(ClockEvent *event) const
Definition: SettableClock.cc:33
bool getAttributeBoolValue(const cXMLElement *node, const char *attrName, bool defVal)
Definition: XMLUtils.cc:169
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
@ SKIP
Definition: ClockEvent_m.h:61
int64_t originClockTick
Definition: OscillatorBasedClock.h:22
OverdueClockEventHandlingMode defaultOverdueClockEventHandlingMode
Definition: SettableClock.h:19
@ ERROR
Definition: ClockEvent_m.h:62
#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.
virtual void setClockTime(clocktime_t time, bool resetOscillator=true)
Definition: SettableClock.cc:59
virtual ClockEvent * cancelClockEvent(ClockEvent *event) override
Cancels a previously scheduled clock event.
Definition: OscillatorBasedClock.cc:101
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...
const char * getMandatoryFilledAttribute(const cXMLElement &node, const char *attr)
Definition: XMLUtils.cc:160