Rimon Ashkenazy | e320103 | 2016-01-11 14:27:30 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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.OchSignal; |
| 20 | import org.onosproject.net.OmsPort; |
| 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 OFOpticalSwitch13. |
| 34 | * |
| 35 | * Note: Standard (ONF TS-022, March 15, 2015) does not support negative values for spacingMultiplier in exp_OCH_sigid. |
| 36 | * Thus, Lambda values cannot be calculated using center and spacingMultiplier of +/- values. |
| 37 | * Therefore, Lambda values are calculated with positive values only: starting from min-frequency of 191.7 THz. |
| 38 | * |
| 39 | * TODO: When standard is fixed - modify queryLambdas accordingly. |
| 40 | * |
| 41 | * OFOpticalSwitch13 exposes OchSignal resources: 'lambdaCount' lambdas with 50GHz width (fixed grid) |
| 42 | * starting from min-frequency of 191.7 THz. |
| 43 | */ |
| 44 | |
| 45 | public class OFOpticalSwitch13LambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery { |
| 46 | |
| 47 | @Override |
| 48 | public Set<OchSignal> queryLambdas(PortNumber port) { |
| 49 | DeviceService deviceService = this.handler().get(DeviceService.class); |
| 50 | Port p = deviceService.getPort(this.data().deviceId(), port); |
| 51 | |
| 52 | // Only OMS ports expose lambda resources |
| 53 | if (!p.type().equals(Port.Type.OMS)) { |
| 54 | return Collections.emptySet(); |
| 55 | } |
| 56 | |
| 57 | short lambdaCount = ((OmsPort) p).totalChannels(); |
| 58 | // OMS ports expose 'lambdaCount' fixed grid lambdas of 50GHz width, starting from min-frequency 191.7 THz. |
| 59 | return IntStream.rangeClosed(1, lambdaCount) |
| 60 | .mapToObj(x -> OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, x)) |
| 61 | .collect(Collectors.toSet()); |
| 62 | } |
| 63 | } |