Skip to content

Commit

Permalink
D907066: Expose InstArray in pyedb. (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenchienjacklin authored Nov 3, 2023
1 parent 02a201b commit ed88e90
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/api/hierarchy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Object Types
:toctree: _autosummary

CellInstance
InstArray
ComponentGroup
Group
PinGroup
Expand Down
43 changes: 43 additions & 0 deletions protos/ansys/api/edb/v1/inst_array.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Proto file representing the EDB Instance Array class

syntax = "proto3";

// Package
package ansys.api.edb.v1;

// Imports
import "edb_messages.proto";
import "point_data.proto";

// Instance Array service definition
service InstArrayService {
rpc Create(InstArrayCreationMessage) returns (EDBObjMessage) {}

rpc FindByName(StringPropertyMessage) returns (EDBObjMessage) {}

rpc GetOrig(EDBObjMessage) returns (PointMessage) {}

rpc GetXAxis(EDBObjMessage) returns (PointMessage) {}
rpc SetXAxis(PointPropertyMessage) returns (google.protobuf.Empty) {}

rpc GetYAxis(EDBObjMessage) returns (PointMessage) {}
rpc SetYAxis(PointPropertyMessage) returns (google.protobuf.Empty) {}

rpc GetXCount(EDBObjMessage) returns (ValueMessage) {}
rpc SetXCount(ValuePropertyMessage) returns (google.protobuf.Empty) {}

rpc GetYCount(EDBObjMessage) returns (ValueMessage) {}
rpc SetYCount(ValuePropertyMessage) returns (google.protobuf.Empty) {}

rpc Decompose(EDBObjMessage) returns (google.protobuf.Empty) {}
}

message InstArrayCreationMessage {
StringPropertyMessage layout = 1;
EDBObjMessage ref = 2;
PointMessage orig = 3;
PointMessage xaxis = 4;
PointMessage yaxis = 5;
ValueMessage xcount = 6;
ValueMessage ycount = 7;
}
1 change: 1 addition & 0 deletions protos/ansys/api/edb/v1/layout_obj.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ enum LayoutObjType {
VOLTAGE_REGULATOR = 13;
EXTENDED_NET = 14;
LAYOUT_OBJ_TYPE_COUNT = 15;
INST_ARRAY = 16;
INVALID_LAYOUT_OBJ = -1;
}

Expand Down
14 changes: 14 additions & 0 deletions src/ansys/edb/core/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
SkinDepthMeshOperationMessage,
)
from ansys.api.edb.v1.hierarchy_obj_pb2 import ObjectNameInLayoutMessage
from ansys.api.edb.v1.inst_array_pb2 import InstArrayCreationMessage
from ansys.api.edb.v1.layout_pb2 import (
LayoutConvertP2VMessage,
LayoutExpandedExtentMessage,
Expand Down Expand Up @@ -444,6 +445,19 @@ def cell_instance_parameter_override_message(target, param_name, param_value):
)


def inst_array_creation_message(layout, name, ref, orig, xaxis, yaxis, xcount, ycount):
"""Convert to InstArrayCreationMessage."""
return InstArrayCreationMessage(
layout=string_property_message(layout, name),
ref=edb_obj_message(ref),
orig=point_message(orig),
xaxis=point_message(xaxis),
yaxis=point_message(yaxis),
xcount=value_message(xcount),
ycount=value_message(ycount),
)


def component_def_creation_message(db, comp_name, fp):
"""Convert to ComponentDefCreateMessage."""
return ComponentDefCreateMessage(db=db.msg, comp_name=comp_name, fp=fp.msg)
Expand Down
1 change: 1 addition & 0 deletions src/ansys/edb/edb_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class LayoutObjType(enum.Enum):
TERMINAL = layout_obj_pb2.TERM
TERMINAL_INSTANCE = layout_obj_pb2.TERM_INST
CELL_INSTANCE = layout_obj_pb2.CELL_INST
INST_ARRAY = layout_obj_pb2.INST_ARRAY
LAYER = layout_obj_pb2.LAYER
NET = layout_obj_pb2.NET
PADSTACK = layout_obj_pb2.PADSTACK
Expand Down
1 change: 1 addition & 0 deletions src/ansys/edb/hierarchy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from ansys.edb.hierarchy.cell_instance import CellInstance
from ansys.edb.hierarchy.component_group import ComponentGroup, ComponentType
from ansys.edb.hierarchy.group import Group
from ansys.edb.hierarchy.inst_array import InstArray
from ansys.edb.hierarchy.model import Model
from ansys.edb.hierarchy.netlist_model import NetlistModel
from ansys.edb.hierarchy.pin_group import PinGroup
Expand Down
118 changes: 118 additions & 0 deletions src/ansys/edb/hierarchy/inst_array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
"""Inst Array."""

