blob: 7f3849282be3757e5b7457cb8fffa99c6cf6059a [file] [log] [blame]
alessio7da44432023-04-03 17:11:58 +02001/*
2 * Copyright 2023-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * This Work is contributed by CNR within the B5G-OPEN project.
17 */
18
19package org.onosproject.net;
20
21import org.onlab.util.Frequency;
22import org.slf4j.Logger;
23import org.slf4j.LoggerFactory;
24
25/**
26 * Utils to manage OCH signal on multiple optical bands.
27 * Given an OCH signal it is mapped in one band.
28 * Start and End frequency for each band can be queried.
29 */
30public final class OpticalBandUtils {
31
32 private static final Logger log = LoggerFactory.getLogger(OpticalBandUtils.class);
33 private static final Frequency L_BAND_START_FREQ = Frequency.ofGHz(184500);
34 private static final Frequency L_BAND_STOP_FREQ = Frequency.ofGHz(191500);
35 private static final Frequency C_BAND_START_FREQ = Frequency.ofGHz(191500);
36 private static final Frequency C_BAND_STOP_FREQ = Frequency.ofGHz(195500);
37 private static final Frequency S_BAND_START_FREQ = Frequency.ofGHz(195500);
38 private static final Frequency S_BAND_STOP_FREQ = Frequency.ofGHz(205300);
39
40 // prohibit instantiation
41 private OpticalBandUtils() {}
42 /**
43 * Maps the provided OCH signal on optical band type.
44 *
45 * @param ochSignal signal to be mapped
46 * @return OpticalBandType band
47 */
48 public static OpticalBandType computeOpticalBand(OchSignal ochSignal) {
49 if (L_BAND_START_FREQ.isLessThan(ochSignal.centralFrequency())
50 && L_BAND_STOP_FREQ.isGreaterThan(ochSignal.centralFrequency())) {
51 return OpticalBandType.L_BAND;
52 }
53 if (C_BAND_START_FREQ.isLessThan(ochSignal.centralFrequency())
54 && C_BAND_STOP_FREQ.isGreaterThan(ochSignal.centralFrequency())) {
55 return OpticalBandType.C_BAND;
56 }
57 if (S_BAND_START_FREQ.isLessThan(ochSignal.centralFrequency())
58 && S_BAND_STOP_FREQ.isGreaterThan(ochSignal.centralFrequency())) {
59 return OpticalBandType.S_BAND;
60 }
61 return null;
62 }
63
64 /**
65 * Return the start frequency of the specified band.
66 *
67 * @param bandType band type to be considered
68 * @return Frequency
69 */
70 public static Frequency startFrequency(OpticalBandType bandType) {
71 switch (bandType) {
72 case L_BAND:
73 return L_BAND_START_FREQ;
74 case C_BAND:
75 return C_BAND_START_FREQ;
76 case S_BAND:
77 return S_BAND_START_FREQ;
78 default:
79 log.error("Unsupported OpticalBandType {}", bandType);
80 return null;
81 }
82 }
83
84 /**
85 * Return the end frequency of the specified band.
86 *
87 * @param bandType band type to be considered
88 * @return Frequency
89 */
90 public static Frequency stopFrequency(OpticalBandType bandType) {
91 switch (bandType) {
92 case L_BAND:
93 return L_BAND_STOP_FREQ;
94 case C_BAND:
95 return C_BAND_STOP_FREQ;
96 case S_BAND:
97 return S_BAND_STOP_FREQ;
98 default:
99 log.error("Unsupported OpticalBandType {}", bandType);
100 return null;
101 }
102 }
103}