def _start_port_agent(self, instrument_agent_instance_obj=None):
        """
        Construct and start the port agent, ONLY NEEDED FOR INSTRUMENT AGENTS.
        """

        _port_agent_config = instrument_agent_instance_obj.port_agent_config

        # It blocks until the port agent starts up or a timeout
        _pagent = PortAgentProcess.launch_process(_port_agent_config,  test_mode = True)
        pid = _pagent.get_pid()
        port = _pagent.get_data_port()
        cmd_port = _pagent.get_command_port()
        log.info("IMS:_start_pagent returned from PortAgentProcess.launch_process pid: %s ", pid)

        # Hack to get ready for DEMO.  Further though needs to be put int
        # how we pass this config info around.
        host = 'localhost'

        driver_config = instrument_agent_instance_obj.driver_config
        comms_config = driver_config.get('comms_config')
        if comms_config:
            host = comms_config.get('addr')
        else:
            log.warn("No comms_config specified, using '%s'" % host)

        # Configure driver to use port agent port number.
        instrument_agent_instance_obj.driver_config['comms_config'] = {
            'addr' : host,
            'cmd_port' : cmd_port,
            'port' : port
        }
        instrument_agent_instance_obj.driver_config['pagent_pid'] = pid
        self.imsclient.update_instrument_agent_instance(instrument_agent_instance_obj)
        return self.imsclient.read_instrument_agent_instance(instrument_agent_instance_obj._id)
Exemplo n.º 2
0
    def start_pagent(self):
        """
        Construct and start the port agent.
        @retval port Port that was used for connection to agent
        """
        # Create port agent object.
        comm_config = self.comm_config

        config = {
            'device_addr' : comm_config.device_addr,
            'device_port' : comm_config.device_port,

            'command_port': comm_config.command_port,
            'data_port': comm_config.data_port,

            'process_type': PortAgentProcessType.UNIX,
            'log_level': 5,
        }

        self._pagent = PortAgentProcess.launch_process(config, timeout = 60, test_mode = True)
        pid = self._pagent.get_pid()
        port = self._pagent.get_data_port()

        log.info('Started port agent pid %d listening at port %d', pid, port)

        # Configure driver to use port agent port number.
        DVR_CONFIG['comms_config'] = {
            'addr' : 'localhost',
            'port' : port
        }

        return port
Exemplo n.º 3
0
    def start_pagent(self):
        """
        Construct and start the port agent.
        @retval port Port that was used for connection to agent
        """
        # Create port agent object.
        comm_config = self.comm_config

        config = {
            'device_addr': comm_config.device_addr,
            'device_port': comm_config.device_port,
            'command_port': comm_config.command_port,
            'data_port': comm_config.data_port,
            'process_type': PortAgentProcessType.UNIX,
            'log_level': 5,
        }

        self._pagent = PortAgentProcess.launch_process(config,
                                                       timeout=60,
                                                       test_mode=True)
        pid = self._pagent.get_pid()
        port = self._pagent.get_data_port()
        cmd_port = self._pagent.get_command_port()

        log.info('Started port agent pid %d listening at port %d', pid, port)

        # Configure driver to use port agent port number.
        DVR_CONFIG['comms_config'] = {
            'addr': 'localhost',
            'port': port,
            'cmd_port': cmd_port
        }

        return port
Exemplo n.º 4
0
    def init_port_agent(cls):
        """
        @brief Launch the driver process and driver client.  This is used in the
        integration and qualification tests.  The port agent abstracts the physical
        interface with the instrument.
        @retval return the pid to the logger process
        """
        log.info("Startup Port Agent")

        comm_config = cls.get_comm_config()

        config = {
            'device_addr' : comm_config.device_addr,
            'device_port' : comm_config.device_port
        }

        port_agent = PortAgentProcess.launch_process(config, timeout = 60,
            test_mode = True)

        port = port_agent.get_data_port()
        pid  = port_agent.get_pid()

        log.info('Started port agent pid %s listening at port %s' % (pid, port))

        cls.test_config.port_agent = port_agent
        return port
Exemplo n.º 5
0
    def start_pagent(self):
        """
        Construct and start the port agent.
        @retval port Port that was used for connection to agent
        """
        # Create port agent object.
        config = {
            'device_addr': self.device_addr,
            'device_port': self.device_port,
            'command_port': self.command_port,
            'data_port': self.data_port,
            'process_type': PortAgentProcessType.UNIX,
            'log_level': 5,
        }

        self._pagent = PortAgentProcess.launch_process(config,
                                                       timeout=60,
                                                       test_mode=True)
        pid = self._pagent.get_pid()
        port = self._pagent.get_data_port()

        if (pid and port):
            mi_logger.info('Started port agent pid %d listening at port %d',
                           pid, port)
        else:
            raise PortAgentLaunchException()

        return port
    def init_port_agent(self):
        """
        @brief Launch the driver process and driver client.  This is used in the
        integration and qualification tests.  The port agent abstracts the physical
        interface with the instrument.
        @retval return the pid to the logger process
        """
        if (self.port_agent):
            log.error("Port agent already initialized")
            return

        log.debug("Startup Port Agent")

        #comm_config = self.get_comm_config()

        config = self.port_agent_config()
        log.debug("port agent config: %s" % config)

        port_agent = PortAgentProcess.launch_process(config, timeout = 60, test_mode = True)

        port = port_agent.get_data_port()
        pid  = port_agent.get_pid()

        log.info('Started port agent pid %s listening at port %s' % (pid, port))

        self.addCleanup(self.stop_port_agent)
        self.port_agent = port_agent
        return port
    def init_port_agent(self):
        """
        @brief Launch the driver process and driver client.  This is used in the
        integration and qualification tests.  The port agent abstracts the physical
        interface with the instrument.
        @retval return the pid to the logger process
        """
        if (self.port_agent):
            log.error("Port agent already initialized")
            return

        log.debug("Startup Port Agent")

        #comm_config = self.get_comm_config()

        config = self.port_agent_config()
        log.debug("port agent config: %s" % config)

        port_agent = PortAgentProcess.launch_process(config,
                                                     timeout=60,
                                                     test_mode=True)

        port = port_agent.get_data_port()
        pid = port_agent.get_pid()

        log.info('Started port agent pid %s listening at port %s' %
                 (pid, port))

        self.addCleanup(self.stop_port_agent)
        self.port_agent = port_agent
        return port
