Compare commits

..

1 Commits

Author SHA1 Message Date
alban
259fdeb7b0 feat: Add device interface and factory
wip

fix borrowing issue and make everything compile

wip
2023-06-07 12:20:42 +02:00
2 changed files with 4 additions and 35 deletions

View File

@ -1,14 +0,0 @@
mod device;
mod helios;
use crate::conf::{Conf, DacFamily, EtherDreamConf, HeliosConf};
use crate::device::device::Device;
use crate::device::helios::HeliosDevice;
pub fn device_factory(config: Conf) -> Box<dyn Device> {
let device = match config.dac {
DacFamily::Helios(conf) => Box::new(HeliosDevice { conf }),
DacFamily::Etherdream(conf) => todo!(),
};
device
}

View File

@ -21,12 +21,6 @@ pub struct HeliosDevice {
} }
impl HeliosDevice { impl HeliosDevice {
/// This is fabulous doc !
/// # Woot
///
/// ` some example `
///
pub fn new(conf: &HeliosConf) -> LJResult<Self> { pub fn new(conf: &HeliosConf) -> LJResult<Self> {
let id = conf.id; let id = conf.id;
let controller = NativeHeliosDacController::new()?; let controller = NativeHeliosDacController::new()?;
@ -36,21 +30,10 @@ impl HeliosDevice {
}; };
let dac = device.open()?; let dac = device.open()?;
Ok(Self { Ok(Self {
conf: (*conf).clone(), conf: (*conf).clone(), dac,
dac,
}) })
} }
} }
//
// fn get_helios_device() -> LJResult<NativeHeliosDac> {
// let controller = NativeHeliosDacController::new()?;
// let devices = controller.list_devices()?;
// let Some(device) = devices.into_iter().next() else {
// return Err(Box::new(LJError::HeliosDeviceMissing));
// };
// let device = device.open()?;
// Ok(device)
// }
impl Device for HeliosDevice { impl Device for HeliosDevice {
fn status(&self) -> Status { fn status(&self) -> Status {