PifChannel
public sealed class PifChannel
One process-interface channel, as data.
Direction, signal and meaning are three separate fields rather than a class per combination, so every behaviour appears exactly once.
When the channel's own unit is a temperature: that is PifChannelKind.AmbientTemperature, PifChannelKind.InternalTemperature and a PifChannelKind.MeasurementField on a temperature statistic. Its own unit is then the SDK's temperature unit (Celsius unless Sdk.TemperatureUnit chose Fahrenheit): PifChannel.InputMinimum, PifChannel.InputMaximum and PifChannel.Threshold are temperatures in it, and PifChannel.Gain and PifChannel.Offset map that unit to the wire. The SDK keeps the mapping in Celsius and re-expresses it for the unit in force, so the same wire mapping reads back as different numbers in Fahrenheit (the gain divided by 1.8, and an offset that absorbs the 32 F shift). A PifChannelKind.MeasurementField on a standard deviation is a difference and takes no shift. Zero and zero for the clamp still mean no clamp. Every other kind (emissivity, an uncommitted value, the digital ones) is not converted.
What is on the wire is never converted. The value ProcessInterface.WriteAnalogOutput(…) takes and the value ProcessInterface.ReadAnalogInput(…) decodes follow the unit on such a channel; the level on the pin does not, because a wire value is never a temperature. ProcessInterface.ReadAnalogOutput(…), ProcessInterface.ReadRawAnalogInput(…), IOSnapshot.AnalogOutputs, IOSnapshot.RawAnalogInputs and the SignalField.AnalogOut signal answer in volts or milliamperes, the same numbers in Celsius and in Fahrenheit.
Example A digital output an application drives directly:
var relay = new PifChannel { Index = 0, Direction = PifDirection.Output, Signal = PifSignal.Digital, Kind = PifChannelKind.ExternalComm, }; pif.Configure([relay]); pif.WriteDigitalOutput(0, DigitalState.High);
PifChannel: constructors
public PifChannel()
Create a channel with the defaults.
PifChannel: properties
public float ActiveValue { get; set; }
The level this pin drives when asserted.
Levels belong to the pin rather than to whatever asserts it, because several alarm rules can share one pin and have to agree.
On an analog output these are in PifChannel.OutputRange's own unit -- volts in 0-10 V, milliamperes in 0-20 mA and 4-20 mA, never amperes. The defaults, 1 and 0, are therefore 1 mA and 0 mA on a current range, and in 4-20 mA both clamp to 4 mA, which is one converter code and no edge at all. Set them from the range.
On a digital output they are a logic level: non-zero asserts, and PifChannel.IsActiveLow inverts the electrical sense.
public int Decimals { get; set; }
Display precision for a named value.
public PifDirection Direction { get; set; }
Which way the channel carries its signal.
public float Gain { get; set; }
Conversion between the wire value and the channel's own unit.
Inputs decode as (raw - Offset) / Gain; outputs encode as Gain * value + Offset. On a channel whose own unit is a temperature, value is in the SDK's temperature unit and this reads back re-expressed for it; see PifChannel.
public float InactiveValue { get; set; }
The level it drives when not asserted.
See PifChannel.ActiveValue for the unit.
public int Index { get; set; }
The flat channel index. The SDK does the device and pin arithmetic for stacked interfaces; nothing here addresses a device.
public float InputMaximum { get; set; }
public float InputMinimum { get; set; }
Lower clamp on a decoded analog input, in the channel's own unit: the SDK's temperature unit when that is a temperature.
public float IntermediateValue { get; set; }
A third level, for kinds whose state is not binary -- the shutter is open, closed, or moving between the two.
Same unit as PifChannel.ActiveValue -- PifChannel.OutputRange's own.
public bool IsActiveLow { get; set; }
Invert a digital output's electrical sense, so "asserted" drives the line low.
public bool IsAutonomous { get; set; }
Whether the camera firmware drives this channel without a host.
Per channel, not per device: a device can run some channels unattended and leave others to the application.
public bool IsThresholdLowActive { get; set; }
Whether the channel is asserted below PifChannel.Threshold rather than above it.
public PifChannelKind Kind { get; set; }
What the channel means.
public string Name { get; set; }
The name of an uncommitted value; diagnostics for other kinds.
public float Offset { get; set; }
See PifChannel.Gain.
public AnalogRange OutputRange { get; set; }
The range an analog output drives into.
public PifSignal Signal { get; set; }
The channel's electrical nature.
public SignalField Statistic { get; set; }
Which statistic of PifChannel.Target a measurement-field channel encodes.
public int Target { get; set; }
The kind-specific target: for PifChannelKind.MeasurementField, the region id that ThermalCamera.AddRegion returned; for PifChannelKind.FlagControl, the flag channel.
The id, not the signal slot from GetRegionSignalSlot: a slot is a runtime handle that changes when a region is removed and re-added, and this value is persisted with the channel table.
AddRegion returns a UInt64 and this is an Int32. Region ids are allocated from 1 upward, so a camera's own ids fit; a target that does not fit will not resolve and the output is not driven, with a warning logged.
The output is driven on the frame the region is measured, through the channel's PifChannel.Gain, PifChannel.Offset and PifChannel.OutputRange like any other analog write. When the region produces no reading -- there is no region with that id, or it could not be measured this frame -- the pin holds its last value rather than being driven to the bottom of its range, and the condition is logged once.
public float Threshold { get; set; }
The level at which an analog input counts as asserted, for the kinds that act on a crossing rather than on a value.
In the channel's own unit: the SDK's temperature unit when that is a temperature.
Not a convenience: the Xi80 and Xi410 report zero digital inputs of any kind, so an analog input with a threshold is the only way those cameras take a signal in.
public string Unit { get; set; }
The unit of an uncommitted value.