Marc De Leenheer | 622861d | 2015-12-15 22:52:52 -0800 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.driver.query; |
| 17 | |
| 18 | import org.onosproject.net.ChannelSpacing; |
| 19 | import org.onosproject.net.GridType; |
| 20 | import org.onosproject.net.OchSignal; |
| 21 | import org.onosproject.net.Port; |
| 22 | import org.onosproject.net.PortNumber; |
| 23 | import org.onosproject.net.behaviour.LambdaQuery; |
| 24 | import org.onosproject.net.device.DeviceService; |
| 25 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
| 26 | |
| 27 | import java.util.Collections; |
| 28 | import java.util.Set; |
| 29 | import java.util.stream.Collectors; |
| 30 | import 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 | |
| 41 | public 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 | } |