pyedb 0.38.0__py3-none-any.whl → 0.39.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyedb might be problematic. Click here for more details.

Files changed (205) hide show
  1. pyedb/__init__.py +1 -1
  2. pyedb/common/nets.py +53 -139
  3. pyedb/configuration/cfg_components.py +1 -1
  4. pyedb/configuration/cfg_general.py +4 -2
  5. pyedb/configuration/cfg_modeler.py +1 -1
  6. pyedb/configuration/cfg_package_definition.py +1 -1
  7. pyedb/configuration/cfg_padstacks.py +1 -1
  8. pyedb/configuration/cfg_ports_sources.py +56 -23
  9. pyedb/configuration/configuration.py +18 -1
  10. pyedb/dotnet/{application → database}/Variables.py +21 -21
  11. pyedb/dotnet/{edb_core → database}/cell/connectable.py +5 -5
  12. pyedb/dotnet/{edb_core → database}/cell/hierarchy/component.py +11 -11
  13. pyedb/dotnet/{edb_core → database}/cell/hierarchy/hierarchy_obj.py +1 -1
  14. pyedb/dotnet/{edb_core → database}/cell/hierarchy/model.py +1 -1
  15. pyedb/dotnet/{edb_core → database}/cell/layout.py +17 -17
  16. pyedb/dotnet/{edb_core → database}/cell/layout_obj.py +3 -3
  17. pyedb/dotnet/{edb_core → database}/cell/primitive/bondwire.py +1 -1
  18. pyedb/dotnet/{edb_core → database}/cell/primitive/path.py +4 -4
  19. pyedb/dotnet/{edb_core → database}/cell/primitive/primitive.py +14 -14
  20. pyedb/dotnet/{edb_core → database}/cell/terminal/bundle_terminal.py +2 -2
  21. pyedb/dotnet/{edb_core → database}/cell/terminal/edge_terminal.py +4 -4
  22. pyedb/dotnet/{edb_core → database}/cell/terminal/padstack_instance_terminal.py +2 -2
  23. pyedb/dotnet/{edb_core → database}/cell/terminal/pingroup_terminal.py +2 -2
  24. pyedb/dotnet/{edb_core → database}/cell/terminal/point_terminal.py +2 -2
  25. pyedb/dotnet/{edb_core → database}/cell/terminal/terminal.py +11 -11
  26. pyedb/dotnet/{edb_core → database}/cell/voltage_regulator.py +2 -2
  27. pyedb/dotnet/{edb_core → database}/components.py +101 -124
  28. pyedb/dotnet/{edb_core → database}/definition/component_def.py +5 -5
  29. pyedb/dotnet/{edb_core → database}/definition/component_model.py +1 -1
  30. pyedb/dotnet/{edb_core → database}/definition/definition_obj.py +1 -1
  31. pyedb/dotnet/{edb_core → database}/definition/definitions.py +2 -2
  32. pyedb/dotnet/{edb_core → database}/definition/package_def.py +4 -4
  33. pyedb/dotnet/{edb_core → database}/dotnet/database.py +8 -8
  34. pyedb/dotnet/{edb_core → database}/dotnet/primitive.py +9 -9
  35. pyedb/dotnet/{edb_core → database}/edb_data/control_file.py +12 -12
  36. pyedb/dotnet/{edb_core → database}/edb_data/hfss_extent_info.py +7 -7
  37. pyedb/dotnet/{edb_core → database}/edb_data/nets_data.py +10 -13
  38. pyedb/dotnet/{edb_core → database}/edb_data/padstacks_data.py +16 -16
  39. pyedb/dotnet/{edb_core → database}/edb_data/ports.py +4 -4
  40. pyedb/dotnet/{edb_core → database}/edb_data/primitives_data.py +5 -5
  41. pyedb/dotnet/{edb_core → database}/edb_data/raptor_x_simulation_setup_data.py +4 -4
  42. pyedb/dotnet/{edb_core → database}/edb_data/simulation_configuration.py +10 -10
  43. pyedb/dotnet/{edb_core → database}/edb_data/sources.py +4 -4
  44. pyedb/dotnet/{edb_core → database}/edb_data/variables.py +1 -1
  45. pyedb/dotnet/{edb_core → database}/geometry/polygon_data.py +4 -4
  46. pyedb/dotnet/{edb_core → database}/hfss.py +8 -8
  47. pyedb/dotnet/{edb_core → database}/layout_obj_instance.py +1 -1
  48. pyedb/dotnet/{edb_core → database}/layout_validation.py +2 -2
  49. pyedb/dotnet/{edb_core → database}/materials.py +23 -8
  50. pyedb/dotnet/{edb_core → database}/modeler.py +27 -27
  51. pyedb/dotnet/{edb_core → database}/net_class.py +8 -8
  52. pyedb/dotnet/{edb_core → database}/nets.py +12 -12
  53. pyedb/dotnet/{edb_core → database}/padstack.py +15 -15
  54. pyedb/dotnet/{edb_core → database}/sim_setup_data/data/mesh_operation.py +1 -1
  55. pyedb/dotnet/{edb_core → database}/sim_setup_data/data/settings.py +3 -3
  56. pyedb/dotnet/{edb_core → database}/sim_setup_data/data/sim_setup_info.py +2 -2
  57. pyedb/dotnet/{edb_core → database}/sim_setup_data/data/simulation_settings.py +1 -1
  58. pyedb/dotnet/{edb_core → database}/sim_setup_data/data/siw_dc_ir_settings.py +1 -1
  59. pyedb/dotnet/{edb_core → database}/sim_setup_data/data/sweep_data.py +1 -1
  60. pyedb/dotnet/{edb_core → database}/siwave.py +10 -10
  61. pyedb/dotnet/{edb_core → database}/stackup.py +12 -12
  62. pyedb/dotnet/{edb_core → database}/utilities/hfss_simulation_setup.py +15 -15
  63. pyedb/dotnet/{edb_core → database}/utilities/obj_base.py +1 -1
  64. pyedb/dotnet/{edb_core → database}/utilities/simulation_setup.py +3 -3
  65. pyedb/dotnet/{edb_core → database}/utilities/siwave_simulation_setup.py +6 -6
  66. pyedb/dotnet/edb.py +117 -112
  67. pyedb/generic/design_types.py +26 -19
  68. pyedb/generic/general_methods.py +1 -1
  69. pyedb/generic/plot.py +0 -2
  70. pyedb/grpc/database/__init__.py +1 -0
  71. pyedb/grpc/database/components.py +2354 -0
  72. pyedb/grpc/database/control_file.py +1277 -0
  73. pyedb/grpc/database/definition/component_def.py +218 -0
  74. pyedb/grpc/database/definition/component_model.py +39 -0
  75. pyedb/grpc/database/definition/component_pin.py +32 -0
  76. pyedb/grpc/database/definition/materials.py +1207 -0
  77. pyedb/grpc/database/definition/n_port_component_model.py +34 -0
  78. pyedb/grpc/database/definition/package_def.py +227 -0
  79. pyedb/grpc/database/definition/padstack_def.py +842 -0
  80. pyedb/grpc/database/definitions.py +70 -0
  81. pyedb/grpc/database/general.py +43 -0
  82. pyedb/grpc/database/geometry/__init__.py +0 -0
  83. pyedb/grpc/database/geometry/arc_data.py +93 -0
  84. pyedb/grpc/database/geometry/point_3d_data.py +79 -0
  85. pyedb/grpc/database/geometry/point_data.py +30 -0
  86. pyedb/grpc/database/geometry/polygon_data.py +133 -0
  87. pyedb/grpc/database/hfss.py +1279 -0
  88. pyedb/grpc/database/hierarchy/__init__.py +0 -0
  89. pyedb/grpc/database/hierarchy/component.py +1301 -0
  90. pyedb/grpc/database/hierarchy/model.py +31 -0
  91. pyedb/grpc/database/hierarchy/netlist_model.py +30 -0
  92. pyedb/grpc/database/hierarchy/pin_pair_model.py +128 -0
  93. pyedb/grpc/database/hierarchy/pingroup.py +245 -0
  94. pyedb/grpc/database/hierarchy/s_parameter_model.py +33 -0
  95. pyedb/grpc/database/hierarchy/spice_model.py +48 -0
  96. pyedb/grpc/database/layers/__init__.py +0 -0
  97. pyedb/grpc/database/layers/layer.py +57 -0
  98. pyedb/grpc/database/layers/stackup_layer.py +410 -0
  99. pyedb/grpc/database/layout/__init__.py +0 -0
  100. pyedb/grpc/database/layout/cell.py +30 -0
  101. pyedb/grpc/database/layout/layout.py +196 -0
  102. pyedb/grpc/database/layout/voltage_regulator.py +149 -0
  103. pyedb/grpc/database/layout_validation.py +319 -0
  104. pyedb/grpc/database/modeler.py +1468 -0
  105. pyedb/grpc/database/net/__init__.py +0 -0
  106. pyedb/grpc/database/net/differential_pair.py +138 -0
  107. pyedb/grpc/database/net/extended_net.py +340 -0
  108. pyedb/grpc/database/net/net.py +198 -0
  109. pyedb/grpc/database/net/net_class.py +93 -0
  110. pyedb/grpc/database/nets.py +633 -0
  111. pyedb/grpc/database/padstacks.py +1500 -0
  112. pyedb/grpc/database/ports/__init__.py +0 -0
  113. pyedb/grpc/database/ports/ports.py +396 -0
  114. pyedb/grpc/database/primitive/__init__.py +3 -0
  115. pyedb/grpc/database/primitive/bondwire.py +181 -0
  116. pyedb/grpc/database/primitive/circle.py +75 -0
  117. pyedb/grpc/database/primitive/padstack_instance.py +1116 -0
  118. pyedb/grpc/database/primitive/path.py +346 -0
  119. pyedb/grpc/database/primitive/polygon.py +276 -0
  120. pyedb/grpc/database/primitive/primitive.py +739 -0
  121. pyedb/grpc/database/primitive/rectangle.py +146 -0
  122. pyedb/grpc/database/simulation_setup/__init__.py +0 -0
  123. pyedb/grpc/database/simulation_setup/adaptive_frequency.py +33 -0
  124. pyedb/grpc/database/simulation_setup/hfss_advanced_meshing_settings.py +32 -0
  125. pyedb/grpc/database/simulation_setup/hfss_advanced_settings.py +59 -0
  126. pyedb/grpc/database/simulation_setup/hfss_dcr_settings.py +35 -0
  127. pyedb/grpc/database/simulation_setup/hfss_general_settings.py +61 -0
  128. pyedb/grpc/database/simulation_setup/hfss_settings_options.py +78 -0
  129. pyedb/grpc/database/simulation_setup/hfss_simulation_settings.py +118 -0
  130. pyedb/grpc/database/simulation_setup/hfss_simulation_setup.py +355 -0
  131. pyedb/grpc/database/simulation_setup/hfss_solver_settings.py +34 -0
  132. pyedb/grpc/database/simulation_setup/mesh_operation.py +34 -0
  133. pyedb/grpc/database/simulation_setup/raptor_x_advanced_settings.py +34 -0
  134. pyedb/grpc/database/simulation_setup/raptor_x_general_settings.py +33 -0
  135. pyedb/grpc/database/simulation_setup/raptor_x_simulation_settings.py +64 -0
  136. pyedb/grpc/database/simulation_setup/raptor_x_simulation_setup.py +125 -0
  137. pyedb/grpc/database/simulation_setup/siwave_dcir_simulation_setup.py +34 -0
  138. pyedb/grpc/database/simulation_setup/siwave_simulation_setup.py +119 -0
  139. pyedb/grpc/database/simulation_setup/sweep_data.py +32 -0
  140. pyedb/grpc/database/siwave.py +1023 -0
  141. pyedb/grpc/database/source_excitations.py +2572 -0
  142. pyedb/grpc/database/stackup.py +2574 -0
  143. pyedb/grpc/database/terminal/__init__.py +0 -0
  144. pyedb/grpc/database/terminal/bundle_terminal.py +218 -0
  145. pyedb/grpc/database/terminal/edge_terminal.py +51 -0
  146. pyedb/grpc/database/terminal/padstack_instance_terminal.py +171 -0
  147. pyedb/grpc/database/terminal/pingroup_terminal.py +162 -0
  148. pyedb/grpc/database/terminal/point_terminal.py +99 -0
  149. pyedb/grpc/database/terminal/terminal.py +470 -0
  150. pyedb/grpc/database/utility/__init__.py +3 -0
  151. pyedb/grpc/database/utility/constants.py +25 -0
  152. pyedb/grpc/database/utility/heat_sink.py +124 -0
  153. pyedb/grpc/database/utility/hfss_extent_info.py +448 -0
  154. pyedb/grpc/database/utility/layout_statistics.py +277 -0
  155. pyedb/grpc/database/utility/rlc.py +80 -0
  156. pyedb/grpc/database/utility/simulation_configuration.py +3305 -0
  157. pyedb/grpc/database/utility/sources.py +388 -0
  158. pyedb/grpc/database/utility/sweep_data_distribution.py +83 -0
  159. pyedb/grpc/database/utility/xml_control_file.py +1277 -0
  160. pyedb/grpc/edb.py +4151 -0
  161. pyedb/grpc/edb_init.py +481 -0
  162. pyedb/grpc/rpc_session.py +177 -0
  163. pyedb/ipc2581/ecad/cad_data/assembly_drawing.py +3 -2
  164. pyedb/ipc2581/ecad/cad_data/feature.py +4 -3
  165. pyedb/ipc2581/ecad/cad_data/layer_feature.py +32 -20
  166. pyedb/ipc2581/ecad/cad_data/outline.py +3 -2
  167. pyedb/ipc2581/ecad/cad_data/package.py +4 -3
  168. pyedb/ipc2581/ecad/cad_data/path.py +82 -31
  169. pyedb/ipc2581/ecad/cad_data/polygon.py +122 -60
  170. pyedb/ipc2581/ecad/cad_data/profile.py +13 -12
  171. pyedb/ipc2581/ecad/cad_data/step.py +53 -21
  172. pyedb/ipc2581/ipc2581.py +47 -49
  173. pyedb/modeler/geometry_operators.py +1 -1
  174. {pyedb-0.38.0.dist-info → pyedb-0.39.0.dist-info}/METADATA +5 -2
  175. pyedb-0.39.0.dist-info/RECORD +288 -0
  176. pyedb-0.38.0.dist-info/RECORD +0 -195
  177. /pyedb/dotnet/{edb_core → database}/__init__.py +0 -0
  178. /pyedb/dotnet/{application → database/cell}/__init__.py +0 -0
  179. /pyedb/dotnet/{edb_core/cell → database/cell/hierarchy}/__init__.py +0 -0
  180. /pyedb/dotnet/{edb_core → database}/cell/hierarchy/netlist_model.py +0 -0
  181. /pyedb/dotnet/{edb_core → database}/cell/hierarchy/pin_pair_model.py +0 -0
  182. /pyedb/dotnet/{edb_core → database}/cell/hierarchy/s_parameter_model.py +0 -0
  183. /pyedb/dotnet/{edb_core → database}/cell/hierarchy/spice_model.py +0 -0
  184. /pyedb/dotnet/{edb_core → database}/cell/primitive/__init__.py +0 -0
  185. /pyedb/dotnet/{edb_core/cell/hierarchy → database/cell/terminal}/__init__.py +0 -0
  186. /pyedb/dotnet/{edb_core/cell/terminal → database/definition}/__init__.py +0 -0
  187. /pyedb/dotnet/{edb_core/definition → database/dotnet}/__init__.py +0 -0
  188. /pyedb/dotnet/{edb_core/dotnet → database/edb_data}/__init__.py +0 -0
  189. /pyedb/dotnet/{edb_core → database}/edb_data/design_options.py +0 -0
  190. /pyedb/dotnet/{edb_core → database}/edb_data/edbvalue.py +0 -0
  191. /pyedb/dotnet/{edb_core → database}/edb_data/layer_data.py +0 -0
  192. /pyedb/dotnet/{edb_core → database}/edb_data/utilities.py +0 -0
  193. /pyedb/dotnet/{edb_core → database}/general.py +0 -0
  194. /pyedb/dotnet/{edb_core/edb_data → database/geometry}/__init__.py +0 -0
  195. /pyedb/dotnet/{edb_core → database}/geometry/point_data.py +0 -0
  196. /pyedb/dotnet/{edb_core → database}/sim_setup_data/__init__.py +0 -0
  197. /pyedb/dotnet/{edb_core → database}/sim_setup_data/data/__init__.py +0 -0
  198. /pyedb/dotnet/{edb_core → database}/sim_setup_data/data/adaptive_frequency_data.py +0 -0
  199. /pyedb/dotnet/{edb_core/geometry → database/sim_setup_data/io}/__init__.py +0 -0
  200. /pyedb/dotnet/{edb_core → database}/sim_setup_data/io/siwave.py +0 -0
  201. /pyedb/dotnet/{edb_core → database}/utilities/__init__.py +0 -0
  202. /pyedb/dotnet/{edb_core → database}/utilities/heatsink.py +0 -0
  203. /pyedb/{dotnet/edb_core/sim_setup_data/io → grpc/database/definition}/__init__.py +0 -0
  204. {pyedb-0.38.0.dist-info → pyedb-0.39.0.dist-info}/LICENSE +0 -0
  205. {pyedb-0.38.0.dist-info → pyedb-0.39.0.dist-info}/WHEEL +0 -0
