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 from typing import overload
21 from model.python.tower import Tower
22 from model.python.o_ran_near_rt_ric import ORanNearRtRic
23 from model.python.o_ran_object import IORanObject
24 from model.python.o_ran_node import ORanNode
25 from model.python.hexagon import Hex
26 from model.python.o_ran_termination_point import ORanTerminationPoint
27 import model.python.hexagon as Hexagon
28 import xml.etree.ElementTree as ET
31 # Define the "IORanSmo" interface
32 class IORanSmo(IORanObject):
33 def __init__(self, **kwargs):
34 super().__init__(**kwargs)
37 # Define an abstract O-RAN Node class
38 class ORanSmo(ORanNode, IORanSmo):
39 def __init__(self, o_ran_smo_data: IORanSmo = None, **kwargs):
40 super().__init__(o_ran_smo_data, **kwargs)
41 self._o_ran_near_rt_rics: list[ORanNearRtRic] = self._calculate_near_rt_rics()
43 def _calculate_near_rt_rics(self) -> list[ORanNearRtRic]:
44 hex_ring_radius: int = self.spiralRadiusProfile.oRanSmoSpiralRadiusOfNearRtRics
45 hex_list: list[Hex] = self.spiralRadiusProfile.oRanNearRtRicSpiral(
46 self.position, hex_ring_radius
48 result: list[ORanNearRtRic] = []
49 for index, hex in enumerate(hex_list):
50 s: str = "00" + str(index)
52 [self.name.replace("SMO", "NearRtRic"), s[len(s) - 2 : len(s)]]
54 network_center: dict = self.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,
74 def o_ran_near_rt_rics(self) -> list[ORanNearRtRic]:
75 return self._o_ran_near_rt_rics
78 def termination_points(self) -> list[ORanTerminationPoint]:
79 result: list[ORanTerminationPoint] = super().termination_points
80 phy_tp: str = "-".join([self.name, "phy".upper()])
81 result.append(ORanTerminationPoint({"id": phy_tp, "name": phy_tp}))
82 for interface in ["a1", "o1", "o2"]:
83 id:str = "-".join([self.name, interface.upper()])
84 result.append(ORanTerminationPoint({"id": id, "name":id, "supporter": phy_tp, "parent":self}))
88 def towers(self) -> list[Tower]:
89 result: list[Tower] = []
90 for ric in self.o_ran_near_rt_rics:
91 for tower in ric.towers:
95 def to_topology_nodes(self) -> list[dict[str, dict]]:
96 result: list[dict[str, dict]] = super().to_topology_nodes()
97 for ric in self.o_ran_near_rt_rics:
98 result.extend(ric.to_topology_nodes())
101 def to_topology_links(self) -> list[dict[str, dict]]:
102 result: list[dict[str, dict]] = [] # super().to_topology_links()
103 for ric in self.o_ran_near_rt_rics:
104 result.extend(ric.to_topology_links())
107 def toKml(self) -> ET.Element:
108 smo: ET.Element = ET.Element("Folder")
109 open: ET.Element = ET.SubElement(smo, "open")
111 name: ET.Element = ET.SubElement(smo, "name")
112 name.text = self.name
113 for ric in self.o_ran_near_rt_rics:
114 smo.append(ric.toKml())
117 def toSvg(self) -> None: