Pif
class optris_sdk.pif.Pif
One camera's process interface.
Obtained from Camera.pif, which returns None on a
camera that has none. Use it as a context manager, or close it: it
holds a handle the SDK hands out and expects back.
Pif — properties
is_connected
Whether the device is still there.
A PIF is routinely unplugged. This is the question to ask before blaming a write for failing.
analog_calibration
The device-wide analog calibration the file declared.
What the calibration file says, in converter steps, and the
controller applies none of it. channel_trim is what the
device actually does.
fail_safe
The fail-safe watchdog's configuration.
The readback half of the setter: an application can now show an operator which channel carries the line and at what period, and restore it, without keeping its own copy.
outputs_blocked
Whether the outputs are held at rest.
Block them while the process is knowingly disturbed; releasing puts them straight back to whatever drives them.
Pif — methods
identity()
Who is attached.
hardware_info()
What it can do.
configure(channels)
Declare what every channel is for, as one table.
The whole table is validated before any of it is sent to the camera, and a bad entry leaves the previous table in place -- so this either takes effect entirely or not at all.
configuration()
The channel table currently configured, one entry each.
This is the readback half of configure. Without it an
application had to keep its own shadow copy of what it wrote,
so it could neither show an operator what the interface is set
to nor restore it after a restart.
Empty on an interface with nothing configured over it, which is a real answer rather than a failure: a channel carries no meaning until it has been given one.
declare_identity(kind, device_count = 1)
Say what is attached, when the camera cannot tell.
Required on the PI 1 family, for a proprietary interface, for an external temperature probe, and on an autonomous camera whose type switch disagrees with what is physically there.
This is not how an interface that connected after the camera
was opened is found -- redetect_identity is, on every
camera that can detect its interface at all. Declaring is for
the kinds a camera cannot see, and
supported_device_kinds is the list to offer a user so
a declaration the camera would refuse is never reached.
This clears the channel table: a table configured against one interface does not carry over to a different one. A camera that refuses the declaration leaves everything exactly as it was.
redetect_identity()
Ask the camera again what is attached.
This is how an interface that was powered up or plugged in
after the camera was opened is found. Offer it as "automatic"
beside supported_device_kinds.
supported_device_kinds()
The interface kinds that can be declared on this camera.
A camera family accepts a subset, so offering the rest in a user interface offers configurations that cannot be applied.
These are not the kinds that can be attached. On a PI
camera a Standard or Industrial interface is read from its own
EEPROM and can never be declared, so it is absent here while
being a perfectly normal value of
PifIdentity.kind. Render the attached kind from the
identity; offer this list as the choice.
supported_analog_output_range(index)
One of the analog output ranges the hardware supports.
index is zero-based, below
PifHardwareInfo.supported_analog_output_range_count.
Past the end raises optris_sdk.OutOfRangeError.
supported_analog_output_ranges()
Every analog output range the hardware supports.
The count comes from the hardware description rather than from a sentinel, so this never asks for a range past the end.
channel_trim(direction, index)
What one analog channel's converter actually does.
direction is ANALOG_INPUT or ANALOG_OUTPUT, and it
also selects the converter scale the answer is in -- the two
directions do not share one.
Check PifChannelTrim.source before believing the gain
and the offset.
fail_safe_health()
What the fail-safe line is actually doing.
Measured rather than asserted, and answered at the moment of the call from the time since the last edge -- so a heartbeat that has stopped is reported as stopped.
read_digital_input(channel)
One digital input's state.
DIGITAL_UNKNOWN is a real answer: a line not read yet, or
one on a device no longer attached.
read_digital_output(channel)
What one digital output is being driven to.
The readback of write_digital_output, including a level
an alarm rule is holding rather than something this process
wrote.
DIGITAL_UNKNOWN when nothing has driven it since the
interface was attached or last configured, as a snapshot's
digital_outputs reports that pin on a camera. Never the
level of an input: up to 12.0.28 an undriven output answered
with the digital input of the same index on a simulated
interface, and raised on a camera.
read_analog_output(channel)
What one analog output is being driven to, as it is on the wire.
In the channel's output range's own unit: volts in 0-10 V,
milliamperes in 0-20 mA and 4-20 mA, volts on an output with no
channel configured. The same number in Celsius and in
Fahrenheit: a wire value is never a temperature, so on a
temperature channel this is not the number
write_analog_output took. 50 C written at 0.1 V per
degree and 0.5 V at zero (122 F in Fahrenheit) reads back 5.5
in either unit; up to 12.0.27 Fahrenheit answered 41.9.
NaN when nothing has driven it since the interface was attached or last configured. Never the reading of an input: up to 12.0.28 an undriven output answered with the analog input of the same index on a simulated interface, and raised on a camera.
snapshot()
Read every input and output in one pass.
on_input(handler)
Call handler(index, kind, value) on a decoded input.
The value arrives in its own unit, which is what declaring the
channel's kind bought you: a temperature channel's in the SDK's
temperature unit (Celsius unless
optris_sdk.set_temperature_unit chose Fahrenheit).
This is a data path, not an alarm. Something that should
react to a PIF value is an alarm rule instead --
optris_sdk.SignalId addresses a PIF channel exactly
as it addresses a region.
read_analog_input(channel)
One analog input, in its channel's configured unit.
A temperature channel's unit is the SDK's temperature unit
(Celsius unless optris_sdk.set_temperature_unit chose
Fahrenheit).
A channel with no configuration over it has no unit of its own
and reads in volts, the same unit as
read_raw_analog_input. nan before the first reading
has arrived.
read_raw_analog_input(channel)
One analog input as it is on the wire, in volts.
What a multimeter on that pin would show, before any channel
decode. read_analog_input answers in the channel's own
unit, so on a configured channel the wire reading used to be
unobtainable: with gain 0.1 and 4.0 V on the pin it answers
40.0, and nothing answered 4.0.
Always volts, whether or not a channel is configured, and in
either temperature unit. nan before the first reading has
arrived.
external_probe_temperature()
The external temperature probe's reading, in the SDK's
temperature unit (Celsius unless
optris_sdk.set_temperature_unit chose Fahrenheit).
None on a camera with no probe fitted, and until the first
frame that carries a reading.
Only while the interface is declared a temperature probe
(DEVICE_KIND_TEMPERATURE_PROBE): no camera can detect a
probe, so the declaration is the only way one is known. On any
other interface, and on a camera with none, this is None
whatever the frame carries.
The probe is its own measurement, not a channel: it has no
index, no gain and no direction. Declaring
DEVICE_KIND_TEMPERATURE_PROBE made the identity read back
and nothing returned a temperature -- the frame path decoded
the probe and the controller kept it, reachable only from
inside the SDK.
The same reading is published as FIELD_PROBE_TEMP on the
device domain, so an interlock on the reference probe is an
ordinary alarm rule rather than a poll.
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 (the bus's all-zero or
all-ones non-answer) counts as no probe, never as a
temperature, so an unpopulated connector reads None
rather than a full-scale 511.9375 C.
write_digital_output(channel, state)
Drive one digital output high or low.
write_analog_output(channel, value)
Drive one analog output to a value.
In the channel's output range's own unit; on an output
configured as a temperature channel, a temperature in the SDK's
temperature unit (Celsius unless
optris_sdk.set_temperature_unit chose Fahrenheit),
which the channel's gain and offset turn into the level
on the wire. read_analog_output reads back that level,
not the temperature.
poll()
Advance the controller once.
Reads the inputs, decodes them and dispatches
on_input. The call rate is yours to choose.
It deliberately does not touch the fail-safe line: that is driven by the fail-safe watchdog, on frames arriving and the pipeline finishing them, so that it means "the camera is healthy" rather than "this loop is still running".