Skip to content

Commit

Permalink
fix update attributes on command
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Giese authored and Lucas Giese committed Dec 16, 2024
1 parent 634217d commit 9a2a3b5
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 42 deletions.
8 changes: 4 additions & 4 deletions src/virtual_instrument/device/bool_ro_wo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ pub async fn mount(
///
///
async fn on_command(
mut att_boolean_ro: BooleanAttServer,
att_boolean_wo: BooleanAttServer,
att_boolean_ro: BooleanAttServer,
mut att_boolean_wo: BooleanAttServer,
) -> Result<(), Error> {
while let Some(command) = att_boolean_ro.pop_cmd().await {
att_boolean_wo.set(command).await?;
while let Some(command) = att_boolean_wo.pop_cmd().await {
att_boolean_ro.set(command).await?;
}

Ok(())
Expand Down
8 changes: 4 additions & 4 deletions src/virtual_instrument/device/enum_ro_wo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ pub async fn mount(
///
///
async fn on_command(
mut att_enum_ro: EnumAttServer,
att_enum_wo: EnumAttServer,
att_enum_ro: EnumAttServer,
mut att_enum_wo: EnumAttServer,
) -> Result<(), Error> {
while let Some(command) = att_enum_ro.pop_cmd().await {
att_enum_wo.set(command?).await?;
while let Some(command) = att_enum_wo.pop_cmd().await {
att_enum_ro.set(command?).await?;
}

Ok(())
Expand Down
8 changes: 4 additions & 4 deletions src/virtual_instrument/device/json_ro_wo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ pub async fn mount(
///
///
async fn on_command(
mut att_json_ro: JsonAttServer,
att_json_wo: JsonAttServer,
att_json_ro: JsonAttServer,
mut att_json_wo: JsonAttServer,
) -> Result<(), Error> {
while let Some(command) = att_json_ro.pop_cmd().await {
att_json_wo.set(command).await?;
while let Some(command) = att_json_wo.pop_cmd().await {
att_json_ro.set(command).await?;
}

Ok(())
Expand Down
18 changes: 3 additions & 15 deletions src/virtual_instrument/device/number_ro_wo.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
use panduza_platform_core::{log_info, spawn_on_command, Error, Instance, InstanceLogger, NumberAttServer};
use panduza_platform_core::{spawn_on_command, Error, Instance, NumberAttServer};

///
///
///
pub async fn mount(
mut instance: Instance,
) -> Result<(), Error> {
//
//
let logger = instance.logger.clone();
logger.info("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

//
// Create interface
let mut class = instance.create_class("number").finish();
Expand All @@ -26,7 +21,7 @@ pub async fn mount(

//
//
att_number_ro.set_from_i64(0);
att_number_ro.set_from_i64(0).await?;

//
//
Expand All @@ -39,24 +34,20 @@ pub async fn mount(

//
//
att_number_wo.set_from_i64(0);
att_number_wo.set_from_i64(0).await?;

//
//
let logger_2 = logger.clone();
let att_number_wo_2 = att_number_wo.clone();
spawn_on_command!(
"on_command",
instance,
att_number_wo_2,
on_command(
logger_2.clone(),
att_number_ro.clone(),
att_number_wo_2.clone()
)
);

logger.info("fin numberrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr");

Ok(())
}
Expand All @@ -65,13 +56,10 @@ pub async fn mount(
///
///
async fn on_command(
logger: InstanceLogger,
att_number_ro: NumberAttServer,
mut att_number_wo: NumberAttServer,
) -> Result<(), Error> {
log_info!(logger, "commmmmmmmmmmmmmannnnnnnnnnnnnnnnnnnnnndddddddddddddddddddddd");
while let Some(command) = att_number_wo.pop_cmd_as_i64().await {
log_info!(logger, "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");
att_number_ro.set_from_i64(command).await?;
att_number_wo.set_from_i64(command).await?;
}
Expand Down
8 changes: 4 additions & 4 deletions src/virtual_instrument/device/si_ro_wo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ pub async fn mount(
///
///
async fn on_command(
mut att_si_ro: SiAttServer,
att_si_wo: SiAttServer,
att_si_ro: SiAttServer,
mut att_si_wo: SiAttServer,
) -> Result<(), Error> {
while let Some(command) = att_si_ro.pop_cmd_as_f32().await {
att_si_wo.set_from_f32(command?).await?;
while let Some(command) = att_si_wo.pop_cmd_as_f32().await {
att_si_ro.set_from_f32(command?).await?;
}

Ok(())
Expand Down
23 changes: 12 additions & 11 deletions src/virtual_instrument/device/string_ro_wo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ use panduza_platform_core::{log_info, spawn_on_command, Error, Instance, Instanc
pub async fn mount(
mut instance: Instance,
) -> Result<(), Error> {
//
//
let logger = instance.logger.clone();
logger.info("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

//
// Create interface
let mut class = instance.create_class("string").finish();
Expand All @@ -24,6 +19,10 @@ pub async fn mount(
.finish_as_string()
.await?;

//
//
att_string_ro.set("test".to_string()).await?;

//
//
let att_string_wo = class
Expand All @@ -33,6 +32,10 @@ pub async fn mount(
.finish_as_string()
.await?;

//
//
att_string_wo.set("test".to_string()).await?;

//
//
let att_string_wo_2 = att_string_wo.clone();
Expand All @@ -49,20 +52,18 @@ pub async fn mount(
// let Some(resp) = att_string_ro.pop_cmd().await;
// att_string_wo.set(resp).await?;

logger.info("fin numberrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr");

Ok(())
}

///
///
///
async fn on_command(
mut att_string_ro: StringAttServer,
att_string_wo: StringAttServer,
att_string_ro: StringAttServer,
mut att_string_wo: StringAttServer,
) -> Result<(), Error> {
while let Some(command) = att_string_ro.pop_cmd().await {
att_string_wo.set(command).await?;
while let Some(command) = att_string_wo.pop_cmd().await {
att_string_ro.set(command).await?;
}

Ok(())
Expand Down

0 comments on commit 9a2a3b5

Please sign in to comment.