blob: 8a7836b4c3502deabda5ce8b10e07b4061d35585 [file] [log] [blame]
Marc De Leenheerbb382352015-04-23 18:20:34 -07001/*
2 * Copyright 2015 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 */
16package org.onosproject.net;
17
18import org.onlab.util.Frequency;
19
20import java.util.Objects;
21
22import static com.google.common.base.MoreObjects.toStringHelper;
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070023import static com.google.common.base.Preconditions.checkNotNull;
Marc De Leenheerbb382352015-04-23 18:20:34 -070024
25/**
26 * Implementation of OCh port (Optical Channel).
27 * Also referred to as a line side port (L-port) or narrow band port.
28 * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
29 */
30public class OchPort extends DefaultPort {
31
32 public static final Frequency CENTER_FREQUENCY = Frequency.ofTHz(193.1);
33 public static final Frequency FLEX_GRID_SLOT = Frequency.ofGHz(12.5);
34
Sho SHIMIZU014c33a2015-04-30 11:40:37 -070035 private final OduSignalType signalType;
Marc De Leenheerbb382352015-04-23 18:20:34 -070036 private final boolean isTunable;
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070037 private final OchSignal lambda;
Marc De Leenheerbb382352015-04-23 18:20:34 -070038
39 /**
40 * Creates an OCh port in the specified network element.
41 *
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070042 * @param element parent network element
43 * @param number port number
44 * @param isEnabled port enabled state
45 * @param signalType ODU signal type
46 * @param isTunable maximum frequency in MHz
47 * @param lambda OCh signal
48 * @param annotations optional key/value annotations
Marc De Leenheerbb382352015-04-23 18:20:34 -070049 */
Sho SHIMIZU014c33a2015-04-30 11:40:37 -070050 public OchPort(Element element, PortNumber number, boolean isEnabled, OduSignalType signalType,
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070051 boolean isTunable, OchSignal lambda, Annotations... annotations) {
Marc De Leenheerbb382352015-04-23 18:20:34 -070052 super(element, number, isEnabled, Type.OCH, 0, annotations);
53 this.signalType = signalType;
54 this.isTunable = isTunable;
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070055 this.lambda = checkNotNull(lambda);
Marc De Leenheerbb382352015-04-23 18:20:34 -070056 }
57
58 /**
59 * Returns ODU signal type.
60 *
61 * @return ODU signal type
62 */
Sho SHIMIZU014c33a2015-04-30 11:40:37 -070063 public OduSignalType signalType() {
Marc De Leenheerbb382352015-04-23 18:20:34 -070064 return signalType;
65 }
66
67 /**
68 * Returns true if port is wavelength tunable.
69 *
70 * @return tunable wavelength capability
71 */
72 public boolean isTunable() {
73 return isTunable;
74 }
75
76 /**
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070077 * Returns OCh signal.
Marc De Leenheerbb382352015-04-23 18:20:34 -070078 *
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070079 * @return OCh signal
Marc De Leenheerbb382352015-04-23 18:20:34 -070080 */
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070081 public OchSignal lambda() {
82 return lambda;
Marc De Leenheerbb382352015-04-23 18:20:34 -070083 }
84
85 @Override
86 public int hashCode() {
Sho SHIMIZU0abceb82015-05-04 09:20:53 -070087 return Objects.hash(number(), isEnabled(), type(), signalType, isTunable, lambda, annotations());
Marc De Leenheerbb382352015-04-23 18:20:34 -070088 }
89
90 @Override
91 public boolean equals(Object obj) {
92 if (this == obj) {
93 return true;
94 }
95 if (obj instanceof OchPort) {
96 final OchPort other = (OchPort) obj;
97 return Objects.equals(this.element().id(), other.element().id()) &&
98 Objects.equals(this.number(), other.number()) &&
99 Objects.equals(this.isEnabled(), other.isEnabled()) &&
100 Objects.equals(this.signalType, other.signalType) &&
101 Objects.equals(this.isTunable, other.isTunable) &&
Sho SHIMIZU0abceb82015-05-04 09:20:53 -0700102 Objects.equals(this.lambda, other.lambda) &&
Marc De Leenheerbb382352015-04-23 18:20:34 -0700103 Objects.equals(this.annotations(), other.annotations());
104 }
105 return false;
106 }
107
108 @Override
109 public String toString() {
110 return toStringHelper(this)
111 .add("element", element().id())
112 .add("number", number())
113 .add("isEnabled", isEnabled())
114 .add("type", type())
115 .add("signalType", signalType)
116 .add("isTunable", isTunable)
Sho SHIMIZU0abceb82015-05-04 09:20:53 -0700117 .add("lambda", lambda)
Marc De Leenheerbb382352015-04-23 18:20:34 -0700118 .toString();
119 }
120}