diff options
-rw-r--r-- | lib/harness.py | 10 | ||||
-rw-r--r-- | lib/loader.py | 61 | ||||
-rw-r--r-- | lib/runner.py | 6 |
3 files changed, 40 insertions, 37 deletions
diff --git a/lib/harness.py b/lib/harness.py index 833807e..f0f2837 100644 --- a/lib/harness.py +++ b/lib/harness.py @@ -141,9 +141,7 @@ class TransitionHarness: def start_trace(self): """Prepare a new trace/run in the internal `.traces` structure.""" - self.traces.append( - {"id": self.trace_id, "trace": list(),} - ) + self.traces.append({"id": self.trace_id, "trace": list()}) self.trace_id += 1 def append_state(self, state_name, param): @@ -154,7 +152,7 @@ class TransitionHarness: :param param: parameter dict """ self.traces[-1]["trace"].append( - {"name": state_name, "isa": "state", "parameter": param,} + {"name": state_name, "isa": "state", "parameter": param} ) def append_transition(self, transition_name, param, args=[]): @@ -405,7 +403,7 @@ class OnboardTimerHarness(TransitionHarness): ret = "#define PTALOG_TIMING\n" ret += super().global_code() if self.energytrace_sync == "led": - #TODO Make nicer + # TODO Make nicer ret += """\nvoid runLASync(){ // ======================= LED SYNC ================================ ptalog.passTransition(0); @@ -424,7 +422,7 @@ class OnboardTimerHarness(TransitionHarness): gpio.led_toggle(1); ptalog.stopTransition(); // ======================= LED SYNC ================================ - arch.sleep_ms(250); + //arch.sleep_ms(250); }\n\n""" return ret diff --git a/lib/loader.py b/lib/loader.py index d14680e..4ae883e 100644 --- a/lib/loader.py +++ b/lib/loader.py @@ -1648,7 +1648,7 @@ class EnergyTraceWithLogicAnalyzer: pass - def analyze_states(self, traces, offline_index: int): + def analyze_states(self, traces, offline_index: int, timer_measurement=False): u""" Split log data into states and transitions and return duration, energy, and mean power for each element. @@ -1673,24 +1673,25 @@ class EnergyTraceWithLogicAnalyzer: * `W_mean_delta_next`: Differenz zwischen W_mean und W_mean des Folgezustands """ - names = [] for trace_number, trace in enumerate(traces): for state_or_transition in trace["trace"]: names.append(state_or_transition["name"]) - #print(names[:15]) + # print(names[:15]) dp = DataProcessor(sync_data=self.sync_data, energy_data=self.energy_data) - dp.run() + dp.run(timer_measurement) energy_trace_new = list() energy_trace_new.extend(dp.getStatesdfatool(state_sleep=self.state_duration)) - #dp.plot() - #dp.plot(names) + dp.plot() + # dp.plot(names) energy_trace_new = energy_trace_new[4:] energy_trace = list() expected_transitions = list() for trace_number, trace in enumerate(traces): - for state_or_transition_number, state_or_transition in enumerate(trace["trace"]): + for state_or_transition_number, state_or_transitistddevon in enumerate( + trace["trace"] + ): if state_or_transition["isa"] == "transition": try: expected_transitions.append( @@ -1713,8 +1714,6 @@ class EnergyTraceWithLogicAnalyzer: ) return energy_trace - - for number, item in enumerate(expected_transitions): name, duration = item transition = { @@ -1729,7 +1728,7 @@ class EnergyTraceWithLogicAnalyzer: if len(energy_trace) > 1: energy_trace[-1]["W_mean_delta_prev"] = ( - energy_trace[-1]["W_mean"] - energy_trace[-2]["W_mean"] + energy_trace[-1]["W_mean"] - energy_trace[-2]["W_mean"] ) state = { @@ -1743,35 +1742,39 @@ class EnergyTraceWithLogicAnalyzer: energy_trace.append(state) energy_trace[-2]["W_mean_delta_next"] = ( - energy_trace[-2]["W_mean"] - energy_trace[-1]["W_mean"] + energy_trace[-2]["W_mean"] - energy_trace[-1]["W_mean"] ) for number, item in enumerate(energy_trace): name = item["name"] - #print(energy_trace[number - 1]["name"]) - #if name == "state" and "switchTo3K3" in energy_trace[number - 1]["name"]: - #print(name, energy_trace_new[number]["W_mean"]) + # print(energy_trace[number - 1]["name"]) + # if name == "state" and "switchTo3K3" in energy_trace[number - 1]["name"]: + # print(name, energy_trace_new[number]["W_mean"]) # add next/prev state W_mean_delta for number, item in enumerate(energy_trace_new): - if item['isa'] == 'transition' and number > 0 and number < len(energy_trace_new) - 1: - item['W_mean_delta_prev'] = energy_trace_new[number - 1] - item['W_mean_delta_next'] = energy_trace_new[number + 1] + if item["isa"] == "transition" and 0 < number < len(energy_trace_new) - 1: + item["W_mean_delta_prev"] = energy_trace_new[number - 1] + item["W_mean_delta_next"] = energy_trace_new[number + 1] + """ for number, item in enumerate(energy_trace): - name = energy_trace[number]['name'] - - if energy_trace_new[number]['isa'] == 'transition': - print(name, energy_trace_new[number]['count_dp'], energy_trace_new[number]["W_mean"]) - - #st = "" - #for i, x in enumerate(energy_trace_new[-10:]): + name = energy_trace[number]["name"] + if energy_trace_new[number]["isa"] == "transition": + print( + name, + energy_trace_new[number]["count_dp"], + energy_trace_new[number]["W_mean"], + ) + """ + # st = "" + # for i, x in enumerate(energy_trace_new[-10:]): # #st += "(%s|%s|%s)" % (energy_trace[i-10]["name"],x['W_mean'],x['s']) # st += "(%s|%s|%s)\n" % (energy_trace[i-10]["s"], x['s'], x['W_mean']) - #print(st, "\n_______________________") - #print(len(self.sync_data.timestamps), " - ", len(energy_trace_new), " - ", len(energy_trace), " - ", ",".join([str(x["s"]) for x in energy_trace_new[-6:]]), " - ", ",".join([str(x["s"]) for x in energy_trace[-6:]])) - #if len(energy_trace_new) < len(energy_trace): + # print(st, "\n_______________________") + # print(len(self.sync_data.timestamps), " - ", len(energy_trace_new), " - ", len(energy_trace), " - ", ",".join([str(x["s"]) for x in energy_trace_new[-6:]]), " - ", ",".join([str(x["s"]) for x in energy_trace[-6:]])) + # if len(energy_trace_new) < len(energy_trace): # return None return energy_trace_new @@ -1815,8 +1818,10 @@ class EnergyTraceWithTimer(EnergyTraceWithLogicAnalyzer): def analyze_states(self, traces, offline_index: int): from data.timing.SigrokInterface import SigrokResult + self.sync_data = SigrokResult.fromTraces(traces) - return super().analyze_states(traces, offline_index) + return super().analyze_states(traces, offline_index, timer_measurement=True) + class MIMOSA: """ diff --git a/lib/runner.py b/lib/runner.py index 3092d5a..8093a55 100644 --- a/lib/runner.py +++ b/lib/runner.py @@ -157,7 +157,7 @@ class EnergyTraceMonitor(SerialMonitor): self._start_energytrace() def _start_energytrace(self): - print("EnergyTrace Start") + print("[%s] Starting Measurement" % type(self).__name__) cmd = ["msp430-etv", "--save", self._output, "0"] self._logger = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True @@ -165,15 +165,15 @@ class EnergyTraceMonitor(SerialMonitor): # Benchmark fertig -> externe Hilfsprogramme beenden def close(self): - print("EnergyTrace Close") super().close() self._logger.send_signal(subprocess.signal.SIGINT) stdout, stderr = self._logger.communicate(timeout=15) + print("[%s] Stopped Measurement" % type(self).__name__) # Zusätzliche Dateien, die mit dem Benchmark-Log und -Plan abgespeichert werden sollen # (hier: Die von msp430-etv generierten Logfiles) def get_files(self) -> list: - print("EnergyTrace Get Files") + print("[%s] Getting files" % type(self).__name__) return [self._output] # Benchmark-Konfiguration. Hier: Die (konstante) Spannung. |