diff --git a/dstat_interface/dstat_comm.py b/dstat_interface/dstat_comm.py index 0e8469b73f40ec0539de0da8e45b9f40c0a36cb1..d002e006781b0364d7cad44f8ab381595fbdcea9 100755 --- a/dstat_interface/dstat_comm.py +++ b/dstat_interface/dstat_comm.py @@ -345,8 +345,10 @@ class Experiment(object): self.databytes = 8 self.scan = 0 self.time = 0 - - self.data_extra = [] # must be defined even when not needed + + # list of scans, tuple of dimensions, list of data + self.data = [([], [])] + self.line_data = ([], []) major, minor = self.parameters['version'] @@ -463,13 +465,15 @@ class Experiment(object): def data_handler(self, data_input): """Takes data_input as tuple -- (scan, data). Returns: - (scan number, [voltage, current]) -- voltage in mV, current in A + (scan number, (voltage, current)) -- voltage in mV, current in A """ scan, data = data_input voltage, current = struct.unpack(' self.lastdataline: - self.current_exp.data += [[], []] - if len(data) > 2: - self.current_exp.data_extra += [[], []] + self.current_exp.data.append( + deepcopy(self.current_exp.line_data)) self.lastdataline = self.line - for i in range(2): - self.current_exp.data[2*self.line+i].append(data[i]) - if len(data) > 2: - self.current_exp.data_extra[2*self.line+i].append( - data[i+2]) + + for i in range(len(self.current_exp.data[self.line])): + self.current_exp.data[self.line][i].append(data[i]) + if comm.serial_instance.data_pipe_p.poll(): self.experiment_running_data() return True @@ -673,39 +668,50 @@ class Main(object): gobject.source_remove(self.plot_proc) # stop automatic plot update self.experiment_running_plot() # make sure all data updated on plot + self.databuffer.set_text("") + self.databuffer.place_cursor(self.databuffer.get_start_iter()) + self.rawbuffer.insert_at_cursor("\n") + self.rawbuffer.set_text("") + self.rawbuffer.place_cursor(self.rawbuffer.get_start_iter()) + + # Shutter stuff if (self.current_exp.parameters['shutter_true'] and self.current_exp.parameters['sync_true']): self.ft_plot.updateline(self.current_exp, 0) self.ft_plot.redraw() - self.current_exp.data_extra = self.current_exp.ftdata + for col in zip(*self.current_exp.ftdata): + for row in col: + self.databuffer.insert_at_cursor(str(row)+ " ") + self.databuffer.insert_at_cursor("\n") + self.statusbar.push( self.message_context_id, " ".join( ("Integral:", str(self.current_exp.ft_int), " A") ) ) - - self.databuffer.set_text("") - self.databuffer.place_cursor(self.databuffer.get_start_iter()) - self.rawbuffer.insert_at_cursor("\n") - self.rawbuffer.set_text("") - self.rawbuffer.place_cursor(self.rawbuffer.get_start_iter()) - + + # Write DStat commands for i in self.current_exp.commands: self.rawbuffer.insert_at_cursor(i) self.rawbuffer.insert_at_cursor("\n") - - for col in zip(*self.current_exp.data): - for row in col: - self.rawbuffer.insert_at_cursor(str(row)+ " ") - self.rawbuffer.insert_at_cursor("\n") - if self.current_exp.data_extra: - for col in zip(*self.current_exp.data_extra): - for row in col: - self.databuffer.insert_at_cursor(str(row)+ " ") - self.databuffer.insert_at_cursor("\n") - + # Data Output + line_buffer = [] + + for scan in self.current_exp.data: + for dimension in scan: + for i in range(len(dimension)): + try: + line_buffer[i] += "%s " % dimension[i] + except IndexError: + line_buffer.append("") + line_buffer[i] += "%s " % dimension[i] + + for i in line_buffer: + self.rawbuffer.insert_at_cursor("%s\n" % i) + + # Autosaving if self.autosave_checkbox.get_active(): save.autoSave(self.current_exp, self.autosavedir_button, self.autosavename.get_text(), self.expnumber) @@ -718,7 +724,8 @@ class Main(object): save.autoPlot(plots, self.autosavedir_button, self.autosavename.get_text(), self.expnumber) self.expnumber += 1 - + + # uDrop if self.dropbot_enabled == True: if self.dropbot_triggered == True: self.dropbot_triggered = False @@ -726,9 +733,11 @@ class Main(object): self.microdrop_proc = gobject.timeout_add(500, self.microdrop_listen) + # UI stuff self.spinner.stop() self.startbutton.set_sensitive(True) self.stopbutton.set_sensitive(False) + self.start_ocp() def on_pot_stop_clicked(self, data=None): diff --git a/dstat_interface/plot.py b/dstat_interface/plot.py index d69ba65594f54d6bed1b55e5f014ed2bc05c8e09..d49589ef0016c6eae02809b89554e3b342dca70b 100755 --- a/dstat_interface/plot.py +++ b/dstat_interface/plot.py @@ -138,12 +138,12 @@ class plotbox(object): the Experiment instance. """ # limits display to 2000 data points per line - divisor = len(Experiment.data[1+line_number*2]) // 2000 + 1 - + divisor = len(Experiment.data[line_number][0]) // 2000 + 1 + self.axe1.lines[line_number].set_ydata( - Experiment.data[1+line_number*2][1::divisor]) + Experiment.data[line_number][1][1::divisor]) self.axe1.lines[line_number].set_xdata( - Experiment.data[line_number*2][1::divisor]) + Experiment.data[line_number][0][1::divisor]) def changetype(self, Experiment): """Change plot type. Set axis labels and x bounds to those stored @@ -170,8 +170,8 @@ class ft_box(plotbox): if data[i] > target: return i - y = Experiment.data[1+line_number*2] - x = Experiment.data[line_number*2] + y = Experiment.data[line_number][1] + x = Experiment.data[line_number][0] freq = Experiment.parameters['adc_rate_hz'] i = search_value(x, float(Experiment.parameters['fft_start'])) y1 = y[i:]