Process Interface (PIF)
In Fahrenheit: with the SDK switched to Fahrenheit (SetTemperatureUnit() and its counterparts, see Temperatures in Fahrenheit), every temperature on this page is read and written in Fahrenheit, and every difference in Fahrenheit degrees; the samples are unchanged. What is on the wire is not a temperature and stays in volts or milliamperes in either unit: see What is on the wire.
Overview
Process interfaces (PIFs) extend camera functionality with industrial I/O channels:
- Analog inputs: read voltages (0--10 V).
- Digital inputs: read binary signals (high/low).
- Analog outputs: provide voltage or current output signals.
- Digital outputs: provide binary output signals.
- Fail-safe: a dedicated line indicating system health (see Fail Safe).
Channel counts depend on the camera model and the attached PIF variant. Typical layouts:
| PIF Variant | AI | DI | AO | DO | Fail-Safe |
|---|---|---|---|---|---|
| Standard | 1 | 1 | 1 | (none) | No |
| Industrial (mA) | 2 | 1 | 3 | (none) | Yes |
| Industrial (mV) | 2 | 1 | 3 | (none) | Yes |
| Internal | 1 | (none) | 1 | (none) | No |
| Stackable | 3 | (none) | 3 | 3 | Yes |
| Proprietary | 1 | 1 | 1 | (none) | No |
| Temperature probe | 1 | (none) | (none) | (none) | No |
The table is a guide, not a specification. Read the camera's own numbers from GetHardwareInfo(): digital_input_count, digital_output_count, analog_input_count, analog_output_count, has_fail_safe, maximum_stackable_device_count (how many stackable PIFs this camera family accepts). Every kind except the last two reports its counts from the camera. The Xi 80 and Xi 410 have no digital inputs; an analog input with a threshold does that job there. A proprietary interface and a temperature probe are invisible to the firmware, so the SDK fixes their layouts at one of each, and one analog input, respectively.
Every call that can fail throws pif::PifException on a refusal, and code() on it says which refusal it was as a PifError. The message names the specifics; branch on the code and log the message, never the other way round. The pure accessors cannot fail and return their value directly: GetIdentity(), GetHardwareInfo(), IsConnected(), GetConfiguration(), GetFailSafe(), GetFailSafeHealth(), GetSupportedDeviceKinds(), SetOutputsBlocked().
A PIF is routinely absent or unplugged, so it is worth being precise about what counts as a refusal here. Reading an input before the first frame has brought one is not a failure: ReadDigitalInput() answers DigitalState::Unknown, ReadAnalogInput() answers NaN, and ReadAll() comes back with inputs_known false. Reading back an output nothing has driven yet is not a failure either: ReadDigitalOutput() answers DigitalState::Unknown and ReadAnalogOutput() NaN, because the SDK reports what it drove and never reads an input to answer for an output. A poll loop over a working interface therefore never throws, and does not need to be wrapped in a try block. What throws is a wrong request: an index the hardware does not have, a value outside a channel's range, a PIF that is not attached.
PifController
Access the PIF through Imager::GetPif():
#include <optrissdk.h> auto pif = imager->GetPif(); if (!pif) { // No process interface at all: a simulated camera or a recording. return; } if (!pif->IsConnected()) { // This camera supports one and none is attached. return; }
optris_sdk_pif *pif = NULL; int connected = 0; if (optris_sdk_imager_acquire_pif(imager, &pif) != OPTRIS_SDK_OK) { /* No process interface at all: a simulated camera or a recording. */ return; } optris_sdk_pif_is_connected(pif, &connected); if (!connected) { /* This camera supports one and none is attached. */ optris_sdk_pif_free(pif); return; }
if (!camera.TryOpenProcessInterface(out ProcessInterface? pif)) { // No process interface at all: a simulated camera or a recording. return; } if (!pif.IsConnected) { // This camera supports one and none is attached. pif.Dispose(); return; }
pif = camera.pif() if pif is None: # No process interface at all: a simulated camera or a recording. raise SystemExit(0) if not pif.is_connected: # This camera supports one and none is attached. pif.close() raise SystemExit(0)
// Err when there is no process interface at all: a simulated camera // or a recording. let pif = camera.process_interface()?; if !pif.is_connected()? { // This camera supports one and none is attached. return Ok(()); }
GetPif() returns a std::shared_ptr<PifController>. It is nullptr only when there is no camera behind the imager to have a process interface: a simulated camera or a recording. The controller is valid as long as the imager is connected.
Imager::AttachSimulatedPif() plugs a memory-backed interface into a simulated camera; GetPif() then returns a real controller, and every path above the wire (channel table, decoded inputs, output read-back, fail-safe watchdog) is the shipping code. DetachSimulatedPif() unplugs it. Both throw FeatureNotSupportedException on a real camera.
A handle is not evidence a PIF is attached. There are three states; the handle separates only the first:
| State | GetPif() |
IsConnected() |
Enumeration's has_pif |
|---|---|---|---|
| No process interface at all (simulated, recording) | nullptr |
(none) | false |
| The camera supports one, none attached | a controller | false |
true |
| One attached | a controller | true |
true |
Detection is advisory (see Identity) and SetIdentity() is called on the controller, so every physical camera yields one whether or not anything is plugged in. Declare a PIF by hand where the firmware cannot report what is on the connector: the PI 1 family, proprietary interfaces, external probes, and autonomous cameras whose on-board type switch disagrees with the wiring. With nothing attached, a controller reports kind kNone, detection kUnknown, zero channels and IsConnected() == false.
has_pif answers a third question: whether the model supports a process interface. It is true on every supported imager, so it never distinguishes an attached PIF from an absent one. Branching on the handle alone reports a PIF on a camera that has none.
Query who is attached and what it can do:
const auto& identity = pif->GetIdentity(); const auto& info = pif->GetHardwareInfo(); std::println("PIF {}: DI={} DO={} AI={} AO={}", identity.serial, info.digital_input_count, info.digital_output_count, info.analog_input_count, info.analog_output_count);
optris_sdk_pif_identity identity; optris_sdk_pif_hardware_info info; optris_sdk_pif_identity_init(&identity, sizeof(identity)); optris_sdk_pif_get_identity(pif, &identity); optris_sdk_pif_hardware_info_init(&info, sizeof(info)); optris_sdk_pif_get_hardware_info(pif, &info); printf("PIF %s: DI=%u DO=%u AI=%u AO=%u\n", identity.serial, info.digital_input_count, info.digital_output_count, info.analog_input_count, info.analog_output_count);
if (!camera.TryOpenProcessInterface(out ProcessInterface? pif)) { Console.WriteLine("no camera behind this, so no process interface"); return; } using (pif) { Console.WriteLine($"{pif.Identity.Kind}, " + $"{pif.Hardware.DigitalOutputCount} digital outputs"); }
identity = pif.identity() info = pif.hardware_info() print(f"PIF {identity.serial}: " f"DI={info.digital_input_count} DO={info.digital_output_count} " f"AI={info.analog_input_count} AO={info.analog_output_count}")
let identity = pif.identity()?; let info = pif.hardware_info()?; println!("PIF {}: DI={} DO={} AI={} AO={}", identity.serial, info.digital_input_count, info.digital_output_count, info.analog_input_count, info.analog_output_count);
Identity: detected or declared
The camera cannot always tell which PIF is attached: the firmware cannot read the PIF EEPROM on the PI 1 family, sees nothing for a proprietary interface or an external temperature probe, and on an autonomous camera reports whatever its on-board type switch says. GetIdentity().detection is kDetected, kDeclared or kUnknown.
When detection is wrong, state what is attached:
using optris::sdk::pif::PifDeviceKind; try { pif->SetIdentity(PifDeviceKind::kStackable, 2); } catch (const optris::sdk::pif::PifException &e) { std::println("Declaration refused: {}", e.what()); }
if (optris_sdk_pif_set_identity(pif, OPTRIS_SDK_PIF_STACKABLE, 2) != OPTRIS_SDK_OK) { printf("Declaration refused: %s\n", optris_sdk_last_error_message()); }
pif.DeclareIdentity(PifDeviceKind.Stackable, 2);
pif.declare_identity(optris_sdk.DEVICE_KIND_STACKABLE, device_count=2)
pif.set_identity(PifDeviceKind::Stackable, 2)?;
GetSupportedDeviceKinds()lists the kinds this camera accepts a declaration for; offer exactly those. A kind outside the list is refused withkUnsupportedwithout reaching the camera.- A declaration the camera declines for what is on the connector right now (typically another PIF it can see) is refused with
kInvalidState, and the message names what is in the way. - Applying a declaration clears the channel table: a table configured for one PIF does not carry over. A refused declaration changes nothing.
RedetectIdentity()discards the declaration and asks the camera again.detectionis thenkDetectedif the camera named a kind,kUnknownif it named none, neverkDeclared: the previous belief is discarded before the question is asked. On an autonomous camera the declaration lives in the camera, so re-detection confirms it, askDetectedbecause the camera answered, rather than undoing it; declarekNoneor reopen the camera to undo it there.- A refused re-detection leaves the controller exactly as it was, as a refused declaration does. A thrown
PifExceptionwhosecode()isPifError::kUnsupportedmeans this backend cannot be asked again. A camera that can be asked and sees nothing is not an error: it answerskNone/kUnknownand nothing is thrown.
The rest of PifIdentity: device_count (physical devices the flat channel space spans, more than one only for a stackable PIF), serial, firmware_version. firmware_version of 0 means "not reported", never "revision zero". Every camera is asked, not only the autonomous ones, because the PIF EEPROM a PI reads carries no firmware field. A camera whose firmware does not answer, or answers about a different PIF than the EEPROM describes, leaves it at 0.
Note: That last path is unverified on a PI camera. No PIF has been attached to one since the probe was written, so whether a PI's firmware answers the command at all is not yet known from hardware.
pif.DeclareIdentity(PifDeviceKind.Standard);
The declared kind reshapes the hardware report:
// An Xi 410 whose type switch says nothing is attached, with a // stackable box actually wired up. if (pif.Identity.Detection == PifDetection.Unknown) { pif.DeclareIdentity(PifDeviceKind.Stackable, 1); // Hardware now reports 3 analog in, 3 analog out, 3 digital out. pif.WriteAnalogOutput(0, 5.0f); }
And re-detection asks the camera again:
pif.RedetectIdentity(); // Detected when the camera named a kind, Unknown when it named none. // Never Declared. Console.WriteLine(pif.Identity.Detection);
Configuring Channels
A channel carries no meaning until it is configured; only configured channels are decoded and published as alarm signals. Configure() applies the whole table at once and validates it in full before writing anything. A rejected table leaves the device as it was, and the error names the channel and the problem.
using namespace optris::sdk::pif; PifChannelConfig emissivity; emissivity.index = 0; emissivity.direction = PifDirection::kInput; emissivity.signal = PifSignal::kAnalog; emissivity.kind = PifChannelKind::kEmissivity; // Inputs decode as (raw - offset) / gain: 10 V per unit emissivity, // so 9.5 V reads 0.95. emissivity.gain = 10.0F; emissivity.input_min = 0.1F; emissivity.input_max = 1.0F; PifChannelConfig marker; marker.index = 0; marker.direction = PifDirection::kOutput; marker.signal = PifSignal::kDigital; marker.kind = PifChannelKind::kExternalComm; // driven by you or a rule try { pif->Configure({emissivity, marker}); } catch (const optris::sdk::pif::PifException &e) { std::println("Configure failed: {}", e.what()); }
optris_sdk_pif_channel_config channels[2]; optris_sdk_pif_channel_config_init(&channels[0], sizeof(channels[0])); channels[0].index = 0; channels[0].direction = OPTRIS_SDK_PIF_INPUT; channels[0].signal = OPTRIS_SDK_PIF_SIGNAL_ANALOG; channels[0].kind = OPTRIS_SDK_PIF_KIND_EMISSIVITY; /* Inputs decode as (raw - offset) / gain: 10 V per unit emissivity, * so 9.5 V reads 0.95. */ channels[0].gain = 10.0F; channels[0].input_min = 0.1F; channels[0].input_max = 1.0F; optris_sdk_pif_channel_config_init(&channels[1], sizeof(channels[1])); channels[1].index = 0; channels[1].direction = OPTRIS_SDK_PIF_OUTPUT; channels[1].signal = OPTRIS_SDK_PIF_SIGNAL_DIGITAL; channels[1].kind = OPTRIS_SDK_PIF_KIND_EXTERNAL_COMM; if (optris_sdk_pif_configure(pif, channels, sizeof(channels[0]), 2) != OPTRIS_SDK_OK) { printf("Configure failed: %s\n", optris_sdk_last_error_message()); }
var emissivity = new PifChannel { Index = 0, Direction = PifDirection.Input, Signal = PifSignal.Analog, Kind = PifChannelKind.Emissivity, // Inputs decode as (raw - offset) / gain: 10 V per unit // emissivity, so 9.5 V reads 0.95. Gain = 10.0f, InputMinimum = 0.1f, InputMaximum = 1.0f, }; var marker = new PifChannel { Index = 0, Direction = PifDirection.Output, Signal = PifSignal.Digital, Kind = PifChannelKind.ExternalComm, // driven by you or a rule }; pif.Configure([emissivity, marker]);
emissivity = optris_sdk.PifChannelConfig( index=0, direction=optris_sdk.DIRECTION_INPUT, signal=optris_sdk.SIGNAL_ANALOG, kind=optris_sdk.KIND_EMISSIVITY, # Inputs decode as (raw - offset) / gain: 10 V per unit # emissivity, so 9.5 V reads 0.95. gain=10.0, input_min=0.1, input_max=1.0) marker = optris_sdk.PifChannelConfig( index=0, direction=optris_sdk.DIRECTION_OUTPUT, signal=optris_sdk.SIGNAL_DIGITAL, # External comm -- driven by you or a rule. The binding names # no constant for this kind yet; 9 is # OPTRIS_SDK_PIF_KIND_EXTERNAL_COMM. kind=9) pif.configure([emissivity, marker])
let mut emissivity = PifChannelConfig::new()?; emissivity.index = 0; emissivity.direction = PifDirection::Input; emissivity.signal = PifSignal::Analog; emissivity.kind = PifChannelKind::Emissivity; // Inputs decode as (raw - offset) / gain: 10 V per unit emissivity, // so 9.5 V reads 0.95. emissivity.gain = 10.0; emissivity.input_min = 0.1; emissivity.input_max = 1.0; let mut marker = PifChannelConfig::new()?; marker.index = 0; marker.direction = PifDirection::Output; marker.signal = PifSignal::Digital; marker.kind = PifChannelKind::ExternalComm; // driven by you or a rule pif.configure(&[emissivity, marker])?;
PifChannelKind says what a channel means:
| Kind | Direction | Meaning |
|---|---|---|
kEmissivity |
input | decodes to an emissivity |
kAmbientTemperature |
input | decodes to an ambient temperature |
kUncommittedValue |
input | decodes to a named value the SDK does not act on |
kFlagControl |
input | threshold crossing: gives the pin the camera's shutter, see Shutter Control |
kResetPeakValleyHold |
input | threshold crossing: resets peak/valley hold |
kFlagStatus |
output | flag status |
kFrameSync |
output | frame sync |
kInternalTemperature |
output | an internal temperature |
kMeasurementField |
output | a region statistic |
kAlarm |
output | alarm state |
kExternalComm |
output | whatever the application writes |
gain and offset convert between the wire value and the channel's own unit; outputs encode as gain * value + offset.
To watch a digital input without letting it drive anything, configure it as kUncommittedValue, the monitor-only kind on a digital pin: the firmware mode stays off, the wire drives nothing, and the level arrives with each frame as SignalField::kDigitalIn for an alarm rule or an inhibit to read. The only other kind a digital input takes, kFlagControl, watches the pin by giving it the camera's shutter: not something to do to an input wired to an operator switch or a PLC line.
pif.Configure([ new PifChannel { Index = 0, Direction = PifDirection.Output, Signal = PifSignal.Digital, Kind = PifChannelKind.ExternalComm, }, new PifChannel { Index = 0, Direction = PifDirection.Input, Signal = PifSignal.Analog, Kind = PifChannelKind.UncommittedValue, Name = "pressure", Unit = "bar", Decimals = 2, }, ]);
Shutter Control: giving the flag to an input
An input configured as PifChannelKind::kFlagControl is Shutter Control: the camera's shutter flag stops being the SDK's and becomes the wire's.
What it is for
A shutter cycle takes something over a second and delivers no frames at all, so one landing in the middle of a part being measured loses the measurement. Instead of letting the SDK choose the moment, wire a digital input to the machine and close the flag from it in the break between two parts. That closure is when the camera corrects.
It is not "disable the shutter": the correction still happens, as often as the process allows; only the choice of moment changes.
Who owns the flag
The camera firmware. The SDK writes the pin's firmware mode and polarity; the flag then follows the wire at that polarity, so it can be shut on either level. The firmware only moves the flag: it computes no correction, which remains the host's work from the frames the shut flag gives it.
What the SDK does not do while an input has the flag
For as long as any input is in Shutter Control:
- No automatic shutter cycle, whatever the automatic schedule says. The schedule is not altered, it is not consulted.
- No startup calibration cycle. Opening the camera skips the flag cycles it would normally run.
TriggerShutter()is refused, with an error naming the reason. In C it isOPTRIS_SDK_ERROR_NOT_SUPPORTED; in C++ and .NET aFeatureNotSupportedException.
Ask before you offer the control:
if (imager->Detector().IsShutterExternallyControlled()) { // The process interface owns the flag. Disable your own shutter // controls and say why, rather than offering one that throws. }
int externally_controlled = 0; optris_sdk_imager_get_shutter_externally_controlled( imager, &externally_controlled); if (externally_controlled) { /* The process interface owns the flag. Disable your own shutter * controls and say why, rather than offering one that fails. */ }
if (camera.IsShutterExternallyControlled) { // The process interface owns the flag. Disable your own shutter // controls and say why, rather than offering one that throws. }
if camera.detector.shutter_externally_controlled: # The process interface owns the flag. Disable your own shutter # controls and say why, rather than offering one that raises. pass
if camera.shutter_externally_controlled()? { // The process interface owns the flag. Disable your own shutter // controls and say why, rather than offering one that errs. }
Read that rather than inferring it from the table your own code sent: it answers from what was applied to the camera, so it cannot disagree with the behaviour, and it survives a reconnect, which re-applies the table and re-derives the answer.
Do not switch the automatic shutter off yourself. The SDK already does not run it, and turning it off in the application would leave it off after the input went back to kOff.
What an application sees while the interface holds the flag
Everything that reports the shutter reports the interface's closures, exactly as it reports the SDK's own:
| What | While the interface holds the flag shut |
|---|---|
| The shutter notification | Closing, Closed, Opening and Open as the camera reports them, with both timestamps |
SignalField::kFlagOpen (device) |
0 |
SignalField::kNucInProgress (device) |
1: the shutter is in the way, so a reading taken now is not of the scene |
SignalField::kFlag (PIF, indexed by the owning pin) |
1 while that input is holding the flag |
A frame's IsFlagOpen |
false |
| Frames | still delivered, which is the whole point |
| The temperatures in those frames | held at the last open frame's values, and for a few frames after the reopen |
The picture during a closure is of the flag, not of the scene, so the temperature output is held rather than measured from it. A frame whose IsFlagOpen is false is not a measurement: skip it rather than plotting or alarming on it.
SignalField::kFlag is published only while an input owns the flag. A rule on it otherwise reads orphaned, so "nothing is holding the flag" cannot be confused with "no input is configured to hold it".
Watching the flag move, not just arrive
The shutter notification reports the flag travelling as well as arrived: Closing on its way shut, Closed when the camera confirms it, Opening when it starts back, Open when it is there. It is the same sequence an SDK-driven cycle produces, so an application need not know who moved the flag.
An intention without its result is how a flag that sticks, or moves only part of the way, shows up; a closure reported only once it has arrived cannot tell you about one that never did.
These come from the camera, not from the SDK: telemetry byte 11 carries the two transitional positions and the SDK publishes what it finds there.
A camera that does not report them is not broken. What a device can distinguish is a property of its firmware: one that drives the flag from the pin while reporting only "open" and "closed" produces no Closing and no Opening, and the Closed/Open pair is all there is. The SDK does not synthesise a transition from the input's level, because that would report an intention the camera never confirmed, and a stuck-flag signal must not invent one. Drive a display from Closed and Open and treat the other two as additional information when the camera offers them.
Finding out what your camera reports: OTC_LOG_SHUTTER_BYTE
Set OTC_LOG_SHUTTER_BYTE before starting your application and the SDK writes one line per delivered frame to stderr, saying what the camera put in the frame and what the SDK made of it:
OTC_LOG_SHUTTER_BYTE=all # every frame OTC_LOG_SHUTTER_BYTE=2000 # the first 2000 frames
SHUTTERBYTE serial=22042036 frame=412 backend=gpu byte11=3 (closing) flag_open=1 owner=process-interface published=Closing SHUTTERBYTE serial=22042036 frame=413 backend=gpu byte11=1 (closed) flag_open=0 owner=process-interface published=Closed
| Field | What it carries |
|---|---|
byte11 |
The camera's own value, with the protocol's name: 0 open, 1 closed, 2 opening, 3 closing. A closure that never shows a 2 or a 3 means your firmware does not report them: nothing is wrong, and the transitional states will not appear on the notification either. |
backend |
Which pipeline decoded it, so one run answers the question on the pipeline that machine actually uses. |
owner |
Whether an input held the flag at that moment, so a log taken before the interface was configured cannot be mistaken for one taken after. |
frame |
Counts the lines, so a value that never moves across a closure you know happened is visible as exactly that. It counts per camera: on a multi-camera host read it with serial. |
serial |
The camera this line is about. Every camera in the process writes to the same stderr, so without it fifteen cameras' lines are one inseparable interleaved stream. |
It is off unless set, writes nothing otherwise, and goes to stderr rather than through the SDK's log so it cannot be reordered against it. Read once at startup: changing the variable while the application runs has no effect.
When a position the camera announced does not arrive, the notification reports Error and the closure counts toward the fail-safe's shutter-stops-cycling check, as an SDK-driven cycle does when its shutter never reports the state it was asked for. The budget is the one the SDK gives its own shutter: at least two seconds, never fewer than four frame periods, so a camera delivering 4 fps over a long USB link is judged on its own rate. It counts once per unconfirmed transition, and the flag arriving late, or turning back the way it came, clears it.
Error means the shutter was asked for a position and has not taken it. It does not mean a closure was too short to correct from; the two are reported separately.
The correction
Every closure the interface makes produces one. The SDK collects shut-flag frames for as long as the flag stays shut, up to a cap, computes the new reference at the reopen, and applies it with the usual post-correction frame handling.
A closure too short to average a reference from is skipped, and the previous reference is kept. Below four shut-flag frames the average is one or two frames' noise, which as a per-pixel offset on every later frame is measurably worse than not correcting, and stays worse until a longer pause. The closure is still reported: "the flag shut" and "a correction was taken" are different questions. Exception: the first closure after the camera opens has no previous reference to keep, and the picture is unusable without one, so it is used however short it was.
The floor is a change from version 11. v11 applied whatever it had collected whenever at least one frame was left after its ignored frames, and reported an error only when it had collected nothing. A machine whose breaks are consistently brief therefore gets a fresh reference on v11 and keeps the previous one on v12: steadier, and older. If your process cannot afford to skip, lengthen the closure rather than lowering the floor.
Knowing which of those happened
Subscribe to the correction outcome. It fires once per closure, at the reopen, and carries whether the reference was taken, how many frames went into it, the floor they were judged against, and how long the flag was shut:
imager->SetShutterCorrectionCallback( [](const optris::sdk::ShutterCorrectionEvent &outcome) { if (outcome.outcome == optris::sdk::ShutterCorrectionOutcome::kSkippedTooShort) { // The break was too short: outcome.frames_used of // outcome.frames_required, in outcome.closed_ms milliseconds. } });
optris_sdk_imager_set_shutter_correction_callback(imager, OnCorrection, NULL);
camera.OnShutterCorrection(outcome => { if (outcome.Outcome == ShutterCorrectionOutcome.SkippedTooShort) { // The break was too short: outcome.FramesUsed of // outcome.FramesRequired, in outcome.Closed. } });
def on_correction(outcome): if outcome.outcome == optris_sdk.SHUTTER_CORRECTION_SKIPPED_TOO_SHORT: # The break was too short: outcome.frames_used of # outcome.frames_required, in outcome.closed_ms milliseconds. pass camera.detector.on_shutter_correction(on_correction)
camera.on_shutter_correction(|outcome| { if outcome.outcome == ShutterCorrectionOutcome::SkippedTooShort { // The break was too short: outcome.frames_used of // outcome.frames_required, in outcome.closed_ms milliseconds. } })?;
Three outcomes; the third is not a variant of the other two:
| Outcome | What it means |
|---|---|
kApplied |
Enough frames. A new reference is in force. |
kSkippedTooShort |
Below the floor, and there was a reference to keep, so it was kept. Nothing about the measurement changed. |
kAppliedWithoutAReferenceToKeep |
Below the floor, and there was no reference at all, so this one was used. The first closure after the camera opens. |
kSkippedTooShort is not a fault to report to an operator on its own; one brief break is normal. A pattern of them is worth reporting: a line whose breaks are consistently that short never gets a fresh reference.
It fires at the reopen and not at the closure, because until the flag opens there is no answer: the closure's own duration is the capture window.
Detector::GetLastShutterCorrection() returns the most recent outcome, for an application that installed its handler after a closure had already happened. Its sequence is 0 when nothing has been reported: also the answer on a camera whose flag no interface has taken, on a simulated camera and on a recording.
Taking the flag while the SDK is mid-cycle
Configuring an input into Shutter Control stops the SDK starting a cycle, and ends one already running: the part-collected reference is discarded, the previous one is kept, and a line in the log says so. The camera's correction then comes from the closure the interface makes.
This is not a rare race. An application restoring a saved layout writes its process-interface table in the first seconds after the camera opens, exactly when the startup calibration runs; that calibration ends there rather than going on to command a flag that is no longer the SDK's.
It is not reported as Error and does not count toward the shutter-stops-cycling check.
Turning it off
Configure the pin as something else, or leave it out of the table. A channel table is the whole truth about the device and every pin not named in it is parked, so a table without a Shutter Control input hands the flag back to the SDK: the automatic cycle and TriggerShutter() work again.
Digital and Analog I/O
using optris::sdk::pif::DigitalState; // Inputs. Most PIFs report their inputs with a frame, so before the // first frame a digital input reads Unknown and an analog input NaN. if (pif->ReadDigitalInput(0) == DigitalState::High) { // Input 0 is high. } float value = pif->ReadAnalogInput(0); std::println("AI0 = {:.3f}", value); // in the channel's unit // Outputs. pif->WriteDigitalOutput(0, DigitalState::High); pif->WriteAnalogOutput(0, 5.5F); // in the channel's unit auto out = pif->ReadDigitalOutput(0); // what the SDK drove
optris_sdk_digital_state state; float value = 0.0F; /* Inputs. Before the first frame a digital input reads Unknown and * an analog input NaN. */ if (optris_sdk_pif_read_digital_input(pif, 0, &state) == OPTRIS_SDK_OK && state == OPTRIS_SDK_DIGITAL_HIGH) { /* Input 0 is high. */ } if (optris_sdk_pif_read_analog_input(pif, 0, &value) == OPTRIS_SDK_OK) { printf("AI0 = %.3f\n", (double)value); /* in the channel's unit */ } /* Outputs. */ optris_sdk_pif_write_digital_output(pif, 0, OPTRIS_SDK_DIGITAL_HIGH); optris_sdk_pif_write_analog_output(pif, 0, 5.5F); optris_sdk_pif_read_digital_output(pif, 0, &state); /* what was driven */
// Inputs. Before the first frame a digital input reads Unknown and // an analog input NaN. if (pif.TryReadDigitalInput(0, out DigitalState state) && state == DigitalState.High) { // Input 0 is high. } if (pif.TryReadAnalogInput(0, out float value)) { Console.WriteLine($"AI0 = {value:F3}"); // in the channel's unit } // Outputs. pif.WriteDigitalOutput(0, DigitalState.High); pif.WriteAnalogOutput(0, 5.5f); // in the channel's unit DigitalState back = pif.ReadDigitalOutput(0); // what the SDK drove
# Inputs. Before the first frame a digital input reads UNKNOWN and an # analog input NaN. if pif.read_digital_input(0) == optris_sdk.DIGITAL_HIGH: pass # Input 0 is high. value = pif.read_analog_input(0) print(f"AI0 = {value:.3f}") # in the channel's unit # Outputs. pif.write_digital_output(0, optris_sdk.DIGITAL_HIGH) pif.write_analog_output(0, 5.5) # in the channel's unit back = pif.read_digital_output(0) # what the SDK drove
// Inputs. Before the first frame a digital input reads Unknown and // an analog input NaN. if pif.read_digital_input(0)? == DigitalState::High { // Input 0 is high. } let value = pif.read_analog_input(0)?; println!("AI0 = {value:.3}"); // in the channel's unit // Outputs. pif.write_digital_output(0, DigitalState::High)?; pif.write_analog_output(0, 5.5)?; // in the channel's unit let back = pif.read_digital_output(0)?; // what the SDK drove
An index beyond the hardware's channel count throws PifException with code() PifError::kOutOfRange. SetOutputsBlocked(true) holds every output at its inactive level without losing the configuration or alarm state, for while a process is knowingly disturbed. The outputs resume when it is released, and AreOutputsBlocked() reports the state.
The fail-safe heartbeat is the one exception: it keeps alternating through a block, on whichever destination carries it. A heartbeat that stopped because outputs were blocked would report a fault the camera does not have.
Note: Analog inputs read voltages between 0 V and 10 V. Values above 10 V register as 10 V. Due to calibration offsets, the SDK may report values slightly above 0 V when pins are floating or slightly above 10 V at the upper end.
pif.WriteDigitalOutput(0, DigitalState.High); DigitalState back = pif.ReadDigitalOutput(0); pif.WriteAnalogOutput(0, 4.2f);
And the Try forms answer false before the first frame:
if (pif.TryReadDigitalInput(0, out DigitalState state)) { Console.WriteLine(state); } if (pif.TryReadAnalogInput(0, out float bar)) { Console.WriteLine($"{bar:F2} bar"); }
What is on the wire
A wire value is never a temperature. ReadAnalogOutput() reads back the level the SDK drove onto the pin, in the unit of the channel's output range: volts in 0-10 V, milliamperes in 0-20 mA and 4-20 mA, and volts on an output with no channel configured. A snapshot's analog_outputs, ReadRawAnalogInput() and a snapshot's raw_analog_inputs are the same kind of number, and so is the kAnalogOut signal an alarm rule can watch. All of them read the same in Celsius and in Fahrenheit.
On a temperature channel that is not the number written. With 0.1 V per degree and 0.5 V at zero, WriteAnalogOutput(0, 50.0F) in Celsius, or WriteAnalogOutput(0, 122.0F) in Fahrenheit, puts 5.5 V on the wire, and ReadAnalogOutput(0) answers 5.5 in both. What follows the unit is the temperature itself: the value WriteAnalogOutput() takes, the value ReadAnalogInput() decodes from an input such as an ambient temperature, and the kAnalogIn signal. Up to 12.0.27 a program in Fahrenheit read the 5.5 converted as if it were a temperature, 41.9.
Batch Reads
ReadAll() reads every channel in one transaction, so the values cannot skew against each other:
const auto snapshot = pif->ReadAll(); std::println("Timestamp: {} us", snapshot.timestamp_us); if (!snapshot.inputs_known) { std::println("No frame yet: inputs are not known."); } for (size_t i = 0; i < snapshot.analog_inputs.size(); ++i) { std::println("AI[{}] = {:.3f}", i, snapshot.analog_inputs[i]); }
optris_sdk_io_snapshot *snapshot = NULL; if (optris_sdk_pif_acquire_snapshot(pif, &snapshot) == OPTRIS_SDK_OK) { uint64_t timestamp_us = 0; float values[16]; size_t written = 0; size_t i; optris_sdk_io_snapshot_get_timestamp_us(snapshot, ×tamp_us); printf("Timestamp: %llu us\n", (unsigned long long)timestamp_us); optris_sdk_io_snapshot_get_analog_inputs(snapshot, values, 16, &written); for (i = 0; i < written; ++i) { printf("AI[%u] = %.3f\n", (unsigned)i, (double)values[i]); } optris_sdk_io_snapshot_free(snapshot); }
IOSnapshot io = pif.ReadAll(); Console.WriteLine($"Timestamp: {io.Timestamp}"); for (int i = 0; i < io.AnalogInputs.Count; i++) { Console.WriteLine($"AI[{i}] = {io.AnalogInputs[i]:F3}"); }
snapshot = pif.snapshot() print(f"Timestamp: {snapshot.timestamp_us} us") if not snapshot.inputs_known: print('No frame yet: inputs are not known.') for i, value in enumerate(snapshot.analog_inputs): print(f"AI[{i}] = {value:.3f}")
let snapshot = pif.read_all()?; println!("Timestamp: {} us", snapshot.timestamp_us()?); if !snapshot.inputs_known()? { println!("No frame yet: inputs are not known."); } for (i, value) in snapshot.analog_inputs()?.iter().enumerate() { println!("AI[{i}] = {value:.3}"); }
IoSnapshot holds:
| Field | Type | Description |
|---|---|---|
digital_inputs |
std::vector<DigitalState> |
One state per digital input. |
digital_outputs |
std::vector<DigitalState> |
One state per digital output, as driven by the SDK. |
analog_inputs |
std::vector<float> |
One value per analog input, decoded into the channel's own unit. An input with no channel configured over it has no unit of its own and reads in volts. |
raw_analog_inputs |
std::vector<float> |
The same inputs as they are on the wire, in volts in either temperature unit, before any channel decode: what a multimeter on the pin would show. Transaction-consistent with analog_inputs, at no extra device traffic. |
analog_inputs_clamped |
std::vector<bool> |
Whether each decoded value was held at its configured input_min / input_max. The answer to "is my sensor saturated or is my slope wrong?". False for a channel with no bounds, an unconfigured channel, and while inputs_known is false. |
analog_outputs |
std::vector<float> |
One value per analog output, as driven by the SDK: the level on the wire, in volts or milliamperes, the same in Celsius and in Fahrenheit. See What is on the wire. |
timestamp_us |
uint64_t |
Camera clock, microseconds. |
inputs_known |
bool |
False before the first frame on a PIF whose inputs arrive with frames; the inputs then read Unknown / NaN. Outputs are valid throughout. |
fail_safe_level |
DigitalState |
The level commanded on the dedicated fail-safe terminals, or Unknown. What the SDK drove, not a measurement; no PIF reports that terminal back. Not a health indicator, and not in digital_outputs either: the dedicated line has no index, and this field is its only read-back. See Fail-Safe. |
ReadRawAnalogInput(index) is the single-read counterpart of raw_analog_inputs, and the only way to reach the wire value on a configured channel: with gain 0.1 and 4.0 V on the pin, ReadAnalogInput() answers 40.0 and nothing else answered 4.0. It is always in volts, configured or not, and NaN until the first reading arrives. A handler registered with OnDecodedInput() may call it for the index it was handed: the decoded value and the wire reading come from the same poll.
In C++, imager->GetTelemetry() carries the same wire readings for the first two analog inputs, as pif_analog_in_1 and pif_analog_in_2: the voltage each pin had in the camera's last frame, after the interface's own trim. They are NaN wherever ReadRawAnalogInput(0) and ReadRawAnalogInput(1) would be NaN or refuse: no interface attached or declared, an interface with fewer inputs, no frame yet, and every recording or snapshot. pif_digital_in has one bit per digital input that reads high, and pif_digital_out one bit per digital output the SDK last drove high; a bitmask cannot say "no reading", so use ReadDigitalInput() where Unknown matters. The other languages have no telemetry getter and read these values through the process interface calls on this page.
IOSnapshot io = pif.ReadAll(); Console.WriteLine($"at {io.Timestamp}: " + $"{string.Join(", ", io.DigitalInputs)}");
Reacting to Inputs
There are no per-channel change handlers or threshold objects on the controller. Every configured channel is published as an alarm signal, SignalId::Pif(channel, field) with field one of kDigitalIn, kDigitalOut, kAnalogIn, kAnalogOut or kFailSafe. Reacting to an input is therefore a Rule, with the hysteresis, warning bands, delays, latching and actions (callback, snapshot, recording, PIF output) that come with one. See Alarms.
using namespace optris::sdk; // Ring while analog input 0 is above 5 V, with 0.5 V hysteresis. Rule high_level; high_level.name = "AI0 high"; high_level.input = SignalId::Pif(0, SignalField::kAnalogIn); high_level.condition.compare = Compare::kAbove; high_level.condition.alarm.high = 5.0F; high_level.condition.alarm.hysteresis = 0.5F; imager->Alarms().Add(std::move(high_level)); // Any change on digital input 0. Rule edge; edge.name = "DI0 changed"; edge.input = SignalId::Pif(0, SignalField::kDigitalIn); edge.condition.compare = Compare::kChanged; imager->Alarms().Add(std::move(edge)); imager->Alarms().SetCallback([](const AlarmEvent& e) { std::println("{}: {} -> {} ({:.3f})", e.rule_name, ToString(e.previous), ToString(e.current), e.value); });
optris_sdk_rule *high_level = NULL; optris_sdk_signal_id input; optris_sdk_condition condition; uint64_t rule_id = 0; /* Ring while analog input 0 is above 5 V, with 0.5 V hysteresis. */ optris_sdk_rule_create(&high_level); optris_sdk_rule_set_name(high_level, "AI0 high"); optris_sdk_signal_id_init(&input, sizeof(input)); input.domain = OPTRIS_SDK_SIGNAL_DOMAIN_PIF; input.field = OPTRIS_SDK_FIELD_ANALOG_IN; input.index = 0; optris_sdk_rule_set_input(high_level, &input); optris_sdk_condition_init(&condition, sizeof(condition)); condition.compare = OPTRIS_SDK_COMPARE_ABOVE; condition.alarm.high = 5.0F; condition.alarm.hysteresis = 0.5F; optris_sdk_rule_set_condition(high_level, &condition); optris_sdk_imager_add_rule(imager, 0, high_level, &rule_id); optris_sdk_rule_free(high_level); optris_sdk_imager_register_alarm_callback(imager, OnAlarm, NULL);
// Ring while analog input 0 is above 5 V, with 0.5 V hysteresis. var highLevel = new AlarmRule { Name = "AI0 high", Input = SignalId.ProcessInterface(0, SignalField.AnalogIn), Condition = AlarmCondition.Above(5.0f, hysteresis: 0.5f), }; camera.AddRule(highLevel); // Any change on digital input 0. var edge = new AlarmRule { Name = "DI0 changed", Input = SignalId.ProcessInterface(0, SignalField.DigitalIn), Condition = new AlarmCondition { Compare = AlarmCompare.Changed }, }; camera.AddRule(edge);
# Ring while analog input 0 is above 5 V, with 0.5 V hysteresis. high_level = optris_sdk.Rule( name='AI0 high', input=optris_sdk.SignalId.pif(optris_sdk.FIELD_ANALOG_IN, 0), condition=optris_sdk.Condition( compare=optris_sdk.COMPARE_ABOVE, alarm=optris_sdk.Limits(high=5.0, hysteresis=0.5))) camera.alarms.add(high_level) # Any change on digital input 0. # COMPARE_CHANGED is spelled through the alarms module; the package # re-exports the other five compares at the top level but not yet # this one. edge = optris_sdk.Rule( name='DI0 changed', input=optris_sdk.SignalId.pif(optris_sdk.FIELD_DIGITAL_IN, 0), condition=optris_sdk.Condition( compare=optris_sdk.alarms.COMPARE_CHANGED, alarm=optris_sdk.Limits(high=0.0))) camera.alarms.add(edge) camera.alarms.on_alarm( lambda e: print(f"{e.rule_name}: {e.previous} -> {e.current} " f"({e.value:.3f})"))
// Ring while analog input 0 is above 5 V, with 0.5 V hysteresis. let mut high_level = Rule::new()?; high_level.set_name("AI0 high")?; high_level.set_input(SignalId::pif(SignalField::AnalogIn, 0))?; high_level.set_condition(Condition::above(5.0, 0.5))?; camera.add_rule(0, &high_level)?; // Any change on digital input 0. let mut edge = Rule::new()?; edge.set_name("DI0 changed")?; edge.set_input(SignalId::pif(SignalField::DigitalIn, 0))?; let mut changed = Condition::above(0.0, 0.0); changed.compare = Compare::Changed; edge.set_condition(changed)?; camera.add_rule(0, &edge)?; camera.on_alarm(|e| { println!("{}: {:?} -> {:?} ({:.3})", e.rule_name, e.previous, e.current, e.value); })?;
While the camera is streaming, inputs arrive with each frame and are published at once. Without a stream, call pif->Poll() to read the inputs, publish them and dispatch handlers.
The one handler on the controller is OnDecodedInput(), for observing the decoded emissivity, ambient temperature and uncommitted-value inputs that feed the measurement. It observes only: the SDK has already applied the value when it is called.
pif->OnDecodedInput([](uint8_t index, optris::sdk::pif::PifChannelKind /*kind*/, float value) { std::println("channel {}: {}", index, value); }); pif->Poll();
optris_sdk_pif_set_input_callback(pif, OnDecoded, NULL); optris_sdk_pif_poll(pif);
pif.OnInputDecoded(value => Console.WriteLine($"channel {value.ChannelIndex}: {value.Value}")); pif.Poll();
pif.on_input(lambda index, kind, value: print(f"channel {index}: {value}")) pif.poll()
Fail-Safe
The PIF controller configures which channel carries the fail-safe line; it does not drive it. The fail-safe watchdog does, stepping the line on every health check that passes and withholding it on every check that fails.
pif::PifFailSafeConfig fail_safe; fail_safe.enabled = true; // The dedicated terminal pair, which has no index. For kDigital or // kAnalog instead, set `index` -- and check it against // GetHardwareInfo(): an output this PIF does not have is refused. fail_safe.signal = pif::PifSignal::kFailSafe; // Shortest interval between edges. Zero means "on every passed check". // Bounded by GetHardwareInfo().fail_safe_max_period -- a longer period // is refused, because the interface's relay cannot hold it. fail_safe.period = pif::kFailSafePeriodDefault; // 100 ms try { pif->SetFailSafe(fail_safe); } catch (const optris::sdk::pif::PifException &e) { std::println("Fail-safe not available: {}", e.what()); } // What is in force now. const auto ¤t = pif->GetFailSafe();
To stop the heartbeat from the application, call imager->Device().InterruptFailSafe(true, "reason").
SetFailSafe() refuses a period above GetHardwareInfo().fail_safe_max_period (250 ms on every interface today) with PifError::kOutOfRange rather than clamping it, refuses an index beyond the hardware's output count with the same code, and refuses the never-implemented on_alarm and on_flag_timeout with PifError::kUnsupported. Each arrives as a thrown PifException carrying that code.
The line alternates on whichever destination carries it, the dedicated terminals included; it is the edges that retrigger the interface's relay. It keeps alternating through SetOutputsBlocked(true). When a condition fails the stepping stops and the level stays where it was: that is the fault indication.
Read what the line is doing from pif->GetFailSafeHealth(): kBeating is the only state that says edges are reaching the interface fast enough to hold its relay, kArming that no heartbeat has arrived yet, kLate that the relay has released (including when the camera reports that it cannot reach a Stackable PIF). Do not use IoSnapshot::fail_safe_level as a health indicator; it is the instantaneous level of a line whose job is to alternate.
There is no SetFailSafeEnabled, IsFailSafeActive, TriggerFailSafe, ResetFailSafe or OnFailSafe.
See the Fail Safe page for details on conditions and PIF signal types.
Camera Temperatures
The camera's own temperatures are not PIF values. Read them from the imager's telemetry:
const auto t = imager->GetTelemetry(); // The detector is the one probe that can be absent rather than cold: // `chip_temp_c` is 0.0 and `chip_temp_known` false on a camera whose // detector count does not decode. std::println("Box={:.1f} C, Flag={:.1f} C", t.box_temp_c, t.flag_temp_c); if (t.chip_temp_known) { std::println("Chip={:.1f} C", t.chip_temp_c); } else { std::println("Chip: no reading from this camera"); }
optris_sdk_frame_info info; optris_sdk_frame_info_init(&info, sizeof(info)); optris_sdk_frame_get_info(frame, &info); printf("Box=%.1f C, Flag=%.1f C\n", (double)info.box_temp_c, (double)info.flag_temp_c);
FrameMetadata meta = frame.Metadata; Console.WriteLine($"Flag={meta.FlagTemperature:F1} C");
print(f"Box={frame.box_temp_c:.1f} C, Flag={frame.flag_temp_c:.1f} C")
let info = frame.info()?; if let (Some(housing), Some(flag)) = (info.box_temp_c, info.flag_temp_c) { println!("Box={housing:.1} C, Flag={flag:.1} C"); }
To act on one, write a rule on SignalId::Device(...), for example SignalId::Device(SignalField::kChipTemp).
An external temperature probe arrives over the PIF connector but is not a channel: it has no index, no gain and no direction, so it is read on its own:
if (auto probe = pif->GetExternalProbeTemperature()) std::println("Probe = {:.1f} C", *probe);
float probe = 0.0F; optris_sdk_status status = optris_sdk_pif_get_external_probe_temperature(pif, &probe); if (status == OPTRIS_SDK_OK) { printf("Probe = %.1f C\n", (double)probe); } else if (status == OPTRIS_SDK_ERROR_NOT_FOUND) { /* Not declared a temperature probe, none fitted, or no frame yet. */ printf("No probe reading\n"); }
if (pif.ExternalProbeTemperature is float probe) { Console.WriteLine($"Probe = {probe:F1} C"); }
probe = pif.external_probe_temperature() if probe is not None: print(f"Probe = {probe:.1f} C")
if let Some(probe) = pif.external_probe_temperature()? { println!("Probe = {probe:.1} C"); }
nullopt on a camera with no probe fitted, and until the first frame that carries a reading. Whether a frame carries a reading is decided at the frame decode, per camera family, by the probe's I2C bus answering validly: a read nothing acknowledged counts as no probe, never as a temperature, so an unpopulated connector reads nullopt rather than a full-scale 511.9375 C. Declare the interface with SetIdentity(PifDeviceKind::kTemperatureProbe): the firmware cannot see a probe, so it has to be stated, and without that declaration there is no reading at all, whatever the frame carries. Cameras without a probe carry other values in the same telemetry bytes: up to 12.0.20 the SDK reported 10.125 C from a PI 640 with an Industrial (mA) PIF and 34.1 C from a PI 4x0i with nothing on the connector. The reading is also published as SignalField::kProbeTemp on the device domain, so an interlock on the reference probe is an ordinary rule: SignalId::Device(SignalField::kProbeTemp). Version 11 hid this value in the first slot of the PIF analog output array.
Complete Example
#include <optrissdk.h> #include <chrono> #include <print> #include <thread> using namespace optris::sdk; using namespace optris::sdk::pif; int main() { auto imager = Imager::Create(); auto pif = imager->GetPif(); if (!pif) { std::println("No camera hardware behind this imager."); return 1; } const auto& info = pif->GetHardwareInfo(); std::println("PIF serial: {}", pif->GetIdentity().serial); std::println(" AI={} DI={} AO={} DO={}", info.analog_input_count, info.digital_input_count, info.analog_output_count, info.digital_output_count); if (!pif->IsConnected()) { std::println("Nothing detected. Declare it with SetIdentity()."); return 1; } // Analog input 0 as a plain value in volts, so a rule can watch it. if (info.analog_input_count > 0) { PifChannelConfig level; level.index = 0; level.direction = PifDirection::kInput; level.signal = PifSignal::kAnalog; level.kind = PifChannelKind::kUncommittedValue; level.name = "level"; level.unit = "V"; try { pif->Configure({level}); } catch (const optris::sdk::pif::PifException &e) { std::println("Configure failed: {}", e.what()); return 1; } Rule crossing; crossing.name = "level above 5 V"; crossing.input = SignalId::Pif(0, SignalField::kAnalogIn); crossing.condition.compare = Compare::kAbove; crossing.condition.alarm.high = 5.0F; crossing.condition.alarm.hysteresis = 0.3F; imager->Alarms().Add(std::move(crossing)); imager->Alarms().SetCallback([](const AlarmEvent& e) { std::println("{} -> {} at {:.3f} V", e.rule_name, ToString(e.current), e.value); }); } // Put the fail-safe heartbeat on the dedicated line. From here it // alternates on its own, driven by frames arriving and the pipeline // finishing them. if (info.has_fail_safe) { PifFailSafeConfig fail_safe; fail_safe.enabled = true; fail_safe.signal = PifSignal::kFailSafe; fail_safe.period = std::chrono::milliseconds{100}; try { pif->SetFailSafe(fail_safe); } catch (const optris::sdk::pif::PifException &e) { std::println("Fail-safe not available: {}", e.what()); } } imager->Start(); for (int i = 0; i < 5; ++i) { std::this_thread::sleep_for(std::chrono::seconds(2)); const IoSnapshot snap = pif->ReadAll(); if (snap.inputs_known) { for (size_t j = 0; j < snap.analog_inputs.size(); ++j) { std::println(" AI[{}]={:.3f}", j, snap.analog_inputs[j]); } } if (info.has_fail_safe) { std::println(" fail-safe: {}", pif->GetFailSafeHealth().detail); } } imager->Stop(); return 0; }
optris_sdk_imager *camera = NULL; optris_sdk_pif *pif = NULL; optris_sdk_pif_identity identity; optris_sdk_pif_hardware_info info; int connected = 0; optris_sdk_imager_create(&camera); if (optris_sdk_imager_acquire_pif(camera, &pif) != OPTRIS_SDK_OK) { printf("No camera hardware behind this imager.\n"); return 1; } optris_sdk_pif_identity_init(&identity, sizeof(identity)); optris_sdk_pif_get_identity(pif, &identity); optris_sdk_pif_hardware_info_init(&info, sizeof(info)); optris_sdk_pif_get_hardware_info(pif, &info); printf("PIF serial: %s\n", identity.serial); printf(" AI=%u DI=%u AO=%u DO=%u\n", info.analog_input_count, info.digital_input_count, info.analog_output_count, info.digital_output_count); optris_sdk_pif_is_connected(pif, &connected); if (!connected) { printf("Nothing detected. Declare it with set_identity().\n"); return 1; } /* Analog input 0 as a plain value in volts, so a rule can watch it. */ if (info.analog_input_count > 0) { optris_sdk_pif_channel_config level; optris_sdk_rule *crossing = NULL; optris_sdk_signal_id input; optris_sdk_condition condition; uint64_t rule_id = 0; optris_sdk_pif_channel_config_init(&level, sizeof(level)); level.index = 0; level.direction = OPTRIS_SDK_PIF_INPUT; level.signal = OPTRIS_SDK_PIF_SIGNAL_ANALOG; level.kind = OPTRIS_SDK_PIF_KIND_UNCOMMITTED_VALUE; optris_sdk_pif_configure(pif, &level, 1); optris_sdk_rule_create(&crossing); optris_sdk_rule_set_name(crossing, "level above 5 V"); optris_sdk_signal_id_init(&input, sizeof(input)); input.domain = OPTRIS_SDK_SIGNAL_DOMAIN_PIF; input.field = OPTRIS_SDK_FIELD_ANALOG_IN; optris_sdk_rule_set_input(crossing, &input); optris_sdk_condition_init(&condition, sizeof(condition)); condition.compare = OPTRIS_SDK_COMPARE_ABOVE; condition.alarm.high = 5.0F; condition.alarm.hysteresis = 0.3F; optris_sdk_rule_set_condition(crossing, &condition); optris_sdk_imager_add_rule(camera, 0, crossing, &rule_id); optris_sdk_rule_free(crossing); } /* Put the fail-safe heartbeat on the dedicated line. */ if (info.has_fail_safe) { optris_sdk_pif_fail_safe_config fail_safe; optris_sdk_pif_fail_safe_config_init(&fail_safe, sizeof(fail_safe)); fail_safe.enabled = 1; fail_safe.signal = OPTRIS_SDK_PIF_SIGNAL_FAIL_SAFE; fail_safe.period_ms = 100; optris_sdk_pif_set_fail_safe(pif, &fail_safe); } optris_sdk_imager_start(camera); /* ... read snapshots with optris_sdk_pif_read_all() as above ... */ optris_sdk_imager_stop(camera); optris_sdk_pif_free(pif); optris_sdk_imager_destroy(camera);
using Optris.Sdk; await using ThermalCamera camera = ThermalCamera.Open(); if (!camera.TryOpenProcessInterface(out ProcessInterface? pif)) { Console.WriteLine("No camera hardware behind this imager."); return; } using (pif) { PifHardwareInfo info = pif.Hardware; Console.WriteLine($"PIF serial: {pif.Identity.Serial}"); Console.WriteLine($" AI={info.AnalogInputCount} " + $"DI={info.DigitalInputCount} " + $"AO={info.AnalogOutputCount} " + $"DO={info.DigitalOutputCount}"); if (!pif.IsConnected) { Console.WriteLine("Nothing detected. Declare it with " + "DeclareIdentity()."); return; } // Analog input 0 as a plain value in volts, so a rule can watch it. if (info.AnalogInputCount > 0) { pif.Configure([new PifChannel { Index = 0, Direction = PifDirection.Input, Signal = PifSignal.Analog, Kind = PifChannelKind.UncommittedValue, Name = "level", Unit = "V", }]); camera.AddRule(new AlarmRule { Name = "level above 5 V", Input = SignalId.ProcessInterface(0, SignalField.AnalogIn), Condition = AlarmCondition.Above(5.0f, hysteresis: 0.3f), }); } // Put the fail-safe heartbeat on the dedicated line. if (info.HasFailSafe) { pif.FailSafe = new FailSafeConfiguration { IsEnabled = true, Signal = PifSignal.FailSafe, Period = TimeSpan.FromMilliseconds(100), }; } camera.Start(); // ... read snapshots with pif.ReadAll() as above ... camera.Stop(); }
import optris_sdk camera = optris_sdk.Camera.open() pif = camera.pif() if pif is None: raise SystemExit("No camera hardware behind this imager.") info = pif.hardware_info() print(f"PIF serial: {pif.identity().serial}") print(f" AI={info.analog_input_count} DI={info.digital_input_count} " f"AO={info.analog_output_count} DO={info.digital_output_count}") if not pif.is_connected: raise SystemExit("Nothing detected. Declare it with " "declare_identity().") # Analog input 0 as a plain value in volts, so a rule can watch it. if info.analog_input_count > 0: pif.configure([optris_sdk.PifChannelConfig( index=0, direction=optris_sdk.DIRECTION_INPUT, signal=optris_sdk.SIGNAL_ANALOG, kind=optris_sdk.pif.KIND_UNCOMMITTED_VALUE, name='level', unit='V')]) camera.alarms.add(optris_sdk.Rule( name='level above 5 V', input=optris_sdk.SignalId.pif(optris_sdk.FIELD_ANALOG_IN, 0), condition=optris_sdk.Condition( compare=optris_sdk.COMPARE_ABOVE, alarm=optris_sdk.Limits(high=5.0, hysteresis=0.3)))) # Put the fail-safe heartbeat on the dedicated line. if info.has_fail_safe: pif.fail_safe = optris_sdk.PifFailSafeConfig( enabled=True, signal=optris_sdk.SIGNAL_FAIL_SAFE, period_ms=100) camera.start() # ... read snapshots with pif.snapshot() as above ... camera.stop() camera.close()
let mut camera = Camera::open()?; // Err when there is no camera hardware behind this imager. let mut pif = camera.process_interface()?; let identity = pif.identity()?; let info = pif.hardware_info()?; println!("PIF serial: {}", identity.serial); println!(" AI={} DI={} AO={} DO={}", info.analog_input_count, info.digital_input_count, info.analog_output_count, info.digital_output_count); if !pif.is_connected()? { println!("Nothing detected. Declare it with set_identity()."); return Ok(()); } // Analog input 0 as a plain value in volts, so a rule can watch it. if info.analog_input_count > 0 { let mut level = PifChannelConfig::new()?; level.index = 0; level.direction = PifDirection::Input; level.signal = PifSignal::Analog; level.kind = PifChannelKind::UncommittedValue; level.name = "level".to_string(); level.unit = "V".to_string(); pif.configure(&[level])?; } // Put the fail-safe heartbeat on the dedicated line. if info.has_fail_safe { let mut fail_safe = PifFailSafeConfig::new()?; fail_safe.enabled = true; fail_safe.signal = PifSignal::FailSafe; fail_safe.period_ms = 100; pif.set_fail_safe(fail_safe)?; } // The rule on the decoded input is the same Rule as anywhere else: // SignalId::pif(SignalField::AnalogIn, 0), Condition::above(5.0, 0.3). drop(pif); camera.start()?; camera.stop()?;