diff --git a/src/event.rs b/src/event.rs index 5f10b12..cb5592d 100644 --- a/src/event.rs +++ b/src/event.rs @@ -150,7 +150,7 @@ impl EventManager { if let Some(ws_manager) = &ws_manager_clone { let ws_message = crate::websocket::WsMessage::PointValueChange( - crate::telemetry::WsPointMonitorInfo::from(&monitor), + monitor.clone(), ); if let Err(e) = ws_manager.send_to_public(ws_message.clone()).await { diff --git a/src/handler/point.rs b/src/handler/point.rs index 6ac5e78..1feb455 100644 --- a/src/handler/point.rs +++ b/src/handler/point.rs @@ -21,7 +21,7 @@ pub struct GetPointListQuery { pub struct PointWithMonitor { #[serde(flatten)] pub point: Point, - pub point_monitor: Option, + pub point_monitor: Option, } pub async fn get_point_list( @@ -63,8 +63,7 @@ pub async fn get_point_list( .map(|point| { let point_monitor = monitor_guard .get(&point.id) - .cloned() - .map(|m| crate::telemetry::WsPointMonitorInfo::from(&m)); + .cloned(); PointWithMonitor { point, point_monitor } }) .collect(); diff --git a/src/telemetry.rs b/src/telemetry.rs index 6de3132..0dca3b2 100644 --- a/src/telemetry.rs +++ b/src/telemetry.rs @@ -107,33 +107,6 @@ pub struct PointNewValue { pub scan_mode: ScanMode, } -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct WsPointMonitorInfo { - pub protocol: String, - pub point_id: Uuid, - pub scan_mode: String, - pub timestamp: Option, - pub quality: PointQuality, - pub value: Option, - pub value_type: Option, -} - -impl From<&PointMonitorInfo> for WsPointMonitorInfo { - fn from(m: &PointMonitorInfo) -> Self { - Self { - protocol: m.protocol.clone(), - point_id: m.point_id, - scan_mode: m.scan_mode.to_string(), - timestamp: m - .timestamp - .as_ref() - .map(crate::util::datetime::utc_to_local_string), - quality: m.quality.clone(), - value: m.value_as_json(), - value_type: m.value_type.clone(), - } - } -} pub fn opcua_variant_to_data(value: &opcua::types::Variant) -> DataValue { use opcua::types::Variant; diff --git a/src/websocket.rs b/src/websocket.rs index 00bac7f..25bebc8 100644 --- a/src/websocket.rs +++ b/src/websocket.rs @@ -15,7 +15,7 @@ use uuid::Uuid; #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(tag = "type", content = "data")] pub enum WsMessage { - PointValueChange(crate::telemetry::WsPointMonitorInfo), + PointValueChange(crate::telemetry::PointMonitorInfo), PointSetValueBatchResult(crate::connection::BatchSetPointValueRes), }