Example #1
0
    def _manager_factory(self):
        """
        """

        ip = InitializationParser()
        plugin = ip.get_plugin(self.klass[1].replace('Manager', ''), category='hardware')
        mode = ip.get_parameter(plugin, 'mode')

        if mode == 'client':
            klass = ip.get_parameter(plugin, 'klass')
            if klass is None:
                klass = 'PychronLaserManager'

            pkg = 'pychron.lasers.laser_managers.pychron_laser_manager'
            try:
                tag = ip.get_parameter(plugin, 'communications', element=True)
                #                tag = plugin.find('communications')
                params = dict()
                for attr in ['host', 'port', 'kind']:
                    try:
                        params[attr] = tag.find(attr).text.strip()
                    except Exception, e:
                        print 'client comms fail', attr, e
            except Exception, e:
                print 'client comms fail', e

            params['name'] = self.name
            factory = __import__(pkg, fromlist=[klass])
            m = getattr(factory, klass)(**params)
Example #2
0
    def _manager_factory(self):
        """
        """

        ip = InitializationParser()
        plugin = ip.get_plugin(self.klass[1].replace('Manager', ''),
                               category='hardware')
        mode = ip.get_parameter(plugin, 'mode')

        if mode == 'client':
            klass = ip.get_parameter(plugin, 'klass')
            if klass is None:
                klass = 'PychronLaserManager'

            pkg = 'pychron.lasers.laser_managers.pychron_laser_manager'
            try:
                tag = ip.get_parameter(plugin, 'communications', element=True)
                #                tag = plugin.find('communications')
                params = dict()
                for attr in ['host', 'port', 'kind']:
                    try:
                        params[attr] = tag.find(attr).text.strip()
                    except Exception, e:
                        print 'client comms fail', attr, e
            except Exception, e:
                print 'client comms fail', e

            params['name'] = self.name
            factory = __import__(pkg, fromlist=[klass])
            m = getattr(factory, klass)(**params)
Example #3
0
    def _monitor_factory(self):
        mon = None
        isok = True
        self.debug('Experiment Executor mode={}'.format(self.mode))
        if self.mode == 'client':
            ip = InitializationParser()
            exp = ip.get_plugin('Experiment', category='general')
            monitor = exp.find('monitor')
            if monitor is not None:
                if to_bool(monitor.get('enabled')):
                    host, port, kind = None, None, None
                    comms = monitor.find('communications')
                    host = comms.find('host')
                    port = comms.find('port')
                    kind = comms.find('kind')

                    if host is not None:
                        host = host.text  # if host else 'localhost'
                    if port is not None:
                        port = int(port.text)  # if port else 1061
                    if kind is not None:
                        kind = kind.text
                    mon = RemoteAutomatedRunMonitor(host, port, kind, name=monitor.text.strip())
        else:
            mon = AutomatedRunMonitor()

        self.debug('Automated run monitor {}'.format(mon))
        if mon is not None:
        #        mon.configuration_dir_name = paths.monitors_dir
            isok = mon.load()
            if isok:
                return mon
            else:
                self.warning(
                    'no automated run monitor avaliable. Make sure config file is located at setupfiles/monitors/automated_run_monitor.cfg')
Example #4
0
    def _pyscript_runner_default(self):
        if self.mode == 'client':
        #            em = self.extraction_line_manager
            ip = InitializationParser()
            elm = ip.get_plugin('Experiment', category='general')
            runner = elm.find('runner')
            host, port, kind = None, None, None

            if runner is not None:
                comms = runner.find('communications')
                host = comms.find('host')
                port = comms.find('port')
                kind = comms.find('kind')

            if host is not None:
                host = host.text  # if host else 'localhost'
            if port is not None:
                port = int(port.text)  # if port else 1061
                kind = kind.text  # if kind else 'udp'

            runner = RemotePyScriptRunner(host, port, kind)
        else:
            runner = PyScriptRunner()

        return runner
