diff --git a/examples/path_requests_run.py b/examples/path_requests_run.py index 89ebeb02..e61ed3c8 100644 --- a/examples/path_requests_run.py +++ b/examples/path_requests_run.py @@ -59,11 +59,12 @@ def requests_from_json(json_data,equipment): params['destination'] = req['dst-tp-id'] params['trx_type'] = req['path-constraints']['te-bandwidth']['trx_type'] params['trx_mode'] = req['path-constraints']['te-bandwidth']['trx_mode'] + params['frequency'] = tsp_lib[params['trx_type']].frequency try: - extra_params = next(m + extra_params = next(m for m in tsp_lib[params['trx_type']].mode if m['format'] == params['trx_mode']) except StopIteration : - msg = f'could not find tsp : {params} with mode: {params} in eqpt library' + msg = f'could not find tsp : {params["trx_type"]} with mode: {params["trx_mode"]} in eqpt library' raise ValueError(msg) nd_list = req['optimizations']['explicit-route-include-objects'] params['nodes_list'] = [n['unnumbered-hop']['node-id'] for n in nd_list] @@ -87,50 +88,7 @@ def load_requests(filename,eqpt_filename): json_data = loads(f.read()) return json_data -# def compute_constrained_path(network, req): -# trx = [n for n in network.nodes() if isinstance(n, Transceiver)] -# roadm = [n for n in network.nodes() if isinstance(n, Roadm)] -# edfa = [n for n in network.nodes() if isinstance(n, Edfa)] - -# source = next(el for el in trx if el.uid == req.source) -# # start the path with its source -# total_path = [source] -# for n in req.nodes_list: -# # print(n) -# try : -# node = next(el for el in trx if el.uid == n) -# except StopIteration: -# try: -# node = next(el for el in roadm if el.uid == f'roadm {n}') -# except StopIteration: -# try: -# node = next(el for el in edfa -# if el.uid.startswith(f'egress edfa in {n}')) -# except StopIteration: -# msg = f'could not find node : {n} in network topology: \ -# not a trx, roadm, edfa or fused element' -# logger.critical(msg) -# raise ValueError(msg) -# # extend path list without repeating source -> skip first element in the list -# try: -# total_path.extend(dijkstra_path(network, source, node)[1:]) -# source = node -# except NetworkXNoPath: -# # for debug -# # print(req.loose_list) -# # print(req.nodes_list.index(n)) -# if req.loose_list[req.nodes_list.index(n)] == 'loose': -# print(f'could not find a path from {source.uid} to loose node : {n} in network topology') -# print(f'node {n} is skipped') -# else: -# msg = f'could not find a path from {source.uid} to node : {n} in network topology' -# logger.critical(msg) -# raise ValueError(msg) -# return total_path - def compute_path(network, pathreqlist): - # temporary : repeats calls from transmission_main_example - # to be merged when ready path_res_list = [] diff --git a/examples/transmission_main_example.py b/examples/transmission_main_example.py index c7355546..342bb3c7 100755 --- a/examples/transmission_main_example.py +++ b/examples/transmission_main_example.py @@ -141,9 +141,11 @@ if __name__ == '__main__': params['spacing'] = 50e9 params['power'] = 0 params['nb_channel'] = 97 + params['frequency'] = equipment['Transceiver'][params['trx_type']].frequency try: extra_params = next(m - for m in equipment['Transceiver'][params['trx_type']].mode if m['format'] == params['trx_mode']) + for m in equipment['Transceiver'][params['trx_type']].mode + if m['format'] == params['trx_mode']) except StopIteration : msg = f'could not find tsp : {params} with mode: {params} in eqpt library' raise ValueError(msg) diff --git a/gnpy/core/request.py b/gnpy/core/request.py index b045960c..756a04cd 100644 --- a/gnpy/core/request.py +++ b/gnpy/core/request.py @@ -36,24 +36,23 @@ from numpy import log10 RequestParams = namedtuple('RequestParams','request_id source destination trx_type'+ -' trx_mode nodes_list loose_list spacing power nb_channel format baudrate OSNR bit_rate') +' trx_mode nodes_list loose_list spacing power nb_channel frequency format baudrate OSNR bit_rate') class Path_request: def __init__(self, *args, **params): params = RequestParams(**params) self.request_id = params.request_id - self.source = params.source + self.source = params.source self.destination = params.destination self.tsp = params.trx_type self.tsp_mode = params.trx_mode - # retrieve baudrate out of transponder type and mode (format) - - self.baudrate = params.baudrate + self.baudrate = params.baudrate self.nodes_list = params.nodes_list self.loose_list = params.loose_list self.spacing = params.spacing self.power = params.power self.nb_channel = params.nb_channel + self.frequency = params.frequency self.format = params.format self.OSNR = params.OSNR self.bit_rate = params.bit_rate @@ -175,9 +174,8 @@ def compute_constrained_path(network, req): def propagate(path,req,equipment, show=False): default_si_data = equipment['SI']['default'] si = create_input_spectral_information( - default_si_data.f_min, default_si_data.roll_off, + req.frequency['min'], default_si_data.roll_off, req.baudrate, req.power, req.spacing, req.nb_channel) - # TODO : use tsp f_min instead of default for el in path: si = el(si) if show :