waveform: updates

This commit is contained in:
Simon Renblad 2024-01-11 10:38:59 +08:00
parent 6ba81b5116
commit 082962df2f

View File

@ -10,6 +10,7 @@ from artiq.gui.tools import LayoutWidget, get_open_file_name, get_save_file_name
from artiq.gui.models import DictSyncTreeSepModel, LocalModelManager
from artiq.gui.dndwidgets import DragDropSplitter, VDragScrollArea
from artiq.coredevice import comm_analyzer
from artiq.coredevice.comm_analyzer import WaveformType
import os
import numpy as np
@ -259,6 +260,7 @@ class BitWaveform(Waveform):
def __init__(self, channel, state, parent=None):
Waveform.__init__(self, channel, state, parent)
self._arrows = []
#self.plot_data_item.setDownsampling(ds=1000, method="peak", auto=False)
def extract_data_from_state(self):
try:
@ -273,9 +275,9 @@ class BitWaveform(Waveform):
previous_y = None
for x, y in zip(self.x_data, self.y_data):
state_unchanged = previous_y == y
if y is None:
if y == "X":
dis_y = DISPLAY_MID
elif y == 1:
elif y == "1":
dis_y = DISPLAY_HIGH
else:
dis_y = DISPLAY_LOW
@ -295,11 +297,7 @@ class BitWaveform(Waveform):
self.plot_data_item.setData(x=[], y=[])
def format_cursor_label(self):
if self.cursor_y is None:
lbl = "x"
else:
lbl = str(self.cursor_y)
self.cursor_label.setText(lbl)
self.cursor_label.setText(self.cursor_y)
class BitVectorWaveform(Waveform):
@ -337,10 +335,10 @@ class BitVectorWaveform(Waveform):
for x, y in zip(self.x_data, self.y_data):
display_x.append(x)
display_y.append(DISPLAY_LOW)
if y is None:
if "X" in y:
display_x.append(x)
display_y.append(DISPLAY_MID)
elif y != 0:
elif int(y) != 0:
display_x.append(x)
display_y.append(DISPLAY_HIGH)
lbl = pg.TextItem(
@ -356,10 +354,10 @@ class BitVectorWaveform(Waveform):
self.plot_data_item.setData(x=[], y=[])
def format_cursor_label(self):
if self.cursor_y is None:
lbl = "X"
if "X" in self.cursor_y:
lbl = self.cursor_y
else:
lbl = self._format_string.format(self.cursor_y)
lbl = self._format_string.format(int(self.cursor_y, 2))
self.cursor_label.setText(lbl)
@ -477,10 +475,10 @@ class WaveformArea(QtWidgets.QWidget):
def update_channels(self, channel_list):
type_map = {
"bit": BitWaveform,
"vector": BitVectorWaveform,
"analog": AnalogWaveform,
"log": LogWaveform
WaveformType.BIT: BitWaveform,
WaveformType.VECTOR: BitVectorWaveform,
WaveformType.ANALOG: AnalogWaveform,
WaveformType.LOG: LogWaveform
}
for channel in channel_list:
ty = channel[1][1]
@ -757,7 +755,7 @@ class WaveformDock(QtWidgets.QDockWidget):
header = comm_analyzer.decode_header_from_receiver(*args)
decoded_dump = comm_analyzer.decode_dump_loop(*header)
ddb = self._ddb
trace = comm_analyzer.decoded_dump_to_dict(ddb, decoded_dump)
trace = comm_analyzer.decoded_dump_to_waveform_data(ddb, decoded_dump)
self._state.update(trace)
self._dump = args
self.traceDataChanged.emit()