Skip to main content

Controller

Trait Controller 

Source
pub trait Controller: Send + Sync {
    type Config: Send + Sync;
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn init<'async_trait>(
        config: Self::Config,
    ) -> Pin<Box<dyn Future<Output = Result<Self, Self::Error>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait;
    fn start<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stop<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ControllerHealth> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn capabilities(&self) -> ControllerCapabilities;

    // Provided method
    fn diagnostics<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = HashMap<String, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Base trait for all hardware controllers

Controllers manage the lifecycle and interaction with physical hardware or simulated devices. They abstract device SDKs and provide consistent interfaces for nodes to use.

Required Associated Types§

Source

type Config: Send + Sync

Configuration type for this controller

Source

type Error: Error + Send + Sync + 'static

Error type for this controller

Required Methods§

Source

fn init<'async_trait>( config: Self::Config, ) -> Pin<Box<dyn Future<Output = Result<Self, Self::Error>> + Send + 'async_trait>>
where Self: Sized + 'async_trait,

Initialize the controller with the given configuration

This should perform all necessary setup including:

  • Opening device connections
  • Configuring device parameters
  • Running initialization sequences
  • Loading calibration data
Source

fn start<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Start the controller

Begin data acquisition, motor control, or other active operations. This may start background threads or async tasks.

Source

fn stop<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stop the controller

Stop all active operations gracefully. The controller should still be in a valid state and can be restarted with start().

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ControllerHealth> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check the health status of the controller

Source

fn capabilities(&self) -> ControllerCapabilities

Get the capabilities of this controller

Returns metadata about what features and operations this controller supports. This is useful for runtime capability detection.

Provided Methods§

Source

fn diagnostics<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = HashMap<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get controller-specific diagnostics

Returns detailed diagnostic information for debugging and monitoring.

Implementors§