2 * Copyright © 2020 Orange, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.transportpce.common.fixedflex;
11 import java.math.BigDecimal;
12 import java.math.RoundingMode;
13 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.OchAttributes.ModulationFormat;
14 import org.opendaylight.yangtools.yang.common.Uint32;
17 * Spectrum information for cross connect and openroadm interfaces management.
19 public class SpectrumInformation {
20 private Uint32 waveLength;
21 private int lowerSpectralSlotNumber;
22 private int higherSpectralSlotNumber;
23 private BigDecimal width = GridConstant.WIDTH_40;
24 private BigDecimal centerFrequency;
25 private BigDecimal minFrequency;
26 private BigDecimal maxFrequency;
27 private String modulationFormat = ModulationFormat.DpQpsk.name();
28 private int scale = GridConstant.FIXED_GRID_FREQUENCY_PRECISION;
30 public String getSpectralSlotFormat() {
31 return String.join(GridConstant.SPECTRAL_SLOT_SEPARATOR,
32 String.valueOf(lowerSpectralSlotNumber),
33 String.valueOf(higherSpectralSlotNumber));
36 public String getIdentifierFromParams(String...params) {
37 String joinedParams = String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, params);
38 return String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, joinedParams, getSpectralSlotFormat());
43 * @return the waveLength
45 public Uint32 getWaveLength() {
51 * @param waveLength the waveLength to set
53 public void setWaveLength(Uint32 waveLength) {
54 this.waveLength = waveLength;
55 if (waveLength == null || waveLength.longValue() == GridConstant.IRRELEVANT_WAVELENGTH_NUMBER) {
56 scale = GridConstant.FLEX_GRID_FREQUENCY_PRECISION;
61 * Get the lower spectral slot number.
62 * @return the lowerSpectralSlotNumber
64 public int getLowerSpectralSlotNumber() {
65 return lowerSpectralSlotNumber;
69 * Set the lower spectral slot number.
70 * @param lowerSpectralSlotNumber the lowerSpectralSlotNumber to set
72 public void setLowerSpectralSlotNumber(int lowerSpectralSlotNumber) {
73 this.lowerSpectralSlotNumber = lowerSpectralSlotNumber;
77 * Get the higher spectral slot number.
78 * @return the higherSpectralSlotNumber
80 public int getHigherSpectralSlotNumber() {
81 return higherSpectralSlotNumber;
85 * Set the higher spectral slot number.
86 * @param higherSpectralSlotNumber the higherSpectralSlotNumber to set
88 public void setHigherSpectralSlotNumber(int higherSpectralSlotNumber) {
89 this.higherSpectralSlotNumber = higherSpectralSlotNumber;
93 * Get the frequency width.
96 public BigDecimal getWidth() {
101 * Set the frequency width.
102 * @param width the width to set
104 public void setWidth(BigDecimal width) {
109 * Get center frequency.
110 * @return the centerFrequency
112 public BigDecimal getCenterFrequency() {
113 return centerFrequency;
117 * Set center frequency.
118 * @param centerFrequency the centerFrequency to set
120 public void setCenterFrequency(BigDecimal centerFrequency) {
121 this.centerFrequency = centerFrequency.setScale(scale, RoundingMode.HALF_EVEN);
126 * @return the minFrequency
128 public BigDecimal getMinFrequency() {
134 * @param minFrequency the minFrequency to set
136 public void setMinFrequency(BigDecimal minFrequency) {
137 this.minFrequency = minFrequency.setScale(scale, RoundingMode.HALF_EVEN);
142 * @return the maxFrequency
144 public BigDecimal getMaxFrequency() {
150 * @param maxFrequency the maxFrequency to set
152 public void setMaxFrequency(BigDecimal maxFrequency) {
153 this.maxFrequency = maxFrequency.setScale(scale, RoundingMode.HALF_EVEN);
157 * Get the modulation format.
158 * @return the modulationFormat
160 public String getModulationFormat() {
161 return modulationFormat;
165 * Set the modulation format.
166 * @param modulationFormat the modulationFormat to set
168 public void setModulationFormat(String modulationFormat) {
169 this.modulationFormat = modulationFormat;
175 * @see java.lang.Object#toString()
178 public String toString() {
179 StringBuilder builder = new StringBuilder();
180 builder.append("SpectrumInformation [waveLength=").append(waveLength).append(", lowerSpectralSlotNumber=")
181 .append(lowerSpectralSlotNumber).append(", higherSpectralSlotNumber=").append(higherSpectralSlotNumber)
182 .append(", width=").append(width).append(", centerFrequency=").append(centerFrequency)
183 .append(", minFrequency=").append(minFrequency).append(", maxFrequency=").append(maxFrequency)
184 .append(", modulationFormat=").append(modulationFormat).append(", scale=").append(scale).append("]");
185 return builder.toString();