def _read_config_file(self): """ Read the instrument configuration from self.config_source. :return: True if we read the file successfully, False if not """ try: self.configd = utils.parse_ini_file(self.config_source) except IOError: return False return True
def __init__(self, board_id, instrument_config, *args, **kwargs): """ Create a filter host :param board_id: :param instrument_config: :return: """ # Just in case... try: self.getLogger = kwargs['getLogger'] except KeyError: self.getLogger = getLogger # No idea logger_name = 'FpgaFilterHost_{}'.format(board_id) # Why is logging defaulted to INFO, what if I do not want to see the info logs? logLevel = kwargs.get('logLevel', INFO) result, self.logger = self.getLogger(logger_name=logger_name, log_level=logLevel, **kwargs) if not result: # Problem errmsg = 'Unable to create logger for {}'.format(self.descriptor) raise ValueError(errmsg) if isinstance(instrument_config, basestring): instrument_config = c2_utils.parse_ini_file(instrument_config) self._config = instrument_config['filter'] self.new_style = self._config['new_style'] == 'true' self._instrument_config = instrument_config _katcp_port = int(self._instrument_config['FxCorrelator']['katcp_port']) _bof = self._config['bitstream'] _hosts = self._config['hosts'].strip().split(',') super(FpgaFilterHost, self).__init__(_hosts[board_id], katcp_port=_katcp_port, bitstream=_bof, transport=SkarabTransport, connect=True) self.board_id = board_id self.data_sources = [] self.data_destinations = []
def __init__(self, host, katcp_port=7147, bitstream=None, connect=True, config=None, config_file=None, **kwargs): """ :param host: :param katcp_port: :param bitstream: :param connect: :param config: """ FpgaHost.__init__(self, host=host, katcp_port=katcp_port, **kwargs) if config is not None and config_file is not None: LOGGER.warn('config file and config supplied, defaulting to config') self.config = config or parse_ini_file(config_file)['dsimengine'] self.bitstream = bitstream self.sine_sources = AttributeContainer() self.noise_sources = AttributeContainer() self.pulsar_sources = AttributeContainer() self.outputs = AttributeContainer()
def __init__(self, board_id, instrument_config): """ Create a filter host :param board_id: :param instrument_config: :return: """ if isinstance(instrument_config, basestring): instrument_config = c2_utils.parse_ini_file(instrument_config) self._config = instrument_config['filter'] self.new_style = self._config['new_style'] == 'true' self._instrument_config = instrument_config _katcp_port = int(self._instrument_config['FxCorrelator']['katcp_port']) _bof = self._config['bitstream'] _hosts = self._config['hosts'].strip().split(',') super(FpgaFilterHost, self).__init__(_hosts[board_id], katcp_port=_katcp_port, boffile=_bof, connect=True) self.board_id = board_id self.data_sources = [] self.data_destinations = []