Update connection and interface name
[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_40 = BigDecimal.valueOf(40);
38     public static final BigDecimal SLOT_WIDTH_50 = BigDecimal.valueOf(50);
39     public static final BigDecimal SLOT_WIDTH_87_5 = BigDecimal.valueOf(87.5);
40
41     /**
42      * Map for associate service type with nb slots.
43      */
44     public static final Map<String, Integer> SPECTRAL_WIDTH_SLOT_NUMBER_MAP = Map.of(
45             StringConstants.SERVICE_TYPE_100GE, NB_SLOTS_100G,
46             StringConstants.SERVICE_TYPE_400GE, NB_SLOTS_400G,
47             StringConstants.SERVICE_TYPE_OTU4, NB_SLOTS_100G);
48     /**
49      * Map to associate service rate to modulation format.
50      */
51     public static final Map<Uint32, ModulationFormat> RATE_MODULATION_FORMAT_MAP = Map.of(
52             ServiceRateConstant.RATE_100, ModulationFormat.DpQpsk,
53             ServiceRateConstant.RATE_200, ModulationFormat.DpQpsk,
54             ServiceRateConstant.RATE_300, ModulationFormat.DpQam8,
55             ServiceRateConstant.RATE_400, ModulationFormat.DpQam16);
56     /**
57      * Map to associate service rate and modulation format to frequency width.
58      */
59     public static final Table<Uint32, ModulationFormat, String> FREQUENCY_WIDTH_TABLE = initFrequencyWidthTable();
60
61     public static final long IRRELEVANT_WAVELENGTH_NUMBER = 0;
62
63     /**
64      * Map to associate width format to slot width.
65      */
66     public static final Map<BigDecimal, BigDecimal> WIDTH_SLOT_WIDTH_MAP = Map.of(
67             WIDTH_40, SLOT_WIDTH_50,
68             WIDTH_80, SLOT_WIDTH_87_5);
69
70     public static final int FREQUENCY_PRECISION = 4;
71
72     /**
73      * Map to associate service rate and modulation format to frequency slot width.
74      */
75     public static final Table<Uint32, ModulationFormat, BigDecimal> FREQUENCY_SLOT_WIDTH_TABLE =
76             initFrequencySlotWidthTable();
77     public static final String SPECTRAL_SLOT_SEPARATOR = ":";
78     public static final String NAME_PARAMETERS_SEPARATOR = "-";
79
80     private GridConstant() {
81     }
82
83     private static Table<Uint32, ModulationFormat, String> initFrequencyWidthTable() {
84         Table<Uint32, ModulationFormat, String> frequencyWidthTable = HashBasedTable.create();
85         frequencyWidthTable.put(ServiceRateConstant.RATE_100, ModulationFormat.DpQpsk, String.valueOf(WIDTH_40));
86         frequencyWidthTable.put(ServiceRateConstant.RATE_200, ModulationFormat.DpQpsk, String.valueOf(WIDTH_80));
87         frequencyWidthTable.put(ServiceRateConstant.RATE_300, ModulationFormat.DpQam8, String.valueOf(WIDTH_80));
88         frequencyWidthTable.put(ServiceRateConstant.RATE_400, ModulationFormat.DpQam16, String.valueOf(WIDTH_80));
89         return frequencyWidthTable;
90     }
91
92     private static Table<Uint32, ModulationFormat, BigDecimal> initFrequencySlotWidthTable() {
93         Table<Uint32, ModulationFormat, BigDecimal> frequencyWidthTable = HashBasedTable.create();
94         frequencyWidthTable.put(ServiceRateConstant.RATE_100, ModulationFormat.DpQpsk, SLOT_WIDTH_50);
95         frequencyWidthTable.put(ServiceRateConstant.RATE_200, ModulationFormat.DpQpsk, SLOT_WIDTH_87_5);
96         frequencyWidthTable.put(ServiceRateConstant.RATE_300, ModulationFormat.DpQam8, SLOT_WIDTH_87_5);
97         frequencyWidthTable.put(ServiceRateConstant.RATE_400, ModulationFormat.DpQam16, SLOT_WIDTH_87_5);
98         return frequencyWidthTable;
99     }
100 }