diff --git a/control_seekat_demo.py b/control_seekat_demo.py index 7af6cd3..0c180c2 100644 --- a/control_seekat_demo.py +++ b/control_seekat_demo.py @@ -23,14 +23,25 @@ class SerComm: def error_popup(self, x): error_popup(self.getobj("win"), x) + def append(self, s): + o = self.getobj("debug_buf") + o.insert_markup(o.get_end_iter(), s, -1) + self.getobj("debug_win").scroll_to_mark( + o.get_insert(), 0.1, False, 0, 1) + def get_or_to(self): s = self.ser.read_until().decode() if not s: raise Exception(f"DAC timeout: '{s}'") s = s.rstrip("\r\n") - self.getobj("dac_resp").set_text(s) + self.append(f'{s}\n') return s + def send(self, s): + b = bytes(s, "UTF-8") + self.ser.write(b + b"\r") + self.append(f'{s}\n') + def make_dac_conn(self, f): for x in CHANGE_BUTTONS: self.getobj(x).set_sensitive(False) @@ -51,8 +62,10 @@ class SerComm: if s == None: self.getobj("dac_idn").set_label("(disconnected)") + self.append('Disconnecting\n') return None + self.append(f'Connecting to "{s}"\n') self.ser.port = s self.ser.open() @@ -66,7 +79,7 @@ class SerComm: raise Exception(f"Unknown message from DAC: '{s}'") self.getobj(f"Ch{int(loc.group(0)) + 1}").set_label('ERR') - self.ser.write(b"*IDN?\r\n") + self.send("*IDN?") self.getobj("dac_idn").set_label(self.get_or_to()) def on_connect(self, _): @@ -79,7 +92,7 @@ class SerComm: ch = int(self.getobj("SET_ch").get_active_id()) - 1 vol = float(self.getobj("SET_v").get_text()) - self.ser.write(bytes(f"SET,{ch},{vol}\r", "UTF-8")) + self.send(f"SET,{ch},{vol}") s = self.get_or_to() if not s.startswith("DAC"): diff --git a/gui.glade b/gui.glade index 3b1215c..39a930a 100644 --- a/gui.glade +++ b/gui.glade @@ -2,6 +2,10 @@ + + + + False @@ -127,94 +131,15 @@ True False - vertical - 32 - - - True - False - center - - - True - False - Set channel - - - False - True - 1 - - - - - True - False - 0 - - 1 - 2 - 3 - 4 - - - - False - True - 2 - - - - - True - False - to voltage - - - False - True - 3 - - - - - True - True - 6 - ±10 - number - - - False - True - 4 - - - - - Execute - True - True - True - - - False - True - 5 - - - - - False - True - 0 - - + True + 5 True False + end vertical + 32 True @@ -224,16 +149,16 @@ True False - Ramp channel + Set channel False True - 0 + 1 - + True False 0 @@ -247,33 +172,14 @@ False True - 1 + 2 True False - and - - - False - True - 2 - - - - - True - False - default - - 1 - 2 - 3 - 4 - N/A - + to voltage False @@ -281,32 +187,8 @@ 3 - - - False - True - 0 - - - - - True - False - center - - True - False - from - - - False - True - 0 - - - - + True True 6 @@ -316,142 +198,278 @@ False True - 1 + 4 - - True - False - to - - - False - True - 2 - - - - - True - True - 6 - ±10 - number - - - False - True - 3 - - - - - False - True - 1 - - - - - True - False - center - - - True - False - in a total of - - - False - True - 0 - - - - - True - True - 9 - steps - number - - - False - True - 1 - - - - - True - False - steps - - - False - True - 2 - - - - - False - True - 2 - - - - - True - False - center - - - True - False - with - - - False - True - 0 - - - - - True - True - 4 - time - number - - - False - True - 1 - - - - - True - False - milliseconds between each - - - False - True - 2 - - - - + Execute True True True + + False + True + 5 + + + + + False + True + 0 + + + + + True + False + vertical + + + True + False + center + + + True + False + Ramp channel + + + False + True + 0 + + + + + True + False + 0 + + 1 + 2 + 3 + 4 + + + + False + True + 1 + + + + + True + False + and + + + False + True + 2 + + + + + True + False + default + + 1 + 2 + 3 + 4 + N/A + + + + False + True + 3 + + + + + False + True + 0 + + + + + True + False + center + + + True + False + from + + + False + True + 0 + + + + + True + True + 6 + ±10 + number + + + False + True + 1 + + + + + True + False + to + + + False + True + 2 + + + + + True + True + 6 + ±10 + number + + + False + True + 3 + + + + + False + True + 1 + + + + + True + False + center + + + True + False + in a total of + + + False + True + 0 + + + + + True + True + 9 + steps + number + + + False + True + 1 + + + + + True + False + steps + + + False + True + 2 + + + + + False + True + 2 + + + + + True + False + center + + + True + False + with + + + False + True + 0 + + + + + True + True + 4 + time + number + + + False + True + 1 + + + + + True + False + milliseconds between each + + + False + True + 2 + + + + + Execute + True + True + True + + + False + True + 3 + + + False True @@ -462,10 +480,95 @@ False True - 3 + 1 + + False + False + 0 + + + + + True + False + vertical + + + True + False + start + Communication Log + + + False + True + 0 + + + + + 206 + True + True + in + + + True + True + False + debug_buf + False + terminal + + + + + True + True + 1 + + + + + True + True + 1 + + + + + True + True + 1 + + + + + True + False + center + + + True + False + (disconnected) + + + False + True + 0 + + + + + Refresh + True + True + True + False True @@ -473,84 +576,23 @@ - + True False - center - - - Refresh - True - True - True - - - False - True - 0 - - - - - True - False - 0 - - - False - True - 2 - - - - - Connect - True - True - True - - - False - True - 3 - - + 0 - True + False True 2 - + + Connect True - False - - - True - False - (disconnected) - - - False - True - 0 - - - - - True - False - end - (previous response) - - - True - True - 1 - - + True + True False @@ -561,8 +603,8 @@ False - True - 1 + False + 2