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 Near real-time intelligent controller
21 import xml.etree.ElementTree as ET
22 from typing import Any, cast
24 import network_generation.model.python.hexagon as Hexagon
25 from network_generation.model.python.geo_location import GeoLocation
26 from network_generation.model.python.hexagon import Hex
27 from network_generation.model.python.o_ran_cu import ORanCu
28 from network_generation.model.python.o_ran_node import (
33 from network_generation.model.python.o_ran_termination_point import (
36 from network_generation.model.python.tower import Tower
38 # Define the "IORanNearRtRic" interface
39 IORanNearRtRic = IORanNode
42 # Define an abstract O-RAN Node class
43 class ORanNearRtRic(ORanNode):
46 data: dict[str, Any] = cast(dict[str, Any], default_value),
47 **kwargs: dict[str, Any]
49 o_ran_near_rt_ric_data: IORanNearRtRic = (
50 self._to_o_ran_near_rt_ric_data(data)
53 cast(dict[str, Any], o_ran_near_rt_ric_data), **kwargs
55 self._o_ran_cus: list[ORanCu] = self._calculate_o_ran_cus()
57 def _to_o_ran_near_rt_ric_data(
58 self, data: dict[str, Any]
60 result: IORanNearRtRic = default_value
61 for key, key_type in IORanNearRtRic.__annotations__.items():
63 result[key] = data[key] # type: ignore
66 def _calculate_o_ran_cus(self) -> list[ORanCu]:
67 hex_ring_radius: int = (
69 .spiral_radius_profile.oRanNearRtRicSpiralRadiusOfOCus
73 ] = self.parent.parent.spiral_radius_profile.oRanCuSpiral(
74 self.position, hex_ring_radius
76 result: list[ORanCu] = []
77 for index, hex in enumerate(hex_list):
78 s: str = "00" + str(index)
80 [self.name.replace("NearRtRic", "CU"), s[len(s) - 2: len(s)]]
82 network_center: GeoLocation = self.parent.parent.center
83 newGeo = Hexagon.hex_to_geo_location(
84 self.layout, hex, network_center
90 "geoLocation": newGeo,
92 "layout": self.layout,
100 def o_ran_cus(self) -> list[ORanCu]:
101 return self._o_ran_cus
104 def towers(self) -> list[Tower]:
105 result: list[Tower] = []
106 for cu in self.o_ran_cus:
107 for tower in cu.towers:
111 def termination_points(self) -> list[ORanTerminationPoint]:
112 result: list[ORanTerminationPoint] = super().termination_points()
113 phy_tp: str = "-".join([self.name, "phy".upper()])
114 result.append(ORanTerminationPoint({"tp-id": phy_tp, "name": phy_tp}))
115 for interface in ["a1", "o1", "o2", "e2"]:
116 id: str = "-".join([self.name, interface.upper()])
118 ORanTerminationPoint(
119 {"id": id, "name": id, "supporter": phy_tp, "parent": self}
124 def to_topology_nodes(self) -> list[dict[str, Any]]:
125 result: list[dict[str, Any]] = super().to_topology_nodes()
126 for o_ran_cu in self.o_ran_cus:
127 result.extend(o_ran_cu.to_topology_nodes())
130 def to_topology_links(self) -> list[dict[str, Any]]:
131 result: list[dict[str, Any]] = super().to_topology_links()
132 for o_ran_cu in self.o_ran_cus:
133 result.extend(o_ran_cu.to_topology_links())
136 def toKml(self) -> ET.Element:
137 ric: ET.Element = ET.Element("Folder")
138 open: ET.Element = ET.SubElement(ric, "open")
140 name: ET.Element = ET.SubElement(ric, "name")
141 name.text = self.name
142 for o_ran_cu in self.o_ran_cus:
143 ric.append(o_ran_cu.toKml())
146 def toSvg(self) -> ET.Element:
147 return ET.Element("to-be-implemented")
149 def to_directory(self, parent_dir: str) -> None:
150 for o_ran_cu in self.o_ran_cus:
151 o_ran_cu.to_directory(parent_dir)