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

siwave current source test passed #53

Merged
merged 1 commit into from
Nov 6, 2023
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
38 changes: 22 additions & 16 deletions src/pyedb/grpc/edb_core/edb_data/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,11 @@ def net_name(self):
@pyedb_function_handler()
def _create_pin_group_terminal(self, is_reference=False):
if not self._edb_pin_group.is_null:
pin_group_net = self._edb_pin_group.pins[0].net
pin_group_net = [pin.net for pin in self._edb_pin_group.pins if not pin.net.is_null]
if pin_group_net:
pin_group_net = pin_group_net[0]
else:
return False
return terminal.PinGroupTerminal.create(
layout=self._active_layout,
net_ref=pin_group_net,
Expand All @@ -294,27 +298,29 @@ def _create_pin_group_terminal(self, is_reference=False):

@pyedb_function_handler()
def create_current_source_terminal(self, magnitude=1, phase=0):
terminal = self._create_pin_group_terminal()
terminal.boundary_type = terminal.BoundaryType.CURRENT_SOURCE
terminal.source_amplitude = utility.Value(magnitude)
terminal.source_phase = utility.Value(phase)
return terminal
edb_terminal = self._create_pin_group_terminal()
if not edb_terminal.is_null:
edb_terminal.boundary_type = terminal.BoundaryType.CURRENT_SOURCE
edb_terminal.source_amplitude = utility.Value(magnitude)
edb_terminal.source_phase = utility.Value(phase)
return edb_terminal
return False

@pyedb_function_handler()
def create_voltage_source_terminal(self, magnitude=1, phase=0, impedance=0.001):
terminal = self._create_pin_group_terminal()
terminal.boundary_type = terminal.BoundaryType.VOLTAGE_SOURCE
terminal.source_amplitude = utility.Value(magnitude)
terminal.source_phase = utility.Value(phase)
terminal.impedance = utility.Value(impedance)
return terminal
edb_terminal = self._create_pin_group_terminal()
edb_terminal.boundary_type = terminal.BoundaryType.VOLTAGE_SOURCE
edb_terminal.source_amplitude = utility.Value(magnitude)
edb_terminal.source_phase = utility.Value(phase)
edb_terminal.impedance = utility.Value(impedance)
return edb_terminal

@pyedb_function_handler()
def create_voltage_probe_terminal(self, impedance=1000000):
terminal = self._create_pin_group_terminal()
terminal.boundary_type = terminal.BoundaryType.VOLTAGE_PROBE
terminal.impedance = utility.Value(impedance)
return terminal
edb_terminal = self._create_pin_group_terminal()
edb_terminal.boundary_type = terminal.BoundaryType.VOLTAGE_PROBE
edb_terminal.impedance = utility.Value(impedance)
return edb_terminal

@pyedb_function_handler()
def create_port_terminal(self, impedance=50):
Expand Down
12 changes: 5 additions & 7 deletions src/pyedb/grpc/siwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,9 @@ def create_current_source_on_pin(self, pos_pin, neg_pin, current_value=0.1, phas
current_source.phase = phase_value
if not source_name:
source_name = "ISource_{}_{}_{}_{}".format(
pos_pin.component.name,
pos_pin.component.refdes,
pos_pin.net.name,
neg_pin.component.name,
neg_pin.component.refdes,
neg_pin.net.name,
)
current_source.name = source_name
Expand Down Expand Up @@ -901,14 +901,12 @@ def create_pin_group_terminal(self, source):
self._logger.warning("Port already exists with same name. Renaming to {}".format(source.name))
pos_pin_group = self._pedb.components.create_pingroup_from_pins(source.positive_node.node_pins)
pos_node_net = self._pedb.nets.get_net_by_name(source.positive_node.net)

pos_pingroup_term_name = source.name
pos_pingroup_terminal = terminal.PinGroupTerminal.create(layout=self._active_layout,
net_ref=pos_node_net.net_object,
name=pos_pingroup_term_name,
pin_group=pos_pin_group,
is_ref=False)
time.sleep(0.5)
if source.negative_node.node_pins:
neg_pin_group = self._pedb.components.create_pingroup_from_pins(source.negative_node.node_pins)
neg_node_net = self._pedb.nets.get_net_by_name(source.negative_node.net)
Expand Down Expand Up @@ -1268,12 +1266,12 @@ def create_current_source_on_pin_group(
pos_pin_group = self.pin_groups[pos_pin_group_name]
pos_terminal = pos_pin_group.create_current_source_terminal(magnitude, phase)
if name:
pos_terminal.SetName(name)
pos_terminal.name = name
else:
name = generate_unique_name("isource")
pos_terminal.name = name
neg_pin_group_name = self.pin_groups[neg_pin_group_name]
neg_terminal = neg_pin_group_name.create_current_source_terminal()
neg_pin = self.pin_groups[neg_pin_group_name]
neg_terminal = neg_pin.create_current_source_terminal()
neg_terminal.name = name + "_ref"
pos_terminal.reference_terminal = neg_terminal
return True
Expand Down
11 changes: 2 additions & 9 deletions tests/grpc/system/test_edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,10 @@ def test_siwave_create_current_source(self):
self.edbapp.siwave.create_current_source_on_pin_group(
pos_pin_group_name="vrm_pos", neg_pin_group_name="gnd", name="vrm_current_source"
)

self.edbapp.siwave.create_pin_group(
reference_designator="U1", pin_numbers=["A14", "A15"], group_name="sink_pos"
)

# TODO: Moves this piece of code in another place
assert self.edbapp.siwave.create_voltage_source_on_pin_group("sink_pos", "gnd", name="vrm_voltage_source")
self.edbapp.siwave.create_pin_group(reference_designator="U1", pin_numbers=["A27", "A28"], group_name="vp_pos")
self.edbapp.siwave.create_pin_group(reference_designator="U1", pin_numbers=["A14", "A15"], group_name="vp_neg")
assert self.edbapp.siwave.create_voltage_probe_on_pin_group("vprobe", "vp_pos", "vp_neg")
assert self.edbapp.probes["vprobe"]
assert self.edbapp.siwave.pin_groups["vp_pos"]
assert self.edbapp.siwave.pin_groups["vp_neg"]

def test_siwave_create_dc_terminal(self):
"""Create a DC terminal."""
Expand Down
Loading