blob: dae002c105c404b4b1a3cbda8a1733b46f82f3e0 [file] [log] [blame]
slowr13fa5b02017-08-08 16:32:31 -07001/*
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
17package org.onosproject.xran.entities;
18
slowr60d4d102017-08-16 18:33:58 -070019import com.fasterxml.jackson.annotation.JsonIgnore;
20import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
21import com.fasterxml.jackson.annotation.JsonProperty;
22import com.fasterxml.jackson.annotation.JsonPropertyOrder;
slowr13fa5b02017-08-08 16:32:31 -070023import com.fasterxml.jackson.databind.JsonNode;
24import org.onosproject.net.DeviceId;
25import org.onosproject.xran.codecs.api.ECGI;
slowr13fa5b02017-08-08 16:32:31 -070026import org.onosproject.xran.codecs.api.PRBUsage;
27import org.onosproject.xran.codecs.pdu.CellConfigReport;
28import org.onosproject.xran.codecs.pdu.L2MeasConfig;
29import org.onosproject.xran.codecs.pdu.RRMConfig;
30import org.onosproject.xran.codecs.pdu.SchedMeasReportPerCell;
slowr60d4d102017-08-16 18:33:58 -070031import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream;
32import org.onosproject.xran.codecs.ber.types.BerBitString;
33import org.onosproject.xran.codecs.ber.types.BerInteger;
slowr13fa5b02017-08-08 16:32:31 -070034
35import javax.xml.bind.DatatypeConverter;
36import java.io.ByteArrayInputStream;
37import java.io.IOException;
38import java.io.InputStream;
39import java.net.URI;
40import java.net.URISyntaxException;
slowr67d05e42017-08-11 20:37:22 -070041import java.util.List;
slowr8ddc2b12017-08-14 14:13:38 -070042import java.util.stream.Collectors;
43import java.util.stream.Stream;
slowr13fa5b02017-08-08 16:32:31 -070044
45/**
46 * Created by dimitris on 7/22/17.
47 */
slowr60d4d102017-08-16 18:33:58 -070048
49@JsonPropertyOrder({
50 "ECGI",
51 "Configuration",
52 "PRB-Usage",
53 "QCI",
54 "RRMConfiguration",
55 "MeasurementConfiguration"
56})
57@JsonIgnoreProperties(ignoreUnknown = true)
slowr13fa5b02017-08-08 16:32:31 -070058public class RnibCell {
slowr60d4d102017-08-16 18:33:58 -070059 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -070060 private static final String SCHEME = "xran";
61
slowr60d4d102017-08-16 18:33:58 -070062 @JsonProperty("ECGI")
slowr13fa5b02017-08-08 16:32:31 -070063 private ECGI ecgi;
slowr60d4d102017-08-16 18:33:58 -070064 @JsonProperty("Configuration")
slowr13fa5b02017-08-08 16:32:31 -070065 private CellConfigReport conf;
slowr60d4d102017-08-16 18:33:58 -070066 @JsonProperty("PRB-Usage")
slowr13fa5b02017-08-08 16:32:31 -070067 private PrbUsageContainer prbUsage;
slowr60d4d102017-08-16 18:33:58 -070068 @JsonProperty("QCI")
slowr13fa5b02017-08-08 16:32:31 -070069 private SchedMeasReportPerCell.QciVals qci;
slowr60d4d102017-08-16 18:33:58 -070070 @JsonProperty("RRMConfiguration")
slowr13fa5b02017-08-08 16:32:31 -070071 private RRMConfig rrmConfig;
slowr60d4d102017-08-16 18:33:58 -070072 @JsonProperty("MeasurementConfiguration")
slowr13fa5b02017-08-08 16:32:31 -070073 private L2MeasConfig measConfig;
74
slowr60d4d102017-08-16 18:33:58 -070075 @JsonIgnore
slowr8ddc2b12017-08-14 14:13:38 -070076 private String version;
77
slowr13fa5b02017-08-08 16:32:31 -070078 public RnibCell() {
79 prbUsage = new PrbUsageContainer();
slowr8ddc2b12017-08-14 14:13:38 -070080 version = "3";
slowr89c2ac12017-08-15 16:20:06 -070081
82 rrmConfig = new RRMConfig();
83 rrmConfig.setEcgi(ecgi);
slowr13fa5b02017-08-08 16:32:31 -070084 }
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
slowr8ddc2b12017-08-14 14:13:38 -0700112 public String getVersion() {
113 return version;
114 }
115
116 public void setVersion(String version) {
117 this.version = version;
118 }
119
slowr60d4d102017-08-16 18:33:58 -0700120 @JsonProperty("RRMConfiguration")
slowr67d05e42017-08-11 20:37:22 -0700121 public RRMConfig getRrmConfig() {
122 return rrmConfig;
123 }
124
slowr60d4d102017-08-16 18:33:58 -0700125 @JsonProperty("RRMConfiguration")
slowr67d05e42017-08-11 20:37:22 -0700126 public void setRrmConfig(RRMConfig rrmConfig) {
127 this.rrmConfig = rrmConfig;
128 }
129
slowr60d4d102017-08-16 18:33:58 -0700130 @JsonProperty("PRB-Usage")
slowr67d05e42017-08-11 20:37:22 -0700131 public PrbUsageContainer getPrbUsage() {
132 return prbUsage;
133 }
134
slowr60d4d102017-08-16 18:33:58 -0700135 @JsonProperty("PRB-Usage")
slowr67d05e42017-08-11 20:37:22 -0700136 public void setPrbUsage(PrbUsageContainer prbUsage) {
137 this.prbUsage = prbUsage;
138 }
139
slowr60d4d102017-08-16 18:33:58 -0700140 @JsonProperty("ECGI")
slowr13fa5b02017-08-08 16:32:31 -0700141 public ECGI getEcgi() {
142 return ecgi;
143 }
144
slowr60d4d102017-08-16 18:33:58 -0700145 @JsonProperty("ECGI")
slowr13fa5b02017-08-08 16:32:31 -0700146 public void setEcgi(ECGI ecgi) {
147 this.ecgi = ecgi;
148 }
149
slowr60d4d102017-08-16 18:33:58 -0700150 @JsonProperty("Configuration")
slowr13fa5b02017-08-08 16:32:31 -0700151 public CellConfigReport getConf() {
152 return conf;
153 }
154
slowr67d05e42017-08-11 20:37:22 -0700155 /*public RRMConfig getRrmConfig() {
156 return rrmConfig;
157 }*/
158
slowr60d4d102017-08-16 18:33:58 -0700159 @JsonProperty("Configuration")
slowr13fa5b02017-08-08 16:32:31 -0700160 public void setConf(CellConfigReport conf) {
161 this.conf = conf;
162 }
163
slowr67d05e42017-08-11 20:37:22 -0700164 public void modifyRrmConfig(JsonNode rrmConfigNode, List<RnibUe> ueList) {
165 RRMConfig.Crnti crnti = new RRMConfig.Crnti();
166 ueList.forEach(ue -> crnti.addCRNTI(ue.getRanId()));
slowr13fa5b02017-08-08 16:32:31 -0700167
slowr8ddc2b12017-08-14 14:13:38 -0700168 {
slowr60d4d102017-08-16 18:33:58 -0700169 JsonNode start_prb_dl = rrmConfigNode.path("start_prb_dl");
170 if (!start_prb_dl.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700171 RRMConfig.StartPrbDl startPrbDl = new RRMConfig.StartPrbDl();
172 if (start_prb_dl.isArray()) {
slowr89c2ac12017-08-15 16:20:06 -0700173 if (ueList.size() == start_prb_dl.size()) {
slowr8ddc2b12017-08-14 14:13:38 -0700174 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);
slowr67d05e42017-08-11 20:37:22 -0700181 }
182 }
slowr67d05e42017-08-11 20:37:22 -0700183
slowr8ddc2b12017-08-14 14:13:38 -0700184 {
slowr60d4d102017-08-16 18:33:58 -0700185 JsonNode end_prb_dl = rrmConfigNode.path("end_prb_dl");
186 if (!end_prb_dl.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700187 RRMConfig.EndPrbDl endPrbDl = new RRMConfig.EndPrbDl();
188 if (end_prb_dl.isArray()) {
slowr89c2ac12017-08-15 16:20:06 -0700189 if (ueList.size() == end_prb_dl.size()) {
slowr8ddc2b12017-08-14 14:13:38 -0700190 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 {
slowr60d4d102017-08-16 18:33:58 -0700201 JsonNode start_prb_ul = rrmConfigNode.path("start_prb_ul");
202 if (!start_prb_ul.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700203 RRMConfig.StartPrbUl startPrbUl = new RRMConfig.StartPrbUl();
204 if (start_prb_ul.isArray()) {
slowr89c2ac12017-08-15 16:20:06 -0700205 if (ueList.size() == start_prb_ul.size()) {
slowr8ddc2b12017-08-14 14:13:38 -0700206 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 {
slowr60d4d102017-08-16 18:33:58 -0700217 JsonNode end_prb_ul = rrmConfigNode.path("end_prb_ul");
218 if (!end_prb_ul.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700219 RRMConfig.EndPrbUl endPrbUl = new RRMConfig.EndPrbUl();
220 if (end_prb_ul.isArray()) {
slowr89c2ac12017-08-15 16:20:06 -0700221 if (ueList.size() == end_prb_ul.size()) {
slowr8ddc2b12017-08-14 14:13:38 -0700222 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);
slowr13fa5b02017-08-08 16:32:31 -0700233 }
234
slowr60d4d102017-08-16 18:33:58 -0700235 @JsonProperty("QCI")
slowr13fa5b02017-08-08 16:32:31 -0700236 public SchedMeasReportPerCell.QciVals getQci() {
237 return qci;
238 }
239
slowr60d4d102017-08-16 18:33:58 -0700240 @JsonProperty("QCI")
slowr13fa5b02017-08-08 16:32:31 -0700241 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
slowr60d4d102017-08-16 18:33:58 -0700253 @JsonProperty("MeasurementConfiguration")
slowr13fa5b02017-08-08 16:32:31 -0700254 public L2MeasConfig getMeasConfig() {
255 return measConfig;
256 }
257
slowr60d4d102017-08-16 18:33:58 -0700258 @JsonProperty("MeasurementConfiguration")
slowr13fa5b02017-08-08 16:32:31 -0700259 public void setMeasConfig(L2MeasConfig measConfig) {
260 this.measConfig = measConfig;
261 }
262
263 @Override
264 public String toString() {
slowr60d4d102017-08-16 18:33:58 -0700265 return "RnibCell{" +
266 "ecgi=" + ecgi +
267 ", conf=" + conf +
268 ", prbUsage=" + prbUsage +
269 ", qci=" + qci +
270 ", rrmConfig=" + rrmConfig +
271 ", measConfig=" + measConfig +
272 ", version='" + version + '\'' +
273 '}';
slowr13fa5b02017-08-08 16:32:31 -0700274 }
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
slowr60d4d102017-08-16 18:33:58 -0700291 @JsonPropertyOrder({
292 "primary",
293 "secondary"
294 })
295 @JsonIgnoreProperties(ignoreUnknown = true)
slowr13fa5b02017-08-08 16:32:31 -0700296 class PrbUsageContainer {
297 PRBUsage primary;
298 PRBUsage secondary;
299
slowr60d4d102017-08-16 18:33:58 -0700300 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
slowr13fa5b02017-08-08 16:32:31 -0700316 @Override
317 public String toString() {
slowr60d4d102017-08-16 18:33:58 -0700318 return "PrbUsageContainer{" +
319 "primary=" + primary +
320 ", secondary=" + secondary +
321 '}';
slowr13fa5b02017-08-08 16:32:31 -0700322 }
323 }
324}