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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
use crate::analyse::cause::Cause;
use crate::reception::exchange::message::Message;
use crate::reception::exchange::Exchange;
use crate::reception::mortal::now;
pub fn monitor(
exchange: &Exchange,
cause: Option<Cause>,
direction: &str,
component: String,
partner: String,
) {
match &exchange.message {
Message::CAM(cam) => {
println!(
"{} {} {} {} {}/{} at {}",
component,
exchange.type_field,
direction,
partner,
cam.station_id,
cam.generation_delta_time,
now()
);
}
Message::DENM(denm) => {
println!(
"{} {} {} {} {}/{}/{}/{}/{}{} at {}",
component,
exchange.type_field,
direction,
partner,
denm.station_id,
denm.management_container.action_id.originating_station_id,
denm.management_container.action_id.sequence_number,
denm.management_container.reference_time,
denm.management_container.detection_time,
get_cause_str(cause),
now()
);
}
Message::CPM(cpm) => {
println!(
"{} {} {} {} {}/{} at {}",
component,
exchange.type_field,
direction,
partner,
cpm.station_id,
cpm.generation_delta_time,
now()
);
}
Message::MAPEM(map) => {
println!(
"{} {} {} {} {}/{}/{} at {}",
component,
exchange.type_field,
direction,
partner,
map.sending_station_id.unwrap_or_default(),
map.id,
map.region.unwrap_or_default(),
now()
);
}
Message::SPATEM(spat) => {
println!(
"{} {} {} {} {}/{}/{} at {}",
component,
exchange.type_field,
direction,
partner,
spat.sending_station_id.unwrap_or_default(),
spat.id,
spat.region.unwrap_or_default(),
now()
);
}
};
}
fn get_cause_str(cause: Option<Cause>) -> String {
return match cause {
Some(cause) => format!("/cause_type:{}/cause_id:{}", cause.m_type, cause.id),
None => String::new(),
};
}