Module clock

class sismic.clock.Clock

Bases: object

Abstract implementation of a clock, as used by an interpreter.

The purpose of a clock instance is to provide a way for the interpreter to get the current time during the execution of a statechart.

abstract property time: float

Current time

Return type

float

class sismic.clock.SimulatedClock

Bases: Clock

A simulated clock, starting from 0, that can be manually or automatically incremented.

Manual incrementation can be done by setting a new value to the time attribute. Automatic incrementation occurs when start() is called, until stop() is called. In that case, clock speed can be adjusted with the speed attribute. A value strictly greater than 1 increases clock speed while a value strictly lower than 1 slows down the clock.

start()

Clock will be automatically updated both based on real time and its speed attribute.

Return type

None

stop()

Clock won’t be automatically updated.

Return type

None

property speed: float

Speed of the current clock. Only affects time if start() is called.

Return type

float

property time: float

Time value of this clock.

Return type

float

class sismic.clock.UtcClock

Bases: Clock

A clock that simulates a wall clock in UTC.

The returned time value is based on Python time.time() function.

property time: float

Current time

Return type

float

class sismic.clock.SynchronizedClock(interpreter)

Bases: Clock

A clock that is synchronized with a given interpreter.

The synchronization is based on the interpreter’s internal time value, not on its clock. As a consequence, the time value of a SynchronizedClock only changes when the underlying interpreter is executed.

Parameters

interpreter – an interpreter instance

property time: float

Current time

Return type

float