Exemplo n.º 8
0
    def init_port_agent(self):
        """
        @brief Launch the driver process and driver client.  This is used in the
        integration and qualification tests.  The port agent abstracts the physical
        interface with the instrument.
        @retval return the pid to the logger process
        """
        log.info("Startup Port Agent")

        config = {
            'device_addr' : self.comm_config.device_addr,
            'device_port' : self.comm_config.device_port,

            'command_port': self.comm_config.command_port,
            'data_port': self.comm_config.data_port,

            'process_type': PortAgentProcessType.UNIX,
            'log_level': 5,
        }

        self.port_agent = PortAgentProcess.launch_process(config, timeout = 60,
            test_mode = True)

        port = self.port_agent.get_data_port()
        pid  = self.port_agent.get_pid()

        log.info('Started port agent pid %s listening at port %s' % (pid, port))

        if self.launch_monitor:
            self.logfile = self.port_agent.port_agent.logfname
            log.info('Started port agent pid %s listening at port %s' % (pid, port))
            log.info("data log: %s" % self.logfile)
            self.monitor_process = launch_data_monitor(self.logfile)
Exemplo n.º 9
0
    def start_pagent(self):
        """
        Construct and start the port agent.
        @retval port Port that was used for connection to agent
        """
        # Create port agent object.
        config = { 'device_addr' : self.device_addr,
                   'device_port' : self.device_port,

                   'command_port': self.command_port,
                   'data_port': self.data_port,

                   'process_type': PortAgentProcessType.UNIX,
                   'log_level': 5,
                  }

        self._pagent = PortAgentProcess.launch_process(config, timeout = 60, test_mode = True)
        pid = self._pagent.get_pid()
        port = self._pagent.get_data_port()

        if(pid and port):
            mi_logger.info('Started port agent pid %d listening at port %d', pid, port)
        else:
            raise PortAgentLaunchException();
            
        return port
Exemplo n.º 10
0
    def test_driver_launch(self):
        """
        Test the alternate method for launching a port agent
        """
        process = PortAgentProcess.launch_process(self._port_config, test_mode=True)

        # Check that it launched properly
        self.assertTrue(process.get_pid() > 0)
        self.assertTrue(process.get_data_port())
        # Python logger has no command port
        self.assertEqual(process.get_command_port(), None)

        process.stop()
        self.assertFalse(process.get_pid())
Exemplo n.º 11
0
    def test_driver_launch(self):
        """
        Test the alternate method for launching a port agent
        """
        process = PortAgentProcess.launch_process(self._port_config,
                                                  test_mode=True)

        # Check that it launched properly
        self.assertTrue(process.get_pid() > 0)
        self.assertTrue(process.get_data_port())
        # Python logger has no command port
        self.assertEqual(process.get_command_port(), None)

        process.stop()
        self.assertFalse(process.get_pid())
    def start_pagent(self):
        """
        Construct and start the port agent.
        @retval port Port that was used for connection to agent
        """
        # Create port agent object.
        config = {
            "device_addr": self.device_addr,
            "device_port": self.device_port,
            "working_dir": self.work_dir,
            "delimiter": self.delim,
        }
        self._pagent = PortAgentProcess.launch_process(config, timeout=60, test_mode=True)
        pid = self._pagent.get_pid()
        port = self._pagent.get_data_port()

        mi_logger.info("Started port agent pid %d listening at port %d", pid, port)
        return port
Exemplo n.º 13
0
    def _start_port_agent(self, instrument_agent_instance_obj=None):
        """
        Construct and start the port agent, ONLY NEEDED FOR INSTRUMENT AGENTS.
        """

        _port_agent_config = instrument_agent_instance_obj.port_agent_config

        # It blocks until the port agent starts up or a timeout
        _pagent = PortAgentProcess.launch_process(_port_agent_config,
                                                  test_mode=True)
        pid = _pagent.get_pid()
        port = _pagent.get_data_port()
        cmd_port = _pagent.get_command_port()
        log.info(
            "IMS:_start_pagent returned from PortAgentProcess.launch_process pid: %s ",
            pid)

        # Hack to get ready for DEMO.  Further though needs to be put int
        # how we pass this config info around.
        host = 'localhost'

        driver_config = instrument_agent_instance_obj.driver_config
        comms_config = driver_config.get('comms_config')
        if comms_config:
            host = comms_config.get('addr')
        else:
            log.warn("No comms_config specified, using '%s'" % host)

        # Configure driver to use port agent port number.
        instrument_agent_instance_obj.driver_config['comms_config'] = {
            'addr': host,
            'cmd_port': cmd_port,
            'port': port
        }
        instrument_agent_instance_obj.driver_config['pagent_pid'] = pid
        self.imsclient.update_instrument_agent_instance(
            instrument_agent_instance_obj)
        return self.imsclient.read_instrument_agent_instance(
            instrument_agent_instance_obj._id)