mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-27 00:37:37 +08:00
[link] handle correctly the fake link id (used in sim or while waiting for a new link)
This commit is contained in:
+1
-1
@@ -2747,7 +2747,7 @@
|
||||
Combines DATLINK_REPORT (telemetry class) and LINK_REPORT (ground class)
|
||||
</description>
|
||||
<field name="ac_id" type="string"/>
|
||||
<field name="link_id" type="uint8"/>
|
||||
<field name="link_id" type="string"/>
|
||||
<field name="time_since_last_msg" type="float" unit="s"/>
|
||||
<field name="rx_bytes" type="uint32"/>
|
||||
<field name="rx_msgs" type="uint32"/>
|
||||
|
||||
@@ -843,7 +843,7 @@ let get_fbw_msg = fun alarm _sender vs ->
|
||||
|
||||
let get_telemetry_status = fun alarm _sender vs ->
|
||||
let ac = get_ac vs in
|
||||
let link_id = Pprz.int_assoc "link_id" vs in
|
||||
let link_id = Pprz.string_assoc "link_id" vs in
|
||||
(* Update color and lost time in the strip *)
|
||||
let time_lost = Pprz.float_assoc "time_since_last_msg" vs in
|
||||
let (links_up, total_links) = ac.link_page#links_ratio () in
|
||||
@@ -858,15 +858,15 @@ let get_telemetry_status = fun alarm _sender vs ->
|
||||
let ping_time = Pprz.float_assoc "ping_time" vs in
|
||||
if (not (ac.link_page#link_exists link_id)) then begin
|
||||
ac.link_page#add_link link_id;
|
||||
log_and_say alarm ac.ac_name (sprintf "%s, new link detected: %i" ac.ac_speech_name link_id)
|
||||
log_and_say alarm ac.ac_name (sprintf "%s, new link detected: %s" ac.ac_speech_name link_id)
|
||||
end;
|
||||
let link_changed = ac.link_page#update_link link_id time_lost ping_time rx_msgs_rate downlink_bytes_rate uplink_lost_time in
|
||||
let (links_up, _) = ac.link_page#links_ratio () in
|
||||
match (link_changed, links_up) with
|
||||
(_, 0) -> log_and_say alarm ac.ac_name (sprintf "%s, all links lost" ac.ac_speech_name)
|
||||
| (Pages.Linkup, _)-> log_and_say alarm ac.ac_name (sprintf "%s, link %i re-connected" ac.ac_speech_name link_id)
|
||||
| (Pages.Linkup, _)-> log_and_say alarm ac.ac_name (sprintf "%s, link %s re-connected" ac.ac_speech_name link_id)
|
||||
| (Pages.Nochange, _) -> ()
|
||||
| (Pages.Linkdown, _) -> log_and_say alarm ac.ac_name (sprintf "%s, link %i lost" ac.ac_speech_name link_id)
|
||||
| (Pages.Linkdown, _) -> log_and_say alarm ac.ac_name (sprintf "%s, link %s lost" ac.ac_speech_name link_id)
|
||||
|
||||
let get_engine_status_msg = fun _sender vs ->
|
||||
let ac = get_ac vs in
|
||||
|
||||
@@ -321,26 +321,28 @@ class link ?(visible = fun _ -> true) (widget: GBin.frame) =
|
||||
val mutable links = [] (* Stores the GUI elements that need to be updated and whether the link is connected or not*)
|
||||
val mutable links_up = 0 (* Stores the number of links that are connected*)
|
||||
|
||||
method link_exists link_id =
|
||||
try
|
||||
let link = List.assoc link_id links in
|
||||
ignore link;
|
||||
true
|
||||
with
|
||||
Not_found -> false
|
||||
method link_exists link_id = List.mem_assoc link_id links
|
||||
|
||||
method add_link link_id =
|
||||
let number_of_links = List.length links in
|
||||
let _ = GMisc.label ~text: (sprintf "%i" link_id) ~packing: (table#attach ~top:0 ~left: (number_of_links+1) ) () in
|
||||
let link_status_eventbox = GBin.event_box ~width: 50 ~packing: (table#attach ~top:1 ~left: (number_of_links+1) ) () in
|
||||
let link_status_label = GMisc.label ~text: " " ~packing: link_status_eventbox#add () in
|
||||
let ping_time_label = GMisc.label ~text: " " ~packing: (table#attach ~top:2 ~left: (number_of_links+1) ) () in
|
||||
let rx_bytes_rate_label = GMisc.label ~text: " " ~packing: (table#attach ~top:3 ~left: (number_of_links+1) ) () in
|
||||
let downlink_bytes_rate_label = GMisc.label ~text: " " ~packing: (table#attach ~top:4 ~left: (number_of_links+1) ) () in
|
||||
let uplink_lost_label = GMisc.label ~text: " " ~packing: (table#attach ~top:5 ~left: (number_of_links+1) ) () in
|
||||
let up = true in
|
||||
ignore (links <- (link_id, (up, link_status_eventbox, link_status_label, ping_time_label, rx_bytes_rate_label, downlink_bytes_rate_label, uplink_lost_label)) :: links);
|
||||
links_up <- links_up + 1;
|
||||
(* replace the no_id link if needed *)
|
||||
if List.mem_assoc "no_id" links
|
||||
then begin
|
||||
let (_, dummy1, dummy2, dummy3, dummy4, dummy5, dummy6) = List.assoc "no_id" links in
|
||||
links <- (link_id, (true, dummy1, dummy2, dummy3, dummy4, dummy5, dummy6)) :: (List.remove_assoc "no_id" links)
|
||||
end
|
||||
else begin
|
||||
let number_of_links = List.length links in
|
||||
let _ = GMisc.label ~text: (sprintf "%s" link_id) ~packing: (table#attach ~top:0 ~left: (number_of_links+1) ) () in
|
||||
let link_status_eventbox = GBin.event_box ~width: 50 ~packing: (table#attach ~top:1 ~left: (number_of_links+1) ) () in
|
||||
let link_status_label = GMisc.label ~text: " " ~packing: link_status_eventbox#add () in
|
||||
let ping_time_label = GMisc.label ~text: " " ~packing: (table#attach ~top:2 ~left: (number_of_links+1) ) () in
|
||||
let rx_bytes_rate_label = GMisc.label ~text: " " ~packing: (table#attach ~top:3 ~left: (number_of_links+1) ) () in
|
||||
let downlink_bytes_rate_label = GMisc.label ~text: " " ~packing: (table#attach ~top:4 ~left: (number_of_links+1) ) () in
|
||||
let uplink_lost_label = GMisc.label ~text: " " ~packing: (table#attach ~top:5 ~left: (number_of_links+1) ) () in
|
||||
let up = true in
|
||||
ignore (links <- (link_id, (up, link_status_eventbox, link_status_label, ping_time_label, rx_bytes_rate_label, downlink_bytes_rate_label, uplink_lost_label)) :: links);
|
||||
links_up <- links_up + 1;
|
||||
end
|
||||
|
||||
|
||||
method update_link link_id time_since_last_msg ping_time rx_bytes_rate downlink_bytes_rate uplink_lost_time =
|
||||
|
||||
@@ -64,9 +64,9 @@ class rc_settings :
|
||||
type link_change = Linkup | Nochange | Linkdown
|
||||
class link : ?visible:(GBin.frame -> bool) -> GBin.frame ->
|
||||
object
|
||||
method link_exists : int -> bool
|
||||
method add_link : int -> unit
|
||||
method update_link : int -> float -> float -> float -> int -> int -> link_change
|
||||
method link_exists : string -> bool
|
||||
method add_link : string -> unit
|
||||
method update_link : string -> float -> float -> float -> int -> int -> link_change
|
||||
method links_ratio : unit -> (int * int)
|
||||
method multiple_links : unit -> bool
|
||||
end
|
||||
|
||||
@@ -279,7 +279,7 @@ let send_telemetry_status = fun a ->
|
||||
let id = a.id in
|
||||
let tl_payload = fun link_id datalink_status link_status ->
|
||||
[ "ac_id", Pprz.String id;
|
||||
"link_id", Pprz.Int link_id;
|
||||
"link_id", Pprz.String link_id;
|
||||
"time_since_last_msg", Pprz.Float (U.gettimeofday () -. a.last_msg_date); (* don't use rx_lost_time from LINK_REPORT so it also works in simulation *)
|
||||
"rx_bytes", Pprz.Int link_status.rx_bytes;
|
||||
"rx_msgs", Pprz.Int link_status.rx_msgs;
|
||||
@@ -291,17 +291,17 @@ let send_telemetry_status = fun a ->
|
||||
"downlink_rate", Pprz.Int datalink_status.downlink_rate;
|
||||
"ping_time", Pprz.Float link_status.ping_time]
|
||||
in
|
||||
(* if no link send anyway for rx_lost_time with default link id (0) *)
|
||||
(* if no link send anyway for rx_lost_time with special link id *)
|
||||
if Hashtbl.length a.link_status = 0 then
|
||||
begin
|
||||
let vs = tl_payload 0 a.datalink_status (Aircraft.link_status_init ()) in
|
||||
let vs = tl_payload "no_id" a.datalink_status (Aircraft.link_status_init ()) in
|
||||
Ground_Pprz.message_send my_id "TELEMETRY_STATUS" vs
|
||||
end
|
||||
else
|
||||
(* send telemetry status for each link *)
|
||||
Hashtbl.iter (fun link_id link_status ->
|
||||
try
|
||||
let vs = tl_payload link_id a.datalink_status link_status in
|
||||
let vs = tl_payload (string_of_int link_id) a.datalink_status link_status in
|
||||
Ground_Pprz.message_send my_id "TELEMETRY_STATUS" vs
|
||||
with
|
||||
_exc -> ()
|
||||
|
||||
Reference in New Issue
Block a user