from ansys.api.edb.v1.inst_array_pb2_grpc import InstArrayServiceStub

from ansys.edb.core import messages, parser
from ansys.edb.edb_defs import LayoutObjType
from ansys.edb.hierarchy import cell_instance
from ansys.edb.session import StubAccessor, StubType
from ansys.edb.utility import Value


class InstArray(cell_instance.CellInstance):
"""Class representing an instance array object."""

__stub: InstArrayServiceStub = StubAccessor(StubType.inst_array)
layout_obj_type = LayoutObjType.INST_ARRAY

@classmethod
def create(cls, layout, name, ref, orig, xaxis, yaxis, xcount, ycount):
"""Create an instance array object with a layout.
Parameters
----------
layout : :class:`Layout <ansys.edb.layout.Layout>`
Layout that owns the instance array.
name : str
Name of instance array to be created.
ref : :class:`Layout <ansys.edb.layout.Layout>`
Layout that the instance array refers to.
orig : :class:`PointData <ansys.edb.geometry.PointData>`
PointData that represents the origin of the instance array.
xaxis : :class:`PointData <ansys.edb.geometry.PointData>`
PointData that represents the xaxis of the instance array.
yaxis : :class:`PointData <ansys.edb.geometry.PointData>`
PointData that represents the yaxis of the instance array.
xcount : :class:`Value <ansys.edb.layout.Value>`
Value of x count of the instance array.
ycount : :class:`Value <ansys.edb.utility.Value>`
Value of y count of the instance array.
Returns
-------
InstArray
Newly created instance array.
"""
return InstArray(
cls.__stub.Create(
messages.inst_array_creation_message(
layout, name, ref, orig, xaxis, yaxis, xcount, ycount
)
)
)

@classmethod
def find(cls, layout, name):
"""Find an instance array in layout by name.
Parameters
----------
layout : :class:`Layout <ansys.edb.layout.Layout>`
Layout to search for the instance array in.
name : str
Name of the instance array to be searched for.
Returns
-------
InstArray
instance array that is found, None otherwise.
"""
return InstArray(cls.__stub.FindByName(messages.string_property_message(layout, name)))

@property
@parser.to_point_data
def orig(self):
""":class:`PointData <geometry.PointData>`: origin of the instance array."""
return self.__stub.GetOrig(self.msg)

@property
@parser.to_point_data
def x_axis(self):
""":class:`PointData <geometry.PointData>`: x axis of the instance array."""
return self.__stub.GetXAxis(self.msg)

@x_axis.setter
def x_axis(self, value):
self.__stub.SetXAxis(messages.point_property_message(self, value))

@property
@parser.to_point_data
def y_axis(self):
""":class:`PointData <geometry.PointData>`: y axis of the instance array."""
return self.__stub.GetYAxis(self.msg)

@y_axis.setter
def y_axis(self, value):
self.__stub.SetYAxis(messages.point_property_message(self, value))

@property
def x_count(self):
""":class:`Value <ansys.edb.utility.Value>`: x count of the instance array."""
return Value(self.__stub.GetXCount(self.msg))

@x_count.setter
def x_count(self, value):
self.__stub.SetXCount(messages.value_property_message(self, value))

@property
def y_count(self):
""":class:`Value <ansys.edb.utility.Value>`: y count of the instance array."""
return Value(self.__stub.GetYCount(self.msg))

@y_count.setter
def y_count(self, value):
self.__stub.SetYCount(messages.value_property_message(self, value))

def decompose(self):
"""Decompose the instance array."""
self.__stub.Decompose(self.msg)
2 changes: 2 additions & 0 deletions src/ansys/edb/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from ansys.api.edb.v1.hfss_simulation_setup_pb2_grpc import HfssSimulationSetupServiceStub
from ansys.api.edb.v1.hierarchy_obj_pb2_grpc import HierarchyObjectServiceStub
from ansys.api.edb.v1.ic_component_property_pb2_grpc import ICComponentPropertyServiceStub
from ansys.api.edb.v1.inst_array_pb2_grpc import InstArrayServiceStub
from ansys.api.edb.v1.io_component_property_pb2_grpc import IOComponentPropertyServiceStub
from ansys.api.edb.v1.layer_collection_pb2_grpc import LayerCollectionServiceStub
from ansys.api.edb.v1.layer_map_pb2_grpc import LayerMapServiceStub
Expand Down Expand Up @@ -354,6 +355,7 @@ class StubType(Enum):
value = ValueServiceStub
variable_server = VariableServerServiceStub
cell_instance = CellInstanceServiceStub
inst_array = InstArrayServiceStub
hierarchy_obj = HierarchyObjectServiceStub
group = GroupServiceStub
netclass = NetClassServiceStub
Expand Down

0 comments on commit ed88e90

Please sign in to comment.