diff --git a/src/pyedb/configuration/cfg_operations.py b/src/pyedb/configuration/cfg_operations.py index b2fea2e2a3..ed31cbac5f 100644 --- a/src/pyedb/configuration/cfg_operations.py +++ b/src/pyedb/configuration/cfg_operations.py @@ -65,7 +65,7 @@ def get_data_from_db(self): self.reference_list = [] self.signal_list = net_names - return self.export_properties() + return self.export_properties() def export_properties(self): return { @@ -84,7 +84,7 @@ def apply(self): """Imports operation information from JSON.""" if self.op_cutout: polygon_points = self._pedb.cutout(**self.op_cutout.get_attributes()) - if not "pyedb_cutout" in self._pedb.stackup.all_layers: + if "pyedb_cutout" not in self._pedb.stackup.all_layers: self._pedb.stackup.add_document_layer(name="pyedb_cutout") self._pedb.modeler.create_polygon(polygon_points, layer_name="pyedb_cutout", net_name="pyedb_cutout") @@ -92,4 +92,6 @@ def apply(self): def get_data_from_db(self): self.op_cutout = CfgCutout(self._pedb) - return {"cutout": self.op_cutout.get_data_from_db()} + data_from_db = self.op_cutout.get_data_from_db() + if data_from_db: + return {"cutout": data_from_db} diff --git a/src/pyedb/configuration/cfg_pin_groups.py b/src/pyedb/configuration/cfg_pin_groups.py index 7bb8bb6d8d..05c8e3c224 100644 --- a/src/pyedb/configuration/cfg_pin_groups.py +++ b/src/pyedb/configuration/cfg_pin_groups.py @@ -36,12 +36,14 @@ def apply(self): def get_data_from_db(self): self.pin_groups = [] - for name, pg in self._pedb.siwave.pin_groups.items(): - pins = [p.aedt_name for p in pg.pins.values()] + layout_pin_groups = self._pedb.siwave.pin_groups + for pg_name, pg_obj in layout_pin_groups.items(): + pins = list(pg_obj.pins.keys()) + refdes = list(pg_obj.pins.values())[0].component.name cfg_pg = CfgPinGroup( self._pedb, - name=name, - reference_designator=None, + name=pg_name, + reference_designator=refdes, pins=pins, ) self.pin_groups.append(cfg_pg) @@ -65,10 +67,7 @@ def __init__(self, pedb, **kwargs): def create(self): """Apply pin group on layout.""" if self.pins: - if self.reference_designator is None: - self._pedb.modeler.create_pin_group(self.name, pins_by_aedt_name=self.pins) - else: - self._pedb.siwave.create_pin_group(self.reference_designator, list(self.pins), self.name) + self._pedb.siwave.create_pin_group(self.reference_designator, list(self.pins), self.name) elif self.net: if self.reference_designator in self._pedb.components.instances: comp = self._pedb.components.instances[self.reference_designator] diff --git a/src/pyedb/dotnet/edb_core/cell/layout.py b/src/pyedb/dotnet/edb_core/cell/layout.py index d67cd44089..366217ec3e 100644 --- a/src/pyedb/dotnet/edb_core/cell/layout.py +++ b/src/pyedb/dotnet/edb_core/cell/layout.py @@ -323,7 +323,10 @@ def find_net_by_name(self, value: str): """ obj = self._pedb._edb.Cell.Net.FindByName(self._edb_object, value) - return EDBNetsData(obj, self._pedb) if obj is not None else None + if obj.IsNull(): + raise ValueError(f"Net {value} doesn't exist") + else: + return EDBNetsData(obj, self._pedb) def find_component_by_name(self, value: str): """Find a component object by name. Component name is the reference designator in layout. diff --git a/src/pyedb/dotnet/edb_core/cell/terminal/pingroup_terminal.py b/src/pyedb/dotnet/edb_core/cell/terminal/pingroup_terminal.py index b2b723bbf9..9914f32d34 100644 --- a/src/pyedb/dotnet/edb_core/cell/terminal/pingroup_terminal.py +++ b/src/pyedb/dotnet/edb_core/cell/terminal/pingroup_terminal.py @@ -47,10 +47,10 @@ def create(self, name, net_name, pin_group_name, is_ref=False): ------- :class:`pyedb.dotnet.edb_core.edb_data.terminals.PinGroupTerminal` """ - net_obj = self._pedb.edb_api.cell.net.find_by_name(self._pedb.active_layout, net_name) + net_obj = self._pedb.layout.find_net_by_name(net_name) term = self._pedb.edb_api.cell.terminal.PinGroupTerminal.Create( self._pedb.active_layout, - net_obj.api_object, + net_obj._edb_object, name, self._pedb.siwave.pin_groups[pin_group_name]._edb_object, is_ref, @@ -60,7 +60,7 @@ def create(self, name, net_name, pin_group_name, is_ref=False): msg = f"Failed to create terminal. " if name in self._pedb.terminals: msg += f"Terminal {name} already exists." - raise Exception(msg) + raise ValueError(msg) else: return term diff --git a/src/pyedb/dotnet/edb_core/modeler.py b/src/pyedb/dotnet/edb_core/modeler.py index bed4e89d5f..7644a723bc 100644 --- a/src/pyedb/dotnet/edb_core/modeler.py +++ b/src/pyedb/dotnet/edb_core/modeler.py @@ -1460,6 +1460,9 @@ def create_pin_group( self._pedb.active_layout, name, convert_py_list_to_net_list(pins) ) if obj.IsNull(): - self._logger.debug("Pin group creation returned Null obj.") - return False + raise RuntimeError(f"Failed to create pin group {name}.") + else: + net_obj = [i.GetNet() for i in pins if not i.GetNet().IsNull()] + if net_obj: + obj.SetNet(net_obj[0]) return self._pedb.siwave.pin_groups[name] diff --git a/tests/legacy/system/test_edb_configuration_2p0.py b/tests/legacy/system/test_edb_configuration_2p0.py index 72221f6fc6..91e05e9240 100644 --- a/tests/legacy/system/test_edb_configuration_2p0.py +++ b/tests/legacy/system/test_edb_configuration_2p0.py @@ -156,7 +156,7 @@ def test_02_pin_groups(self, edb_examples): pin_groups = [ {"name": "U9_5V_1", "reference_designator": "U9", "pins": ["32", "33"]}, {"name": "U9_GND", "reference_designator": "U9", "net": "GND"}, - {"name": "J3", "pins": ["J3-6", "J3-8"]}, + {"name": "X1_5V", "reference_designator": "X1", "pins": ["A17", "A18", "B17", "B18"]}, ] data = {"pin_groups": pin_groups} assert edbapp.configuration.load(data, apply_file=True) @@ -165,7 +165,7 @@ def test_02_pin_groups(self, edb_examples): data_from_db = edbapp.configuration.cfg_data.pin_groups.get_data_from_db() assert data_from_db[0]["name"] == "U9_5V_1" - assert data_from_db[0]["pins"] == ["U9-32", "U9-33"] + assert data_from_db[0]["pins"] == ["32", "33"] edbapp.close() def test_03_spice_models(self, edb_examples): diff --git a/tests/legacy/system/test_siwave.py b/tests/legacy/system/test_siwave.py index b00a68c311..c6726be675 100644 --- a/tests/legacy/system/test_siwave.py +++ b/tests/legacy/system/test_siwave.py @@ -69,9 +69,21 @@ def test_configuration(self, edb_examples): "type": "circuit", "positive_terminal": {"pin": "B8"}, "negative_terminal": {"net": "GND"}, - }, - ] + } + ], + "operations": { + "cutout": { + "custom_extent": [ + [77, 54], + [5, 54], + [5, 20], + [77, 20], + ], + "custom_extent_units": "mm", + } + }, } + cfg_json = os.path.join(edb_examples.test_folder, "cfg.json") with open(cfg_json, "w") as f: json.dump(data, f) @@ -82,3 +94,11 @@ def test_configuration(self, edb_examples): cfg_json_2 = os.path.join(edb_examples.test_folder, "cfg2.json") siw.export_configuration(cfg_json_2) siw.quit_application() + with open(cfg_json_2, "r") as f: + json_data = json.load(f) + assert json_data["ports"][0]["name"] == "CIRCUIT_X1_B8_GND" + + siw = Siwave(desktop_version) + siw.import_edb(edbapp) + siw.load_configuration(cfg_json_2) + siw.quit_application()