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 model.python.nr_cell_du import NrCellDu
21 from model.python.o_ran_object import IORanObject
22 from model.python.o_ran_node import ORanNode
23 import xml.etree.ElementTree as ET
26 # Define the "IORanRu" interface
27 class IORanRu(IORanObject):
28 def __init__(self, cell_count: int, ru_angle:int, ru_azimuth:int, **kwargs):
29 super().__init__(**kwargs)
30 self._cell_count = cell_count
31 self._ru_angle = ru_angle
32 self._ru_azimuth = ru_azimuth
35 # Define an abstract O-RAN Node class
36 class ORanRu(ORanNode, IORanRu):
37 def __init__(self, o_ran_ru_data: IORanRu = None, **kwargs):
38 super().__init__(o_ran_ru_data, **kwargs)
39 self._cell_count = o_ran_ru_data["cellCount"] if o_ran_ru_data and "cellCount" in o_ran_ru_data else 1
40 self._ru_angle = o_ran_ru_data["ruAngle"] if o_ran_ru_data and "ruAngle" in o_ran_ru_data else 120
41 self._ru_azimuth = o_ran_ru_data["ruAzimuth"] if o_ran_ru_data and "ruAzimuth" in o_ran_ru_data else 0
42 self._cells: list[NrCellDu] = self._create_cells()
45 def _create_cells(self) -> list[NrCellDu]:
46 result: list[NrCellDu] = []
47 cell_angle : int = self.parent.parent.parent.parent.parent.parent.configuration()[
49 ]["nr-cell-du"]["cell-angle"]
50 for index in range(self._cell_count):
51 s: str = "00" + str(index)
53 [self.name.replace("RU", "NRCellDu"), s[len(s) - 2 : len(s)]]
55 azimuth: int = index * cell_angle +self._ru_azimuth
60 "geoLocation": self.geoLocation,
61 "position": self.position,
62 "layout": self.layout,
63 "spiralRadiusProfile": self.spiralRadiusProfile,
65 "cellAngle": cell_angle,
73 def cells(self) -> list[NrCellDu]:
76 def toKml(self) -> ET.Element:
77 print("ru-tower", self.position, self.parent.position) if self.position.q is not self.parent.position.q else "ok"
78 o_ran_ru: ET.Element = ET.Element("Folder")
79 open: ET.Element = ET.SubElement(o_ran_ru, "open")
81 name: ET.Element = ET.SubElement(o_ran_ru, "name")
83 for cell in self.cells:
84 o_ran_ru.append(cell.toKml())
87 def toSvg(self) -> None: