Exemplo n.º 1
0
from ._version import get_versions
__version__ = get_versions()['version']
del get_versions

# Prevent warning about potential future changes to Numpy scalar encoding
# behaviour.
json_tricks.NumpyEncoder.SHOW_SCALAR_WARNING = False

logger = logging.getLogger(__name__)

# Ignore natural name warnings from PyTables [1].
#
# [1]: https://www.mail-archive.com/[email protected]/msg01130.html
warnings.simplefilter('ignore', tables.NaturalNameWarning)

PluginGlobals.push_env('microdrop.managed')


class DmfZmqPlugin(ZmqPlugin):
    """
    API for adding/clearing droplet routes.
    """
    def __init__(self, parent, *args, **kwargs):
        self.parent = parent
        super(DmfZmqPlugin, self).__init__(*args, **kwargs)

    def check_sockets(self):
        """
        Check for messages on command and subscription sockets and process
        any messages accordingly.
        """
        return app.dmf_device

    def on_execute__get_svg_frame(self, request):
        app = get_app()
        return app.dmf_device.get_svg_frame()

    def on_execute__get_electrode_channels(self, request):
        app = get_app()
        return app.dmf_device.get_electrode_channels()

    def on_execute__dumps(self, request):
        app = get_app()
        return pickle.dumps(app.dmf_device)


PluginGlobals.push_env('microdrop.managed')


class DeviceInfoPlugin(Plugin, AppDataController):
    """
    This class is automatically registered with the PluginManager.
    """
    implements(IPlugin)
    version = get_plugin_info(path(__file__).parent).version
    plugin_name = get_plugin_info(path(__file__).parent).plugin_name

    '''
    AppFields
    ---------

    A flatland Form specifying application options for the current plugin.
                    observers = ExtensionPoint(IPlugin)
                    service = observers.service(form_name)
                    service.set_step_values(form_step.attrs,
                                            step_number=step_number)

    def on_selection_changed(self, grid_view):
        if self.selected_ids:
            _L().debug('selected_ids=%s', self.selected_ids)
            app = get_app()
            _L().debug('current_step_number=%d',
                       app.protocol.current_step_number)
            if app.protocol.current_step_number not in self.selected_ids:
                app.protocol.goto_step(self.selected_ids[0])


PluginGlobals.push_env('microdrop')


class ProtocolGridController(SingletonPlugin, AppDataController):
    implements(IPlugin)

    AppFields = Form.of(
        String.named('column_positions').using(
            default='{}', optional=True, properties=dict(show_in_gui=False)))

    def __init__(self):
        self.name = "microdrop.gui.protocol_grid_controller"
        self.builder = None
        self.widget = None
        self._enabled_fields = None
                    service = observers.service(form_name)
                    service.set_step_values(form_step.attrs,
                                            step_number=step_number)

    def on_selection_changed(self, grid_view):
        if self.selected_ids:
            logging.debug('[ProtocolGridView].on_selection_changed: '
                          'selected_ids=%s', self.selected_ids)
            app = get_app()
            logging.debug('\tcurrent_step_number=%d',
                          app.protocol.current_step_number)
            if app.protocol.current_step_number not in self.selected_ids:
                app.protocol.goto_step(self.selected_ids[0])


PluginGlobals.push_env('microdrop')


class ProtocolGridController(SingletonPlugin, AppDataController):
    implements(IPlugin)

    AppFields = Form.of(String.named('column_positions')
                        .using(default='{}', optional=True,
                               properties=dict(show_in_gui=False)))

    def __init__(self):
        self.name = "microdrop.gui.protocol_grid_controller"
        self.builder = None
        self.widget = None
        self._enabled_fields = None
        # e.g., 'wheelerlab.dmf_control_board_1.2':\