pamoja.profile
Idiomatic device-profile facade.
A profile is a named, pre-wired bundle: a control policy, a publish topic, and a power schedule. Instantiate one rather than choosing algorithms and tuning constants by hand.
A Profile is the manifest, which loads from and saves to JSON so it
ships as a file. A Controller is the decision logic that manifest
describes: hand it a reading and it says what the output should do and whether
the reading crossed a threshold worth raising. The presentation a dashboard
reads travels inside the manifest JSON.
1"""Idiomatic device-profile facade. 2 3A profile is a named, pre-wired bundle: a control policy, a publish topic, and a 4power schedule. Instantiate one rather than choosing algorithms and tuning 5constants by hand. 6 7A :class:`Profile` is the manifest, which loads from and saves to JSON so it 8ships as a file. A :class:`Controller` is the decision logic that manifest 9describes: hand it a reading and it says what the output should do and whether 10the reading crossed a threshold worth raising. The presentation a dashboard 11reads travels inside the manifest JSON. 12""" 13 14from __future__ import annotations 15 16import enum 17 18from pamoja._native import ( 19 AlertReport, 20 ControlPolicy, 21 Controller, 22 PowerScheduleSpec, 23 Profile, 24 Reaction, 25) 26 27__all__ = [ 28 "AlertKind", 29 "AlertReport", 30 "ControlKind", 31 "ControlPolicy", 32 "Controller", 33 "PowerScheduleSpec", 34 "Profile", 35 "Reaction", 36] 37 38 39class ControlKind(str, enum.Enum): 40 """Which control policy a profile applies to each reading.""" 41 42 #: Hold a reading near a setpoint by switching an output on and off. 43 SETPOINT = "Setpoint" 44 #: Watch a falling level and warn before it reaches empty. 45 LEVEL = "Level" 46 #: Warn when a reading changes faster than a limit. 47 SURGE = "Surge" 48 #: Report readings only, with no output and no alerts. 49 MONITOR = "Monitor" 50 51 52class AlertKind(str, enum.Enum): 53 """Which threshold a reading crossed.""" 54 55 #: A controlled reading drifted outside its safe band. 56 OUT_OF_RANGE = "OutOfRange" 57 #: A falling level will reach empty within a few more samples. 58 RUNNING_OUT = "RunningOut" 59 #: A reading is changing faster than its safe rate. 60 CHANGING_FAST = "ChangingFast"
53class AlertKind(str, enum.Enum): 54 """Which threshold a reading crossed.""" 55 56 #: A controlled reading drifted outside its safe band. 57 OUT_OF_RANGE = "OutOfRange" 58 #: A falling level will reach empty within a few more samples. 59 RUNNING_OUT = "RunningOut" 60 #: A reading is changing faster than its safe rate. 61 CHANGING_FAST = "ChangingFast"
Which threshold a reading crossed.
An alert a reading raised.
Only the attribute belonging to kind is set; the rest are None.
40class ControlKind(str, enum.Enum): 41 """Which control policy a profile applies to each reading.""" 42 43 #: Hold a reading near a setpoint by switching an output on and off. 44 SETPOINT = "Setpoint" 45 #: Watch a falling level and warn before it reaches empty. 46 LEVEL = "Level" 47 #: Warn when a reading changes faster than a limit. 48 SURGE = "Surge" 49 #: Report readings only, with no output and no alerts. 50 MONITOR = "Monitor"
Which control policy a profile applies to each reading.
A profile's control policy.
Only the attributes belonging to kind are set; the rest are None.
The decision logic a profile assembles.
A controller carries state between readings, because a level estimate and a rate of change both need the previous sample, so evaluate readings through one controller in the order they were taken.
How often a node samples as its battery drains, in whole seconds.
A named, ready-to-run node assembled from pamoja capabilities.
What a controller decided about one reading.