pyedb/grpc/edb_init.py ADDED
@@ -0,0 +1,481 @@
1
+ # Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
2
+ # SPDX-License-Identifier: MIT
3
+ #
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+
24
+ """Database."""
25
+ import os
26
+ import sys
27
+
28
+ import ansys.edb.core.database as database
29
+
30
+ from pyedb import __version__
31
+ from pyedb.edb_logger import pyedb_logger
32
+ from pyedb.generic.general_methods import env_path, env_value, is_linux
33
+ from pyedb.grpc.rpc_session import RpcSession
34
+ from pyedb.misc.misc import list_installed_ansysem
35
+
36
+
37
+ class EdbInit(object):
38
+ """Edb Dot Net Class."""
39
+
40
+ def __init__(self, edbversion):
41
+ self.logger = pyedb_logger
42
+ self._db = None
43
+ if not edbversion: # pragma: no cover
44
+ try:
45
+ edbversion = "20{}.{}".format(list_installed_ansysem()[0][-3:-1], list_installed_ansysem()[0][-1:])
46
+ self.logger.info("Edb version " + edbversion)
47
+ except IndexError:
48
+ raise Exception("No ANSYSEM_ROOTxxx is found.")
49
+ self.edbversion = edbversion
50
+ self.logger.info("Logger is initialized in EDB.")
51
+ self.logger.info("legacy v%s", __version__)
52
+ self.logger.info("Python version %s", sys.version)
53
+ self.session = None
54
+ if is_linux:
55
+ if env_value(self.edbversion) in os.environ:
56
+ self.base_path = env_path(self.edbversion)
57
+ sys.path.append(self.base_path)
58
+ else:
59
+ edb_path = os.getenv("PYAEDT_SERVER_AEDT_PATH")
60
+ if edb_path:
61
+ self.base_path = edb_path
62
+ sys.path.append(edb_path)
63
+ os.environ[env_value(self.edbversion)] = self.base_path
64
+ else:
65
+ self.base_path = env_path(self.edbversion)
66
+ sys.path.append(self.base_path)
67
+ os.environ["ECAD_TRANSLATORS_INSTALL_DIR"] = self.base_path
68
+ oa_directory = os.path.join(self.base_path, "common", "oa")
69
+ os.environ["ANSYS_OADIR"] = oa_directory
70
+ os.environ["PATH"] = "{};{}".format(os.environ["PATH"], self.base_path)
71
+
72
+ @property
73
+ def db(self):
74
+ """Active database object."""
75
+ return self._db
76
+
77
+ def create(self, db_path, port=0, restart_rpc_server=False, kill_all_instances=False):
78
+ """Create a Database at the specified file location.
79
+
80
+ Parameters
81
+ ----------
82
+ db_path : str
83
+ Path to top-level database folder
84
+
85
+ restart_rpc_server : optional, bool
86
+ Force restarting RPC server when `True`.Default value is `False`
87
+
88
+ kill_all_instances : optional, bool.
89
+ Force killing all RPC server instances, must be used with caution. Default value is `False`.
90
+
91
+ Returns
92
+ -------
93
+ Database
94
+ """
95
+ if not RpcSession.pid:
96
+ RpcSession.start(
97
+ edb_version=self.edbversion,
98
+ port=port,
99
+ restart_server=restart_rpc_server,
100
+ kill_all_instances=kill_all_instances,
101
+ )
102
+ if not RpcSession.pid:
103
+ self.logger.error("Failed to start RPC server.")
104
+ return False
105
+ self._db = database.Database.create(db_path)
106
+ return self._db
107
+
108
+ def open(self, db_path, read_only, port=0, restart_rpc_server=False, kill_all_instances=False):
109
+ """Open an existing Database at the specified file location.
110
+
111
+ Parameters
112
+ ----------
113
+ db_path : str
114
+ Path to top-level Database folder.
115
+ read_only : bool
116
+ Obtain read-only access.
117
+ port : optional, int.
118
+ Specify the port number.If not provided a randon free one is selected. Default value is `0`.
119
+ restart_rpc_server : optional, bool
120
+ Force restarting RPC server when `True`. Default value is `False`.
121
+ kill_all_instances : optional, bool.
122
+ Force killing all RPC server instances, must be used with caution. Default value is `False`.
123
+
124
+ Returns
125
+ -------
126
+ Database or None
127
+ The opened Database object, or None if not found.
128
+ """
129
+ if restart_rpc_server:
130
+ RpcSession.pid = 0
131
+ if not RpcSession.pid:
132
+ RpcSession.start(
133
+ edb_version=self.edbversion,
134
+ port=port,
135
+ restart_server=restart_rpc_server,
136
+ kill_all_instances=kill_all_instances,
137
+ )
138
+ if not RpcSession.pid:
139
+ self.logger.error("Failed to start RPC server.")
140
+ return False
141
+ self._db = database.Database.open(db_path, read_only)
142
+
143
+ def delete(self, db_path):
144
+ """Delete a database at the specified file location.
145
+
146
+ Parameters
147
+ ----------
148
+ db_path : str
149
+ Path to top-level database folder.
150
+ """
151
+ return database.Database.delete(db_path)
152
+
153
+ def save(self):
154
+ """Save any changes into a file."""
155
+ return self._db.save()
156
+
157
+ def close(self, terminate_rpc_session=True, kill_all_instances=False):
158
+ """Close the database.
159
+
160
+ Parameters
161
+ ----------
162
+ terminate_rpc_session : bool, optional
163
+
164
+
165
+ . note::
166
+ Unsaved changes will be lost.
167
+ """
168
+ self._db.close()
169
+ self._db = None
170
+ if kill_all_instances:
171
+ RpcSession._kill_all_instances()
172
+ RpcSession.pid = 0
173
+ elif terminate_rpc_session:
174
+ RpcSession.rpc_session.disconnect()
175
+ RpcSession.pid = 0
176
+ return True
177
+
178
+ @property
179
+ def top_circuit_cells(self):
180
+ """Get top circuit cells.
181
+
182
+ Returns
183
+ -------
184
+ list[:class:`Cell <ansys.edb.layout.Cell>`]
185
+ """
186
+ return [i for i in self._db.top_circuit_cells]
187
+
188
+ @property
189
+ def circuit_cells(self):
190
+ """Get all circuit cells in the Database.
191
+
192
+ Returns
193
+ -------
194
+ list[:class:`Cell <ansys.edb.layout.Cell>`]
195
+ """
196
+ return [i for i in self._db.circuit_cells]
197
+
198
+ @property
199
+ def footprint_cells(self):
200
+ """Get all footprint cells in the Database.
201
+
202
+ Returns
203
+ -------
204
+ list[:class:`Cell <ansys.edb.layout.Cell>`]
205
+ """
206
+ return [i for i in self._db.footprint_cells]
207
+
208
+ @property
209
+ def edb_uid(self):
210
+ """Get ID of the database.
211
+
212
+ Returns
213
+ -------
214
+ int
215
+ The unique EDB id of the Database.
216
+ """
217
+ return self._db.id
218
+
219
+ @property
220
+ def is_read_only(self):
221
+ """Determine if the database is open in a read-only mode.
222
+
223
+ Returns
224
+ -------
225
+ bool
226
+ True if Database is open with read only access, otherwise False.
227
+ """
228
+ return self._db.is_read_only
229
+
230
+ def find_by_id(self, db_id):
231
+ """Find a database by ID.
232
+
233
+ Parameters
234
+ ----------
235
+ db_id : int
236
+ The Database's unique EDB id.
237
+
238
+ Returns
239
+ -------
240
+ Database
241
+ The Database or Null on failure.
242
+ """
243
+ return database.Database.find_by_id(db_id)
244
+
245
+ def save_as(self, path, version=""):
246
+ """Save this Database to a new location and older EDB version.
247
+
248
+ Parameters
249
+ ----------
250
+ path : str
251
+ New Database file location.
252
+ version : str
253
+ EDB version to save to. Empty string means current version.
254
+ """
255
+ self._db.save_as(path, version)
256
+
257
+ @property
258
+ def directory(self):
259
+ """Get the directory of the Database.
260
+
261
+ Returns
262
+ -------
263
+ str
264
+ Directory of the Database.
265
+ """
266
+ return self._db.directory
267
+
268
+ def get_product_property(self, prod_id, attr_it):
269
+ """Get the product-specific property value.
270
+
271
+ Parameters
272
+ ----------
273
+ prod_id : ProductIdType
274
+ Product ID.
275
+ attr_it : int
276
+ Attribute ID.
277
+
278
+ Returns
279
+ -------
280
+ str
281
+ Property value returned.
282
+ """
283
+ return self._db.get_product_property(prod_id, attr_it)
284
+
285
+ def set_product_property(self, prod_id, attr_it, prop_value):
286
+ """Set the product property associated with the given product and attribute ids.
287
+
288
+ Parameters
289
+ ----------
290
+ prod_id : ProductIdType
291
+ Product ID.
292
+ attr_it : int
293
+ Attribute ID.
294
+ prop_value : str
295
+ Product property's new value
296
+ """
297
+ self._db.set_product_property(prod_id, attr_it, prop_value)
298
+
299
+ def get_product_property_ids(self, prod_id):
300
+ """Get a list of attribute ids corresponding to a product property id.
301
+
302
+ Parameters
303
+ ----------
304
+ prod_id : ProductIdType
305
+ Product ID.
306
+
307
+ Returns
308
+ -------
309
+ list[int]
310
+ The attribute ids associated with this product property.
311
+ """
312
+ return self._db.get_product_property_ids(prod_id)
313
+
314
+ def import_material_from_control_file(self, control_file, schema_dir=None, append=True):
315
+ """Import materials from the provided control file.
316
+
317
+ Parameters
318
+ ----------
319
+ control_file : str
320
+ Control file name with full path.
321
+ schema_dir : str
322
+ Schema file path.
323
+ append : bool
324
+ True if the existing materials in Database are kept. False to remove existing materials in database.
325
+ """
326
+ self._db.import_material_from_control_file(control_file, schema_dir, append)
327
+
328
+ @property
329
+ def version(self):
330
+ """Get version of the Database.
331
+
332
+ Returns
333
+ -------
334
+ tuple(int, int)
335
+ A tuple of the version numbers [major, minor]
336
+ """
337
+ major, minor = self._db.version
338
+ return major, minor
339
+
340
+ def scale(self, scale_factor):
341
+ """Uniformly scale all geometry and their locations by a positive factor.
342
+
343
+ Parameters
344
+ ----------
345
+ scale_factor : float
346
+ Amount that coordinates are multiplied by.
347
+ """
348
+ return self._db.scale(scale_factor)
349
+
350
+ @property
351
+ def source(self):
352
+ """Get source name for this Database.
353
+
354
+ This attribute is also used to set the source name.
355
+
356
+ Returns
357
+ -------
358
+ str
359
+ name of the source
360
+ """
361
+ return self._db.source
362
+
363
+ @source.setter
364
+ def source(self, source):
365
+ """Set source name of the database."""
366
+ self._db.source = source
367
+
368
+ @property
369
+ def source_version(self):
370
+ """Get the source version for this Database.
371
+
372
+ This attribute is also used to set the version.
373
+
374
+ Returns
375
+ -------
376
+ str
377
+ version string
378
+
379
+ """
380
+ return self._db.source_version
381
+
382
+ @source_version.setter
383
+ def source_version(self, source_version):
384
+ """Set source version of the database."""
385
+ self._db.source_version = source_version
386
+
387
+ def copy_cells(self, cells_to_copy):
388
+ """Copy Cells from other Databases or this Database into this Database.
389
+
390
+ Parameters
391
+ ----------
392
+ cells_to_copy : list[:class:`Cell <ansys.edb.core.layout.cell.Cell>`]
393
+ Cells to copy.
394
+
395
+ Returns
396
+ -------
397
+ list[:class:`Cell <ansys.edb.core.layout.cell.Cell>`]
398
+ """
399
+ if not isinstance(cells_to_copy, list):
400
+ cells_to_copy = [cells_to_copy]
401
+ return self._db.copy_cells(cells_to_copy)
402
+
403
+ @property
404
+ def apd_bondwire_defs(self):
405
+ """Get all APD bondwire definitions in this Database.
406
+
407
+ Returns
408
+ -------
409
+ list[:class:`ApdBondwireDef <ansys.edb.definition.ApdBondwireDef>`]
410
+ """
411
+ return list(self._db.apd_bondwire_defs)
412
+
413
+ @property
414
+ def jedec4_bondwire_defs(self):
415
+ """Get all JEDEC4 bondwire definitions in this Database.
416
+
417
+ Returns
418
+ -------
419
+ list[:class:`Jedec4BondwireDef <ansys.edb.definition.Jedec4BondwireDef>`]
420
+ """
421
+ return list(self._db.jedec4_bondwire_defs)
422
+
423
+ @property
424
+ def jedec5_bondwire_defs(self):
425
+ """Get all JEDEC5 bondwire definitions in this Database.
426
+
427
+ Returns
428
+ -------
429
+ list[:class:`Jedec5BondwireDef <ansys.edb.definition.Jedec5BondwireDef>`]
430
+ """
431
+ return list(self._db.jedec5_bondwire_defs)
432
+
433
+ @property
434
+ def padstack_defs(self):
435
+ """Get all Padstack definitions in this Database.
436
+
437
+ Returns
438
+ -------
439
+ list[:class:`PadstackDef <ansys.edb.definition.PadstackDef>`]
440
+ """
441
+ return list(self._db.padstack_defs)
442
+
443
+ @property
444
+ def package_defs(self):
445
+ """Get all Package definitions in this Database.
446
+
447
+ Returns
448
+ -------
449
+ list[:class:`PackageDef <ansys.edb.definition.PackageDef>`]
450
+ """
451
+ return list(self._db.package_defs)
452
+
453
+ @property
454
+ def component_defs(self):
455
+ """Get all component definitions in the database.
456
+
457
+ Returns
458
+ -------
459
+ list[:class:`ComponentDef <ansys.edb.definition.ComponentDef>`]
460
+ """
461
+ return list(self._db.component_defs)
462
+
463
+ @property
464
+ def material_defs(self):
465
+ """Get all material definitions in the database.
466
+
467
+ Returns
468
+ -------
469
+ list[:class:`MaterialDef <ansys.edb.definition.MaterialDef>`]
470
+ """
471
+ return list(self._db.material_defs)
472
+
473
+ @property
474
+ def dataset_defs(self):
475
+ """Get all dataset definitions in the database.
476
+
477
+ Returns
478
+ -------
479
+ list[:class:`DatasetDef <ansys.edb.definition.DatasetDef>`]
480
+ """
481
+ return list(self._db.dataset_defs)
@@ -0,0 +1,177 @@
1
+ # Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
2
+ # SPDX-License-Identifier: MIT
3
+ #
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ import os
24
+ from random import randint
25
+ import sys
26
+ import time
27
+
28
+ from ansys.edb.core.session import launch_session
29
+ from ansys.edb.core.utility.io_manager import (
30
+ IOMangementType,
31
+ end_managing,
32
+ start_managing,
33
+ )
34
+ import psutil
35
+
36
+ from pyedb import __version__
37
+ from pyedb.edb_logger import pyedb_logger
38
+ from pyedb.generic.general_methods import env_path, env_value, is_linux
39
+ from pyedb.misc.misc import list_installed_ansysem
40
+
41
+ latency_delay = 0.1
42
+
43
+
44
+ class RpcSession:
45
+ """Static Class managing RPC server."""
46
+
47
+ pid = 0
48
+ rpc_session = None
49
+ base_path = None
50
+ port = 10000
51
+
52
+ @staticmethod
53
+ def start(edb_version, port=0, restart_server=False, kill_all_instances=False):
54
+ """Start RPC-server, the server must be started before opening EDB.
55
+
56
+ Parameters
57
+ ----------
58
+ edb_version : str, optional.
59
+ Specify ANSYS version.
60
+ If None, the latest installation will be detected on the local machine.
61
+
62
+ port : int, optional
63
+ Port number used for the RPC session.
64
+ If not provided, a random free port is automatically selected.
65
+
66
+ restart_server : bool, optional.
67
+ Force restarting the RPC server by killing the process in case EDB_RPC is already started.
68
+ All open EDB
69
+ connection will be lost.
70
+ This option must be used at the beginning of an application only to ensure the
71
+ server is properly started.
72
+ kill_all_instances : bool, optional.
73
+ Force killing all RPC sever instances, including a zombie process.
74
+ To be used with caution, default value is `False`.
75
+ """
76
+ if not port:
77
+ RpcSession.port = RpcSession.__get_random_free_port()
78
+ else:
79
+ RpcSession.port = port
80
+ if not edb_version: # pragma: no cover
81
+ try:
82
+ edb_version = "20{}.{}".format(list_installed_ansysem()[0][-3:-1], list_installed_ansysem()[0][-1:])
83
+ pyedb_logger.info("Edb version " + edb_version)
84
+ except IndexError:
85
+ raise Exception("No ANSYSEM_ROOTxxx is found.")
86
+ pyedb_logger.info("Logger is initialized in EDB.")
87
+ pyedb_logger.info("legacy v%s", __version__)
88
+ pyedb_logger.info("Python version %s", sys.version)
89
+ if is_linux:
90
+ if env_value(edb_version) in os.environ:
91
+ RpcSession.base_path = env_path(edb_version)
92
+ sys.path.append(RpcSession.base_path)
93
+ else:
94
+ edb_path = os.getenv("PYAEDT_SERVER_AEDT_PATH")
95
+ if edb_path:
96
+ RpcSession.base_path = edb_path
97
+ sys.path.append(edb_path)
98
+ os.environ[env_value(edb_version)] = RpcSession.base_path
99
+ else:
100
+ RpcSession.base_path = env_path(edb_version)
101
+ sys.path.append(RpcSession.base_path)
102
+ os.environ["ECAD_TRANSLATORS_INSTALL_DIR"] = RpcSession.base_path
103
+ oa_directory = os.path.join(RpcSession.base_path, "common", "oa")
104
+ os.environ["ANSYS_OADIR"] = oa_directory
105
+ os.environ["PATH"] = "{};{}".format(os.environ["PATH"], RpcSession.base_path)
106
+
107
+ if RpcSession.pid:
108
+ if restart_server:
109
+ pyedb_logger.logger.info("Restarting RPC server")
110
+ if kill_all_instances:
111
+ RpcSession.__kill_all_instances()
112
+ else:
113
+ RpcSession.__kill()
114
+ RpcSession.__start_rpc_server()
115
+ else:
116
+ pyedb_logger.info(f"Server already running on port {RpcSession.port}")
117
+ else:
118
+ RpcSession.__start_rpc_server()
119
+ if RpcSession.rpc_session:
120
+ RpcSession.server_pid = RpcSession.rpc_session.local_server_proc.pid
121
+ pyedb_logger.info(f"Grpc session started: pid={RpcSession.server_pid}")
122
+ else:
123
+ pyedb_logger.error("Failed to start EDB_RPC_server process")
124
+
125
+ @staticmethod
126
+ def __get_process_id():
127
+ proc = [p for p in list(psutil.process_iter()) if "edb_rpc" in p.name().lower()]
128
+ time.sleep(latency_delay)
129
+ if proc:
130
+ RpcSession.pid = proc[-1].pid
131
+ else:
132
+ RpcSession.pid = 0
133
+
134
+ @staticmethod
135
+ def __start_rpc_server():
136
+ RpcSession.rpc_session = launch_session(RpcSession.base_path, port_num=RpcSession.port)
137
+ start_managing(IOMangementType.READ_AND_WRITE)
138
+ time.sleep(latency_delay)
139
+ if RpcSession.rpc_session:
140
+ RpcSession.pid = RpcSession.rpc_session.local_server_proc.pid
141
+ pyedb_logger.logger.info("Grpc session started")
142
+
143
+ @staticmethod
144
+ def __kill():
145
+ p = psutil.Process(RpcSession.pid)
146
+ time.sleep(latency_delay)
147
+ p.terminate()
148
+
149
+ @staticmethod
150
+ def _kill_all_instances():
151
+ proc = [p.pid for p in list(psutil.process_iter()) if "edb_rpc" in p.name().lower()]
152
+ time.sleep(latency_delay)
153
+ for pid in proc:
154
+ p = psutil.Process(pid)
155
+ p.terminate()
156
+
157
+ @staticmethod
158
+ def close():
159
+ """Terminate the current RPC session. Must be executed at the end of the script to close properly the session.
160
+ If not executed, users should force restarting the process using the flag `restart_server`=`True`.
161
+ """
162
+ if RpcSession.rpc_session:
163
+ end_managing()
164
+ RpcSession.rpc_session.disconnect()
165
+ time.sleep(latency_delay)
166
+
167
+ @staticmethod
168
+ def __get_random_free_port():
169
+ """"""
170
+ port = randint(49152, 65535)
171
+ while True:
172
+ used_ports = [conn.laddr[1] for conn in psutil.net_connections()]
173
+ if port in used_ports:
174
+ port = randint(49152, 65535)
175
+ else:
176
+ break
177
+ return port
@@ -27,9 +27,10 @@ from pyedb.ipc2581.ecad.cad_data.polygon import Polygon
27
27
  class AssemblyDrawing(object):
