blob: 596d152df06e3fe554bf014a3c579b4a22133a58 [file] [log] [blame]
fahadnaeemkhanffc917f2017-10-03 14:04:46 -07001/*
2 * Copyright 2017-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 */
16package org.onosproject.drivers.ciena;
17
18import org.onosproject.net.ChannelSpacing;
19import org.onosproject.net.OchSignal;
20import org.onosproject.net.PortNumber;
21import org.onosproject.net.behaviour.LambdaQuery;
22import org.onosproject.net.driver.AbstractHandlerBehaviour;
23
24
25import com.google.common.collect.ImmutableSet;
26
27import java.util.Set;
28import java.util.stream.IntStream;
29
30/**
31 * Ciena WaveServer Lambda query.
fahadnaeemkhan2200ed02018-02-21 23:21:23 -080032 * 88 50GHz flex grid channels with 6.25 slot width, starting from 0 to 87.
fahadnaeemkhanffc917f2017-10-03 14:04:46 -070033 */
34public class CienaWaveServerLambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery {
35
36 @Override
37 public Set<OchSignal> queryLambdas(PortNumber port) {
fahadnaeemkhan2200ed02018-02-21 23:21:23 -080038 // 88 channels of 50 GHz with 6.25 GHz slothWidth
fahadnaeemkhanffc917f2017-10-03 14:04:46 -070039 int slots = (int) (ChannelSpacing.CHL_50GHZ.frequency().asHz() /
fahadnaeemkhan2200ed02018-02-21 23:21:23 -080040 ChannelSpacing.CHL_6P25GHZ.frequency().asHz());
fahadnaeemkhanffc917f2017-10-03 14:04:46 -070041 int channels = 88;
fahadnaeemkhan2200ed02018-02-21 23:21:23 -080042 // total lambdas are equal to: channels * slots
fahadnaeemkhanffc917f2017-10-03 14:04:46 -070043 return IntStream.rangeClosed(0, channels * slots)
fahadnaeemkhan2200ed02018-02-21 23:21:23 -080044 .mapToObj(OchSignal::newFlexGridSlot)
fahadnaeemkhanffc917f2017-10-03 14:04:46 -070045 .collect(ImmutableSet.toImmutableSet());
46 }
47
48}
49
50