forked from M-Labs/artiq
1
0
Fork 0

moninj: Python-side fixes

This commit is contained in:
Sebastien Bourdeauducq 2017-02-27 11:45:04 +08:00
parent 7481eaff52
commit 26654e6a3a
2 changed files with 12 additions and 10 deletions

View File

@ -51,15 +51,15 @@ class MonInjComm:
async def _receive_cr(self): async def _receive_cr(self):
try: try:
while True: while True:
ty = await self.reader.read(1) ty = await self._reader.read(1)
if not ty: if not ty:
return return
if ty == "\x00": if ty == b"\x00":
payload = await self.reader.read(9) payload = await self._reader.read(9)
channel, probe, value = struct.unpack(">lbl", payload) channel, probe, value = struct.unpack(">lbl", payload)
self.monitor_cb(channel, probe, value) self.monitor_cb(channel, probe, value)
elif ty == "\x01": elif ty == b"\x01":
payload = await self.reader.read(6) payload = await self._reader.read(6)
channel, override, value = struct.unpack(">lbb", payload) channel, override, value = struct.unpack(">lbb", payload)
self.injection_status_cb(channel, override, value) self.injection_status_cb(channel, override, value)
else: else:

View File

@ -70,7 +70,7 @@ class _TTLWidget(QtWidgets.QFrame):
self.override.clicked.connect(self.override_toggled) self.override.clicked.connect(self.override_toggled)
self.level.clicked.connect(self.level_toggled) self.level.clicked.connect(self.level_toggled)
self.cur_value = False self.cur_level = False
self.cur_oe = False self.cur_oe = False
self.cur_override = False self.cur_override = False
self.refresh_display() self.refresh_display()
@ -105,7 +105,7 @@ class _TTLWidget(QtWidgets.QFrame):
self.set_mode(self.channel, "0") self.set_mode(self.channel, "0")
def refresh_display(self): def refresh_display(self):
value_s = "1" if self.cur_value else "0" value_s = "1" if self.cur_level else "0"
if self.cur_override: if self.cur_override:
value_s = "<b>" + value_s + "</b>" value_s = "<b>" + value_s + "</b>"
color = " color=\"red\"" color = " color=\"red\""
@ -122,7 +122,7 @@ class _TTLWidget(QtWidgets.QFrame):
self.override.setChecked(self.cur_override) self.override.setChecked(self.cur_override)
if self.cur_override: if self.cur_override:
self.stack.setCurrentIndex(1) self.stack.setCurrentIndex(1)
self.level.setChecked(self.cur_value) self.level.setChecked(self.cur_level)
finally: finally:
self.programmatic_change = False self.programmatic_change = False
@ -173,7 +173,7 @@ class _DDSWidget(QtWidgets.QFrame):
TTL_PROBE_LEVEL = 0 TTL_PROBE_LEVEL = 0
TTL_PROBE_OE = 1 TTL_PROBE_OE = 1
TTL_OVERRIDE_ENABLE = 0 TTL_OVERRIDE_EN = 0
TTL_OVERRIDE_LEVEL = 1 TTL_OVERRIDE_LEVEL = 1
TTL_OVERRIDE_OE = 2 TTL_OVERRIDE_OE = 2
@ -272,6 +272,8 @@ class _DeviceManager:
if self.core_connection is not None: if self.core_connection is not None:
self.core_connection.monitor(enable, channel, TTL_PROBE_LEVEL) self.core_connection.monitor(enable, channel, TTL_PROBE_LEVEL)
self.core_connection.monitor(enable, channel, TTL_PROBE_OE) self.core_connection.monitor(enable, channel, TTL_PROBE_OE)
if enable:
self.core_connection.get_injection_status(channel, TTL_OVERRIDE_EN)
def setup_dds_monitoring(self, enable, bus_channel, channel): def setup_dds_monitoring(self, enable, bus_channel, channel):
if self.core_connection is not None: if self.core_connection is not None:
@ -285,7 +287,7 @@ class _DeviceManager:
elif probe == TTL_PROBE_OE: elif probe == TTL_PROBE_OE:
widget.cur_oe = bool(value) widget.cur_oe = bool(value)
widget.refresh_display() widget.refresh_display()
if (bus_channel, channel) in self.dds_widgets_by_channel: if (channel, probe) in self.dds_widgets_by_channel:
widget = self.dds_widgets_by_channel[(channel, probe)] widget = self.dds_widgets_by_channel[(channel, probe)]
widget.cur_frequency = value*self.dds_sysclk/2**32 widget.cur_frequency = value*self.dds_sysclk/2**32
widget.refresh_display() widget.refresh_display()