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