Skip to main content

RegisterMap

Struct RegisterMap 

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

Pre-populated register store for the fake camera.

All feature registers are initialized with realistic defaults. The register map is thread-safe via external Mutex wrapping.

Implementations§

Source§

impl RegisterMap

Source

pub fn new(width: u32, height: u32, pixel_format: u32, zip_xml: bool) -> Self

Create a new register map with the given image dimensions.

Initializes all bootstrap, feature, and device info registers with sensible defaults. The GenApi XML is embedded at XML_BLOB_BASE, served as a ZIP archive when zip_xml is set (as many real cameras do).

Source

pub fn enforce_heartbeat(&mut self, enable: bool)

Arm the GigE Vision heartbeat rule: release control privilege when the controller goes quiet for longer than GevHeartbeatTimeout.

Real devices always do this, and it is the entire reason a client needs a keepalive — GVSP image traffic does not refresh the timer, so a camera can be streaming at full rate while its control channel times out underneath. A fake that never expires CCP cannot tell a working keepalive from a missing one, which is how SR-05 stayed open through three app-layer reimplementations of the same loop.

Off by default, because arming it makes every test that holds control privilege sensitive to a 3 s stall — on a loaded CI runner that is a flake, not a finding. Tests that are about the keepalive turn it on.

Source

pub fn set_max_on_wire(&mut self, max: u32)

Clamp GevSCPSPacketSize writes to max, the way a real device does.

A request above max is acknowledged and silently reduced, so the register reads back lower than what was written — nothing on the wire distinguishes that from acceptance, which is the defect in #112. Silently drop any GVSP datagram larger than max, as a path with a smaller frame ceiling than either endpoint believes does.

See RegisterMap::max_on_wire.

Source

pub fn max_on_wire(&self) -> Option<u32>

The path ceiling, if one was configured.

Source

pub fn take_pending_test_packet(&mut self) -> Option<u32>

Take the size requested by the last fire-test-packet write, if any.

Source

pub fn set_max_packet_size(&mut self, max: u32)

Source

pub fn note_register_command(&mut self) -> bool

Apply the heartbeat rule, and report whether privilege was just revoked.

Called for register-access commands only. Discovery and FORCEIP are broadcast by any application on the subnet, so counting them would let an unrelated viva-camctl list hold another application’s privilege open. Unlike a real device we do not track which peer is the controller — there is only ever one in a test.

Source

pub fn set_heartbeat_timeout_ms(&mut self, timeout_ms: u32)

Report a different GevHeartbeatTimeout than the 3 000 ms default.

Lets a test pick a window short enough to wait out without making the suite slow, and makes the timing it depends on explicit rather than implied by this crate’s default.

Source

pub fn heartbeat_timeout_ms(&self) -> u32

The heartbeat window this device reports, in milliseconds.

Source

pub fn read(&self, addr: u64, len: usize) -> Vec<u8>

Read len bytes starting at addr.

Source

pub fn write(&mut self, addr: u64, data: &[u8])

Write data starting at addr.

Source

pub fn handle_special_write(&mut self, addr: u64)

Handle side effects of register writes.

Source

pub fn device_timestamp(&self) -> u64

Current device timestamp in nanoseconds since creation.

Source

pub fn stream_dest_ip(&self) -> Ipv4Addr

Stream destination IP address.

Source

pub fn stream_dest_port(&self) -> u16

Stream destination port.

Source

pub fn message_dest_ip(&self) -> Ipv4Addr

Message channel destination address (GevMCDA).

Source

pub fn message_dest_port(&self) -> u16

Message channel destination port (GevMCP), low 16 bits of the register.

Source

pub fn event_selector(&self) -> u16

Event identifier currently selected by EventSelector.

Source

pub fn event_notification_on(&self, event_id: u16) -> bool

Whether EventNotification is On for event_id.

Takes the event explicitly: the emitter cares whether its event is enabled, which is independent of whichever entry the controller happened to select last.

Source

pub fn stream_packet_size(&self) -> u32

Stream packet size.

Source

pub fn width(&self) -> u32

Image width.

Source

pub fn height(&self) -> u32

Image height.

Source

pub fn pixel_format_code(&self) -> u32

Pixel format PFNC code.

Source

pub fn chunk_mode_active(&self) -> bool

Whether chunk mode is active.

Source

pub fn exposure_time(&self) -> f64

Current exposure time in microseconds.

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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