ThreadControllerImpl

Struct ThreadControllerImpl 

Source
pub struct ThreadControllerImpl { /* private fields */ }
Expand description

Thread controller implementation.

This is the main implementation of the ThreadController trait. It manages device threads and provides methods for device operations. Thread controller implementation.

This is the main implementation of the ThreadController trait. It manages device threads and provides methods for device operations.

Implementations§

Source§

impl ThreadControllerImpl

Source

pub fn new() -> Self

Create a new thread controller.

§Returns

A new thread controller with default settings.

Source

pub fn with_logger(logger: Arc<dyn Logger>) -> Self

Create a new thread controller with a logger.

§Parameters
  • logger - The logger to use.
§Returns

A new thread controller with the specified logger.

Source

pub fn set_default_refresh_interval(&mut self, interval_ms: u64)

Set the default refresh interval.

§Parameters
  • interval_ms - The refresh interval in milliseconds.
Source

pub fn set_logger(&mut self, logger: Arc<dyn Logger>)

Set the logger.

§Parameters
  • logger - The logger to use.

Trait Implementations§

Source§

impl Default for ThreadControllerImpl

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl DeviceOperations for ThreadControllerImpl

Source§

fn set_digital_output( &self, thread_id: u32, pin: u32, value: bool, ) -> Result<()>

Set a digital output pin. Read more
Source§

fn get_digital_input(&self, thread_id: u32, pin: u32) -> Result<bool>

Get a digital input pin. Read more
Source§

fn set_analog_output(&self, thread_id: u32, pin: u32, value: u32) -> Result<()>

Set an analog output. Read more
Source§

fn get_analog_input(&self, thread_id: u32, pin: u32) -> Result<u32>

Get an analog input. Read more
Source§

fn set_pwm_duty_cycle( &self, thread_id: u32, channel: usize, duty: u32, ) -> Result<()>

Set a PWM duty cycle. Read more
Source§

fn set_pwm_duty_cycle_percent( &self, thread_id: u32, channel: usize, duty_percent: f32, ) -> Result<()>

Set a PWM duty cycle as a percentage. Read more
Source§

fn configure_servo( &self, thread_id: u32, pin: u8, servo_config: ServoConfig, ) -> Result<()>

Configure a servo on a PWM pin. Read more
Source§

fn set_servo_angle(&self, thread_id: u32, pin: u8, angle: f32) -> Result<()>

Set servo angle (for 180° and 360° position servos). Read more
Source§

fn set_servo_speed(&self, thread_id: u32, pin: u8, speed: f32) -> Result<()>

Set servo speed (for 360° speed servos). Read more
Source§

fn stop_servo(&self, thread_id: u32, pin: u8) -> Result<()>

Stop a servo (set to neutral position). Read more
Source§

fn i2c_write(&self, thread_id: u32, address: u8, data: Vec<u8>) -> Result<()>

Write data to an I2C device. Read more
Source§

fn i2c_read(&self, thread_id: u32, address: u8, length: u8) -> Result<Vec<u8>>

Read data from an I2C device. Read more
Source§

fn i2c_write_read( &self, thread_id: u32, address: u8, write_data: Vec<u8>, read_length: u8, ) -> Result<Vec<u8>>

Write then read from an I2C device (combined operation). Read more
Source§

fn i2c_scan(&self, thread_id: u32) -> Result<Vec<u8>>

Scan for I2C devices on the bus. Read more
Source§

fn configure_uspibridge( &self, thread_id: u32, config: USPIBridgeConfig, ) -> Result<()>

Configure uSPIBridge with custom pinout. Read more
Source§

fn uspibridge_command( &self, thread_id: u32, command: Vec<u8>, ) -> Result<Vec<u8>>

Send uSPIBridge command. Read more
Source§

fn check_pin_capability( &self, thread_id: u32, pin: u8, capability: PinCapability, ) -> Result<bool>

Check if a pin supports a specific capability. Read more
Source§

fn get_device_model(&self, thread_id: u32) -> Result<Option<String>>

Get device model information. Read more
Source§

fn validate_pin_operation( &self, thread_id: u32, pin: u8, operation: &str, ) -> Result<()>

Validate pin configuration before operation. Read more
Source§

