Skip to content

Commit

Permalink
FIX: pytlu receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
leloup314 committed Oct 29, 2023
1 parent 81f6ca1 commit 2c5ded5
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions pytlu/online_monitor/pytlu_receiver.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import time

from PyQt5 import Qt
from PyQt5 import QtWidgets
import pyqtgraph as pg
from pyqtgraph.Qt import QtGui
from pyqtgraph.dockarea import DockArea, Dock
import pyqtgraph.ptime as ptime

from online_monitor.utils import utils
from online_monitor.receiver.receiver import Receiver
from zmq.utils import jsonapi


class PyTLU(Receiver):
Expand All @@ -26,17 +23,17 @@ def setup_widgets(self, parent, name):
dock_area.addDock(dock_status, 'top')

# Status dock on top
cw = QtGui.QWidget()
cw = QtWidgets.QWidget()
cw.setStyleSheet("QWidget {background-color:white}")
layout = QtGui.QGridLayout()
layout = QtWidgets.QGridLayout()
cw.setLayout(layout)
self.rate_label = QtGui.QLabel("Readout Rate\n0 Hz")
self.timestamp_label = QtGui.QLabel("Data Timestamp\n")
self.plot_delay_label = QtGui.QLabel("Plot Delay\n")
self.spin_box = Qt.QSpinBox(value=0)
self.rate_label = QtWidgets.QLabel("Readout Rate\n0 Hz")
self.timestamp_label = QtWidgets.QLabel("Data Timestamp\n")
self.plot_delay_label = QtWidgets.QLabel("Plot Delay\n")
self.spin_box = QtWidgets.QSpinBox(value=0)
self.spin_box.setMaximum(1000000)
self.spin_box.setSuffix(" Readouts")
self.reset_button = QtGui.QPushButton('Reset')
self.reset_button = QtWidgets.QPushButton('Reset')
layout.addWidget(self.timestamp_label, 0, 0, 0, 1)
layout.addWidget(self.plot_delay_label, 0, 1, 0, 1)
layout.addWidget(self.rate_label, 0, 2, 0, 1)
Expand Down Expand Up @@ -104,6 +101,6 @@ def handle_data_if_active(self, data):
# set timestamp, plot delay and readour rate
self.rate_label.setText("Readout Rate\n%d Hz" % data['fps'])
self.timestamp_label.setText("Data Timestamp\n%s" % time.asctime(time.localtime(data['timestamp_stop'])))
now = ptime.time()
now = time.time()
self.plot_delay = self.plot_delay * 0.9 + (now - data['timestamp_stop']) * 0.1
self.plot_delay_label.setText("Plot Delay\n%s" % 'not realtime' if abs(self.plot_delay) > 5 else "%1.2f ms" % (self.plot_delay * 1.e3))

0 comments on commit 2c5ded5

Please sign in to comment.