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 from typing import overload
22 from model.python.o_ran_du import ORanDu
23 from model.python.o_ran_termination_point import ORanTerminationPoint
24 from model.python.nr_cell_du import NrCellDu
25 from model.python.o_ran_object import IORanObject
26 from model.python.o_ran_node import ORanNode
27 import xml.etree.ElementTree as ET
30 # Define the "IORanRu" interface
31 class IORanRu(IORanObject):
32 def __init__(self, cell_count: int, ru_angle: int, ru_azimuth: int, **kwargs):
33 super().__init__(**kwargs)
34 self._cell_count = cell_count
35 self._ru_angle = ru_angle
36 self._ru_azimuth = ru_azimuth
39 # Define an abstract O-RAN Node class
40 class ORanRu(ORanNode, IORanRu):
41 def __init__(self, o_ran_ru_data: IORanRu = None, **kwargs):
42 super().__init__(o_ran_ru_data, **kwargs)
44 o_ran_ru_data["cellCount"]
45 if o_ran_ru_data and "cellCount" in o_ran_ru_data
49 o_ran_ru_data["ruAngle"]
50 if o_ran_ru_data and "ruAngle" in o_ran_ru_data
54 o_ran_ru_data["ruAzimuth"]
55 if o_ran_ru_data and "ruAzimuth" in o_ran_ru_data
58 self._cells: list[NrCellDu] = self._create_cells()
59 name: str = self.name.replace("RU", "DU")
60 self._oRanDu: ORanDu = ORanDu(
63 "geoLocation": self.parent.geoLocation,
64 "position": self.parent.position,
65 "layout": self.layout,
66 "parent": self.parent.parent.parent,
70 def _create_cells(self) -> list[NrCellDu]:
71 result: list[NrCellDu] = []
73 self.parent.parent.parent.parent.parent.parent.configuration()["pattern"][
77 for index in range(self._cell_count):
78 s: str = "00" + str(index)
80 [self.name.replace("RU", "NRCellDu"), s[len(s) - 2 : len(s)]]
82 azimuth: int = index * cell_angle + self._ru_azimuth
87 "geoLocation": self.geoLocation,
88 "position": self.position,
89 "layout": self.layout,
90 "spiralRadiusProfile": self.spiralRadiusProfile,
92 "cellAngle": cell_angle,
100 def cells(self) -> list[NrCellDu]:
104 def oRanDu(self) -> ORanDu:
108 def termination_points(self) -> list[ORanTerminationPoint]:
109 result: list[ORanTerminationPoint] = super().termination_points
110 phy_tp: str = "-".join([self.name, "phy".upper()])
111 result.append(ORanTerminationPoint({"id": phy_tp, "name": phy_tp}))
112 for interface in ["ofhm", "ofhc", "ofhu", "ofhs"]:
113 id: str = "-".join([self.name, interface.upper()])
115 ORanTerminationPoint(
116 {"id": id, "name": id, "supporter": phy_tp, "parent": self}
119 for cell in self.cells:
120 result.extend(cell.termination_points)
123 def to_topology_nodes(self) -> list[dict[str, dict]]:
124 result: list[dict[str, dict]] = super().to_topology_nodes()
125 result.extend(self.oRanDu.to_topology_nodes())
128 def to_topology_links(self) -> list[dict[str, dict]]:
129 result: list[dict[str, dict]] = super().to_topology_links()
130 result.extend(self.oRanDu.to_topology_links())
131 for interface in ["phy", "ofhm", "ofhc", "ofhu", "ofhs"]:
132 link_id: str = "".join([interface, ":", self.name, "<->", self.oRanDu.name])
133 source_tp: str = "-".join([self.name, interface.upper()])
134 dest_tp: str = "-".join([self.oRanDu.name, interface.upper()])
138 "source": {"source-node": self.name, "source-tp": source_tp},
139 "destination": {"dest-node": self.oRanDu.name, "dest-tp": dest_tp},
144 def toKml(self) -> ET.Element:
145 o_ran_ru: ET.Element = ET.Element("Folder")
146 open: ET.Element = ET.SubElement(o_ran_ru, "open")
148 name: ET.Element = ET.SubElement(o_ran_ru, "name")
149 name.text = self.name
150 for cell in self.cells:
151 o_ran_ru.append(cell.toKml())
154 def toSvg(self) -> None: