blob: f01a266e5cc48fc3dc0a65cb8b7bf41f99a98351 [file] [log] [blame]
Rimon Ashkenazye3201032016-01-11 14:27:30 +02001/*
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 */
16package org.onosproject.driver.query;
17
18import org.onosproject.net.ChannelSpacing;
19import org.onosproject.net.OchSignal;
20import org.onosproject.net.OmsPort;
21import 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;
26
27import java.util.Collections;
28import java.util.Set;
29import java.util.stream.Collectors;
30import 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
45public 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}