From d135483cd94cb87d8c27c2ae67de302718430f4b Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Wed, 24 Apr 2024 14:29:52 +0200 Subject: [PATCH] FEAT: Siwave icepak settings (#404) * FEATURE: add icepak property siwave.py * FEATURE: update edb_example class. * FEATURE: add unittest * MISC: Auto fixes from pre-commit.com hooks For more information, see https://pre-commit.ci * Fix PR tittle --------- Co-authored-by: ring630 <@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/pyedb/dotnet/edb_core/siwave.py | 31 + .../siwave/icepak_component.pwrd | 854 ++++++++++++++++++ tests/legacy/system/conftest.py | 41 +- tests/legacy/system/test_edb.py | 10 + 4 files changed, 925 insertions(+), 11 deletions(-) create mode 100644 tests/example_models/siwave/icepak_component.pwrd diff --git a/src/pyedb/dotnet/edb_core/siwave.py b/src/pyedb/dotnet/edb_core/siwave.py index 31f6210c0a..56695a478c 100644 --- a/src/pyedb/dotnet/edb_core/siwave.py +++ b/src/pyedb/dotnet/edb_core/siwave.py @@ -1454,3 +1454,34 @@ def place_voltage_probe( p_terminal = self._pedb.get_point_terminal(name, positive_net_name, positive_location, positive_layer) n_terminal = self._pedb.get_point_terminal(name + "_ref", negative_net_name, negative_location, negative_layer) return self._pedb.create_voltage_probe(p_terminal, n_terminal) + + @property + def icepak_use_minimal_comp_defaults(self): + """Icepak default setting. If "True", only resistor are active in Icepak simulation. + The power dissipation of the resistors are calculated from DC results. + """ + siwave_id = self._pedb.edb_api.ProductId.SIWave + cell = self._pedb.active_cell._active_cell + _, value = cell.GetProductProperty(siwave_id, 422, "") + return bool(value) + + @icepak_use_minimal_comp_defaults.setter + def icepak_use_minimal_comp_defaults(self, value): + value = "True" if bool(value) else "" + siwave_id = self._pedb.edb_api.ProductId.SIWave + cell = self._pedb.active_cell._active_cell + cell.SetProductProperty(siwave_id, 422, value) + + @property + def icepak_component_file(self): + """Icepak component file path.""" + siwave_id = self._pedb.edb_api.ProductId.SIWave + cell = self._pedb.active_cell._active_cell + _, value = cell.GetProductProperty(siwave_id, 420, "") + return value + + @icepak_component_file.setter + def icepak_component_file(self, value): + siwave_id = self._pedb.edb_api.ProductId.SIWave + cell = self._pedb.active_cell._active_cell + cell.SetProductProperty(siwave_id, 420, value) diff --git a/tests/example_models/siwave/icepak_component.pwrd b/tests/example_models/siwave/icepak_component.pwrd new file mode 100644 index 0000000000..0a424fee9b --- /dev/null +++ b/tests/example_models/siwave/icepak_component.pwrd @@ -0,0 +1,854 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/legacy/system/conftest.py b/tests/legacy/system/conftest.py index 00bb34978a..228ebd3700 100644 --- a/tests/legacy/system/conftest.py +++ b/tests/legacy/system/conftest.py @@ -49,25 +49,44 @@ class EdbExamples: def __init__(self, local_scratch): self.local_scratch = local_scratch - - @property - def _local_folder(self): - return os.path.join(self.local_scratch.path, generate_random_string(6)) - - def _get_folder(self, name): - src = os.path.join(example_models_path, name) - dst = self.local_scratch.copyfolder(src, os.path.join(self._local_folder, os.path.split(src)[-1])) + self.example_models_path = example_models_path + self._test_folder = "" + + def get_local_file_folder(self, name): + return os.path.join(self.local_scratch.path, name) + + def _create_test_folder(self): + """Create a local folder under `local_scratch`.""" + self._test_folder = os.path.join(self.local_scratch.path, generate_random_string(6)) + return self._test_folder + + def _copy_file_folder_into_local_folder(self, file_folder_path): + src = os.path.join(self.example_models_path, file_folder_path) + local_folder = self._create_test_folder() + file_folder_name = os.path.join(local_folder, os.path.split(src)[-1]) + dst = self.local_scratch.copyfolder(src, file_folder_name) return dst - def get_si_verse(self, edbapp=True): - aedb = self._get_folder("TEDB/ANSYS-HSD_V1.aedb") + def get_si_verse(self, edbapp=True, additional_files_folders=""): + aedb = self._copy_file_folder_into_local_folder("TEDB/ANSYS-HSD_V1.aedb") + if additional_files_folders: + files = ( + additional_files_folders if isinstance(additional_files_folders, list) else [additional_files_folders] + ) + for f in files: + src = os.path.join(self.example_models_path, f) + file_folder_name = os.path.join(self._test_folder, os.path.split(src)[-1]) + if os.path.isfile(src): + self.local_scratch.copyfile(src, file_folder_name) + else: + self.local_scratch.copyfolder(src, file_folder_name) if edbapp: return Edb(aedb, edbversion=desktop_version) else: return aedb def get_multizone_pcb(self): - aedb = self._get_folder("multi_zone_project.aedb") + aedb = self._copy_file_folder_into_local_folder("multi_zone_project.aedb") return Edb(aedb, edbversion=desktop_version) diff --git a/tests/legacy/system/test_edb.py b/tests/legacy/system/test_edb.py index 949e8ba3b3..7185e6e28c 100644 --- a/tests/legacy/system/test_edb.py +++ b/tests/legacy/system/test_edb.py @@ -1732,3 +1732,13 @@ def test_multizone(self, edb_examples): assert defined_ports assert project_connexions edbapp.close_edb() + + def test_icepak(self, edb_examples): + edbapp = edb_examples.get_si_verse(additional_files_folders=["siwave/icepak_component.pwrd"]) + edbapp.siwave.icepak_use_minimal_comp_defaults = True + assert edbapp.siwave.icepak_use_minimal_comp_defaults + edbapp.siwave.icepak_use_minimal_comp_defaults = False + assert not edbapp.siwave.icepak_use_minimal_comp_defaults + edbapp.siwave.icepak_component_file = edb_examples.get_local_file_folder("siwave/icepak_component.pwrd") + assert edbapp.siwave.icepak_component_file == edb_examples.get_local_file_folder("siwave/icepak_component.pwrd") + edbapp.close()