1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use date_time::DateTime;
use basic_types::*;
use node_ids::ObjectId;
use service_types::{NotificationMessage, MonitoredItemNotification, DataChangeNotification};
impl NotificationMessage {
pub fn new_data_change(sequence_number: UInt32, publish_time: DateTime, monitored_items: Vec<MonitoredItemNotification>) -> NotificationMessage {
let data_change_notification = DataChangeNotification {
monitored_items: Some(monitored_items),
diagnostic_infos: None,
};
trace!("data change notification = {:?}", data_change_notification);
let notification_data = ExtensionObject::from_encodable(ObjectId::DataChangeNotification_Encoding_DefaultBinary, data_change_notification);
NotificationMessage {
sequence_number,
publish_time,
notification_data: Some(vec![notification_data]),
}
}
pub fn data_change_notifications(&self) -> Vec<DataChangeNotification> {
let mut result = Vec::with_capacity(10);
if let Some(ref notification_data) = self.notification_data {
for n in notification_data {
if n.node_id != ObjectId::DataChangeNotification_Encoding_DefaultBinary.into() {
continue;
}
result.push(n.decode_inner::<DataChangeNotification>().unwrap());
}
}
result
}
}