From 5c2cca6dc8b8583c9c11389645998bfc42723a06 Mon Sep 17 00:00:00 2001 From: cgbsat Date: Sat, 11 May 2019 17:45:41 +0000 Subject: [PATCH] Usage cleanup and wait time bug fix --- schedule_single_station.py | 19 +++++++++++++------ utils.py | 10 +++++----- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/schedule_single_station.py b/schedule_single_station.py index f62a686..3ac5627 100755 --- a/schedule_single_station.py +++ b/schedule_single_station.py @@ -85,10 +85,10 @@ def main(): "--duration", help="Duration to schedule [hours; default 1.0]", type=float, - default=1) + default=1.0) parser.add_argument("-m", "--min-horizon", - help="Minimum horizon [default 0]", + help="Minimum horizon [default 0.0]", type=float, default=0.) parser.add_argument("-f", @@ -100,9 +100,8 @@ def main(): parser.add_argument("-w", "--wait", help="Wait time between consecutive observations (for setup and slewing)" + - " [seconds; default: 0.0]", + " [seconds; default: 0, max 3600]", type=int, - choices=range(0, 3600), default=0) parser.add_argument("-n", "--dryrun", @@ -138,8 +137,16 @@ def main(): # Settings ground_station_id = args.station - length_hours = args.duration - wait_time_seconds = args.wait + if args.duration>0.0: + length_hours = args.duration + else: + length_hours = 1.0 + if args.wait<=0: + wait_time_seconds = 0 + elif args.wait<=3600: + wait_time_seconds = args.wait + else: + wait_time_seconds = 3600 min_horizon_arg = args.min_horizon cache_dir = "/tmp/cache" schedule = not args.dryrun diff --git a/utils.py b/utils.py index 594a575..9283119 100644 --- a/utils.py +++ b/utils.py @@ -150,20 +150,20 @@ def overlap(satpass, scheduledpasses, wait_time_seconds): # Loop over scheduled passes for scheduledpass in scheduledpasses: # Test pass falls within scheduled pass - if tr >= scheduledpass['tr'] and ts < scheduledpass['ts']: + if tr >= scheduledpass['tr'] and ts < scheduledpass['ts'] + timedelta(seconds=wait_time_seconds): overlap = True # Scheduled pass falls within test pass - elif scheduledpass['tr'] >= tr and scheduledpass['ts'] < ts: + elif scheduledpass['tr'] >= tr and scheduledpass['ts'] + timedelta(seconds=wait_time_seconds) < ts: overlap = True # Pass start falls within pass - elif tr >= scheduledpass['tr'] and tr < scheduledpass['ts']: + elif tr >= scheduledpass['tr'] and tr < scheduledpass['ts'] + timedelta(seconds=wait_time_seconds): overlap = True # Pass end falls within end - elif ts >= scheduledpass['tr'] and ts < scheduledpass['ts']: + elif ts >= scheduledpass['tr'] and ts < scheduledpass['ts'] + timedelta(seconds=wait_time_seconds): overlap = True if overlap: break - + return overlap