|
58 | 58 | pub trajectory: Traj<MsrIn>,
|
59 | 59 | /// Configuration of each device
|
60 | 60 | pub configs: HashMap<String, TrkConfig>,
|
61 |
| - /// Set to true to allow for overlapping measurements (enabled by default), |
62 |
| - /// i.e. if N ground stations are available at a given epoch, generate N measurements not just one. |
63 |
| - pub allow_overlap: bool, |
64 | 61 | /// Random number generator used for this tracking arc, ensures repeatability
|
65 | 62 | rng: Pcg64Mcg,
|
66 | 63 | /// Greatest common denominator time series that allows this arc to meet all of the conditions.
|
@@ -131,7 +128,6 @@ where
|
131 | 128 | devices: devices_map,
|
132 | 129 | trajectory,
|
133 | 130 | configs,
|
134 |
| - allow_overlap: false, |
135 | 131 | rng,
|
136 | 132 | time_series,
|
137 | 133 | _msr_in: PhantomData,
|
@@ -290,7 +286,10 @@ impl TrackingArcSim<Orbit, RangeDoppler, GroundStation> {
|
290 | 286 | /// 3. Find when the vehicle trajectory has an elevation less than zero (i.e. disappears below the horizon), after that initial epoch
|
291 | 287 | /// 4. Repeat 2, 3 until the end of the trajectory
|
292 | 288 | /// 5. Build each of these as "tracking strands" for this tracking device.
|
293 |
| - /// 6. THEN REMOVE OVERLAPPING MEASUREMENTS - ALGO TBD |
| 289 | + /// 6. Organize all of the built tracking strands chronologically. |
| 290 | + /// 7. Iterate through all of the strands: |
| 291 | + /// 7.a. if that tracker is marked as `Greedy` and it ends after the start of the next strand, change the start date of the next strand. |
| 292 | + /// 7.b. if that tracker is marked as `Eager` and it ends after the start of the next strand, change the end date of the current strand. |
294 | 293 | pub fn generate_schedule(
|
295 | 294 | &self,
|
296 | 295 | cosm: Arc<Cosm>,
|
@@ -438,7 +437,10 @@ impl TrackingArcSim<Spacecraft, RangeDoppler, GroundStation> {
|
438 | 437 | /// 3. Find when the vehicle trajectory has an elevation less than zero (i.e. disappears below the horizon), after that initial epoch
|
439 | 438 | /// 4. Repeat 2, 3 until the end of the trajectory
|
440 | 439 | /// 5. Build each of these as "tracking strands" for this tracking device.
|
441 |
| - /// 6. THEN REMOVE OVERLAPPING MEASUREMENTS - ALGO TBD |
| 440 | + /// 6. Organize all of the built tracking strands chronologically. |
| 441 | + /// 7. Iterate through all of the strands: |
| 442 | + /// 7.a. if that tracker is marked as `Greedy` and it ends after the start of the next strand, change the start date of the next strand. |
| 443 | + /// 7.b. if that tracker is marked as `Eager` and it ends after the start of the next strand, change the end date of the current strand. |
442 | 444 | pub fn generate_schedule(
|
443 | 445 | &self,
|
444 | 446 | cosm: Arc<Cosm>,
|
@@ -513,7 +515,50 @@ impl TrackingArcSim<Spacecraft, RangeDoppler, GroundStation> {
|
513 | 515 | }
|
514 | 516 | }
|
515 | 517 | }
|
516 |
| - // todo!("remove overlaps") |
| 518 | + |
| 519 | + // Build all of the strands, remembering which tracker they come from. |
| 520 | + let mut cfg_as_vec = Vec::new(); |
| 521 | + for (name, cfg) in &built_cfg { |
| 522 | + for (ii, strand) in cfg.strands.as_ref().unwrap().iter().enumerate() { |
| 523 | + cfg_as_vec.push((name.clone(), ii, *strand)); |
| 524 | + } |
| 525 | + } |
| 526 | + // Iterate through the strands by chronological order. Cannot use maps because we change types. |
| 527 | + cfg_as_vec.sort_by_key(|(_, _, strand)| strand.start); |
| 528 | + for (ii, (this_name, this_pos, this_strand)) in |
| 529 | + cfg_as_vec.iter().take(cfg_as_vec.len() - 1).enumerate() |
| 530 | + { |
| 531 | + // Grab the config |
| 532 | + if let Some(config) = self.configs[this_name].scheduler.as_ref() { |
| 533 | + // Grab the next strand, chronologically |
| 534 | + if let Some((next_name, next_pos, next_strand)) = cfg_as_vec.get(ii + 1) { |
| 535 | + if config.handoff == Handoff::Greedy && this_strand.end >= next_strand.start { |
| 536 | + // Modify the built configurations to change the start time of the next strand because the current one is greedy. |
| 537 | + let next_config = built_cfg.get_mut(next_name).unwrap(); |
| 538 | + let new_start = this_strand.end + next_config.sampling; |
| 539 | + next_config.strands.as_mut().unwrap()[*next_pos].start = new_start; |
| 540 | + info!( |
| 541 | + "{this_name} configured as {:?}, so {next_name} now starts on {new_start}", |
| 542 | + config.handoff |
| 543 | + ); |
| 544 | + } else if config.handoff == Handoff::Eager |
| 545 | + && this_strand.end >= next_strand.start |
| 546 | + { |
| 547 | + let this_config = built_cfg.get_mut(this_name).unwrap(); |
| 548 | + let new_end = next_strand.start - this_config.sampling; |
| 549 | + this_config.strands.as_mut().unwrap()[*this_pos].end = new_end; |
| 550 | + info!( |
| 551 | + "{this_name} now hands off to {next_name} on {new_end} because it's configured as {:?}", |
| 552 | + config.handoff |
| 553 | + ); |
| 554 | + } |
| 555 | + } else { |
| 556 | + // Reached the end |
| 557 | + break; |
| 558 | + } |
| 559 | + } |
| 560 | + } |
| 561 | + |
517 | 562 | Ok(built_cfg)
|
518 | 563 | }
|
519 | 564 |
|
|
0 commit comments