OptrisOptrisDocumentation

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

optris::sdk::pif

What a process-interface channel is, as data.

The v11 subsystem spent 23 classes and 5 base interfaces expressing the cross product of {analog, digital} x {in, out} x behaviour. All of that variation is in PifChannelConfig below: direction and signal are fields, behaviour is one enum, and the per-channel numbers are numbers. There is no channel object at runtime -- the controller holds a table of these and a table of pure functions keyed by kind.

The process interface: industrial I/O on a camera.

One controller per camera, obtained from Imager::GetPif(). It owns a table of channel descriptors (pif_channel.h) and drives them; there is no object per channel, no factory and no per-channel interface.

Two things deliberately do NOT live here:

  • Alarms. A PIF input that should ring, or an output a ringing alarm should drive, is a Rule in the unified alarm system (optris/sdk/alarm.h) naming SignalId::Pif(channel, field). There is no threshold, hysteresis or trigger surface on this class, because a second alarm model is exactly what version 12 removes.
  • Change notification. Every channel's value is published as a signal on each Poll(), so "tell me when this input changes" is a Rule with a CallbackAction, with the warning bands, delays and latching that come with it.

Errors are thrown, as PifException, whose code() says which refusal it was. A PIF is routinely absent or unplugged and this is a polling interface, so note what is NOT a refusal: before the first frame has brought a reading, ReadDigitalInput() answers DigitalState::Unknown, ReadAnalogInput() answers NaN and ReadAll() reports inputs_known false. All three are readings. A read loop over a working PIF therefore throws nothing and does not need to be a try block; what throws is a wrong request, which is a wiring fault.

Enumerations

DigitalState

enum DigitalState

Digital channel state.

Value Initialiser Description
Low = 0
High = 1
Unknown = 255

PifDirection

enum PifDirection

Which way a channel carries its signal.

Value Initialiser Description
kInput
kOutput

PifSignal

enum PifSignal

The electrical nature of a channel. Fail-safe is its own kind of port on the hardware, not an analog or digital one.

Value Initialiser Description
kDigital
kAnalog
kFailSafe

PifChannelKind

enum PifChannelKind

What a channel means. This single enum replaces the 23 channel classes; the direction/signal split that used to multiply them (AiEmissivity vs DiFlagControl vs AoAlarm ...) is now two separate fields, so each behaviour appears exactly once.

Every entry is backed by a mode the camera firmware implements, or by host-side decoding of a value the camera already sends. The desktop products carry a wider enum -- recording control, snapshot control, line scanner, event grabber -- but the Xi80 and Xi410 firmware compile those out, so they are deliberately absent here rather than offered and then failing on the wire.

Value Initialiser Description
kOff Channel is configured off; the pin is parked.
kEmissivity
kAmbientTemperature Input: decoded to the ambient temperature used by the pipeline.
kUncommittedValue
kFlagControl Input: drives the shutter flag when the input crosses threshold.
kResetPeakValleyHold
kFlagStatus Output: firmware reports flag open/closed/moving on the pin.
kFrameSync
kInternalTemperature Output: encoded internal (box) temperature.
kExternalComm Output: driven by the application, or by an alarm rule.
kMeasurementField Output: encoded statistic of the region named by target.
kAlarm
kFailSafe Output: the fail-safe watchdog line. See PifFailSafeConfig.

PifAutonomy

enum PifAutonomy

How much of the PIF the camera firmware drives on its own, without a host. Was three "modes" strategy classes; it is a lookup key.

Value Initialiser Description
kNone
kNonAutonomous
kAutonomous

PifError

enum PifError

Why a PIF operation could not be carried out.

Value Initialiser Description
kOk
kNoDevice No PIF is attached.
kNotConnected Attached but not reachable.
kUnsupported The hardware cannot do this.
kInvalidParameter The request does not make sense.
kOutOfRange Channel index beyond the hardware's count.
kIoError The transport failed.
kTimeout
kInvalidState

PifDeviceKind

enum PifDeviceKind

Which PIF is attached.

The full set, because this is a value an application may have to state rather than read: on several cameras the firmware cannot tell you (see PifDetection). A coarse "internal or external" enum would leave a caller unable to say which external PIF it wired up.

Value Initialiser Description
kNone
kStandard Standard PIF.
kStackable Stackable PIF; several devices share one flat channel space.
kInternal
kIndustrialVoltage Industrial PIF with voltage analog outputs (0-10 V).
kIndustrialCurrent Industrial PIF with current analog outputs (0-20 mA, 4-20 mA).
kProprietary
kTemperatureProbe

PifDetection

enum PifDetection

How the SDK came to believe what is attached.

