Skip to main content

FakeCameraBuilder

Struct FakeCameraBuilder 

Source
pub struct FakeCameraBuilder { /* private fields */ }
Expand description

Builder for configuring and starting a fake GigE Vision camera.

Implementations§

Source§

impl FakeCameraBuilder

Source

pub fn width(self, width: u32) -> Self

Set the image width in pixels.

Source

pub fn height(self, height: u32) -> Self

Set the image height in pixels.

Source

pub fn fps(self, fps: u32) -> Self

Set the target frame rate.

Source

pub fn bind_ip(self, ip: Ipv4Addr) -> Self

Set the IPv4 address to bind the GVCP socket to.

Source

pub fn port(self, port: u16) -> Self

Set the GVCP control port (default: 3956).

Source

pub fn pixel_format(self, code: u32) -> Self

Set the initial pixel format (PFNC code). Default: Mono8.

Use MONO8 or RGB8 constants.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn subnet_mask(self, mask: Ipv4Addr) -> Self

Report mask as the current subnet mask (default FAKE_SUBNET_MASK, loopback’s /8).

Source

pub fn gateway(self, gateway: Ipv4Addr) -> Self

Report gateway as the current default gateway (default 0.0.0.0).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn profile(self, profile: XmlProfile) -> Self

Serve this GenApi XML profile (default XmlProfile::Sfnc).

Source

pub async fn build(self) -> Result<FakeCamera, Error>

Start the fake camera and return a handle.

Trait Implementations§

Source§

impl Default for FakeCameraBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more