hio.base.tyming

hio.core.tyming Module

Module Contents

Classes

Tymist

Tymist keeps artificial or simulated or cycle time, called tyme.

Tymee

Tymee has .tyme property that returns the artificial or simulated or cycle time

Tymer

Tymer class to measure cycle time given by .tyme property of Tymist instance.

class hio.base.tyming.Tymist(tyme=0.0, tock=None, **kwa)[source]

Bases: hio.hioing.Mixin

Tymist keeps artificial or simulated or cycle time, called tyme. Provides relative cycle time, tyme, in seconds with .tyme property in incremets of .tock seconds. .tyme is advanced one .tock increment with .tick method. .tyme may be synchronized with real time by a .tyme manager

Class Attributes:

.Tock is default .tock

Attributes:

Properties:

.tyme is float relative cycle time, .tyme is artificial time .tock is float tyme increment of .tick()

.tick increments .tyme by one .tock or provided tock
Tock = 0.03125[source]
property tyme(self)[source]

tyme property getter, get ._tyme .tyme is float cycle time in seconds

property tock(self)[source]

tock property getter, get ._tock .tock is float cycle time .tyme increment in seconds

tick(self, tock=None)[source]

Advance cycle time .tyme by tock seconds when provided othewise by .tock and return new .tyme :param tock is float of amount of time in seconds to change .tyme:

tymen(self)[source]

Returns function wrapper closure tymth, when called tymth() returns .tyme. This enables read only injection of .tyme into any object via tymth() that wants to be on or access this Tymist’s tyme base.

class hio.base.tyming.Tymee(tymth=None, **kwa)[source]

Bases: hio.hioing.Mixin

Tymee has .tyme property that returns the artificial or simulated or cycle time from its referenced Tymist instance ._tymist.

Attributes:

Properties:
.tyme is float relative cycle time of associated Tymist .tyme obtained

via injected .tymth function wrapper closure.

.tymth is function wrapper closure returned by Tymist .tymeth() method.

When .tymth is called it returns associated Tymist .tyme. .tymth provides injected dependency on Tymist tyme base.

.wind  injects ._tymth dependency from associated Tymist to get its .tyme
Hidden:
._tymth is injected function wrapper closure returned by .tymen() of

associated Tymist instance that returns Tymist .tyme. when called.

property tyme(self)[source]

tyme property getter, get ._tyme .tyme is float cycle time in seconds

property tymth(self)[source]

tymth property getter, get ._tymth returns own copy of tymist.tynth function wrapper closure for subsequent injection into related objects that want to be on same tymist tyme base.

wind(self, tymth)[source]

Inject new tymist.tymth as new ._tymth. Changes tymist.tyme base. Override in subclasses to update any dependencies on a change in tymist.tymth base

class hio.base.tyming.Tymer(duration=None, start=None, **kwa)[source]

Bases: Tymee

Tymer class to measure cycle time given by .tyme property of Tymist instance. tyme is relative cycle time either artificial or real

Inherited Attributes

Attributes:

Inherited Properties:
.tyme is float relative cycle time of associated Tymist .tyme obtained

via injected .tymth function wrapper closure.

.tymth is function wrapper closure returned by Tymist .tymeth() method.

When .tymth is called it returns associated Tymist .tyme. .tymth provides injected dependency on Tymist tyme base.

Properties:

.duration = tyme duration of tymer in seconds from ._start to ._stop .elaspsed = tyme elasped in seconds since ._start .remaining = tyme remaining in seconds until ._stop .expired = True if expired, False otherwise, i.e. .tyme >= ._stop

Inherited Methods:

.wind is injects ._tymth dependency

.start() = start tymer at current .tyme
.restart() = restart tymer at last ._stop so no time lost
Hidden:
._tymth is injected function wrapper closure returned by .tymen() of

associated Tymist instance that returns Tymist .tyme. when called.

._start is start tyme in seconds ._stop is stop tyme in seconds

Duration = 0.0[source]
property duration(self)[source]

duration property getter, .duration = ._stop - ._start .duration is float duration tyme

property elapsed(self)[source]

elapsed tyme property getter, Returns elapsed tyme in seconds (fractional) since ._start.

property remaining(self)[source]

remaining tyme property getter, Returns remaining tyme in seconds (fractional) before ._stop.

property expired(self)[source]

Returns True if tymer has expired, False otherwise. .tyme >= ._stop,

wind(self, tymth)[source]

Inject new ._tymist and any other bundled tymee references Update any dependencies on a change in ._tymist:

starts over itself at new ._tymists time

start(self, duration=None, start=None)[source]
Starts Tymer of duration secs at start time start secs.

If duration not provided then uses current duration If start not provided then starts at current .tyme

restart(self, duration=None)[source]

Lossless restart of Tymer at .tyme = ._stop for duration if provided, current duration otherwise No time lost. Useful to extend Tymer so no time lost