Add to_directory method to relevant object classes
[oam.git] / code / network-generator / network_generation / model / python / o_ran_ru.py
index e8ca9cf..c88dfec 100644 (file)
@@ -18,6 +18,7 @@
 A Class representing an O-RAN radio unit (ORanRu)
 """
 import xml.etree.ElementTree as ET
+import os
 from typing import Any, cast
 
 from network_generation.model.python.nr_cell_du import NrCellDu
@@ -70,6 +71,7 @@ class ORanRu(ORanNode):
         )
         self._cells: list[NrCellDu] = self._create_cells()
         name: str = self.name.replace("RU", "DU")
+        self.type = "ntsim-ng-o-ru"
 
         o_ran_du_data: dict[str, Any] = {
             "name": name,
@@ -89,11 +91,15 @@ class ORanRu(ORanNode):
 
     def _create_cells(self) -> list[NrCellDu]:
         result: list[NrCellDu] = []
-        cell_angle: int = (
-            self.parent.parent.parent.parent.parent.parent.configuration[
-                "pattern"
-            ]["nr-cell-du"]["cell-angle"]
+        cell_config: dict = (
+            self.parent.parent.parent.parent.parent.parent
+            .configuration["pattern"]["nrCellDu"]
         )
+        cell_angle: int = cell_config["cellAngle"]
+        cell_scale_factor: int = (
+            cell_config["cellScaleFactorForHandoverArea"]
+        )
+        maxReach: int = cell_config["maxReach"]
         for index in range(self._cell_count):
             s: str = "00" + str(index)
             name: str = "-".join(
@@ -109,6 +115,8 @@ class ORanRu(ORanNode):
                         "layout": self.layout,
                         "parent": self,
                         "cellAngle": cell_angle,
+                        "cellScaleFactorForHandoverArea": cell_scale_factor,
+                        "maxReach": maxReach,
                         "azimuth": azimuth,
                     }
                 )
@@ -179,3 +187,12 @@ class ORanRu(ORanNode):
 
     def toSvg(self) -> ET.Element:
         return ET.Element("to-be-implemented")
+
+    def to_directory(self, parent_dir: str) -> None:
+        self.oRanDu.to_directory(parent_dir)
+        parent_path = os.path.join(parent_dir, self.type)
+        path = os.path.join(parent_path, self.name)
+        if not os.path.exists(parent_path):
+            os.makedirs(parent_path, exist_ok=True)
+        if not os.path.exists(path):
+            os.mkdir(path)