diff --git a/control_seekat_demo.py b/control_seekat_demo.py
index 8f3ad87..7af6cd3 100644
--- a/control_seekat_demo.py
+++ b/control_seekat_demo.py
@@ -31,6 +31,19 @@ class SerComm:
self.getobj("dac_resp").set_text(s)
return s
+ def make_dac_conn(self, f):
+ for x in CHANGE_BUTTONS:
+ self.getobj(x).set_sensitive(False)
+
+ try:
+ f()
+ except Exception as e:
+ self.error_popup(str(e))
+
+ for x in CHANGE_BUTTONS:
+ self.getobj(x).set_sensitive(True)
+
+ """ make connection (*IDN?) """
def connect(self):
s = self.sel_box.get_active_id()
if self.ser.is_open:
@@ -57,16 +70,23 @@ class SerComm:
self.getobj("dac_idn").set_label(self.get_or_to())
def on_connect(self, _):
- for x in CHANGE_BUTTONS:
- self.getobj(x).set_sensitive(False)
+ self.make_dac_conn(self.connect)
- try:
- self.connect()
- except Exception as e:
- self.error_popup(str(e))
-
- for x in CHANGE_BUTTONS:
- self.getobj(x).set_sensitive(True)
+ """ SET """
+ def do_SET(self):
+ if not self.ser.is_open:
+ return None
+ 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"))
+ s = self.get_or_to()
+
+ if not s.startswith("DAC"):
+ raise Exception(f"DAC reported an error: {s}")
+
+ def on_SET(self, _):
+ self.make_dac_conn(self.do_SET)
def refresh(self, _):
# Does this cause a memory error? This is a GTK interned string
@@ -96,6 +116,7 @@ class SerComm:
getobj("sel_ref").connect("clicked", self.refresh)
self.refresh(None)
getobj("sel_do").connect("clicked", self.on_connect)
+ getobj("SET_do").connect("clicked", self.on_SET)
if __name__ == "__main__":
builder = Gtk.Builder()
diff --git a/gui.glade b/gui.glade
index 12a734d..3b1215c 100644
--- a/gui.glade
+++ b/gui.glade
@@ -181,7 +181,7 @@
True
True
6
- 10.000
+ ±10
number
@@ -310,7 +310,7 @@
True
True
6
- start
+ ±10
number
@@ -336,7 +336,7 @@
True
True
6
- end
+ ±10
number