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 distributed unit (ORanDu)
20 from typing import overload
21 from model.python.o_ran_object import IORanObject
22 from model.python.o_ran_node import ORanNode
23 from model.python.o_ran_termination_point import ORanTerminationPoint
24 import xml.etree.ElementTree as ET
27 # Define the "IORanDu" interface
28 class IORanDu(IORanObject):
29 def __init__(self, o_ran_ru_count: int, **kwargs):
30 super().__init__(**kwargs)
31 self._o_ran_ru_count = o_ran_ru_count
34 # Define an abstract O-RAN Node class
35 class ORanDu(ORanNode, IORanDu):
36 def __init__(self, o_ran_du_data: IORanDu = None, **kwargs):
37 super().__init__(o_ran_du_data, **kwargs)
38 self._o_ran_ru_count = (
39 o_ran_du_data["oRanRuCount"] if o_ran_du_data and "oRanRuCount" in o_ran_du_data else 1
43 def termination_points(self) -> list[ORanTerminationPoint]:
44 result: list[ORanTerminationPoint] = super().termination_points
45 phy_tp: str = "-".join([self.name, "phy".upper()])
46 result.append(ORanTerminationPoint({"id": phy_tp, "name": phy_tp}))
47 for interface in ["e2", "o1", "ofhm", "ofhc", "ofhu","ofhs"]:
48 id:str = "-".join([self.name, interface.upper()])
49 result.append(ORanTerminationPoint({"id": id, "name":id, "supporter": phy_tp, "parent":self}))
52 def to_topology_nodes(self) -> list[dict[str, dict]]:
53 result: list[dict[str, dict]] = super().to_topology_nodes()
56 def to_topology_links(self) -> list[dict[str, dict]]:
57 result: list[dict[str, dict]] = super().to_topology_links()
58 for interface in ["e2", "o1"]:
59 link_id: str = "".join([interface, ":", self.name, "<->", self.parent.name])
60 source_tp: str = "-".join([self.name, interface.upper()])
61 dest_tp: str = "-".join([self.parent.name, interface.upper()])
65 "source": {"source-node": self.name, "source-tp": source_tp},
66 "destination": {"dest-node": self.parent.name, "dest-tp": dest_tp},
71 def toKml(self) -> ET.Element:
72 o_ran_du: ET.Element = ET.Element("Folder")
73 open: ET.Element = ET.SubElement(o_ran_du, "open")
75 name: ET.Element = ET.SubElement(o_ran_du, "name")
77 for tower in self.towers:
78 o_ran_du.append(tower.toKml())
81 def toSvg(self) -> None: