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 model.python.o_ran_smo import ORanSmo
20 from model.python.o_ran_spiral_radius_profile import SpiralRadiusProfile
21 from model.python.o_ran_object import IORanObject, ORanObject
22 import model.python.hexagon as Hexagon
23 from model.python.hexagon import Layout
24 from model.python.point import Point
25 import xml.etree.ElementTree as ET
28 class ORanNetwork(ORanObject):
30 Class representing an O-RAN Network object.
34 def __init__(self, configuration: dict[str, dict], of: IORanObject = None, **kwargs):
35 super().__init__(of, **kwargs)
36 self.__configuration = configuration
37 self.name = configuration["name"]
38 self.center = configuration["center"]
39 size = configuration["pattern"]["nr-cell-du"]["max-reach"]
41 Hexagon.layout_flat, Point(size, size), Point(0, 0)
43 spiral_radius_profile = SpiralRadiusProfile(
45 "oRanSmoSpiralRadiusOfNearRtRics": configuration["pattern"]["smo"][
46 "near-rt-ric-spiral-radius"
48 "oRanNearRtRicSpiralRadiusOfOCus": configuration["pattern"][
50 ]["o-ran-cu-spiral-radius"],
51 "oRanCuSpiralRadiusOfODus": configuration["pattern"]["o-ran-cu"][
52 "o-ran-du-spiral-radius"
54 "oRanDuSpiralRadiusOfTowers": configuration["pattern"]["o-ran-du"][
59 self._o_ran_smo = ORanSmo(
62 "geoLocation": self.center,
64 "spiralRadiusProfile": spiral_radius_profile,
70 def configuration(self) -> dict[str, dict]:
72 Getter for a json object representing the O-RAN Network.
73 :return O-RAN Network as json object.
75 return self.__configuration
77 def to_topology(self) -> dict[str, dict]:
78 nodes: dict[str, dict] = self._o_ran_smo.to_topology_nodes()
79 links: dict[str, dict] = self._o_ran_smo.to_topology_links()
81 "ietf-network:networks": {
84 "network-id": self.id,
86 "ietf-network-topology:link": links,
92 def toKml(self) -> ET.Element:
93 root: ET.Element = ET.Element("kml", xmlns="http://www.opengis.net/kml/2.2")
94 document = ET.SubElement(root, "Document")
95 open: ET.Element = ET.SubElement(document, "open")
97 name: ET.Element = ET.SubElement(document, "name")
100 document.append(self._o_ran_smo.toKml())
104 def toSvg(self) -> ET.Element:
106 Getter for a xml/svg Element object representing the Network.
107 :return Network as SVG object.
109 root: ET.Element = ET.Element(
111 # width=str(self.__svg_width()),
112 # height=str(self.__svg_height()),
114 # str(-3*self.FONTSIZE),
115 # str(-3*self.FONTSIZE),
116 # str(self.__svg_width()),
117 # str(self.__svg_height())]
119 xmlns="http://www.w3.org/2000/svg",
121 desc = ET.Element("desc")
122 # desc.text="\n context: " + str(self.id()) + "\n name: " + str(self.name())
125 title = ET.Element("title")
126 title.text = self.configuration()["name"]
129 # root.append(self.__context.svg(x, y))