Alessio Giorgetti | 648b538 | 2018-02-15 18:35:45 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Foundation |
| 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; |
Alessio Giorgetti | 648b538 | 2018-02-15 18:35:45 +0100 | [diff] [blame] | 20 | import org.onosproject.net.GridType; |
alessio | 1bf2a63 | 2019-06-04 15:47:39 +0200 | [diff] [blame] | 21 | import org.onosproject.net.ChannelSpacing; |
Alessio Giorgetti | 648b538 | 2018-02-15 18:35:45 +0100 | [diff] [blame] | 22 | import org.onosproject.net.OchSignal; |
alessio | 1bf2a63 | 2019-06-04 15:47:39 +0200 | [diff] [blame] | 23 | import org.onosproject.net.Port; |
Alessio Giorgetti | 648b538 | 2018-02-15 18:35:45 +0100 | [diff] [blame] | 24 | import org.onosproject.net.PortNumber; |
| 25 | import org.onosproject.net.behaviour.LambdaQuery; |
alessio | 1bf2a63 | 2019-06-04 15:47:39 +0200 | [diff] [blame] | 26 | import org.onosproject.net.device.DeviceService; |
Alessio Giorgetti | 648b538 | 2018-02-15 18:35:45 +0100 | [diff] [blame] | 27 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
| 28 | |
alessio | 1bf2a63 | 2019-06-04 15:47:39 +0200 | [diff] [blame] | 29 | import java.util.Collections; |
Alessio Giorgetti | 648b538 | 2018-02-15 18:35:45 +0100 | [diff] [blame] | 30 | import java.util.Set; |
| 31 | import java.util.stream.IntStream; |
| 32 | import java.util.stream.Collectors; |
Alessio Giorgetti | 648b538 | 2018-02-15 18:35:45 +0100 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * Implementation of lambda query interface for Lumentum ROADMs. |
| 36 | * |
| 37 | * Tested on both Lumentum SDN ROADM and Lumentum ROADM-A Whitebox. |
| 38 | * |
| 39 | * 96 OchSignals of 50 GHz, center frequencies range 191.350 - 196.100 THz. |
| 40 | * 48 OchSignals of 100 GHz, center frequencies 191.375 - 196.075 THz |
| 41 | */ |
| 42 | public class LumentumRoadmLambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery { |
| 43 | |
| 44 | |
| 45 | public static final GridType GRID_TYPE = GridType.DWDM; |
| 46 | |
| 47 | public static final ChannelSpacing CHANNEL_SPACING_50 = ChannelSpacing.CHL_50GHZ; |
| 48 | public static final Frequency START_CENTER_FREQ_50 = Frequency.ofGHz(191_350); |
| 49 | public static final Frequency END_CENTER_FREQ_50 = Frequency.ofGHz(196_100); |
| 50 | private static final int LAMBDA_COUNT_50 = 96; |
| 51 | |
| 52 | public static final ChannelSpacing CHANNEL_SPACING_100 = ChannelSpacing.CHL_100GHZ; |
| 53 | public static final Frequency START_CENTER_FREQ_100 = Frequency.ofGHz(191_375); |
| 54 | public static final Frequency END_CENTER_FREQ_100 = Frequency.ofGHz(196_075); |
| 55 | private static final int LAMBDA_COUNT_100 = 48; |
| 56 | |
| 57 | @Override |
alessio | 1bf2a63 | 2019-06-04 15:47:39 +0200 | [diff] [blame] | 58 | public Set<OchSignal> queryLambdas(PortNumber portNumber) { |
| 59 | DeviceService deviceService = this.handler().get(DeviceService.class); |
| 60 | Port port = deviceService.getPort(data().deviceId(), portNumber); |
Alessio Giorgetti | 648b538 | 2018-02-15 18:35:45 +0100 | [diff] [blame] | 61 | |
alessio | 1bf2a63 | 2019-06-04 15:47:39 +0200 | [diff] [blame] | 62 | if (port.type() == Port.Type.FIBER) { |
Alessio Giorgetti | 648b538 | 2018-02-15 18:35:45 +0100 | [diff] [blame] | 63 | |
alessio | 1bf2a63 | 2019-06-04 15:47:39 +0200 | [diff] [blame] | 64 | //Complete set of 50GHz OchSignal |
| 65 | int startMultiplier50 = (int) (START_CENTER_FREQ_50.subtract(Spectrum.CENTER_FREQUENCY).asHz() |
| 66 | / Frequency.ofGHz(50).asHz()); |
Alessio Giorgetti | 648b538 | 2018-02-15 18:35:45 +0100 | [diff] [blame] | 67 | |
alessio | 1bf2a63 | 2019-06-04 15:47:39 +0200 | [diff] [blame] | 68 | Set<OchSignal> channels50 = IntStream.range(0, LAMBDA_COUNT_50) |
| 69 | .mapToObj(x -> new OchSignal(GRID_TYPE, CHANNEL_SPACING_50, |
| 70 | startMultiplier50 + x, |
| 71 | 4)) |
| 72 | .collect(Collectors.toSet()); |
| 73 | |
| 74 | /*//Complete set of 100GHz OchSignal |
Alessio Giorgetti | 648b538 | 2018-02-15 18:35:45 +0100 | [diff] [blame] | 75 | int startMultiplier100 = (int) (START_CENTER_FREQ_100.subtract(Spectrum.CENTER_FREQUENCY).asHz() |
| 76 | / Frequency.ofGHz(100).asHz()); |
| 77 | |
| 78 | Set<OchSignal> channels100 = IntStream.range(0, LAMBDA_COUNT_100) |
| 79 | .mapToObj(x -> new OchSignal(GRID_TYPE, |
| 80 | CHANNEL_SPACING_100, startMultiplier100 + x, 8)) |
| 81 | .collect(Collectors.toSet()); |
| 82 | |
alessio | 1bf2a63 | 2019-06-04 15:47:39 +0200 | [diff] [blame] | 83 | Set<OchSignal> channels = Sets.union(channels50, channels100);*/ |
Alessio Giorgetti | 648b538 | 2018-02-15 18:35:45 +0100 | [diff] [blame] | 84 | |
alessio | 1bf2a63 | 2019-06-04 15:47:39 +0200 | [diff] [blame] | 85 | return channels50; |
| 86 | } else { |
| 87 | return Collections.emptySet(); |
| 88 | } |
Alessio Giorgetti | 648b538 | 2018-02-15 18:35:45 +0100 | [diff] [blame] | 89 | } |
| 90 | } |
| 91 | |
| 92 | |