Marc De Leenheer | bb38235 | 2015-04-23 18:20:34 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.net.device; |
| 17 | |
| 18 | import com.google.common.base.MoreObjects; |
| 19 | import org.onosproject.net.OchPort; |
| 20 | import org.onosproject.net.Port; |
| 21 | import org.onosproject.net.PortNumber; |
| 22 | import org.onosproject.net.SparseAnnotations; |
| 23 | |
| 24 | /** |
| 25 | * Default implementation of immutable OCh port description. |
| 26 | */ |
| 27 | public class OchPortDescription extends DefaultPortDescription { |
| 28 | |
| 29 | private final OchPort.SignalType signalType; |
| 30 | private final boolean isTunable; |
| 31 | private final OchPort.GridType gridType; |
| 32 | private final OchPort.ChannelSpacing channelSpacing; |
| 33 | // Frequency = 193.1 THz + spacingMultiplier * channelSpacing |
| 34 | private final int spacingMultiplier; |
| 35 | // Slot width = slotGranularity * 12.5 GHz |
| 36 | private final int slotGranularity; |
| 37 | |
| 38 | /** |
| 39 | * Creates OCH port description based on the supplied information. |
| 40 | * |
| 41 | * @param number port number |
| 42 | * @param isEnabled port enabled state |
| 43 | * @param signalType ODU signal type |
| 44 | * @param isTunable tunable wavelength capability |
| 45 | * @param gridType grid type |
| 46 | * @param channelSpacing channel spacing |
| 47 | * @param spacingMultiplier channel spacing multiplier |
| 48 | * @param slotGranularity slow width granularity |
| 49 | * @param annotations optional key/value annotations map |
| 50 | */ |
| 51 | public OchPortDescription(PortNumber number, boolean isEnabled, OchPort.SignalType signalType, |
| 52 | boolean isTunable, OchPort.GridType gridType, |
| 53 | OchPort.ChannelSpacing channelSpacing, |
| 54 | int spacingMultiplier, int slotGranularity, SparseAnnotations... annotations) { |
| 55 | super(number, isEnabled, Port.Type.OCH, 0, annotations); |
| 56 | this.signalType = signalType; |
| 57 | this.isTunable = isTunable; |
| 58 | this.gridType = gridType; |
| 59 | this.channelSpacing = channelSpacing; |
| 60 | this.spacingMultiplier = spacingMultiplier; |
| 61 | this.slotGranularity = slotGranularity; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Creates OCH port description based on the supplied information. |
| 66 | * |
| 67 | * @param base PortDescription to get basic information from |
| 68 | * @param signalType ODU signal type |
| 69 | * @param isTunable tunable wavelength capability |
| 70 | * @param gridType grid type |
| 71 | * @param channelSpacing channel spacing |
| 72 | * @param spacingMultiplier channel spacing multiplier |
| 73 | * @param slotGranularity slot width granularity |
| 74 | * @param annotations optional key/value annotations map |
| 75 | */ |
| 76 | public OchPortDescription(PortDescription base, OchPort.SignalType signalType, boolean isTunable, |
| 77 | OchPort.GridType gridType, OchPort.ChannelSpacing channelSpacing, |
| 78 | int spacingMultiplier, int slotGranularity, SparseAnnotations annotations) { |
| 79 | super(base, annotations); |
| 80 | this.signalType = signalType; |
| 81 | this.isTunable = isTunable; |
| 82 | this.gridType = gridType; |
| 83 | this.channelSpacing = channelSpacing; |
| 84 | this.spacingMultiplier = spacingMultiplier; |
| 85 | this.slotGranularity = slotGranularity; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Returns ODU signal type. |
| 90 | * |
| 91 | * @return ODU signal type |
| 92 | */ |
| 93 | public OchPort.SignalType signalType() { |
| 94 | return signalType; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Returns true if port is wavelength tunable. |
| 99 | * |
| 100 | * @return tunable wavelength capability |
| 101 | */ |
| 102 | public boolean isTunable() { |
| 103 | return isTunable; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Returns grid type. |
| 108 | * |
| 109 | * @return grid type |
| 110 | */ |
| 111 | public OchPort.GridType gridType() { |
| 112 | return gridType; |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Returns channel spacing. |
| 117 | * |
| 118 | * @return channel spacing |
| 119 | */ |
| 120 | public OchPort.ChannelSpacing channelSpacing() { |
| 121 | return channelSpacing; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Returns channel spacing multiplier. |
| 126 | * |
| 127 | * @return channel spacing multiplier |
| 128 | */ |
| 129 | public int spacingMultiplier() { |
| 130 | return spacingMultiplier; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Returns slot width granularity. |
| 135 | * |
| 136 | * @return slot width granularity |
| 137 | */ |
| 138 | public int slotGranularity() { |
| 139 | return slotGranularity; |
| 140 | } |
| 141 | |
| 142 | @Override |
| 143 | public String toString() { |
| 144 | return MoreObjects.toStringHelper(getClass()) |
| 145 | .add("number", portNumber()) |
| 146 | .add("isEnabled", isEnabled()) |
| 147 | .add("type", type()) |
| 148 | .add("signalType", signalType) |
| 149 | .add("isTunable", isTunable) |
| 150 | .add("gridType", gridType) |
| 151 | .add("channelSpacing", channelSpacing) |
| 152 | .add("spacingMultiplier", spacingMultiplier) |
| 153 | .add("slotGranularity", slotGranularity) |
| 154 | .add("annotations", annotations()) |
| 155 | .toString(); |
| 156 | } |
| 157 | |
| 158 | } |