blob: 838955b7995b7e988fa9a9c5f6d1694a8bfad8b2 [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
18import org.onosproject.net.ChannelSpacing;
19import org.onosproject.net.OchSignal;
Rimon Ashkenazye3201032016-01-11 14:27:30 +020020import org.onosproject.net.Port;
21import org.onosproject.net.PortNumber;
22import org.onosproject.net.behaviour.LambdaQuery;
23import org.onosproject.net.device.DeviceService;
24import org.onosproject.net.driver.AbstractHandlerBehaviour;
HIGUCHI Yuta95d83e82016-04-26 12:13:48 -070025import org.onosproject.net.optical.OmsPort;
26
27import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView;
Rimon Ashkenazye3201032016-01-11 14:27:30 +020028
29import java.util.Collections;
30import java.util.Set;
31import java.util.stream.Collectors;
32import 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
55 if (!p.type().equals(Port.Type.OMS)) {
56 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))
63 .collect(Collectors.toSet());
64 }
65}