slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015-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 | |
| 17 | package org.onosproject.xran.entities; |
| 18 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 19 | import com.fasterxml.jackson.annotation.JsonIgnore; |
| 20 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 21 | import com.fasterxml.jackson.annotation.JsonProperty; |
| 22 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 23 | import com.fasterxml.jackson.databind.JsonNode; |
| 24 | import org.onosproject.net.DeviceId; |
| 25 | import org.onosproject.xran.codecs.api.ECGI; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 26 | import org.onosproject.xran.codecs.api.PRBUsage; |
| 27 | import org.onosproject.xran.codecs.pdu.CellConfigReport; |
| 28 | import org.onosproject.xran.codecs.pdu.L2MeasConfig; |
| 29 | import org.onosproject.xran.codecs.pdu.RRMConfig; |
| 30 | import org.onosproject.xran.codecs.pdu.SchedMeasReportPerCell; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 31 | import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream; |
| 32 | import org.onosproject.xran.codecs.ber.types.BerBitString; |
| 33 | import org.onosproject.xran.codecs.ber.types.BerInteger; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 34 | |
| 35 | import javax.xml.bind.DatatypeConverter; |
| 36 | import java.io.ByteArrayInputStream; |
| 37 | import java.io.IOException; |
| 38 | import java.io.InputStream; |
| 39 | import java.net.URI; |
| 40 | import java.net.URISyntaxException; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 41 | import java.util.List; |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 42 | import java.util.stream.Collectors; |
| 43 | import java.util.stream.Stream; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 44 | |
| 45 | /** |
| 46 | * Created by dimitris on 7/22/17. |
| 47 | */ |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 48 | |
| 49 | @JsonPropertyOrder({ |
| 50 | "ECGI", |
| 51 | "Configuration", |
| 52 | "PRB-Usage", |
| 53 | "QCI", |
| 54 | "RRMConfiguration", |
| 55 | "MeasurementConfiguration" |
| 56 | }) |
| 57 | @JsonIgnoreProperties(ignoreUnknown = true) |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 58 | public class RnibCell { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 59 | @JsonIgnore |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 60 | private static final String SCHEME = "xran"; |
| 61 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 62 | @JsonProperty("ECGI") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 63 | private ECGI ecgi; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 64 | @JsonProperty("Configuration") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 65 | private CellConfigReport conf; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 66 | @JsonProperty("PRB-Usage") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 67 | private PrbUsageContainer prbUsage; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 68 | @JsonProperty("QCI") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 69 | private SchedMeasReportPerCell.QciVals qci; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 70 | @JsonProperty("RRMConfiguration") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 71 | private RRMConfig rrmConfig; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 72 | @JsonProperty("MeasurementConfiguration") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 73 | private L2MeasConfig measConfig; |
| 74 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 75 | @JsonIgnore |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 76 | private String version; |
| 77 | |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 78 | public RnibCell() { |
| 79 | prbUsage = new PrbUsageContainer(); |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 80 | version = "3"; |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 81 | |
| 82 | rrmConfig = new RRMConfig(); |
| 83 | rrmConfig.setEcgi(ecgi); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | public static URI uri(ECGI ecgi) { |
| 87 | if (ecgi != null) { |
| 88 | try { |
| 89 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(4096); |
| 90 | ecgi.encode(os); |
| 91 | String message = DatatypeConverter.printHexBinary(os.getArray()); |
| 92 | return new URI(SCHEME, message, null); |
| 93 | } catch (URISyntaxException | IOException e) { |
| 94 | return null; |
| 95 | } |
| 96 | } |
| 97 | return null; |
| 98 | } |
| 99 | |
| 100 | public static ECGI decodeDeviceId(DeviceId deviceId) throws IOException { |
| 101 | String uri = deviceId.toString(); |
| 102 | String hexEcgi = uri.substring(uri.lastIndexOf("xran:") + 5); |
| 103 | |
| 104 | ECGI ecgi = new ECGI(); |
| 105 | byte[] bytearray = DatatypeConverter.parseHexBinary(hexEcgi); |
| 106 | InputStream inputStream = new ByteArrayInputStream(bytearray); |
| 107 | |
| 108 | ecgi.decode(inputStream); |
| 109 | return ecgi; |
| 110 | } |
| 111 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 112 | public String getVersion() { |
| 113 | return version; |
| 114 | } |
| 115 | |
| 116 | public void setVersion(String version) { |
| 117 | this.version = version; |
| 118 | } |
| 119 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 120 | @JsonProperty("RRMConfiguration") |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 121 | public RRMConfig getRrmConfig() { |
| 122 | return rrmConfig; |
| 123 | } |
| 124 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 125 | @JsonProperty("RRMConfiguration") |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 126 | public void setRrmConfig(RRMConfig rrmConfig) { |
| 127 | this.rrmConfig = rrmConfig; |
| 128 | } |
| 129 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 130 | @JsonProperty("PRB-Usage") |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 131 | public PrbUsageContainer getPrbUsage() { |
| 132 | return prbUsage; |
| 133 | } |
| 134 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 135 | @JsonProperty("PRB-Usage") |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 136 | public void setPrbUsage(PrbUsageContainer prbUsage) { |
| 137 | this.prbUsage = prbUsage; |
| 138 | } |
| 139 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 140 | @JsonProperty("ECGI") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 141 | public ECGI getEcgi() { |
| 142 | return ecgi; |
| 143 | } |
| 144 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 145 | @JsonProperty("ECGI") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 146 | public void setEcgi(ECGI ecgi) { |
| 147 | this.ecgi = ecgi; |
| 148 | } |
| 149 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 150 | @JsonProperty("Configuration") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 151 | public CellConfigReport getConf() { |
| 152 | return conf; |
| 153 | } |
| 154 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 155 | /*public RRMConfig getRrmConfig() { |
| 156 | return rrmConfig; |
| 157 | }*/ |
| 158 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 159 | @JsonProperty("Configuration") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 160 | public void setConf(CellConfigReport conf) { |
| 161 | this.conf = conf; |
| 162 | } |
| 163 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 164 | public void modifyRrmConfig(JsonNode rrmConfigNode, List<RnibUe> ueList) { |
| 165 | RRMConfig.Crnti crnti = new RRMConfig.Crnti(); |
| 166 | ueList.forEach(ue -> crnti.addCRNTI(ue.getRanId())); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 167 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 168 | { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 169 | JsonNode start_prb_dl = rrmConfigNode.path("start_prb_dl"); |
| 170 | if (!start_prb_dl.isMissingNode()) { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 171 | RRMConfig.StartPrbDl startPrbDl = new RRMConfig.StartPrbDl(); |
| 172 | if (start_prb_dl.isArray()) { |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 173 | if (ueList.size() == start_prb_dl.size()) { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 174 | List<BerInteger> collect = Stream.of(start_prb_dl) |
| 175 | .map(val -> new BerInteger(val.asInt())) |
| 176 | .collect(Collectors.toList()); |
| 177 | startPrbDl.setSeqOf(collect); |
| 178 | } |
| 179 | } |
| 180 | rrmConfig.setStartPrbDl(startPrbDl); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 181 | } |
| 182 | } |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 183 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 184 | { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 185 | JsonNode end_prb_dl = rrmConfigNode.path("end_prb_dl"); |
| 186 | if (!end_prb_dl.isMissingNode()) { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 187 | RRMConfig.EndPrbDl endPrbDl = new RRMConfig.EndPrbDl(); |
| 188 | if (end_prb_dl.isArray()) { |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 189 | if (ueList.size() == end_prb_dl.size()) { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 190 | List<BerInteger> collect = Stream.of(end_prb_dl) |
| 191 | .map(val -> new BerInteger(val.asInt())) |
| 192 | .collect(Collectors.toList()); |
| 193 | endPrbDl.setSeqOf(collect); |
| 194 | } |
| 195 | } |
| 196 | rrmConfig.setEndPrbDl(endPrbDl); |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 201 | JsonNode start_prb_ul = rrmConfigNode.path("start_prb_ul"); |
| 202 | if (!start_prb_ul.isMissingNode()) { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 203 | RRMConfig.StartPrbUl startPrbUl = new RRMConfig.StartPrbUl(); |
| 204 | if (start_prb_ul.isArray()) { |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 205 | if (ueList.size() == start_prb_ul.size()) { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 206 | List<BerInteger> collect = Stream.of(start_prb_ul) |
| 207 | .map(val -> new BerInteger(val.asInt())) |
| 208 | .collect(Collectors.toList()); |
| 209 | startPrbUl.setSeqOf(collect); |
| 210 | } |
| 211 | } |
| 212 | rrmConfig.setStartPrbUl(startPrbUl); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 217 | JsonNode end_prb_ul = rrmConfigNode.path("end_prb_ul"); |
| 218 | if (!end_prb_ul.isMissingNode()) { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 219 | RRMConfig.EndPrbUl endPrbUl = new RRMConfig.EndPrbUl(); |
| 220 | if (end_prb_ul.isArray()) { |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 221 | if (ueList.size() == end_prb_ul.size()) { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 222 | List<BerInteger> collect = Stream.of(end_prb_ul) |
| 223 | .map(val -> new BerInteger(val.asInt())) |
| 224 | .collect(Collectors.toList()); |
| 225 | endPrbUl.setSeqOf(collect); |
| 226 | } |
| 227 | } |
| 228 | rrmConfig.setEndPrbUl(endPrbUl); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | rrmConfig.setCrnti(crnti); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 233 | } |
| 234 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 235 | @JsonProperty("QCI") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 236 | public SchedMeasReportPerCell.QciVals getQci() { |
| 237 | return qci; |
| 238 | } |
| 239 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 240 | @JsonProperty("QCI") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 241 | public void setQci(SchedMeasReportPerCell.QciVals qci) { |
| 242 | this.qci = qci; |
| 243 | } |
| 244 | |
| 245 | public void setPrimaryPrbUsage(PRBUsage primary) { |
| 246 | this.prbUsage.primary = primary; |
| 247 | } |
| 248 | |
| 249 | public void setSecondaryPrbUsage(PRBUsage secondary) { |
| 250 | this.prbUsage.secondary = secondary; |
| 251 | } |
| 252 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 253 | @JsonProperty("MeasurementConfiguration") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 254 | public L2MeasConfig getMeasConfig() { |
| 255 | return measConfig; |
| 256 | } |
| 257 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 258 | @JsonProperty("MeasurementConfiguration") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 259 | public void setMeasConfig(L2MeasConfig measConfig) { |
| 260 | this.measConfig = measConfig; |
| 261 | } |
| 262 | |
| 263 | @Override |
| 264 | public String toString() { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 265 | return "RnibCell{" + |
| 266 | "ecgi=" + ecgi + |
| 267 | ", conf=" + conf + |
| 268 | ", prbUsage=" + prbUsage + |
| 269 | ", qci=" + qci + |
| 270 | ", rrmConfig=" + rrmConfig + |
| 271 | ", measConfig=" + measConfig + |
| 272 | ", version='" + version + '\'' + |
| 273 | '}'; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | @Override |
| 277 | public boolean equals(Object o) { |
| 278 | if (this == o) return true; |
| 279 | if (o == null || getClass() != o.getClass()) return false; |
| 280 | |
| 281 | RnibCell rnibCell = (RnibCell) o; |
| 282 | |
| 283 | return ecgi.equals(rnibCell.ecgi); |
| 284 | } |
| 285 | |
| 286 | @Override |
| 287 | public int hashCode() { |
| 288 | return ecgi.hashCode(); |
| 289 | } |
| 290 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 291 | @JsonPropertyOrder({ |
| 292 | "primary", |
| 293 | "secondary" |
| 294 | }) |
| 295 | @JsonIgnoreProperties(ignoreUnknown = true) |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 296 | class PrbUsageContainer { |
| 297 | PRBUsage primary; |
| 298 | PRBUsage secondary; |
| 299 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 300 | public PRBUsage getPrimary() { |
| 301 | return primary; |
| 302 | } |
| 303 | |
| 304 | public void setPrimary(PRBUsage primary) { |
| 305 | this.primary = primary; |
| 306 | } |
| 307 | |
| 308 | public PRBUsage getSecondary() { |
| 309 | return secondary; |
| 310 | } |
| 311 | |
| 312 | public void setSecondary(PRBUsage secondary) { |
| 313 | this.secondary = secondary; |
| 314 | } |
| 315 | |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 316 | @Override |
| 317 | public String toString() { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 318 | return "PrbUsageContainer{" + |
| 319 | "primary=" + primary + |
| 320 | ", secondary=" + secondary + |
| 321 | '}'; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 322 | } |
| 323 | } |
| 324 | } |