Expand description
High level GenICam facade that re-exports the workspace crates and provides convenience wrappers.
use viva_genicam::{gige, genapi, Camera, GenicamError};
use std::time::Duration;
let timeout = Duration::from_millis(500);
let devices = gige::discover(timeout)
.await
.expect("discover cameras");
println!("found {} cameras", devices.len());
let mut camera = Camera::new(open_transport().await?, load_nodemap());
camera.set("ExposureTime", "5000")?;use std::net::Ipv4Addr;
let ids = ["FrameStart", "ExposureEnd"];
let iface = Ipv4Addr::new(127, 0, 0, 1);
camera.configure_events(iface, 10020, &ids).await?;
let stream = camera.open_event_stream(iface, 10020).await?;
let event = stream.next().await?;
println!("event id=0x{:04X} payload={} bytes", event.id, event.data.len());use viva_genicam::gige::{send_action, ActionParams};
use std::net::SocketAddr;
let params = ActionParams {
device_key: 0,
group_key: 1,
group_mask: 0xFFFF_FFFF,
scheduled_time: None,
};
let dest: SocketAddr = "255.255.255.255:3956".parse().unwrap();
let summary = send_action(dest, ¶ms, 200).await?;
println!("acks={}", summary.acks);
Ok(())Re-exports§
pub use viva_genapi as genapi;pub use viva_gencp as gencp;pub use viva_gige as gige;pub use viva_pfnc as pfnc;pub use viva_sfnc as sfnc;pub use viva_u3v as u3v;
Modules§
- blocking
- GigE Vision cameras for programs without an async runtime.
- image_
io - Saving frames as PNG or TIFF at the camera’s bit depth.
- report
- A diagnostic report: everything we ask someone with a camera for, in one plain-text file.
Structs§
- AckSummary
- Summary of the broadcast performed by
send_action. - Action
Params - Parameters used to construct an action command.
- Camera
- Camera facade combining a nodemap with a transport implementing
RegisterIo. - Chunk
Config - Configuration for enabling chunk data via SFNC features.
- Chunk
Data - The chunks of one stream buffer, by chunk ID: what a nodemap’s chunk ports read.
- Event
- Public representation of a GigE Vision event.
- Event
Configuration - Event settings changed by one successful setup, tied to its camera session.
- Event
Restore Failure - One setting that could not be restored. Other independent settings are still attempted while the camera remains writable.
- Event
Restore Report - The outcome of restoring only the settings an event setup changed.
- Event
Setup Error - Setup failed;
Self::sourceretains the error andSelf::restorationsays whether rollback succeeded. A failed rollback must not be reported as a successful cleanup. - Event
Stream - Asynchronous stream of events delivered over the GVCP message channel.
- EvsBlock
- One raw event-vision block reassembled from GVSP packets.
- Frame
- Image frame produced by the GigE Vision stream reassembler.
- Frame
Stream - Frames from one GVSP stream, assembled by a receive thread of its own.
- Generic
Stream Block - An opaque complete GVSP block with common metadata accessors.
- Gige
Register Io - Blocking adapter turning an asynchronous
GigeDeviceinto aRegisterIoimplementation. - Reopen
- How
reopen_gigelooks for a camera that went away, and what it puts back. - Reopened
- A camera
reopen_gigeopened again. - Resolved
Feature - The node a standard feature resolved to on this camera.
- Roi
- A region of interest: the offsets of its top-left corner on the sensor, and its size, in pixels.
- Stream
- Handle returned by
StreamBuilder: the bound socket and the negotiated parameters, ready forFrameStream::new. - Stream
Builder - Builder for configuring a GVSP stream.
- Stream
Options - How
Camera::open_streamsets up a GigE stream. The defaults: the interface the operating system routes to the camera, unicast to a port the operating system picks, the camera’s own packet size (path-probed, ADR-0021) and packet delay, packet resend when the camera supports it, and a receive buffer the engine sizes from the frame. - Stream
Stats - Snapshot of one stream’s counters (backlog SR-07).
- Stream
Stats Accumulator - Shared, cloneable handle to one stream’s counters.
- Time
Sync - Maintain a linear mapping between device ticks and host time.
- U3vConnection
- Whether a USB3 Vision camera is gone, readable apart from its
transport (
U3vRegisterIo::connection). - U3vEvent
Stream - Events from a USB3 Vision camera’s event interface, read on a thread of its own (backlog TC-27 (4)).
- U3vFrame
Stream - Frames from a USB3 Vision camera, read on a thread of its own.
- U3vRegister
Io - Blocking
RegisterIoadapter wrapping aU3vDevice. - U3vStream
Builder - Builder for a USB3 Vision
U3vFrameStreamon a camera’s transport — the device, as GigE Vision’sStreamBuildertakes the device. - U3vStream
Options - How a stream reads: the payload size to use when the device does not say, and the transfers it keeps queued.
- Write
Refused - Why a
GigeRegisterIorefused a write before it reached the camera: the session does not hold control. Thesourceof theGenApiError::Ioa refused feature write returns, so a caller can tell it from a camera’s refusal by downcasting.
Enums§
- Access
- How
connect_gige_asopens a camera. - Chunk
Error - A chunk payload that does not tile into tagged chunks.
- Control
State - Where a GigE session stands with the camera’s control channel privilege (CCP). Only a session that holds it writes registers: in every other state a write is refused before it reaches the camera.
- Event
Restore Skipped - Why restoration deliberately performed no further writes.
- EvsFormat
- Encoding used by a LUCID event-vision stream block.
- Frame
Status - How a frame’s block ended.
- Genicam
Error - Error type produced by the high level GenICam facade.
- Resend
Policy - Whether a stream asks the camera to send lost packets again (SR-04).
- Standard
Feature - A standard feature the helpers look up, by the names cameras declare it under.
- Stream
Block - The semantic payload carried by one complete GVSP block.
- Stream
Dest - Destination for GVSP packets received by the stream.
Constants§
- COMMAND_
POLL_ INTERVAL - How often
Camera::execute_and_waitasks a command whether it has finished, when the command declares no<PollingTime>. - COMMAND_
TIMEOUT - How long the helpers that wait for a command — the user-set helpers, among them — give it to finish, and what consumers of this crate wait by default.
Functions§
- chunk_
data - Split a GigE Vision chunk payload into a
ChunkData, by chunk ID. - connect_
gige - Connect to a GigE Vision camera and return a fully configured
Camera. - connect_
gige_ as - Connect to a GigE Vision camera with the given
Access, returning theCameraand the GenICam XML it was built from. - connect_
gige_ with_ xml - Connect to a GigE Vision camera and return both a
Cameraand the raw GenICam XML string fetched from the device. - connect_
u3v - Connect to a USB3 Vision camera and return a fully configured
Camera. - connect_
u3v_ with_ xml - Connect to a USB3 Vision camera and return both a
Cameraand the raw GenICam XML string fetched from the device. - open_
u3v_ device - Create a
Camerafrom an already-openedU3vDevicewith anyUsbTransferbackend. - reopen_
gige - Open again a GigE Vision camera that went away: unplugged, power-cycled, or with its heartbeat expired.