python 3.10 type definitions
[oam.git] / code / network-generator / model / python / o_ran_smo.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 Service Management and Orchestration Framework (SMO)
19 """
20 from model.python.tower import Tower
21 from model.python.o_ran_near_rt_ric import ORanNearRtRic
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
27 # Define the "IORanSmo" interface
28 class IORanSmo(IORanObject):
29     def __init__(self, **kwargs):
30         super().__init__(**kwargs)
31
32
33 # Define an abstract O-RAN Node class
34 class ORanSmo(ORanNode, IORanSmo):
35     def __init__(self, o_ran_smo_data: IORanSmo = None, **kwargs):
36         super().__init__(o_ran_smo_data, **kwargs)
37         self._o_ran_near_rt_rics: list[ORanNearRtRic] = self._calculate_near_rt_rics()
38
39     def _calculate_near_rt_rics(self) -> list[ORanNearRtRic]:
40         hex_ring_radius: int = self.spiralRadiusProfile.oRanSmoSpiralRadiusOfNearRtRics
41         index: int = 0
42         s: str = "00" + str(index)
43         name: str = "Ric-" + s[len(s) - 2 : len(s)]
44         result: list[ORanNearRtRic] = []
45         result.append(
46             ORanNearRtRic(
47                 {
48                     "name": name,
49                     "geoLocation": self.geoLocation,
50                     "position": self.position,
51                     "layout": self.layout,
52                     "spiralRadiusProfile": self.spiralRadiusProfile,
53                     "parent": self,
54                 }
55             )
56         )
57         return result
58
59     # return this.spiralProfile.oRanNearRtRicSpiral(this.position, hexRingRadius).map((hex, index) => {
60     #   const name: string = 'Ric-' + ('00' + index).slice(-2);
61     #   return new ORanNearRtRic({ name: name, position: hex, layout: this.layout, spiralProfile: this.spiralProfile, parent: this });
62     # });
63
64     @property
65     def o_ran_near_rt_rics(self) -> list[ORanNearRtRic]:
66         return self._o_ran_near_rt_rics
67
68     @property
69     def towers(self) -> list[Tower]:
70         result: list[Tower] = []
71         for ric in self.o_ran_near_rt_rics:
72             for tower in ric.towers:
73                 result.append(tower)
74         return result
75
76     def toKml(self) -> None:
77         return None
78
79     def toSvg(self) -> None:
80         return None