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 (ORanNearRtRic)
20 from typing import overload
21 from network_generation.model.python.tower import Tower
22 from network_generation.model.python.o_ran_cu import ORanCu
23 from network_generation.model.python.o_ran_object import IORanObject
24 from network_generation.model.python.o_ran_node import ORanNode
25 from network_generation.model.python.o_ran_termination_point import ORanTerminationPoint
26 from network_generation.model.python.hexagon import Hex
27 import network_generation.model.python.hexagon as Hexagon
28 import xml.etree.ElementTree as ET
31 # Define the "IORanNearRtRic" interface
32 class IORanNearRtRic(IORanObject):
33 def __init__(self, **kwargs):
34 super().__init__(**kwargs)
37 # Define an abstract O-RAN Node class
38 class ORanNearRtRic(ORanNode, IORanNearRtRic):
39 def __init__(self, o_ran_near_rt_ric_data: IORanNearRtRic = None, **kwargs):
40 super().__init__(o_ran_near_rt_ric_data, **kwargs)
41 self._o_ran_cus: list[ORanCu] = self._calculate_o_ran_cus()
43 def _calculate_o_ran_cus(self) -> list[ORanCu]:
44 hex_ring_radius: int = self.spiralRadiusProfile.oRanNearRtRicSpiralRadiusOfOCus
45 hex_list: list[Hex] = self.spiralRadiusProfile.oRanCuSpiral(
46 self.position, hex_ring_radius
48 result: list[ORanCu] = []
49 for index, hex in enumerate(hex_list):
50 s: str = "00" + str(index)
52 [self.name.replace("NearRtRic", "CU"), s[len(s) - 2 : len(s)]]
54 network_center: dict = self.parent.parent.center
55 newGeo = Hexagon.hex_to_geo_location(
56 self.layout, hex, network_center
62 "geoLocation": newGeo,
64 "layout": self.layout,
65 "spiralRadiusProfile": self.spiralRadiusProfile,
73 def o_ran_cus(self) -> list[ORanCu]:
74 return self._o_ran_cus
77 def towers(self) -> list[Tower]:
78 result: list[Tower] = []
79 for cu in self.o_ran_cus:
80 for tower in cu.towers:
85 def termination_points(self) -> list[ORanTerminationPoint]:
86 result: list[ORanTerminationPoint] = super().termination_points
87 phy_tp: str = "-".join([self.name, "phy".upper()])
88 result.append({"tp-id": phy_tp, "name": phy_tp})
89 for interface in ["a1", "o1", "o2", "e2"]:
90 id:str = "-".join([self.name, interface.upper()])
91 result.append(ORanTerminationPoint({"id": id, "name":id, "supporter": phy_tp, "parent":self}))
94 def to_topology_nodes(self) -> list[dict[str, dict]]:
95 result: list[dict[str, dict]] = super().to_topology_nodes()
96 for o_ran_cu in self.o_ran_cus:
97 result.extend(o_ran_cu.to_topology_nodes())
100 def to_topology_links(self) -> list[dict[str, dict]]:
101 result: list[dict[str, dict]] = super().to_topology_links()
102 for o_ran_cu in self.o_ran_cus:
103 result.extend(o_ran_cu.to_topology_links())
106 def toKml(self) -> ET.Element:
107 ric: ET.Element = ET.Element("Folder")
108 open: ET.Element = ET.SubElement(ric, "open")
110 name: ET.Element = ET.SubElement(ric, "name")
111 name.text = self.name
112 for o_ran_cu in self.o_ran_cus:
113 ric.append(o_ran_cu.toKml())
116 def toSvg(self) -> None: