Skip to main content

Crate viva_fake_gige

Crate viva_fake_gige 

Source
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§

BlockSpec
What one block looks like on the wire.
CommandCounters
Per-command, per-address count of register-access commands received.
Datagram
One GVSP datagram, labelled for scripting.
DiscoveryRequest
One DISCOVERY_CMD the fake received.
FakeCamera
Handle to a running fake GigE Vision camera.
FakeCameraBuilder
Builder for configuring and starting a fake GigE Vision camera.
MessageChannelStats
What a fake camera’s message channel did: FakeCamera::message_channel.
PacketScript
A deterministic list of ScriptSteps, keyed by block and packet id.
ResendStats
A snapshot of the fake’s resend counters.

Enums§

GvcpCommand
The four GVCP register-access commands, as the fake counts them.
PacketKind
Which part of a block a datagram is.
RegisterCommandRefusal
How the fake refuses READREG and WRITEREG when told to.
ScriptStep
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-endian u32s; ChunkImageLength reads 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 UserSetLoad loads Default.
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 EVENTDATA carrying 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, from viva-pfnc (ADR-0030).
MONO16
PFNC Mono16. Sent as a byte ramp — byte i of block b is (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
ChunkEnable for 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
GainRaw of GainSelector entry n lives at REG_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> with AccessMode WO whose <StructEntry> bits each pulse one software signal.
REG_TIMESTAMP_VALUE
REG_TRIGGER_MODE
TriggerMode of the trigger at index n lives at REG_TRIGGER_MODE + 4n; 1 is On.
REG_TRIGGER_SELECTOR
TriggerSelector: which trigger TriggerMode, TriggerSource and TriggerSoftware act on. FrameStart is 0, AcquisitionStart 1; the selected value indexes the mode and source registers (<pIndex>, as the Basler acA1600 and Hikrobot documents address theirs).
REG_TRIGGER_SOURCE
TriggerSource of the trigger at index n lives at REG_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: writing n saves the current settings into user set n. Default cannot be saved: the XML makes the command unavailable while it is selected, and the fake ignores a write of 0.
REG_USER_SET_SELECTOR
REG_USER_SET_SELECTOR, REG_USER_SET_LOAD and REG_USER_SET_SAVE back 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
TriggerSource value of Line1, the source the fake boots with.
TRIGGER_SOURCE_SOFTWARE
TriggerSource value of Software.
WRITE_ONLY_REGISTERS
Registers the XML declares WO. Reading any of them is refused with ACCESS_DENIED, as a real device refuses it.

Functions§

block_datagrams
Every datagram of one block in transmission order: the leader, payload split at the block’s stride — an image, or a chunk_payload — and the trailer.
chunk_payload
Lay chunks out 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, a first; the longer one’s tail follows.