From 7ef67f41483739e12e693fcdfc8897fe2990726e Mon Sep 17 00:00:00 2001 From: "Michael D. M. Dryden" Date: Thu, 26 Nov 2015 20:32:18 -0500 Subject: [PATCH] Move serial connection to single process. --- dstat_interface/__main__.py | 216 +++++++------- dstat_interface/dstat_comm.py | 405 ++++++++++++++++++--------- dstat_interface/interface/exp_int.py | 2 + 3 files changed, 403 insertions(+), 220 deletions(-) diff --git a/dstat_interface/__main__.py b/dstat_interface/__main__.py index dc3602e..6461973 100755 --- a/dstat_interface/__main__.py +++ b/dstat_interface/__main__.py @@ -134,13 +134,11 @@ class Main(object): def on_window1_destroy(self, object, data=None): """ Quit when main window closed.""" - self.on_pot_stop_clicked() self.on_serial_disconnect_clicked() gtk.main_quit() def on_gtk_quit_activate(self, menuitem, data=None): """Quit when Quit selected from menu.""" - self.on_pot_stop_clicked() self.on_serial_disconnect_clicked() gtk.main_quit() @@ -168,42 +166,53 @@ class Main(object): def on_serial_connect_clicked(self, data=None): """Connect and retrieve DStat version.""" - try: - self.on_pot_stop_clicked() - except AttributeError: - pass - - version_list = comm.version_check(self.serial_liststore.get_value( - self.serial_combobox.get_active_iter(), 0)) - - self.version = version_list - - self.statusbar.remove_all(self.error_context_id) - - if not len(self.version) == 2: - self.statusbar.push(self.error_context_id, "Communication Error") - return - else: - self.adc_pot.set_version(self.version) - self.statusbar.push(self.error_context_id, - "".join(["DStat version: ", str(self.version[0]), - ".", str(self.version[1])]) - ) - comm.read_settings() - self.start_ocp() - self.connected = True + try: self.serial_connect.set_sensitive(False) - self.serial_disconnect.set_sensitive(True) + self.version = comm.version_check(self.serial_liststore.get_value( + self.serial_combobox.get_active_iter(), 0)) + + self.statusbar.remove_all(self.error_context_id) + + if not len(self.version) == 2: + self.statusbar.push(self.error_context_id, "Communication Error") + return + + else: + self.adc_pot.set_version(self.version) + self.statusbar.push(self.error_context_id, + "".join(["DStat version: ", str(self.version[0]), + ".", str(self.version[1])]) + ) + + comm.read_settings() + + print "connect" + self.start_ocp() + self.connected = True + self.serial_connect.set_sensitive(False) + self.serial_disconnect.set_sensitive(True) + + except AttributeError as i: + print i + self.serial_connect.set_sensitive(True) + except TypeError as i: + print i + self.serial_connect.set_sensitive(True) def on_serial_disconnect_clicked(self, data=None): """Disconnect from DStat.""" + if self.connected == False: + return + try: self.on_pot_stop_clicked() gobject.source_remove(self.ocp_proc) # Stop OCP measurements - comm.serial_instance.close() + comm.serial_instance.ctrl_pipe_p.send("DISCONNECT") + comm.serial_instance.proc.terminate() - except AttributeError: + except AttributeError as i: + print i pass self.connected = False @@ -212,14 +221,9 @@ class Main(object): def start_ocp(self): """Start OCP measurements.""" - if self.version[0] >= 1 and self.version[1] >= 2: - self.recv_p, self.send_p = multiprocessing.Pipe(duplex=True) - self.ocp_exp = comm.OCPExp(self.send_p) - - self.ocp_exp.run_wrapper() - - self.send_p.close() # need for EOF signal to work - + if self.version[0] >= 1 and self.version[1] >= 2: + print "start OCP" + comm.serial_instance.proc_pipe_p.send(comm.OCPExp()) self.ocp_proc = gobject.idle_add(self.ocp_running) else: print "OCP measurements not supported on v1.1 boards." @@ -239,11 +243,14 @@ class Main(object): self.spinner.stop() self.startbutton.set_sensitive(True) self.stopbutton.set_sensitive(False) + print "exceptions" self.start_ocp() # Stop OCP measurements self.on_pot_stop_clicked() - gobject.source_remove(self.ocp_proc) + + while comm.serial_instance.data_pipe_p.poll(): # Clear data pipe + comm.serial_instance.data_pipe_p.recv() selection = self.expcombobox.get_active() parameters = {} @@ -287,8 +294,8 @@ class Main(object): raise InputError(parameters['potential'], "Step table is empty") - self.recv_p, self.send_p = multiprocessing.Pipe(duplex=True) - self.current_exp = comm.Chronoamp(parameters, self.send_p) + + self.current_exp = comm.Chronoamp(parameters) self.plot.clearall() self.plot.changetype(self.current_exp) @@ -297,10 +304,8 @@ class Main(object): for i in self.current_exp.commands: self.rawbuffer.insert_at_cursor(i) - - self.current_exp.run_wrapper() - - self.send_p.close() # need for EOF signal to work + + comm.serial_instance.proc_pipe_p.send(self.current_exp) self.plot_proc = gobject.timeout_add(200, self.experiment_running_plot) @@ -338,15 +343,13 @@ class Main(object): raise InputError(parameters['start'], "Start cannot equal Stop.") - self.recv_p, self.send_p = multiprocessing.Pipe(duplex=True) - self.current_exp = comm.LSVExp(parameters, self.send_p) + + self.current_exp = comm.LSVExp(parameters) self.plot.clearall() self.plot.changetype(self.current_exp) - self.current_exp.run_wrapper() - - self.send_p.close() + comm.serial_instance.proc_pipe_p.send(self.current_exp) self.plot_proc = gobject.timeout_add(200, self.experiment_running_plot) @@ -390,15 +393,13 @@ class Main(object): raise InputError(parameters['v1'], "Vertex 1 cannot equal Vertex 2.") - self.recv_p, self.send_p = multiprocessing.Pipe(duplex=True) - self.current_exp = comm.CVExp(parameters, self.send_p) + + self.current_exp = comm.CVExp(parameters) self.plot.clearall() self.plot.changetype(self.current_exp) - self.current_exp.run_wrapper() - - self.send_p.close() + comm.serial_instance.proc_pipe_p.send(self.current_exp) self.plot_proc = gobject.timeout_add(200, self.experiment_running_plot) @@ -451,15 +452,13 @@ class Main(object): raise InputError(parameters['start'], "Start cannot equal Stop.") - self.recv_p, self.send_p = multiprocessing.Pipe(duplex=True) - self.current_exp = comm.SWVExp(parameters, self.send_p) + + self.current_exp = comm.SWVExp(parameters) self.plot.clearall() self.plot.changetype(self.current_exp) - self.current_exp.run_wrapper() - - self.send_p.close() + comm.serial_instance.proc_pipe_p.send(self.current_exp) self.plot_proc = gobject.timeout_add(200, self.experiment_running_plot) @@ -508,15 +507,13 @@ class Main(object): raise InputError(parameters['start'], "Start cannot equal Stop.") - self.recv_p, self.send_p = multiprocessing.Pipe(duplex=True) - self.current_exp = comm.DPVExp(parameters, self.send_p) + + self.current_exp = comm.DPVExp(parameters) self.plot.clearall() self.plot.changetype(self.current_exp) - self.current_exp.run_wrapper() - - self.send_p.close() + comm.serial_instance.proc_pipe_p.send(self.current_exp) self.plot_proc = gobject.timeout_add(200, self.experiment_running_plot) @@ -533,15 +530,13 @@ class Main(object): raise InputError(parameters['clean_s'], "Time must fit in 16-bit counter.") - self.recv_p, self.send_p = multiprocessing.Pipe(duplex=True) - self.current_exp = comm.PDExp(parameters, self.send_p) + + self.current_exp = comm.PDExp(parameters) self.plot.clearall() self.plot.changetype(self.current_exp) - self.current_exp.run_wrapper() - - self.send_p.close() + comm.serial_instance.proc_pipe_p.send(self.current_exp) self.plot_proc = gobject.timeout_add(200, self.experiment_running_plot) @@ -564,15 +559,13 @@ class Main(object): raise InputError(parameters['clean_s'], "Time must fit in 16-bit counter.") - self.recv_p, self.send_p = multiprocessing.Pipe(duplex=True) - self.current_exp = comm.PotExp(parameters, self.send_p) + + self.current_exp = comm.PotExp(parameters) self.plot.clearall() self.plot.changetype(self.current_exp) - self.current_exp.run_wrapper() - - self.send_p.close() + comm.serial_instance.proc_pipe_p.send(self.current_exp) self.plot_proc = gobject.timeout_add(200, self.experiment_running_plot) @@ -584,21 +577,25 @@ class Main(object): "Experiment not yet implemented.") exceptions() - except ValueError: + except ValueError as i: + print i self.statusbar.push(self.error_context_id, "Experiment parameters must be integers.") exceptions() except InputError as err: + print err self.statusbar.push(self.error_context_id, err.msg) exceptions() - except SerialException: + except SerialException as err: + print err self.statusbar.push(self.error_context_id, "Could not establish serial connection.") exceptions() except AssertionError as err: + print err self.statusbar.push(self.error_context_id, str(err)) exceptions() @@ -612,8 +609,8 @@ class Main(object): function from GTK's queue. """ try: - if self.recv_p.poll(): - incoming = self.recv_p.recv() + if comm.serial_instance.data_pipe_p.poll(): + incoming = comm.serial_instance.data_pipe_p.recv() if isinstance(incoming, basestring): #test if incoming is str self.experiment_done() self.on_serial_disconnect_clicked() @@ -630,13 +627,37 @@ class Main(object): if len(data) > 2: self.current_exp.data_extra[2*self.line+i].append( data[i+2]) + + return True + + elif comm.serial_instance.proc_pipe_p.poll(): + proc_buffer = comm.serial_instance.proc_pipe_p.recv() + + if proc_buffer == ("DONE" or "SERIAL_ERROR" or "ABORT"): + print proc_buffer + if (proc_buffer == "DONE") and (comm.serial_instance.data_pipe_p.poll()): + pass + + else: + self.experiment_done() + if proc_buffer == "SERIAL_ERROR": + self.on_serial_disconnect_clicked() + return False + + else: + print proc_buffer + + return True + else: time.sleep(.001) - return True - except EOFError: + return True + except EOFError as err: + print err self.experiment_done() return False - except IOError: + except IOError as err: + print err self.experiment_done() return False @@ -648,10 +669,20 @@ class Main(object): False -- when experiment process signals EOFError or IOError to remove function from GTK's queue. """ + try: - if self.recv_p.poll(): - incoming = self.recv_p.recv() + if comm.serial_instance.proc_pipe_p.poll(): + proc_buffer = comm.serial_instance.proc_pipe_p.recv() + if proc_buffer == "DONE" or "SERIAL_ERROR" or "ABORT": + if proc_buffer == "SERIAL_ERROR": + self.on_serial_disconnect_clicked() + + return False + + if comm.serial_instance.data_pipe_p.poll(): + incoming = comm.serial_instance.data_pipe_p.recv() + if isinstance(incoming, basestring): #test if incoming is str self.on_serial_disconnect_clicked() return False @@ -661,6 +692,7 @@ class Main(object): " V"]) self.ocp_disp.set_text(data) + else: time.sleep(.001) return True @@ -720,7 +752,6 @@ class Main(object): if self.dropbot_enabled == True: if self.dropbot_triggered == True: self.dropbot_triggered = False - print "expdone" self.microdrop.reply(microdrop.EXPFINISHED) self.microdrop_proc = gobject.timeout_add(500, self.microdrop_listen) @@ -733,18 +764,15 @@ class Main(object): def on_pot_stop_clicked(self, data=None): """Stop current experiment. Signals experiment process to stop.""" try: - print "stop" - self.recv_p.send('a') - while True: - if self.recv_p.poll(): - if self.recv_p.recv() == "ABORT": - return + gobject.source_remove(self.ocp_proc) + time.sleep(.1) + comm.serial_instance.ctrl_pipe_p.send('a') + while not (comm.serial_instance.proc_pipe_p.recv() == "ABORT"): + pass except AttributeError: pass - except IOError: - pass - except EOFError: - pass + except: + print str(sys.exc_info()) def on_file_save_exp_activate(self, menuitem, data=None): """Activate dialogue to save current experiment data. """ diff --git a/dstat_interface/dstat_comm.py b/dstat_interface/dstat_comm.py index e4fc8f6..59b15d3 100644 --- a/dstat_interface/dstat_comm.py +++ b/dstat_interface/dstat_comm.py @@ -24,6 +24,61 @@ import struct import multiprocessing as mp from errors import VarError +def _serial_process(ser_port, proc_pipe, ctrl_pipe, data_pipe): + ser = delayedSerial(ser_port, baudrate=1000000, timeout=1) + + print "Connecting" + + ser.write("ck") + + ser.flushInput() + ser.write('!') + + for i in range(10): + if not ser.read()=="C": + time.sleep(.5) + ser.write('!') + else: + break + + print "loop" + while True: + if ctrl_pipe.poll(): + ctrl_buffer = ctrl_pipe.recv() + print ctrl_buffer + + if ctrl_buffer == ('a' or "DISCONNECT"): + ser.write('a') + print "ABORT!" + proc_pipe.send("ABORT") + + if ctrl_buffer == "DISCONNECT": + print "_serial_process DISCONNECT" + ser.close() + proc_pipe.send("DISCONNECT") + return False + + + elif proc_pipe.poll(): + while ctrl_pipe.poll(): + ctrl_pipe.recv() + proc_pipe.send(proc_pipe.recv().run(ser, ctrl_pipe, data_pipe)) + + + +class SerialConnection(object): + def __init__(self, ser_port): + self.proc_pipe_p, self.proc_pipe_c = mp.Pipe(duplex=True) + self.ctrl_pipe_p, self.ctrl_pipe_c = mp.Pipe(duplex=True) + self.data_pipe_p, self.data_pipe_c = mp.Pipe(duplex=True) + + print "connect" + self.proc = mp.Process(target=_serial_process, args=(ser_port, + self.proc_pipe_c, self.ctrl_pipe_c, + self.data_pipe_c)) + self.proc.start() + + def call_it(instance, name, args=(), kwargs=None): """Indirect caller for instance methods and multiprocessing. @@ -37,6 +92,153 @@ def call_it(instance, name, args=(), kwargs=None): kwargs = {} return getattr(instance, name)(*args, **kwargs) +class VersionCheck: + def __init__(self): + pass + + def run(self, ser, ctrl_pipe, data_pipe): + """Tries to contact DStat and get version. Returns a tuple of + (major, minor). If no response, returns empty tuple. + + Arguments: + ser_port -- address of serial port to use + """ + try: + ser.write('V') + for line in ser: + if line.startswith('V'): + input = line.lstrip('V') + elif line.startswith("#"): + print line + elif line.lstrip().startswith("no"): + print line + ser.flushInput() + break + + parted = input.rstrip().split('.') + print "run()" + print parted + + data_pipe.send((int(parted[0]), int(parted[1]))) + status = "DONE" + + except UnboundLocalError as i: + print i + status = "SERIAL_ERROR" + except SerialException as i: + print i + status = "SERIAL_ERROR" + + finally: + return status + +class Settings: + def __init__(self, task, settings=None): + self.task = task + self.settings = settings + + def run(self, ser, ctrl_pipe, data_pipe): + """Tries to contact DStat and get settings. Returns dict of + settings. + """ + + self.ser = ser + + if 'w' in self.task: + self.write() + + if 'r' in self.task: + data_pipe.send(self.read()) + + status = "DONE" + + return status + + def read(self): + settings = {} + + self.ser.flushInput() + self.ser.write('!') + + while not self.ser.read()=="C": + time.sleep(.5) + self.ser.write('!') + + self.ser.write('SR') + for line in self.ser: + if line.lstrip().startswith('S'): + input = line.lstrip().lstrip('S') + elif line.lstrip().startswith("#"): + print line + elif line.lstrip().startswith("no"): + print line + self.ser.flushInput() + break + + parted = input.rstrip().split(':') + + for i in range(len(parted)): + settings[parted[i].split('.')[0]] = [i, parted[i].split('.')[1]] + + return settings + + def write(self): + self.ser.flushInput() + self.ser.write('!') + + while not self.ser.read()=="C": + time.sleep(.5) + self.ser.write('!') + + write_buffer = range(len(self.settings)) + + for i in self.settings: # make sure settings are in right order + write_buffer[self.settings[i][0]] = self.settings[i][1] + + self.ser.write('SW') + for i in write_buffer: + self.ser.write(i) + self.ser.write(' ') + + return + +class LightSensor: + def __init__(self): + pass + + def run(self, ser, ctrl_pipe, data_pipe): + """Tries to contact DStat and get light sensor reading. Returns uint of + light sensor clear channel. + """ + + ser.flushInput() + ser.write('!') + + while not ser.read()=="C": + time.sleep(.5) + ser.write('!') + + + ser.write('T') + for line in ser: + if line.lstrip().startswith('T'): + input = line.lstrip().lstrip('T') + elif line.lstrip().startswith("#"): + print line + elif line.lstrip().startswith("no"): + print line + ser.flushInput() + break + + parted = input.rstrip().split('.') + print parted + + data_pipe.send(parted[0]) + status = "DONE" + + return status + + def version_check(ser_port): """Tries to contact DStat and get version. Returns a list of [(major, minor), serial instance]. If no response, returns empty tuple. @@ -44,63 +246,35 @@ def version_check(ser_port): Arguments: ser_port -- address of serial port to use """ - - global serial_instance - serial_instance = delayedSerial(ser_port, baudrate=1000000, timeout=1) + try: + global serial_instance + serial_instance = SerialConnection(ser_port) - serial_instance.write("ck") - - serial_instance.flushInput() - serial_instance.write('!') - - while not serial_instance.read()=="C": - time.sleep(.5) - serial_instance.write('!') - - serial_instance.write('V') - for line in serial_instance: - if line.startswith('V'): - input = line.lstrip('V') - elif line.startswith("#"): - print line - elif line.lstrip().startswith("no"): - print line - serial_instance.flushInput() - break - - parted = input.rstrip().split('.') - print parted + serial_instance.proc_pipe_p.send(VersionCheck()) + result = serial_instance.proc_pipe_p.recv() + if result == "SERIAL_ERROR": + buffer = 1 + else: + buffer = serial_instance.data_pipe_p.recv() + print result + + return buffer + + except: + pass - return (int(parted[0]), int(parted[1])) def read_light_sensor(): """Tries to contact DStat and get light sensor reading. Returns uint of light sensor clear channel. """ - serial_instance.flushInput() - serial_instance.write('!') - - while not serial_instance.read()=="C": - time.sleep(.5) - serial_instance.write('!') - - - serial_instance.write('T') - for line in serial_instance: - if line.lstrip().startswith('T'): - input = line.lstrip().lstrip('T') - elif line.lstrip().startswith("#"): - print line - elif line.lstrip().startswith("no"): - print line - serial_instance.flushInput() - break - - parted = input.rstrip().split('.') - print parted + serial_instance.proc_pipe_p.send(LightSensor()) - return int(parted[0]) + while serial_instance.proc_pipe_p.recv() != "DONE": + pass + + return serial_instance.data_pipe_p.recv() def read_settings(): """Tries to contact DStat and get settings. Returns dict of @@ -109,29 +283,11 @@ def read_settings(): global settings settings = {} + serial_instance.proc_pipe_p.send(Settings(task='r')) + settings = serial_instance.data_pipe_p.recv() - serial_instance.flushInput() - serial_instance.write('!') - - while not serial_instance.read()=="C": - time.sleep(.5) - serial_instance.write('!') - - serial_instance.write('SR') - for line in serial_instance: - if line.lstrip().startswith('S'): - input = line.lstrip().lstrip('S') - elif line.lstrip().startswith("#"): - print line - elif line.lstrip().startswith("no"): - print line - serial_instance.flushInput() - break - - parted = input.rstrip().split(':') - - for i in range(len(parted)): - settings[parted[i].split('.')[0]] = [i, parted[i].split('.')[1]] + while serial_instance.proc_pipe_p.recv() != "DONE": + pass return @@ -139,22 +295,10 @@ def write_settings(): """Tries to write settings to DStat from global settings var. """ - serial_instance.flushInput() - serial_instance.write('!') - - while not serial_instance.read()=="C": - time.sleep(.5) - serial_instance.write('!') - - write_buffer = range(len(settings)) - - for i in settings: # make sure settings are in right order - write_buffer[settings[i][0]] = settings[i][1] + serial_instance.proc_pipe_p.send(Settings(task='w')) - serial_instance.write('SW') - for i in write_buffer: - serial_instance.write(i) - serial_instance.write(' ') + while serial_instance.proc_pipe_p.recv() != "DONE": + pass return @@ -185,18 +329,18 @@ class Experiment(object): """Store and acquire a potentiostat experiment. Meant to be subclassed to by different experiment types and not used instanced directly. """ - def run_wrapper(self, *argv): - """Execute experiment indirectly using call_it to bypass lack of fork() - on Windows for multiprocessing. - """ - self.proc = mp.Process(target=call_it, args=(self, 'run', argv)) - self.proc.start() + # def run_wrapper(self, *argv): + # """Execute experiment indirectly using call_it to bypass lack of fork() + # on Windows for multiprocessing. + # """ + # self.proc = mp.Process(target=call_it, args=(self, 'run', argv)) + # self.proc.start() - def __init__(self, parameters, main_pipe): + def __init__(self, parameters): """Adds commands for gain and ADC.""" self.parameters = parameters - self.main_pipe = main_pipe self.databytes = 8 + self.scan = 0 self.data_extra = [] # must be defined even when not needed @@ -230,15 +374,20 @@ class Experiment(object): self.commands[1] += (self.parameters['re_short']) self.commands[1] += " " - def run(self): + def run(self, ser, ctrl_pipe, data_pipe): """Execute experiment. Connects and sends handshake signal to DStat then sends self.commands. Don't call directly as a process in Windows, use run_wrapper instead. """ - self.serial = serial_instance + self.serial = ser + self.ctrl_pipe = ctrl_pipe + self.data_pipe = data_pipe + + print "run" try: self.serial.flushInput() + status = "DONE" for i in self.commands: print i @@ -249,42 +398,48 @@ class Experiment(object): self.serial.write(i) if not self.serial_handler(): - self.main_pipe.send("ABORT") + status = "ABORT" break - + except serial.SerialException: - self.main_pipe.send("ABORT") + status = "SERIAL_ERROR" finally: self.data_postprocessing() - self.main_pipe.close() + while self.ctrl_pipe.poll(): + self.ctrl_pipe.recv() + return status def serial_handler(self): """Handles incoming serial transmissions from DStat. Returns False if stop button pressed and sends abort signal to instrument. Sends - data to self.main_pipe as result of self.data_handler). + data to self.data_pipe as result of self.data_handler). """ scan = 0 try: while True: - if self.main_pipe.poll(): - if self.main_pipe.recv() == 'a': + if self.ctrl_pipe.poll(): + print "serial_handler ctrl_pipe" + input = self.ctrl_pipe.recv() + print input + if input == ('a' or "DISCONNECT"): self.serial.write('a') - print "ABORT!" + print "ABORT pressed!" return False for line in self.serial: - if self.main_pipe.poll(): - if self.main_pipe.recv() == 'a': + if self.ctrl_pipe.poll(): + if self.ctrl_pipe.recv() == 'a': self.serial.write('a') - print "ABORT!" + print "ABORT pressed" return False if line.startswith('B'): - self.main_pipe.send(self.data_handler( - (scan, self.serial.read(size=self.databytes)))) + data = self.data_handler( + (scan, self.serial.read(size=self.databytes))) + self.data_pipe.send(data) elif line.startswith('S'): - scan += 1 + self.scan += 1 elif line.lstrip().startswith("#"): print line elif line.lstrip().startswith("no"): @@ -315,8 +470,8 @@ class Experiment(object): class Chronoamp(Experiment): """Chronoamperometry experiment""" - def __init__(self, parameters, main_pipe): - super(Chronoamp, self).__init__(parameters, main_pipe) + def __init__(self, parameters): + super(Chronoamp, self).__init__(parameters) self.datatype = "linearData" self.xlabel = "Time (s)" @@ -353,8 +508,8 @@ class Chronoamp(Experiment): class PDExp(Chronoamp): """Photodiode/PMT experiment""" - def __init__(self, parameters, main_pipe): - super(Chronoamp, self).__init__(parameters, main_pipe) # Don't want to call CA's init + def __init__(self, parameters): + super(Chronoamp, self).__init__(parameters) # Don't want to call CA's init self.datatype = "linearData" self.xlabel = "Time (s)" @@ -386,8 +541,8 @@ class PDExp(Chronoamp): class PotExp(Experiment): """Potentiometry experiment""" - def __init__(self, parameters, main_pipe): - super(PotExp, self).__init__(parameters, main_pipe) + def __init__(self, parameters): + super(PotExp, self).__init__(parameters) self.datatype = "linearData" self.xlabel = "Time (s)" @@ -413,8 +568,8 @@ class PotExp(Experiment): class LSVExp(Experiment): """Linear Scan Voltammetry experiment""" - def __init__(self, parameters, main_pipe): - super(LSVExp, self).__init__(parameters, main_pipe) + def __init__(self, parameters): + super(LSVExp, self).__init__(parameters) self.datatype = "linearData" self.xlabel = "Voltage (mV)" @@ -446,8 +601,8 @@ class LSVExp(Experiment): class CVExp(Experiment): """Cyclic Voltammetry experiment""" - def __init__(self, parameters, main_pipe): - super(CVExp, self).__init__(parameters, main_pipe) + def __init__(self, parameters): + super(CVExp, self).__init__(parameters) self.datatype = "CVData" self.xlabel = "Voltage (mV)" @@ -483,8 +638,8 @@ class CVExp(Experiment): class SWVExp(Experiment): """Square Wave Voltammetry experiment""" - def __init__(self, parameters, main_pipe): - super(SWVExp, self).__init__(parameters, main_pipe) + def __init__(self, parameters): + super(SWVExp, self).__init__(parameters) self.datatype = "SWVData" self.xlabel = "Voltage (mV)" @@ -539,9 +694,9 @@ class SWVExp(Experiment): class DPVExp(SWVExp): """Diffential Pulse Voltammetry experiment.""" - def __init__(self, parameters, main_pipe): + def __init__(self, parameters): """Overrides SWVExp method, extends Experiment method""" - super(SWVExp, self).__init__(parameters, main_pipe) + super(SWVExp, self).__init__(parameters) self.datatype = "SWVData" self.xlabel = "Voltage (mV)" @@ -582,9 +737,7 @@ class DPVExp(SWVExp): class OCPExp(Experiment): """Open circuit potential measumement in statusbar.""" - def __init__(self, main_pipe): - """Only needs data pipe.""" - self.main_pipe = main_pipe + def __init__(self): self.databytes = 8 self.commands = ["EA", "EP"] diff --git a/dstat_interface/interface/exp_int.py b/dstat_interface/interface/exp_int.py index b6410b2..682d375 100644 --- a/dstat_interface/interface/exp_int.py +++ b/dstat_interface/interface/exp_int.py @@ -214,6 +214,7 @@ class PD(ExpInterface): self.builder.get_object('light_label').set_text(str( dstat_comm.read_light_sensor())) dstat_comm.read_settings() + self.builder.get_object('threshold_entry').set_text(str( dstat_comm.settings['tcs_clear_threshold'][1])) __main__.MAIN.start_ocp() @@ -266,6 +267,7 @@ class CAL(ExpInterface): gobject.source_remove(__main__.MAIN.ocp_proc) dstat_comm.read_settings() + self.entry['R100'].set_text(str( dstat_comm.settings['r100_trim'][1])) self.entry['R3k'].set_text(str( -- GitLab