blob: 22459196576871d1c51f6e1da559e446777c9ac4 [file] [log] [blame]
MaoLu819fde22017-04-20 17:17:49 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016 Open Networking Foundation
MaoLu819fde22017-04-20 17:17:49 -07003 *
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
17package org.onosproject.drivers.oplink;
18
19import org.onlab.util.GuavaCollectors;
20import org.onosproject.net.OchSignal;
21import org.onosproject.net.PortNumber;
22import org.onosproject.net.behaviour.LambdaQuery;
23import org.onosproject.net.driver.AbstractHandlerBehaviour;
24
25import java.util.Set;
26import java.util.stream.IntStream;
27
28import static org.onlab.util.Spectrum.CENTER_FREQUENCY;
29import static org.onosproject.drivers.oplink.OplinkOpticalUtility.CHANNEL_SPACING;
30import static org.onosproject.drivers.oplink.OplinkOpticalUtility.STOP_CENTER_FREQ;
31import static org.onosproject.drivers.oplink.OplinkOpticalUtility.START_CENTER_FREQ;
32
33/**
34 * Lambda query implementation for Oplink netconf devices in C band.
35 *
36 * 96 lambdas with 50GHz width (fixed grid).
37 *
38 * Channel id: Nominal central frequency = 193100 GHz + spacingMultiplier * channelSpacing).
39 * Channel (-35 to 60): starting from 191350 GHz to 196100 GHz, Increment by 50GHz.
40 */
41public class OplinkOpticalLambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery {
42
43 private static final int MIN_CHANNEL = (int) Math.round(
44 START_CENTER_FREQ.subtract(CENTER_FREQUENCY).asHz() / CHANNEL_SPACING.frequency().asHz());
45 private static final int MAX_CHANNEL = (int) Math.round(
46 STOP_CENTER_FREQ.subtract(CENTER_FREQUENCY).asHz() / CHANNEL_SPACING.frequency().asHz());
47
48 @Override
49 public Set<OchSignal> queryLambdas(PortNumber port) {
50 return IntStream.rangeClosed(MIN_CHANNEL, MAX_CHANNEL)
51 .mapToObj(x -> OchSignal.newDwdmSlot(CHANNEL_SPACING, x))
52 .collect(GuavaCollectors.toImmutableSet());
53 }
54}