MaoLu | c201ae4 | 2017-02-06 17:57:01 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 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 | |
| 17 | package org.onosproject.driver.optical.power; |
| 18 | |
MaoLu | c201ae4 | 2017-02-06 17:57:01 -0800 | [diff] [blame] | 19 | import java.util.Optional; |
| 20 | |
| 21 | import com.google.common.collect.Range; |
| 22 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
MaoLu | c201ae4 | 2017-02-06 17:57:01 -0800 | [diff] [blame] | 23 | import org.onosproject.net.PortNumber; |
| 24 | import org.onosproject.net.behaviour.PowerConfig; |
MaoLu | c201ae4 | 2017-02-06 17:57:01 -0800 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * Port Power (Gain and attenuation) implementation for Oplink EDFA device. |
| 28 | * |
| 29 | * An Oplink EDFA port exposes Direction resources. |
| 30 | * Set gain(attenuation) at AGC mode or set output level at APC mode. |
| 31 | * |
| 32 | */ |
| 33 | |
| 34 | public class OplinkEdfaPowerConfig extends AbstractHandlerBehaviour |
| 35 | implements PowerConfig<Object> { |
| 36 | |
Mao Lu | 1f52470 | 2017-02-22 17:05:12 +0800 | [diff] [blame^] | 37 | // oplink power config utility |
| 38 | private OplinkPowerConfigUtil oplinkUtil = new OplinkPowerConfigUtil(this); |
MaoLu | c201ae4 | 2017-02-06 17:57:01 -0800 | [diff] [blame] | 39 | |
| 40 | @Override |
Mao Lu | 1f52470 | 2017-02-22 17:05:12 +0800 | [diff] [blame^] | 41 | public Optional<Long> getTargetPower(PortNumber port, Object component) { |
| 42 | return Optional.ofNullable(oplinkUtil.getTargetPower(port, component)); |
MaoLu | c201ae4 | 2017-02-06 17:57:01 -0800 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | @Override |
Mao Lu | 1f52470 | 2017-02-22 17:05:12 +0800 | [diff] [blame^] | 46 | public Optional<Long> currentPower(PortNumber port, Object component) { |
| 47 | return Optional.ofNullable(oplinkUtil.getCurrentPower(port, component)); |
MaoLu | c201ae4 | 2017-02-06 17:57:01 -0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | @Override |
Mao Lu | 1f52470 | 2017-02-22 17:05:12 +0800 | [diff] [blame^] | 51 | public void setTargetPower(PortNumber port, Object component, long power) { |
| 52 | oplinkUtil.setTargetPower(port, component, power); |
MaoLu | c201ae4 | 2017-02-06 17:57:01 -0800 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public Optional<Range<Long>> getTargetPowerRange(PortNumber port, Object component) { |
Mao Lu | 1f52470 | 2017-02-22 17:05:12 +0800 | [diff] [blame^] | 57 | return Optional.ofNullable(oplinkUtil.getTargetPowerRange(port, component)); |
MaoLu | c201ae4 | 2017-02-06 17:57:01 -0800 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public Optional<Range<Long>> getInputPowerRange(PortNumber port, Object component) { |
Mao Lu | 1f52470 | 2017-02-22 17:05:12 +0800 | [diff] [blame^] | 62 | return Optional.ofNullable(oplinkUtil.getInputPowerRange(port, component)); |
MaoLu | c201ae4 | 2017-02-06 17:57:01 -0800 | [diff] [blame] | 63 | } |
| 64 | } |