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 Service Management and Orchestration Framework (SMO)
20 import xml.etree.ElementTree as ET
21 from typing import overload
23 import network_generation.model.python.hexagon as Hexagon
24 from network_generation.model.python.hexagon import Hex
25 from network_generation.model.python.o_ran_near_rt_ric import ORanNearRtRic
26 from network_generation.model.python.o_ran_node import ORanNode
27 from network_generation.model.python.o_ran_object import IORanObject
28 from network_generation.model.python.o_ran_termination_point import (
31 from network_generation.model.python.tower import Tower
34 # Define the "IORanSmo" interface
35 class IORanSmo(IORanObject):
36 def __init__(self, **kwargs):
37 super().__init__(**kwargs)
40 # Define an abstract O-RAN Node class
41 class ORanSmo(ORanNode, IORanSmo):
42 def __init__(self, o_ran_smo_data: IORanSmo = None, **kwargs):
43 super().__init__(o_ran_smo_data, **kwargs)
44 self._o_ran_near_rt_rics: list[
46 ] = self._calculate_near_rt_rics()
48 def _calculate_near_rt_rics(self) -> list[ORanNearRtRic]:
49 hex_ring_radius: int = (
50 self.spiralRadiusProfile.oRanSmoSpiralRadiusOfNearRtRics
52 hex_list: list[Hex] = self.spiralRadiusProfile.oRanNearRtRicSpiral(
53 self.position, hex_ring_radius
55 result: list[ORanNearRtRic] = []
56 for index, hex in enumerate(hex_list):
57 s: str = "00" + str(index)
59 [self.name.replace("SMO", "NearRtRic"), s[len(s) - 2 : len(s)]]
61 network_center: dict = self.parent.center
62 newGeo = Hexagon.hex_to_geo_location(
63 self.layout, hex, network_center
69 "geoLocation": newGeo,
71 "layout": self.layout,
72 "spiralRadiusProfile": self.spiralRadiusProfile,
80 def o_ran_near_rt_rics(self) -> list[ORanNearRtRic]:
81 return self._o_ran_near_rt_rics
84 def termination_points(self) -> list[ORanTerminationPoint]:
85 result: list[ORanTerminationPoint] = super().termination_points
86 phy_tp: str = "-".join([self.name, "phy".upper()])
87 result.append(ORanTerminationPoint({"id": phy_tp, "name": phy_tp}))
88 for interface in ["a1", "o1", "o2"]:
89 id: str = "-".join([self.name, interface.upper()])
92 {"id": id, "name": id, "supporter": phy_tp, "parent": self}
98 def towers(self) -> list[Tower]:
99 result: list[Tower] = []
100 for ric in self.o_ran_near_rt_rics:
101 for tower in ric.towers:
105 def to_topology_nodes(self) -> list[dict[str, dict]]:
106 result: list[dict[str, dict]] = super().to_topology_nodes()
107 for ric in self.o_ran_near_rt_rics:
108 result.extend(ric.to_topology_nodes())
111 def to_topology_links(self) -> list[dict[str, dict]]:
112 result: list[dict[str, dict]] = [] # super().to_topology_links()
113 for ric in self.o_ran_near_rt_rics:
114 result.extend(ric.to_topology_links())
117 def toKml(self) -> ET.Element:
118 smo: ET.Element = ET.Element("Folder")
119 open: ET.Element = ET.SubElement(smo, "open")
121 name: ET.Element = ET.SubElement(smo, "name")
122 name.text = self.name
123 for ric in self.o_ran_near_rt_rics:
124 smo.append(ric.toKml())
127 def toSvg(self) -> None: