blob: d171c17d3e45c97039e72292deddfcf9051d2ec0 [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 */
46 Optional<Long> getTargetPower(PortNumber port, T component);
47
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 */
55 void setTargetPower(PortNumber port, T component, long power);
56
57 /**
58 * Get the current power on the component.
59 *
60 * @param port the port
61 * @param component the port component
62 * @return power power in .01 dBm
63 */
64 Optional<Long> currentPower(PortNumber port, T component);
Jimmy Yan32bceca2016-09-02 16:32:01 -070065
66 /**
67 * Get the acceptable target power range for setTargetPower,
68 * as optical components have different configurable output power ranges.
69 *
70 * @param port the port
71 * @param component the port component
72 * @return the accepted target power range, null if the component's power is
73 * not configurable. For example the port target power can only be set on TX ports.
74 */
75 default Optional<Range<Long>> getTargetPowerRange(PortNumber port, T component) {
76 return Optional.empty();
77 }
78
79 /**
80 * Get the expected input power range for the component,
81 * as optical components have different working input power ranges.
82 *
83 * @param port the port
84 * @param component the port component
85 * @return the expected input power range, null if the component does not have
86 * a specified input power range. For example input power range only applies
87 * to RX ports.
88 */
89 default Optional<Range<Long>> getInputPowerRange(PortNumber port, T component) {
90 return Optional.empty();
91 }
Laszlo Papp8cd61fb2017-10-13 16:45:00 +010092
93 /**
94 * Get the ports, which support {@code PowerConfig} operations for the specified
95 * {@code component}.
96 *
97 * @param component the port component
98 * @return a set of power config ports
99 */
100 default List<PortNumber> getPorts(T component) {
101 return new ArrayList<PortNumber>();
102 }
Marc De Leenheer118f6712015-10-21 16:06:21 -0700103}