dec957862a926e22aba63527479eccd3bcebc701
[oam.git] / code / network-generator / model / python / o_ran_cu.py
1 # Copyright 2023 highstreet technologies GmbH
2 #
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
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 #!/usr/bin/python
16
17 """
18 A Class representing an O-RAN centralized unit (ORanCu)
19 """
20 from model.python.o_ran_du import ORanDu
21 from model.python.tower import Tower
22 from model.python.o_ran_object import IORanObject
23 from model.python.o_ran_node import ORanNode
24 import xml.etree.ElementTree as ET
25
26 # Define the "IORanCu" interface
27 class IORanCu(IORanObject):
28     def __init__(self, **kwargs):
29         super().__init__(**kwargs)
30
31
32 # Define an abstract O-RAN Node class
33 class ORanCu(ORanNode, IORanCu):
34     def __init__(self, o_ran_cu_data: IORanCu = None, **kwargs):
35         super().__init__(o_ran_cu_data, **kwargs)
36         self._o_ran_dus: list(ORanCu) = self._calculate_o_ran_dus()
37
38     def _calculate_o_ran_dus(self):
39         hex_ring_radius: int = self.spiralRadiusProfile.oRanCuSpiralRadiusOfODus
40         index: int = 0
41         s: str = "00" + str(index)
42         name: str = "O-RAN-DU-" + s[len(s) - 2 : len(s)]
43         result: list(ORanDu) = []
44         result.append(
45             ORanDu(
46                 {
47                     "name": name,
48                     "geoLocation": self.geoLocation,
49                     "position": self.position,
50                     "layout": self.layout,
51                     "spiralRadiusProfile": self.spiralRadiusProfile,
52                     "parent": self
53                 }
54             )
55         )
56         return result
57     
58     @property
59     def o_ran_dus(self):
60         return self._o_ran_dus
61
62     @property
63     def towers(self):
64         result: list(Tower) = []
65         for du in self.o_ran_dus:
66             for tower in du.towers:
67                 result.append(tower)
68         return result
69
70     def toKml(self):
71         return None
72
73     def toSvg(self):
74         return None