-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87c514d
commit 4ad2d77
Showing
7 changed files
with
107 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
pub mod device; | ||
use device::Device; | ||
use panduza_platform_core::{DriverOperations, Producer}; | ||
|
||
#[derive(Default)] | ||
pub struct Package {} | ||
|
||
impl Package { | ||
pub fn boxed(self) -> Box<Self> { | ||
Box::new(self) | ||
} | ||
} | ||
|
||
impl Producer for Package { | ||
fn manufacturer(&self) -> String { | ||
"vi".to_string() | ||
} | ||
|
||
fn model(&self) -> String { | ||
"daq".to_string() | ||
} | ||
|
||
fn description(&self) -> String { | ||
"Virtual DAQ interface".to_string() | ||
} | ||
|
||
fn props(&self) -> panduza_platform_core::Props { | ||
panduza_platform_core::Props::default() | ||
} | ||
|
||
fn produce(&self) -> Result<Box<dyn DriverOperations>, panduza_platform_core::Error> { | ||
return Ok(Box::new(Device::default())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use async_trait::async_trait; | ||
use panduza_platform_core::{DriverOperations, Error, Instance}; | ||
use std::time::Duration; | ||
use tokio::time::sleep; | ||
mod random_si_reader; | ||
|
||
#[derive(Default)] | ||
/// | ||
/// Device to control PicoHA SSB Board | ||
/// | ||
pub struct Device {} | ||
|
||
#[async_trait] | ||
impl DriverOperations for Device { | ||
/// | ||
/// | ||
/// | ||
async fn mount(&mut self, instance: Instance) -> Result<(), Error> { | ||
let interface = random_si_reader::RandomSiReader::default().into_arc_mutex(); | ||
panduza_platform_core::std::class::acq_si::mount( | ||
"randommeter", | ||
"Pika", | ||
0.0, | ||
0xffff as f64, | ||
4, | ||
instance.clone(), | ||
interface.clone(), | ||
) | ||
.await?; | ||
Ok(()) | ||
} | ||
/// | ||
/// Easiest way to implement the reboot event | ||
/// | ||
async fn wait_reboot_event(&mut self, mut _device: Instance) { | ||
sleep(Duration::from_secs(5)).await; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use async_trait::async_trait; | ||
use panduza_platform_core::{std::class::acq_si::SiDataReader, Error}; | ||
use rand::Rng; | ||
use std::sync::Arc; | ||
use tokio::sync::Mutex; | ||
|
||
#[derive(Default)] | ||
/// | ||
/// Simple echo evaluation | ||
/// | ||
pub struct RandomSiReader {} | ||
|
||
impl RandomSiReader { | ||
pub fn into_arc_mutex(self) -> Arc<Mutex<Self>> { | ||
Arc::new(Mutex::new(self)) | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl SiDataReader for RandomSiReader { | ||
async fn read_data(&mut self, _channel: usize) -> Result<f64, Error> { | ||
let mut rng = rand::thread_rng(); | ||
let random_value: f64 = rng.gen_range(0.0..0xffff as f64); | ||
Ok(random_value) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters