Skip to content

Commit

Permalink
Ignore B radar in replay mode
Browse files Browse the repository at this point in the history
  • Loading branch information
keesverruijt committed Aug 26, 2024
1 parent 262b514 commit d07cd13
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async fn main() -> Result<()> {
warn!("Replay mode activated, this does the following:");
warn!(" * A circle is drawn at the last two pixels in each spoke");
warn!(" * Timestamp on each spoke is as if received now");
warn!(" * Any 4G/HALO secondary radar B is ignored and not reported");
}
if args.record > 0 {
warn!(
Expand All @@ -65,7 +66,7 @@ async fn main() -> Result<()> {
warn!("to stdout. The data is in 'protobuf' format and consists of RadarMessages.");
}

let radars = Radars::new();
let radars = Radars::new(args.clone()); // TODO args moet hier in
let radars_clone1 = radars.clone();

let web = Web::new(args.port, radars_clone1);
Expand Down
13 changes: 8 additions & 5 deletions src/radar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::{
use thiserror::Error;

use crate::locator::LocatorId;
use crate::Cli;

#[derive(Error, Debug)]
pub enum RadarError {
Expand Down Expand Up @@ -213,12 +214,14 @@ impl Display for RadarInfo {
#[derive(Clone, Debug)]
pub struct Radars {
pub info: HashMap<String, RadarInfo>,
pub args: Cli,
}

impl Radars {
pub fn new() -> Arc<RwLock<Radars>> {
pub fn new(args: Cli) -> Arc<RwLock<Radars>> {
Arc::new(RwLock::new(Radars {
info: HashMap::new(),
args,
}))
}
}
Expand All @@ -229,10 +232,10 @@ impl Radars {
let mut radars = radars.write().unwrap();
let count = radars.info.len();

// For now, drop second radar...
// if count > 0 {
// return None;
// }
// For now, drop second radar in replay Mode...
if radars.args.replay && key.ends_with("-B") {
return None;
}
let entry = radars.info.entry(key).or_insert(new_info);

if entry.id == usize::MAX {
Expand Down

0 comments on commit d07cd13

Please sign in to comment.