Upgrade to OpenROADM 7.1.0 network models
[transportpce.git] / common / src / main / java / org / opendaylight / transportpce / common / fixedflex / GridUtils.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 java.math.BigDecimal;
12 import java.util.Arrays;
13 import java.util.HashMap;
14 import java.util.Map;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.FrequencyGHz;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.FrequencyTHz;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.available.freq.map.AvailFreqMaps;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.available.freq.map.AvailFreqMapsBuilder;
19 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.available.freq.map.AvailFreqMapsKey;
20 import org.opendaylight.yangtools.yang.common.Uint16;
21
22 /**
23  * Util class for grid.
24  *
25  */
26 public final class GridUtils {
27
28     private GridUtils() {
29     }
30
31     public static Map<AvailFreqMapsKey, AvailFreqMaps> initFreqMaps4FixedGrid2Available() {
32         byte[] byteArray = new byte[FixedGridConstant.NB_CHANNELS];
33         Arrays.fill(byteArray, (byte) GridConstant.AVAILABLE_SLOT_VALUE);
34         Map<AvailFreqMapsKey, AvailFreqMaps> waveMap = new HashMap<>();
35         AvailFreqMaps availFreqMaps = new AvailFreqMapsBuilder().setMapName(GridConstant.C_BAND)
36                 .setFreqMapGranularity(new FrequencyGHz(BigDecimal.valueOf(FixedGridConstant.GRANULARITY)))
37                 .setStartEdgeFreq(new FrequencyTHz(BigDecimal.valueOf(FixedGridConstant.START_EDGE_FREQUENCY)))
38                 .setEffectiveBits(Uint16.valueOf(FixedGridConstant.EFFECTIVE_BITS))
39                 .setFreqMap(byteArray)
40                 .build();
41         waveMap.put(availFreqMaps.key(), availFreqMaps);
42         return waveMap;
43     }
44
45 }