diff --git a/doc/changelog.d/1947.fixed.md b/doc/changelog.d/1947.fixed.md new file mode 100644 index 0000000000..2ebcee4fa1 --- /dev/null +++ b/doc/changelog.d/1947.fixed.md @@ -0,0 +1 @@ +Issue #1063 fixed source to ground diff --git a/src/pyedb/dotnet/database/sim_setup_data/data/siw_dc_ir_settings.py b/src/pyedb/dotnet/database/sim_setup_data/data/siw_dc_ir_settings.py index 19a099e7ce..7c4e3580d4 100644 --- a/src/pyedb/dotnet/database/sim_setup_data/data/siw_dc_ir_settings.py +++ b/src/pyedb/dotnet/database/sim_setup_data/data/siw_dc_ir_settings.py @@ -21,7 +21,6 @@ # SOFTWARE. from pyedb.dotnet.database.general import ( - convert_netdict_to_pydict, convert_pydict_to_netdict, ) from pyedb.misc.decorators import deprecated_property @@ -241,8 +240,9 @@ def source_terms_to_ground(self): str: source name, int: node to ground pairs, 0 (unspecified), 1 (negative), 2 (positive) . """ - temp = self._parent.get_sim_setup_info.simulation_settings.DCIRSettings.SourceTermsToGround - return convert_netdict_to_pydict(temp) + temp = dict(self._parent.get_sim_setup_info.simulation_settings.DCIRSettings.SourceTermsToGround) + temp = {name.strip("'"): node for name, node in temp.items()} # strip single quotes from the source names + return temp @source_terms_to_ground.setter def source_terms_to_ground(self, value): diff --git a/src/pyedb/dotnet/database/utilities/siwave_simulation_setup.py b/src/pyedb/dotnet/database/utilities/siwave_simulation_setup.py index 5ad39cb082..c5f0d52bd3 100644 --- a/src/pyedb/dotnet/database/utilities/siwave_simulation_setup.py +++ b/src/pyedb/dotnet/database/utilities/siwave_simulation_setup.py @@ -22,7 +22,6 @@ import warnings from pyedb.dotnet.database.general import ( - convert_netdict_to_pydict, convert_pydict_to_netdict, ) from pyedb.dotnet.database.sim_setup_data.data.sim_setup_info import SimSetupInfo @@ -245,7 +244,7 @@ def via_report_path(self) -> str: def via_report_path(self, value: str): self.dc_ir.via_report_path = value - def add_source_terminal_to_ground(self, source_name, terminal=0): + def add_source_terminal_to_ground(self, source_name, terminal=0) -> None: """Add a source terminal to ground. Parameters @@ -261,13 +260,11 @@ def add_source_terminal_to_ground(self, source_name, terminal=0): Returns ------- - bool - + None """ terminals = self.dc_ir.source_terms_to_ground terminals[source_name] = terminal - self._sim_setup_info.simulation_settings.DCIRSettings.SourceTermsToGround = convert_pydict_to_netdict(terminals) - return self._update_setup() + self.dc_ir.source_terms_to_ground = terminals class SIwaveSimulationSetup(SimulationSetup): diff --git a/src/pyedb/grpc/database/simulation_setup/siwave_dcir_settings.py b/src/pyedb/grpc/database/simulation_setup/siwave_dcir_settings.py index 3832bdf4d1..2d44dd3770 100644 --- a/src/pyedb/grpc/database/simulation_setup/siwave_dcir_settings.py +++ b/src/pyedb/grpc/database/simulation_setup/siwave_dcir_settings.py @@ -192,6 +192,20 @@ def per_pin_use_pin_format(self) -> bool: def per_pin_use_pin_format(self, value): self.core.per_pin_use_pin_format = value + def add_source_terminal_to_ground(self, source_name: str, terminal: int = 1) -> None: + """Add source terminal to ground mapping. + + Parameters + ---------- + source_name : str + Source terminal name. + terminal : int + The terminal number to reference. `0` set the positive terminal `1` set the negative terminal as reference. + Default is `1` + """ + temp = {source_name: terminal} + self.source_terms_to_ground = {**self.source_terms_to_ground, **temp} + @property def source_terms_to_ground(self) -> dict[str, int]: """Source terms to ground mapping. diff --git a/tests/system/test_edb.py b/tests/system/test_edb.py index 8490a7411c..995fb2dcf8 100644 --- a/tests/system/test_edb.py +++ b/tests/system/test_edb.py @@ -100,6 +100,13 @@ def test_siwave_create_voltage_source(self): term2 = u6.pins["F1"].get_terminal(create_new_terminal=True) voltage_source = edbapp.create_voltage_source(terminal=term1, ref_terminal=term2) assert not voltage_source.is_null + # testing source to ground assignment + setup = edbapp.siwave.add_siwave_dc_analysis(name="Test_dc") + setup.settings.add_source_terminal_to_ground("Vsource_U1_USB3_D_P_U1_GND", 1) + if edbapp.grpc: + assert "Vsource_U1_USB3_D_P_U1_GND" in setup.settings.dc.source_terms_to_ground + else: + assert "Vsource_U1_USB3_D_P_U1_GND" in setup.settings.dc_ir.source_terms_to_ground edbapp.close(terminate_rpc_session=False) def test_siwave_create_current_source(self):