refactor: 统一使用 PointMonitorInfo,移除 WsPointMonitorInfo
This commit is contained in:
parent
a82921193c
commit
cc7142e556
|
|
@ -150,7 +150,7 @@ impl EventManager {
|
||||||
|
|
||||||
if let Some(ws_manager) = &ws_manager_clone {
|
if let Some(ws_manager) = &ws_manager_clone {
|
||||||
let ws_message = crate::websocket::WsMessage::PointValueChange(
|
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 {
|
if let Err(e) = ws_manager.send_to_public(ws_message.clone()).await {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub struct GetPointListQuery {
|
||||||
pub struct PointWithMonitor {
|
pub struct PointWithMonitor {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub point: Point,
|
pub point: Point,
|
||||||
pub point_monitor: Option<crate::telemetry::WsPointMonitorInfo>,
|
pub point_monitor: Option<crate::telemetry::PointMonitorInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_point_list(
|
pub async fn get_point_list(
|
||||||
|
|
@ -63,8 +63,7 @@ pub async fn get_point_list(
|
||||||
.map(|point| {
|
.map(|point| {
|
||||||
let point_monitor = monitor_guard
|
let point_monitor = monitor_guard
|
||||||
.get(&point.id)
|
.get(&point.id)
|
||||||
.cloned()
|
.cloned();
|
||||||
.map(|m| crate::telemetry::WsPointMonitorInfo::from(&m));
|
|
||||||
PointWithMonitor { point, point_monitor }
|
PointWithMonitor { point, point_monitor }
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
||||||
|
|
@ -107,33 +107,6 @@ pub struct PointNewValue {
|
||||||
pub scan_mode: ScanMode,
|
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<String>,
|
|
||||||
pub quality: PointQuality,
|
|
||||||
pub value: Option<serde_json::Value>,
|
|
||||||
pub value_type: Option<ValueType>,
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
pub fn opcua_variant_to_data(value: &opcua::types::Variant) -> DataValue {
|
||||||
use opcua::types::Variant;
|
use opcua::types::Variant;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use uuid::Uuid;
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(tag = "type", content = "data")]
|
#[serde(tag = "type", content = "data")]
|
||||||
pub enum WsMessage {
|
pub enum WsMessage {
|
||||||
PointValueChange(crate::telemetry::WsPointMonitorInfo),
|
PointValueChange(crate::telemetry::PointMonitorInfo),
|
||||||
PointSetValueBatchResult(crate::connection::BatchSetPointValueRes),
|
PointSetValueBatchResult(crate::connection::BatchSetPointValueRes),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue