def connect(self):
        '''
        Connect to dropbot-dx instrument.
        '''
        self.has_environment_data = False
        self.environment_sensor_master = None

        # if the dropbot dx plugin is installed and enabled, try getting its
        # reference
        try:
            service = get_service_instance_by_name('wheelerlab.dropbot_dx')
            if service.enabled():
                self.dropbot_dx_remote = service.control_board
        except:
            pass

        if self.dropbot_dx_remote is None:
            # if we couldn't get a reference, try finding a DropBot DX connected to
            # a serial port
            try:
                self.dropbot_dx_remote = dx.SerialProxy()
                host_version = self.dropbot_dx_remote.host_software_version
                remote_version = self.dropbot_dx_remote.remote_software_version

                if remote_version != host_version:
                    response = yesno('The DropBot DX firmware version (%s) '
                                     'does not match the driver version (%s). '
                                     'Update firmware?' % (remote_version,
                                                           host_version))
                    if response == gtk.RESPONSE_YES:
                        self.on_flash_firmware()

                # turn on the light by default
                self.dropbot_dx_remote.light_enabled = True
            except IOError:
                logger.warning('Could not connect to DropBot DX.')

        try:
            env = self.get_environment_state(self.dropbot_dx_remote).to_dict()
            logger.info('temp=%.1fC, Rel. humidity=%.1f%%' %
                        (env['temperature_celsius'],
                         100 * env['relative_humidity']))
            self.has_environment_data = True
            self.environment_sensor_master = self.dropbot_dx_remote
        except:
            service = get_service_instance_by_name('wheelerlab.dmf_control_board_plugin')
            if service.enabled() and service.control_board.connected():
                try:
                    env = self.get_environment_state(service.control_board).to_dict()
                    logger.info('temp=%.1fC, Rel. humidity=%.1f%%' %
                                (env['temperature_celsius'],
                                 100 * env['relative_humidity']))
                    self.has_environment_data = True
                    self.environment_sensor_master = service.control_board
                except:
                    pass

        # Get instrument identifier, if available.
        self.dropbot_dx_id = getattr(self.dropbot_dx_remote, 'id', None)
 def get_step_label(self):
     try:
         step_label_plugin =\
             get_service_instance_by_name('wheelerlab.step_label_plugin')
         return step_label_plugin.get_step_options().get('label')
     except:
         return None
Пример #3
0
def max_voltage(element, state):
    """Verify that the voltage is below a set maximum"""
    service = get_service_instance_by_name(ph.path(__file__).parent.name)

    if service.control_board and (element.value >
                                  service.control_board.max_waveform_voltage):
        return element.errors.append(
            'Voltage exceeds the maximum value (%d '
            'V).' % service.control_board.max_waveform_voltage)
    else:
        return True
def max_voltage(element, state):
    """Verify that the voltage is below a set maximum"""
    service = get_service_instance_by_name(
        get_plugin_info(path(__file__).parent).plugin_name)

    if service.control_board.connected() and \
        element.value > service.control_board.max_waveform_voltage:
        return element.errors.append('Voltage exceeds the maximum value '
                                     '(%d V).' %
                                     service.control_board.max_waveform_voltage)
    else:
        return True
Пример #5
0
def check_frequency(element, state):
    """Verify that the frequency is within the valid range"""
    service = get_service_instance_by_name(ph.path(__file__).parent.name)

    if service.control_board and (
            element.value < service.control_board.min_waveform_frequency
            or element.value > service.control_board.max_waveform_frequency):
        return element.errors.append(
            'Frequency is outside of the valid range '
            '(%.1f - %.1f Hz).' %
            (service.control_board.min_waveform_frequency,
             service.control_board.max_waveform_frequency))
    else:
        return True
Пример #6
0
 def initialize_connection_with_dropbot(self):
     '''
     If the dropbot plugin is installed and enabled, try getting its
     reference.
     '''
     try:
         service = get_service_instance_by_name('dropbot_plugin')
         if service.enabled():
             self.dropbot_remote = service.control_board
         assert(self.dropbot_remote.properties.package_name == 'dropbot')
     except Exception:
         logger.debug('[%s] Could not communicate with Dropbot.', __name__,
                      exc_info=True)
         logger.warning('Could not communicate with DropBot.')
def check_frequency(element, state):
    """Verify that the frequency is within the valid range"""
    service = get_service_instance_by_name(
        get_plugin_info(path(__file__).parent).plugin_name)

    if service.control_board.connected() and \
        (element.value < service.control_board.min_waveform_frequency or \
        element.value > service.control_board.max_waveform_frequency):
        return element.errors.append('Frequency is outside of the valid range '
            '(%.1f - %.1f Hz).' %
            (service.control_board.min_waveform_frequency,
             service.control_board.max_waveform_frequency)
        )
    else:
        return True