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.
18 A Class representing an O-RAN radio unit (ORanRu)
20 import xml.etree.ElementTree as ET
21 from typing import overload
23 from network_generation.model.python.nr_cell_du import NrCellDu
24 from network_generation.model.python.o_ran_du import ORanDu
25 from network_generation.model.python.o_ran_node import ORanNode
26 from network_generation.model.python.o_ran_object import IORanObject
27 from network_generation.model.python.o_ran_termination_point import (
32 # Define the "IORanRu" interface
33 class IORanRu(IORanObject):
35 self, cell_count: int, ru_angle: int, ru_azimuth: int, **kwargs
37 super().__init__(**kwargs)
38 self._cell_count = cell_count
39 self._ru_angle = ru_angle
40 self._ru_azimuth = ru_azimuth
43 # Define an abstract O-RAN Node class
44 class ORanRu(ORanNode, IORanRu):
45 def __init__(self, o_ran_ru_data: IORanRu = None, **kwargs):
46 super().__init__(o_ran_ru_data, **kwargs)
48 o_ran_ru_data["cellCount"]
49 if o_ran_ru_data and "cellCount" in o_ran_ru_data
53 o_ran_ru_data["ruAngle"]
54 if o_ran_ru_data and "ruAngle" in o_ran_ru_data
58 o_ran_ru_data["ruAzimuth"]
59 if o_ran_ru_data and "ruAzimuth" in o_ran_ru_data
62 self._cells: list[NrCellDu] = self._create_cells()
63 name: str = self.name.replace("RU", "DU")
64 self._oRanDu: ORanDu = ORanDu(
67 "geoLocation": self.parent.geoLocation,
68 "position": self.parent.position,
69 "layout": self.layout,
70 "parent": self.parent.parent.parent,
74 def _create_cells(self) -> list[NrCellDu]:
75 result: list[NrCellDu] = []
77 self.parent.parent.parent.parent.parent.parent.configuration()[
79 ]["nr-cell-du"]["cell-angle"]
81 for index in range(self._cell_count):
82 s: str = "00" + str(index)
84 [self.name.replace("RU", "NRCellDu"), s[len(s) - 2 : len(s)]]
86 azimuth: int = index * cell_angle + self._ru_azimuth
91 "geoLocation": self.geoLocation,
92 "position": self.position,
93 "layout": self.layout,
94 "spiralRadiusProfile": self.spiralRadiusProfile,
96 "cellAngle": cell_angle,
104 def cells(self) -> list[NrCellDu]:
108 def oRanDu(self) -> ORanDu:
112 def termination_points(self) -> list[ORanTerminationPoint]:
113 result: list[ORanTerminationPoint] = super().termination_points
114 phy_tp: str = "-".join([self.name, "phy".upper()])
115 result.append(ORanTerminationPoint({"id": phy_tp, "name": phy_tp}))
116 for interface in ["ofhm", "ofhc", "ofhu", "ofhs"]:
117 id: str = "-".join([self.name, interface.upper()])
119 ORanTerminationPoint(
120 {"id": id, "name": id, "supporter": phy_tp, "parent": self}
123 for cell in self.cells:
124 result.extend(cell.termination_points)
127 def to_topology_nodes(self) -> list[dict[str, dict]]:
128 result: list[dict[str, dict]] = super().to_topology_nodes()
129 result.extend(self.oRanDu.to_topology_nodes())
132 def to_topology_links(self) -> list[dict[str, dict]]:
133 result: list[dict[str, dict]] = super().to_topology_links()
134 result.extend(self.oRanDu.to_topology_links())
135 for interface in ["phy", "ofhm", "ofhc", "ofhu", "ofhs"]:
136 link_id: str = "".join(
137 [interface, ":", self.name, "<->", self.oRanDu.name]
139 source_tp: str = "-".join([self.name, interface.upper()])
140 dest_tp: str = "-".join([self.oRanDu.name, interface.upper()])
145 "source-node": self.name,
146 "source-tp": source_tp,
149 "dest-node": self.oRanDu.name,
156 def toKml(self) -> ET.Element:
157 o_ran_ru: ET.Element = ET.Element("Folder")
158 open: ET.Element = ET.SubElement(o_ran_ru, "open")
160 name: ET.Element = ET.SubElement(o_ran_ru, "name")
161 name.text = self.name
162 for cell in self.cells:
163 o_ran_ru.append(cell.toKml())
166 def toSvg(self) -> None: