OptrisOptrisDocumentation

Documentation/OTC SDK/OTC SDK — C API referencev12.0

optris_sdk_alarm_event

A state transition, carrying its own cause.

Everything needed to report "which region fired, and why" is in here, so a handler never has to call back into the imager -- which matters because it is invoked on the SDK's own action thread.

Public attributes

struct_size

uint32_t struct_size

Set to sizeof(optris_sdk_alarm_event).

rule_id

uint64_t rule_id

Which rule changed state.

rule_name

char rule_name[OPTRIS_SDK_MAX_NAME]

Its name. UTF-8, NUL-terminated, possibly empty.

previous

optris_sdk_alarm_state previous

The state before and after.

current

optris_sdk_alarm_state current

The state the rule is in now, and the one to act on.

An event exists only for a change, so this never equals previous, and the pair together is what decides which optris_sdk_action_trigger fired -- neither field alone does.

It is not always the outcome of a measurement. OPTRIS_SDK_ALARM_DISABLED, OPTRIS_SDK_ALARM_ORPHANED and OPTRIS_SDK_ALARM_INHIBITED arrive here as ordinary transitions, and on those the rule was never evaluated against its limits -- see value and limit_kind before reading either.

input

optris_sdk_signal_id input

The signal that caused it, and its value at the transition.

value

double value

The reading behind the transition, in the signal's own unit: the SDK's temperature unit (Celsius unless optris_sdk_set_temperature_unit() chose Fahrenheit) for a region temperature, a difference in degrees of that unit for a standard deviation or a rule with a reference, whatever the application published for a user signal.

A double where limit is a float, because a user signal is published as a double and narrowing it here would report a number the application never sent.

Read it only when the rule was actually evaluated. On a transition into OPTRIS_SDK_ALARM_DISABLED, OPTRIS_SDK_ALARM_ORPHANED or OPTRIS_SDK_ALARM_INHIBITED nothing was compared, and this holds whatever was last left in the signal slot -- 0 for a signal that never produced anything. In Fahrenheit it is NaN on a transition into OPTRIS_SDK_ALARM_ORPHANED.

limit

float limit

The limit that was crossed, and which one it was, in the same unit as value.

limit_kind

optris_sdk_limit_kind limit_kind

Which limit limit is: the alarm or the warning band, its low or high end, or the tolerance of a OPTRIS_SDK_COMPARE_CHANGED or OPTRIS_SDK_COMPARE_EQUAL rule.

OPTRIS_SDK_LIMIT_INVALID means the rule is a watchdog and what it caught is the signal ceasing to be produced, not a value.

OPTRIS_SDK_LIMIT_NONE means no limit was involved at all. That covers every transition into OPTRIS_SDK_ALARM_DISABLED, OPTRIS_SDK_ALARM_ORPHANED or OPTRIS_SDK_ALARM_INHIBITED, and also the ordinary fall back to OPTRIS_SDK_ALARM_CLEAR -- coming back inside the band crosses nothing. Test this before formatting limit: on those events limit is 0 (NaN in Fahrenheit), and a log line reading "crossed 0.0 C" is worse than one that omits the limit.

region_id

uint64_t region_id

The region owning the rule, or 0 for a rule not attached to one.

region_name

char region_name[OPTRIS_SDK_MAX_NAME]

Its name. UTF-8, NUL-terminated, possibly empty.

timestamp_us

uint64_t timestamp_us

When the input was observed, in microseconds.

Which clock that is depends on the rule, so two of these are not comparable unless both rules watch the same kind of signal. This field is carried over from the observation that drove the evaluation, and the SDK does not restamp it:

  • a rule on a region (OPTRIS_SDK_SIGNAL_DOMAIN_REGION) or on camera telemetry (OPTRIS_SDK_SIGNAL_DOMAIN_DEVICE) is evaluated on a frame and carries that frame's timestamp, which is the SDK's monotonic frame clock, counting from the camera's start. A few seconds into a session it is a few seconds.
  • a rule on a process-interface channel (OPTRIS_SDK_SIGNAL_DOMAIN_PIF) carries whatever the PIF poll that read the channel stamped.
  • a rule on a value the application published with optris_sdk_imager_publish_signal() (OPTRIS_SDK_SIGNAL_DOMAIN_USER) carries wall-clock microseconds since the Unix epoch, taken when the value was published.
  • a transition into OPTRIS_SDK_ALARM_ORPHANED before any input has arrived carries 0.

So subtracting a region rule's timestamp from a published signal's gives an answer wrong by decades, and neither can be formatted as a time of day. Earlier releases of this header described the field as being on one monotonic clock throughout. That was never true of the published-signal path.

Use sequence to order events, this field to measure an interval between two events of the same rule, and host_time_us to say when something happened.

sequence

uint64_t sequence

The evaluation cycle this transition belongs to.

host_time_us

uint64_t host_time_us

The same transition as a date: microseconds since the Unix epoch, read from std::chrono::system_clock when the evaluation that raised the event ran.

This is the field for an alarm log or an alarm history. Every event of one evaluation cycle carries the same value, and it is sampled where the transition is decided, not where the callback is invoked -- so the queue latency between the two is not in it. Events read back with optris_sdk_imager_read_alarm_log() carry the host time they were raised with, so a transition nobody was subscribed for still has a usable date.

One frame is not always one cycle, so do not use equality here to decide that two events came from the same frame. A frame evaluates the region and device rules together, then evaluates the motion rules separately once every zone has published, and those are two cycles with two clock readings microseconds apart. Rules on process-interface channels and on published values are evaluated on their own occasions again. Events that belong together are identified by sequence, which is carried from the observation, not by this field.

This clock is not monotonic and timestamp_us is. NTP can step the system clock forwards or backwards, and an operator can set it, so this value can jump or go backwards between two consecutive events. timestamp_us never will. Order events by sequence, measure intervals with timestamp_us, and display this one. Do not compute either from the other: they are two real readings of two different clocks.

The two are also not read at the same instant. timestamp_us is the input observation's timestamp, stamped when the frame arrived or the value was published; this is read when the rule engine evaluated it. The gap is the evaluation latency, well under a frame period, so their difference is not a clock offset.

Added after this struct's first release, and the reason to check struct_size before reading it if you compile against a header you did not ship with. It is not a field the SDK can omit: optris_sdk_imager_read_alarm_log() takes the element size and requires it to equal this library's sizeof exactly, because it strides through the caller's array with its own stride. A mismatched size is refused with OPTRIS_SDK_ERROR_INVALID_ARGUMENT and nothing is written. So an application built against an older header does not read a short-filled struct; it gets an error and knows.