blob: f8533ddf17bddd17ad623a39d89c3663cd0d9e50 [file] [log] [blame]
Jan Kundrát981fe472019-10-15 22:44:19 +02001/*
2 * Copyright 2016-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.czechlight;
17
18import org.onlab.util.Frequency;
19import org.onlab.util.Spectrum;
20import org.onosproject.net.ChannelSpacing;
21import org.onosproject.net.OchSignal;
22import org.onosproject.net.Port;
23import org.onosproject.net.PortNumber;
24import org.onosproject.net.behaviour.LambdaQuery;
25import org.onosproject.net.device.DeviceService;
26import org.onosproject.net.driver.AbstractHandlerBehaviour;
27
28import java.util.Collections;
29import java.util.Set;
30import java.util.stream.IntStream;
31import java.util.stream.Collectors;
32
33/**
34 * Implementation of lambda query interface for CzechLight ROADMs.
35 *
36 * These devices are actually fully flexgrid-capable. Same as the other devices supported by ONOS,
37 * we're just returning a dummy list of 50 GHz channels.
38 */
39public class CzechLightLambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery {
40
41 private static final Frequency START_CENTER_FREQ_50 = Frequency.ofGHz(191_350);
42 private static final Frequency END_CENTER_FREQ_50 = Frequency.ofGHz(196_100);
43
44 @Override
45 public Set<OchSignal> queryLambdas(PortNumber portNumber) {
46 DeviceService deviceService = this.handler().get(DeviceService.class);
47 Port port = deviceService.getPort(data().deviceId(), portNumber);
48
49 if ((port.type() == Port.Type.FIBER) || (port.type() == Port.Type.OMS)) {
50 final int startMultiplier50 = (int) (START_CENTER_FREQ_50.subtract(Spectrum.CENTER_FREQUENCY).asHz()
51 / Frequency.ofGHz(50).asHz());
52 final int endMultiplier50 = (int) (END_CENTER_FREQ_50.subtract(Spectrum.CENTER_FREQUENCY).asHz()
53 / Frequency.ofGHz(50).asHz());
54 return IntStream.range(startMultiplier50, endMultiplier50 + 1)
55 .mapToObj(x -> OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, x))
56 .collect(Collectors.toSet());
57 } else {
58 return Collections.emptySet();
59 }
60 }
61}
62
63