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 An abstract Class for O-RAN Node
20 from abc import abstractmethod
21 from typing import Any
22 import xml.etree.ElementTree as ET
23 from model.python.geo_location import GeoLocation
24 from model.python.o_ran_object import IORanObject, ORanObject
25 import model.python.hexagon as Hexagon
26 from model.python.hexagon import Hex, Layout
27 from model.python.point import Point
28 from model.python.o_ran_spiral_radius_profile import SpiralRadiusProfile
29 from model.python.o_ran_termination_point import ORanTerminationPoint
30 from model.python.type_definitions import (
35 # Define the "IORanObject" interface
36 class IORanNode(IORanObject):
39 address: AddressType = None,
40 geoLocation: GeoLocation = None,
43 layout: Layout = None,
44 spiralRadiusProfile: SpiralRadiusProfile = None,
48 super().__init__(**kwargs)
49 self.address = address
50 self.geoLocation = geoLocation
52 self.position = position
54 self.spiralRadiusProfile = (spiralRadiusProfile,)
58 # Define an abstract O-RAN Node class
59 class ORanNode(ORanObject, IORanNode):
60 def __init__(self, of: IORanNode = None, **kwargs):
61 super().__init__(of, **kwargs)
62 self.address = of["address"] if of and "address" in of else None
64 of["geoLocation"] if of and "geoLocation" in of else GeoLocation()
66 self.url = of["url"] if of and "url" in of else self.id
67 self.position = of["position"] if of and "position" in of else Hex(0, 0, 0)
70 if of and "layout" in of
71 else Layout(Hexagon.layout_flat, Point(1, 1), Point(0, 0))
73 self.spiralRadiusProfile = (
74 of["spiralRadiusProfile"]
75 if of and "spiralRadiusProfile" in of
76 else SpiralRadiusProfile()
78 self.parent = of["parent"] if of and "parent" in of else None
79 self._terminationPoints = []
82 def address(self) -> str:
86 def address(self, value: str):
90 def geoLocation(self) -> GeoLocation:
91 return self._geographicalLocation
94 def geoLocation(self, value: GeoLocation):
95 self._geographicalLocation = value
102 def url(self, value: str):
106 def position(self) -> Hex:
107 return self._position
110 def position(self, value: Hex):
111 self._position = value
114 def layout(self) -> Layout:
118 def layout(self, value: Layout):
122 def spiralRadiusProfile(self) -> SpiralRadiusProfile:
123 return self._spiralRadiusProfile
125 @spiralRadiusProfile.setter
126 def spiralRadiusProfile(self, value: SpiralRadiusProfile):
127 self._spiralRadiusProfile = value
130 def parent(self) -> Any: # expected are ORanNodes and all inherits for ORanNode
134 def parent(self, value: Any):
138 def terminationPoints(self) -> list[ORanTerminationPoint]:
139 return self._terminationPoints
141 def json(self) -> dict[str, Any]:
142 result: dict = super().json()
143 result["address"] = self.address
144 result["geoLocation"] = self.geoLocation
145 result["url"] = self.url
146 result["layout"] = self.layout
147 result["spiralRadiusProfile"] = self.spiralRadiusProfile
148 result["parent"] = self.parent
151 def toTopology(self) -> dict[str, Any]:
152 result: dict[str, Any] = {
153 "node-id": self.name,
154 "ietf-network-topology:termination-point": self.terminationPoints,
159 def toKml(self) -> ET.Element | None:
163 def toSvg(self) -> ET.Element | None: