Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Add timestamps to actuator target values
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmittag committed Feb 10, 2023
1 parent 75446da commit b1d7cae
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions kuksa_databroker/databroker/src/broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct Datapoint {
#[derive(Debug, Clone)]
pub struct Entry {
pub datapoint: Datapoint,
pub actuator_target: Option<DataValue>,
pub actuator_target: Option<Datapoint>,
pub metadata: Metadata,
}

Expand Down Expand Up @@ -145,7 +145,7 @@ pub struct EntryUpdate {
// Actuator target is wrapped in an additional Option<> in
// order to be able to convey "update it to None" which would
// mean setting it to `Some(None)`.
pub actuator_target: Option<Option<DataValue>>, // only for actuators
pub actuator_target: Option<Option<Datapoint>>, // only for actuators

// Metadata
pub entry_type: Option<EntryType>,
Expand Down Expand Up @@ -176,8 +176,8 @@ impl Entry {
if let Some(datapoint) = &update.datapoint {
self.validate_value(&datapoint.value)?;
}
if let Some(Some(value)) = &update.actuator_target {
self.validate_value(value)?;
if let Some(Some(actuatortarget)) = &update.actuator_target {
self.validate_value(&actuatortarget.value)?;
}
Ok(())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ impl From<broker::EntryUpdate> for proto::DataEntry {
None => None,
},
actuator_target: match from.actuator_target {
Some(Some(actuator_target)) => Option::<proto::Datapoint>::from(actuator_target),
Some(Some(actuator_target)) => {
Option::<proto::Datapoint>::from(actuator_target)
}
Some(None) => None,
None => None,
},
Expand Down
6 changes: 4 additions & 2 deletions kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ fn proto_entry_from_entry_and_fields(
};
let actuator_target = if fields.contains(&proto::Field::ActuatorTarget) {
match entry.actuator_target {
Some(actuator_target) => Option::<proto::Datapoint>::from(actuator_target),
Some(actuator_target) => {
Option::<proto::Datapoint>::from(actuator_target)
}
None => None,
}
} else {
Expand Down Expand Up @@ -419,7 +421,7 @@ impl broker::EntryUpdate {
};
let actuator_target = if fields.contains(&proto::Field::ActuatorTarget) {
match &entry.actuator_target {
Some(datapoint) => Some(Some(broker::DataValue::from(datapoint.value.clone()))),
Some(datapoint) => Some(Some(broker::Datapoint::from(datapoint.clone()))),
None => Some(None),
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ impl proto::broker_server::Broker for broker::DataBroker {
broker::EntryUpdate {
path: None,
datapoint: None,
actuator_target: Some(Some(broker::DataValue::from(
&datapoint,
))),
actuator_target: Some(Some(broker::Datapoint::from(&datapoint))),
entry_type: None,
data_type: None,
description: None,
Expand Down

0 comments on commit b1d7cae

Please sign in to comment.