blob: 7e04198d61f4bc03aecbe6e7484677b5c97b8fb4 [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
Laszlo Papp8cd61fb2017-10-13 16:45:00 +010023import java.util.ArrayList;
24import java.util.List;
Marc De Leenheer118f6712015-10-21 16:06:21 -070025import java.util.Optional;
26
27/**
28 * Behavior for handling port power configurations.
29 *
30 * Power operations act on a network port and a component thereof.
31 * Supported components are either the full directed port ({@link org.onosproject.net.Direction})
32 * or a wavelength on a port ({@link org.onosproject.net.OchSignal}).
33 *
34 * Power levels are specified with a long and unit .01 dBm.
35 */
Jimmy Yan32bceca2016-09-02 16:32:01 -070036@Beta
Marc De Leenheer118f6712015-10-21 16:06:21 -070037public interface PowerConfig<T> extends HandlerBehaviour {
38
39 /**
40 * Get the target power on the component.
41 *
42 * @param port the port
43 * @param component the port component
44 * @return target power in .01 dBm
45 */
Andrea Campanelladadf6402019-08-07 15:24:11 +020046 Optional<Double> getTargetPower(PortNumber port, T component);
Marc De Leenheer118f6712015-10-21 16:06:21 -070047
48 /**
49 * Set the target power on the component.
50 *
Marc De Leenheer118f6712015-10-21 16:06:21 -070051 * @param port the port
52 * @param component the port component
53 * @param power target power in .01 dBm
54 */
Andrea Campanelladadf6402019-08-07 15:24:11 +020055 void setTargetPower(PortNumber port, T component, double power);
Marc De Leenheer118f6712015-10-21 16:06:21 -070056
57 /**
Boyuan Yan7bee2482019-05-22 17:15:53 -070058 * Get the current output power on the component.
Marc De Leenheer118f6712015-10-21 16:06:21 -070059 *
60 * @param port the port
61 * @param component the port component
62 * @return power power in .01 dBm
63 */
Andrea Campanelladadf6402019-08-07 15:24:11 +020064 Optional<Double> currentPower(PortNumber port, T component);
Jimmy Yan32bceca2016-09-02 16:32:01 -070065
66 /**
Boyuan Yan7bee2482019-05-22 17:15:53 -070067 * Get the current input power on the component.
68 * @param port the port
69 * @param component the port component
70 * @return power in .01 dBm
71 */
Andrea Campanelladadf6402019-08-07 15:24:11 +020072 default Optional<Double> currentInputPower(PortNumber port, T component) {
Boyuan Yan7bee2482019-05-22 17:15:53 -070073 return Optional.empty();
74 }
75
76 /**
Jimmy Yan32bceca2016-09-02 16:32:01 -070077 * Get the acceptable target power range for setTargetPower,
78 * as optical components have different configurable output power ranges.
79 *
80 * @param port the port
81 * @param component the port component
82 * @return the accepted target power range, null if the component's power is
83 * not configurable. For example the port target power can only be set on TX ports.
84 */
Andrea Campanelladadf6402019-08-07 15:24:11 +020085 default Optional<Range<Double>> getTargetPowerRange(PortNumber port, T component) {
Jimmy Yan32bceca2016-09-02 16:32:01 -070086 return Optional.empty();
87 }
88
89 /**
90 * Get the expected input power range for the component,
91 * as optical components have different working input power ranges.
92 *
93 * @param port the port
94 * @param component the port component
95 * @return the expected input power range, null if the component does not have
96 * a specified input power range. For example input power range only applies
97 * to RX ports.
98 */
Andrea Campanelladadf6402019-08-07 15:24:11 +020099 default Optional<Range<Double>> getInputPowerRange(PortNumber port, T component) {
Jimmy Yan32bceca2016-09-02 16:32:01 -0700100 return Optional.empty();
101 }
Laszlo Papp8cd61fb2017-10-13 16:45:00 +0100102
103 /**
104 * Get the ports, which support {@code PowerConfig} operations for the specified
105 * {@code component}.
106 *
107 * @param component the port component
108 * @return a set of power config ports
109 */
110 default List<PortNumber> getPorts(T component) {
111 return new ArrayList<PortNumber>();
112 }
Marc De Leenheer118f6712015-10-21 16:06:21 -0700113}