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.onlab.util.Spectrum; |
| 19 | import org.onosproject.net.ChannelSpacing; |
| 20 | import org.onosproject.net.GridType; |
| 21 | import org.onosproject.net.OchSignal; |
| 22 | import org.onosproject.net.PortNumber; |
| 23 | import org.onosproject.net.behaviour.LambdaQuery; |
| 24 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
| 25 | |
| 26 | import java.util.Set; |
| 27 | import java.util.stream.Collectors; |
| 28 | import java.util.stream.IntStream; |
| 29 | |
| 30 | /** |
| 31 | * Lambda query implementation for Calient S160 and S320 Optical Circuit Switch. |
| 32 | * |
| 33 | * The device consists of OMS ports only, and each port exposes lambda resources covering the whole |
| 34 | * usable optical spectrum (U to O band, see {@link Spectrum} for spectrum definitions). |
| 35 | */ |
| 36 | public class CalientLambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery { |
| 37 | |
| 38 | @Override |
| 39 | public Set<OchSignal> queryLambdas(PortNumber port) { |
| 40 | // S160 data sheet |
| 41 | // Wavelength range: 1260 - 1630 nm |
| 42 | long startSpacingMultiplier = Spectrum.U_BAND_MIN.subtract(Spectrum.CENTER_FREQUENCY).asHz() / |
| 43 | ChannelSpacing.CHL_12P5GHZ.frequency().asHz(); |
| 44 | long stopSpacingMultiplier = Spectrum.O_BAND_MAX.subtract(Spectrum.CENTER_FREQUENCY).asHz() / |
| 45 | ChannelSpacing.CHL_12P5GHZ.frequency().asHz(); |
| 46 | |
| 47 | // Only consider odd values for the multiplier (for easy mapping to fixed grid) |
| 48 | return IntStream.rangeClosed((int) startSpacingMultiplier, (int) stopSpacingMultiplier) |
| 49 | .filter(i -> i % 2 == 1) |
| 50 | .mapToObj(i -> new OchSignal(GridType.FLEX, ChannelSpacing.CHL_6P25GHZ, i, 1)) |
| 51 | .collect(Collectors.toSet()); |
| 52 | } |
| 53 | } |