pub struct SolenoidGroup { /* private fields */ }Expand description
A group of pneumatic solenoids that can be controlled together.
SolenoidGroup wraps multiple AdiDigitalOut devices and provides
methods to control them as a single unit. All operations are async and
thread-safe using an Arc<Mutex<>> wrapper.
§Use Cases
- Dual-acting pistons: Control both sides of a piston simultaneously
- Synchronized mechanisms: Ensure multiple pistons extend/retract together
- Redundant systems: Control backup solenoids alongside primary ones
§Error Handling
Group operations return Result<(), GroupErrors> where GroupErrors is a
vector of individual port errors. If all solenoids succeed, Ok(()) is
returned. If any fail, Err(errors) contains all failures.
Implementations§
Source§impl SolenoidGroup
impl SolenoidGroup
Sourcepub fn new(pneumatics: Vec<AdiDigitalOut>) -> Self
pub fn new(pneumatics: Vec<AdiDigitalOut>) -> Self
Creates a new solenoid group from a vector of digital outputs.
§Arguments
pneumatics- Vector ofAdiDigitalOutdevices to control together
§Returns
A new SolenoidGroup wrapping the provided solenoids.
§Example
let group = SolenoidGroup::new(vec![solenoid1, solenoid2]);Sourcepub async fn use_at<F, R>(&self, index: usize, f: F) -> Rwhere
F: FnOnce(&mut AdiDigitalOut) -> R,
pub async fn use_at<F, R>(&self, index: usize, f: F) -> Rwhere
F: FnOnce(&mut AdiDigitalOut) -> R,
Runs a function on a specific solenoid by index.
This method provides direct access to an individual solenoid within the group for custom operations.
§Arguments
index- Index of the solenoid to access (0-based)f- Closure that receives a mutable reference to the solenoid
§Returns
The return value of the provided closure.
§Panics
Panics if index is out of bounds.
Sourcepub async fn set_level(&self, logic: LogicLevel) -> Result<(), GroupErrors>
pub async fn set_level(&self, logic: LogicLevel) -> Result<(), GroupErrors>
Sets the logic level for all solenoids.
§Arguments
logic- TheLogicLevelto set (HighorLow)
§Returns
Ok(())- All solenoids set successfullyErr(errors)- One or more solenoids failed; contains all errors
Sourcepub async fn extend(&self) -> Result<(), GroupErrors>
pub async fn extend(&self) -> Result<(), GroupErrors>
Extends all solenoids (sets to high).
Equivalent to set_level(LogicLevel::High). Use this to extend
pneumatic cylinders.
§Returns
Ok(())- All solenoids extended successfullyErr(errors)- One or more solenoids failed
Sourcepub async fn retract(&self) -> Result<(), GroupErrors>
pub async fn retract(&self) -> Result<(), GroupErrors>
Retracts all solenoids (sets to low).
Equivalent to set_level(LogicLevel::Low). Use this to retract
pneumatic cylinders.
§Returns
Ok(())- All solenoids retracted successfullyErr(errors)- One or more solenoids failed
Sourcepub async fn toggle(&self) -> Result<(), GroupErrors>
pub async fn toggle(&self) -> Result<(), GroupErrors>
Toggles all solenoids.
Each solenoid switches to its opposite state (high → low, low → high). Note that solenoids toggle independently, so if they were in different states, they will swap states rather than synchronize.
§Returns
Ok(())- All solenoids toggled successfullyErr(errors)- One or more solenoids failed
Sourcepub async fn is_level(&self, logic: LogicLevel) -> bool
pub async fn is_level(&self, logic: LogicLevel) -> bool
Checks if all solenoids are at the given logic level.
§Arguments
logic- TheLogicLevelto check against
§Returns
true if all solenoids are at the specified level, false otherwise.
If any solenoid’s level cannot be read, it is treated as not matching.
Trait Implementations§
Source§impl Clone for SolenoidGroup
impl Clone for SolenoidGroup
Source§fn clone(&self) -> SolenoidGroup
fn clone(&self) -> SolenoidGroup
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SolenoidGroup
impl !RefUnwindSafe for SolenoidGroup
impl Send for SolenoidGroup
impl Sync for SolenoidGroup
impl Unpin for SolenoidGroup
impl UnsafeUnpin for SolenoidGroup
impl !UnwindSafe for SolenoidGroup
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.