blob: b180f329196badd56d5752a8a1380a6046b93780 [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.onosproject.net.ChannelSpacing;
19import org.onosproject.net.GridType;
20import org.onosproject.net.OchSignal;
21import org.onosproject.net.Port;
22import org.onosproject.net.PortNumber;
23import org.onosproject.net.behaviour.LambdaQuery;
24import org.onosproject.net.device.DeviceService;
25import org.onosproject.net.driver.AbstractHandlerBehaviour;
26
27import java.util.Collections;
28import java.util.Set;
29import java.util.stream.Collectors;
30import java.util.stream.IntStream;
31
32/**
33 * Lambda query implementation for LINC-OE Optical Emulator switch.
34 *
35 * The LINC ROADM emulator exposes two types of ports: OCh ports connect to ports in the packet layer,
36 * while OMS ports connect to an OMS port on a neighbouring ROADM.
37 *
38 * LINC exposes OchSignal resources: 80 lambdas of 50 GHz (fixed grid) around ITU-T G.694.1 center frequency 193.1 GHz.
39 */
40
41public class LincOELambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery {
42
43 private static final int LAMBDA_COUNT = 80;
44
45 @Override
46 public Set<OchSignal> queryLambdas(PortNumber port) {
47 DeviceService deviceService = this.handler().get(DeviceService.class);
48 Port p = deviceService.getPort(this.data().deviceId(), port);
49
50 // OCh ports don't expose lambda resources
51 if (!p.type().equals(Port.Type.OMS)) {
52 return Collections.emptySet();
53 }
54
55 // OMS ports expose 80 fixed grid lambdas of 50GHz width, centered around the ITU-T center frequency 193.1 THz.
56 return IntStream.range(0, LAMBDA_COUNT)
57 .mapToObj(x -> new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, x - (LAMBDA_COUNT / 2), 4))
58 .collect(Collectors.toSet());
59 }
60}