pub trait ThreadController {
Show 19 methods
// Required methods
fn discover_usb_devices(&mut self) -> Result<Vec<u32>>;
fn discover_network_devices(
&mut self,
timeout_ms: u32,
) -> Result<Vec<NetworkDeviceSummary>>;
fn start_usb_device_thread(&mut self, device_index: u32) -> Result<u32>;
fn start_network_device_thread(
&mut self,
device_summary: NetworkDeviceSummary,
) -> Result<u32>;
fn start_device_thread_by_serial(
&mut self,
serial_number: u32,
check_network: bool,
timeout_ms: u32,
) -> Result<u32>;
fn send_command(&self, thread_id: u32, command: DeviceCommand) -> Result<()>;
fn get_status(&self, thread_id: u32) -> Result<ThreadStatus>;
fn get_state(&self, thread_id: u32) -> Result<DeviceState>;
fn get_shared_state(&self, thread_id: u32) -> Result<Arc<SharedDeviceState>>;
fn create_observer(&self, thread_id: u32) -> Result<StateObserver>;
fn stop_all(&mut self) -> Result<()>;
fn set_thread_log_level(
&mut self,
thread_id: u32,
level: LevelFilter,
) -> Result<()>;
fn set_global_log_level(&mut self, level: LevelFilter) -> Result<()>;
fn start_model_monitoring(
&mut self,
thread_id: u32,
model_dir: Option<PathBuf>,
) -> Result<()>;
fn stop_model_monitoring(&mut self, thread_id: u32) -> Result<()>;
fn update_device_model(
&self,
thread_id: u32,
model: DeviceModel,
) -> Result<()>;
fn list_active_threads(&self) -> Result<Vec<u32>>;
fn stop_thread(&mut self, thread_id: u32) -> Result<()>;
// Provided method
fn is_thread_running(&self, thread_id: u32) -> Result<bool> { ... }
}Expand description
Thread controller for managing device threads.
The thread controller is responsible for:
- Discovering devices
- Starting and stopping device threads
- Sending commands to device threads
- Retrieving device state
- Creating state observers
- Performing device operations
Required Methods§
Sourcefn discover_usb_devices(&mut self) -> Result<Vec<u32>>
fn discover_usb_devices(&mut self) -> Result<Vec<u32>>
Sourcefn discover_network_devices(
&mut self,
timeout_ms: u32,
) -> Result<Vec<NetworkDeviceSummary>>
fn discover_network_devices( &mut self, timeout_ms: u32, ) -> Result<Vec<NetworkDeviceSummary>>
Sourcefn start_usb_device_thread(&mut self, device_index: u32) -> Result<u32>
fn start_usb_device_thread(&mut self, device_index: u32) -> Result<u32>
Sourcefn start_network_device_thread(
&mut self,
device_summary: NetworkDeviceSummary,
) -> Result<u32>
fn start_network_device_thread( &mut self, device_summary: NetworkDeviceSummary, ) -> Result<u32>
Sourcefn start_device_thread_by_serial(
&mut self,
serial_number: u32,
check_network: bool,
timeout_ms: u32,
) -> Result<u32>
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.
§Parameters
serial_number- The serial number of the device to connect to.check_network- Whether to check for network devices.timeout_ms- The timeout in milliseconds for network device discovery.
§Returns
The thread ID of the newly created thread.
§Errors
Returns an error if the thread creation fails or if the device connection fails.
Sourcefn send_command(&self, thread_id: u32, command: DeviceCommand) -> Result<()>
fn send_command(&self, thread_id: u32, command: DeviceCommand) -> Result<()>
Sourcefn get_status(&self, thread_id: u32) -> Result<ThreadStatus>
fn get_status(&self, thread_id: u32) -> Result<ThreadStatus>
Sourcefn get_state(&self, thread_id: u32) -> Result<DeviceState>
fn get_state(&self, thread_id: u32) -> Result<DeviceState>
Sourcefn create_observer(&self, thread_id: u32) -> Result<StateObserver>
fn create_observer(&self, thread_id: u32) -> Result<StateObserver>
Sourcefn set_thread_log_level(
&mut self,
thread_id: u32,
level: LevelFilter,
) -> Result<()>
fn set_thread_log_level( &mut self, thread_id: u32, level: LevelFilter, ) -> Result<()>
Sourcefn set_global_log_level(&mut self, level: LevelFilter) -> Result<()>
fn set_global_log_level(&mut self, level: LevelFilter) -> Result<()>
Sourcefn start_model_monitoring(
&mut self,
thread_id: u32,
model_dir: Option<PathBuf>,
) -> Result<()>
fn start_model_monitoring( &mut self, thread_id: u32, model_dir: Option<PathBuf>, ) -> Result<()>
Start model monitoring for a device thread.
This method starts monitoring the device model file for changes and updates the device model when changes are detected.
§Parameters
thread_id- The ID of the thread to monitor.model_dir- Optional custom directory for model files.
§Errors
Returns an error if the thread is not found or if monitoring fails to start.