From: Martin Skorupski Date: Thu, 23 Nov 2023 06:47:10 +0000 (+0100) Subject: Decide about "list-case" or "camelCase" in schema. X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=4b089018e34cea369399ace99c2a81bc77b7ce82;p=oam.git Decide about "list-case" or "camelCase" in schema. - updates in model/python Issue-ID: OAM-396 Change-Id: I7ab4a3ebf45bd51a3004d9577eda813bcd6612e2 Signed-off-by: Martin Skorupski --- diff --git a/code/network-generator/network_generation/cli.py b/code/network-generator/network_generation/cli.py index ad4188a..c642433 100644 --- a/code/network-generator/network_generation/cli.py +++ b/code/network-generator/network_generation/cli.py @@ -44,26 +44,26 @@ def main() -> None: # pragma: no cover network: ORanNetwork = generator.generate() viewer: NetworkViewer = NetworkViewer(network) - output_folder: str = configuration["output-folder"] + output_folder: str = configuration["outputFolder"] # If folder doesn't exist, then create it. if not os.path.isdir(output_folder): os.makedirs(output_folder) - name: str = configuration["network"]["name"] + name: str = str(configuration["network"]["name"]).lower() filename: str = "" # topology json - if configuration["generation-tasks"]["topology"] is True: + if configuration["generationTasks"]["topology"] is True: filename = output_folder + "/" + name + "-operational.json" viewer.json().save(filename) # svg xml - if configuration["generation-tasks"]["svg"] is True: + if configuration["generationTasks"]["svg"] is True: filename = output_folder + "/" + name + ".svg" viewer.svg(filename) # kml xml - if configuration["generation-tasks"]["kml"] is True: + if configuration["generationTasks"]["kml"] is True: filename = output_folder + "/" + name + ".kml" viewer.kml(filename) diff --git a/code/network-generator/network_generation/model/python/nr_cell_du.py b/code/network-generator/network_generation/model/python/nr_cell_du.py index 578ac16..acdafe1 100644 --- a/code/network-generator/network_generation/model/python/nr_cell_du.py +++ b/code/network-generator/network_generation/model/python/nr_cell_du.py @@ -112,7 +112,9 @@ class NrCellDu(ORanNode): def termination_points(self) -> list[ORanTerminationPoint]: result: list[ORanTerminationPoint] = super().termination_points() - result.append(ORanTerminationPoint({"id": self.name, "name": self.name})) + result.append(ORanTerminationPoint( + {"id": self.name, "name": self.name} + )) return result def to_topology_nodes(self) -> list[dict[str, Any]]: @@ -137,9 +139,12 @@ class NrCellDu(ORanNode): linear_ring: ET.Element = ET.SubElement(outer_boundary, "LinearRing") coordinates: ET.Element = ET.SubElement(linear_ring, "coordinates") - points: list[Point] = Hexagon.polygon_corners(self.layout, self.position) + points: list[Point] = Hexagon.polygon_corners( + self.layout, self.position + ) method = ( - self.parent.parent.parent.parent.parent.parent.geo_location.point_to_geo_location + self.parent.parent.parent.parent.parent.parent + .geo_location.point_to_geo_location ) geo_locations: list[GeoLocation] = list(map(method, points)) text: list[str] = [] @@ -149,19 +154,23 @@ class NrCellDu(ORanNode): self.parent.parent.parent.parent.parent.parent.geo_location ) + p1: int = (2 * index + 1) % 6 + p2: int = (2 * index + 2) % 6 intersect1: Point = Point( - (points[(2 * index + 1) % 6].x + points[(2 * index + 2) % 6].x) / 2, - (points[(2 * index + 1) % 6].y + points[(2 * index + 2) % 6].y) / 2, + (points[p1].x + points[p2].x) / 2, + (points[p1].y + points[p2].y) / 2, ) - intersect_geo_location1: GeoLocation = network_center.point_to_geo_location( + intersect_gl1: GeoLocation = network_center.point_to_geo_location( intersect1 ) + p3: int = (2 * index + 3) % 6 + p4: int = (2 * index + 4) % 6 intersect2: Point = Point( - (points[(2 * index + 3) % 6].x + points[(2 * index + 4) % 6].x) / 2, - (points[(2 * index + 3) % 6].y + points[(2 * index + 4) % 6].y) / 2, + (points[p3].x + points[p4].x) / 2, + (points[p3].y + points[p4].y) / 2, ) - intersect_geo_location2: GeoLocation = network_center.point_to_geo_location( + intersect_gl2: GeoLocation = network_center.point_to_geo_location( intersect2 ) @@ -170,10 +179,10 @@ class NrCellDu(ORanNode): cell_polygon: list[GeoLocation] = [] cell_polygon.append(tower) - cell_polygon.append(intersect_geo_location1) + cell_polygon.append(intersect_gl1) cell_polygon.append(geo_locations[(2 * index + 2) % 6]) cell_polygon.append(geo_locations[(2 * index + 3) % 6]) - cell_polygon.append(intersect_geo_location2) + cell_polygon.append(intersect_gl2) # close polygon cell_polygon.append(tower) @@ -187,26 +196,22 @@ class NrCellDu(ORanNode): coordinates.text = " ".join(text) if self.cell_scale_factor > 0: - scaled_polygon: ET.Element = ET.SubElement(multi_geometry, "Polygon") - scaled_outer_boundary: ET.Element = ET.SubElement(scaled_polygon, "outerBoundaryIs") - scaled_linear_ring: ET.Element = ET.SubElement(scaled_outer_boundary, "LinearRing") - scaled_coordinates: ET.Element = ET.SubElement(scaled_linear_ring, "coordinates") + scaled_polygon: ET.Element = ET.SubElement( + multi_geometry, "Polygon") + scaled_outer_boundary: ET.Element = ET.SubElement( + scaled_polygon, "outerBoundaryIs") + scaled_linear_ring: ET.Element = ET.SubElement( + scaled_outer_boundary, "LinearRing") + scaled_coordinates: ET.Element = ET.SubElement( + scaled_linear_ring, "coordinates") arc: float = self.azimuth * math.pi / 180 - meterToDegree: float = 2 * math.pi * GeoLocation().equatorialRadius / 360 - translateX: float = ( - self.layout.size.x - * (self.cell_scale_factor / 100) - * math.sin(arc) - ) - translateY: float = ( - self.layout.size.y - * (self.cell_scale_factor / 100) - * math.cos(arc) + meterToDegree: float = ( + 2 * math.pi * GeoLocation().equatorialRadius / 360 ) centerX: float = self.layout.size.x * 0.5 * math.sin(arc) centerY: float = self.layout.size.y * 0.5 * math.cos(arc) - cell_center : GeoLocation = GeoLocation( + cell_center: GeoLocation = GeoLocation( { "latitude": tower.latitude + centerY / meterToDegree, "longitude": tower.longitude + centerX / meterToDegree, @@ -217,8 +222,12 @@ class NrCellDu(ORanNode): text = [] for gl in cell_polygon: scale: float = 1 + self.cell_scale_factor / 100 - lng_new: float = ( 1 * scale * (gl.longitude - cell_center.longitude) ) + cell_center.longitude - lat_new: float = ( 1 * scale * ( gl.latitude - cell_center.latitude ) ) + cell_center.latitude + lng_new: float = ( + 1 * scale * (gl.longitude - cell_center.longitude) + ) + cell_center.longitude + lat_new: float = ( + 1 * scale * (gl.latitude - cell_center.latitude) + ) + cell_center.latitude scaled_strs: list[str] = [ str("%.6f" % float(lng_new)), str("%.6f" % float(lat_new)), diff --git a/code/network-generator/network_generation/model/python/o_ran_network.py b/code/network-generator/network_generation/model/python/o_ran_network.py index 907c20d..962e5b1 100644 --- a/code/network-generator/network_generation/model/python/o_ran_network.py +++ b/code/network-generator/network_generation/model/python/o_ran_network.py @@ -63,11 +63,11 @@ class ORanNetwork(ORanObject): ) size: int = int( - int(configuration["pattern"]["nr-cell-du"]["maxReach"]) + int(configuration["pattern"]["nrCellDu"]["maxReach"]) / ( 1 + int( - configuration["pattern"]["nr-cell-du"][ + configuration["pattern"]["nrCellDu"][ "cellScaleFactorForHandoverArea" ] ) @@ -81,16 +81,16 @@ class ORanNetwork(ORanObject): { "oRanSmoSpiralRadiusOfNearRtRics": configuration["pattern"][ "smo" - ]["near-rt-ric-spiral-radius"], + ]["nearRtRicSpiralRadius"], "oRanNearRtRicSpiralRadiusOfOCus": configuration["pattern"][ - "near-rt-ric" - ]["o-ran-cu-spiral-radius"], + "nearRtRic" + ]["oRanCuSpiralRadius"], "oRanCuSpiralRadiusOfODus": configuration["pattern"][ - "o-ran-cu" - ]["o-ran-du-spiral-radius"], + "oRanCu" + ]["oRanDuSpiralRadius"], "oRanDuSpiralRadiusOfTowers": configuration["pattern"][ - "o-ran-du" - ]["tower-spiral-radius"], + "oRanDu" + ]["towerSpiralRadius"], } ) self._o_ran_smo = ORanSmo( diff --git a/code/network-generator/network_generation/model/python/o_ran_ru.py b/code/network-generator/network_generation/model/python/o_ran_ru.py index 05e901a..265e6f4 100644 --- a/code/network-generator/network_generation/model/python/o_ran_ru.py +++ b/code/network-generator/network_generation/model/python/o_ran_ru.py @@ -91,9 +91,9 @@ class ORanRu(ORanNode): result: list[NrCellDu] = [] cell_config: dict = ( self.parent.parent.parent.parent.parent.parent - .configuration["pattern"]["nr-cell-du"] + .configuration["pattern"]["nrCellDu"] ) - cell_angle: int = cell_config["cell-angle"] + cell_angle: int = cell_config["cellAngle"] cell_scale_factor: int = ( cell_config["cellScaleFactorForHandoverArea"] ) diff --git a/code/network-generator/network_generation/model/python/o_ran_termination_point.py b/code/network-generator/network_generation/model/python/o_ran_termination_point.py index 034c49a..03ecd2a 100644 --- a/code/network-generator/network_generation/model/python/o_ran_termination_point.py +++ b/code/network-generator/network_generation/model/python/o_ran_termination_point.py @@ -83,37 +83,33 @@ class ORanTerminationPoint(ORanObject): def to_topology(self) -> dict[str, Any]: result: dict[str, Any] = {"tp-id": self.name} - # TODO - # if self.supporter: - # network_ref: str = "" - # match self.parent.__qualname__: - # case ORanSmo.__qualname__: - # network_ref = self.parent.parent.id - # case "": - # network_ref = self.parent.parent.id - # case "": - # network_ref = self.parent.parent.parent.id - # case "": - # network_ref = self.parent.parent.parent.parent.id - # case "": - # network_ref = self.parent.parent.parent.parent.parent.id - # case "": - # network_ref = self.parent.parent.parent.parent.parent.id - # case "": - # network_ref = ( - # self.parent.parent.parent.parent.parent.parent.id - # ) - # case _: - # print("unknown: implement " + str(type(self.parent))) - # network_ref = "unknown: implement " + str( - # type(self.parent) - # ) - - # result["supporting-termination-point"] = [ - # { - # "network-ref": network_ref, - # "node-ref": self.parent.name, - # "tp-ref": self.supporter, - # } - # ] + if self.supporter and type(self.parent) is not int: + network_ref: str = "" + match str(type(self.parent)): + case "": + network_ref = self.parent.parent.id + case "": + network_ref = self.parent.parent.parent.id + case "": + network_ref = self.parent.parent.parent.parent.id + case "": + network_ref = self.parent.parent.parent.parent.parent.id + case "": + network_ref = self.parent.parent.parent.parent.parent.id + case "": + network_ref = ( + self.parent.parent.parent.parent.parent.parent.id + ) + case _: + print("unknown: implement " + str(type(self.parent))) + network_ref = "unknown: implement " + str( + type(self.parent)) + + result["supporting-termination-point"] = [ + { + "network-ref": network_ref, + "node-ref": self.parent.name, + "tp-ref": self.supporter, + } + ] return result diff --git a/code/network-generator/network_generation/model/python/tower.py b/code/network-generator/network_generation/model/python/tower.py index d650ee0..dd1eb70 100644 --- a/code/network-generator/network_generation/model/python/tower.py +++ b/code/network-generator/network_generation/model/python/tower.py @@ -29,7 +29,7 @@ from network_generation.model.python.o_ran_termination_point import ( ) -# Define the "IORanDu" interface +# Define the "IoRanDu" interface class ITower(IORanNode): o_ran_ru_count: int @@ -78,12 +78,12 @@ class Tower(ORanNode): cell_count: int = ( self.parent.parent.parent.parent.parent.configuration[ "pattern" - ]["o-ran-ru"]["nr-cell-du-count"] + ]["oRanRu"]["nrCellDuCount"] ) cell_angle: int = ( self.parent.parent.parent.parent.parent.configuration[ "pattern" - ]["nr-cell-du"]["cell-angle"] + ]["nrCellDu"]["cellAngle"] ) ru_angle: int = cell_count * cell_angle ru_azimuth: int = index * ru_angle