diff --git a/software/management/dashboard/parse.py b/software/management/dashboard/parse.py new file mode 100644 index 00000000..293c956b --- /dev/null +++ b/software/management/dashboard/parse.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import sys +from tottag import * + + +def process_tottag_data(data, experiment_start_time): + i = 0 + log_data = defaultdict(dict) + while i + 5 < len(data): + timestamp_raw = struct.unpack(' int(time.time()) or ((timestamp_raw % 500) != 0) or data[i] < 1 or data[i] >= STORAGE_NUM_TYPES: + i += 1 + elif data[i] == STORAGE_TYPE_VOLTAGE: + datum = struct.unpack(' 0 and datum < 4500: + log_data[timestamp]['v'] = datum + i += 9 + else: + i += 1 + elif data[i] == STORAGE_TYPE_CHARGING_EVENT: + if data[i+5] > 0 and data[i+5] < 5: + log_data[timestamp]['c'] = BATTERY_CODES[data[i+5]] + i += 6 + else: + i += 1 + elif data[i] == STORAGE_TYPE_MOTION: + if data[i+5] == 0 or data[i+5] == 1: + log_data[timestamp]['m'] = data[i+5] > 0 + i += 6 + else: + i += 1 + elif data[i] == STORAGE_TYPE_RANGES: + log_data[timestamp]['r'] = {} + if data[i+5] < MAX_NUM_DEVICES: + for j in range(data[i+5]): + uid = data[i+6+(j*3)] + datum = struct.unpack('