blob: bf7892999edb56bd9dcbbb72c8adaf22a9252191 [file] [log] [blame]
Ramon Casellas99c16252019-05-31 14:29:00 +02001/*
2 * Copyright 2018-present Open Networking Foundation
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 * This work was partially supported by EC H2020 project METRO-HAUL (761727).
17 */
18package org.onosproject.drivers.odtn.openroadm;
19
20import org.onlab.util.Frequency;
21
22
23public class OpenRoadmMcInterface extends OpenRoadmInterface {
24
25 protected Frequency mcMinFrequency; // expressed in Thz
26 protected Frequency mcMaxFrequency; // expressed in Thz
27
28 public String toString() {
29 StringBuilder sb = new StringBuilder();
30 sb.append("<interface>");
31 sb.append("<name>" + name + "</name>");
32 sb.append("<description>Media-Channel</description>");
33 sb.append("<type xmlns:openROADM-if=\"http://org/openroadm/interfaces\">"
34 + "openROADM-if:mediaChannelTrailTerminationPoint</type>");
35 sb.append("<administrative-state>inService</administrative-state>");
36 sb.append("<supporting-circuit-pack-name>" + supportingCircuitPack +
37 "</supporting-circuit-pack-name>");
38 sb.append("<supporting-port>" + supportingPort + "</supporting-port>");
39 if (!supportingInterface.isEmpty()) {
40 sb.append("<supporting-interface>" + supportingInterface +
41 "</supporting-interface>");
42 }
43 sb.append("<mc-ttp xmlns=\"http://org/openroadm/media-channel-interfaces\">");
44 sb.append("<min-freq>" + mcMinFrequency.asTHz() + "</min-freq>");
45 sb.append("<max-freq>" + mcMaxFrequency.asTHz() + "</max-freq>");
46 sb.append("</mc-ttp>");
47 sb.append("</interface>");
48
49 return sb.toString();
50 }
51
52 public abstract static class Builder<T extends Builder<T>>
53 extends OpenRoadmInterface.Builder<T> {
54
55 protected Frequency mcMinFrequency; // expressed in Thz
56 protected Frequency mcMaxFrequency; // expressed in Thz
57
58 public T mcMinFrequency(Frequency mcMinFrequency) {
59 this.mcMinFrequency = mcMinFrequency;
60 return self();
61 }
62
63 public T mcMaxFrequency(Frequency mcMaxFrequency) {
64 this.mcMaxFrequency = mcMaxFrequency;
65 return self();
66 }
67 }
68
69 private static class Builder2 extends Builder<Builder2> {
70 @Override
71 protected Builder2 self() {
72 return this;
73 }
74 }
75
76 public static Builder<?> builder() {
77 return new Builder2();
78 }
79
80
81 protected OpenRoadmMcInterface(Builder<?> builder) {
82 super(builder);
83 this.mcMinFrequency = builder.mcMinFrequency;
84 this.mcMaxFrequency = builder.mcMaxFrequency;
85 }
86}