pub struct Channel { /* private fields */ }
Expand description

An Industrial I/O Device Channel

Implementations§

source§

impl Channel

source

pub fn name(&self) -> Option<String>

Retrieves the name of the channel (e.g. vccint)

source

pub fn id(&self) -> Option<String>

Retrieve the channel ID (e.g. voltage0)

source

pub fn is_output(&self) -> bool

Determines if this is an output channel.

source

pub fn is_scan_element(&self) -> bool

Determines if the channel is a scan element

A scan element is a channel that can generate samples (for an input channel) or receive samples (for an output channel) after being enabled.

source

pub fn index(&self) -> Result<usize>

Gets the index of the channel in the device

source

pub fn has_attrs(&self) -> bool

Determines if the channel has any attributes

source

pub fn num_attrs(&self) -> usize

Gets the number of attributes for the channel

source

pub fn has_attr(&self, attr: &str) -> bool

Determines if the channel has the specified attribute.

source

pub fn get_attr(&self, idx: usize) -> Result<String>

Gets the channel-specific attribute at the index

source

pub fn find_attr(&self, name: &str) -> Option<String>

Try to find the channel-specific attribute by name.

source

pub fn attr_read<T: FromAttribute>(&self, attr: &str) -> Result<T>

Reads a channel-specific attribute

attr The name of the attribute

source

pub fn attr_read_str(&self, attr: &str) -> Result<String>

Reads a channel-specific attribute as a string

attr The name of the attribute

source

pub fn attr_read_bool(&self, attr: &str) -> Result<bool>

Reads a channel-specific attribute as a boolean attr The name of the attribute

source

pub fn attr_read_int(&self, attr: &str) -> Result<i64>

Reads a channel-specific attribute as an integer (i64)

attr The name of the attribute

source

pub fn attr_read_float(&self, attr: &str) -> Result<f64>

Reads a channel-specific attribute as a floating-point (f64) number

attr The name of the attribute

source

pub fn attr_read_all(&self) -> Result<HashMap<String, String>>

Reads all the channel-specific attributes. This is especially useful when using the network backend to retrieve all the attributes with a single call.

source

pub fn attr_write<T: ToAttribute>(&self, attr: &str, val: T) -> Result<()>

Writes a channel-specific attribute

attr The name of the attribute val The value to write

source

pub fn attr_write_str(&self, attr: &str, val: &str) -> Result<()>

Writes a channel-specific attribute as a string

attr The name of the attribute val The value to write

source

pub fn attr_write_bool(&self, attr: &str, val: bool) -> Result<()>

Writes a channel-specific attribute as a boolean

attr The name of the attribute val The value to write

source

pub fn attr_write_int(&self, attr: &str, val: i64) -> Result<()>

Writes a channel-specific attribute as an integer (i64)

attr The name of the attribute val The value to write

source

pub fn attr_write_float(&self, attr: &str, val: f64) -> Result<()>

Writes a channel-specific attribute as a floating-point (f64) number

attr The name of the attribute val The value to write

source

pub fn attrs(&self) -> AttrIterator<'_>

Gets an iterator for the attributes of the channel

source

pub fn enable(&self)

Enable the channel

Before creating a buffer, at least one channel of the device must be enabled.

source

pub fn disable(&self)

Disable the channel

source

pub fn is_enabled(&self) -> bool

Determines if the channel is enabled

source

pub fn data_format(&self) -> DataFormat

Gets the data format for the channel

source

pub fn type_of(&self) -> Option<TypeId>

Gets the TypeId for a single sample from the channel.

This will get the TypeId for a sample if it can fit into a standard integer type, signed or unsigned, of 8, 16, 32, or 64 bits.

source

pub fn channel_type(&self) -> ChannelType

Gets the type of data associated with the channel

source

pub fn convert<T>(&self, val: T) -> Twhere
    T: Copy + 'static,

Converts a single sample from the hardware format to the host format.

To be properly converted, the value must be the same type as that of the channel, including size and sign. If not, the original value is returned.

source

pub fn convert_inverse<T>(&self, val: T) -> Twhere
    T: Copy + 'static,

Converts a sample from the host format to the hardware format.

To be properly converted, the value must be the same type as that of the channel, including size and sign. If not, the original value is returned.

source

pub fn read<T>(&self, buf: &Buffer) -> Result<Vec<T>>where
    T: Default + Copy + 'static,

Demultiplex and convert the samples of a given channel.

source

pub fn read_raw<T>(&self, buf: &Buffer) -> Result<Vec<T>>where
    T: Default + Copy + 'static,

Demultiplex the samples of a given channel.

source

pub fn write<T>(&self, buf: &Buffer, data: &[T]) -> Result<usize>where
    T: Default + Copy + 'static,

Convert and multiplex the samples of a given channel. Returns the number of items written.

source

pub fn write_raw<T>(&self, buf: &Buffer, data: &[T]) -> Result<usize>where
    T: Default + Copy + 'static,

Multiplex the samples of a given channel. Returns the number of items written.

Trait Implementations§

source§

impl Clone for Channel

source§

fn clone(&self) -> Channel

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Channel

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> ToOwned for Twhere
    T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.