pub struct FakeCameraBuilder { /* private fields */ }Expand description
Builder for configuring and starting a fake GigE Vision camera.
Implementations§
Source§impl FakeCameraBuilder
impl FakeCameraBuilder
Sourcepub fn pixel_format(self, code: u32) -> Self
pub fn pixel_format(self, code: u32) -> Self
Sourcepub fn zip_xml(self, enable: bool) -> Self
pub fn zip_xml(self, enable: bool) -> Self
Serve the GenApi XML as a ZIP archive (default: plain XML).
Many real cameras (Basler, FLIR, Hikrobot, …) publish their register-description XML zipped; enable this to exercise that path.
Sourcepub fn zip_xml_extra(self, extra: &[u8]) -> Self
pub fn zip_xml_extra(self, extra: &[u8]) -> Self
Serve the GenApi XML as a ZIP archive whose headers carry extra as
their extra field (default: none). Implies Self::zip_xml.
The bytes are written as given, valid ZIP extra records or not: a
Basler acA2440-20gc serves 20 bytes starting with GCV0 that are not
(issue #236).
Sourcepub fn enforce_heartbeat(self, enable: bool) -> Self
pub fn enforce_heartbeat(self, enable: bool) -> Self
Release control privilege when the controller stops sending GVCP commands
for longer than GevHeartbeatTimeout (default: off).
Every real device behaves this way; it is off by default because it makes every test that holds control sensitive to a 3 s stall, a flake on a loaded CI runner. Tests that are about the keepalive turn it on.
Sourcepub fn max_packet_size(self, max: u32) -> Self
pub fn max_packet_size(self, max: u32) -> Self
Clamp GevSCPSPacketSize to max, the way a real camera caps it.
A request above max is acknowledged and silently reduced, so the
register reads back lower than what was written. Off by default: the
fake accepts any size, which is what every existing test expects.
The fake accepted anything until 0.4.1, so it could not express the camera behind #112 and no test could have caught that defect — the ADR-0019 failure mode of a fake that only ever agrees with its client.
Sourcepub fn max_on_wire(self, max: u32) -> Self
pub fn max_on_wire(self, max: u32) -> Self
Silently drop any GVSP datagram larger than max, as a network path
with a smaller frame ceiling than either endpoint believes does.
Different from FakeCameraBuilder::max_packet_size, and the
difference is the whole of
#112: that
camera accepts and stores 16114, then streams nothing, because the
link tops out at a 9216-byte frame. No register read can find that —
only a test packet can.
Sourcepub fn refuse_register_commands(self, refusal: RegisterCommandRefusal) -> Self
pub fn refuse_register_commands(self, refusal: RegisterCommandRefusal) -> Self
Refuse every READREG and WRITEREG, as a device that implements only the memory commands would (default: serve them).
The only way to exercise a controller’s fallback from register to memory access without hardware that lacks the register commands. The refused command changes nothing on the device, so a test can tell a write that fell back from one that was silently lost.
Sourcepub fn extended_ids(self, enable: bool) -> Self
pub fn extended_ids(self, enable: bool) -> Self
Send 20-byte extended-ID GVSP headers with 64-bit block ids and 32-bit packet ids (GigE Vision 2.0), as a LUCID TRT009S-E does (default: off).
The stride shrinks by the 12 extra header bytes, so a receiver that assumes the 8-byte header places every packet after the first 12 bytes too far.
Sourcepub fn chunk_payload_type(self, payload_type: u16) -> Self
pub fn chunk_payload_type(self, payload_type: u16) -> Self
Send chunk-mode blocks with payload_type instead of 0x4001: an
Allied Vision Manta G-125B sends GigE Vision 1.x’s extended chunk data,
PAYLOAD_TYPE_EXTENDED_CHUNK_DATA (0x0005), in the layout that
constant describes.
Sourcepub fn payload_type(self, payload_type: u16) -> Self
pub fn payload_type(self, payload_type: u16) -> Self
Put payload_type in every leader and trailer instead of 0x0001
(0x4001 while chunk mode is active).
Sourcepub fn delivered_lines(self, lines: u32) -> Self
pub fn delivered_lines(self, lines: u32) -> Self
Send only the first lines lines of every image, with lines in the
trailer’s Size Y, as a variable-height line-scan camera ends a frame
early; the leader keeps Height. Ignored in chunk mode.
Sourcepub fn packet_script(self, script: PacketScript) -> Self
pub fn packet_script(self, script: PacketScript) -> Self
Damage the stream deterministically: drop, repeat or reorder packets by block and packet id. Block ids count from 1 at each acquisition start.
Sourcepub fn packet_resend(self, enable: bool) -> Self
pub fn packet_resend(self, enable: bool) -> Self
Answer PACKETRESEND_CMD, and say so in the GVCP Capability register
(0x0934, mask 0x4) (default: on).
Off, the capability bit is clear and requests are counted in
FakeCamera::resends but never answered, as on a device without
resend.
Sourcepub fn resend_retention(self, frames: usize) -> Self
pub fn resend_retention(self, frames: usize) -> Self
Keep the packets of the last frames blocks for resending (default
4). A request for an older block is answered with a header-only GVSP
packet carrying PACKET_UNAVAILABLE (0x800C).
Sourcepub fn tick_frequency(self, hz: u64) -> Self
pub fn tick_frequency(self, hz: u64) -> Self
Report hz as the timestamp tick frequency (bootstrap 0x093C and
0x0940; default 1 GHz), the unit GevSCPD counts in. 0 is what a
device without a timestamp clock reports.
Sourcepub fn spoof_source(self, addr: Ipv4Addr) -> Self
pub fn spoof_source(self, addr: Ipv4Addr) -> Self
Also send every block from a second socket bound to addr, ahead of
the genuine one and with its image bytes inverted: valid GVSP from an
address that is not the camera’s, which a receiver must ignore.
addr must be one of this host’s addresses other than the camera’s.
Sourcepub fn heartbeat_timeout_ms(self, timeout_ms: u32) -> Self
pub fn heartbeat_timeout_ms(self, timeout_ms: u32) -> Self
Report a different GevHeartbeatTimeout than the 3 000 ms default.
A shorter window keeps a test that has to wait one out from dominating the suite’s runtime.
Sourcepub fn mac(self, mac: [u8; 6]) -> Self
pub fn mac(self, mac: [u8; 6]) -> Self
Report mac instead of FAKE_MAC, in the Discovery ACK and the
bootstrap MAC registers alike.
Services key a GigE camera by its MAC, so two fakes that should appear as two cameras need two MACs, not only two serials.
Sourcepub fn model(self, model: impl Into<String>) -> Self
pub fn model(self, model: impl Into<String>) -> Self
Report model instead of FAKE_MODEL in the Discovery ACK.
The field is 32 bytes on the wire; a longer name is truncated.
Sourcepub fn serial(self, serial: impl Into<String>) -> Self
pub fn serial(self, serial: impl Into<String>) -> Self
Report serial instead of FAKE_SERIAL in the Discovery ACK.
The field is 16 bytes on the wire; a longer serial is truncated.
Sourcepub fn user_name(self, user_name: impl Into<String>) -> Self
pub fn user_name(self, user_name: impl Into<String>) -> Self
Report user_name instead of FAKE_USER_NAME in the Discovery ACK.
An empty string reports no user-defined name, as an unnamed camera does.
The field is 16 bytes on the wire; a longer name is truncated.
Sourcepub fn current_ip(self, ip: Ipv4Addr) -> Self
pub fn current_ip(self, ip: Ipv4Addr) -> Self
Report ip as the camera’s current IP address in the Discovery ACK
and bootstrap 0x0024, instead of the address it is bound to.
A camera configured for another network still answers a broadcast discovery, with an address the host cannot reach; this is that camera.
Sourcepub fn subnet_mask(self, mask: Ipv4Addr) -> Self
pub fn subnet_mask(self, mask: Ipv4Addr) -> Self
Report mask as the current subnet mask (default
FAKE_SUBNET_MASK, loopback’s /8).
Sourcepub fn gateway(self, gateway: Ipv4Addr) -> Self
pub fn gateway(self, gateway: Ipv4Addr) -> Self
Report gateway as the current default gateway (default 0.0.0.0).
Sourcepub fn pending_ack(self, supported: bool) -> Self
pub fn pending_ack(self, supported: bool) -> Self
Say in GVCP Capability (0x0934, mask 0x20) that this device can
answer a slow command with PENDING_ACK (default: on).
It sends one only once the controller sets the enable bit (0x2) of
GVCP Configuration (0x0954), as the specification has it.
Sourcepub fn names_primary_application(self, names: bool) -> Self
pub fn names_primary_application(self, names: bool) -> Self
Say in GVCP Capability (0x0934, mask 0x0800_0000) that this device
names its primary application at 0x0A04 (port) and 0x0A14 (IP)
(default: on).
Off, the device is an Allied Vision Manta G-125B (firmware
00.01.44.28514): the capability bit is clear and both registers answer
INVALID_ADDRESS, so CCP, which every application reads alike, is all
that says whether anyone holds control.
Sourcepub fn action_commands(self, implemented: bool) -> Self
pub fn action_commands(self, implemented: bool) -> Self
Act on ACTION_CMDs addressed to this device (default: on).
Off, the device answers every action command as an Allied Vision
Manta G-125B (firmware 00.01.44.28514, GVCP Capability without the
action bit) did, broadcast or not: with status NOT_IMPLEMENTED under
the command’s own opcode, 0x0100, not ACTION_ACK.
Sourcepub fn delay_ack(self, addr: u64, delay: Duration) -> Self
pub fn delay_ack(self, addr: u64, delay: Duration) -> Self
Acknowledge every register-access command that starts at addr only
after delay, as a device busy with a flash write or a mode change
does — first with a PENDING_ACK of one and a half times delay when
PENDING_ACK is enabled. Other commands are served meanwhile, and a
retry of the delayed one is not executed again.
Sourcepub fn profile(self, profile: XmlProfile) -> Self
pub fn profile(self, profile: XmlProfile) -> Self
Serve this GenApi XML profile (default XmlProfile::Sfnc).
Sourcepub async fn build(self) -> Result<FakeCamera, Error>
pub async fn build(self) -> Result<FakeCamera, Error>
Start the fake camera and return a handle.