Skip to content

Commit 52da4fd

Browse files
committed
test #4 done
1 parent a1cf8d7 commit 52da4fd

File tree

11 files changed

+346
-232
lines changed

11 files changed

+346
-232
lines changed

src/pyedb/grpc/edb.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
from pyedb.grpc.application.Variables import Variable, decompose_variable_value
3434
from pyedb.grpc.edb_core.components import Components
3535
from pyedb.grpc.edb_core.control_file import ControlFile, convert_technology_file
36-
from pyedb.grpc.edb_core.excitation import Excitation
3736
from pyedb.grpc.edb_core.hfss import Hfss
3837
from pyedb.grpc.edb_core.layout.layout import Layout
3938
from pyedb.grpc.edb_core.layout_validation import LayoutValidation
@@ -69,6 +68,7 @@
6968
SiwaveSimulationSetup,
7069
)
7170
from pyedb.grpc.edb_core.siwave import Siwave
71+
from pyedb.grpc.edb_core.source_excitations import SourceExcitation
7272
from pyedb.grpc.edb_core.stackup import Stackup
7373
from pyedb.grpc.edb_core.terminal.padstack_instance_terminal import (
7474
PadstackInstanceTerminal,
@@ -337,7 +337,7 @@ def _init_objects(self):
337337
self._nets = Nets(self)
338338
self._modeler = Modeler(self)
339339
self._materials = Materials(self)
340-
self._excitation = Excitation(self)
340+
self._source_excitation = SourceExcitation(self)
341341

342342
@property
343343
def cell_names(self):
@@ -743,10 +743,9 @@ def stackup(self):
743743
return self._stackup
744744

745745
@property
746-
def excitation(self):
746+
def source_excitation(self):
747747
if self.active_db:
748-
self._excitation = Excitation(self)
749-
return self._excitation
748+
return self._source_excitation
750749

751750
@property
752751
def materials(self):
@@ -2754,7 +2753,7 @@ def get_bounding_box(self):
27542753
"""
27552754
lay_inst_polygon_data = [obj_inst.get_bbox() for obj_inst in self.layout_instance.query_layout_obj_instances()]
27562755
layout_bbox = GrpcPolygonData.bbox_of_polygons(lay_inst_polygon_data)
2757-
return [layout_bbox[0].x.value, layout_bbox[0].y.value, layout_bbox[1].x.value, layout_bbox[1].y.value]
2756+
return [[layout_bbox[0].x.value, layout_bbox[0].y.value], [layout_bbox[1].x.value, layout_bbox[1].y.value]]
27582757

27592758
def build_simulation_project(self, simulation_setup):
27602759
# type: (SimulationConfiguration) -> bool

src/pyedb/grpc/edb_core/components.py

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,34 @@ def get_component_by_name(self, name):
471471
"""
472472
return self.instances[name]
473473

474+
def get_pin_from_component(self, component, net_name=None, pin_name=None):
475+
"""Return component pins.
476+
Parameters
477+
----------
478+
component : :class: `Component` or str.
479+
Component object or component name.
480+
net_name : str, List[str], optional
481+
Apply filter on net name.
482+
pin_name : str, optional
483+
Apply filter on specific pin name.
484+
Return
485+
------
486+
List[:clas: `PadstackInstance`]
487+
488+
489+
490+
"""
491+
if isinstance(component, Component):
492+
component = component.name
493+
pins = [pin for pin in list(self.instances[component].pins.values())]
494+
if net_name:
495+
if isinstance(net_name, str):
496+
net_name = [net_name]
497+
pins = [pin for pin in pins if pin.net_name in net_name]
498+
if pin_name:
499+
pins = [pin for pin in pins if pin.name == pin_name]
500+
return pins
501+
474502
def get_components_from_nets(self, netlist=None):
475503
"""Retrieve components from a net list.
476504
@@ -2232,8 +2260,8 @@ def create_pin_group(self, reference_designator, pin_numbers, group_name=None):
22322260
----------
22332261
reference_designator : str
22342262
References designator of the component.
2235-
pin_numbers : int, str, list
2236-
List of pin names.
2263+
pin_numbers : int, str, list[str] or list[:class: `PadstackInstance]`
2264+
List of pins.
22372265
group_name : str, optional
22382266
Name of the pin group.
22392267
@@ -2247,7 +2275,7 @@ def create_pin_group(self, reference_designator, pin_numbers, group_name=None):
22472275
if group_name is None:
22482276
group_name = PinGroup.unique_name(self._active_layout, "")
22492277
comp = self.instances[reference_designator]
2250-
pins = [pin.pin for name, pin in comp.pins.items() if name in pin_numbers]
2278+
pins = [pin for pin in list(comp.pins.values()) if pin.name in pin_numbers]
22512279
edb_pingroup = PinGroup.create(self._active_layout, group_name, pins)
22522280

22532281
if edb_pingroup.is_null: # pragma: no cover
@@ -2256,7 +2284,7 @@ def create_pin_group(self, reference_designator, pin_numbers, group_name=None):
22562284
else:
22572285
names = [i for i in pins if i.net.name]
22582286
edb_pingroup.net = names[0].net
2259-
return group_name, self._pedb.layout.pin_groups[group_name]
2287+
return group_name
22602288

22612289
def create_pin_group_on_net(self, reference_designator, net_name, group_name=None):
22622290
"""Create pin group on component by net name.
@@ -2274,5 +2302,7 @@ def create_pin_group_on_net(self, reference_designator, net_name, group_name=Non
22742302
-------
22752303
PinGroup
22762304
"""
2277-
pins = [pin.name for pin in self.instances[reference_designator].pins if pin.name == net_name]
2305+
pins = [
2306+
pin.name for pin in list(self.instances[reference_designator].pins.values()) if pin.net_name == net_name
2307+
]
22782308
return self.create_pin_group(reference_designator, pins, group_name)

src/pyedb/grpc/edb_core/hfss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def create_circuit_port_on_net(
328328
"`pyedb.grpc.core.excitations.create_circuit_port_on_net` instead.",
329329
DeprecationWarning,
330330
)
331-
return self._pedb.excitations.create_circuit_port_on_net(
331+
return self._pedb.source_excitation.create_circuit_port_on_net(
332332
positive_component_name,
333333
positive_net_name,
334334
negative_component_name,

src/pyedb/grpc/edb_core/hierarchy/pingroup.py

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,10 @@
3535
class PinGroup(GrpcPinGroup):
3636
"""Manages pin groups."""
3737

38-
def __init__(self, pedb, edb_pin_group):
39-
super().__init__(edb_pin_group.msg)
38+
def __init__(self, pedb, edb_pin_group=None):
39+
if edb_pin_group:
40+
super().__init__(edb_pin_group.msg)
4041
self._pedb = pedb
41-
self._edb_pin_group = edb_pin_group
42-
self._name = edb_pin_group.name
43-
self._component = ""
44-
self._node_pins = []
45-
self._net = ""
46-
self._edb_object = self._edb_pin_group
4742

4843
@property
4944
def _active_layout(self):
@@ -52,37 +47,37 @@ def _active_layout(self):
5247
@property
5348
def component(self):
5449
"""Component."""
55-
return Component(self._pedb, self.component)
50+
return Component(self._pedb, super().component)
5651

5752
@component.setter
5853
def component(self, value):
5954
if isinstance(value, Component):
60-
self.component = value._edb_object
55+
super(PinGroup, self.__class__).component.__set__(self, value)
6156

6257
@property
6358
def pins(self):
6459
"""Gets the pins belong to this pin group."""
65-
return {i.name: PadstackInstance(self._pedb, i) for i in self.pins}
60+
return {i.name: PadstackInstance(self._pedb, i) for i in super().pins}
6661

6762
@property
6863
def net(self):
6964
"""Net."""
70-
return Net(self._pedb, self.net)
65+
return Net(self._pedb, super().net)
7166

7267
@net.setter
7368
def net(self, value):
7469
if isinstance(value, Net):
75-
self.net = value._edb_object
70+
super(PinGroup, self.__class__).net.__set__(self, value)
7671

7772
@property
7873
def net_name(self):
7974
return self.net.name
8075

81-
@property
82-
def terminal(self):
83-
"""Terminal."""
84-
term = PinGroupTerminal(self._pedb, self.get_pin_group_terminal()) # TODO check method is missing
85-
return term if not term.is_null else None
76+
# @property
77+
# def terminal(self):
78+
# """Terminal."""
79+
# term = PinGroupTerminal(self._pedb, self.get_pin_group_terminal()) # TODO check method is missing
80+
# return term if not term.is_null else None
8681

8782
def create_terminal(self, name=None):
8883
"""Create a terminal.
@@ -94,52 +89,53 @@ def create_terminal(self, name=None):
9489
"""
9590
if not name:
9691
name = generate_unique_name(self.name)
97-
term = PinGroupTerminal(self._pedb, self._edb_object)
98-
term = term.create(name, self.net_name, self.name)
99-
return term
92+
term = PinGroupTerminal.create(
93+
layout=self._active_layout, name=name, pin_group=self, net=self.net, is_ref=False
94+
)
95+
return PinGroupTerminal(self._pedb, term)
10096

10197
def _json_format(self):
10298
dict_out = {"component": self.component, "name": self.name, "net": self.net, "node_type": self.node_type}
10399
return dict_out
104100

105101
def create_current_source_terminal(self, magnitude=1, phase=0, impedance=1e6):
106-
terminal = self.create_terminal()._edb_object
102+
terminal = self.create_terminal()
107103
terminal.boundary_type = GrpcBoundaryType.CURRENT_SOURCE
108104
terminal.source_amplitude = GrpcValue(magnitude)
109105
terminal.source_phase = GrpcValue(phase)
110106
terminal.impedance = GrpcValue(impedance)
111107
return terminal
112108

113109
def create_voltage_source_terminal(self, magnitude=1, phase=0, impedance=0.001):
114-
terminal = self.create_terminal()._edb_object
110+
terminal = self.create_terminal()
115111
terminal.boundary_type = GrpcBoundaryType.VOLTAGE_SOURCE
116112
terminal.source_amplitude = GrpcValue(magnitude)
117113
terminal.source_phase = GrpcValue(phase)
118114
terminal.impedance = GrpcValue(impedance)
119115
return terminal
120116

121117
def create_voltage_probe_terminal(self, impedance=1000000):
122-
terminal = self.create_terminal()._edb_object
118+
terminal = self.create_terminal()
123119
terminal.boundary_type = GrpcBoundaryType.VOLTAGE_PROBE
124120
terminal.impedance = GrpcValue(impedance)
125121
return terminal
126122

127123
def create_port_terminal(self, impedance=50):
128-
terminal = self.create_terminal()._edb_object
124+
terminal = self.create_terminal()
129125
terminal.boundary_type = GrpcBoundaryType.PORT
130126
terminal.impedance = GrpcValue(impedance)
131127
terminal.is_circuit_port = True
132128
return terminal
133129

134-
def delete(self):
135-
"""Delete active pin group.
136-
137-
Returns
138-
-------
139-
bool
140-
141-
"""
142-
terminal = self.get_pin_group_terminal() # TODO check method exists in grpc
143-
self.delete()
144-
terminal.delete()
145-
return True
130+
# def delete(self):
131+
# """Delete active pin group.
132+
#
133+
# Returns
134+
# -------
135+
# bool
136+
#
137+
# """
138+
# terminal = self.get_pin_group_terminal() # TODO check method exists in grpc
139+
# self.delete()
140+
# terminal.delete()
141+
# return True

src/pyedb/grpc/edb_core/layout/layout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def groups(self):
105105

106106
@property
107107
def pin_groups(self):
108-
return [PinGroup(pedb=self._pedb, edb_pin_group=i) for i in self._pedb.active_cell.layout.pin_groups]
108+
return [PinGroup(self._pedb, i) for i in self._pedb.active_cell.layout.pin_groups]
109109

110110
@property
111111
def net_classes(self):

src/pyedb/grpc/edb_core/primitive/padstack_instances.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -313,20 +313,17 @@ def net_name(self):
313313
str
314314
Name of the net.
315315
"""
316-
return self.net.name
316+
if self.is_null:
317+
return ""
318+
elif self.net.is_null:
319+
return ""
320+
else:
321+
return self.net.name
317322

318323
@net_name.setter
319324
def net_name(self, val):
320-
if not isinstance(val, str):
321-
try:
322-
self.net = val
323-
except:
324-
raise AttributeError("Value inserted not found. Input has to be net name or net object.")
325-
elif val in self._pedb.nets.netlist:
326-
net = self._pedb.nets.nets[val]
327-
self.net = net
328-
else:
329-
raise AttributeError("Value inserted not found. Input has to be net name or net object.")
325+
if not self.is_null and self.net.is_null:
326+
self.net.name = val
330327

331328
@property
332329
def is_pin(self):

0 commit comments

Comments
 (0)