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.
17 Module for a class representing a O-RAN Network
19 from typing import Any, Dict, List
20 from model.python.tower import Tower
21 from model.python.o_ran_object import IORanObject, ORanObject
22 import xml.etree.ElementTree as ET
25 class ORanNetwork(ORanObject):
27 Class representing an O-RAN Network object.
31 def __init__(self, configuration: Dict[str, Any], of: IORanObject = None, **kwargs):
32 super().__init__(of, **kwargs)
33 self.__configuration = configuration
34 self.__towers: List[Tower] = []
36 center = configuration["center"]
37 self.__towers.append(Tower(center))
40 def configuration(self) -> Dict[str, Dict]:
42 Getter for a json object representing the O-RAN Network.
43 :return O-RAN Network as json object.
45 return self.__configuration
47 def __appendNodes(self):
48 result: List[Dict[str, Any]] = []
49 for tower in self.__towers:
50 result.append(tower.toTopology())
55 "ietf-network:networks": {
58 "network-id": self.id,
59 "node": self.__appendNodes(),
60 "ietf-network-topology:link": [],
67 root: Element = ET.Element("kml", xmlns="http://www.opengis.net/kml/2.2")
68 document = ET.SubElement(root, "Document")
69 open = ET.SubElement(document, "open")
75 Getter for a xml/svg Element object representing the Network.
76 :return Network as SVG object.
78 root: Element = ET.Element(
80 # width=str(self.__svg_width()),
81 # height=str(self.__svg_height()),
83 # str(-3*self.FONTSIZE),
84 # str(-3*self.FONTSIZE),
85 # str(self.__svg_width()),
86 # str(self.__svg_height())]
88 xmlns="http://www.w3.org/2000/svg",
90 desc = ET.Element("desc")
91 # desc.text="\n context: " + str(self.id()) + "\n name: " + str(self.name())
94 title = ET.Element("title")
95 title.text = self.configuration()["name"]
98 # root.append(self.__context.svg(x, y))