From 1b43e776987d1677eb69ff1e7b75fc3a4c71136d Mon Sep 17 00:00:00 2001 From: chenchienjacklin <104948990+chenchienjacklin@users.noreply.github.com> Date: Thu, 2 Nov 2023 14:09:18 -0700 Subject: [PATCH] D907066: Expose InstArray in pyedb. --- doc/source/api/hierarchy.rst | 1 + protos/ansys/api/edb/v1/inst_array.proto | 43 +++++++++ protos/ansys/api/edb/v1/layout_obj.proto | 1 + src/ansys/edb/core/messages.py | 14 +++ src/ansys/edb/edb_defs.py | 1 + src/ansys/edb/hierarchy/__init__.py | 1 + src/ansys/edb/hierarchy/inst_array.py | 118 +++++++++++++++++++++++ src/ansys/edb/session.py | 2 + 8 files changed, 181 insertions(+) create mode 100644 protos/ansys/api/edb/v1/inst_array.proto create mode 100644 src/ansys/edb/hierarchy/inst_array.py diff --git a/doc/source/api/hierarchy.rst b/doc/source/api/hierarchy.rst index b7ed5e8a57..e07afa15de 100644 --- a/doc/source/api/hierarchy.rst +++ b/doc/source/api/hierarchy.rst @@ -14,6 +14,7 @@ Object Types :toctree: _autosummary CellInstance + InstArray ComponentGroup Group PinGroup diff --git a/protos/ansys/api/edb/v1/inst_array.proto b/protos/ansys/api/edb/v1/inst_array.proto new file mode 100644 index 0000000000..de5ba64441 --- /dev/null +++ b/protos/ansys/api/edb/v1/inst_array.proto @@ -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; +} diff --git a/protos/ansys/api/edb/v1/layout_obj.proto b/protos/ansys/api/edb/v1/layout_obj.proto index 5ea9a0658f..dcf2848eb6 100644 --- a/protos/ansys/api/edb/v1/layout_obj.proto +++ b/protos/ansys/api/edb/v1/layout_obj.proto @@ -24,6 +24,7 @@ enum LayoutObjType { VOLTAGE_REGULATOR = 13; EXTENDED_NET = 14; LAYOUT_OBJ_TYPE_COUNT = 15; + INST_ARRAY = 16; INVALID_LAYOUT_OBJ = -1; } diff --git a/src/ansys/edb/core/messages.py b/src/ansys/edb/core/messages.py index 6be4eea73b..19aa07f0c6 100644 --- a/src/ansys/edb/core/messages.py +++ b/src/ansys/edb/core/messages.py @@ -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, @@ -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) diff --git a/src/ansys/edb/edb_defs.py b/src/ansys/edb/edb_defs.py index 6d4d16234e..7840129aba 100644 --- a/src/ansys/edb/edb_defs.py +++ b/src/ansys/edb/edb_defs.py @@ -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 diff --git a/src/ansys/edb/hierarchy/__init__.py b/src/ansys/edb/hierarchy/__init__.py index cf8f65d28e..74f8c74909 100644 --- a/src/ansys/edb/hierarchy/__init__.py +++ b/src/ansys/edb/hierarchy/__init__.py @@ -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 diff --git a/src/ansys/edb/hierarchy/inst_array.py b/src/ansys/edb/hierarchy/inst_array.py new file mode 100644 index 0000000000..85ac394ed1 --- /dev/null +++ b/src/ansys/edb/hierarchy/inst_array.py @@ -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 ` + Layout that owns the instance array. + name : str + Name of instance array to be created. + ref : :class:`Layout ` + Layout that the instance array refers to. + orig : :class:`PointData ` + PointData that represents the origin of the instance array. + xaxis : :class:`PointData ` + PointData that represents the xaxis of the instance array. + yaxis : :class:`PointData ` + PointData that represents the yaxis of the instance array. + xcount : :class:`Value ` + Value of x count of the instance array. + ycount : :class:`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 ` + 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 `: origin of the instance array.""" + return self.__stub.GetOrig(self.msg) + + @property + @parser.to_point_data + def x_axis(self): + """:class:`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 `: 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 `: 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 `: 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) diff --git a/src/ansys/edb/session.py b/src/ansys/edb/session.py index 77ab718356..95920e57c6 100644 --- a/src/ansys/edb/session.py +++ b/src/ansys/edb/session.py @@ -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 @@ -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