Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: padstack and siwave #792

Merged
merged 3 commits into from
Sep 17, 2024
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
2 changes: 1 addition & 1 deletion examples/use_configuration/import_ports.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@

port_5 = {"name": "port_5", "reference_designator": "U1", "type": "coax", "positive_terminal": {"pin": "AM17"}}

# ## Add a port reference to the neareast pin
# ## Add a port reference to the nearest pin

# Keywords
#
Expand Down
2 changes: 1 addition & 1 deletion src/pyedb/configuration/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def load(self, config_file, append=True, apply_file=False, output_file=None, ope
elif config_file.endswith(".toml"):
data = toml.load(f)
else: # pragma: no cover
return False
raise RuntimeError(f"File {config_file} does not exist.")

if not append: # pragma: no cover
self.data = {}
Expand Down
30 changes: 23 additions & 7 deletions src/pyedb/dotnet/edb_core/edb_data/padstacks_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,16 +426,32 @@ def __init__(self, edb_padstack, ppadstack):
self._edb_object = edb_padstack
self.edb_padstack = edb_padstack
self._ppadstack = ppadstack
self.pad_by_layer = {}
self.antipad_by_layer = {}
self.thermalpad_by_layer = {}
self._bounding_box = []
self._hole_params = None

@property
def pad_by_layer(self):
"""Regular pad property."""
temp = {}
for layer in self.via_layers:
temp[layer] = EDBPadProperties(self._edb_object, layer, 0, self)
return temp

@property
def antipad_by_layer(self):
"""Anti pad property."""
temp = {}
for layer in self.via_layers:
temp[layer] = EDBPadProperties(self._edb_object, layer, 1, self)
return temp

@property
def thermalpad_by_layer(self):
"""Thermal pad property."""
temp = {}
for layer in self.via_layers:
self.pad_by_layer[layer] = EDBPadProperties(edb_padstack, layer, 0, self)
self.antipad_by_layer[layer] = EDBPadProperties(edb_padstack, layer, 1, self)
self.thermalpad_by_layer[layer] = EDBPadProperties(edb_padstack, layer, 2, self)
pass
temp[layer] = EDBPadProperties(self._edb_object, layer, 2, self)
return temp

@property
def _padstack_def_data(self):
Expand Down
40 changes: 33 additions & 7 deletions src/pyedb/siwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import sys
import tempfile
import time
from typing import Optional, Union
import warnings

from pyedb import Edb
Expand Down Expand Up @@ -53,6 +54,15 @@ def wait_export_folder(flag, folder_path, time_sleep=0.5):
time.sleep(time_sleep)


def parser_file_path(file_path):
if isinstance(file_path, Path):
file_path = str(file_path)

if not Path(file_path).root:
file_path = str(Path().cwd() / file_path)
return file_path


class Siwave(object): # pragma no cover
"""Initializes SIwave based on the inputs provided and manages SIwave release and closing.

Expand Down Expand Up @@ -264,9 +274,9 @@ def open_project(self, proj_path=None):
``True`` when successful, ``False`` when failed.

"""

if os.path.exists(proj_path):
open_result = self.oSiwave.OpenProject(proj_path)
file_path = parser_file_path(proj_path)
if os.path.exists(file_path):
open_result = self.oSiwave.OpenProject(file_path)
self._oproject = self.oSiwave.GetActiveProject()
return open_result
else:
Expand Down Expand Up @@ -306,6 +316,22 @@ def save_project(self, projectpath=None, projectName=None):
self.oproject.Save()
return True

def save(self, file_path: Optional[Union[str, Path]]):
"""Save the project.

Parameters
----------
file_path : str, optional
Full path to the project. The default is ``None``.
"""

if file_path:
file_path = parser_file_path(file_path)
file_path = str(Path(file_path).with_suffix(".siw"))
self.oproject.ScrSaveProjectAs(file_path)
else:
self.oproject.Save()

def close_project(self, save_project=False):
"""Close the project.

Expand Down Expand Up @@ -494,6 +520,8 @@ def import_edb(self, file_path: str):
"""
if isinstance(file_path, Path):
file_path = str(file_path)
if not Path(file_path).root:
file_path = str(Path().cwd() / file_path)
flag = self.oproject.ScrImportEDB(file_path)
# self.save_project(self.di)
if flag == 0:
Expand All @@ -510,8 +538,7 @@ def load_configuration(self, file_path: str):
file_path : str
Path to the configuration file.
"""
if isinstance(file_path, Path):
file_path = str(file_path)
file_path = parser_file_path(file_path)

# temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
# temp_edb = os.path.join(temp_folder.name, "temp.aedb")
Expand All @@ -536,8 +563,7 @@ def export_configuration(self, file_path: str):
file_path : str
Path to the configuration file.
"""
if isinstance(file_path, Path):
file_path = str(file_path)
file_path = parser_file_path(file_path)

temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
temp_edb = os.path.join(temp_folder.name, "temp.aedb")
Expand Down
26 changes: 22 additions & 4 deletions tests/legacy/system/test_edb_configuration_2p0.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,28 @@ def test_05f_ports_between_two_points(self, edb_examples):
edbapp.close()

def test_06_s_parameters(self, edb_examples):
with open(self.local_input_folder / "s_parameter.json") as f:
data = json.load(f)
data["general"]["s_parameter_library"] = self.local_input_folder

data = {
"general": {"s_parameter_library": self.local_input_folder},
"s_parameters": [
{
"name": "GRM32_DC0V_25degC_series",
"file_path": "GRM32_DC0V_25degC_series.s2p",
"component_definition": "CAPC3216X180X55ML20T25",
"apply_to_all": True,
"components": [],
"reference_net": "GND",
},
{
"name": "GRM32_DC0V_25degC_series",
"file_path": "GRM32_DC0V_25degC_series.s2p",
"apply_to_all": False,
"component_definition": "CAPC3216X190X55ML30T25",
"components": ["C59"],
"reference_net": "GND",
"reference_net_per_component": {"C59": "GND"},
},
],
}
hui-zhou-a marked this conversation as resolved.
Show resolved Hide resolved
edbapp = edb_examples.get_si_verse()
assert edbapp.configuration.load(data, apply_file=True)
assert len(edbapp.components.nport_comp_definition) == 2
Expand Down
Loading