Struct industrial_io::channel::Channel
source · pub struct Channel { /* private fields */ }
Expand description
An Industrial I/O Device Channel
Implementations§
source§impl Channel
impl Channel
sourcepub fn is_scan_element(&self) -> bool
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.
sourcepub fn has_attr(&self, attr: &str) -> bool
pub fn has_attr(&self, attr: &str) -> bool
Determines if the channel has the specified attribute.
sourcepub fn get_attr(&self, idx: usize) -> Result<String>
pub fn get_attr(&self, idx: usize) -> Result<String>
Gets the channel-specific attribute at the index
sourcepub fn find_attr(&self, name: &str) -> Option<String>
pub fn find_attr(&self, name: &str) -> Option<String>
Try to find the channel-specific attribute by name.
sourcepub fn attr_read<T: FromAttribute>(&self, attr: &str) -> Result<T>
pub fn attr_read<T: FromAttribute>(&self, attr: &str) -> Result<T>
Reads a channel-specific attribute
attr
The name of the attribute
sourcepub fn attr_read_str(&self, attr: &str) -> Result<String>
pub fn attr_read_str(&self, attr: &str) -> Result<String>
Reads a channel-specific attribute as a string
attr
The name of the attribute
sourcepub fn attr_read_bool(&self, attr: &str) -> Result<bool>
pub fn attr_read_bool(&self, attr: &str) -> Result<bool>
Reads a channel-specific attribute as a boolean
attr
The name of the attribute
sourcepub fn attr_read_int(&self, attr: &str) -> Result<i64>
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
sourcepub fn attr_read_float(&self, attr: &str) -> Result<f64>
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
sourcepub fn attr_read_all(&self) -> Result<HashMap<String, String>>
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.
sourcepub fn attr_write<T: ToAttribute>(&self, attr: &str, val: T) -> Result<()>
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
sourcepub fn attr_write_str(&self, attr: &str, val: &str) -> Result<()>
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
sourcepub fn attr_write_bool(&self, attr: &str, val: bool) -> Result<()>
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
sourcepub fn attr_write_int(&self, attr: &str, val: i64) -> Result<()>
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
sourcepub fn attr_write_float(&self, attr: &str, val: f64) -> Result<()>
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
sourcepub fn attrs(&self) -> AttrIterator<'_> ⓘ
pub fn attrs(&self) -> AttrIterator<'_> ⓘ
Gets an iterator for the attributes of the channel
sourcepub fn enable(&self)
pub fn enable(&self)
Enable the channel
Before creating a buffer, at least one channel of the device must be enabled.
sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Determines if the channel is enabled
sourcepub fn data_format(&self) -> DataFormat
pub fn data_format(&self) -> DataFormat
Gets the data format for the channel
sourcepub fn type_of(&self) -> Option<TypeId>
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.
sourcepub fn channel_type(&self) -> ChannelType
pub fn channel_type(&self) -> ChannelType
Gets the type of data associated with the channel
sourcepub fn convert<T>(&self, val: T) -> Twhere
T: Copy + 'static,
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.
sourcepub fn convert_inverse<T>(&self, val: T) -> Twhere
T: Copy + 'static,
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.
sourcepub fn read<T>(&self, buf: &Buffer) -> Result<Vec<T>>where
T: Default + Copy + 'static,
pub fn read<T>(&self, buf: &Buffer) -> Result<Vec<T>>where
T: Default + Copy + 'static,
Demultiplex and convert the samples of a given channel.
sourcepub fn read_raw<T>(&self, buf: &Buffer) -> Result<Vec<T>>where
T: Default + Copy + 'static,
pub fn read_raw<T>(&self, buf: &Buffer) -> Result<Vec<T>>where
T: Default + Copy + 'static,
Demultiplex the samples of a given channel.