Skip to content

Commit

Permalink
populate timing information
Browse files Browse the repository at this point in the history
  • Loading branch information
yconst committed Sep 25, 2023
1 parent 1fd5509 commit cd115d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions studio/Python/tinymovr/gui/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ def timings_updated(self, timings_dict):
meas_freq = timings_dict["meas_freq"]
meas_freq_str = "-" if meas_freq == 0 else "{:.1f}Hz".format(meas_freq)
self.status_label.setText(
"{}\t CH:{:.0f}%\t RT:{:.1f}ms".format(
"{}\t Load:{:.0f}%\t RT:{:.1f}ms".format(
meas_freq_str,
timings_dict["load"],
timings_dict["load"] * 100,
timings_dict["getter_dt"] * 1000,
)
)
Expand Down
11 changes: 10 additions & 1 deletion studio/Python/tinymovr/gui/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def __init__(self, busparams, logger):
)
self.timed_getter = TimedGetter()

self.dt_update = 1
self.dt_load = 0
self.t_last_update = time.time()

@QtCore.Slot()
def stop(self):
destroy_tee()
Expand Down Expand Up @@ -102,12 +106,17 @@ def _init_containers(self):
self.dynamic_attrs_last_update = {}

def _update(self):
t = time.time()
self.dt_update = self.dt_update * 0.95 + (t - self.t_last_update) * 0.05
self.t_last_update = t
self.mutx.lock()
t = time.time()
last_updated = self._get_attr_values()
self.dt_load = self.dt_load * 0.95 + (time.time() - t) * 0.05
if len(last_updated) > 0:
self.updateAttrsSignal.emit(last_updated)
self.updateTimingsSignal.emit(
{"meas_freq": 0, "load": 0, "getter_dt": self.timed_getter.dt}
{"meas_freq": 1/self.dt_update, "load": self.dt_load/self.dt_update, "getter_dt": self.timed_getter.dt}
)
self.mutx.unlock()

Expand Down

0 comments on commit cd115d2

Please sign in to comment.