Expand description
In-process fake GigE Vision camera for testing and demos.
This crate provides a simulated GigE Vision camera that speaks real GVCP/GVSP protocols over UDP on localhost. It is intended for integration testing and demonstrations without requiring physical camera hardware or external tools like aravis.
§Example
use viva_fake_gige::FakeCamera;
let camera = FakeCamera::builder()
.width(640)
.height(480)
.fps(30)
.bind_ip([127, 0, 0, 1].into())
.build()
.await
.expect("failed to start fake camera");
// Camera is now discoverable on the configured port.
// Use viva_genicam::gige::discover() to find it.
// When done:
camera.stop().await;Structs§
- Block
Spec - What one block looks like on the wire.
- Command
Counters - Per-command, per-address count of register-access commands received.
- Datagram
- One GVSP datagram, labelled for scripting.
- Discovery
Request - One
DISCOVERY_CMDthe fake received. - Fake
Camera - Handle to a running fake GigE Vision camera.
- Fake
Camera Builder - Builder for configuring and starting a fake GigE Vision camera.
- Message
Channel Stats - What a fake camera’s message channel did:
FakeCamera::message_channel. - Packet
Script - A deterministic list of
ScriptSteps, keyed by block and packet id. - Resend
Stats - A snapshot of the fake’s resend counters.
Enums§
- Gvcp
Command - The four GVCP register-access commands, as the fake counts them.
- Packet
Kind - Which part of a block a datagram is.
- Register
Command Refusal - How the fake refuses READREG and WRITEREG when told to.
- Script
Step - One deterministic change to the datagrams of a block.
- XmlProfile
- Which GenApi XML the fake serves.
Constants§
- CHUNK_
ID_ EXPOSURE_ TIME ChunkExposureTime: IEEE 754 double, little-endian.- CHUNK_
ID_ FRAME_ ID ChunkFrameID: the block id, 8 bytes little-endian.- CHUNK_
ID_ IMAGE - Chunk IDs on this fake’s chunk ports, as its XML declares them. A real camera’s are whatever its XML says; two here are above 0xFFFF, which a 16-bit ID could not carry.
- CHUNK_
ID_ IMAGE_ INFO ImageInfo: width, height, reserved, image length — four big-endianu32s;ChunkImageLengthreads the last at address-4.- CHUNK_
ID_ TIMESTAMP ChunkTimestamp: the leader’s timestamp, 8 bytes little-endian.- CHUNK_
SELECTOR_ FRAME_ ID ChunkSelector=FrameID.- DEFAULT_
EXPOSURE_ US - Exposure the fake boots with, and returns to when
UserSetLoadloadsDefault. - DEFAULT_
MESSAGE_ RETRY_ COUNT - This fake’s
GevMCRC: retransmissions before an event message is abandoned. - DEFAULT_
MESSAGE_ TIMEOUT_ MS - This fake’s
GevMCTT: milliseconds before an unacknowledged event message is sent again. - EVENT_
EXPOSURE_ END - GigE Vision event identifier this fake sends for ExposureEnd, as an
EVENTDATAcarrying the frame id. Device-specific range, this fake’s own choice; its event port declares<EventID>9001</EventID>. - FAKE_
DEVICE_ KEY - Action keys the fake accepts. A command whose keys do not match is ignored without an acknowledgement, which is how a real device behaves — the command is broadcast to every camera on the subnet and only the addressed group acts.
- FAKE_
GROUP_ KEY - Group key the fake belongs to.
- FAKE_
GROUP_ MASK - Group mask bits the fake responds to.
- FAKE_
MAC - MAC address the fake camera reports. Public so tests can assert the exact bytes rather than merely that a MAC is present (ADR-0019).
- FAKE_
MANUFACTURER - Manufacturer name reported in the Discovery ACK.
- FAKE_
MODEL - Model name reported in the Discovery ACK.
- FAKE_
SERIAL - Serial number reported in the Discovery ACK.
- FAKE_
SUBNET_ MASK - Subnet mask the fake reports unless told otherwise: loopback’s
/8, the network every test fake lives on. - FAKE_
USER_ NAME - User-defined name reported in the Discovery ACK.
- FAKE_
VERSION - Device version reported in the Discovery ACK.
- FAKE_
XML - GenApi XML describing a realistic fake camera following SFNC conventions.
- MONO8
- PFNC
Mono8, the fake’s default pixel format. PFNC codes are vocabulary, fromviva-pfnc(ADR-0030). - MONO16
- PFNC
Mono16. Sent as a byte ramp — byteiof blockbis(i × 7 + b) mod 256— which a test can recompute exactly. - MONO12P
- PFNC
Mono12p: 12-bit pixels packed LSB-first. - MONO12_
PACKED - GigE Vision
Mono12Packed: two 12-bit pixels in three bytes. - PAYLOAD_
TYPE_ EXTENDED_ CHUNK_ DATA - Payload type: GigE Vision 1.x’s extended chunk data, what an Allied Vision Manta G-125B sends with chunk mode on. Its leader is an image’s; its trailer is reserved | payload type | payload data length | Size Y | chunk layout ID.
- PAYLOAD_
TYPE_ IMAGE_ EXTENDED_ CHUNK - Payload type: image with extended chunk data (bit 14 set on image).
- REG_
ACQ_ FRAME_ RATE - REG_
ACQ_ FRAME_ RATE_ ENABLE - Predicate-gating registers driving realistic feature behaviour.
- REG_
ACQ_ MODE - Acquisition registers.
- REG_
ACQ_ START - REG_
ACQ_ STOP - REG_
BINNING_ HORIZONTAL BinningHorizontal, 1 to 4.- REG_
BINNING_ VERTICAL BinningVertical, 1 to 4.- REG_
BLACK_ LEVEL - REG_
CHUNK_ ENABLE ChunkEnablefor the selected chunk: a selected feature, backed by the set of enabled selector values (RegisterMap::chunk_enabled).- REG_
CHUNK_ MODE_ ACTIVE - Chunk data registers.
- REG_
CHUNK_ SELECTOR - REG_
DEVICE_ MODEL_ NAME - Device info string registers.
- REG_
DEVICE_ TEMPERATURE DeviceTemperature_Val: the sensor temperature in 1/256 °C, which the camera changes on its own — no write moves it. The XML declares it the way FLIR’s BFS does (FLIR_BFS_PGE_31S4C_C.xml):NoCache, with a<PollingTime>of 500 ms, behind a<Converter>and a<Float>. A client that caches it shows the first reading forever (backlog GA-05).- REG_
DEVICE_ USER_ BUFFER DeviceUserBuffer: a read-write<Register>, sixteen bytes the camera stores as written — the shape of a vendor’s user data area.- REG_
DEVICE_ USER_ ID DeviceUserID: SFNC’s user-settable name, a read-write<StringReg>.- REG_
EXPOSURE_ AUTO - REG_
EXPOSURE_ TIME - Analog control registers.
- REG_
GAIN - REG_
GAIN_ AUTO - REG_
GAIN_ RAW GainRawofGainSelectorentrynlives atREG_GAIN_RAW + 4n(legacy profile only).- REG_
HEIGHT - REG_
OFFSET_ X - REG_
OFFSET_ Y - REG_
PIXEL_ FORMAT - REG_
SENSOR_ TYPE - REG_
SOFTWARE_ SIGNAL_ PULSE - A write-only register addressed bit by bit: a
<StructReg>withAccessMode WOwhose<StructEntry>bits each pulse one software signal. - REG_
TIMESTAMP_ VALUE - REG_
TRIGGER_ MODE TriggerModeof the trigger at indexnlives atREG_TRIGGER_MODE + 4n;1isOn.- REG_
TRIGGER_ SELECTOR TriggerSelector: which triggerTriggerMode,TriggerSourceandTriggerSoftwareact on.FrameStartis 0,AcquisitionStart1; the selected value indexes the mode and source registers (<pIndex>, as the Basler acA1600 and Hikrobot documents address theirs).- REG_
TRIGGER_ SOURCE TriggerSourceof the trigger at indexnlives atREG_TRIGGER_SOURCE + 4n.- REG_
USER_ SET_ DEFAULT UserSetDefault(SFNC 2) or, in the legacy profile,UserSetDefaultSelector: the set the camera loads at power-up.- REG_
USER_ SET_ SAVE UserSetSave: writingnsaves the current settings into user setn.Defaultcannot be saved: the XML makes the command unavailable while it is selected, and the fake ignores a write of0.- REG_
USER_ SET_ SELECTOR REG_USER_SET_SELECTOR,REG_USER_SET_LOADandREG_USER_SET_SAVEback the SFNC user-set features, so the fake can answer the workflow issue #121 was filed about.- REG_
WIDTH - Image format registers.
- RGB8
- PFNC
RGB8(RGB8Packed). - TRIGGER_
SOURCE_ LINE1 TriggerSourcevalue ofLine1, the source the fake boots with.- TRIGGER_
SOURCE_ SOFTWARE TriggerSourcevalue ofSoftware.- WRITE_
ONLY_ REGISTERS - Registers the XML declares
WO. Reading any of them is refused withACCESS_DENIED, as a real device refuses it.
Functions§
- block_
datagrams - Every datagram of one block in transmission order: the leader,
payloadsplit at the block’s stride — an image, or achunk_payload— and the trailer. - chunk_
payload - Lay
chunksout as a GigE Vision chunk payload, in order: each chunk’s data, then its tag — chunk ID and data length, 32-bit big-endian each. - image_
size - Bytes an image of this format occupies on the wire, by the fake’s own rule.
- interleave
- Alternate two blocks’ datagrams,
afirst; the longer one’s tail follows.