waveform: changes

This commit is contained in:
Simon Renblad 2024-01-22 17:43:34 +08:00
parent c14964b36d
commit ea0cbefa67

View File

@ -218,7 +218,7 @@ class Waveform(pg.PlotWidget):
# self.cursor_y = None
# self.format_cursor_label()
def onDataChange(self):
def onDataChange(self, data):
raise NotImplementedError
#def format_cursor_label(self):
@ -289,6 +289,8 @@ class BitWaveform(Waveform):
#self.plot_data_item.setDownsampling(ds=1000, method="peak", auto=False)
def onDataChange(self, data):
logger.info("bit waveform ondatachanged triggered")
logger.info(str(len(data)))
try:
display_y = []
display_x = []
@ -448,13 +450,14 @@ class _WaveformView(QtWidgets.QWidget):
def onDataChange(self, top, bottom, roles):
first = top.row()
logger.info(str(first))
last = bottom.row()
logger.info(str(last))
for i in range(first, last + 1):
data = self._model.data(self._model.index(i, 2))
data = self._model.data(self._model.index(i, 3))
self._splitter.widget(i).onDataChange(data)
def onInsert(self, parent, first, last):
logger.info("inserting widget")
for i in range(first, last + 1):
w = self._create_waveform(i)
self._splitter.insertWidget(i, w)
@ -481,7 +484,9 @@ class _WaveformView(QtWidgets.QWidget):
WaveformType.ANALOG: AnalogWaveform,
WaveformType.LOG: LogWaveform
}[ty]
return waveform_cls(name, width, parent=self._splitter)
w = waveform_cls(name, width, parent=self._splitter)
w.setXLink(self._ref_vb)
return w
def _resize(self):
self._splitter.setMinimumHeight(Waveform.MIN_HEIGHT * self._model.rowCount())
@ -523,12 +528,14 @@ class _WaveformModel(QtCore.QAbstractTableModel):
self.endMoveRows()
def update_data(self, waveform_data):
for i in range(len(self.backing_struct)):
for i in range(self.rowCount()):
logger.info(str(i))
name = self.data(self.index(i, 0))
if name in waveform_data:
self.backing_struct[i][3] = waveform_data[name]
logger.info(name)
self.backing_struct[i] = waveform_data[name]
self.dataChanged.emit(self.index(0, 0),
self.index(len(self.backing_struct)-1, len(self.headers)))
self.index(self.rowCount()-1, self.columnCount()-1))
class WaveformArea(QtWidgets.QWidget):
@ -689,7 +696,7 @@ class _BaseProxyClient:
self.addr = addr
self.port = port
self._reconnect_event.set()
# TODO: investigate if need to cancel the connection before connecting again..
async def _reconnect(self):
try:
@ -837,7 +844,7 @@ class WaveformDock(QtWidgets.QDockWidget):
trace = comm_analyzer.decoded_dump_to_waveform_data(ddb, decoded_dump)
self._waveform_data.update(trace)
self._channel_model.update(trace['logs'])
self._waveform_model.update_data(self._waveform_data)
self._waveform_model.update_data(trace['data'])
self._dump = data
def on_add_channel_click(self):
@ -853,7 +860,7 @@ class WaveformDock(QtWidgets.QDockWidget):
dialog.open()
channels = await fut
self._waveform_model.extend(channels)
self._waveform_model.update_data(self._waveform_data) # TODO use a specific function for this
self._waveform_model.update_data(self._waveform_data['data']) # TODO use a specific function for this
async def load_trace(self):
try: