Skip to content

Commit

Permalink
S641067: Client side support for NetClass (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
apasarka authored Jul 15, 2022
1 parent 79813a0 commit 6b8d5b7
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 1 deletion.
41 changes: 41 additions & 0 deletions protos/ansys/api/edb/v1/netclass.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Proto file representing the EDB NetClass

syntax = "proto3";

package ansys.api.edb.v1;

import "edb_messages.proto";
import "refs.proto";

service NetClassService {
rpc Create (NetClassCreationMessage) returns (EDBObjMessage) {}

rpc FindByName(EDBObjNameMessage) returns (EDBObjMessage) {}

rpc GetName (EDBObjMessage) returns (google.protobuf.StringValue) {}

rpc SetName(EDBObjNameMessage) returns (google.protobuf.Empty) {}

rpc GetDescription (EDBObjMessage) returns (google.protobuf.StringValue) {}

rpc SetDescription(StringPropertyMessage) returns (google.protobuf.Empty) {}

rpc IsPowerGround(EDBObjMessage) returns (google.protobuf.BoolValue) {}

rpc AddNet(NetClassEditMessage) returns (google.protobuf.Empty) {}

rpc RemoveNet(NetClassEditMessage) returns (google.protobuf.Empty) {}

rpc ContainsNet(NetClassEditMessage) returns (google.protobuf.BoolValue) {}
}

// Message for Create
message NetClassCreationMessage {
EDBObjMessage layout = 1;
string name = 2;
}

message NetClassEditMessage {
EDBObjMessage netclass = 1;
EDBObjMessage net = 2;
}
147 changes: 146 additions & 1 deletion src/ansys/edb/core/net/net_class.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,153 @@
"""Net class."""

import ansys.api.edb.v1.netclass_pb2 as nc_pb2

import ansys.edb.core.interface.grpc.messages as messages
from ansys.edb.core.layout.layout_obj import LayoutObj
from ansys.edb.core.session import StubAccessor, StubType
from ansys.edb.core.utility.edb_errors import handle_grpc_exception


class _QueryBuilder:
@staticmethod
def create(layout, name):
return nc_pb2.NetClassCreationMessage(layout=layout.msg, name=name)


class NetClass(LayoutObj):
"""Net class."""

pass
__stub = StubAccessor(StubType.netclass)

@classmethod
@handle_grpc_exception
def create(cls, layout, name):
"""
Create net class.
Parameters
----------
layout : Layout
name : str
Returns
-------
NetClass
"""
return NetClass(cls.__stub.Create(_QueryBuilder.create(layout, name)))

@classmethod
@handle_grpc_exception
def find(cls, layout, name):
"""
Find net class by name.
Parameters
----------
layout : Layout
name : str
Returns
-------
NetClass
"""
return NetClass(cls.__stub.FindByName(messages.edb_obj_name_message(layout, name)))

@property
def name(self):
"""
Name of net class.
Returns
-------
str
"""
return self.__stub.GetName(self.msg).value

@property
def description(self):
"""
Return description of net class.
Returns
-------
str
"""
return self.__stub.GetDescription(self.msg).value

@name.setter
@handle_grpc_exception
def name(self, newname):
"""
Set name of net class.
Parameters
----------
newname : str
"""
return self.__stub.SetName(messages.edb_obj_name_message(self.msg, newname))

@description.setter
@handle_grpc_exception
def description(self, newdesc):
"""
Set description of net class.
Parameters
----------
newdesc : str
"""
return self.__stub.SetDescription(messages.string_property_message(self, newdesc))

@property
def is_power_ground(self):
"""Return whether this netclass is power or ground.
Returns
-------
bool
"""
return self.__stub.IsPowerGround(messages.edb_obj_message(self.msg)).value

@handle_grpc_exception
def add_net(self, net):
"""
Add net to netclass.
Parameters
----------
net : Net
"""
return self.__stub.AddNet(nc_pb2.NetClassEditMessage(netclass=self.msg, net=net.msg))

@handle_grpc_exception
def remove_net(self, net):
"""
Remove net from netclass.
Parameters
----------
net : Net
"""
self.__stub.RemoveNet(nc_pb2.NetClassEditMessage(netclass=self.msg, net=net.msg))

@handle_grpc_exception
def contains_net(self, net):
"""
Find if net exists in netclass.
Parameters
----------
net : Net
Returns
-------
bool
"""
return self.__stub.ContainsNet(
nc_pb2.NetClassEditMessage(netclass=self.msg, net=net.msg)
).value
2 changes: 2 additions & 0 deletions src/ansys/edb/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from ansys.api.edb.v1.layout_pb2_grpc import LayoutServiceStub
from ansys.api.edb.v1.material_def_pb2_grpc import MaterialDefServiceStub
from ansys.api.edb.v1.net_pb2_grpc import NetServiceStub
from ansys.api.edb.v1.netclass_pb2_grpc import NetClassServiceStub
from ansys.api.edb.v1.padstack_def_pb2_grpc import PadstackDefServiceStub
from ansys.api.edb.v1.padstack_inst_term_pb2_grpc import PadstackInstanceTerminalServiceStub
from ansys.api.edb.v1.path_pb2_grpc import PathServiceStub
Expand Down Expand Up @@ -269,6 +270,7 @@ class StubType(Enum):
cell_instance = CellInstanceServiceStub
hierarchy_obj = HierarchyObjectServiceStub
group = GroupServiceStub
netclass = NetClassServiceStub
layer_map = LayerMapServiceStub


Expand Down

0 comments on commit 6b8d5b7

Please sign in to comment.