Example #5
0
    def _pyscript_runner_default(self):
        if self.mode == 'client':
            #            em = self.extraction_line_manager
            ip = InitializationParser()
            elm = ip.get_plugin('Experiment', category='general')
            runner = elm.find('runner')
            host, port, kind = None, None, None

            if runner is not None:
                comms = runner.find('communications')
                host = comms.find('host')
                port = comms.find('port')
                kind = comms.find('kind')

            if host is not None:
                host = host.text  # if host else 'localhost'
            if port is not None:
                port = int(port.text)  # if port else 1061
                kind = kind.text  # if kind else 'udp'

            runner = RemotePyScriptRunner(host, port, kind)
        else:
            runner = PyScriptRunner()

        return runner
Example #6
0
 def _sources_default(self):
     ip = InitializationParser()
     plugin = ip.get_plugin(self.task_name.replace(' ', ''),
                            category='hardware')
     source = ip.get_parameter(plugin, 'video_source')
     rs = []
     if source:
         rs = [(source, self.task_name)]
     return rs
Example #7
0
 def _sources_default(self):
     ip = InitializationParser()
     plugin = ip.get_plugin(self.task_name.replace(' ', ''),
                            category='hardware')
     source = ip.get_parameter(plugin, 'video_source')
     rs = []
     if source:
         rs = [(source, self.task_name)]
     return rs
    def _factory(self):
        from pychron.initialization_parser import InitializationParser

        ip = InitializationParser()
        try:
            plugin = ip.get_plugin('ExtractionLine', category='hardware')
            mode = ip.get_parameter(plugin, 'mode')
        #            mode = plugin.get('mode')
        except AttributeError:
            # no epxeriment plugin defined
            mode = 'normal'

        elm = ExtractionLineManager(mode=mode)
        elm.bind_preferences()
        return elm
Example #9
0
    def _factory(self):
        from pychron.initialization_parser import InitializationParser

        ip = InitializationParser()
        try:
            plugin = ip.get_plugin('ExtractionLine', category='hardware')
            mode = ip.get_parameter(plugin, 'mode')
        #            mode = plugin.get('mode')
        except AttributeError:
            # no epxeriment plugin defined
            mode = 'normal'

        elm = ExtractionLineManager(mode=mode)
        elm.bind_preferences()
        return elm
Example #10
0
    def _manager_factory(self):
        from pychron.experiment.experimentor import Experimentor
        from pychron.initialization_parser import InitializationParser

        ip = InitializationParser()
        plugin = ip.get_plugin('Experiment', category='general')
        mode = ip.get_parameter(plugin, 'mode')

        app = None
        if self.window:
            app = self.window.application

        exp = Experimentor(application=app,
                           mode=mode)

        return exp
Example #11
0
    def _monitor_factory(self):
        mon = None
        isok = True
        self.debug('Experiment Executor mode={}'.format(self.mode))
        if self.mode == 'client':
            ip = InitializationParser()
            exp = ip.get_plugin('Experiment', category='general')
            monitor = exp.find('monitor')
            if monitor is not None:
                if to_bool(monitor.get('enabled')):
                    host, port, kind = None, None, None
                    comms = monitor.find('communications')
                    host = comms.find('host')
                    port = comms.find('port')
                    kind = comms.find('kind')

                    if host is not None:
                        host = host.text  # if host else 'localhost'
                    if port is not None:
                        port = int(port.text)  # if port else 1061
                    if kind is not None:
                        kind = kind.text
                    mon = RemoteAutomatedRunMonitor(host,
                                                    port,
                                                    kind,
                                                    name=monitor.text.strip())
        else:
            mon = AutomatedRunMonitor()

        self.debug('Automated run monitor {}'.format(mon))
        if mon is not None:
            #        mon.configuration_dir_name = paths.monitors_dir
            isok = mon.load()
            if isok:
                return mon
            else:
                self.warning(
                    'no automated run monitor avaliable. Make sure config file is located at setupfiles/monitors/automated_run_monitor.cfg'
                )