ShutterStateChange
public sealed record ShutterStateChange : IEquatable<ShutterStateChange>
The camera's internal shutter changed position.
Delivered to the handler given to ThermalCamera.OnShutterState(…).
This is the way to get the transitions themselves, with timestamps, and the only way to tell a shutter on its way from one that has arrived: a camera reports ShutterState.Closing and ShutterState.Opening too, and no single bool can carry four values.
It is not the only way to see a closure. This used to say it was, on the ground that "the frames captured while the shutter is closed are never delivered, so that flag is true on every frame a live stream produces". That was true when it was written and false since version 12, which holds the last frame taken with the shutter open and delivers it through the closed window instead of withholding it, so FrameMetadata.IsFlagOpen is false on those frames on every source, and a cycle is a run of repeats rather than a gap.
Example Warning when a cycle takes longer than two seconds:
TimeSpan? closedAt = null; camera.OnShutterState(change => { if (change.Current == ShutterState.Closing) { closedAt = change.Timestamp; } else if (change.Current == ShutterState.Open && closedAt is { } start) { if (change.Timestamp - start > TimeSpan.FromSeconds(2)) { Warn("shutter cycle did not complete in time"); } closedAt = null; } });
ShutterStateChange: constructors
public ShutterStateChange(ShutterState Previous, ShutterState Current, TimeSpan Timestamp, ulong Sequence, DateTimeOffset HostTime)
The camera's internal shutter changed position.
Previous: The state before. Equal toCurrentonly on the first change, which reports the state the camera started in.Current: The state now.Timestamp: When, on a monotonic clock: the same oneStopwatchreads, measured from an unspecified origin. Not a date. It is monotonic on purpose: this exists to time a cycle, and a cycle timed across a clock adjustment would be wrong exactly when it mattered. Subtract two of these to get a duration; do not turn one into aDateTime.Sequence: Changes since the camera was opened, from 1. A consumer that missed one can tell.HostTime: The same change as a date: the wall-clock time the shutter moved. This is what a log row wants. It is read where the SDK detects the transition, at the same moment asTimestamp, and not when this handler runs, so the time between the shutter moving and your callback being called is not in it. 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 changes can carry host times that go backwards or differ by hours.Timestampnever does that. Measure a cycle withTimestamp; writeDateTimeOffsetto your log with this. Neither is computed from the other: they are two real readings of two different clocks, taken one after the other so you can correlate them if you need to. How far this can be from the shutter actually moving. It is stamped where the SDK decides the transition, which is not always where the shutter moves.ShutterState.Closingis the command, stamped before the mechanism has done anything.ShutterState.ClosedandShutterState.Openingare observations, and the only thing that observes the shutter is the frame: the camera puts the flag position in each frame's metadata, so the SDK learns of a movement on the first frame captured after it. The stamp lags the movement by up to one frame period, uniformly distributed, plus that frame's transport and processing time: 31 ms on a PI 640 at 32 Hz, 20 ms on an Xi 80 at 50 Hz, 40 ms on an Xi 410 at 25 Hz over Ethernet, and 244 ms on an Xi 410 at 4.1 Hz over USB, which is the worst case across the supported formats.ShutterState.Openat the end of a cycle is a timer rather than an observation; use theOpeningstamp for the observed reopen. That is an offset on when a transition is learned of, not jitter in the clock: both timestamps are read at the same instant and carry the same lag, soClosedtoOpeningstill measures the closed window correctly. Read a log row as "no earlier than this, by up to one frame period".
Delivered to the handler given to ThermalCamera.OnShutterState(…).
This is the way to get the transitions themselves, with timestamps, and the only way to tell a shutter on its way from one that has arrived: a camera reports ShutterState.Closing and ShutterState.Opening too, and no single bool can carry four values.
It is not the only way to see a closure. This used to say it was, on the ground that "the frames captured while the shutter is closed are never delivered, so that flag is true on every frame a live stream produces". That was true when it was written and false since version 12, which holds the last frame taken with the shutter open and delivers it through the closed window instead of withholding it, so FrameMetadata.IsFlagOpen is false on those frames on every source, and a cycle is a run of repeats rather than a gap.
Example Warning when a cycle takes longer than two seconds:
TimeSpan? closedAt = null; camera.OnShutterState(change => { if (change.Current == ShutterState.Closing) { closedAt = change.Timestamp; } else if (change.Current == ShutterState.Open && closedAt is { } start) { if (change.Timestamp - start > TimeSpan.FromSeconds(2)) { Warn("shutter cycle did not complete in time"); } closedAt = null; } });
ShutterStateChange: properties
public ShutterState Current { get; init; }
The state now.
public DateTimeOffset HostTime { get; init; }
The same change as a date: the wall-clock time the shutter moved.
This is what a log row wants. It is read where the SDK detects the transition, at the same moment as Timestamp, and not when this handler runs, so the time between the shutter moving and your callback being called is not in it.
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 changes can carry host times that go backwards or differ by hours. Timestamp never does that. Measure a cycle with Timestamp; write DateTimeOffset to your log with this. Neither is computed from the other: they are two real readings of two different clocks, taken one after the other so you can correlate them if you need to.
How far this can be from the shutter actually moving. It is stamped where the SDK decides the transition, which is not always where the shutter moves. ShutterState.Closing is the command, stamped before the mechanism has done anything. ShutterState.Closed and ShutterState.Opening are observations, and the only thing that observes the shutter is the frame: the camera puts the flag position in each frame's metadata, so the SDK learns of a movement on the first frame captured after it. The stamp lags the movement by up to one frame period, uniformly distributed, plus that frame's transport and processing time: 31 ms on a PI 640 at 32 Hz, 20 ms on an Xi 80 at 50 Hz, 40 ms on an Xi 410 at 25 Hz over Ethernet, and 244 ms on an Xi 410 at 4.1 Hz over USB, which is the worst case across the supported formats. ShutterState.Open at the end of a cycle is a timer rather than an observation; use the Opening stamp for the observed reopen.
That is an offset on when a transition is learned of, not jitter in the clock: both timestamps are read at the same instant and carry the same lag, so Closed to Opening still measures the closed window correctly. Read a log row as "no earlier than this, by up to one frame period".
public bool IsShut { get; }
Whether the shutter is closed or on its way there.
The question a shutter indicator actually asks, answered once here so that every caller does not have to enumerate the states. ShutterState.Error counts as closed: the cycle did not complete, and showing an open iris because the mechanism failed would be the wrong way round.
public ShutterState Previous { get; init; }
The state before. Equal to Current only on the first change, which reports the state the camera started in.
public ulong Sequence { get; init; }
Changes since the camera was opened, from 1. A consumer that missed one can tell.
public TimeSpan Timestamp { get; init; }
When, on a monotonic clock: the same one Stopwatch reads, measured from an unspecified origin.
Not a date. It is monotonic on purpose: this exists to time a cycle, and a cycle timed across a clock adjustment would be wrong exactly when it mattered. Subtract two of these to get a duration; do not turn one into a DateTime.