X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=transportpce.git;a=blobdiff_plain;f=pce%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2Fnetworkanalyzer%2FPceLink.java;h=720ffcd013e844c19e84cd5574263e59175080d6;hp=dde21e1a79a0f01e2d09578a94fa998d02ce7af2;hb=3698762c472dcee815709036258f76af446bec35;hpb=d9b2da0d29b8da2e1052bc2c653399e68dc767ff diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java index dde21e1a7..720ffcd01 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java @@ -12,6 +12,8 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; +import java.util.Collection; +import java.util.Iterator; import java.util.List; import java.util.Map; import org.eclipse.jdt.annotation.NonNull; @@ -153,24 +155,31 @@ public class PceLink implements Serializable { //Compute the OSNR of a span public double calcSpanOSNR() { - try { - double pout; //power on the output of the previous ROADM (dBm) - pout = retrievePower(this.omsAttributesSpan.nonnullLinkConcatenation() - .values().iterator().next().getFiberType()); - double spanLoss = this.omsAttributesSpan.getSpanlossCurrent().getValue().doubleValue(); // span loss (dB) - double pin = pout - spanLoss; //power on the input of the current ROADM (dBm) - double spanOsnrDb; - spanOsnrDb = NOISE_MASK_A * pin + NOISE_MASK_B; - if (spanOsnrDb > UPPER_BOUND_OSNR) { - spanOsnrDb = UPPER_BOUND_OSNR; - } else if (spanOsnrDb < LOWER_BOUND_OSNR) { - spanOsnrDb = LOWER_BOUND_OSNR; - } - return spanOsnrDb; - } catch (NullPointerException e) { + if (this.omsAttributesSpan == null) { + return 0L; + } + Collection linkConcatenationList = + this.omsAttributesSpan.nonnullLinkConcatenation().values(); + if (linkConcatenationList == null) { LOG.error("in PceLink : Null field in the OmsAttrubtesSpan"); return 0L; } + Iterator linkConcatenationiterator = linkConcatenationList.iterator(); + if (!linkConcatenationiterator.hasNext()) { + return 0L; + } + // power on the output of the previous ROADM (dBm) + double pout = retrievePower(linkConcatenationiterator.next().getFiberType()); + // span loss (dB) + double spanLoss = this.omsAttributesSpan.getSpanlossCurrent().getValue().doubleValue(); + double pin = pout - spanLoss; // power on the input of the current ROADM (dBm) + double spanOsnrDb = NOISE_MASK_A * pin + NOISE_MASK_B; + if (spanOsnrDb > UPPER_BOUND_OSNR) { + spanOsnrDb = UPPER_BOUND_OSNR; + } else if (spanOsnrDb < LOWER_BOUND_OSNR) { + spanOsnrDb = LOWER_BOUND_OSNR; + } + return spanOsnrDb; } private double retrievePower(FiberType fiberType) {