summaryrefslogtreecommitdiff
path: root/lib/lennart
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-12-03 15:16:24 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2020-12-03 15:16:24 +0100
commit85374727ad66b884b25ddd659600ee9317db071b (patch)
tree36c29c86feb8bfa3e3fdb7fd18d11dd7be7c7eb8 /lib/lennart
parente226cb81dd57b9810a093936e750a0e2d4512173 (diff)
use common energytrace loader code
this also fixes a nasty off-by-one in the barcode loader (now _load_energytrace): wrong: interval_start_timestamp = data[:-1, 0] * 1e-6 correct: interval_start_timestamp = data[1:, 0] * 1e-6
Diffstat (limited to 'lib/lennart')
-rw-r--r--lib/lennart/DataProcessor.py37
-rw-r--r--lib/lennart/EnergyInterface.py33
2 files changed, 12 insertions, 58 deletions
diff --git a/lib/lennart/DataProcessor.py b/lib/lennart/DataProcessor.py
index 32d4dae..a8b49bf 100644
--- a/lib/lennart/DataProcessor.py
+++ b/lib/lennart/DataProcessor.py
@@ -7,7 +7,7 @@ logger = logging.getLogger(__name__)
class DataProcessor:
- def __init__(self, sync_data, energy_data):
+ def __init__(self, sync_data, et_timestamps, et_power):
"""
Creates DataProcessor object.
@@ -18,13 +18,14 @@ class DataProcessor:
# high-precision LA/Timer timestamps at synchronization events
self.sync_timestamps = []
# low-precision energytrace timestamps
- self.et_timestamps = []
+ self.et_timestamps = et_timestamps
# energytrace power values
- self.et_power_values = []
+ self.et_power_values = et_power
self.sync_data = sync_data
- self.energy_data = energy_data
self.start_offset = 0
+ # TODO determine automatically based on minimum (or p1) power draw over measurement area + X
+ # use 0.02 for HFXT runs
self.power_sync_watt = 0.011
self.power_sync_len = 0.7
self.power_sync_max_outliers = 2
@@ -53,8 +54,6 @@ class DataProcessor:
f"LogicAnalyzer sync data has length {len(time_stamp_data)}, expected >= 12"
)
- last_data = [0, 0, 0, 0]
-
self.raw_sync_timestamps = time_stamp_data
# NEW
@@ -63,11 +62,8 @@ class DataProcessor:
outliers = 0
pre_outliers_ts = None
# TODO only consider the first few and the last few seconds for sync points
- for i, energytrace_dataset in enumerate(self.energy_data):
- usedtime = energytrace_dataset[0] - last_data[0] # in microseconds
- timestamp = energytrace_dataset[0]
- usedenergy = energytrace_dataset[3] - last_data[3]
- power = usedenergy / usedtime * 1e-3 # in watts
+ for i, timestamp in enumerate(self.et_timestamps):
+ power = self.et_power_values[i]
if power > 0:
if power > self.power_sync_watt:
if sync_start is None:
@@ -80,27 +76,18 @@ class DataProcessor:
outliers += 1
if outliers > self.power_sync_max_outliers:
if sync_start is not None:
- if (
- pre_outliers_ts - sync_start
- ) / 1_000_000 > self.power_sync_len:
+ if (pre_outliers_ts - sync_start) > self.power_sync_len:
datasync_timestamps.append(
(
- sync_start / 1_000_000,
- pre_outliers_ts / 1_000_000,
+ sync_start,
+ pre_outliers_ts,
)
)
sync_start = None
- last_data = energytrace_dataset
-
- self.et_timestamps.append(timestamp / 1_000_000)
- self.et_power_values.append(power)
-
if power > self.power_sync_watt:
- if (self.energy_data[-1][0] - sync_start) / 1_000_000 > self.power_sync_len:
- datasync_timestamps.append(
- (sync_start / 1_000_000, pre_outliers_ts / 1_000_000)
- )
+ if (self.et_timestamps[-1] - sync_start) > self.power_sync_len:
+ datasync_timestamps.append((sync_start, pre_outliers_ts))
# print(datasync_timestamps)
diff --git a/lib/lennart/EnergyInterface.py b/lib/lennart/EnergyInterface.py
index 19aae84..55bf7c1 100644
--- a/lib/lennart/EnergyInterface.py
+++ b/lib/lennart/EnergyInterface.py
@@ -70,39 +70,6 @@ class EnergyInterface(DataInterface):
return
self.energytrace.wait()
- def getData(self):
- """
- cleans the string data and creates int list
- :return: list of data, in format [[int,int,int,int], [int,int,int,int], ... ]
- """
- energytrace_log = open(self.temp_file)
- lines = energytrace_log.readlines()[21:]
- data = []
- for line in lines:
- if "MSP430_DisableEnergyTrace" in line:
- break
- else:
- data.append([int(i) for i in line.split()])
- return data
-
- @classmethod
- def getDataFromString(cls, string, delimiter="\\n"):
- """
- Parsing the data from string
-
- :param string: input string which will be parsed
- :param delimiter: for normal file its \n
- :return: list of data, in format [[int,int,int,int], [int,int,int,int], ... ]
- """
- lines = string.split(delimiter)[21:]
- data = []
- for line in lines:
- if "MSP430_DisableEnergyTrace" in line:
- break
- else:
- data.append([int(i) for i in line.split()])
- return data
-
def setFile(self, path):
"""
changeing the temporary file