fn set_digital_outputs_bulk( &self, thread_id: u32, pin_states: Vec<(u32, bool)>, ) -> Result<()>

Set multiple digital outputs in a single operation. Read more
Source§

fn set_pwm_duties_bulk( &self, thread_id: u32, channel_duties: Vec<(usize, u32)>, ) -> Result<()>

Set multiple PWM duty cycles in a single operation. Read more
Source§

fn read_analog_inputs_bulk( &self, thread_id: u32, pins: Vec<u32>, ) -> Result<Vec<u32>>

Read multiple analog inputs in a single operation. Read more
Source§

fn get_encoder_value(&self, thread_id: u32, encoder_index: u32) -> Result<i32>

Get an encoder value. Read more
Source§

fn configure_encoder( &self, thread_id: u32, encoder_index: u32, pin_a: u32, pin_b: u32, enabled: bool, sampling_4x: bool, ) -> Result<()>

Configure an encoder. Read more
Source§

fn reset_digital_counter(&self, thread_id: u32, pin: u32) -> Result<()>

Reset a digital counter. Read more
Source§

fn send_custom_request( &self, thread_id: u32, request_type: u8, param1: u8, param2: u8, param3: u8, param4: u8, ) -> Result<()>

Send a custom request. Read more
Source§

fn set_pin_function( &self, thread_id: u32, pin: u32, pin_function: PinFunction, ) -> Result<()>

Configure a pin function. Read more
Source§

impl Drop for ThreadControllerImpl

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl ThreadController for ThreadControllerImpl

Source§

fn discover_usb_devices(&mut self) -> Result<Vec<u32>>

Discover USB devices connected to the system. Read more
Source§

fn discover_network_devices( &mut self, timeout_ms: u32, ) -> Result<Vec<NetworkDeviceSummary>>

Discover network devices on the local network. Read more
Source§

fn start_usb_device_thread(&mut self, device_index: u32) -> Result<u32>

Start a thread for a USB device. Read more
Source§

fn start_network_device_thread( &mut self, device_summary: NetworkDeviceSummary, ) -> Result<u32>

Start a thread for a network device. Read more
Source§

fn start_device_thread_by_serial( &mut self, serial_number: u32, check_network: bool, timeout_ms: u32, ) -> Result<u32>

Start a thread for a device with a specific serial number. Read more
Source§

fn send_command(&self, thread_id: u32, command: DeviceCommand) -> Result<()>

Send a command to a device thread. Read more
Source§

fn get_status(&self, thread_id: u32) -> Result<ThreadStatus>

Get the status of a device thread. Read more
Source§

fn get_state(&self, thread_id: u32) -> Result<DeviceState>

Get the state of a device thread. Read more
Source§

fn get_shared_state(&self, thread_id: u32) -> Result<Arc<SharedDeviceState>>

Get the shared state of a device thread. Read more
Source§

fn create_observer(&self, thread_id: u32) -> Result<StateObserver>

Create a state observer for a device thread. Read more
Source§

fn stop_all(&mut self) -> Result<()>

Stop all device threads. Read more
Source§

fn set_thread_log_level( &mut self, thread_id: u32, level: LevelFilter, ) -> Result<()>

Set the log level for a specific thread. Read more
Source§

fn set_global_log_level(&mut self, level: LevelFilter) -> Result<()>

Set the log level for all threads and the controller. Read more
Source§

fn start_model_monitoring( &mut self, thread_id: u32, model_dir: Option<PathBuf>, ) -> Result<()>

Start model monitoring for a device thread. Read more
Source§

fn stop_model_monitoring(&mut self, thread_id: u32) -> Result<()>

Stop model monitoring for a device thread. Read more
Source§

fn update_device_model(&self, thread_id: u32, model: DeviceModel) -> Result<()>

Update the device model for a thread. Read more
Source§

fn list_active_threads(&self) -> Result<Vec<u32>>

Get a list of all active thread IDs. Read more
Source§

fn stop_thread(&mut self, thread_id: u32) -> Result<()>

Stop a specific thread. Read more
Source§

fn is_thread_running(&self, thread_id: u32) -> Result<bool>

Check if a thread is currently running. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.