MultiClock

Package: inet.clock.model

compound module MultiClock

Multi-clock aggregator and switch.

Summary


Exposes a single IClock(1,:ref:2 <neddoc-msg-inet-iclock>) interface while internally hosting multiple subclocks. All IClock(1,:ref:2 <neddoc-msg-inet-iclock>) operations (conversions, scheduling) are delegated to the *currently active* subclock selected by activeClockIndex. The active clock can be changed at runtime (e.g., to switch gPTP time domains).

Semantics


  • Delegation: getClockTime(), scheduleClockEventAt/After(), cancel, and the

    conversion helpers are forwarded to clock[activeClockIndex] at the moment the call is made.

  • Time continuity: switching may introduce a discontinuity in the exposed

    clock time if subclocks are not aligned. Client modules that assume a monotone clock should handle such discontinuities (e.g., via lower/upper bound handling or by listening for timeChanged).

Typical use


  • Multi-domain gPTP: run one subclock per gPTP domain and switch the active

    one according to best-master selection or policy.

See also: MultiDomainGptp

Usage diagram

Inheritance diagram

Extends

Name

Type

Description

Module

compound module

Base module for all INET compound modules.

Parameters

Name

Type

Default value

Description

displayStringTextFormat

string

“”

Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information

numClocks

int

Number of subclocks

activeClockIndex

int

0

Currently active subclock (0..numClocks-1)

Properties

Name

Value

Description

class

MultiClock

display

i=block/timer

Signals

Name

Type

Unit

Description

timeChanged

simtime_t

Statistics

Name

Title

Source

Record

Unit

Interpolation Mode

Description

timeChanged

Clock time

warmup(localSignal(timeChanged))

vector

s

linear

Unassigned submodule parameters

Name

Type

Default value

Description

clock.oscillator.displayStringTextFormat

string

“%c (%n + %d)”

Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information

clock.oscillator.emitNumTicksSignal

bool

!parent.useFutureEventSet

Enables emitting a signal at each oscillator tick, can be useful for validating the behavior of the more efficient implementation without events

clock.oscillator.oscillatorTickEventSchedulingPriority

int

0

Specifies the scheduling priority of the tick event

clock.oscillator.nominalTickLength

double

Specifies the elapsed time between oscillator ticks

clock.oscillator.tickOffset

double

0s

Shifts ticks to the past, must be in the range of [0, current tick length)

clock.oscillator.driftRate

double

0ppm

Constant fractional frequency offset

clock.underlyingClock.oscillator.displayStringTextFormat

string

“%c (%n + %d)”

Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information

clock.underlyingClock.oscillator.emitNumTicksSignal

bool

!parent.useFutureEventSet

Enables emitting a signal at each oscillator tick, can be useful for validating the behavior of the more efficient implementation without events

clock.underlyingClock.oscillator.oscillatorTickEventSchedulingPriority

int

0

Specifies the scheduling priority of the tick event

clock.underlyingClock.oscillator.nominalTickLength

double

Specifies the elapsed time between oscillator ticks

clock.underlyingClock.oscillator.tickOffset

double

0s

Shifts ticks to the past, must be in the range of [0, current tick length)

clock.underlyingClock.oscillator.driftRate

double

0ppm

Constant fractional frequency offset

Source code

//
// Multi-clock aggregator and switch.
//
// Summary
// -------
// Exposes a single ~IClock interface while internally hosting multiple
// subclocks. All IClock operations (conversions, scheduling) are delegated to
// the *currently active* subclock selected by `activeClockIndex`. The active
// clock can be changed at runtime (e.g., to switch gPTP time domains).
//
// Semantics
// ---------
// - Delegation: getClockTime(), scheduleClockEventAt/After(), cancel, and the
//   conversion helpers are forwarded to clock[activeClockIndex] at the moment
//   the call is made.
// - Time continuity: switching may introduce a discontinuity in the exposed
//   clock time if subclocks are not aligned. Client modules that assume a
//   monotone clock should handle such discontinuities (e.g., via lower/upper
//   bound handling or by listening for `timeChanged`).
//
// Typical use
// -----------
// - Multi-domain gPTP: run one subclock per gPTP domain and switch the active
//   one according to best-master selection or policy.
//
// @see ~MultiDomainGptp
//
module MultiClock extends Module like IClock
{
    parameters:
        int numClocks;                                // Number of subclocks
        int activeClockIndex @mutable = default(0);   // Currently active subclock (0..numClocks-1)
        @display("i=block/timer");
        @class(MultiClock);
        @signal[timeChanged](type=simtime_t);
        @statistic[timeChanged](title="Clock time"; source=warmup(localSignal(timeChanged)); record=vector; interpolationmode=linear; unit=s; autoWarmupFilter=false);
    submodules:
        clock[numClocks]: <default("SettableClock")> like IClock {
            @display("p=200,200,row,200");
        }
}

File: src/inet/clock/model/MultiClock.ned