Skip to main content

viva_sfnc/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2//! Standard Feature Naming Convention (SFNC) helpers.
3
4#![allow(dead_code)]
5
6/// Exposure time feature name (`ExposureTime`).
7pub const EXPOSURE_TIME: &str = "ExposureTime";
8/// The names cameras give the exposure time, in the order to try them.
9///
10/// `ExposureTime` is SFNC 2's `<Float>` in microseconds; `ExposureTimeAbs`,
11/// SFNC 1's, is the same in microseconds; `ExposureTimeRaw` is an `<Integer>`
12/// in device units. Of the 38 vendor-corpus documents, 21 declare
13/// `ExposureTime`, 12 only `ExposureTimeAbs` (one of them as an `<Integer>`),
14/// 2 only `ExposureTimeRaw`, and 3 none of them.
15pub const EXPOSURE_TIME_NAMES: &[&str] = &["ExposureTime", "ExposureTimeAbs", "ExposureTimeRaw"];
16/// Gain feature name (`Gain`).
17pub const GAIN: &str = "Gain";
18/// The names cameras give the gain, in the order to try them.
19///
20/// `Gain` is SFNC 2's `<Float>` in dB; `GainRaw` an `<Integer>` in device
21/// units. Of the 38 vendor-corpus documents, 25 declare `Gain` (one as an
22/// `<Integer>`), 10 only `GainRaw` (one as a `<Float>`) and 3 neither; three
23/// documents name a category `Gain`, which is not the feature. `GainAbs`
24/// appears only beside `Gain`, so it would never be chosen and is not listed.
25pub const GAIN_NAMES: &[&str] = &["Gain", "GainRaw"];
26/// Gain selector feature name (`GainSelector`).
27pub const GAIN_SELECTOR: &str = "GainSelector";
28/// Pixel format feature name (`PixelFormat`).
29pub const PIXEL_FORMAT: &str = "PixelFormat";
30/// Chunk mode enable feature name (`ChunkModeActive`).
31pub const CHUNK_MODE_ACTIVE: &str = "ChunkModeActive";
32/// Chunk selector enumeration feature name (`ChunkSelector`).
33pub const CHUNK_SELECTOR: &str = "ChunkSelector";
34/// Chunk enable boolean feature name (`ChunkEnable`).
35pub const CHUNK_ENABLE: &str = "ChunkEnable";
36/// Acquisition start command feature name (`AcquisitionStart`).
37pub const ACQUISITION_START: &str = "AcquisitionStart";
38/// Acquisition stop command feature name (`AcquisitionStop`).
39pub const ACQUISITION_STOP: &str = "AcquisitionStop";
40/// Acquisition mode enumeration feature name (`AcquisitionMode`).
41pub const ACQUISITION_MODE: &str = "AcquisitionMode";
42/// The names cameras give the acquisition frame rate, in the order to try
43/// them: SFNC 2's `AcquisitionFrameRate` (22 corpus documents), then SFNC 1's
44/// `AcquisitionFrameRateAbs` (9 more, 7 of them a `<Converter>`). 7 declare
45/// neither.
46pub const FRAME_RATE_NAMES: &[&str] = &["AcquisitionFrameRate", "AcquisitionFrameRateAbs"];
47/// The names cameras give the switch that makes the frame rate apply, in the
48/// order to try them: `AcquisitionFrameRateEnable` (14 corpus documents),
49/// then `AcquisitionFrameRateEnabled` (5 more, Point Grey and FLIR). 19
50/// declare neither: their frame rate applies as written.
51pub const FRAME_RATE_ENABLE_NAMES: &[&str] =
52    &["AcquisitionFrameRateEnable", "AcquisitionFrameRateEnabled"];
53/// Trigger selector enumeration feature name (`TriggerSelector`).
54pub const TRIGGER_SELECTOR: &str = "TriggerSelector";
55/// Trigger mode enumeration feature name (`TriggerMode`): `On` or `Off` in
56/// every corpus document that has one.
57pub const TRIGGER_MODE: &str = "TriggerMode";
58/// Trigger source enumeration feature name (`TriggerSource`).
59pub const TRIGGER_SOURCE: &str = "TriggerSource";
60/// Software trigger command feature name (`TriggerSoftware`).
61pub const TRIGGER_SOFTWARE: &str = "TriggerSoftware";
62/// Image width feature name (`Width`).
63pub const WIDTH: &str = "Width";
64/// Image height feature name (`Height`).
65pub const HEIGHT: &str = "Height";
66/// Horizontal offset feature name (`OffsetX`).
67pub const OFFSET_X: &str = "OffsetX";
68/// Vertical offset feature name (`OffsetY`).
69pub const OFFSET_Y: &str = "OffsetY";
70/// Horizontal binning feature name (`BinningHorizontal`).
71pub const BINNING_HORIZONTAL: &str = "BinningHorizontal";
72/// Vertical binning feature name (`BinningVertical`).
73pub const BINNING_VERTICAL: &str = "BinningVertical";
74/// User set selector enumeration feature name (`UserSetSelector`).
75pub const USER_SET_SELECTOR: &str = "UserSetSelector";
76/// Command loading the selected user set (`UserSetLoad`).
77pub const USER_SET_LOAD: &str = "UserSetLoad";
78/// Command saving into the selected user set (`UserSetSave`).
79pub const USER_SET_SAVE: &str = "UserSetSave";
80/// The names cameras give the power-up user set, in the order to try them:
81/// SFNC 2's `UserSetDefault` (13 corpus documents), then the older
82/// `UserSetDefaultSelector` (22; 4 documents declare both).
83pub const USER_SET_DEFAULT_NAMES: &[&str] = &["UserSetDefault", "UserSetDefaultSelector"];
84/// `TLParamsLocked`: set while the host streams, so features that would
85/// change the payload are locked. An `<Integer>` in 27 corpus documents and
86/// a `<Boolean>` in 6, usually with no register behind it.
87pub const TL_PARAMS_LOCKED: &str = "TLParamsLocked";
88/// Device temperature float feature name (`DeviceTemperature`).
89pub const DEVICE_TEMPERATURE: &str = "DeviceTemperature";
90
91/// Event selector enumeration feature name (`EventSelector`).
92pub const EVENT_SELECTOR: &str = "EventSelector";
93/// Event notification mode enumeration feature (`EventNotification`).
94pub const EVENT_NOTIFICATION: &str = "EventNotification";
95/// Event notification value used to enable delivery (`On`).
96pub const EVENT_NOTIF_ON: &str = "On";
97
98/// Message channel selector aliases ordered by preference.
99pub const MSG_SEL: &[&str] = &["GevMessageChannelSelector", "MessageChannelSelector"];
100/// Message channel IP address aliases ordered by preference.
101pub const MSG_IP: &[&str] = &["GevMessageChannelIPAddress", "MessageChannelIPAddress"];
102/// Message channel UDP port aliases ordered by preference.
103pub const MSG_PORT: &[&str] = &["GevMessageChannelPort", "MessageChannelPort"];
104/// Message channel enable aliases ordered by preference.
105pub const MSG_EN: &[&str] = &["GevMessageChannelEnable", "MessageChannelEnable"];
106
107/// Stream channel selector feature name (`GevStreamChannelSelector`).
108pub const STREAM_CH_SELECTOR: &str = "GevStreamChannelSelector";
109/// Stream channel destination UDP port aliases ordered by preference.
110pub const SCP_HOST_PORT: &[&str] = &["GevSCPHostPort", "SCPHostPort"];
111/// Stream channel destination address aliases ordered by preference.
112///
113/// SFNC names it `GevSCDA` (25 documents in the vendor corpus). A multicast
114/// address here is what makes a stream multicast: SFNC has no separate
115/// "multicast enable" feature.
116pub const SCP_DEST_ADDR: &[&str] = &["GevSCDA"];
117
118/// Timestamp latch commands ordered by preference.
119///
120/// Different vendors expose the SFNC timestamp latch using slightly different
121/// identifiers. Consumers should iterate the list and execute the first command
122/// present in the nodemap.
123pub const TS_LATCH_CMDS: &[&str] = &[
124    "GevTimestampControlLatch",
125    "TimestampControlLatch",
126    "TimestampLatch",
127];
128
129/// Timestamp value nodes ordered by preference.
130///
131/// Reading the node immediately after executing the latch command returns the
132/// device tick counter captured at the time of the latch. `Timestamp` is the
133/// name USB3 Vision cameras give GenCP's latched timestamp register (0x1F0):
134/// a MATRIX VISION mvBlueFOX3-2004G and the corpus's Grasshopper3.
135pub const TS_VALUE_NODES: &[&str] = &[
136    "GevTimestampValue",
137    "TimestampValue",
138    "TimestampLatchValue",
139    "Timestamp",
140];
141
142/// Nanoseconds per timestamp tick: GenCP's Timestamp Increment register
143/// (0x1FC), under the name the same cameras give it. The tick frequency is
144/// 10⁹ over it.
145pub const TS_INCREMENT_NODES: &[&str] = &["TimestampIncrement"];
146
147/// Timestamp frequency nodes ordered by preference.
148///
149/// Returns the number of device ticks per second when present. Some cameras
150/// omit the SFNC name in favour of a shortened alias, hence the list of
151/// fallbacks.
152pub const TS_FREQ_NODES: &[&str] = &["GevTimestampTickFrequency", "TimestampTickFrequency"];
153
154/// Timestamp reset commands ordered by preference.
155///
156/// Executing any of these commands restarts the device tick counter when the
157/// camera supports it. Not every device exposes a reset capability.
158pub const TS_RESET_CMDS: &[&str] = &[
159    "GevTimestampControlReset",
160    "TimestampControlReset",
161    "TimestampReset",
162];