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, Dict
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, Point
27 from model.python.o_ran_spiral_radius_profile import SpiralRadiusProfile
28 from model.python.type_definitions import (
33 # Define the "IORanObject" interface
34 class IORanNode(IORanObject):
37 address: AddressType = None,
38 geoLocation: GeoLocation = None,
41 layout: Layout = None,
42 spiralRadiusProfile: SpiralRadiusProfile = None,
46 super().__init__(**kwargs)
47 self.address = address
48 self.geoLocation = geoLocation
50 self.position = position
52 self.spiralRadiusProfile = spiralRadiusProfile,
55 # Define an abstract O-RAN Node class
56 class ORanNode(ORanObject, IORanNode):
57 def __init__(self, of: IORanNode = None, **kwargs):
58 super().__init__(of, **kwargs)
59 self.address = of["address"] if of and "address" in of else None
61 of["geoLocation"] if of and "geoLocation" in of else GeoLocation()
63 self.url = of["url"] if of and "url" in of else self.id
64 self.position = of["position"] if of and "position" in of else Hex(0,0,0)
65 self.layout = of["layout"] if of and "layout" in of else Layout(Hexagon.layout_flat, Point(1,1), Point(0,0))
66 self.spiralRadiusProfile = of["spiralRadiusProfile"] if of and "spiralRadiusProfile" in of else SpiralRadiusProfile()
67 self.parent = of["parent"] if of and "parent" in of else None
68 self._terminationPoints = []
75 def address(self, value):
79 def geoLocation(self):
80 return self._geographicalLocation
83 def geoLocation(self, value):
84 self._geographicalLocation = value
99 def position(self, value):
100 self._position = value
107 def layout(self, value):
111 def spiralRadiusProfile(self):
112 return self._spiralRadiusProfile
114 @spiralRadiusProfile.setter
115 def spiralRadiusProfile(self, value):
116 self._spiralRadiusProfile = value
123 def parent(self, value):
127 def terminationPoints(self):
128 return self._terminationPoints
131 result: Dict = super().json()
132 result["address"] = self.address
133 result["geoLocation"] = self.geoLocation
134 result["url"] = self.url
135 result["layout"] = self.layout
136 result["spiralRadiusProfile"] = self.spiralRadiusProfile
137 result["parent"] = self.parent
140 def toTopology(self):
141 result:Dict[str, Any] = {
142 "node-id": self.name,
143 "ietf-network-topology:termination-point": self.terminationPoints