1 # Copyright 2023 highstreet technologies GmbH
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
17 Module for a class representing a O-RAN Network
19 from typing import Any
21 from model.python.o_ran_smo import ORanSmo
22 from model.python.o_ran_spiral_radius_profile import SpiralRadiusProfile
23 from model.python.o_ran_object import IORanObject, ORanObject
24 import model.python.hexagon as Hexagon
25 from model.python.hexagon import Layout
26 from model.python.point import Point
27 import xml.etree.ElementTree as ET
30 class ORanNetwork(ORanObject):
32 Class representing an O-RAN Network object.
36 def __init__(self, configuration: dict[str, Any], of: IORanObject = None, **kwargs):
37 super().__init__(of, **kwargs)
38 self.__configuration = configuration
39 self.name = configuration["name"]
40 self.center = configuration["center"]
41 size = configuration["pattern"]["nr-cell-du"]["max-reach"]
43 Hexagon.layout_flat, Point(size, size), Point(0, 0)
45 spiral_radius_profile = SpiralRadiusProfile(
47 "oRanSmoSpiralRadiusOfNearRtRics": configuration["pattern"]["smo"][
48 "near-rt-ric-spiral-radius"
50 "oRanNearRtRicSpiralRadiusOfOCus": configuration["pattern"][
52 ]["o-ran-cu-spiral-radius"],
53 "oRanCuSpiralRadiusOfODus": configuration["pattern"]["o-ran-cu"][
54 "o-ran-du-spiral-radius"
56 "oRanDuSpiralRadiusOfTowers": configuration["pattern"]["o-ran-du"][
61 self._o_ran_smo = ORanSmo(
64 "geoLocation": self.center,
66 "spiralRadiusProfile": spiral_radius_profile,
72 def configuration(self) -> dict[str, dict]:
74 Getter for a json object representing the O-RAN Network.
75 :return O-RAN Network as json object.
77 return self.__configuration
79 def __appendNodes(self) -> list[dict[str, Any]]:
80 result: list[dict[str, Any]] = []
81 for tower in self._o_ran_smo.towers:
82 result.append(tower.toTopology())
85 def toTopology(self) -> dict[str, Any]:
87 "ietf-network:networks": {
90 "network-id": self.id,
91 "node": self.__appendNodes(),
92 "ietf-network-topology:link": [],
98 def toKml(self) -> ET.Element:
99 root: ET.Element = ET.Element("kml", xmlns="http://www.opengis.net/kml/2.2")
100 document = ET.SubElement(root, "Document")
101 open: ET.Element = ET.SubElement(document, "open")
103 name: ET.Element = ET.SubElement(document, "name")
104 name.text = self.name
106 document.append(self._o_ran_smo.toKml())
110 def toSvg(self) -> ET.Element:
112 Getter for a xml/svg Element object representing the Network.
113 :return Network as SVG object.
115 root: ET.Element = ET.Element(
117 # width=str(self.__svg_width()),
118 # height=str(self.__svg_height()),
120 # str(-3*self.FONTSIZE),
121 # str(-3*self.FONTSIZE),
122 # str(self.__svg_width()),
123 # str(self.__svg_height())]
125 xmlns="http://www.w3.org/2000/svg",
127 desc = ET.Element("desc")
128 # desc.text="\n context: " + str(self.id()) + "\n name: " + str(self.name())
131 title = ET.Element("title")
132 title.text = self.configuration()["name"]
135 # root.append(self.__context.svg(x, y))