-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
S641067: Client side support for NetClass (#52)
- Loading branch information
Showing
3 changed files
with
189 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters