Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/pyedb/configuration/cfg_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -84,12 +84,14 @@ 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")

# create a polygon on pyedb layer

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}
15 changes: 7 additions & 8 deletions src/pyedb/configuration/cfg_pin_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand Down
5 changes: 4 additions & 1 deletion src/pyedb/dotnet/edb_core/cell/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/pyedb/dotnet/edb_core/cell/terminal/pingroup_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down
7 changes: 5 additions & 2 deletions src/pyedb/dotnet/edb_core/modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
4 changes: 2 additions & 2 deletions tests/legacy/system/test_edb_configuration_2p0.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand Down
24 changes: 22 additions & 2 deletions tests/legacy/system/test_siwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()