From c59456d5a7cce5c3f6f1ac9682d702c8b35b496d Mon Sep 17 00:00:00 2001 From: "guillaume.lambert" Date: Mon, 20 Feb 2023 13:27:46 +0100 Subject: [PATCH] Leverage Map Ref in PCE PostAlgoPathValidator CatalogUtils compute many signal parameters stored with double values. They are passed to many methods arguments and modified in many places in PCE PostAlgoPathValidator. Leveraging Map references to group these double values would help to simplify the code by avoiding long list of such parameters and allowing their values to be modified directly inside intermediate functions. TODO: Ideally, this work should be generalized to the whole CatalogUtils class. Also as Double is immutable, it prevents from updating directly Map values here. Apache proposes a MutableDouble alternative. Of course, there is still the possibility to use double[] arrays. But w/o key names to describe, the code reading will be harder. JIRA: TRNSPRTPCE-725 Change-Id: Iff3cf98d82cb53dc3cc89714b92a2e3bf77157fb Signed-off-by: guillaume.lambert --- .../pce/graph/PostAlgoPathValidator.java | 342 ++++++++---------- 1 file changed, 151 insertions(+), 191 deletions(-) diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java b/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java index fe7dd48a9..04bfa905b 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java @@ -401,15 +401,17 @@ public class PostAlgoPathValidator { */ private double checkOSNRaz(GraphPath path, Map allPceNodes, Map allPceLinks, String serviceType, CatalogUtils cu) { - double spacing = 50.0; - double calcPdl2 = 0; - double calcOsnrdB = 0; - double calcCd = 0; - double calcPmd2 = 0; - double calcOnsrLin = 0.0001; + Map signal = new HashMap<>( + Map.of( + "spacing", Double.valueOf(50.0), + "calcPdl2", Double.valueOf(0), + "calcCd", Double.valueOf(0), + "calcPmd2", Double.valueOf(0), + "calcOnsrLin", Double.valueOf(0.0001), + "pwrIn", Double.valueOf(-60.0), + "pwrOut", Double.valueOf(-60.0))); + double calcOnsrdB = 0; double margin = 0; - double pwrIn = -60.0; - double pwrOut = -60.0; boolean transponderPresent = false; List vertices = path.getVertexList(); List edges = path.getEdgeList(); @@ -427,14 +429,12 @@ public class PostAlgoPathValidator { case XPONDER: LOG.debug("loop of check OSNR direction AZ: XPDR, Path Element = {}", pathElement); transponderPresent = true; - Map results = calcXpdrOSNR(cu, + calcXpdrOSNR(cu, signal, pathElement == 0 // First transponder on the Path (TX side) / Last Xponder of the path (RX side) ? edges.get(pathElement).link().getSourceTP().getValue() : edges.get(pathElement - 1).link().getDestTP().getValue(), serviceType, currentNode, nextNode, vertices.get(pathElement), pathElement); - calcOnsrLin = results.get("calcOnsrLin"); - spacing = results.get("spacing"); break; case SRG: LOG.debug("loop of check OSNR direction AZ: SRG, Path Element = {}", pathElement); @@ -444,18 +444,12 @@ public class PostAlgoPathValidator { LOG.error("Error processing Node {} for which output link {} is not an ADDLINK Type", currentNode.getNodeId(), pathElement); } - pwrIn = 0.0; - Map impairments = calcAddContrib( - cu, currentNode, edges.get(pathElement + 1).link(), - calcCd, calcPmd2, calcPdl2, calcOnsrLin, spacing); - calcCd = impairments.get("calcCd"); - calcPmd2 = impairments.get("calcPmd2"); - calcPdl2 = impairments.get("calcPdl2"); - calcOnsrLin = impairments.get("calcOnsrLin"); - pwrOut = impairments.get("pwrOut"); + signal.put("pwrIn", Double.valueOf(0)); + calcAddContrib(cu, signal, currentNode, edges.get(pathElement + 1).link()); LOG.debug("loop of check OSNR direction AZ: SRG, pathElement = {} link {} Pout = {}", - pathElement, pathElement + 1, pwrOut); - if (calcOnsrLin == Double.NEGATIVE_INFINITY || calcOnsrLin == Double.POSITIVE_INFINITY) { + pathElement, pathElement + 1, signal.get("pwrOut")); + double calcOnsr = signal.get("calcOnsrLin").doubleValue(); + if (calcOnsr == Double.NEGATIVE_INFINITY || calcOnsr == Double.POSITIVE_INFINITY) { return -1.0; } // For the ADD, degradation brought by the node are calculated from the MW-WR spec. @@ -484,14 +478,9 @@ public class PostAlgoPathValidator { PceLink pceLink = edges.get(pathElement - 2).link(); LOG.info("loop of check OSNR : SRG, pathElement = {} CD on preceeding link {} = {} ps", pathElement, pathElement - 2, pceLink.getcd()); - Map impairments = calcDropContrib( - cu, currentNode, pceLink, pwrOut, calcCd, calcPmd2, calcPdl2, calcOnsrLin, spacing); - calcCd = impairments.get("calcCd"); - calcPmd2 = impairments.get("calcPmd2"); - calcPdl2 = impairments.get("calcPdl2"); - calcOnsrLin = impairments.get("calcOnsrLin"); - pwrIn = impairments.get("pwrIn"); - if (calcOnsrLin == Double.NEGATIVE_INFINITY || calcOnsrLin == Double.POSITIVE_INFINITY) { + calcDropContrib(cu, signal, currentNode, pceLink); + double calcOnsr = signal.get("calcOnsrLin").doubleValue(); + if (calcOnsr == Double.NEGATIVE_INFINITY || calcOnsr == Double.POSITIVE_INFINITY) { return -1.0; } // If SRG is not the first or the second element of the Path, it is the DROP @@ -500,9 +489,9 @@ public class PostAlgoPathValidator { // resulting OSNR in dB to pass it to the method that verifies end Xponder // performances are compatible with degradations experienced on the path try { - calcOsnrdB = getOsnrDbfromOnsrLin(calcOnsrLin); - LOG.info("checkOSNR loop, last SRG osnr is {} dB", calcOsnrdB); - LOG.info("Loop pathElement = {}, DROP, calcOsnrdB= {}", pathElement, calcOsnrdB); + calcOnsrdB = getOsnrDbfromOnsrLin(calcOnsr); + LOG.info("checkOSNR loop, last SRG osnr is {} dB", calcOnsrdB); + LOG.info("Loop pathElement = {}, DROP, calcOnsrdB= {}", pathElement, calcOnsrdB); } catch (ArithmeticException e) { LOG.debug("In checkOSNR: OSNR is equal to 0 and the number of links is: {}", path.getEdgeList().size()); @@ -515,19 +504,11 @@ public class PostAlgoPathValidator { break; } LOG.info("loop of check OSNR direction AZ: DEGREE, Path Element = {}", pathElement); - Map impairments0 = calcBypassContrib( - cu, currentNode, nextNode, - edges.get(pathElement - 1).link(), edges.get(pathElement + 1).link(), - pwrOut, calcCd, calcPmd2, calcPdl2, calcOnsrLin, spacing); - calcCd = impairments0.get("CD").doubleValue(); - calcPmd2 = impairments0.get("DGD2").doubleValue(); - calcPdl2 = impairments0.get("PDL2").doubleValue(); - calcOnsrLin = impairments0.get("ONSRLIN").doubleValue(); - //TODO rename impariments0 var and/or adapt catalog utils - pwrIn = impairments0.get("pwrIn").doubleValue(); - pwrOut = impairments0.get("pwrOut").doubleValue(); + calcBypassContrib(cu, signal, currentNode, nextNode, + edges.get(pathElement - 1).link(), edges.get(pathElement + 1).link()); + double calcOnsrLin = signal.get("calcOnsrLin").doubleValue(); LOG.debug( - "Loop pathElement= {}, DEGREE, calcOsnrdB= {}", pathElement, getOsnrDbfromOnsrLin(calcOnsrLin)); + "Loop pathElement= {}, DEGREE, calcOnsrdB= {}", pathElement, getOsnrDbfromOnsrLin(calcOnsrLin)); if (calcOnsrLin == Double.NEGATIVE_INFINITY || calcOnsrLin == Double.POSITIVE_INFINITY) { return -1.0; } @@ -535,8 +516,9 @@ public class PostAlgoPathValidator { // next node pathElement++; LOG.info("Accumulated degradations in the path including ROADM {} + {} are CD: {}; PMD2: " - + "{}; Pdl2 : {}; ONSRdB : {}", currentNode.getNodeId(), - nextNode.getNodeId(), calcCd, calcPmd2, calcPdl2, getOsnrDbfromOnsrLin(calcOnsrLin)); + + "{}; Pdl2 : {}; ONSRdB : {}", currentNode.getNodeId(), nextNode.getNodeId(), + signal.get("calcCd"), signal.get("calcPmd2"), signal.get("calcPdl2"), + getOsnrDbfromOnsrLin(calcOnsrLin)); break; case XPONDER: LOG.debug("loop of check OSNR direction AZ: XPDR, Path Element = {}", pathElement); @@ -553,9 +535,8 @@ public class PostAlgoPathValidator { LOG.debug("loop of check OSNR direction AZ: XPDR, Path Element = {}", vertices.size() - 1); transponderPresent = true; // TSP is the last of the path - margin = getLastXpdrMargin(cu, edges.get(vertices.size() - 2).link().getDestTP().getValue(), - serviceType, currentNode, vertices.get(vertices.size() - 1), vertices.size() - 1, - calcCd, calcPmd2, calcPdl2, calcOnsrLin); + margin = getLastXpdrMargin(cu, signal, edges.get(vertices.size() - 2).link().getDestTP().getValue(), + serviceType, currentNode, vertices.get(vertices.size() - 1), vertices.size() - 1); break; case SRG: LOG.debug("loop of check OSNR direction AZ: SRG, Path Element = {}", vertices.size() - 1); @@ -567,14 +548,10 @@ public class PostAlgoPathValidator { PceLink pceLink = edges.get(vertices.size() - 3).link(); LOG.info("loop of check OSNR : SRG, pathElement = {} CD on preceeding link {} = {} ps", vertices.size() - 1, vertices.size() - 3, pceLink.getcd()); - Map impairments = calcDropContrib( - cu, currentNode, pceLink, pwrOut, calcCd, calcPmd2, calcPdl2, calcOnsrLin, spacing); - calcCd = impairments.get("calcCd"); - calcPmd2 = impairments.get("calcPmd2"); - calcPdl2 = impairments.get("calcPdl2"); - calcOnsrLin = impairments.get("calcOnsrLin"); + calcDropContrib(cu, signal, currentNode, pceLink); + double calcOnsr = signal.get("calcOnsrLin").doubleValue(); //commented out to avoid spotbug DLS_DEAD_LOCAL_STORE pwrIn = impairments.get("pwrIn"); - if (calcOnsrLin == Double.NEGATIVE_INFINITY || calcOnsrLin == Double.POSITIVE_INFINITY) { + if (calcOnsr == Double.NEGATIVE_INFINITY || calcOnsr == Double.POSITIVE_INFINITY) { return -1.0; } // If SRG is not the first or the second element of the Path, it is the DROP @@ -583,9 +560,9 @@ public class PostAlgoPathValidator { // resulting OSNR in dB to pass it to the method that verifies end Xponder // performances are compatible with degradations experienced on the path try { - calcOsnrdB = getOsnrDbfromOnsrLin(calcOnsrLin); - LOG.info("checkOSNR loop, last SRG osnr is {} dB", calcOsnrdB); - LOG.info("Loop pathElement = {}, DROP, calcOsnrdB= {}", vertices.size() - 1, calcOsnrdB); + calcOnsrdB = getOsnrDbfromOnsrLin(calcOnsr); + LOG.info("checkOSNR loop, last SRG osnr is {} dB", calcOnsrdB); + LOG.info("Loop pathElement = {}, DROP, calcOnsrdB= {}", vertices.size() - 1, calcOnsrdB); } catch (ArithmeticException e) { LOG.debug("In checkOSNR: OSNR is equal to 0 and the number of links is: {}", path.getEdgeList().size()); @@ -596,9 +573,11 @@ public class PostAlgoPathValidator { default: LOG.error("PostAlgoPathValidator.CheckOSNR : unsupported resource type in the path chain last element"); } - LOG.info("- In checkOSNR: accumulated CD = {} ps, PMD = {} ps, PDL = {} dB, and resulting OSNR calcOsnrdB = {} " + LOG.info("- In checkOSNR: accumulated CD = {} ps, PMD = {} ps, PDL = {} dB, and resulting OSNR calcOnsrdB = {} " + "dB and ONSR dB exterapolated from calcosnrlin = {} including non linear contributions", - calcCd, Math.sqrt(calcPmd2), Math.sqrt(calcPdl2), calcOsnrdB, getOsnrDbfromOnsrLin(calcOnsrLin)); + signal.get("calcCd"), Math.sqrt(signal.get("calcPmd2").doubleValue()), + Math.sqrt(signal.get("calcPdl2").doubleValue()), calcOnsrdB, + getOsnrDbfromOnsrLin(signal.get("calcOnsrLin").doubleValue())); if (!transponderPresent) { LOG.info("No transponder in the path, User shall check from CD, PMD, and OSNR values provided " + "that optical tunnel degradations are compatible with external transponder performances"); @@ -626,15 +605,17 @@ public class PostAlgoPathValidator { */ private double checkOSNRza(GraphPath path, Map allPceNodes, Map allPceLinks, String serviceType, CatalogUtils cu) { - double spacing = 50.0; - double calcPdl2 = 0; - double calcOsnrdB = 0; - double calcCd = 0; - double calcPmd2 = 0; - double calcOnsrLin = 0.0001; + Map signal = new HashMap<>( + Map.of( + "spacing", Double.valueOf(50.0), + "calcPdl2", Double.valueOf(0), + "calcCd", Double.valueOf(0), + "calcPmd2", Double.valueOf(0), + "calcOnsrLin", Double.valueOf(0.0001), + "pwrIn", Double.valueOf(-60.0), + "pwrOut", Double.valueOf(-60.0))); + double calcOnsrdB = 0; double margin = 0; - double pwrIn = -60.0; - double pwrOut = -60.0; boolean transponderPresent = false; List vertices = path.getVertexList(); List edges = path.getEdgeList(); @@ -652,14 +633,12 @@ public class PostAlgoPathValidator { case XPONDER: LOG.debug("loop of check OSNR direction ZA: XPDR, Path Element = {}", pathElement); transponderPresent = true; - Map results = calcXpdrOSNR(cu, + calcXpdrOSNR(cu, signal, pathElement == vertices.size() - 1 // First transponder on the Path (TX side) / Last Xponder of the path (RX side) ? getOppPceLink(pathElement - 1, edges, allPceLinks).getSourceTP().getValue() : getOppPceLink((pathElement), edges, allPceLinks).getDestTP().getValue(), serviceType, currentNode, nextNode, vertices.get(pathElement), pathElement); - calcOnsrLin = results.get("calcOnsrLin"); - spacing = results.get("spacing"); break; case SRG: LOG.debug("loop of check OSNR direction ZA: SRG, Path Element = {}", pathElement); @@ -669,17 +648,10 @@ public class PostAlgoPathValidator { LOG.error("Error processing Node {} for which output link {} is not an ADDLINK Type", currentNode.getNodeId(), pathElement - 1); } - pwrIn = 0.0; - - Map impairments = calcAddContrib( - cu, currentNode, getOppPceLink(pathElement - 2, edges, allPceLinks), - calcCd, calcPmd2, calcPdl2, calcOnsrLin, spacing); - calcCd = impairments.get("calcCd"); - calcPmd2 = impairments.get("calcPmd2"); - calcPdl2 = impairments.get("calcPdl2"); - calcOnsrLin = impairments.get("calcOnsrLin"); - pwrOut = impairments.get("pwrOut"); - if (calcOnsrLin == Double.NEGATIVE_INFINITY || calcOnsrLin == Double.POSITIVE_INFINITY) { + signal.put("pwrIn", Double.valueOf(0)); + calcAddContrib(cu, signal, currentNode, getOppPceLink(pathElement - 2, edges, allPceLinks)); + double calcOnsr = signal.get("calcOnsrLin").doubleValue(); + if (calcOnsr == Double.NEGATIVE_INFINITY || calcOnsr == Double.POSITIVE_INFINITY) { return -1.0; } // For the ADD, degradation brought by the node are calculated from the MW-WR spec. @@ -707,14 +679,9 @@ public class PostAlgoPathValidator { PceLink pceLink = getOppPceLink(pathElement + 1, edges, allPceLinks); LOG.info("loop of check OSNR direction ZA: SRG, path Element = {} CD on preceeding link {} = {} ps", pathElement, pathElement + 1, pceLink.getcd()); - Map impairments = calcDropContrib( - cu, currentNode, pceLink, pwrOut, calcCd, calcPmd2, calcPdl2, calcOnsrLin, spacing); - calcCd = impairments.get("calcCd"); - calcPmd2 = impairments.get("calcPmd2"); - calcPdl2 = impairments.get("calcPdl2"); - calcOnsrLin = impairments.get("calcOnsrLin"); - pwrIn = impairments.get("pwrIn"); - if (calcOnsrLin == Double.NEGATIVE_INFINITY || calcOnsrLin == Double.POSITIVE_INFINITY) { + calcDropContrib(cu, signal, currentNode, pceLink); + double calcOnsr = signal.get("calcOnsrLin").doubleValue(); + if (calcOnsr == Double.NEGATIVE_INFINITY || calcOnsr == Double.POSITIVE_INFINITY) { return -1.0; } // If SRG is not the first or the second element of the Path, it is the DROP @@ -723,9 +690,9 @@ public class PostAlgoPathValidator { // resulting OSNR in dB to pass it to the method that verifies end Xponder // performances are compatible with degradations experienced on the path try { - calcOsnrdB = getOsnrDbfromOnsrLin(calcOnsrLin); - LOG.info("checkOSNR loop, last SRG osnr is {} dB", calcOsnrdB); - LOG.info("Loop Path Element = {}, DROP, calcOsnrdB= {}", pathElement, calcOsnrdB); + calcOnsrdB = getOsnrDbfromOnsrLin(calcOnsr); + LOG.info("checkOSNR loop, last SRG osnr is {} dB", calcOnsrdB); + LOG.info("Loop Path Element = {}, DROP, calcOnsrdB= {}", pathElement, calcOnsrdB); } catch (ArithmeticException e) { LOG.debug("In checkOSNR: OSNR is equal to 0 and the number of links is: {}", path.getEdgeList().size()); @@ -738,19 +705,11 @@ public class PostAlgoPathValidator { break; } LOG.info("loop of check OSNR direction ZA: DEGREE, Path Element = {}", pathElement); - Map impairments0 = calcBypassContrib( - cu, currentNode, nextNode, + calcBypassContrib(cu, signal, currentNode, nextNode, getOppPceLink(pathElement, edges, allPceLinks), - getOppPceLink(pathElement - 2, edges, allPceLinks), - pwrOut, calcCd, calcPmd2, calcPdl2, calcOnsrLin, spacing); - calcCd = impairments0.get("CD").doubleValue(); - calcPmd2 = impairments0.get("DGD2").doubleValue(); - calcPdl2 = impairments0.get("PDL2").doubleValue(); - calcOnsrLin = impairments0.get("ONSRLIN").doubleValue(); - //TODO rename impariments0 var and/or adapt catalog utils - pwrIn = impairments0.get("pwrIn").doubleValue(); - pwrOut = impairments0.get("pwrOut").doubleValue(); - LOG.debug("Loop Path Element = {}, DEGREE, calcOsnrdB= {}", + getOppPceLink(pathElement - 2, edges, allPceLinks)); + double calcOnsrLin = signal.get("calcOnsrLin").doubleValue(); + LOG.debug("Loop Path Element = {}, DEGREE, calcOnsrdB= {}", pathElement, getOsnrDbfromOnsrLin(calcOnsrLin)); if (calcOnsrLin == Double.NEGATIVE_INFINITY || calcOnsrLin == Double.POSITIVE_INFINITY) { return -1.0; @@ -759,8 +718,9 @@ public class PostAlgoPathValidator { // next node pathElement--; LOG.info("Accumulated degradations in the path including ROADM {} + {} are CD: {}; PMD2: " - + "{}; Pdl2 : {}; ONSRdB : {}", currentNode.getNodeId(), - nextNode.getNodeId(), calcCd, calcPmd2, calcPdl2, getOsnrDbfromOnsrLin(calcOnsrLin)); + + "{}; Pdl2 : {}; ONSRdB : {}", currentNode.getNodeId(), nextNode.getNodeId(), + signal.get("calcCd"), signal.get("calcPmd2"), signal.get("calcPdl2"), + getOsnrDbfromOnsrLin(calcOnsrLin)); break; case XPONDER: LOG.debug("loop of check OSNR direction AZ: XPDR, Path Element = {}", pathElement); @@ -777,8 +737,8 @@ public class PostAlgoPathValidator { LOG.debug("loop of check OSNR direction ZA: XPDR, Path Element = 0"); transponderPresent = true; // TSP is the last of the path - margin = getLastXpdrMargin(cu, getOppPceLink(0, edges, allPceLinks).getDestTP().getValue(), - serviceType, currentNode, vertices.get(0), 0, calcCd, calcPmd2, calcPdl2, calcOnsrLin); + margin = getLastXpdrMargin(cu, signal, getOppPceLink(0, edges, allPceLinks).getDestTP().getValue(), + serviceType, currentNode, vertices.get(0), 0); break; case SRG: LOG.debug("loop of check OSNR direction ZA: SRG, Path Element = 0"); @@ -789,14 +749,10 @@ public class PostAlgoPathValidator { PceLink pceLink = getOppPceLink(1, edges, allPceLinks); LOG.info("loop of check OSNR direction ZA: SRG, path Element = 0 CD on preceeding link 1 = {} ps", pceLink.getcd()); - Map impairments = calcDropContrib( - cu, currentNode, pceLink, pwrOut, calcCd, calcPmd2, calcPdl2, calcOnsrLin, spacing); - calcCd = impairments.get("calcCd"); - calcPmd2 = impairments.get("calcPmd2"); - calcPdl2 = impairments.get("calcPdl2"); - calcOnsrLin = impairments.get("calcOnsrLin"); + calcDropContrib(cu, signal, currentNode, pceLink); + double calcOnsr = signal.get("calcOnsrLin").doubleValue(); //commented out to avoid spotbug DLS_DEAD_LOCAL_STORE pwrIn = impairments.get("pwrIn"); - if (calcOnsrLin == Double.NEGATIVE_INFINITY || calcOnsrLin == Double.POSITIVE_INFINITY) { + if (calcOnsr == Double.NEGATIVE_INFINITY || calcOnsr == Double.POSITIVE_INFINITY) { return -1.0; } // If SRG is not the first or the second element of the Path, it is the DROP @@ -805,9 +761,9 @@ public class PostAlgoPathValidator { // resulting OSNR in dB to pass it to the method that verifies end Xponder // performances are compatible with degradations experienced on the path try { - calcOsnrdB = getOsnrDbfromOnsrLin(calcOnsrLin); - LOG.info("checkOSNR loop, last SRG osnr is {} dB", calcOsnrdB); - LOG.info("Loop Path Element = 0, DROP, calcOsnrdB= {}", calcOsnrdB); + calcOnsrdB = getOsnrDbfromOnsrLin(calcOnsr); + LOG.info("checkOSNR loop, last SRG osnr is {} dB", calcOnsrdB); + LOG.info("Loop Path Element = 0, DROP, calcOnsrdB= {}", calcOnsrdB); } catch (ArithmeticException e) { LOG.debug("In checkOSNR: OSNR is equal to 0 and the number of links is: {}", path.getEdgeList().size()); @@ -818,9 +774,11 @@ public class PostAlgoPathValidator { default: LOG.error("PostAlgoPathValidator.CheckOSNR : unsupported resource type in the path chain last element"); } - LOG.info("- In checkOSNR: accumulated CD = {} ps, PMD = {} ps, PDL = {} dB, and resulting OSNR calcOsnrdB = {} " + LOG.info("- In checkOSNR: accumulated CD = {} ps, PMD = {} ps, PDL = {} dB, and resulting OSNR calcOnsrdB = {} " + "dB and ONSR dB exterapolated from calcosnrlin = {} including non linear contributions", - calcCd, Math.sqrt(calcPmd2), Math.sqrt(calcPdl2), calcOsnrdB, getOsnrDbfromOnsrLin(calcOnsrLin)); + signal.get("calcCd"), Math.sqrt(signal.get("calcPmd2").doubleValue()), + Math.sqrt(signal.get("calcPdl2").doubleValue()), calcOnsrdB, + getOsnrDbfromOnsrLin(signal.get("calcOnsrLin").doubleValue())); if (!transponderPresent) { LOG.info("No transponder in the path, User shall check from CD, PMD, and OSNR values provided " + "that optical tunnel degradations are compatible with external transponder performances"); @@ -881,23 +839,26 @@ public class PostAlgoPathValidator { } private double getLastXpdrMargin( - CatalogUtils cu, String nwTpId, String serviceType, PceNode currentNode, String vertice, int pathElement, - double calcCd, double calcPmd2, double calcPdl2, double calcOnsrLin) { + CatalogUtils cu, Map signal, + String nwTpId, String serviceType, PceNode currentNode, String vertice, int pathElement) { LOG.debug("Loop Path Element = {}, Step5.1, XPDR, tries calculating Margin, just before call", pathElement); // Check that accumulated degradations are compatible with TSP performances // According to OpenROADM spec : // margin = cu.getPceRxTspParameters(opMode, calcCd, Math.sqrt(calcPmd2), Math.sqrt(calcPdl2), // getOsnrDbfromOnsrLin(calcOnsrLin)); // Calculation modified for pdl according to calculation in Julia's Tool - double calcosnrdB = getOsnrDbfromOnsrLin(calcOnsrLin); - LOG.info("Loop Path Element = {}, XPDR, calcosnrdB= {}", pathElement, calcosnrdB); + double calcOnsrdB = getOsnrDbfromOnsrLin(signal.get("calcOnsrLin").doubleValue()); + LOG.info("Loop Path Element = {}, XPDR, calcosnrdB= {}", pathElement, calcOnsrdB); return cu.getPceRxTspParameters( getXpdrOpMode(nwTpId, vertice, pathElement, currentNode, serviceType, cu), - calcCd, Math.sqrt(calcPmd2), Math.sqrt(calcPdl2), calcosnrdB); + signal.get("calcCd").doubleValue(), + Math.sqrt(signal.get("calcPmd2").doubleValue()), + Math.sqrt(signal.get("calcPdl2").doubleValue()), + calcOnsrdB); } - private Map calcXpdrOSNR( - CatalogUtils cu, String nwTpId, String serviceType, + private void calcXpdrOSNR( + CatalogUtils cu, Map signal, String nwTpId, String serviceType, PceNode currentNode, PceNode nextNode, String vertice, int pathElement) { // If the Xponder operational mode (setOpMode Arg1) is not consistent nor declared in the topology (Network TP) // Operational mode is retrieved from the service Type assuming it is supported by the Xponder (setOpMode Arg2) @@ -913,61 +874,58 @@ public class PostAlgoPathValidator { currentNode.getNodeId().getValue(), pathElement, getOsnrDbfromOnsrLin(calcOnsrLin)); // Return the Tx ONSR of the Xponder which results from IB and OOB OSNR contributions // and the spacing associated with Xponder operational mode that is needed to calculate OSNR - return Map.of( - "spacing", cu.getPceTxTspChannelSpacing(opMode), - "calcOnsrLin", calcOnsrLin); + signal.put("spacing", Double.valueOf(cu.getPceTxTspChannelSpacing(opMode))); + signal.put("calcOnsrLin", Double.valueOf(calcOnsrLin)); } - private Map calcDropContrib( - CatalogUtils cu, PceNode currentNode, PceLink pceLink, - double pwrOut, double calcCd, double calcPmd2, double calcPdl2, double calcOnsrLin, double spacing) { + private void calcDropContrib( + CatalogUtils cu, Map signal, PceNode currentNode, PceLink pceLink) { //calculation of the SRG contribution for Drop - Map impairments = - calcLineDegradation(cu, pceLink, pwrOut, calcCd, calcPmd2, calcPdl2, calcOnsrLin, spacing); - double pwrIn = impairments.get("pwrIn"); - impairments = cu.getPceRoadmAmpParameters( + calcLineDegradation(cu, signal, pceLink); + Map impairments = cu.getPceRoadmAmpParameters( CatalogConstant.CatalogNodeType.DROP, setOpMode(currentNode.getOperationalMode(), CatalogConstant.MWWRCORE), // If the operational mode of the ADD/DROP MUX is not consistent or not declared in the topology (Network TP) // Operational mode is set by default to standard opMode for ADD/DROP SRGs - pwrIn, - impairments.get("calcCd").doubleValue(), - impairments.get("calcPmd2").doubleValue(), - calcPdl2, - impairments.get("calcOnsrLin").doubleValue(), - spacing); - return Map.of( - "calcCd", impairments.get("CD"), - "calcPmd2", impairments.get("DGD2"), - "calcPdl2", impairments.get("PDL2"), - "calcOnsrLin", impairments.get("ONSRLIN"), - "pwrIn", pwrIn); + signal.get("pwrIn").doubleValue(), + signal.get("calcCd").doubleValue(), + signal.get("calcPmd2").doubleValue(), + signal.get("calcPdl2").doubleValue(), + signal.get("calcOnsrLin").doubleValue(), + signal.get("spacing").doubleValue()); + signal.putAll( + Map.of( + "calcCd", impairments.get("CD"), + "calcPmd2", impairments.get("DGD2"), + "calcPdl2", impairments.get("PDL2"), + "calcOnsrLin", impairments.get("ONSRLIN"))); } - private Map calcAddContrib( - CatalogUtils cu, PceNode currentNode, PceLink pceLink, - double calcCd, double calcPmd2, double calcPdl2, double calcOnsrLin, double spacing) { + private void calcAddContrib( + CatalogUtils cu, Map signal, PceNode currentNode, PceLink pceLink) { //calculation of the SRG contribution for Add String srgMode = setOpMode(currentNode.getOperationalMode(), CatalogConstant.MWWRCORE); // If the operational mode of the ADD/DROP MUX is not consistent or is not declared in the topology (Network TP) // Operational mode is set by default to standard opMode for ADD/DROP SRGs CatalogNodeType cnt = CatalogConstant.CatalogNodeType.ADD; double pwrOut = cu.getPceRoadmAmpOutputPower( - cnt, srgMode, pceLink.getspanLoss(), spacing, pceLink.getpowerCorrection()); + cnt, srgMode, pceLink.getspanLoss(), signal.get("spacing").doubleValue(), pceLink.getpowerCorrection()); //calculation of the SRG contribution either for Add and Drop - Map impairments = cu.getPceRoadmAmpParameters( - cnt, srgMode, 0, calcCd, calcPmd2, calcPdl2, calcOnsrLin, spacing); - return Map.of( - "calcCd", impairments.get("CD"), - "calcPmd2", impairments.get("DGD2"), - "calcPdl2", impairments.get("PDL2"), - "calcOnsrLin", impairments.get("ONSRLIN"), - "pwrOut", pwrOut); + Map impairments = cu.getPceRoadmAmpParameters(cnt, srgMode, 0, + signal.get("calcCd").doubleValue(), signal.get("calcPmd2").doubleValue(), + signal.get("calcPdl2").doubleValue(), + signal.get("calcOnsrLin").doubleValue(), signal.get("spacing").doubleValue()); + signal.putAll( + Map.of( + "calcCd", impairments.get("CD"), + "calcPmd2", impairments.get("DGD2"), + "calcPdl2", impairments.get("PDL2"), + "calcOnsrLin", impairments.get("ONSRLIN"), + "pwrOut", Double.valueOf(pwrOut))); } - private Map calcBypassContrib( - CatalogUtils cu, PceNode currentNode, PceNode nextNode, PceLink pceLink0, PceLink pceLink1, - double pwrOut, double calcCd, double calcPmd2, double calcPdl2, double calcOnsrLin, double spacing) { + private void calcBypassContrib(CatalogUtils cu, Map signal, + PceNode currentNode, PceNode nextNode, PceLink pceLink0, PceLink pceLink1) { // If the operational mode of the Degree is not consistent or declared in the topology // Operational mode is set by default to standard opMode for Degree String degree1Mode = setOpMode(currentNode.getOperationalMode(), CatalogConstant.MWMWCORE); @@ -979,40 +937,42 @@ public class PostAlgoPathValidator { + "{} of {} operational mode. Will by default use operational mode of Degree2", currentNode.getNodeId(), degree1Mode, nextNode.getNodeId(), degree2Mode); } - Map impairments = calcLineDegradation( - cu, pceLink0, pwrOut, calcCd, calcPmd2, calcPdl2, calcOnsrLin, spacing); - calcCd = impairments.get("calcCd"); - calcPmd2 = impairments.get("calcPmd2"); - calcOnsrLin = impairments.get("calcOnsrLin"); - CatalogNodeType cnt0 = CatalogConstant.CatalogNodeType.EXPRESS; - double pwrIn = impairments.get("pwrIn"); - pwrOut = cu.getPceRoadmAmpOutputPower( - cnt0, degree2Mode, pceLink1.getspanLoss(), spacing, pceLink1.getpowerCorrection()); + calcLineDegradation(cu, signal, pceLink0); + CatalogNodeType cnt = CatalogConstant.CatalogNodeType.EXPRESS; + double pwrOut = cu.getPceRoadmAmpOutputPower(cnt, degree2Mode, pceLink1.getspanLoss(), + signal.get("spacing").doubleValue(), pceLink1.getpowerCorrection()); // Adds to accumulated impairments the degradation associated with the Express // path of ROADM : Degree1, express link, Degree2 - impairments = cu.getPceRoadmAmpParameters( - cnt0, degree2Mode, pwrIn, calcCd, calcPmd2, calcPdl2, calcOnsrLin, spacing); - impairments.put("pwrIn", pwrIn); - impairments.put("pwrOut", pwrOut); - return impairments; + Map impairments = cu.getPceRoadmAmpParameters(cnt, degree2Mode, + signal.get("pwrIn").doubleValue(), signal.get("calcCd").doubleValue(), + signal.get("calcPmd2").doubleValue(), signal.get("calcPdl2").doubleValue(), + signal.get("calcOnsrLin").doubleValue(), signal.get("spacing").doubleValue()); + signal.putAll( + Map.of( + "calcCd", impairments.get("CD"), + "calcPmd2", impairments.get("DGD2"), + "calcPdl2", impairments.get("PDL2"), + "calcOnsrLin", impairments.get("ONSRLIN"), + "pwrOut", Double.valueOf(pwrOut))); } //TODO these methods might be more indicated in a catalog utils refactoring - private Map calcLineDegradation( - CatalogUtils cu, PceLink pceLink, - double pwrOut, double calcCd, double calcPmd2, double calcPdl2, double calcOnsrLin, double spacing) { + private void calcLineDegradation(CatalogUtils cu, Map signal, PceLink pceLink) { // Calculate degradation accumulated across incoming Link and add them to // accumulated impairments // This also includes Non Linear Contribution from the path - return Map.of( - "pwrIn", pwrOut - pceLink.getspanLoss(), - "calcCd", calcCd + pceLink.getcd(), - "calcPmd2", calcPmd2 + pceLink.getpmd2(), - "calcOnsrLin", calcOnsrLin + cu.calculateNLonsrContribution(pwrOut, pceLink.getLength(), spacing)); + signal.putAll(Map.of( + "pwrIn", Double.valueOf(signal.get("pwrOut").doubleValue() - pceLink.getspanLoss()), + "calcCd", Double.valueOf(signal.get("calcCd").doubleValue() + pceLink.getcd()), + "calcPmd2", Double.valueOf(signal.get("calcPmd2").doubleValue() + pceLink.getpmd2()), + "calcOnsrLin", Double.valueOf( + signal.get("calcOnsrLin").doubleValue() + + cu.calculateNLonsrContribution( + signal.get("pwrOut").doubleValue(), pceLink.getLength(), signal.get("spacing").doubleValue())))); } - private double getOsnrDbfromOnsrLin(double onsrLu) { - return 10 * Math.log10(1 / onsrLu); + private double getOsnrDbfromOnsrLin(double osnrLu) { + return 10 * Math.log10(1 / osnrLu); } /** -- 2.36.6