28
28
  """Class describing an IPC2581 assembly drawing."""
29
29
 
30
- def __init__(self, ipc):
30
+ def __init__(self, ipc, pedb):
31
31
  self._ipc = ipc
32
- self.polygon = Polygon(self._ipc)
32
+ self._pedb = pedb
33
+ self.polygon = Polygon(self._ipc, pedb)
33
34
  self.line_ref = ""
34
35
 
35
36
  def write_xml(self, package): # pragma no cover
@@ -30,15 +30,16 @@ from pyedb.ipc2581.ecad.cad_data.polygon import Polygon
30
30
  class Feature(object):
31
31
  """Class describing IPC2581 features."""
32
32
 
33
- def __init__(self, ipc):
33
+ def __init__(self, ipc, pedb):
34
34
  self._ipc = ipc
35
+ self._pedb = pedb
35
36
  self.feature_type = FeatureType().Polygon
36
37
  self.net = ""
37
38
  self.x = 0.0
38
39
  self.y = 0.0
39
- self.polygon = Polygon(self._ipc)
40
+ self.polygon = Polygon(self._ipc, self._pedb)
40
41
  self._cutouts = []
41
- self.path = Path(self._ipc)
42
+ self.path = Path(self._ipc, pedb)
42
43
  # self.pad = PadstackDef()
43
44
  self.padstack_instance = PadstackInstance()
44
45
  self.drill = Drill()