summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-10-19 14:28:43 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2020-10-19 14:28:43 +0200
commitdb41acafd2abeca153c9f552e82cd26968092cb3 (patch)
tree8e4a0bb6ede8de2a805aa0c9e0d32c4f7afe5a05
parentf308a519edecd8ee92f2fe18552620a569f48d3b (diff)
ET+LA: add --plot-traces support, actually calculate standard deviation.
Jungejungejungejungejunge...
-rw-r--r--lib/lennart/DataProcessor.py27
-rw-r--r--lib/loader.py10
2 files changed, 21 insertions, 16 deletions
diff --git a/lib/lennart/DataProcessor.py b/lib/lennart/DataProcessor.py
index 58cc705..27005b1 100644
--- a/lib/lennart/DataProcessor.py
+++ b/lib/lennart/DataProcessor.py
@@ -1,3 +1,4 @@
+import numpy as np
import logging
logger = logging.getLogger(__name__)
@@ -248,13 +249,13 @@ class DataProcessor:
def getPowerBetween(self, start, end, state_sleep): # 0.001469
"""
- calculates the average powerusage in interval
+ calculates the powerusage in interval
NOT SIDE EFFECT FREE, DON'T USE IT EVERYWHERE
:param start: Start timestamp of interval
:param end: End timestamp of interval
:param state_sleep: Length in seconds of one state, needed for cutting out the UART Sending cycle
- :return: float with average power usage
+ :return: power measurements in W
"""
first_index = 0
all_power = []
@@ -297,9 +298,9 @@ class DataProcessor:
elif len(all_power) == 1:
# print("OKAY")
pass
- return pre_fix_len, sum(all_power) / len(all_power)
+ return np.array(all_power)
- def getStatesdfatool(self, state_sleep, algorithm=False):
+ def getStatesdfatool(self, state_sleep, with_traces=False, algorithm=False):
"""
Calculates the length and energy usage of the states
@@ -325,14 +326,14 @@ class DataProcessor:
start_transition_ts_timing = self.reduced_timestamps[ts_index * 2]
if end_transition_ts is not None:
- count_dp, power = self.getPowerBetween(
+ power = self.getPowerBetween(
end_transition_ts, start_transition_ts, state_sleep
)
# print("STATE", end_transition_ts * 10 ** 6, start_transition_ts * 10 ** 6, (start_transition_ts - end_transition_ts) * 10 ** 6, power)
if (
(start_transition_ts - end_transition_ts) * 10 ** 6 > 900_000
- and power > self.power_sync_watt * 0.9
+ and np.mean(power) > self.power_sync_watt * 0.9
and ts_index > 10
):
# remove last transition and stop (upcoming data only sync)
@@ -342,8 +343,9 @@ class DataProcessor:
state = {
"isa": "state",
- "W_mean": power,
- "W_std": 0.0001,
+ "W_mean": np.mean(power),
+ "W_std": np.std(power),
+ "uW": power * 1e6,
"s": (
start_transition_ts_timing - end_transition_ts_timing
), # * 10 ** 6,
@@ -356,7 +358,7 @@ class DataProcessor:
# get energy end_transition_ts
end_transition_ts = self.modified_timestamps[ts_index * 2 + 1]
- count_dp, power = self.getPowerBetween(
+ power = self.getPowerBetween(
start_transition_ts, end_transition_ts, state_sleep
)
@@ -365,12 +367,13 @@ class DataProcessor:
transition = {
"isa": "transition",
- "W_mean": power,
- "W_std": 0.0001,
+ "W_mean": np.mean(power),
+ "W_std": np.std(power),
+ "uW": power * 1e6,
"s": (
end_transition_ts_timing - start_transition_ts_timing
), # * 10 ** 6,
- "count_dp": count_dp,
+ "count_dp": len(power),
}
if (end_transition_ts - start_transition_ts) * 10 ** 6 > 2_000_000:
diff --git a/lib/loader.py b/lib/loader.py
index e004fe1..94a76b3 100644
--- a/lib/loader.py
+++ b/lib/loader.py
@@ -1656,8 +1656,6 @@ class EnergyTraceWithLogicAnalyzer:
self.sync_data = SigrokResult.fromString(log_data[0])
self.energy_data = EnergyInterface.getDataFromString(str(log_data[1]))
- pass
-
def analyze_states(self, traces, offline_index: int):
"""
Split log data into states and transitions and return duration, energy, and mean power for each element.
@@ -1693,9 +1691,13 @@ class EnergyTraceWithLogicAnalyzer:
dp = DataProcessor(sync_data=self.sync_data, energy_data=self.energy_data)
dp.run()
energy_trace_new = list()
- energy_trace_new.extend(dp.getStatesdfatool(state_sleep=self.state_duration))
+ energy_trace_new.extend(
+ dp.getStatesdfatool(
+ state_sleep=self.state_duration, with_traces=self.with_traces
+ )
+ )
# Uncomment to plot traces
- # dp.plot() # <- plot traces with sync annotatons
+ # dp.plot() # <- plot traces with sync annotatons
# dp.plot(names) # <- plot annotated traces (with state/transition names)
energy_trace_new = energy_trace_new[4:]