MaoLu | 819fde2 | 2017-04-20 17:17:49 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016 Open Networking Foundation |
MaoLu | 819fde2 | 2017-04-20 17:17:49 -0700 | [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 | |
| 17 | package org.onosproject.drivers.oplink; |
| 18 | |
| 19 | import org.onlab.util.GuavaCollectors; |
| 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.IntStream; |
| 27 | |
| 28 | import static org.onlab.util.Spectrum.CENTER_FREQUENCY; |
| 29 | import static org.onosproject.drivers.oplink.OplinkOpticalUtility.CHANNEL_SPACING; |
| 30 | import static org.onosproject.drivers.oplink.OplinkOpticalUtility.STOP_CENTER_FREQ; |
| 31 | import static org.onosproject.drivers.oplink.OplinkOpticalUtility.START_CENTER_FREQ; |
| 32 | |
| 33 | /** |
| 34 | * Lambda query implementation for Oplink netconf devices in C band. |
| 35 | * |
| 36 | * 96 lambdas with 50GHz width (fixed grid). |
| 37 | * |
| 38 | * Channel id: Nominal central frequency = 193100 GHz + spacingMultiplier * channelSpacing). |
| 39 | * Channel (-35 to 60): starting from 191350 GHz to 196100 GHz, Increment by 50GHz. |
| 40 | */ |
| 41 | public class OplinkOpticalLambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery { |
| 42 | |
| 43 | private static final int MIN_CHANNEL = (int) Math.round( |
| 44 | START_CENTER_FREQ.subtract(CENTER_FREQUENCY).asHz() / CHANNEL_SPACING.frequency().asHz()); |
| 45 | private static final int MAX_CHANNEL = (int) Math.round( |
| 46 | STOP_CENTER_FREQ.subtract(CENTER_FREQUENCY).asHz() / CHANNEL_SPACING.frequency().asHz()); |
| 47 | |
| 48 | @Override |
| 49 | public Set<OchSignal> queryLambdas(PortNumber port) { |
| 50 | return IntStream.rangeClosed(MIN_CHANNEL, MAX_CHANNEL) |
| 51 | .mapToObj(x -> OchSignal.newDwdmSlot(CHANNEL_SPACING, x)) |
| 52 | .collect(GuavaCollectors.toImmutableSet()); |
| 53 | } |
| 54 | } |