Ejemplo n.º 1
0
 def configure(self, config):
     self._factory = config['factory']
     configuration = {'name': config['name'], 'parent': config['parent']}
     if config.has_key('attributes'):
         for attribute in config['attributes']:
             configuration[attribute['name']] = attribute['definition']
     self._node = _factory(self._factory)
     self._node.configure(configuration)
Ejemplo n.º 2
0
 def configure(self,config):
     self._factory = config['factory']
     configuration = {'name':config['name'],'parent':config['parent']}
     if config.has_key('attributes'):
         for attribute in config['attributes']:
             configuration[attribute['name']] = attribute['definition']
     self._node = _factory(self._factory)
     self._node.configure(configuration)
Ejemplo n.º 3
0
    def configure(self, dict):
        #print 'Start Host configure'
        CompositeNode.configure(self, dict)
        set_attribute(self, 'ncounters', 0, dict, int)
        set_attribute(self, 'nAIs', 0, dict, int)
        set_attribute(self, 'nAOs', 0, dict, int)
        set_attribute(self, 'nDIs', 0, dict, int)
        set_attribute(self, 'nrelays', 0, dict, int)
        set_attribute(self, 'ndallas_busses', 0, dict, int)
        set_attribute(self, 'nGPIOs', 0, dict, int)
        set_attribute(self, 'has_coprocessor',
                      self.ncounters or self.nDIs or
                      self.nrelays or self.ndallas_busses or self.nGPIOs or
                      self.nAIs or self.nAOs,
                      dict, int)
        # Attach the coprocessor and configure it.
        if self.has_coprocessor and not self.coprocessor:
            config = {}
            config['name'] = 'coprocessor'
            config['parent'] = self
            config['ncounters'] = self.ncounters
            config['nAIs'] = self.nAIs
            config['nAOs'] = self.nAOs
            config['nDIs'] = self.nDIs
            config['nrelays'] = self.nrelays
            config['ndallas_busses'] = self.ndallas_busses
            config['nGPIOs'] = self.nGPIOs
            self.coprocessor = _factory(self._coprocessor_factory_path)
            self.coprocessor.configure(config)

            # Move the coprocessor's IONs directly to the host.
            for node in self.coprocessor.children_nodes():
                node.parent = self
                self._add_child(node)

            # "Hide" the coprocessor ion.
            del self._children[self.coprocessor.name]
            #print 'coprocessor configure done'

        if self.port_map is None:
            print ' Attach and configure the serial ports.'

            # Attach and configure the serial ports.
            set_attribute(self, 'port_map', None, dict)
            if self.port_map:
                for name, dev in self.port_map.items():
                    port = _factory(self._port_factory_path)
                    config = {}
                    config['dev'] = dev
                    config['name'] = name
                    config['parent'] = self
                    port.configure(config)
                    del port
        if self.modem_map is None:
            # Attach and configure the serial modems.
            set_attribute(self, 'modem_map', None, dict)
            if self.modem_map:
                for name, dev in self.modem_map.items():
                    modem = _factory(self._internal_modem_factory_path)
                    config = {}
                    config['dev'] = dev
                    config['name'] = name
                    config['parent'] = self
                    modem.configure(config)
                    del modem
        if not self.eth_map:
           # Attach and configure the ethernet ports.
           set_attribute(self, 'eth_map', None, dict)
           if self.eth_map:
               for name, dev in self.eth_map.items():
                   eth = _factory(self._eth_factory_path)
                   config = {}
                   config['dev'] = dev
                   config['name'] = name
                   config['parent'] = self
                   eth.configure(config)
                   del eth
Ejemplo n.º 4
0
    def configure(self, dict):
        #print 'Start Host configure'
        CompositeNode.configure(self, dict)
        set_attribute(self, 'ncounters', 0, dict, int)
        set_attribute(self, 'nAIs', 0, dict, int)
        set_attribute(self, 'nAOs', 0, dict, int)
        set_attribute(self, 'nDIs', 0, dict, int)
        set_attribute(self, 'nrelays', 0, dict, int)
        set_attribute(self, 'ndallas_busses', 0, dict, int)
        set_attribute(self, 'nGPIOs', 0, dict, int)
        set_attribute(
            self, 'has_coprocessor', self.ncounters or self.nDIs
            or self.nrelays or self.ndallas_busses or self.nGPIOs or self.nAIs
            or self.nAOs, dict, int)
        # Attach the coprocessor and configure it.
        if self.has_coprocessor and not self.coprocessor:
            config = {}
            config['name'] = 'coprocessor'
            config['parent'] = self
            config['ncounters'] = self.ncounters
            config['nAIs'] = self.nAIs
            config['nAOs'] = self.nAOs
            config['nDIs'] = self.nDIs
            config['nrelays'] = self.nrelays
            config['ndallas_busses'] = self.ndallas_busses
            config['nGPIOs'] = self.nGPIOs
            self.coprocessor = _factory(self._coprocessor_factory_path)
            self.coprocessor.configure(config)

            # Move the coprocessor's IONs directly to the host.
            for node in self.coprocessor.children_nodes():
                node.parent = self
                self._add_child(node)

            # "Hide" the coprocessor ion.
            del self._children[self.coprocessor.name]
            #print 'coprocessor configure done'

        if self.port_map is None:
            print ' Attach and configure the serial ports.'

            # Attach and configure the serial ports.
            set_attribute(self, 'port_map', None, dict)
            if self.port_map:
                for name, dev in self.port_map.items():
                    port = _factory(self._port_factory_path)
                    config = {}
                    config['dev'] = dev
                    config['name'] = name
                    config['parent'] = self
                    port.configure(config)
                    del port
        if self.modem_map is None:
            # Attach and configure the serial modems.
            set_attribute(self, 'modem_map', None, dict)
            if self.modem_map:
                for name, dev in self.modem_map.items():
                    modem = _factory(self._internal_modem_factory_path)
                    config = {}
                    config['dev'] = dev
                    config['name'] = name
                    config['parent'] = self
                    modem.configure(config)
                    del modem
        if not self.eth_map:
            # Attach and configure the ethernet ports.
            set_attribute(self, 'eth_map', None, dict)
            if self.eth_map:
                for name, dev in self.eth_map.items():
                    eth = _factory(self._eth_factory_path)
                    config = {}
                    config['dev'] = dev
                    config['name'] = name
                    config['parent'] = self
                    eth.configure(config)
                    del eth