def get_stream_params(self, rate): if rate not in self._protocol.get_supported_sampling_rates(): raise ValueError('Invalid argument for sampling rate.') mode = self._get_rate_mode(rate) req = Hinawa.FwReq() return ExtCurrentConfigSpace.read_stream_config( self._protocol, req, mode)
def get_router_entries(self, rate): if rate not in self._protocol.get_supported_sampling_rates(): raise ValueError('Invalid argument for sampling rate.') mode = self._get_rate_mode(rate) entries = [] req = Hinawa.FwReq() routes = ExtCurrentConfigSpace.read_router_config( self._protocol, req, mode) for route in routes: for src in self._srcs: if route['src-blk'] == src[1] and route['src-ch'] in src[2]: break else: continue for dst in self._dsts: if route['dst-blk'] == dst[1] and route['dst-ch'] in dst[2]: break else: continue entry = { 'src': '{0}:{1}'.format(src[0], src[2].index(route['src-ch'])), 'dst': '{0}:{1}'.format(dst[0], dst[2].index(route['dst-ch'])), } entries.append(entry) return entries
def _get_available_stream_ports(self, protocol, req, mode): STREAMS = ('avs0', 'avs1') stream_configs = \ ExtCurrentConfigSpace.read_stream_config(protocol, req, mode) dsts = [] for i, params in enumerate(stream_configs['tx']): id = STREAMS[i] count = params['pcm'] if len(stream_configs['tx']) == 1: suffix = '' else: suffix = '-{0:c}'.format(0x41 + i) for j in range(0, count, 2): label = 'Stream{0}-{1}/{2}'.format(suffix, j + 1, j + 2) dst = [label, id, [j, j + 1]] dsts.append(dst) srcs = [] for i, params in enumerate(stream_configs['rx']): id = STREAMS[i] count = params['pcm'] if len(stream_configs['rx']) == 1: suffix = '' else: suffix = '-{0:c}'.format(0x41 + i) for j in range(0, count, 2): label = 'Stream{0}-{1}/{2}'.format(suffix, j + 1, j + 2) src = [label, id, [j, j + 1]] srcs.append(src) return srcs, dsts
def _cache_router_nodes(self): req = Hinawa.FwReq() rate = self._protocol.read_sampling_rate(req) mode = self._get_rate_mode(rate) entries = \ ExtCurrentConfigSpace.read_router_config(self._protocol, req, mode) srcs, dsts = self._spec.get_available_ports(self._protocol, req, mode) routes = self._spec.normalize_router_entries(self._protocol, entries, srcs, dsts) # MEMO: if registered entries are not generated by this module, update # them. Not friendly to the other programs while these entries are # valid for the programs. if entries != routes: ExtNewRouterSpace.set_entries(self._protocol, req, routes) ExtCmdSpace.initiate(self._protocol, req, 'load-from-router', mode) self._srcs = srcs self._dsts = dsts self._routes = routes