Contact Graph Routing for time-varying satellite networks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(lint): resolve E205 Printf/Format usage and add missing fmt deps

Replace Printf.sprintf/printf with Fmt.str/pr across cbort, cfdp,
cgr, claudeio, clcw, conpool, cookeio, and cpio packages. Add fmt
library dependency to dune files where needed.

+17 -18
+1 -1
example/dune
··· 1 1 (executable 2 2 (name tle_contacts) 3 - (libraries cgr sgp4)) 3 + (libraries cgr sgp4 fmt))
+16 -17
example/tle_contacts.ml
··· 166 166 let load_or_default_tles tle_file = 167 167 try load_tle_file tle_file 168 168 with Sys_error _ -> 169 - Printf.eprintf "Could not load %s, using embedded TLEs\n" tle_file; 169 + Fmt.epr "Could not load %s, using embedded TLEs\n" tle_file; 170 170 {|STARLINK-1008 171 171 1 44714U 19074B 26034.10858321 -.00000474 00000+0 -36567-5 0 9992 172 172 2 44714 53.1593 339.5849 0001299 80.4695 279.6453 15.31021178343579 ··· 184 184 2 44747 53.0433 259.4358 0003715 91.8857 268.2575 15.47997310344749|} 185 185 186 186 let print_routing_analysis plan nodes ~start_time = 187 - Printf.printf "\nRouting analysis:\n"; 187 + Fmt.pr "\nRouting analysis:\n"; 188 188 let total_pairs = ref 0 in 189 189 let routable_pairs = ref 0 in 190 190 let check_route src dst = ··· 194 194 match Cgr.route plan ~src ~dst ~time:start_time with 195 195 | Some route -> 196 196 incr routable_pairs; 197 - Printf.printf " %s -> %s: %d hops, latency %.3f s\n" 198 - (Cgr.Node.name src) (Cgr.Node.name dst) 197 + Fmt.pr " %s -> %s: %d hops, latency %.3f s\n" (Cgr.Node.name src) 198 + (Cgr.Node.name dst) 199 199 (List.length (Cgr.Route.hops route)) 200 200 (Cgr.Route.latency route) 201 201 | None -> 202 - Printf.printf " %s -> %s: NO ROUTE\n" (Cgr.Node.name src) 202 + Fmt.pr " %s -> %s: NO ROUTE\n" (Cgr.Node.name src) 203 203 (Cgr.Node.name dst) 204 204 end 205 205 in 206 206 List.iter (fun src -> List.iter (check_route src) nodes) nodes; 207 - Printf.printf "\nRoutability: %d/%d pairs (%.1f%%)\n" !routable_pairs 208 - !total_pairs 207 + Fmt.pr "\nRoutability: %d/%d pairs (%.1f%%)\n" !routable_pairs !total_pairs 209 208 (100. *. Float.of_int !routable_pairs /. Float.of_int !total_pairs) 210 209 211 210 let example () = ··· 213 212 let tle_file = "ocaml-cgr/example/starlink.tle" in 214 213 let tle_text = load_or_default_tles tle_file in 215 214 let sats = parse_tles tle_text in 216 - Printf.printf "Loaded %d Starlink satellites\n" (List.length sats); 217 - List.iter (fun s -> Printf.printf " - %s\n" s.name) sats; 215 + Fmt.pr "Loaded %d Starlink satellites\n" (List.length sats); 216 + List.iter (fun s -> Fmt.pr " - %s\n" s.name) sats; 218 217 219 218 (* Use epoch time from first TLE as reference *) 220 219 let start_time = 221 220 match sats with sat :: _ -> Sgp4.epoch_unix sat.tle | [] -> 1704067200. 222 221 in 223 - Printf.printf "\nSimulation start: %.0f (Unix time)\n" start_time; 222 + Fmt.pr "\nSimulation start: %.0f (Unix time)\n" start_time; 224 223 225 224 (* Generate contacts for 2 orbits (~180 minutes) *) 226 225 let duration = 10800. in 227 226 let rate = 1_000_000_000. in 228 227 (* 1 Gbps ISL *) 229 - Printf.printf "Generating contacts over %.0f seconds (%.1f hours)...\n" 230 - duration (duration /. 3600.); 228 + Fmt.pr "Generating contacts over %.0f seconds (%.1f hours)...\n" duration 229 + (duration /. 3600.); 231 230 232 231 let contacts = 233 232 generate_contacts ~step:30. ~max_range:5000. ~rate sats ~start_time 234 233 ~duration 235 234 in 236 - Printf.printf "Generated %d contacts\n" (List.length contacts); 235 + Fmt.pr "Generated %d contacts\n" (List.length contacts); 237 236 238 237 (* Create contact plan *) 239 238 let plan = Cgr.Contact_plan.of_list contacts in 240 239 let nodes = Cgr.Contact_plan.nodes plan in 241 - Printf.printf "Network has %d nodes\n\n" (List.length nodes); 240 + Fmt.pr "Network has %d nodes\n\n" (List.length nodes); 242 241 243 242 (* Show some contact statistics *) 244 - Printf.printf "Contact plan summary:\n"; 243 + Fmt.pr "Contact plan summary:\n"; 245 244 List.iter 246 245 (fun node -> 247 246 let from_count = List.length (Cgr.Contact_plan.contacts_from plan node) in 248 247 let to_count = List.length (Cgr.Contact_plan.contacts_to plan node) in 249 - Printf.printf " %s: %d outgoing, %d incoming contacts\n" 250 - (Cgr.Node.name node) from_count to_count) 248 + Fmt.pr " %s: %d outgoing, %d incoming contacts\n" (Cgr.Node.name node) 249 + from_count to_count) 251 250 nodes; 252 251 253 252 print_routing_analysis plan nodes ~start_time