Use version 13.1.0 of openroadm-service models
[transportpce.git] / common / src / main / java / org / opendaylight / transportpce / common / fixedflex / GridUtils.java
index ceb99ef5652c69aad6867befdb929d7ded1d0181..8fefb008c50ae9ab91c98a7d7f78a8b7d2505b0c 100644 (file)
@@ -106,9 +106,10 @@ public final class GridUtils {
      * Get the spectrum width for rate and modulation format.
      * @param rate Uint32
      * @param modulationFormat ModulationFormat
-     * @return spectrum width in GHz
+     * @return spectrum width in GHz compatible with models 10.1
      */
-    public static FrequencyGHz getWidthFromRateAndModulationFormat(Uint32 rate, ModulationFormat modulationFormat) {
+    public static FrequencyGHz getWidthFromRateAndModulationFormatToModel101(Uint32 rate,
+            ModulationFormat modulationFormat) {
         String width = GridConstant.FREQUENCY_WIDTH_TABLE.get(rate, modulationFormat);
         if (width == null) {
             LOG.warn("No width found for service rate {} and modulation format {}, set width to 40", rate,
@@ -118,15 +119,44 @@ public final class GridUtils {
         return FrequencyGHz.getDefaultInstance(width);
     }
 
+    /**
+     * Get the spectrum width for rate and modulation format.
+     * @param rate Uint32
+     * @param modulationFormat ModulationFormat
+     * @return spectrum width in GHz compatible with models 13.1
+     */
+    public static org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev230526.FrequencyGHz
+            getWidthFromRateAndModulationFormatToModel131(Uint32 rate, ModulationFormat modulationFormat) {
+        String width = GridConstant.FREQUENCY_WIDTH_TABLE.get(rate, modulationFormat);
+        if (width == null) {
+            LOG.warn("No width found for service rate {} and modulation format {}, set width to 40", rate,
+                    modulationFormat);
+            width = String.valueOf(GridConstant.WIDTH_40);
+        }
+        return org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev230526.FrequencyGHz
+                .getDefaultInstance(width);
+    }
+
     /**
      * Get central frequency of spectrum.
      * @param minFrequency BigDecimal
      * @param maxFrequency BigDecimal
-     * @return central frequency in THz
+     * @return central frequency in THz compatible with models 10.1
      */
-    public static FrequencyTHz getCentralFrequency(BigDecimal minFrequency, BigDecimal maxFrequency) {
+    public static FrequencyTHz getCentralFrequencyToModel101(BigDecimal minFrequency, BigDecimal maxFrequency) {
         return new FrequencyTHz(Decimal64.valueOf(computeCentralFrequency(minFrequency, maxFrequency)));
+    }
 
+    /**
+     * Get central frequency of spectrum.
+     * @param minFrequency BigDecimal
+     * @param maxFrequency BigDecimal
+     * @return central frequency in THz compatible with models 13.1
+     */
+    public static org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev230526.FrequencyTHz
+            getCentralFrequencyToModel131(BigDecimal minFrequency, BigDecimal maxFrequency) {
+        return new org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev230526.FrequencyTHz(
+                Decimal64.valueOf(computeCentralFrequency(minFrequency, maxFrequency)));
     }
 
     /**
@@ -204,8 +234,9 @@ public final class GridUtils {
         if (input.getCenterFreq() != null) {
             spectrumInformation.setCenterFrequency(input.getCenterFreq().getValue().decimalValue());
         } else {
-            spectrumInformation.setCenterFrequency(GridUtils.getCentralFrequency(spectrumInformation.getMinFrequency(),
-                            spectrumInformation.getMaxFrequency()).getValue().decimalValue());
+            spectrumInformation.setCenterFrequency(GridUtils.getCentralFrequencyToModel101(
+                    spectrumInformation.getMinFrequency(),
+                    spectrumInformation.getMaxFrequency()).getValue().decimalValue());
         }
         if (input.getNmcWidth() != null) {
             spectrumInformation.setWidth(input.getNmcWidth().getValue().decimalValue()