X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=code%2Fnetwork-generator%2Fmodel%2Fpython%2Fo_ran_cu.py;h=9069f36acfcccdc717a80b3db4f99afc1f3209bc;hb=7103d3f21271877939dd8c57df8c8c61d5b9f504;hp=dec957862a926e22aba63527479eccd3bcebc701;hpb=5695364ecac8148f7eef8819518362589748b222;p=oam.git diff --git a/code/network-generator/model/python/o_ran_cu.py b/code/network-generator/model/python/o_ran_cu.py index dec9578..9069f36 100644 --- a/code/network-generator/model/python/o_ran_cu.py +++ b/code/network-generator/model/python/o_ran_cu.py @@ -16,13 +16,18 @@ """ A Class representing an O-RAN centralized unit (ORanCu) +and at the same time a location for an O-Cloud resource pool """ -from model.python.o_ran_du import ORanDu +from model.python.cube import Cube +from model.python.hexagon import Hex +import model.python.hexagon as Hexagon +from model.python.o_ran_cloud_du import ORanCloudDu from model.python.tower import Tower from model.python.o_ran_object import IORanObject from model.python.o_ran_node import ORanNode import xml.etree.ElementTree as ET + # Define the "IORanCu" interface class IORanCu(IORanObject): def __init__(self, **kwargs): @@ -33,42 +38,58 @@ class IORanCu(IORanObject): class ORanCu(ORanNode, IORanCu): def __init__(self, o_ran_cu_data: IORanCu = None, **kwargs): super().__init__(o_ran_cu_data, **kwargs) - self._o_ran_dus: list(ORanCu) = self._calculate_o_ran_dus() + self._o_ran_cloud_dus: list[ORanCu] = self._calculate_o_ran_dus() - def _calculate_o_ran_dus(self): + def _calculate_o_ran_dus(self) -> list[ORanCloudDu]: hex_ring_radius: int = self.spiralRadiusProfile.oRanCuSpiralRadiusOfODus - index: int = 0 - s: str = "00" + str(index) - name: str = "O-RAN-DU-" + s[len(s) - 2 : len(s)] - result: list(ORanDu) = [] - result.append( - ORanDu( - { - "name": name, - "geoLocation": self.geoLocation, - "position": self.position, - "layout": self.layout, - "spiralRadiusProfile": self.spiralRadiusProfile, - "parent": self - } + hex_list: list[Hex] = self.spiralRadiusProfile.oRanDuSpiral(self.position, hex_ring_radius) + result: list[ORanCloudDu] = [] + for index, hex in enumerate(hex_list): + s: str = "00" + str(index) + name: str = "-".join( + [self.name.replace("CU", "O-Cloud-DU"), s[len(s) - 2 : len(s)]] + ) + network_center: dict = self.parent.parent.parent.center + newGeo = Hexagon.hex_to_geo_location( + self.layout, hex, network_center + ).json() + result.append( + ORanCloudDu( + { + "name": name, + "geoLocation": newGeo, + "position": hex, + "layout": self.layout, + "spiralRadiusProfile": self.spiralRadiusProfile, + "parent": self, + } + ) ) - ) return result - + + @property - def o_ran_dus(self): - return self._o_ran_dus + def o_ran_cloud_dus(self) -> list[ORanCloudDu]: + return self._o_ran_cloud_dus @property - def towers(self): - result: list(Tower) = [] - for du in self.o_ran_dus: + def towers(self) -> list[Tower]: + result: list[Tower] = [] + for du in self.o_ran_cloud_dus: for tower in du.towers: result.append(tower) return result - def toKml(self): - return None + def toKml(self) -> ET.Element: + o_ran_cu: ET.Element = ET.Element("Folder") + open: ET.Element = ET.SubElement(o_ran_cu, "open") + open.text = "1" + name: ET.Element = ET.SubElement(o_ran_cu, "name") + name.text = self.name + for o_ran_du in self.o_ran_cloud_dus: + o_ran_cu.append(o_ran_du.toKml()) + return o_ran_cu + - def toSvg(self): + def toSvg(self) -> None: return None