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
impl RegisterMap
Sourcepub fn new(width: u32, height: u32, pixel_format: u32, zip_xml: bool) -> Self
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).
Sourcepub fn enforce_heartbeat(&mut self, enable: bool)
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.
Sourcepub fn set_max_on_wire(&mut self, max: u32)
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.
Sourcepub fn max_on_wire(&self) -> Option<u32>
pub fn max_on_wire(&self) -> Option<u32>
The path ceiling, if one was configured.
Sourcepub fn take_pending_test_packet(&mut self) -> Option<u32>
pub fn take_pending_test_packet(&mut self) -> Option<u32>
Take the size requested by the last fire-test-packet write, if any.
pub fn set_max_packet_size(&mut self, max: u32)
Sourcepub fn note_register_command(&mut self) -> bool
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.
Sourcepub fn set_heartbeat_timeout_ms(&mut self, timeout_ms: u32)
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.
Sourcepub fn heartbeat_timeout_ms(&self) -> u32
pub fn heartbeat_timeout_ms(&self) -> u32
The heartbeat window this device reports, in milliseconds.
Sourcepub fn handle_special_write(&mut self, addr: u64)
pub fn handle_special_write(&mut self, addr: u64)
Handle side effects of register writes.
Sourcepub fn device_timestamp(&self) -> u64
pub fn device_timestamp(&self) -> u64
Current device timestamp in nanoseconds since creation.
Sourcepub fn stream_dest_ip(&self) -> Ipv4Addr
pub fn stream_dest_ip(&self) -> Ipv4Addr
Stream destination IP address.
Sourcepub fn stream_dest_port(&self) -> u16
pub fn stream_dest_port(&self) -> u16
Stream destination port.
Sourcepub fn message_dest_ip(&self) -> Ipv4Addr
pub fn message_dest_ip(&self) -> Ipv4Addr
Message channel destination address (GevMCDA).
Sourcepub fn message_dest_port(&self) -> u16
pub fn message_dest_port(&self) -> u16
Message channel destination port (GevMCP), low 16 bits of the register.
Sourcepub fn event_selector(&self) -> u16
pub fn event_selector(&self) -> u16
Event identifier currently selected by EventSelector.
Sourcepub fn event_notification_on(&self, event_id: u16) -> bool
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.
Sourcepub fn stream_packet_size(&self) -> u32
pub fn stream_packet_size(&self) -> u32
Stream packet size.
Sourcepub fn pixel_format_code(&self) -> u32
pub fn pixel_format_code(&self) -> u32
Pixel format PFNC code.
Sourcepub fn chunk_mode_active(&self) -> bool
pub fn chunk_mode_active(&self) -> bool
Whether chunk mode is active.
Sourcepub fn exposure_time(&self) -> f64
pub fn exposure_time(&self) -> f64
Current exposure time in microseconds.