blob: 0cda0649723878cc8ced38f3c2091df3d485148d [file] [log] [blame]
Marc De Leenheer118f6712015-10-21 16:06:21 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Marc De Leenheer118f6712015-10-21 16:06:21 -07003 *
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.net.behaviour;
17
Jimmy Yan32bceca2016-09-02 16:32:01 -070018import com.google.common.annotations.Beta;
19import com.google.common.collect.Range;
Marc De Leenheer118f6712015-10-21 16:06:21 -070020import org.onosproject.net.PortNumber;
21import org.onosproject.net.driver.HandlerBehaviour;
22
23import java.util.Optional;
24
25/**
26 * Behavior for handling port power configurations.
27 *
28 * Power operations act on a network port and a component thereof.
29 * Supported components are either the full directed port ({@link org.onosproject.net.Direction})
30 * or a wavelength on a port ({@link org.onosproject.net.OchSignal}).
31 *
32 * Power levels are specified with a long and unit .01 dBm.
33 */
Jimmy Yan32bceca2016-09-02 16:32:01 -070034@Beta
Marc De Leenheer118f6712015-10-21 16:06:21 -070035public interface PowerConfig<T> extends HandlerBehaviour {
36
37 /**
38 * Get the target power on the component.
39 *
40 * @param port the port
41 * @param component the port component
42 * @return target power in .01 dBm
43 */
44 Optional<Long> getTargetPower(PortNumber port, T component);
45
46 /**
47 * Set the target power on the component.
48 *
Marc De Leenheer118f6712015-10-21 16:06:21 -070049 * @param port the port
50 * @param component the port component
51 * @param power target power in .01 dBm
52 */
53 void setTargetPower(PortNumber port, T component, long power);
54
55 /**
56 * Get the current power on the component.
57 *
58 * @param port the port
59 * @param component the port component
60 * @return power power in .01 dBm
61 */
62 Optional<Long> currentPower(PortNumber port, T component);
Jimmy Yan32bceca2016-09-02 16:32:01 -070063
64 /**
65 * Get the acceptable target power range for setTargetPower,
66 * as optical components have different configurable output power ranges.
67 *
68 * @param port the port
69 * @param component the port component
70 * @return the accepted target power range, null if the component's power is
71 * not configurable. For example the port target power can only be set on TX ports.
72 */
73 default Optional<Range<Long>> getTargetPowerRange(PortNumber port, T component) {
74 return Optional.empty();
75 }
76
77 /**
78 * Get the expected input power range for the component,
79 * as optical components have different working input power ranges.
80 *
81 * @param port the port
82 * @param component the port component
83 * @return the expected input power range, null if the component does not have
84 * a specified input power range. For example input power range only applies
85 * to RX ports.
86 */
87 default Optional<Range<Long>> getInputPowerRange(PortNumber port, T component) {
88 return Optional.empty();
89 }
Marc De Leenheer118f6712015-10-21 16:06:21 -070090}