示例#1
0
    def start(self):
        # if self.managers:
        from pychron.envisage.initialization.initializer import Initializer

        dp = DevicePreferences()
        afh = self.application.preferences.get('pychron.hardware.auto_find_handle')
        awh = self.application.preferences.get('pychron.hardware.auto_write_handle')
        if afh is not None:
            toBool = lambda x: True if x == 'True' else False
            dp.serial_preference.auto_find_handle = toBool(afh)
            dp.serial_preference.auto_write_handle = toBool(awh)

        ini = Initializer(device_prefs=dp)
        for m in self.managers:
            ini.add_initialization(m)

        # any loaded managers will be registered as services
        if not ini.run(application=self.application):
            self.application.exit()
            return

        # create the hardware server
        rhm = self.application.get_service(RemoteHardwareManager)
        bind_preference(rhm, 'enable_hardware_server', 'pychron.hardware.enable_hardware_server')
        bind_preference(rhm, 'enable_directory_server', 'pychron.hardware.enable_directory_server')

        rhm.bootstrap()
示例#2
0
    def start(self):
        # if self.managers:
        from pychron.envisage.initialization.initializer import Initializer

        dp = DevicePreferences()
        afh = self.application.preferences.get('pychron.hardware.auto_find_handle')
        awh = self.application.preferences.get('pychron.hardware.auto_write_handle')
        if afh is not None:
            dp.serial_preference.auto_find_handle = to_bool(afh)
            dp.serial_preference.auto_write_handle = to_bool(awh)

        ini = Initializer(device_prefs=dp)
        for m in self.managers:
            ini.add_initialization(m)

        # any loaded managers will be registered as services
        if not ini.run(application=self.application):
            self.application.exit()
            # self.application.starting
            return

        # create the hardware proxy server
        ehs = to_bool(self.application.preferences.get('pychron.hardware.enable_hardware_server'))
        if ehs:
            # use_tx = to_bool(self.application.preferences.get('pychron.hardware.use_twisted', True))
            use_tx = True
            if use_tx:
                from pychron.tx.server import TxServer
                rhm = TxServer()
                node = self.application.preferences.node('pychron.hardware')
                ports = eval(node.get('ports', '[]'))
                factories = eval(node.get('factories', '[]'))

                for protocol in eval(node.get('pnames', '[]')):
                    factory = import_klass(factories[protocol])
                    port = int(ports[protocol])

                    exc = rhm.add_endpoint(port, factory(self.application))
                    if exc:
                        msg = 'Failed starting Command Server for "{}:{}". Please check that multiple ' \
                              'instances of pychron are not running on this computer. ' \
                              'Exception: {}'.format(protocol, port, exc)
                        self.warning_dialog(msg)
                    else:
                        self.info('Added Pychron Proxy Service: {}:{}'.format(protocol, port))

            # else:
            #     from pychron.remote_hardware.remote_hardware_manager import RemoteHardwareManager
            #     rhm = RemoteHardwareManager(application=self.application)

            self._remote_hardware_manager = rhm
            rhm.bootstrap()
示例#3
0
    def start(self):
        # if self.managers:
        from pychron.envisage.initialization.initializer import Initializer

        dp = DevicePreferences()
        afh = self.application.preferences.get(
            'pychron.hardware.auto_find_handle')
        awh = self.application.preferences.get(
            'pychron.hardware.auto_write_handle')
        if afh is not None:
            dp.serial_preference.auto_find_handle = to_bool(afh)
            dp.serial_preference.auto_write_handle = to_bool(awh)

        ini = Initializer(device_prefs=dp)
        for m in self.managers:
            ini.add_initialization(m)

        # any loaded managers will be registered as services
        if not ini.run(application=self.application):
            self.application.exit()
            # self.application.starting
            return

        # create the hardware proxy server
        ehs = to_bool(
            self.application.preferences.get(
                'pychron.hardware.enable_hardware_server'))
        if ehs:
            # use_tx = to_bool(self.application.preferences.get('pychron.hardware.use_twisted', True))
            use_tx = True
            if use_tx:
                from pychron.tx.server import TxServer
                rhm = TxServer()
                node = self.application.preferences.node('pychron.hardware')
                ports = eval(node.get('ports'))
                factories = eval(node.get('factories'))
                for protocol in eval(node.get('pnames')):
                    factory = import_klass(factories[protocol])
                    port = int(ports[protocol])
                    rhm.add_endpoint(port, factory(self.application))
                    self.debug('Added Pychron Proxy Service: {}:{}'.format(
                        protocol, port))

            else:
                from pychron.remote_hardware.remote_hardware_manager import RemoteHardwareManager
                rhm = RemoteHardwareManager(application=self.application)

            self._remote_hardware_manager = rhm
            rhm.bootstrap()
