blob: 6bd4574ddc8638881326564150230e7a8d3d788d [file] [log] [blame]
Rimon Ashkenazye3201032016-01-11 14:27:30 +02001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Rimon Ashkenazye3201032016-01-11 14:27:30 +02003 *
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 */
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070016package org.onosproject.driver.optical.query;
Rimon Ashkenazye3201032016-01-11 14:27:30 +020017
Yuta HIGUCHIedd932f2017-03-11 13:47:41 -080018import org.onlab.util.GuavaCollectors;
Rimon Ashkenazye3201032016-01-11 14:27:30 +020019import org.onosproject.net.ChannelSpacing;
20import org.onosproject.net.OchSignal;
Rimon Ashkenazye3201032016-01-11 14:27:30 +020021import org.onosproject.net.Port;
22import org.onosproject.net.PortNumber;
23import org.onosproject.net.behaviour.LambdaQuery;
24import org.onosproject.net.device.DeviceService;
25import org.onosproject.net.driver.AbstractHandlerBehaviour;
HIGUCHI Yuta95d83e82016-04-26 12:13:48 -070026import org.onosproject.net.optical.OmsPort;
27
28import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView;
Rimon Ashkenazye3201032016-01-11 14:27:30 +020029
30import java.util.Collections;
31import java.util.Set;
Rimon Ashkenazye3201032016-01-11 14:27:30 +020032import java.util.stream.IntStream;
33
34/**
35 * Lambda query implementation for OFOpticalSwitch13.
36 *
37 * Note: Standard (ONF TS-022, March 15, 2015) does not support negative values for spacingMultiplier in exp_OCH_sigid.
38 * Thus, Lambda values cannot be calculated using center and spacingMultiplier of +/- values.
39 * Therefore, Lambda values are calculated with positive values only: starting from min-frequency of 191.7 THz.
40 *
41 * TODO: When standard is fixed - modify queryLambdas accordingly.
42 *
43 * OFOpticalSwitch13 exposes OchSignal resources: 'lambdaCount' lambdas with 50GHz width (fixed grid)
44 * starting from min-frequency of 191.7 THz.
45 */
46
47public class OFOpticalSwitch13LambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery {
48
49 @Override
50 public Set<OchSignal> queryLambdas(PortNumber port) {
HIGUCHI Yuta95d83e82016-04-26 12:13:48 -070051 DeviceService deviceService = opticalView(this.handler().get(DeviceService.class));
Rimon Ashkenazye3201032016-01-11 14:27:30 +020052 Port p = deviceService.getPort(this.data().deviceId(), port);
53
54 // Only OMS ports expose lambda resources
Yuta HIGUCHI62f80182016-06-28 13:27:53 -070055 if (p == null || !p.type().equals(Port.Type.OMS)) {
Rimon Ashkenazye3201032016-01-11 14:27:30 +020056 return Collections.emptySet();
57 }
58
59 short lambdaCount = ((OmsPort) p).totalChannels();
60 // OMS ports expose 'lambdaCount' fixed grid lambdas of 50GHz width, starting from min-frequency 191.7 THz.
61 return IntStream.rangeClosed(1, lambdaCount)
62 .mapToObj(x -> OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, x))
Yuta HIGUCHIedd932f2017-03-11 13:47:41 -080063 .collect(GuavaCollectors.toImmutableSet());
Rimon Ashkenazye3201032016-01-11 14:27:30 +020064 }
65}