blob: cb43e5415b7dfb3c27863829606269e36e8a06a0 [file] [log] [blame]
Marc De Leenheer622861d2015-12-15 22:52:52 -08001/*
2 * Copyright 2015 Open Networking Laboratory
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 */
16package org.onosproject.driver.query;
17
18import org.onlab.util.Spectrum;
19import org.onosproject.net.ChannelSpacing;
20import org.onosproject.net.GridType;
21import org.onosproject.net.OchSignal;
22import org.onosproject.net.PortNumber;
23import org.onosproject.net.behaviour.LambdaQuery;
24import org.onosproject.net.driver.AbstractHandlerBehaviour;
25
26import java.util.Set;
27import java.util.stream.Collectors;
28import java.util.stream.IntStream;
29
30/**
31 * Lambda query implementation for Calient S160 and S320 Optical Circuit Switch.
32 *
33 * The device consists of OMS ports only, and each port exposes lambda resources covering the whole
34 * usable optical spectrum (U to O band, see {@link Spectrum} for spectrum definitions).
35 */
36public class CalientLambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery {
37
38 @Override
39 public Set<OchSignal> queryLambdas(PortNumber port) {
40 // S160 data sheet
41 // Wavelength range: 1260 - 1630 nm
42 long startSpacingMultiplier = Spectrum.U_BAND_MIN.subtract(Spectrum.CENTER_FREQUENCY).asHz() /
43 ChannelSpacing.CHL_12P5GHZ.frequency().asHz();
44 long stopSpacingMultiplier = Spectrum.O_BAND_MAX.subtract(Spectrum.CENTER_FREQUENCY).asHz() /
45 ChannelSpacing.CHL_12P5GHZ.frequency().asHz();
46
47 // Only consider odd values for the multiplier (for easy mapping to fixed grid)
48 return IntStream.rangeClosed((int) startSpacingMultiplier, (int) stopSpacingMultiplier)
49 .filter(i -> i % 2 == 1)
50 .mapToObj(i -> new OchSignal(GridType.FLEX, ChannelSpacing.CHL_6P25GHZ, i, 1))
51 .collect(Collectors.toSet());
52 }
53}