def get_recent_samples(device_ids, n=SEABIRD_RECENT_SAMPLES): samples = [] with imm_components(): with active_line() as serial: for device_id in device_ids: raw = query_samples(serial, device_id, n) samples.extend(parse_samples(device_id, raw)) return samples
def stop(device_ids): with imm_components(): with active_line() as serial: for device_id in device_ids: expected_response = "logging stopped.*" + REMOTE_RESPONSE_END serial_request(serial, "#{0}Stop".format(device_id), expected_response, timeout=10)
def set_interval(device_ids, interval): with imm_components(): with active_line() as serial: for device_id in device_ids: serial_request( serial, "#{0}SampleInterval={1}".format(device_id, interval), REMOTE_RESPONSE_END, timeout=10, )
def get_sample_range(device_ids, begin, end): sample_chunk_size = 100 samples = [] with imm_components(): with active_line() as serial: for device_id in device_ids: for i in xrange(begin, end, sample_chunk_size): samples.extend( _get_sample_range(serial, device_id, i, i + sample_chunk_size)) return samples
def get_all_samples(device_ids): sample_chunk_size = 100 samples = [] with imm_components(): with active_line() as serial: for device_id in device_ids: status = _get_status(serial, device_id) for i in xrange(1, status["samples"], sample_chunk_size): samples.extend( _get_sample_range(serial, device_id, i, i + sample_chunk_size)) return samples
def get_recent_samples(device_ids, n=AQUADOPP_RECENT_SAMPLES): samples = [] with imm_components(): with active_line() as serial: for device_id in device_ids: if n == 1: raw = query_last_sample(serial, device_id) samples.append(parse_sample(device_id, raw)) else: raw = query_sample_list(serial, device_id) sample_list = parse_sample_list(raw) for sample_id in sample_list[-n:]: raw = query_sample(serial, device_id, sample_id) samples.append(parse_sample(device_id, raw)) return samples
def print_status(device_ids): with imm_components(): with active_line() as serial: for device_id in device_ids: print(_get_status(serial, device_id))