Skip to content

Commit 6106eca

Browse files
committed
SettableClock: Extended documentation.
1 parent f4b067c commit 6106eca

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

src/inet/clock/model/SettableClock.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313

1414
namespace inet {
1515

16+
/**
17+
* @brief Clock that can be stepped (set) and whose effective oscillator compensation can be changed at runtime.
18+
*
19+
* Stepping creates a discontinuity in C(t) (the simulation time to clock time mapping). Conversions at the step instant
20+
* follow the lower/upper-bound conventions documented by ~IClock. When stepping forward, previously scheduled events
21+
* might become overdue; the behavior is controlled by a module parameter.
22+
*/
1623
class INET_API SettableClock : public OscillatorBasedClock, public IScriptable
1724
{
1825
protected:
@@ -39,8 +46,15 @@ class INET_API SettableClock : public OscillatorBasedClock, public IScriptable
3946
virtual ppm getOscillatorCompensation() const override { return oscillatorCompensation; }
4047

4148
/**
42-
* Sets the clock time immediately to the given value. Greater than 1 oscillator
43-
* compensation factor means the clock measures time faster.
49+
* @brief Step the clock to a new time and (optionally) update oscillator compensation.
50+
*
51+
* Effects (executed atomically at the current simulation time s = now):
52+
* - The clock origin is moved to s, and the new origin clock time is set to the given time.
53+
* - The oscillator compensation factor is updated to the provided ppm value.
54+
* - If resetOscillator is true, the phase/origin of the driving oscillator is also reset.
55+
* - Pending events affected by the step are handled according to defaultOverdueClockEventHandlingMode.
56+
*
57+
* Backward steps are allowed and may affect modules assuming monotone clock progression.
4458
*/
4559
virtual void setClockTime(clocktime_t time, ppm oscillatorCompensation, bool resetOscillator);
4660
};

src/inet/clock/model/SettableClock.ned

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@ package inet.clock.model;
1010
import inet.clock.contract.IClock;
1111

1212
//
13-
// Models a clock which can be set to a different clock time. The clock time
14-
// can be set from C++ or using a <set-clock module="..." time="..."/> command
15-
// in a `ScenarioManager` script.
13+
// This module represents a settable (step-able) clock with adjustable oscillator compensation.
1614
//
17-
// @see ~ScenarioManager
15+
// Extends ~OscillatorBasedClock with the ability to step the clock time to an explicitly provided value (forward or
16+
// backward) and to apply a new oscillator-compensation factor. Stepping the clock introduces a discontinuity in the
17+
// clock-time mapping. Overdue events (whose target time becomes < now after the step) can be handled in three ways:
18+
// - execute : run overdue events immediately (in order)
19+
// - skip : drop/cancel overdue events
20+
// - error : terminate simulation and report an error
21+
//
22+
// The clock time can be set from C++ or by a clock servo module or by a time synchronization protocol or using a
23+
// <set-clock module="..." time="..."/> command in a `ScenarioManager` script.
24+
//
25+
// @see ~IClockServo, ~ScenarioManager
1826
//
1927
module SettableClock extends OscillatorBasedClock
2028
{

0 commit comments

Comments
 (0)