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 Objects
20 from abc import ABC, abstractmethod
21 from typing import Dict
23 import model.python.hexagon as Hexagon
24 from model.python.hexagon import Hex, Layout, Point
25 from model.python.o_ran_spiral_radius_profile import SpiralRadiusProfile
26 from model.python.top import ITop, Top
27 from model.python.type_definitions import (
30 from model.python.geo_location import GeoLocation
33 # Define the "IORanObject" interface
34 class IORanObject(ITop):
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,
56 # Define an abstract O-RAN Object class
57 class ORanObject(Top, IORanObject):
58 def __init__(self, of: IORanObject = None, **kwargs):
59 super().__init__(**kwargs)
60 self.address = of["address"] if of and "address" in of else None
62 of["geoLocation"] if of and "geoLocation" in of else GeoLocation()
64 self.url = of["url"] if of and "url" in of else self.id
65 self.position = of["position"] if of and "position" in of else Hex(0,0,0)
66 self.layout = of["layout"] if of and "layout" in of else Layout(Hexagon.layout_flat, Point(1,1), Point(0,0))
67 self.spiralRadiusProfile = of["spiralRadiusProfile"] if of and "spiralRadiusProfile" in of else SpiralRadiusProfile()
68 self.parent = of["parent"] if of and "parent" in of else None
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 result :Dict = super().json()
128 result['address'] = self.address
129 result['geoLocation'] = self.geoLocation
130 result['url'] = self.url
131 result['layout'] = self.layout
132 result['spiralRadiusProfile'] = self.spiralRadiusProfile
133 result['parent'] = self.parent
137 return str(self.json())
140 def toTopology(self):