OptrisOptrisDocumentation

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

optris::sdk::ReconnectConfig

How hard, and for how long, the SDK tries to re-open a camera that has gone.

A reconnect is a re-open, not a retry: the device handle is genuinely invalidated by a suspend or a replug, not merely stale. The streaming session is torn down completely -- the claim is released, the source reader destroyed, the control channel closed -- and a fresh one is opened in its place. Nothing is resumed.

The delays below exist because a camera does not come back the instant it goes: a host resume re-enumerates USB over a second or two, and hammering the bus in that window is how a recoverable drop becomes a wedged one. Attempt n waits initial_delay * backoff_multiplier^(n-1), capped at max_delay.

See also: Imager::EnableAutoReconnect()

Public attributes

enabled

bool enabled = false

Whether automatic reconnection is wanted. Ignored by Imager::EnableAutoReconnect(), which is itself the request; it is here so a configuration record can carry the switch.

max_attempts

int max_attempts = 10

How many attempts before giving up. Zero or negative means keep trying for as long as the camera stays open, which is what an unattended installation wants and what an interactive one does not.

initial_delay

std::chrono::milliseconds initial_delay {500}

The wait before the first attempt.

max_delay

std::chrono::milliseconds max_delay {30000}

The longest wait between attempts, however far the backoff has climbed.

backoff_multiplier

float backoff_multiplier = 2.0F

How much longer each attempt waits than the one before. A value below 1 is rejected by Imager::EnableAutoReconnect(): it would shorten the wait on every failure, which is the opposite of backing off.

Public functions

GetDelayForAttempt

auto GetDelayForAttempt(int attempt) const -> std::chrono::milliseconds

The wait before the first attempt, as documented above.

Parameters

Name Description
attempt 1-based. Anything below 1 is treated as 1.

Saturating, not wrapping. The exponent is evaluated so that a long unattended run cannot produce a negative or nonsensical delay: an unbounded pow() overflows to infinity within a couple of hundred attempts, and converting that to an integer is undefined behaviour which in practice yields a negative delay -- no wait at all, and a retry loop hammering a camera that is not there.