snsary.functions.window

Base class for functions that aggregate Readings over fixed, consecutive periods, specified as the keyword arguments for a timedelta (seconds, minutes, etc.).

A subclass should define an aggregate method that is called each time the age of the window for a sensor / reading name pair reaches the specified period.

The windows are consecutive, not moving: after a window has been aggregated a new window is started using the Reading that triggered the previous window to close.

Windows also act as a Service in order to persist and restore Readings when the program they are used in starts and stops. See the storage module for more details.

Module Contents

class snsary.functions.window.Window(**kwargs)

Bases: snsary.functions.function.Function, snsary.system.Service

stop()

Called asynchronously by the system module when a program is stopping. The execution will eventually time out to ensure the overall program stops in good time.

__call__(reading)
abstract aggregate(readings)
key(reading)