Skip to content

Commit

Permalink
T698080: Change Hfss extent info to dict (#95)
Browse files Browse the repository at this point in the history
* T698080: Change Hfss extent info to dict

* T698080: Change Hfss extent info to dict

* T698080: Hfss Dict update

* T698080: Hfss Dict update

* T698080: typo

* T698080: Fix documentation problem.
  • Loading branch information
vmartidis authored Sep 4, 2022
1 parent 62b1a3c commit 9b3f5f6
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 26 deletions.
1 change: 0 additions & 1 deletion doc/source/api/utility.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Classes
.. autosummary::
:toctree: _autosummary

HfssExtentInfo
PortPostProcessingProp
Rlc
TemperatureSettings
Expand Down
11 changes: 5 additions & 6 deletions protos/ansys/api/edb/v1/edb_messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ message HfssExtentInfoMessage {
EDBObjMessage base_polygon = 4;
HfssExtentsType dielectric_extent_type = 5;
EDBObjMessage dielectric_base_polygon = 6;
HfssExtentMessage extent_size = 7;
HfssExtentMessage dielectric = 7;
bool honor_user_dielectric = 8;
bool truncate_airbox_at_ground = 9;
HfssExtentMessage airbox_horizontal_extent = 10;
HfssExtentMessage airbox_vertical_positive_extent = 11;
HfssExtentMessage airbox_vertical_negative_extent = 12;
bool airbox_truncate_at_ground = 9;
HfssExtentMessage airbox_horizontal = 10;
HfssExtentMessage airbox_vertical_positive = 11;
HfssExtentMessage airbox_vertical_negative = 12;
bool sync_airbox_vertical_extent = 13;
bool is_pml_visible = 14;
ValueMessage operating_frequency = 15;
Expand Down Expand Up @@ -167,4 +167,3 @@ message EDBObjPairMessage {
EDBObjMessage edb_obj_0 = 1;
EDBObjMessage edb_obj_1 = 2;
}

53 changes: 43 additions & 10 deletions src/ansys/edb/layout/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ansys.edb.layout import layout
from ansys.edb.session import StubAccessor, StubType
from ansys.edb.simulation_setup import SimulationSetup
from ansys.edb.utility import HfssExtentInfo, TemperatureSettings
from ansys.edb.utility import TemperatureSettings


class CellType(Enum):
Expand All @@ -30,12 +30,34 @@ class DesignMode(Enum):

# dict representing options of HFSS Extents available via API.
HFSS_EXTENT_ARGS = {
"dielectric": messages.hfss_extent_message,
"airbox_horizontal": messages.hfss_extent_message,
"airbox_vertical": messages.hfss_extent_message,
"airbox_vertical_positive": messages.hfss_extent_message,
"airbox_vertical_negative": messages.hfss_extent_message,
"airbox_truncate_at_ground": messages.bool_message,
"dielectric": "HfssExtentMessage",
"airbox_horizontal": "HfssExtentMessage",
"airbox_vertical_positive": "HfssExtentMessage",
"airbox_vertical_negative": "HfssExtentMessage",
"airbox_truncate_at_ground": "BoolValueMessage",
}


def _translate_bool_value(bool_value):
"""Convert BoolValue Message to tuple of expected values."""
return bool_value.value


def _translate_hfss_extent(hfss_extent_msg):
"""Convert HfssExtentMessage to tuple of expected values."""
return hfss_extent_msg.value, hfss_extent_msg.absolute


# dictionary describing message type and functions to translate them
_HFSS_EXTENT_MESSAGE_HELPER = {
"HfssExtentMessage": {
"msg": messages.hfss_extent_message,
"val": _translate_hfss_extent,
},
"BoolValueMessage": {
"msg": messages.bool_message,
"val": _translate_bool_value,
},
}


Expand All @@ -44,11 +66,21 @@ class DesignMode(Enum):
def sanitize_args(args):
"""Extract valid extent options and convert them into messages."""
return {
k: HFSS_EXTENT_ARGS[k](args[k])
k: _HFSS_EXTENT_MESSAGE_HELPER[HFSS_EXTENT_ARGS[k]]["msg"](args[k])
for k in filter(lambda k: k in args, HFSS_EXTENT_ARGS.keys())
}


def parse_args(msg):
"""Extract extent options values from Hfss Extent message and add them into a dictionary."""
res = {}
for attribute in HFSS_EXTENT_ARGS.keys():
value = getattr(msg, attribute)
msg_type = HFSS_EXTENT_ARGS[attribute]
res[attribute] = _HFSS_EXTENT_MESSAGE_HELPER[msg_type]["val"](value)
return res


class _QueryBuilder:
@staticmethod
def create(db, cell_type, name):
Expand Down Expand Up @@ -272,9 +304,10 @@ def hfss_extent_info(self):
Returns
-------
HfssExtentInfo
dict
"""
return HfssExtentInfo(self.__stub.GetHfssExtentInfo(self.msg))
msg = self.__stub.GetHfssExtentInfo(self.msg)
return parse_args(msg)

def set_hfss_extent_info(self, **extents):
"""Set HFSS Extents of this cell.
Expand Down
1 change: 0 additions & 1 deletion src/ansys/edb/utility/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This package contains utility classes and functions available to users."""

from ansys.edb.utility.hfss_extent_info import HfssExtentInfo
from ansys.edb.utility.port_post_processing_prop import PortPostProcessingProp
from ansys.edb.utility.rlc import Rlc
from ansys.edb.utility.temperature_settings import TemperatureSettings
Expand Down
8 changes: 0 additions & 8 deletions src/ansys/edb/utility/hfss_extent_info.py

This file was deleted.

0 comments on commit 9b3f5f6

Please sign in to comment.