Marc De Leenheer | c662d32 | 2016-02-18 16:05:10 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Marc De Leenheer | c662d32 | 2016-02-18 16:05:10 -0800 | [diff] [blame] | 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.drivers.lumentum; |
| 17 | |
| 18 | import org.onlab.util.Frequency; |
| 19 | import org.onlab.util.Spectrum; |
| 20 | import org.onosproject.net.OchSignal; |
| 21 | import org.onosproject.net.PortNumber; |
| 22 | import org.onosproject.net.behaviour.LambdaQuery; |
| 23 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
| 24 | |
| 25 | import java.util.Set; |
| 26 | import java.util.stream.Collectors; |
| 27 | import java.util.stream.IntStream; |
| 28 | |
| 29 | /** |
| 30 | * Implementation of lambda query interface for Lumentum SDN ROADMs. |
| 31 | * |
| 32 | * Device supports 96 wavelengths of 50 GHz, between center frequencies 191.350 THz and 196.075 THz. |
| 33 | */ |
Marc De Leenheer | 57a5af0 | 2016-12-02 20:54:41 -0800 | [diff] [blame] | 34 | public class LumentumSdnRoadmLambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery { |
Marc De Leenheer | c662d32 | 2016-02-18 16:05:10 -0800 | [diff] [blame] | 35 | private static final int LAMBDA_COUNT = 96; |
| 36 | |
| 37 | @Override |
| 38 | public Set<OchSignal> queryLambdas(PortNumber port) { |
| 39 | int startMultiplier = (int) (LumentumSnmpDevice.START_CENTER_FREQ.subtract(Spectrum.CENTER_FREQUENCY).asHz() |
| 40 | / Frequency.ofGHz(50).asHz()); |
| 41 | |
| 42 | return IntStream.range(0, LAMBDA_COUNT) |
| 43 | .mapToObj(x -> new OchSignal(LumentumSnmpDevice.GRID_TYPE, |
| 44 | LumentumSnmpDevice.CHANNEL_SPACING, |
| 45 | startMultiplier + x, |
| 46 | 4)) |
| 47 | .collect(Collectors.toSet()); |
| 48 | } |
| 49 | } |