diff --git a/dstat_interface/core/dstat/comm.py b/dstat_interface/core/dstat/comm.py index d78ea58e2522ec015db16a95728fe492be13c48a..66903c8a59eda2ddb33c4547deaaeb44df24529f 100755 --- a/dstat_interface/core/dstat/comm.py +++ b/dstat_interface/core/dstat/comm.py @@ -192,7 +192,7 @@ class SerialConnection(GObject.Object): def get_proc(self, block=False): self.assert_connected() - + if block is True: return self.proc_pipe_p.recv() else: @@ -211,7 +211,7 @@ class SerialConnection(GObject.Object): return self.ctrl_pipe_p.recv() else: return None - + def get_data(self, block=False): self.assert_connected() diff --git a/dstat_interface/core/dstat/dfu.py b/dstat_interface/core/dstat/dfu.py index 3b56288c0bb68ee81f3e4e2b3b25c7158331a376..101b9da84d944ed9560e9df26b2666635d590324 100755 --- a/dstat_interface/core/dstat/dfu.py +++ b/dstat_interface/core/dstat/dfu.py @@ -278,6 +278,7 @@ def test_firmware_version(current=None): logger.error('Unexpected git error. Git exited {}'.format(test)) return False, None + def dfu_program(path='./dstat-firmware.hex'): """Tries to program DStat over USB with DFU with hex file at path.""" try: diff --git a/dstat_interface/core/experiments/chronoamp.py b/dstat_interface/core/experiments/chronoamp.py index 56417cdd6aca13a92759c2902836fc36934e6c6c..bce5ecb6ede083565f00aa929de93af4e2ec949c 100644 --- a/dstat_interface/core/experiments/chronoamp.py +++ b/dstat_interface/core/experiments/chronoamp.py @@ -72,6 +72,7 @@ class Chronoamp(Experiment): except IndexError: pass + class ManExp(Chronoamp): id = 'man' """Manual experiment""" @@ -132,8 +133,8 @@ class ManExp(Chronoamp): for line in self.serial: check_ctrl() - - if line.startswith('B'): + line_in = line.lstrip() + if line_in.startswith('B'): data = self.data_handler( (scan, voltage, self.serial.read(size=self.databytes))) data = self.data_postprocessing(data) @@ -144,19 +145,22 @@ class ManExp(Chronoamp): except AttributeError: # Datapoint counting is optional pass - elif line.lstrip().startswith('S'): + elif line_in.startswith('S'): scan += 1 - elif line.lstrip().startswith('G'): + elif line_in.startswith('G'): self.gain = self.parameters["gain_table"][int(line.split(" ")[1])] - elif line.lstrip().startswith('V'): + elif line_in.startswith('V'): voltage = int(line.split(" ")[1]) - elif line.lstrip().startswith("#"): + elif line_in.startswith("#"): dstat_logger.info(line.lstrip().rstrip()) - elif line.lstrip().startswith("@DONE"): + elif line_in.startswith("R"): + self.ctrl_pipe.send("R") + + elif line_in.startswith("@DONE"): dstat_logger.debug(line.lstrip().rstrip()) time.sleep(.3) return True @@ -164,6 +168,10 @@ class ManExp(Chronoamp): except serial.SerialException: return False + def ctrl_loop(self, data): + if data == 'R': + self.emit('exp_ready') + def data_handler(self, data_input): """Overrides Experiment method to not convert x axis to mV.""" scan, voltage, data = data_input @@ -181,6 +189,7 @@ class ManExp(Chronoamp): super(ManExp, self).experiment_done() for i in self.handler_ids: self.parameters['exp_window'].disconnect(i) + self.emit('exp_done') class ManBox(ChronoampBox): def redraw(self): diff --git a/dstat_interface/core/experiments/experiment_template.py b/dstat_interface/core/experiments/experiment_template.py index bd36ce5ce640d68bf7cb4bbd6ae7a56bfe6dd040..9fab05d2049282aed8e9f399ec065bb5c887cc50 100755 --- a/dstat_interface/core/experiments/experiment_template.py +++ b/dstat_interface/core/experiments/experiment_template.py @@ -69,6 +69,7 @@ class Experiment(GObject.Object): b'exp_ready': (GObject.SIGNAL_RUN_FIRST, None, ()), b'exp_done': (GObject.SIGNAL_RUN_FIRST, None, ()) } + def __init__(self, parameters): """Adds commands for gain and ADC.""" super(Experiment, self).__init__() diff --git a/dstat_interface/core/interface/exp_int.py b/dstat_interface/core/interface/exp_int.py index 4a684756b1bb627b3c36ba6213d54be32a2aec73..6f26ece977442e5df602f4a04547df8dff70632a 100755 --- a/dstat_interface/core/interface/exp_int.py +++ b/dstat_interface/core/interface/exp_int.py @@ -214,7 +214,7 @@ class Manual(ExpInterface): self.window.set_vexpand(True) grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL) - grid.set_column_homogeneous(False) + grid.set_column_homogeneous(True) entries = OrderedDict([ ('voltage', 'Voltage (mV)'), @@ -236,8 +236,26 @@ class Manual(ExpInterface): grid.attach(gain_button, 0, n, 2, 1) gain_button.connect('clicked', self.new_gain) + self.buttons = [voltage_button, gain_button] + for i in self.buttons: + i.set_sensitive(False) + self.window.add(grid) + def exp_ready(self, widget): + for i in self.buttons: + i.set_sensitive(True) + + def exp_done(self, widget): + for i in self.buttons: + i.set_sensitive(False) + + def get_experiment(self, parameters): + exp = super(Manual, self).get_experiment(parameters) + exp.connect('exp_ready', self.exp_ready) + exp.connect('exp_done', self.exp_done) + return exp + def new_voltage(self, widget): self.emit('new_voltage', int(self.entry['voltage'].get_text())) diff --git a/dstat_interface/core/interface/exp_window.py b/dstat_interface/core/interface/exp_window.py index 9f7f25abf9d5f56c4467333a5674c33ab4c81cf9..9f977daff749dcbca0c3cf9d355b9e49de515a9f 100755 --- a/dstat_interface/core/interface/exp_window.py +++ b/dstat_interface/core/interface/exp_window.py @@ -33,11 +33,13 @@ from . import exp_int logger = logging.getLogger(__name__) + class Experiments(GObject.Object): __gsignals__ = { 'run_utility': (GObject.SIGNAL_RUN_FIRST, None, ()), 'done_utility': (GObject.SIGNAL_RUN_FIRST, None, ()) } + def __init__(self, builder): super(Experiments,self).__init__() self.builder = builder @@ -96,7 +98,7 @@ class Experiments(GObject.Object): exp.name) ) return exp.get_experiment(parameters) - + def hide_exps(self): for key in self.containers: self.containers[key].hide() diff --git a/dstat_interface/main.py b/dstat_interface/main.py index ff49410e98c6c36888b66e3e912766c0a90e72a3..febd0bac293b08d746644c7508922ec551847e91 100755 --- a/dstat_interface/main.py +++ b/dstat_interface/main.py @@ -640,7 +640,7 @@ class Main(object): self.current_exp.ctrl_loop(ctrl_buffer) except AttributeError: pass - + proc_buffer = dstat.state.ser.get_proc() if proc_buffer is not None: if proc_buffer in ["DONE", "SERIAL_ERROR", "ABORT"]: