Compare commits
3 Commits
02de1f4552
...
8127d04855
| Author | SHA1 | Date |
|---|---|---|
|
|
8127d04855 | |
|
|
cc7142e556 | |
|
|
a82921193c |
|
|
@ -261,8 +261,8 @@ impl ConnectionManager {
|
||||||
.map(crate::telemetry::PointQuality::from_status_code)
|
.map(crate::telemetry::PointQuality::from_status_code)
|
||||||
.unwrap_or(crate::telemetry::PointQuality::Unknown);
|
.unwrap_or(crate::telemetry::PointQuality::Unknown);
|
||||||
|
|
||||||
let _ = event_manager.send(crate::event::ReloadEvent::PointValueChange(
|
let _ = event_manager.send(crate::event::ReloadEvent::PointNewValue(
|
||||||
crate::telemetry::PointValueChangeEvent {
|
crate::telemetry::PointNewValue {
|
||||||
source_id,
|
source_id,
|
||||||
point_id: Some(point_id),
|
point_id: Some(point_id),
|
||||||
client_handle: 0,
|
client_handle: 0,
|
||||||
|
|
@ -758,8 +758,8 @@ impl ConnectionManager {
|
||||||
// Emit local updates only when the full batch succeeds.
|
// Emit local updates only when the full batch succeeds.
|
||||||
if let Some(event_manager) = &self.event_manager {
|
if let Some(event_manager) = &self.event_manager {
|
||||||
for (source_id, point_id, variant) in success_events {
|
for (source_id, point_id, variant) in success_events {
|
||||||
if let Err(e) = event_manager.send(crate::event::ReloadEvent::PointValueChange(
|
if let Err(e) = event_manager.send(crate::event::ReloadEvent::PointNewValue(
|
||||||
crate::telemetry::PointValueChangeEvent {
|
crate::telemetry::PointNewValue {
|
||||||
source_id,
|
source_id,
|
||||||
point_id: Some(point_id),
|
point_id: Some(point_id),
|
||||||
client_handle: 0,
|
client_handle: 0,
|
||||||
|
|
@ -883,8 +883,8 @@ impl ConnectionManager {
|
||||||
.unwrap_or(crate::telemetry::PointQuality::Unknown);
|
.unwrap_or(crate::telemetry::PointQuality::Unknown);
|
||||||
|
|
||||||
if let Some(event_manager) = &manager.event_manager {
|
if let Some(event_manager) = &manager.event_manager {
|
||||||
let _ = event_manager.send(crate::event::ReloadEvent::PointValueChange(
|
let _ = event_manager.send(crate::event::ReloadEvent::PointNewValue(
|
||||||
crate::telemetry::PointValueChangeEvent {
|
crate::telemetry::PointNewValue {
|
||||||
source_id: current_source_id,
|
source_id: current_source_id,
|
||||||
point_id: None,
|
point_id: None,
|
||||||
client_handle,
|
client_handle,
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ pub enum ReloadEvent {
|
||||||
source_id: Uuid,
|
source_id: Uuid,
|
||||||
point_ids: Vec<Uuid>,
|
point_ids: Vec<Uuid>,
|
||||||
},
|
},
|
||||||
PointValueChange(crate::telemetry::PointValueChangeEvent),
|
PointNewValue(crate::telemetry::PointNewValue),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EventManager {
|
pub struct EventManager {
|
||||||
|
|
@ -118,7 +118,7 @@ impl EventManager {
|
||||||
tracing::error!("Failed to unsubscribe points: {}", e);
|
tracing::error!("Failed to unsubscribe points: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReloadEvent::PointValueChange(payload) => {
|
ReloadEvent::PointNewValue(payload) => {
|
||||||
let source_id = payload.source_id;
|
let source_id = payload.source_id;
|
||||||
let client_handle = payload.client_handle;
|
let client_handle = payload.client_handle;
|
||||||
let point_id = if let Some(point_id) = payload.point_id {
|
let point_id = if let Some(point_id) = payload.point_id {
|
||||||
|
|
@ -149,8 +149,8 @@ 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::PointNewValue(
|
||||||
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();
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ impl PointMonitorInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct PointValueChangeEvent {
|
pub struct PointNewValue {
|
||||||
pub source_id: Uuid,
|
pub source_id: Uuid,
|
||||||
pub point_id: Option<Uuid>,
|
pub point_id: Option<Uuid>,
|
||||||
pub client_handle: u32,
|
pub client_handle: u32,
|
||||||
|
|
@ -107,33 +107,6 @@ pub struct PointValueChangeEvent {
|
||||||
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),
|
PointNewValue(crate::telemetry::PointMonitorInfo),
|
||||||
PointSetValueBatchResult(crate::connection::BatchSetPointValueRes),
|
PointSetValueBatchResult(crate::connection::BatchSetPointValueRes),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue