X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=code%2Fnetwork-generator%2Fmodel%2Fpython%2Fo_ran_smo.py;h=fe040883ef76df73cdc78ebdd25f50448ba3f2d2;hb=3461ac19f233f610594196267199266dedcf57db;hp=a5bd7a5ff054bde5633fd512fe674e8ae2b7b8df;hpb=a9a1665ee0b2aff12c16c681750d5d2f57b05582;p=oam.git diff --git a/code/network-generator/model/python/o_ran_smo.py b/code/network-generator/model/python/o_ran_smo.py index a5bd7a5..fe04088 100644 --- a/code/network-generator/model/python/o_ran_smo.py +++ b/code/network-generator/model/python/o_ran_smo.py @@ -21,6 +21,8 @@ from model.python.tower import Tower from model.python.o_ran_near_rt_ric import ORanNearRtRic from model.python.o_ran_object import IORanObject from model.python.o_ran_node import ORanNode +from model.python.hexagon import Hex +import model.python.hexagon as Hexagon import xml.etree.ElementTree as ET @@ -34,47 +36,58 @@ class IORanSmo(IORanObject): class ORanSmo(ORanNode, IORanSmo): def __init__(self, o_ran_smo_data: IORanSmo = None, **kwargs): super().__init__(o_ran_smo_data, **kwargs) - self._o_ran_near_rt_rics: list(ORanNearRtRic) = self._calculate_near_rt_rics() + self._o_ran_near_rt_rics: list[ORanNearRtRic] = self._calculate_near_rt_rics() - def _calculate_near_rt_rics(self): + def _calculate_near_rt_rics(self) -> list[ORanNearRtRic]: hex_ring_radius: int = self.spiralRadiusProfile.oRanSmoSpiralRadiusOfNearRtRics - index: int = 0 - s: str = "00" + str(index) - name: str = "Ric-" + s[len(s) - 2 : len(s)] - result: list(ORanNearRtRic) = [] - result.append( - ORanNearRtRic( - { - "name": name, - "geoLocation": self.geoLocation, - "position": self.position, - "layout": self.layout, - "spiralRadiusProfile": self.spiralRadiusProfile, - "parent": self, - } - ) + hex_list: list[Hex] = self.spiralRadiusProfile.oRanNearRtRicSpiral( + self.position, hex_ring_radius ) + result: list[ORanNearRtRic] = [] + for index, hex in enumerate(hex_list): + s: str = "00" + str(index) + name: str = "-".join( + [self.name.replace("SMO", "NearRtRic"), s[len(s) - 2 : len(s)]] + ) + network_center: dict = self.parent.center + newGeo = Hexagon.hex_to_geo_location( + self.layout, hex, network_center + ).json() + result.append( + ORanNearRtRic( + { + "name": name, + "geoLocation": newGeo, + "position": hex, + "layout": self.layout, + "spiralRadiusProfile": self.spiralRadiusProfile, + "parent": self, + } + ) + ) return result - # return this.spiralProfile.oRanNearRtRicSpiral(this.position, hexRingRadius).map((hex, index) => { - # const name: string = 'Ric-' + ('00' + index).slice(-2); - # return new ORanNearRtRic({ name: name, position: hex, layout: this.layout, spiralProfile: this.spiralProfile, parent: this }); - # }); - @property - def o_ran_near_rt_rics(self): + def o_ran_near_rt_rics(self) -> list[ORanNearRtRic]: return self._o_ran_near_rt_rics - + @property - def towers(self): - result: list(Tower) = [] + def towers(self) -> list[Tower]: + result: list[Tower] = [] for ric in self.o_ran_near_rt_rics: for tower in ric.towers: result.append(tower) return result - def toKml(self): - return None + def toKml(self) -> ET.Element: + smo: ET.Element = ET.Element("Folder") + open: ET.Element = ET.SubElement(smo, "open") + open.text = "1" + name: ET.Element = ET.SubElement(smo, "name") + name.text = self.name + for ric in self.o_ran_near_rt_rics: + smo.append(ric.toKml()) + return smo - def toSvg(self): + def toSvg(self) -> None: return None