From 996c6f159c5753dac1cdf507307455d70e59bb6f Mon Sep 17 00:00:00 2001 From: Xavier RODRIGUEZ Date: Mon, 30 Dec 2024 07:34:43 +0100 Subject: [PATCH] Multiple small improvement (#12) * multiple improvement * provide a tree --- README.md | 23 ++++++++++++++++++++++- src/tester/device.rs | 4 +++- src/tester/device/enum_ro_wo.rs | 4 ++-- src/tester/device/si_ro_wo.rs | 6 +++--- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a730de3..6e3b888 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,25 @@ Panduza Virtual Instruments ```bash cargo install cargo-post cargo post build --features plugin -``` \ No newline at end of file +``` + + + + +# full usage + + +```json +{ + "devices": [ + { + "name": "Virtual REPL", + "dref": "vi.repl" + }, + { + "name": "Attribute Tester", + "dref": "vi.tester" + } + ] +} +``` diff --git a/src/tester/device.rs b/src/tester/device.rs index f01307b..41909ff 100644 --- a/src/tester/device.rs +++ b/src/tester/device.rs @@ -32,7 +32,9 @@ impl DriverOperations for Device { async fn mount(&mut self, instance: Instance) -> Result<(), Error> { string_ro_wo::mount(instance.clone()).await?; bool_ro_wo::mount(instance.clone()).await?; - enum_ro_wo::mount(instance.clone()).await?; + enum_ro_wo::mount(instance.clone(), 0).await?; + enum_ro_wo::mount(instance.clone(), 1).await?; + enum_ro_wo::mount(instance.clone(), 2).await?; json_ro_wo::mount(instance.clone()).await?; number_ro_wo::mount(instance.clone()).await?; si_ro_wo::mount(instance.clone()).await?; diff --git a/src/tester/device/enum_ro_wo.rs b/src/tester/device/enum_ro_wo.rs index ba709ad..686dd9c 100644 --- a/src/tester/device/enum_ro_wo.rs +++ b/src/tester/device/enum_ro_wo.rs @@ -5,10 +5,10 @@ use panduza_platform_core::{ /// /// /// -pub async fn mount(mut instance: Instance) -> Result<(), Error> { +pub async fn mount(mut instance: Instance, id: usize) -> Result<(), Error> { // // Create interface - let mut class = instance.create_class("enum").finish().await; + let mut class = instance.create_class(format!("enum_{}", id)).finish().await; // // Some of the first contributors (sorted by alphabetic order) diff --git a/src/tester/device/si_ro_wo.rs b/src/tester/device/si_ro_wo.rs index 4aacfba..1a34797 100644 --- a/src/tester/device/si_ro_wo.rs +++ b/src/tester/device/si_ro_wo.rs @@ -16,7 +16,7 @@ pub async fn mount(mut instance: Instance) -> Result<(), Error> { .create_attribute("si_ro") .with_ro() .with_info(r#"read command"#) - .finish_as_si("test", 0.0, 100.0, 2) + .finish_as_si("Ω", -20.0, 100.0, 2) .await?; att_si_ro.set_from_f32(0.0).await?; @@ -26,7 +26,7 @@ pub async fn mount(mut instance: Instance) -> Result<(), Error> { .create_attribute("si_wo") .with_wo() .with_info(r#"write command"#) - .finish_as_si("test", 0.0, 100.0, 2) + .finish_as_si("Ω", -20.0, 100.0, 2) .await?; // @@ -45,7 +45,7 @@ pub async fn mount(mut instance: Instance) -> Result<(), Error> { .create_attribute("si_rw") .with_rw() .with_info(r#"read write command"#) - .finish_as_si("test", 0.0, 100.0, 2) + .finish_as_si("Ω", -20.0, 100.0, 2) .await?; att_si_rw.set_from_f32(0.0).await?;