Skip to content

Commit a8f6fd3

Browse files
bryankaylorjsalant22pre-commit-ci[bot]pyansys-ci-botSMoraisAnsys
authored
FEAT: Support new EmitCom API for 25R2, add node classes for all EMIT node types (#6068)
Co-authored-by: jsalant <[email protected]> Co-authored-by: Josh Salant <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Sébastien Morais <[email protected]> Co-authored-by: Sébastien Morais <[email protected]> Co-authored-by: Samuelopez-ansys <[email protected]> Co-authored-by: Samuel Lopez <[email protected]>
1 parent 67d9e0c commit a8f6fd3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+14087
-174
lines changed

doc/changelog.d/6068.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Support new emitcom api for 25r2, add node classes for all emit node types

src/ansys/aedt/core/emit.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,6 @@ def __init__(
185185

186186
self.__emit_api_enabled = True
187187

188-
# set the default units here to make sure the EmitApi level
189-
# stays synced with pyaedt
190-
unit_types = ["Power", "Frequency", "Length", "Time", "Voltage", "Data Rate", "Resistance"]
191-
unit_values = ["dBm", "MHz", "meter", "ns", "mV", "bps", "Ohm"]
192-
self.set_units(unit_types, unit_values)
193-
194188
def _init_from_design(self, *args, **kwargs):
195189
self.__init__(*args, **kwargs)
196190

src/ansys/aedt/core/emit_core/__init__.py

Lines changed: 61 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,37 +56,68 @@ def emit_api_python():
5656

5757

5858
def _init_enums(aedt_version):
59-
ResultType.EMI = emit_api_python().result_type().emi
60-
ResultType.DESENSE = emit_api_python().result_type().desense
61-
ResultType.SENSITIVITY = emit_api_python().result_type().sensitivity
62-
ResultType.POWER_AT_RX = emit_api_python().result_type().powerAtRx
63-
64-
TxRxMode.TX = emit_api_python().tx_rx_mode().tx
65-
TxRxMode.RX = emit_api_python().tx_rx_mode().rx
66-
TxRxMode.BOTH = emit_api_python().tx_rx_mode().both
67-
68-
InterfererType.TRANSMITTERS = emit_api_python().interferer_type().transmitters
69-
InterfererType.EMITTERS = emit_api_python().interferer_type().emitters
70-
InterfererType.TRANSMITTERS_AND_EMITTERS = emit_api_python().interferer_type().transmitters_and_emitters
71-
72-
UnitType.POWER = emit_api_python().unit_type().power
73-
UnitType.FREQUENCY = emit_api_python().unit_type().frequency
74-
UnitType.LENGTH = emit_api_python().unit_type().length
75-
UnitType.TIME = emit_api_python().unit_type().time
76-
UnitType.VOLTAGE = emit_api_python().unit_type().voltage
77-
UnitType.DATA_RATE = emit_api_python().unit_type().dataRate
78-
UnitType.RESISTANCE = emit_api_python().unit_type().resistance
79-
8059
numeric_version = int(aedt_version[-3:])
81-
if numeric_version >= 241:
82-
emi_cat_filter = emit_api_python().emi_category_filter()
83-
EmiCategoryFilter.IN_CHANNEL_TX_FUNDAMENTAL = emi_cat_filter.in_channel_tx_fundamental
84-
EmiCategoryFilter.IN_CHANNEL_TX_HARMONIC_SPURIOUS = emi_cat_filter.in_channel_tx_harmonic_spurious
85-
EmiCategoryFilter.IN_CHANNEL_TX_INTERMOD = emi_cat_filter.in_channel_tx_intermod
86-
EmiCategoryFilter.IN_CHANNEL_TX_BROADBAND = emi_cat_filter.in_channel_tx_broadband
87-
EmiCategoryFilter.OUT_OF_CHANNEL_TX_FUNDAMENTAL = emi_cat_filter.out_of_channel_tx_fundamental
88-
EmiCategoryFilter.OUT_OF_CHANNEL_TX_HARMONIC_SPURIOUS = emi_cat_filter.out_of_channel_tx_harmonic_spurious
89-
EmiCategoryFilter.OUT_OF_CHANNEL_TX_INTERMOD = emi_cat_filter.out_of_channel_tx_intermod
60+
61+
if numeric_version > 251:
62+
ResultType.EMI = emit_api_python().result_type().emi
63+
ResultType.DESENSE = emit_api_python().result_type().desense
64+
ResultType.SENSITIVITY = emit_api_python().result_type().sensitivity
65+
ResultType.POWER_AT_RX = emit_api_python().result_type().powerAtRx
66+
67+
TxRxMode.TX = emit_api_python().tx_rx_mode().tx
68+
TxRxMode.RX = emit_api_python().tx_rx_mode().rx
69+
TxRxMode.BOTH = emit_api_python().tx_rx_mode().both
70+
71+
InterfererType.TRANSMITTERS = emit_api_python().interferer_type().transmitters
72+
InterfererType.EMITTERS = emit_api_python().interferer_type().emitters
73+
InterfererType.TRANSMITTERS_AND_EMITTERS = emit_api_python().interferer_type().transmitters_and_emitters
74+
75+
UnitType.POWER = emit_api_python().unit_type().power
76+
UnitType.FREQUENCY = emit_api_python().unit_type().frequency
77+
UnitType.LENGTH = emit_api_python().unit_type().length
78+
UnitType.TIME = emit_api_python().unit_type().time
79+
UnitType.VOLTAGE = emit_api_python().unit_type().voltage
80+
UnitType.DATA_RATE = emit_api_python().unit_type().dataRate
81+
UnitType.RESISTANCE = emit_api_python().unit_type().resistance
82+
83+
EmiCategoryFilter.IN_CHANNEL_TX_FUNDAMENTAL = 0
84+
EmiCategoryFilter.IN_CHANNEL_TX_HARMONIC_SPURIOUS = 1
85+
EmiCategoryFilter.IN_CHANNEL_TX_INTERMOD = 2
86+
EmiCategoryFilter.IN_CHANNEL_TX_BROADBAND = 3
87+
EmiCategoryFilter.OUT_OF_CHANNEL_TX_FUNDAMENTAL = 4
88+
EmiCategoryFilter.OUT_OF_CHANNEL_TX_HARMONIC_SPURIOUS = 5
89+
EmiCategoryFilter.OUT_OF_CHANNEL_TX_INTERMOD = 6
90+
else:
91+
ResultType.EMI = emit_api_python().result_type().emi
92+
ResultType.DESENSE = emit_api_python().result_type().desense
93+
ResultType.SENSITIVITY = emit_api_python().result_type().sensitivity
94+
ResultType.POWER_AT_RX = emit_api_python().result_type().powerAtRx
95+
96+
TxRxMode.TX = emit_api_python().tx_rx_mode().tx
97+
TxRxMode.RX = emit_api_python().tx_rx_mode().rx
98+
TxRxMode.BOTH = emit_api_python().tx_rx_mode().both
99+
100+
InterfererType.TRANSMITTERS = emit_api_python().interferer_type().transmitters
101+
InterfererType.EMITTERS = emit_api_python().interferer_type().emitters
102+
InterfererType.TRANSMITTERS_AND_EMITTERS = emit_api_python().interferer_type().transmitters_and_emitters
103+
104+
UnitType.POWER = emit_api_python().unit_type().power
105+
UnitType.FREQUENCY = emit_api_python().unit_type().frequency
106+
UnitType.LENGTH = emit_api_python().unit_type().length
107+
UnitType.TIME = emit_api_python().unit_type().time
108+
UnitType.VOLTAGE = emit_api_python().unit_type().voltage
109+
UnitType.DATA_RATE = emit_api_python().unit_type().dataRate
110+
UnitType.RESISTANCE = emit_api_python().unit_type().resistance
111+
112+
if numeric_version >= 241:
113+
emi_cat_filter = emit_api_python().emi_category_filter()
114+
EmiCategoryFilter.IN_CHANNEL_TX_FUNDAMENTAL = emi_cat_filter.in_channel_tx_fundamental
115+
EmiCategoryFilter.IN_CHANNEL_TX_HARMONIC_SPURIOUS = emi_cat_filter.in_channel_tx_harmonic_spurious
116+
EmiCategoryFilter.IN_CHANNEL_TX_INTERMOD = emi_cat_filter.in_channel_tx_intermod
117+
EmiCategoryFilter.IN_CHANNEL_TX_BROADBAND = emi_cat_filter.in_channel_tx_broadband
118+
EmiCategoryFilter.OUT_OF_CHANNEL_TX_FUNDAMENTAL = emi_cat_filter.out_of_channel_tx_fundamental
119+
EmiCategoryFilter.OUT_OF_CHANNEL_TX_HARMONIC_SPURIOUS = emi_cat_filter.out_of_channel_tx_harmonic_spurious
120+
EmiCategoryFilter.OUT_OF_CHANNEL_TX_INTERMOD = emi_cat_filter.out_of_channel_tx_intermod
90121

91122

92123
# need this as a function so that it can be set

src/ansys/aedt/core/emit_core/emit_constants.py

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,111 @@ class UnitType(MutableEnum):
7676
EMIT_VALID_UNITS = {
7777
"Power": ["mW", "W", "kW", "dBm", "dBW"],
7878
"Frequency": ["Hz", "kHz", "MHz", "GHz", "THz"],
79-
"Length": ["pm", "nm", "um", "mm", "cm", "dm", "meter", "km", "mil", "in", "ft", "yd", "mile"],
79+
"Length": ["pm", "nm", "um", "mm", "cm", "dm", "meter", "meters", "km", "mil", "in", "ft", "yd", "mile"],
8080
"Time": ["ps", "ns", "us", "ms", "s"],
81-
"Voltage": ["mV", "V"],
81+
"Voltage": ["nV", "uV", "mV", "V", "kV", "MegV"],
8282
"Data Rate": ["bps", "kbps", "Mbps", "Gbps"],
8383
"Resistance": ["uOhm", "mOhm", "Ohm", "kOhm", "megOhm", "GOhm"],
8484
}
8585
"""Valid units for each unit type."""
8686

87+
EMIT_INTERNAL_UNITS = {
88+
"Power": "dBm",
89+
"Freq": "Hz",
90+
"Length": "meter",
91+
"Time": "s",
92+
"Voltage": "V",
93+
"Data Rate": "bps",
94+
"Resistance": "ohm",
95+
}
96+
"""Default units for each unit type."""
97+
98+
EMIT_TO_AEDT_UNITS = {
99+
"picometers": "pm",
100+
"nanometers": "nm",
101+
"micrometers": "um",
102+
"millimeters": "mm",
103+
"centimeters": "cm",
104+
"decimeters": "dm",
105+
"meters": "meter",
106+
"kilometers": "km",
107+
"inches": "in",
108+
"mils": "mil",
109+
"feet": "ft",
110+
"yards": "yd",
111+
"miles": "mile",
112+
"hertz": "Hz",
113+
"kilohertz": "kHz",
114+
"megahertz": "MHz",
115+
"gigahertz": "GHz",
116+
"terahertz": "THz",
117+
"picoseconds": "ps",
118+
"nanoseconds": "ns",
119+
"microseconds": "us",
120+
"milliseconds": "ms",
121+
"seconds": "s",
122+
"microohms": "uOhm",
123+
"milliohms": "mOhm",
124+
"ohms": "ohm",
125+
"kiloohms": "kOhm",
126+
"megaohms": "megohm",
127+
"gigaohms": "GOhm",
128+
"dBm": "dBm",
129+
"dBW": "dBW",
130+
"watts": "W",
131+
"milliwatts": "mW",
132+
"kilowatts": "kW",
133+
"nanovolts": "nV",
134+
"microvolts": "uV",
135+
"millivolts": "mV",
136+
"volts": "V",
137+
"kilovolts": "kV",
138+
"megavolts": "MegV",
139+
"bps": "bps",
140+
"kbps": "kbps",
141+
"Mbps": "Mbps",
142+
"Gbps": "Gbps",
143+
}
144+
145+
146+
def data_rate_conv(value: float, units: str, to_internal: bool = True):
147+
"""Converts the data rate to (from) the internal units from the
148+
specified units.
149+
150+
Args:
151+
value (float): numeric value of the data rate
152+
units (str): units to convert to (from)
153+
to_internal (bool, optional): Converts from the specified units
154+
to the internal units OR from the internal units to the
155+
specified units. Defaults to True.
156+
157+
Returns:
158+
value: data rate converted to/from the internal units
159+
"""
160+
mult = 1.0
161+
162+
if units not in ("bps", "kbps", "Mbps", "Gbps"):
163+
raise ValueError(f"{units} are not valid units for data rate.")
164+
if to_internal:
165+
if units == "bps":
166+
mult = 1.0
167+
elif units == "kbps":
168+
mult = 1e-3
169+
elif units == "Mbps":
170+
mult = 1e-6
171+
elif units == "Gbps":
172+
mult = 1e-9
173+
else:
174+
if units == "bps":
175+
mult = 1.0
176+
elif units == "kbps":
177+
mult = 1e3
178+
elif units == "Mbps":
179+
mult = 1e6
180+
elif units == "Gbps":
181+
mult = 1e9
182+
return value * mult
183+
87184

88185
def emit_unit_type_string_to_enum(unit_string):
89186
EMIT_UNIT_TYPE_STRING_TO_ENUM = {
@@ -98,6 +195,19 @@ def emit_unit_type_string_to_enum(unit_string):
98195
return EMIT_UNIT_TYPE_STRING_TO_ENUM[unit_string]
99196

100197

198+
def emi_cat_enum_to_string(emi_cat_enum):
199+
EMI_CAT_ENUM_TO_STR = {
200+
EmiCategoryFilter.IN_CHANNEL_TX_FUNDAMENTAL: "In-Channel Tx Fundamental",
201+
EmiCategoryFilter.IN_CHANNEL_TX_HARMONIC_SPURIOUS: "In-Channel Tx Harmonic/Spurious",
202+
EmiCategoryFilter.IN_CHANNEL_TX_INTERMOD: "In-Channel Intermod",
203+
EmiCategoryFilter.IN_CHANNEL_TX_BROADBAND: "In-Channel Broadband",
204+
EmiCategoryFilter.OUT_OF_CHANNEL_TX_FUNDAMENTAL: "Out-of-Channel Tx Fundamental",
205+
EmiCategoryFilter.OUT_OF_CHANNEL_TX_HARMONIC_SPURIOUS: "Out-of-Channel Tx Harmonic/Spurious",
206+
EmiCategoryFilter.OUT_OF_CHANNEL_TX_INTERMOD: "Out-of-Channel Intermod",
207+
}
208+
return EMI_CAT_ENUM_TO_STR[emi_cat_enum]
209+
210+
101211
class EmiCategoryFilter(MutableEnum):
102212
IN_CHANNEL_TX_FUNDAMENTAL = None
103213
IN_CHANNEL_TX_HARMONIC_SPURIOUS = None

0 commit comments

Comments
 (0)