hio.base.tyming

hio.core.tyming Module

Module Contents

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

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: default .tock

Attributes:

Properties:

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

tick method increments .tyme by one .tock or provided tock
property tyme

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

property tock

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

tick(tock=None)

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()

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)

Bases: hio.hioing.Mixin

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

Class Attributes:

Attributes:

Properties:
tyme (float or None): relative cycle time of associated Tymist which is

provided by calling .tymth function wrapper closure which is obtained from Tymist.tymen(). None means not assigned yet.

tymth (Callable or None): function wrapper closure returned by

Tymist.tymen() method. When .tymth is called it returns associated Tymist.tyme. Provides injected dependency on Tymist cycle tyme base. None means not assigned yet.

- 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

tyme property getter, get ._tyme .tyme is float cycle time in seconds :returns: tyme from self.tymth() when wound else None :rtype: tyme (float or None)

property tymth

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(tymth)

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)

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 and properties are documented on Tymee.

Properties:
  • duration (float): tyme duration in seconds from ._start to ._stop.

  • elapsed (float): tyme elapsed in seconds since ._start.

  • remaining (float): tyme remaining in seconds until ._stop.

  • expired (bool): True if expired (.tyme >= ._stop).

Hidden attributes: _tymth, _start, _stop.

property duration

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

property elapsed

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

property remaining

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

property expired

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

wind(tymth)

Inject new ._tymist and any other bundled tymee references Update any dependencies on a change in ._tymist by restarting at the new ._tymist time.

start(duration=None, start=None)

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(duration=None)

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