blob: 49041687a4958960e2c78d6de3582be2024a2ad3 [file] [log] [blame]
yjimmyy646aa022016-07-05 12:09:50 -07001/*
Brian O'Connor0a4e6742016-09-15 23:03:10 -07002 * Copyright 2016-present Open Networking Laboratory
yjimmyy646aa022016-07-05 12:09:50 -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 */
16
17package org.onosproject.driver.optical.power;
18
19import java.util.Optional;
20
Jimmy Yan32bceca2016-09-02 16:32:01 -070021import com.google.common.collect.Range;
yjimmyy646aa022016-07-05 12:09:50 -070022import org.onosproject.net.driver.AbstractHandlerBehaviour;
yjimmyy646aa022016-07-05 12:09:50 -070023import org.onosproject.net.PortNumber;
24import org.onosproject.net.behaviour.PowerConfig;
yjimmyy646aa022016-07-05 12:09:50 -070025
26/**
Jimmy Yan32bceca2016-09-02 16:32:01 -070027 * Port Power (Gain and attenuation) implementation for Oplink 1-SLOT-8D ROADM.
yjimmyy646aa022016-07-05 12:09:50 -070028 *
29 * An Oplink ROADM port exposes OchSignal resources.
30 * Optical Power can be set at port level or channel/wavelength level (attenuation).
31 *
32 */
33
34public class OplinkRoadmPowerConfig extends AbstractHandlerBehaviour
yjimmyycfcb0532016-07-11 16:03:48 -070035 implements PowerConfig<Object> {
36
Mao Lu1f524702017-02-22 17:05:12 +080037 // oplink power config utility
38 private OplinkPowerConfigUtil oplinkUtil = new OplinkPowerConfigUtil(this);
Jimmy Yan32bceca2016-09-02 16:32:01 -070039
Mao Lu1f524702017-02-22 17:05:12 +080040 @Override
41 public Optional<Long> getTargetPower(PortNumber port, Object component) {
42 return Optional.ofNullable(oplinkUtil.getTargetPower(port, component));
yjimmyy646aa022016-07-05 12:09:50 -070043 }
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));
yjimmyy646aa022016-07-05 12:09:50 -070048 }
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);
yjimmyy646aa022016-07-05 12:09:50 -070053 }
yjimmyycfcb0532016-07-11 16:03:48 -070054
Jimmy Yan32bceca2016-09-02 16:32:01 -070055 @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));
Jimmy Yan32bceca2016-09-02 16:32:01 -070058 }
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));
Jimmy Yan32bceca2016-09-02 16:32:01 -070063 }
yjimmyy646aa022016-07-05 12:09:50 -070064}