blob: 4538258fae771e495d89ac7df1f81386a68ece6e [file] [log] [blame]
MaoLuc201ae42017-02-06 17:57:01 -08001/*
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
17package org.onosproject.driver.optical.power;
18
MaoLuc201ae42017-02-06 17:57:01 -080019import java.util.Optional;
20
21import com.google.common.collect.Range;
22import org.onosproject.net.driver.AbstractHandlerBehaviour;
MaoLuc201ae42017-02-06 17:57:01 -080023import org.onosproject.net.PortNumber;
24import org.onosproject.net.behaviour.PowerConfig;
MaoLuc201ae42017-02-06 17:57:01 -080025
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
34public class OplinkEdfaPowerConfig extends AbstractHandlerBehaviour
35 implements PowerConfig<Object> {
36
Mao Lu1f524702017-02-22 17:05:12 +080037 // oplink power config utility
38 private OplinkPowerConfigUtil oplinkUtil = new OplinkPowerConfigUtil(this);
MaoLuc201ae42017-02-06 17:57:01 -080039
40 @Override
Mao Lu1f524702017-02-22 17:05:12 +080041 public Optional<Long> getTargetPower(PortNumber port, Object component) {
42 return Optional.ofNullable(oplinkUtil.getTargetPower(port, component));
MaoLuc201ae42017-02-06 17:57:01 -080043 }
44
45 @Override
Mao Lu1f524702017-02-22 17:05:12 +080046 public Optional<Long> currentPower(PortNumber port, Object component) {
47 return Optional.ofNullable(oplinkUtil.getCurrentPower(port, component));
MaoLuc201ae42017-02-06 17:57:01 -080048 }
49
50 @Override
Mao Lu1f524702017-02-22 17:05:12 +080051 public void setTargetPower(PortNumber port, Object component, long power) {
52 oplinkUtil.setTargetPower(port, component, power);
MaoLuc201ae42017-02-06 17:57:01 -080053 }
54
55 @Override
56 public Optional<Range<Long>> getTargetPowerRange(PortNumber port, Object component) {
Mao Lu1f524702017-02-22 17:05:12 +080057 return Optional.ofNullable(oplinkUtil.getTargetPowerRange(port, component));
MaoLuc201ae42017-02-06 17:57:01 -080058 }
59
60 @Override
61 public Optional<Range<Long>> getInputPowerRange(PortNumber port, Object component) {
Mao Lu1f524702017-02-22 17:05:12 +080062 return Optional.ofNullable(oplinkUtil.getInputPowerRange(port, component));
MaoLuc201ae42017-02-06 17:57:01 -080063 }
64}