- return tmplatency;
- }
-
- //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.getLinkConcatenation().get(0).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 linkLength / 1000.0;
+ }
+
+ //Calculate CD and PMD of the link from link length
+ private Map<String, Double> calcCDandPMDfromLength() {
+ return this.length == null
+ ? new HashMap<>()
+ : new HashMap<>(
+ Map.of(
+ "CD", 16.5 * this.length,
+ "PMD2", Math.pow(this.length * PMD_CONSTANT, 2)));
+ }
+
+ //Calculate CD and PMD of the link
+ private Map<String, Double> calcCDandPMD(Link link) {
+ double linkCd = 0.0;
+ double linkPmd2 = 0.0;
+ if (this.omsAttributesSpan == null) {
+ LOG.debug("In PceLink {} no OMS present, assume G.652 fiber, calculation based on fiber length of {} km",
+ link.getLinkId(), this.length);
+ return calcCDandPMDfromLength();
+ }
+ Map<LinkConcatenationKey, LinkConcatenation> linkConcatenationMap =
+ this.omsAttributesSpan.nonnullLinkConcatenation();
+ for (Map.Entry<LinkConcatenationKey, LinkConcatenation> entry : linkConcatenationMap.entrySet()) {
+ // If the link-concatenation list is not populated or partially populated CD &
+ // PMD shall be derived from link-length (expressed in km in OR topology)
+ if (entry == null || entry.getValue() == null || entry.getValue().getSRLGLength() == null
+ || entry.getValue().augmentation(LinkConcatenation1.class).getFiberType() == null) {
+ if (this.length > 0.0) {
+ LOG.debug("In PceLink: no OMS present; cd and PMD for the link {} extrapolated from link length {}"
+ + "assuming SMF fiber type", link.getLinkId().getValue(), this.length);
+ return calcCDandPMDfromLength();
+ }
+ // If Link-length upper attributes not present or incorrectly populated, no way
+ // to calculate CD & PMD
+ LOG.error("In PceLink: no Link length declared and no OMS present for the link {}."
+ + " No Way to compute CD and PMD", link.getLinkId().getValue());
+ return Map.of();
+ }
+ // SRLG length is expressed in OR topology in meter
+ var entryAug = entry.getValue().augmentation(LinkConcatenation1.class);
+ linkCd += entry.getValue().getSRLGLength().doubleValue() / 1000.0
+ * retrieveCdFromFiberType(entryAug.getFiberType());
+ if (entryAug.getPmd() == null
+ || entryAug.getPmd().getValue().doubleValue() == 0.0
+ || entryAug.getPmd().getValue().toString().isEmpty()) {
+ linkPmd2 += Math.pow(
+ entry.getValue().getSRLGLength().doubleValue() / 1000.0
+ * retrievePmdFromFiberType(entryAug.getFiberType()),
+ 2);
+ } else {
+ linkPmd2 += Math.pow(entryAug.getPmd().getValue().doubleValue(), 2);