diff --git a/dish_common.py b/dish_common.py index 3e5ba16..9b67279 100644 --- a/dish_common.py +++ b/dish_common.py @@ -130,8 +130,7 @@ def run_arg_parser(parser, need_id=False, no_stdout_errors=False): opts.bulk_mode = "bulk_history" in opts.mode if opts.samples is None: - opts.samples = int(opts.loop_interval * - opts.poll_loops) if opts.loop_interval >= 1.0 else SAMPLES_DEFAULT + opts.samples = int(opts.loop_interval) if opts.loop_interval >= 1.0 else SAMPLES_DEFAULT opts.bulk_samples = -1 else: opts.bulk_samples = opts.samples @@ -272,23 +271,25 @@ def get_history_stats(opts, gstate, add_item, add_sequence): conn_error(opts, "Failure getting history: %s", str(starlink_grpc.GrpcError(e))) history = None + parse_samples = opts.samples if gstate.counter_stats is None else -1 + start = gstate.counter_stats if gstate.counter_stats else None + # Accumulate polled history data into gstate.accum_history, even if there # was a dish reboot. if gstate.accum_history: if history is not None: - # This gets too complicated to handle across reboots once the data - # has been accumulated, so just have concatenate do it on the - # first pass and use a value of 0 to remember it was done (as - # opposed to None, which is used for a different purpose). - if gstate.counter_stats: - start = gstate.counter_stats - gstate.counter_stats = 0 - else: - start = None gstate.accum_history = starlink_grpc.concatenate_history(gstate.accum_history, history, - start=start, + samples1=parse_samples, + start1=start, verbose=opts.verbose) + # Counter tracking gets too complicated to handle across reboots + # once the data has been accumulated, so just have concatenate + # handle it on the first polled loop and use a value of 0 to + # remember it was done (as opposed to None, which is used for a + # different purpose). + if not opts.no_counter: + gstate.counter_stats = 0 else: gstate.accum_history = history @@ -303,8 +304,6 @@ def get_history_stats(opts, gstate, add_item, add_sequence): gstate.poll_count = 0 - start = gstate.counter_stats if gstate.counter_stats else None - parse_samples = opts.samples if gstate.counter_stats is None else -1 groups = starlink_grpc.history_stats(parse_samples, start=start, verbose=opts.verbose, diff --git a/starlink_grpc.py b/starlink_grpc.py index 5cd81ee..b3267e2 100644 --- a/starlink_grpc.py +++ b/starlink_grpc.py @@ -846,8 +846,8 @@ def _compute_sample_range(history, parse_samples, start=None, verbose=False): return sample_range, current - start, current -def concatenate_history(history1, history2, start=None, verbose=False): - """ Append the sample-dependent fields of one history object to another. +def concatenate_history(history1, history2, samples1=-1, start1=None, verbose=False): + """Append the sample-dependent fields of one history object to another. Note: Samples data will be appended regardless of dish reboot or history @@ -860,7 +860,9 @@ def concatenate_history(history1, history2, start=None, verbose=False): to append. history2: The grpc history object, such as one returned by a prior call to `get_history`, from which to append. - start (int): Optional starting counter value to be applied to the + samples1 (int): Optional number of samples to process, or -1 to parse + all available samples (bounded by start1, if it is set). + start1 (int): Optional starting counter value to be applied to the history1 data. See `history_bulk_data` documentation for more details on how this parameter is used. verbose (bool): Optionally produce verbose output. @@ -889,7 +891,7 @@ def concatenate_history(history1, history2, start=None, verbose=False): unwrapped.unwrapped = True sample_range, ignore1, ignore2 = _compute_sample_range( # pylint: disable=unused-variable - history1, len(history1.pop_ping_drop_rate), start=start) + history1, samples1, start=start1) for i in sample_range: for field in HISTORY_FIELDS: getattr(unwrapped, field).append(getattr(history1, field)[i])