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 import xml.etree.ElementTree as ET
21 from typing import overload
23 from network_generation.model.python.o_ran_node import ORanNode
24 from network_generation.model.python.o_ran_object import IORanObject
25 from network_generation.model.python.o_ran_termination_point import (
30 # Define the "IORanDu" interface
31 class IORanDu(IORanObject):
32 def __init__(self, o_ran_ru_count: int, **kwargs):
33 super().__init__(**kwargs)
34 self._o_ran_ru_count = o_ran_ru_count
37 # Define an abstract O-RAN Node class
38 class ORanDu(ORanNode, IORanDu):
39 def __init__(self, o_ran_du_data: IORanDu = None, **kwargs):
40 super().__init__(o_ran_du_data, **kwargs)
41 self._o_ran_ru_count = (
42 o_ran_du_data["oRanRuCount"]
43 if o_ran_du_data and "oRanRuCount" in o_ran_du_data
48 def termination_points(self) -> list[ORanTerminationPoint]:
49 result: list[ORanTerminationPoint] = super().termination_points
50 phy_tp: str = "-".join([self.name, "phy".upper()])
51 result.append(ORanTerminationPoint({"id": phy_tp, "name": phy_tp}))
52 for interface in ["e2", "o1", "ofhm", "ofhc", "ofhu", "ofhs"]:
53 id: str = "-".join([self.name, interface.upper()])
56 {"id": id, "name": id, "supporter": phy_tp, "parent": self}
61 def to_topology_nodes(self) -> list[dict[str, dict]]:
62 result: list[dict[str, dict]] = super().to_topology_nodes()
65 def to_topology_links(self) -> list[dict[str, dict]]:
66 result: list[dict[str, dict]] = super().to_topology_links()
67 for interface in ["e2", "o1"]:
68 link_id: str = "".join(
69 [interface, ":", self.name, "<->", self.parent.name]
71 source_tp: str = "-".join([self.name, interface.upper()])
72 dest_tp: str = "-".join([self.parent.name, interface.upper()])
77 "source-node": self.name,
78 "source-tp": source_tp,
81 "dest-node": self.parent.name,
88 def toKml(self) -> ET.Element:
89 o_ran_du: ET.Element = ET.Element("Folder")
90 open: ET.Element = ET.SubElement(o_ran_du, "open")
92 name: ET.Element = ET.SubElement(o_ran_du, "name")
94 for tower in self.towers:
95 o_ran_du.append(tower.toKml())
98 def toSvg(self) -> None: