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 a Tower to mount O-RAN RUs
19 It can be interpreted as 'resource pool' for physical network
22 import xml.etree.ElementTree as ET
23 from typing import Any, cast
25 from network_generation.model.python.o_ran_node import IORanNode, ORanNode
26 from network_generation.model.python.o_ran_ru import ORanRu
27 from network_generation.model.python.o_ran_termination_point import (
32 # Define the "IoRanDu" interface
33 class ITower(IORanNode):
37 default_value: ITower = cast(
48 # Implement a concrete O-RAN Node class
49 class Tower(ORanNode):
52 data: dict[str, Any] = cast(dict[str, Any], default_value),
53 **kwargs: dict[str, Any]
55 tower_data: ITower = self._to_tower_data(data)
56 super().__init__(cast(dict[str, Any], tower_data), **kwargs)
57 self._o_ran_ru_count: int = (
58 int(str(tower_data["oRanRuCount"]))
59 if tower_data and "oRanRuCount" in tower_data
62 self._o_ran_rus: list[ORanRu] = self._create_o_ran_rus()
64 def _to_tower_data(self, data: dict[str, Any]) -> ITower:
65 result: ITower = default_value
66 for key, key_type in ITower.__annotations__.items():
68 result[key] = data[key] # type: ignore
71 def _create_o_ran_rus(self) -> list[ORanRu]:
72 result: list[ORanRu] = []
73 for index in range(self._o_ran_ru_count):
74 s: str = "00" + str(index)
76 [self.name.replace("Tower", "RU"), s[len(s) - 2: len(s)]]
79 self.parent.parent.parent.parent.parent.configuration[
81 ]["oRanRu"]["nrCellDuCount"]
84 self.parent.parent.parent.parent.parent.configuration[
86 ]["nrCellDu"]["cellAngle"]
88 ru_angle: int = cell_count * cell_angle
89 ru_azimuth: int = index * ru_angle
94 "geoLocation": self.geo_location,
95 "position": self.position,
96 "layout": self.layout,
98 "cellCount": cell_count,
100 "ruAzimuth": ru_azimuth,
107 def o_ran_rus(self) -> list[ORanRu]:
108 return self._o_ran_rus
110 def termination_points(self) -> list[ORanTerminationPoint]:
111 result: list[ORanTerminationPoint] = super().termination_points()
112 phy_tp: str = "-".join([self.name, "phy".upper()])
113 result.append(ORanTerminationPoint({"tp-id": phy_tp}))
114 for interface in ["e2", "o1", "ofhm", "ofhc", "ofhu", "ofhs"]:
116 ORanTerminationPoint(
118 "tp-id": "-".join([self.name, interface.upper()]),
119 "supporting-termination-point": [
122 self.parent.parent.parent.parent
124 "node-ref": self.name,
133 def to_topology_nodes(self) -> list[dict[str, Any]]:
134 result: list[dict[str, Any]] = super().to_topology_nodes()
135 for o_ran_ru in self.o_ran_rus:
136 result.extend(o_ran_ru.to_topology_nodes())
139 def to_topology_links(self) -> list[dict[str, Any]]:
140 result: list[dict[str, Any]] = super().to_topology_links()
141 for o_ran_ru in self.o_ran_rus:
142 result.extend(o_ran_ru.to_topology_links())
145 def toKml(self) -> ET.Element:
146 tower: ET.Element = ET.Element("Folder")
147 open: ET.Element = ET.SubElement(tower, "open")
149 name: ET.Element = ET.SubElement(tower, "name")
150 name.text = self.name
151 for o_ran_ru in self.o_ran_rus:
152 tower.append(o_ran_ru.toKml())
155 def toSvg(self) -> ET.Element:
156 return ET.Element("to-be-implemented")