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;
//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<LinkConcatenation> linkConcatenationList =
+ this.omsAttributesSpan.nonnullLinkConcatenation().values();
+ if (linkConcatenationList == null) {
LOG.error("in PceLink : Null field in the OmsAttrubtesSpan");
return 0L;
}
+ Iterator<LinkConcatenation> 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) {