summaryrefslogtreecommitdiff
path: root/lib/loader/generic.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-03-22 16:47:21 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2021-03-22 16:47:21 +0100
commit9284ed037c001d8aa150adbeac533929b6e03a66 (patch)
treefdd0a1d6f0a593950b197e210f225b823d96b86d /lib/loader/generic.py
parent7d3f011f0ce1a07ab9f041e6f73392fcd0e1585d (diff)
EnergyTraceWithLogicAnalyzer: Use ExternalTimerSync as well
DataProcessor is now deprecated and no longer in use
Diffstat (limited to 'lib/loader/generic.py')
-rw-r--r--lib/loader/generic.py43
1 files changed, 25 insertions, 18 deletions
diff --git a/lib/loader/generic.py b/lib/loader/generic.py
index 984cf06..78305e0 100644
--- a/lib/loader/generic.py
+++ b/lib/loader/generic.py
@@ -41,7 +41,10 @@ class ExternalTimerSync:
# * self.sync_min_high_count, self.sync_min_low_count: outlier handling in synchronization pulse detection
# * self.sync_power, self.sync_min_duration: synchronization pulse parameters. one pulse before the measurement, two pulses afterwards
# expected_trace must contain online timestamps
- def analyze_states(self, expected_trace, repeat_id):
+ def analyze_states(self, expected_trace, repeat_id, online_timestamps=None):
+ """
+ :param online_timestamps: must start at 0, if set
+ """
sync_start = None
sync_timestamps = list()
high_count = 0
@@ -81,24 +84,28 @@ class ExternalTimerSync:
start_ts = sync_timestamps[0][1]
end_ts = sync_timestamps[1][0]
- # start and end of first state
- online_timestamps = [0, expected_trace[0]["start_offset"][repeat_id]]
-
- # remaining events from the end of the first transition (start of second state) to the end of the last observed state
- try:
- for trace in expected_trace:
- for word in trace["trace"]:
- online_timestamps.append(
- online_timestamps[-1]
- + word["online_aggregates"]["duration"][repeat_id]
- )
- except IndexError:
- self.errors.append(
- f"""offline_index {repeat_id} missing in trace {trace["id"]}"""
- )
- return list()
+ if online_timestamps is None:
+ # start and end of first state
+ online_timestamps = [0, expected_trace[0]["start_offset"][repeat_id]]
+
+ # remaining events from the end of the first transition (start of second state) to the end of the last observed state
+ try:
+ for trace in expected_trace:
+ for word in trace["trace"]:
+ online_timestamps.append(
+ online_timestamps[-1]
+ + word["online_aggregates"]["duration"][repeat_id]
+ )
+ except IndexError:
+ self.errors.append(
+ f"""offline_index {repeat_id} missing in trace {trace["id"]}"""
+ )
+ return list()
+
+ online_timestamps = np.array(online_timestamps) * 1e-6
+ else:
+ online_timestamps = np.array(online_timestamps)
- online_timestamps = np.array(online_timestamps) * 1e-6
online_timestamps = (
online_timestamps
* ((end_ts - start_ts) / (online_timestamps[-1] - online_timestamps[0]))