7282bec3cc5c42678c2533a6a1d68853a4883cd1
[transportpce.git] / common / src / main / java / org / opendaylight / transportpce / common / fixedflex / GridConstant.java
1 /*
2  * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.transportpce.common.fixedflex;
10
11 import com.google.common.collect.HashBasedTable;
12 import com.google.common.collect.Table;
13 import java.math.BigDecimal;
14 import java.util.Map;
15 import org.opendaylight.transportpce.common.ServiceRateConstant;
16 import org.opendaylight.transportpce.common.StringConstants;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.ModulationFormat;
18 import org.opendaylight.yangtools.yang.common.Uint32;
19
20 /**
21  * Constant class common to fixed grid and flex grid.
22  *
23  */
24 public final class GridConstant {
25
26     public static final String C_BAND = "cband";
27     public static final int AVAILABLE_SLOT_VALUE = 255;
28     public static final int USED_SLOT_VALUE = 0;
29     public static final double GRANULARITY = 6.25;
30     public static final int EFFECTIVE_BITS = 768;
31     public static final double START_EDGE_FREQUENCY = 191.325;
32     public static final int NB_OCTECTS = 96;
33     public static final double CENTRAL_FREQUENCY = 193.1;
34     public static final int NB_SLOTS_100G = 8;
35     public static final int NB_SLOTS_400G = 14;
36     public static final BigDecimal WIDTH_80 = BigDecimal.valueOf(80);
37     public static final BigDecimal WIDTH_75 = BigDecimal.valueOf(75);
38     public static final BigDecimal WIDTH_40 = BigDecimal.valueOf(40);
39     public static final BigDecimal SLOT_WIDTH_50 = BigDecimal.valueOf(50);
40     public static final BigDecimal SLOT_WIDTH_87_5 = BigDecimal.valueOf(87.5);
41
42     /**
43      * Map for associate service type with nb slots.
44      */
45     public static final Map<String, Integer> SPECTRAL_WIDTH_SLOT_NUMBER_MAP = Map.of(
46             StringConstants.SERVICE_TYPE_100GE_T, NB_SLOTS_100G,
47             StringConstants.SERVICE_TYPE_400GE, NB_SLOTS_400G,
48             StringConstants.SERVICE_TYPE_OTU4, NB_SLOTS_100G);
49
50     /**
51      * Map to associate service rate to modulation format.
52      */
53     public static final Map<Uint32, ModulationFormat> RATE_MODULATION_FORMAT_MAP = Map.of(
54             ServiceRateConstant.RATE_100, ModulationFormat.DpQpsk,
55             ServiceRateConstant.RATE_200, ModulationFormat.DpQpsk,
56             ServiceRateConstant.RATE_300, ModulationFormat.DpQam8,
57             ServiceRateConstant.RATE_400, ModulationFormat.DpQam16);
58
59     /**
60      * Map to associate service rate and modulation format to frequency width.
61      */
62     public static final Table<Uint32, ModulationFormat, String> FREQUENCY_WIDTH_TABLE = initFrequencyWidthTable();
63
64     public static final long IRRELEVANT_WAVELENGTH_NUMBER = 0;
65
66     /**
67      * Map to associate width format to slot width.
68      */
69     public static final Map<BigDecimal, BigDecimal> WIDTH_SLOT_WIDTH_MAP = Map.of(
70             WIDTH_40, SLOT_WIDTH_50,
71             WIDTH_75, SLOT_WIDTH_87_5,
72             WIDTH_80, SLOT_WIDTH_87_5);
73
74     public static final int FIXED_GRID_FREQUENCY_PRECISION = 4;
75
76     public static final int FLEX_GRID_FREQUENCY_PRECISION = 5;
77
78     /**
79      * Map to associate service rate and modulation format to frequency slot width.
80      */
81     public static final Table<Uint32, ModulationFormat, BigDecimal> FREQUENCY_SLOT_WIDTH_TABLE =
82             initFrequencySlotWidthTable();
83     public static final String SPECTRAL_SLOT_SEPARATOR = ":";
84     public static final String NAME_PARAMETERS_SEPARATOR = "-";
85
86     /**
87      * Map for associate service rate with nb slots.
88      */
89     public static final Map<Uint32, Integer> RATE_SPECTRAL_WIDTH_SLOT_NUMBER_MAP = Map.of(
90             ServiceRateConstant.RATE_100, NB_SLOTS_100G,
91             ServiceRateConstant.RATE_200, NB_SLOTS_100G,
92             ServiceRateConstant.RATE_300, NB_SLOTS_100G,
93             ServiceRateConstant.RATE_400, NB_SLOTS_400G);
94
95     private GridConstant() {
96     }
97
98     private static Table<Uint32, ModulationFormat, String> initFrequencyWidthTable() {
99         Table<Uint32, ModulationFormat, String> frequencyWidthTable = HashBasedTable.create();
100         frequencyWidthTable.put(ServiceRateConstant.RATE_100, ModulationFormat.DpQpsk, String.valueOf(WIDTH_40));
101         frequencyWidthTable.put(ServiceRateConstant.RATE_200, ModulationFormat.DpQpsk, String.valueOf(WIDTH_80));
102         frequencyWidthTable.put(ServiceRateConstant.RATE_300, ModulationFormat.DpQam8, String.valueOf(WIDTH_80));
103         frequencyWidthTable.put(ServiceRateConstant.RATE_400, ModulationFormat.DpQam16, String.valueOf(WIDTH_75));
104         return frequencyWidthTable;
105     }
106
107     private static Table<Uint32, ModulationFormat, BigDecimal> initFrequencySlotWidthTable() {
108         Table<Uint32, ModulationFormat, BigDecimal> frequencyWidthTable = HashBasedTable.create();
109         frequencyWidthTable.put(ServiceRateConstant.RATE_100, ModulationFormat.DpQpsk, SLOT_WIDTH_50);
110         frequencyWidthTable.put(ServiceRateConstant.RATE_200, ModulationFormat.DpQpsk, SLOT_WIDTH_87_5);
111         frequencyWidthTable.put(ServiceRateConstant.RATE_300, ModulationFormat.DpQam8, SLOT_WIDTH_87_5);
112         frequencyWidthTable.put(ServiceRateConstant.RATE_400, ModulationFormat.DpQam16, SLOT_WIDTH_87_5);
113         return frequencyWidthTable;
114     }
115 }