Example #1
0
    def _handle_sources(self):
        """
        Sort out sources and eqs for them
        :return:
        """
        assert len(self.fhosts) > 0
        _feng_cfg = self.configd['fengine']
        source_names = utils.sources_from_config(config=self.configd)
        source_mcast = _feng_cfg['source_mcast_ips'].strip().split(',')
        assert len(source_mcast) == len(source_names), (
            'Source names (%d) must be paired with multicast source '
            'addresses (%d)' % (len(source_names), len(source_mcast)))

        # match eq polys to source names
        eq_polys = {}
        for src_name in source_names:
            eq_polys[src_name] = utils.process_new_eq(
                _feng_cfg['eq_poly_%s' % src_name])

        # assemble the sources given into a list
        _feng_src_temp = []
        for source_ctr, address in enumerate(source_mcast):
            new_source = FengineSource.from_mcast_string(address)
            new_source.name = source_names[source_ctr]
            new_source.source_number = source_ctr
            new_source.offset = source_ctr % self.f_per_fpga
            new_source.eq_poly = eq_polys[new_source.name]
            new_source.eq_bram_name = 'eq%i' % new_source.offset
            assert new_source.ip_range == self.ports_per_fengine, (
                'F-engines should be receiving from %d streams.' %
                self.ports_per_fengine)
            _feng_src_temp.append(new_source)

        # check that the sources all have the same IP ranges
        for _source in _feng_src_temp:
            assert _source.ip_range == _feng_src_temp[0].ip_range, (
                'All f-engines should be receiving from %d streams.' %
                self.ports_per_fengine)

        # assign sources to fhosts
        self.logger.info('Assigning FengineSources to f-hosts')
        _src_ctr = 0
        self.fengine_sources = {}
        for fhost in self.fhosts:
            self.logger.info('\t%s:' % fhost.host)
            for fengnum in range(0, self.f_per_fpga):
                _src = _feng_src_temp[_src_ctr]
                _src.host = fhost
                self.fengine_sources[_src.name] = _src
                fhost.add_source(_src)
                self.logger.info('\t\t%s' % _src)
                _src_ctr += 1
        if _src_ctr != len(self.fhosts) * self.f_per_fpga:
            raise RuntimeError('We have different numbers of sources (%d) and '
                               'f-engines (%d). Problem.', _src_ctr,
                               len(self.fhosts) * self.f_per_fpga)
        self.logger.info('done.')
Example #2
0
    def _handle_sources(self):
        """
        Sort out sources and eqs for them
        :return:
        """
        assert len(self.fhosts) > 0
        _feng_cfg = self.configd['fengine']
        source_names = _feng_cfg['source_names'].strip().split(',')
        source_mcast = _feng_cfg['source_mcast_ips'].strip().split(',')
        assert len(source_mcast) == len(source_names), (
            'Source names (%d) must be paired with multicast source '
            'addresses (%d)' % (len(source_names), len(source_mcast)))

        # match eq polys to source names
        eq_polys = {}
        for src_name in source_names:
            eq_polys[src_name] = utils.process_new_eq(
                _feng_cfg['eq_poly_%s' % src_name])

        # assemble the sources given into a list
        _fengine_sources = []
        for source_ctr, address in enumerate(source_mcast):
            new_source = DataSource.from_mcast_string(address)
            new_source.name = source_names[source_ctr]
            assert new_source.ip_range == self.ports_per_fengine, (
                'F-engines should be receiving from %d streams.' %
                self.ports_per_fengine)
            _fengine_sources.append(new_source)

        # assign sources and eqs to fhosts
        self.logger.info('Assigning DataSources, EQs and DelayTrackers to '
                         'f-engines...')
        source_ctr = 0
        self.fengine_sources = []
        for fhost in self.fhosts:
            self.logger.info('\t%s:' % fhost.host)
            _eq_dict = {}
            for fengnum in range(0, self.f_per_fpga):
                _source = _fengine_sources[source_ctr]
                _eq_dict[_source.name] = {'eq': eq_polys[_source.name],
                                          'bram_num': fengnum}
                assert _source.ip_range == _fengine_sources[0].ip_range, (
                    'All f-engines should be receiving from %d streams.' %
                    self.ports_per_fengine)
                self.fengine_sources.append({'source': _source,
                                             'source_num': source_ctr,
                                             'host': fhost,
                                             'numonhost': fengnum})
                fhost.add_source(_source)
                self.logger.info('\t\t%s' % _source)
                source_ctr += 1
            fhost.eqs = _eq_dict
        if source_ctr != len(self.fhosts) * self.f_per_fpga:
            raise RuntimeError('We have different numbers of sources (%d) and '
                               'f-engines (%d). Problem.', source_ctr,
                               len(self.fhosts) * self.f_per_fpga)
        self.logger.info('done.')
Example #3
0
 def eq_set(self, write=True, source_name=None, new_eq=None):
     """
     Set the EQ for a specific source
     :param write: should the value be written to BRAM on the device?
     :param source_name: the source name
     :param new_eq: an eq list or value or poly
     :return:
     """
     if new_eq is None:
         raise ValueError('New EQ of nothing makes no sense.')
     # if no source is given, apply the new eq to all sources
     if source_name is None:
         self.logger.info('Setting EQ on all sources to new given EQ.')
         for fhost in self.hosts:
             for src in fhost.data_sources:
                 self.eq_set(write=False, source_name=src.name,
                             new_eq=new_eq)
         if write:
             self.eq_write_all()
     else:
         src = self.corr.fengine_sources[source_name]
         old_eq = src.eq_poly[:]
         try:
             neweq = utils.process_new_eq(new_eq)
             src.eq_poly = neweq
             self.logger.info(
                 'Updated EQ value for source %s: %s...' % (
                     source_name, neweq[0:min(10, len(neweq))]))
             if write:
                 src.host.write_eq(source_name=source_name)
         except Exception as e:
             src.eq_poly = old_eq[:]
             self.logger.error('New EQ error - REVERTED to '
                               'old value! - %s' % e.message)
             raise ValueError('New EQ error - REVERTED to '
                              'old value! - %s' % e.message)
     self.corr.speadops.update_metadata(0x1400)