Alarms
class optris_sdk.alarms.Alarms
The rules on one camera: camera.alarms.
Alarms — methods
add(rule, region_id = 0)
Install a rule and return its id.
Consumes rule: the SDK takes the handle, and the Python
object cannot be added again.
With region_id the rule's signal slot is filled in from
that region, so a region-domain SignalId needs no
index. Without one the rule is on the device and the signal
must already name what it watches.
ids()
The id of every installed rule.
get(rule_id)
A copy of an installed rule, as a Rule.
Close it, or use it as a context manager. Raises if the id is unknown.
update(rule_id, rule)
Replace an installed rule, keeping its id.
Consumes rule, exactly as add does.
Validated before it is applied: a rejected change leaves the
rule exactly as it was rather than half-applied. A rule
installed against a region stays bound to that region --
the input's region slot is re-resolved here exactly as
add resolves it -- so writing back a rule built from
the thresholds on screen keeps measuring the same region, and
there is no need to read the installed rule back first to carry
its index over.
- Raises
~optris_sdk.errors.NotFoundError— if the id is unknown, if the rule's region has since been removed, or if the new state is not evaluable. A refused edit raises this, not theoptris_sdk.errors.InvalidArgumentErrorthataddraises; the message says which it was.
remove(rule_id)
Remove a rule.
- Raises
~optris_sdk.errors.NotFoundError— if the id is unknown.
region_state(region_id)
The worst state across every rule attached to one region.
For colouring a region in a list without walking its rules.
state_of is the per-rule answer and worst_state
the whole-camera one.
log()
The most recent transitions, oldest first, as
AlarmEvent.
For a display that repaints faster than it wants to subscribe.
Reading does not drain it. The log is a ring of the last
256 transitions and this is a view of it, so two polls return
the same events again: de-duplicate on
AlarmEvent.sequence, and poll often enough that more
than 256 transitions cannot happen in between -- or subscribe
with on_alarm instead and miss nothing.
A recording keeps a log too, and answers here.
register_callback(handler)
Register a handler a rule's callback action can name, and return its slot.
The slot goes to Rule.add_callback_action(). Slots are
append-only for the life of the camera: a rule already
installed refers to one by index, so reusing an index would
silently repoint it -- which is why there is no way to remove
one.
Distinct from on_alarm, which is told about every
transition. This is for a rule that names one action among
several, so a handler fires only for the rules that asked for
it.
Fires on the SDK's action thread. Every rule in
optris_sdk.callbacks applies.
register_signal(name)
Register a value your application publishes, and return its slot.
A line pressure, a batch number, a reading from another
instrument -- once registered it behaves exactly like a
temperature, with the same bands, hysteresis, delays and
actions. Name it in a rule with SignalId.user(slot). Its
value is in whatever unit the application publishes it in and
is never converted, whatever
optris_sdk.set_temperature_unit chose.
Scoped to this camera, not to the process: the same name registered on two cameras gives two independent signals, and a slot from one means nothing to the other. Registering the same name twice returns the same slot.
publish_signal(slot, value)
Publish a new value. Rules watching it are evaluated immediately -- on this thread, before this returns.
read_signal(signal)
Read any signal, in any domain.
signal is a SignalId. Returns (value, timestamp_us), or (None, timestamp_us) when the producer
supplied nothing this cycle. The value is in the signal's own
unit, as a rule's limits are (see the module docstring): a
temperature in the SDK's temperature unit, a standard deviation
a difference in it, and a coverage, area, count or published
value as it is.
None is not zero. A signal with no value this cycle
makes a rule on it report ALARM_ORPHANED rather than
holding its last state, and a caller that read a 0 there would
be reading a number nobody published -- which is why this
reports the absence rather than the value beside it.
region_signal_slot(region_id)
A region's packed generational signal slot.
Needed only to point at a region other than the one a rule
is attached to -- an inhibit that silences a rule while some
other region is hot, say. A rule's own input is filled in for
you by add and kept right by update, so leave
that at zero.
The value is a runtime handle, not an identity: it changes when the region is removed and re-added, and it is never valid on another camera. Do not store it -- store the region id and ask again. Zero is never a live slot.
- Raises
~optris_sdk.errors.NotFoundError— if the id is unknown.
region_of(rule_id)
The region a rule was attached to, or 0 for a free rule.
A region rule's own input names a generational slot, not
a region id, so nothing on the rule itself names the region it
belongs to. An unknown id reports 0, which is the same answer a
rule attached to no region gives.
state_of(rule_id)
What one rule reports right now.
runtime_of(rule_id)
What one rule reports, and whether its latch is the only thing holding it active.
Returns (state, held_by_latch). held_by_latch is true
only when state is ALARM_ACTIVE and the condition has
released, so acknowledge will clear it; when it is
false, acknowledging an active alarm re-arms the latch and
changes nothing. Always false for a non-latching rule.
worst_state()
The worst state across every rule, for one indicator.
acknowledge(rule_id)
Clear a latched alarm.
If the condition still holds it stays raised and the latch re-arms: acknowledging a ringing alarm never silences it.
acknowledge_all()
on_alarm(handler)
Call handler(AlarmEvent) on every transition.
Fires on the SDK's action thread rather than the frame thread,
but it is still an SDK thread: every rule in
optris_sdk.callbacks applies.
on_action_completed(handler)
Call handler(ActionCompleted) when an action finishes.
Fires when an action did its work, when it was declined by its own minimum interval, and when it was dropped from a full queue -- the three non-failure endings. Until this existed nothing in Python was told about any of them, so a snapshot that was written successfully produced no event at all and an application had to go looking on disk for a file whose name the SDK had chosen.
The failure ending is on_action_error.
Correlate on ActionCompleted.sequence rather than on
the rule id and a nearby time: an application showing a line
per activation already has that number, so the match is exact
where matching on a time is a guess a chattering alarm gets
wrong.
Fires on the SDK's action thread. Every rule in
optris_sdk.callbacks applies.
on_action_error(handler)
Call handler(ActionError) when an action fails.
The failure half of on_action_completed. Both existed
in the C ABI and neither reached Python, so an alarm action
that failed to write its file was exactly as silent as one
that wrote it.
Fires on the SDK's action thread. Every rule in
optris_sdk.callbacks applies.
action_drop_counts()
How many actions and action reports this source has lost.
Exact totals over the life of the camera, recording or still,
across reconnects. The two callbacks above are best effort; this
is how an application learns that some of their reports never
arrived. See ActionDropCounts.