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 import xml.etree.ElementTree as ET
21 import network_generation.model.python.hexagon as Hexagon
22 from network_generation.model.python.hexagon import Layout
23 from network_generation.model.python.o_ran_object import (
27 from network_generation.model.python.o_ran_smo import ORanSmo
28 from network_generation.model.python.o_ran_spiral_radius_profile import (
31 from network_generation.model.python.point import Point
34 class ORanNetwork(ORanObject):
36 Class representing an O-RAN Network object.
41 self, configuration: dict[str, dict], of: IORanObject = None, **kwargs
43 super().__init__(of, **kwargs)
44 self.__configuration = configuration
45 self.name = configuration["name"]
46 self.center = configuration["center"]
47 size = configuration["pattern"]["nr-cell-du"]["max-reach"]
49 Hexagon.layout_flat, Point(size, size), Point(0, 0)
51 spiral_radius_profile = SpiralRadiusProfile(
53 "oRanSmoSpiralRadiusOfNearRtRics": configuration["pattern"][
55 ]["near-rt-ric-spiral-radius"],
56 "oRanNearRtRicSpiralRadiusOfOCus": configuration["pattern"][
58 ]["o-ran-cu-spiral-radius"],
59 "oRanCuSpiralRadiusOfODus": configuration["pattern"][
61 ]["o-ran-du-spiral-radius"],
62 "oRanDuSpiralRadiusOfTowers": configuration["pattern"][
64 ]["tower-spiral-radius"],
67 self._o_ran_smo = ORanSmo(
70 "geoLocation": self.center,
72 "spiralRadiusProfile": spiral_radius_profile,
78 def configuration(self) -> dict[str, dict]:
80 Getter for a json object representing the O-RAN Network.
81 :return O-RAN Network as json object.
83 return self.__configuration
85 def to_topology(self) -> dict[str, dict]:
86 nodes: dict[str, dict] = self._o_ran_smo.to_topology_nodes()
87 links: dict[str, dict] = self._o_ran_smo.to_topology_links()
89 "ietf-network:networks": {
92 "network-id": self.id,
94 "ietf-network-topology:link": links,
100 def toKml(self) -> ET.Element:
101 root: ET.Element = ET.Element(
102 "kml", xmlns="http://www.opengis.net/kml/2.2"
104 document = ET.SubElement(root, "Document")
105 open: ET.Element = ET.SubElement(document, "open")
107 name: ET.Element = ET.SubElement(document, "name")
108 name.text = self.name
110 document.append(self._o_ran_smo.toKml())
114 def toSvg(self) -> ET.Element:
116 Getter for a xml/svg Element object representing the Network.
117 :return Network as SVG object.
119 root: ET.Element = ET.Element(
121 # width=str(self.__svg_width()),
122 # height=str(self.__svg_height()),
124 # str(-3*self.FONTSIZE),
125 # str(-3*self.FONTSIZE),
126 # str(self.__svg_width()),
127 # str(self.__svg_height())]
129 xmlns="http://www.w3.org/2000/svg",
131 desc = ET.Element("desc")
132 # desc.text="\n context: " + str(self.id()) + "\n name: " + str(self.name())
135 title = ET.Element("title")
136 title.text = self.configuration()["name"]
139 # root.append(self.__context.svg(x, y))