Beispiel #1
0
 def connect(self, button=None):
     """ Function the connect button is attached to, to try to connect a amperometry PSoC device
     and display if the device is connected or not
     :param button: button the user clicks to try to connect the device
     """
     logging.debug("trying connecting")
     self.serialsettings = change_top.SerialSettingChanges(
         self.parent, self, None, None)
     if self.device.connected:
         logging.info("device is connected")
         if self.device.working:
             # If a device was just found then change the button's appearance
             if button:
                 button["text"] = 'Connected'
                 button.config(bg='green')
     else:
         logging.debug("attempting to connect")
         self.device = usb_comm.AmpUsb(self, self.device_params,
                                       self.serialsettings.port,
                                       self.serialsettings.speed)
         # If no device then try to connect
         if self.device.working:
             # If a device was just found then change the button's appearance
             if button:
                 button["text"] = 'Connected'
                 button.config(bg='green')
         else:
             logging.info("No Device detected"
                          )  # If still no device detected, warn the user
    def connect(self, button=None):
        """
        Function the connect button is attached to, to try to connect a amperometry PSoC device and display if the
        device is connected or not
        :param button: button the user clicks to try to connect the device
        :return:
        """
        logging.debug("trying connecting")

        if self.device.connected:
            logging.info("device is connected")
            pass  # If a device is already connected and someone hits the button, ignore it
        else:
            logging.debug("attempting to connect")
            self.device = usb_comm.AmpUsb(
                self,
                self.operation_params)  # If no device then try to connect
            if self.device.working:  # If a device was just found then change the button's appearance

                if button:
                    button["text"] = 'Connected'
                    button.config(bg='green')
            else:
                logging.info("No Device detected"
                             )  # If still no device detected, warn the user
Beispiel #3
0
    def __init__(self, parent=None):
        if not os.path.exists(
                'logging'):  # make a directory to store logging files
            os.makedirs('logging')
        date = time.strftime("%Y_%m_%d")
        logging.basicConfig(
            level=logging.INFO,
            filename="logging/" + date + "_logging_file.log",
            format=
            "%(asctime)-15s %(levelname)s %(module)s %(lineno)d: %(message)s")
        self.sensor_settings = properties.SensorSettings()
        self.serialsettings = None
        self.data_save_type = "Converted"
        self.device_params = properties.DeviceParameters()
        self.display_type = check_display_type()
        tk.Tk.__init__(self, parent)
        self.parent = parent
        self.voltage_source_label = tk.StringVar()
        self.electrode_config_label = tk.StringVar()
        self.device = usb_comm.AmpUsb(self, self.device_params,
                                      self.sensor_settings.port,
                                      self.sensor_settings.baud_rate)
        # let the user see if the device is set for 2 or 3 electrodes
        if hasattr(self.device, "found"):
            if self.device.found and self.device.connected:
                self.electrode_config_label.set(
                    "connected to the serial device")
            elif self.device.found:  # device i
                self.electrode_config_label.set("unable to connect to device")
            else:
                self.electrode_config_label.set("unable to connect to device")

        graph_props = graph_properties.GraphProps()
        # frame to put the connection button, graph toolbar and label for VDAC source
        self.frames = self.make_bottom_frames()

        # Make Notebooks to separate the CV and amperometry methods
        self.notebook = ttk.Notebook(self)
        self.sensor = sensor_frame.SensorFrame(self, self.notebook,
                                               graph_props)
        self.cv = cv_frame.CVFrame(self, self.notebook, graph_props)

        self.notebook.add(self.sensor, text="Settings")
        self.notebook.add(self.cv, text="Application")

        self.notebook.pack(side='top', expand=True, fill=tk.BOTH)
        tk.Label(self.frames[2],
                 textvariable=self.voltage_source_label,
                 font=("Bookman", 10)).pack(side='top')
        tk.Label(self.frames[2],
                 textvariable=self.electrode_config_label,
                 font=("Bookman", 10)).pack(side='top')

        # make a button to display connection settings and allow user to try to reconnect
        self.make_connect_button(self.frames[1])
        option_menu.OptionMenu(self)
    def __init__(self, parent=None):
        if not os.path.exists(
                'logging'):  # make a directory to store logging files
            os.makedirs('logging')
        date = time.strftime("%Y_%m_%d")
        logging.basicConfig(
            level=logging.INFO,
            filename="logging/" + date + "_logging_file.log",
            format=
            "%(asctime)-15s %(levelname)s %(module)s %(lineno)d: %(message)s")

        self.data_save_type = "Converted"
        self.device_params = properties.DeviceParameters()
        self.display_type = check_display_type()
        tk.Tk.__init__(self, parent)
        self.parent = parent
        self.voltage_source_label = tk.StringVar()
        # let the user see if the device is set for 2 or 3 electrodes
        self.electrode_config_label = tk.StringVar()
        # device starts in 3 electrode config
        self.electrode_config_label.set("3 electrode configuration")
        self.device = usb_comm.AmpUsb(self, self.device_params)
        graph_props = graph_properties.GraphProps()
        # frame to put the connection button, graph toolbar and label for VDAC source
        self.frames = self.make_bottom_frames()

        # Make Notebooks to separate the CV and amperometry methods
        self.notebook = ttk.Notebook(self)
        self.cv = cv_frame.CVFrame(self, self.notebook, graph_props)
        self.amp = amp_frame.AmpFrame(self, self.notebook, graph_props)
        self.asv = asv_frame.ASVFrame(self, self.notebook, graph_props)

        self.notebook.add(self.cv, text="Cyclic Voltammetry")
        self.notebook.add(self.amp, text="Amperometry")
        self.notebook.add(self.asv, text="Anode Stripping Voltammetry")

        self.notebook.pack(side='top', expand=True, fill=tk.BOTH)
        tk.Label(self.frames[2],
                 textvariable=self.voltage_source_label,
                 font=("Bookman", 10)).pack(side='top')
        tk.Label(self.frames[2],
                 textvariable=self.electrode_config_label,
                 font=("Bookman", 10)).pack(side='top')
        # make a button to display connection settings and allow user to try to reconnect
        self.make_connect_button(self.frames[1])
        option_menu.OptionMenu(self)
    def __init__(self, parent=None):

        logging.basicConfig(
            level=logging.DEBUG,
            format="%(levelname)s %(module)s %(lineno)d: %(message)s")
        self.data_save_type = "Converted"
        self.device = None  # no device connected yet
        self.data = data_class.PyplotData()

        self.operation_params = operation_params
        self.display_type = check_display_type()
        tk.Tk.__init__(self, parent)
        self.parent = parent
        self.device = usb_comm.AmpUsb(self, operation_params)
        """Make Notebooks to separate the CV and amperometry methods"""
        self.notebook = ttk.Notebook(self)
        amp_frame = ttk.Frame(self.notebook)
        cv_frame = ttk.Frame(self.notebook)
        self.notebook.add(cv_frame, text="Cyclic Voltammetry")
        self.notebook.add(amp_frame, text="Amperometry")

        self.init(amp_frame, cv_frame)