Marc De Leenheer | 118f671 | 2015-10-21 16:06:21 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Marc De Leenheer | 118f671 | 2015-10-21 16:06:21 -0700 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.net.behaviour; |
| 17 | |
Jimmy Yan | 32bceca | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 18 | import com.google.common.annotations.Beta; |
| 19 | import com.google.common.collect.Range; |
Marc De Leenheer | 118f671 | 2015-10-21 16:06:21 -0700 | [diff] [blame] | 20 | import org.onosproject.net.PortNumber; |
| 21 | import org.onosproject.net.driver.HandlerBehaviour; |
| 22 | |
Laszlo Papp | 8cd61fb | 2017-10-13 16:45:00 +0100 | [diff] [blame] | 23 | import java.util.ArrayList; |
| 24 | import java.util.List; |
Marc De Leenheer | 118f671 | 2015-10-21 16:06:21 -0700 | [diff] [blame] | 25 | import 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 Yan | 32bceca | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 36 | @Beta |
Marc De Leenheer | 118f671 | 2015-10-21 16:06:21 -0700 | [diff] [blame] | 37 | public 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 Campanella | dadf640 | 2019-08-07 15:24:11 +0200 | [diff] [blame] | 46 | Optional<Double> getTargetPower(PortNumber port, T component); |
Marc De Leenheer | 118f671 | 2015-10-21 16:06:21 -0700 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * Set the target power on the component. |
| 50 | * |
Marc De Leenheer | 118f671 | 2015-10-21 16:06:21 -0700 | [diff] [blame] | 51 | * @param port the port |
| 52 | * @param component the port component |
| 53 | * @param power target power in .01 dBm |
| 54 | */ |
Andrea Campanella | dadf640 | 2019-08-07 15:24:11 +0200 | [diff] [blame] | 55 | void setTargetPower(PortNumber port, T component, double power); |
Marc De Leenheer | 118f671 | 2015-10-21 16:06:21 -0700 | [diff] [blame] | 56 | |
| 57 | /** |
Boyuan Yan | 7bee248 | 2019-05-22 17:15:53 -0700 | [diff] [blame] | 58 | * Get the current output power on the component. |
Marc De Leenheer | 118f671 | 2015-10-21 16:06:21 -0700 | [diff] [blame] | 59 | * |
| 60 | * @param port the port |
| 61 | * @param component the port component |
| 62 | * @return power power in .01 dBm |
| 63 | */ |
Andrea Campanella | dadf640 | 2019-08-07 15:24:11 +0200 | [diff] [blame] | 64 | Optional<Double> currentPower(PortNumber port, T component); |
Jimmy Yan | 32bceca | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 65 | |
| 66 | /** |
Boyuan Yan | 7bee248 | 2019-05-22 17:15:53 -0700 | [diff] [blame] | 67 | * 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 Campanella | dadf640 | 2019-08-07 15:24:11 +0200 | [diff] [blame] | 72 | default Optional<Double> currentInputPower(PortNumber port, T component) { |
Boyuan Yan | 7bee248 | 2019-05-22 17:15:53 -0700 | [diff] [blame] | 73 | return Optional.empty(); |
| 74 | } |
| 75 | |
| 76 | /** |
Jimmy Yan | 32bceca | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 77 | * 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 Campanella | dadf640 | 2019-08-07 15:24:11 +0200 | [diff] [blame] | 85 | default Optional<Range<Double>> getTargetPowerRange(PortNumber port, T component) { |
Jimmy Yan | 32bceca | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 86 | 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 Campanella | dadf640 | 2019-08-07 15:24:11 +0200 | [diff] [blame] | 99 | default Optional<Range<Double>> getInputPowerRange(PortNumber port, T component) { |
Jimmy Yan | 32bceca | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 100 | return Optional.empty(); |
| 101 | } |
Laszlo Papp | 8cd61fb | 2017-10-13 16:45:00 +0100 | [diff] [blame] | 102 | |
| 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 Leenheer | 118f671 | 2015-10-21 16:06:21 -0700 | [diff] [blame] | 113 | } |