Marc De Leenheer | 118f671 | 2015-10-21 16:06:21 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
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 | |
| 23 | import 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 Yan | 32bceca | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 34 | @Beta |
Marc De Leenheer | 118f671 | 2015-10-21 16:06:21 -0700 | [diff] [blame] | 35 | public 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 Leenheer | 118f671 | 2015-10-21 16:06:21 -0700 | [diff] [blame] | 49 | * @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 Yan | 32bceca | 2016-09-02 16:32:01 -0700 | [diff] [blame] | 63 | |
| 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 Leenheer | 118f671 | 2015-10-21 16:06:21 -0700 | [diff] [blame] | 90 | } |