AlarmEvent
public sealed record AlarmEvent : IEquatable<AlarmEvent>
A rule changing state, and why.
Everything needed to describe the transition is here, so a handler never has to call back into the camera to find out what happened.
AlarmEvent: constructors
public AlarmEvent(ulong RuleId, string RuleName, AlarmState Previous, AlarmState Current, SignalId Input, double Value, float Limit, LimitKind LimitKind, ulong RegionId, string RegionName, TimeSpan Timestamp, ulong Sequence, DateTimeOffset HostTime)
A rule changing state, and why.
RuleId: Which rule changed.RuleName: Its name, possibly empty.Previous: The state before.Current: The state after.Input: The signal that caused it.Value: Its value at the transition. For a rule with anAlarmRule.Referenceit is the input minus the reference, which is the numberLimitwas compared with. In the unit of the input's quantity, asAlarmLimitsdescribes: a temperature in the SDK's temperature unit (Celsius unlessSdk.TemperatureUnitchose Fahrenheit), and for a rule with a reference a difference in degrees of that unit. On such an input, where there is no value (a transition intoAlarmState.Orphaned), it readsDouble.NaNin Fahrenheit.Limit: The limit that was crossed, in the same unit asValue. WhereLimitKindisLimitKind.Nonethere is no limit, and on a temperature input it readsSingle.NaNin Fahrenheit.LimitKind: Which limit that was.RegionId: The region owning the rule, or 0 for a rule attached to none.RegionName: Its name, possibly empty.Timestamp: When the transition happened. Its origin depends on what drove the evaluation, so do not compare two events unless they came from the same kind of rule. A rule on a region or on camera telemetry is evaluated on a frame and carries that frame's timestamp, measured from the camera's start likeFrameMetadata.Timestamp. A rule on a process-interface channel carries whatever the PIF poll that read it stamped. A rule on a value published withThermalCamera.PublishSignal(…)is evaluated immediately and carries wall-clock time instead: seconds since the Unix epoch. A transition intoAlarmState.Orphanedbefore any input has arrived carries zero. Subtracting a region rule'sTimestampfrom a published signal's therefore gives an answer wrong by decades, and none of them can be formatted as a time of day. The native header used to describe this field as one monotonic clock throughout; it never was on the published-signal path, and it no longer says so. This is the SDK's behaviour rather than a choice of this binding. UseAlarmEvent.Sequenceto order events; it is consistent across all of them. To display a time, useAlarmEvent.HostTime, which is a date on every event whatever drove the rule.Sequence: The evaluation cycle it belongs to.HostTime: The same transition as a date: the wall-clock time the evaluation that raised it ran. This is the field for an alarm log or an alarm history, and the one to reach for whenTimestampturns out not to be a time of day. UnlikeTimestampits meaning does not depend on what kind of rule fired: every event carries the same kind of value, and every event of one evaluation cycle carries the same one. It is read where the transition is decided, not where this event is delivered, so the queue latency between the two is not in it, which is what makes it better than the receive time a consumer can take for itself. Events fromThermalCamera.ReadAlarmLog(…)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 evaluation cycle, so do not use equality here to decide that two events came from the same frame. A frame evaluates the measurement-area and camera rules together and the motion rules in a second pass, once every zone has published; rules on process-interface channels and on published values are evaluated on their own occasions again. Each pass reads the clock once, so two events from one frame can differ here by microseconds.Sequenceis what identifies the observation an event belongs to. It can jump, andTimestampcannot. This comes from the machine's wall clock, which NTP can step forwards or backwards and which a user can set, so two consecutive events can carry host times that go backwards or differ by hours.Timestampnever does that. Order bySequence, measure intervals withTimestamp, and display this. Neither is computed from the other: they are two real readings of two different clocks.
Everything needed to describe the transition is here, so a handler never has to call back into the camera to find out what happened.
AlarmEvent: properties
public AlarmState Current { get; init; }
The state after.
public DateTimeOffset HostTime { get; init; }
The same transition as a date: the wall-clock time the evaluation that raised it ran.
This is the field for an alarm log or an alarm history, and the one to reach for when Timestamp turns out not to be a time of day. Unlike Timestamp its meaning does not depend on what kind of rule fired: every event carries the same kind of value, and every event of one evaluation cycle carries the same one. It is read where the transition is decided, not where this event is delivered, so the queue latency between the two is not in it, which is what makes it better than the receive time a consumer can take for itself. Events from ThermalCamera.ReadAlarmLog(…) 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 evaluation cycle, so do not use equality here to decide that two events came from the same frame. A frame evaluates the measurement-area and camera rules together and the motion rules in a second pass, once every zone has published; rules on process-interface channels and on published values are evaluated on their own occasions again. Each pass reads the clock once, so two events from one frame can differ here by microseconds. Sequence is what identifies the observation an event belongs to.
It can jump, and Timestamp cannot. This comes from the machine's wall clock, which NTP can step forwards or backwards and which a user can set, so two consecutive events can carry host times that go backwards or differ by hours. Timestamp never does that. Order by Sequence, measure intervals with Timestamp, and display this. Neither is computed from the other: they are two real readings of two different clocks.
public SignalId Input { get; init; }
The signal that caused it.
public float Limit { get; init; }
The limit that was crossed, in the same unit as Value. Where LimitKind is LimitKind.None there is no limit, and on a temperature input it reads Single.NaN in Fahrenheit.
public LimitKind LimitKind { get; init; }
Which limit that was.
public AlarmState Previous { get; init; }
The state before.
public ulong RegionId { get; init; }
The region owning the rule, or 0 for a rule attached to none.
public string RegionName { get; init; }
Its name, possibly empty.
public ulong RuleId { get; init; }
Which rule changed.
public string RuleName { get; init; }
Its name, possibly empty.
public ulong Sequence { get; init; }
The evaluation cycle it belongs to.
public TimeSpan Timestamp { get; init; }
When the transition happened.
Its origin depends on what drove the evaluation, so do not compare two events unless they came from the same kind of rule. A rule on a region or on camera telemetry is evaluated on a frame and carries that frame's timestamp, measured from the camera's start like FrameMetadata.Timestamp. A rule on a process-interface channel carries whatever the PIF poll that read it stamped. A rule on a value published with ThermalCamera.PublishSignal(…) is evaluated immediately and carries wall-clock time instead: seconds since the Unix epoch. A transition into AlarmState.Orphaned before any input has arrived carries zero.
Subtracting a region rule's Timestamp from a published signal's therefore gives an answer wrong by decades, and none of them can be formatted as a time of day. The native header used to describe this field as one monotonic clock throughout; it never was on the published-signal path, and it no longer says so.
This is the SDK's behaviour rather than a choice of this binding. Use AlarmEvent.Sequence to order events; it is consistent across all of them. To display a time, use AlarmEvent.HostTime, which is a date on every event whatever drove the rule.
public double Value { get; init; }
Its value at the transition. For a rule with an AlarmRule.Reference it is the input minus the reference, which is the number Limit was compared with. In the unit of the input's quantity, as AlarmLimits describes: a temperature in the SDK's temperature unit (Celsius unless Sdk.TemperatureUnit chose Fahrenheit), and for a rule with a reference a difference in degrees of that unit. On such an input, where there is no value (a transition into AlarmState.Orphaned), it reads Double.NaN in Fahrenheit.