Detection is advisory, not authoritative. The firmware cannot see a PIF at all on the PI 1 family (it cannot read the PIF EEPROM), sees nothing for a proprietary PIF or an external probe, and on an autonomous camera reports whatever its on-board type switch says -- which will hide an attached stackable PIF if the switch is set to the internal one. So an API that only reports what the firmware sees is unusable on those cameras, and SetIdentity() exists for them.

A PIF connected or powered up after the camera was opened is a different case with a different answer: it is missed because discovery ran once, at open, not because the firmware cannot see it. PifController::RedetectIdentity() runs discovery again and finds it. This note used to fold that case in with the rest and point at SetIdentity(), which on a PI camera refuses the kind involved.

Value Initialiser Description
kUnknown Nothing known yet.
kDetected The camera reported this.
kDeclared The application stated it, overriding what the camera reports.

PifTrimSource

enum PifTrimSource

Where a channel's analog trim came from.

Four states, and the last two are not the same thing. A device that applies no trim is not a device we failed to ask about one: collapsing those into a single "no trim" makes the capability question unanswerable: a query that cannot say "I do not know" is read as "the feature is absent".

Value Initialiser Description
kUnknown
kEeprom
kFileUniform
kNone

FailSafeHealth

enum FailSafeHealth

What the fail-safe line is actually doing, as opposed to what was configured.

The distinction this enum exists to draw: kBeating is the only value that says the signal is reaching the interface fast enough to keep its relay energised. The SDK's watchdog logging is about whether frames are arriving and the pipeline is finishing them -- a true statement that says nothing about the wire.

Value Initialiser Description
kDisabled No fail-safe is configured. Not a fault.
kArming
kBeating
kLate

Typedefs

Result

optris::sdk::Result< T, PifError > Result

The pif value-or-error type, for this library's own internals.

Warning: Internal. It appears on no declaration in this header and must not: the public PIF surface throws PifException. The alias is kept because src/otc_sdk/pif_controller.cc and the transforms beside it are written in terms of it, which is the arrangement optris/sdk/error.h asks for: a Result below the boundary and an exception at it. PublicResultSurfaceGuard refuses a declaration here that returns one.

Variables

kFailSafeRelayHoldTypical

constexpr std::chrono::milliseconds kFailSafeRelayHoldTypical {1100}

How long the interface's fail-safe relay stays energised after it is retriggered, on the one variant anybody has measured.

The relay is a retriggerable monoflop. Every full cycle of the line -- two edges -- retriggers it; between retriggers it is coasting on this. Measured on an industrial current PIF on a PI 400 (oscilloscope on a 24 V supply through a 10 k pull-up across the relay, supply current as a second witness): about 1.1 s, with the interface reporting a fault at about 1.5 s.

This is the only variant that has been on a scope. It is a default on PifHardwareInfo rather than a constant used directly, so a second measurement changes one field and every derived bound follows.

kFailSafePeriodDefault

constexpr std::chrono::milliseconds kFailSafePeriodDefault {100}

The heartbeat cadence the interface hardware is designed around.

Optris's hardware group's number, not the SDK's: send the heartbeat at 100 ms so a fault is caught quickly. It is also the rate the SDK's own watchdog already offers steps at (FailSafeWatchdog::MIN_SIGNAL_INTERVAL), so at this value the configured period stops fighting the internal cadence and simply agrees with it.

kFailSafePeriodMax

constexpr std::chrono::milliseconds kFailSafePeriodMax {250}

The longest period the SDK will accept, derived from kFailSafeRelayHoldTypical.

The relay is retriggered once per cycle, so the interval that has to fit inside the hold is 2 * period, not period. The breaking point is therefore around 550 ms, and 500 ms was measured holding with 100 ms to spare.

A limit at the breaking point is a limit that fails on the first late frame. The bound here is the largest period at which the SDK can miss an entire cycle -- a long NUC, a stalled USB transfer, a host under load -- and the relay still holds: 4 * 250 ms = 1.0 s, inside the 1.1 s hold. At 500 ms one missed cycle is 2.0 s, the relay releases and the interface reports a fault.

250 ms is also the largest value the reporter put a scope on and watched hold, so the bound is a measurement rather than an extrapolation.

kFailSafeActiveLevelDefault

constexpr float kFailSafeActiveLevelDefault = 1.0F

The two levels PifFailSafeConfig is born with.

They are logic levels, inherited from the digital case where they are not used at all, and they are named here rather than written twice because PifFailSafeConfig::default_to_range_endpoints is scoped by exactly this pair: the flag resolves them to the range's endpoints, and leaves anything else a caller put there alone. A default changed in the struct and not here would silently widen or narrow that scope.

kFailSafeInactiveLevelDefault

constexpr float kFailSafeInactiveLevelDefault = 0.0F