示例#4
0
    def start(self):
        # if self.managers:
        from pychron.envisage.initialization.initializer import Initializer

        dp = DevicePreferences()
        afh = self.application.preferences.get('pychron.hardware.auto_find_handle')
        awh = self.application.preferences.get('pychron.hardware.auto_write_handle')
        if afh is not None:
            dp.serial_preference.auto_find_handle = to_bool(afh)
            dp.serial_preference.auto_write_handle = to_bool(awh)

        ini = Initializer(device_prefs=dp)
        for m in self.managers:
            ini.add_initialization(m)

        # any loaded managers will be registered as services
        if not ini.run(application=self.application):
            self.application.exit()
            # self.application.starting
            return

        # create the hardware proxy server
        ehs = to_bool(self.application.preferences.get('pychron.hardware.enable_hardware_server'))
        if ehs:
            # use_tx = to_bool(self.application.preferences.get('pychron.hardware.use_twisted', True))
            use_tx = True
            if use_tx:
                from pychron.tx.server import TxServer
                rhm = TxServer()
                node = self.application.preferences.node('pychron.hardware')
                ports = eval(node.get('ports'))
                factories = eval(node.get('factories'))
                for protocol in eval(node.get('pnames')):
                    factory = import_klass(factories[protocol])
                    port = int(ports[protocol])
                    rhm.add_endpoint(port, factory(self.application))
                    self.debug('Added Pychron Proxy Service: {}:{}'.format(protocol, port))

            else:
                from pychron.remote_hardware.remote_hardware_manager import RemoteHardwareManager
                rhm = RemoteHardwareManager(application=self.application)

            self._remote_hardware_manager = rhm
            rhm.bootstrap()
        return 'Diode Manager'

    def _control_module_manager_default(self):
        v = VueMetrixManager()  # control = self.control_module)
        return v


if __name__ == '__main__':
    from pychron.core.helpers.logger_setup import logging_setup
    from pychron.envisage.initialization.initializer import Initializer

    logging_setup('fusions diode')
    f = FusionsDiodeManager()
    f.use_video = True
    f.record_brightness = True
    ini = Initializer()

    a = dict(manager=f, name='FusionsDiode')
    ini.add_initialization(a)
    ini.run()
    #    f.bootstrap()
    f.configure_traits()

# ======================= EOF ============================
#    def finish_loading(self):
#        super(FusionsDiodeManager, self).finish_loading()
#
#        self.pyrometer.start_scan()
# #        self.control_module_manager.start_scan()
# def open_scanner(self):
#    from pychron.lasers.scanner import PIDScanner
示例#6
0
        return 'Diode Manager'

    def _control_module_manager_default(self):
        v = VueMetrixManager()  # control = self.control_module)
        return v


if __name__ == '__main__':
    from pychron.core.helpers.logger_setup import logging_setup
    from pychron.envisage.initialization.initializer import Initializer

    logging_setup('fusions diode')
    f = FusionsDiodeManager()
    f.use_video = True
    f.record_brightness = True
    ini = Initializer()

    a = dict(manager=f, name='FusionsDiode')
    ini.add_initialization(a)
    ini.run()
    #    f.bootstrap()
    f.configure_traits()

# ======================= EOF ============================
#    def finish_loading(self):
#        super(FusionsDiodeManager, self).finish_loading()
#
#        self.pyrometer.start_scan()
# #        self.control_module_manager.start_scan()
# def open_scanner(self):
#    from pychron.lasers.scanner import PIDScanner