-
Notifications
You must be signed in to change notification settings - Fork 164
Adding Process ID so PyAEDT can point to a specific instance of Electronics Desktop #1187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
5055c9c
d6a25c1
2a806e7
7bc4230
26affba
83f8860
c725de2
4be49eb
bdf938d
c79d1fe
94b31d3
0e61189
5e0a2e9
36d2aac
6d4d470
25f8a98
1404c94
e1880c5
0d7612b
528cf88
cd14eb7
21ed735
a49088c
4f2c46e
fb140da
e1d5775
6986c98
8b34468
c125bf8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -290,6 +290,9 @@ class Desktop: | |||||
Port number of which start the oDesktop communication on already existing server. | ||||||
This parameter is ignored in new server creation. It works only on 2022R2. | ||||||
Remote Server must be up and running with command `"ansysedt.exe -grpcsrv portnum"`. | ||||||
aedt_process_id : int, optional | ||||||
Only used when new_desktop_session == False, specifies by process id which instance | ||||||
of electronics desktop to point PyAEDT at. | ||||||
|
||||||
Examples | ||||||
-------- | ||||||
|
@@ -321,6 +324,7 @@ def __init__( | |||||
student_version=False, | ||||||
machine="", | ||||||
port=0, | ||||||
aedt_process_id = None, | ||||||
): | ||||||
"""Initialize desktop.""" | ||||||
self._main = sys.modules["__main__"] | ||||||
|
@@ -332,6 +336,7 @@ def __init__( | |||||
self._main.student_version = student_version | ||||||
self.machine = machine | ||||||
self.port = port | ||||||
self.aedt_process_id = aedt_process_id | ||||||
if is_ironpython: | ||||||
self._main.isoutsideDesktop = False | ||||||
else: | ||||||
|
@@ -363,7 +368,7 @@ def __init__( | |||||
if StrictVersion(version_key) < StrictVersion("2022.2.0") or not settings.use_grpc_api: | ||||||
print("Launching PyAEDT outside Electronics Desktop with CPython and Pythonnet") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @PipKat , while I don't mind committing the small change to this print statement, it is outside the scope of changes I contributed to the code. I'd appreciate the (somewhat redundant) affirmation that it is ok to proceed with this commit. |
||||||
self._init_cpython( | ||||||
non_graphical, new_desktop_session, version, self._main.student_version, version_key | ||||||
non_graphical, new_desktop_session, version, self._main.student_version, version_key, aedt_process_id | ||||||
) | ||||||
else: | ||||||
self._init_cpython_new(non_graphical, new_desktop_session, version, self._main.student_version) | ||||||
|
@@ -382,6 +387,7 @@ def __init__( | |||||
settings.aedt_version = self.odesktop.GetVersion()[0:6] | ||||||
settings.machine = self.machine | ||||||
settings.port = self.port | ||||||
self.aedt_process_id = self.odesktop.GetProcessID() #bit of cleanup for consistency if used in future | ||||||
|
||||||
if _com == "ironpython": | ||||||
sys.path.append( | ||||||
|
@@ -545,7 +551,8 @@ def _dispatch_win32(self, version): | |||||
self._main.oDesktop = o_ansoft_app.GetAppDesktop() | ||||||
self._main.isoutsideDesktop = True | ||||||
|
||||||
def _init_cpython(self, non_graphical, new_aedt_session, version, student_version, version_key): | ||||||
def _init_cpython(self, non_graphical, new_aedt_session, version, student_version, version_key,aedt_process_id = None): | ||||||
|
||||||
base_path = self._main.sDesktopinstallDirectory | ||||||
sys.path.append(base_path) | ||||||
sys.path.append(os.path.join(base_path, "PythonFiles", "DesktopPlugin")) | ||||||
|
@@ -561,7 +568,7 @@ def _init_cpython(self, non_graphical, new_aedt_session, version, student_versio | |||||
processID = [] | ||||||
if IsWindows: | ||||||
processID = self._get_tasks_list_windows(student_version) | ||||||
if student_version and not processID: | ||||||
if student_version and not processID: #Opens an instance if processID is an empty list | ||||||
self._run_student() | ||||||
elif non_graphical or new_aedt_session or not processID: | ||||||
# Force new object if no non-graphical instance is running or if there is not an already existing process. | ||||||
|
@@ -573,8 +580,10 @@ def _init_cpython(self, non_graphical, new_aedt_session, version, student_versio | |||||
processID2 = [] | ||||||
if IsWindows: | ||||||
processID2 = self._get_tasks_list_windows(student_version) | ||||||
proc = [i for i in processID2 if i not in processID] | ||||||
if not proc: | ||||||
proc = [i for i in processID2 if i not in processID] #Looking for the "new" process | ||||||
if not proc and (not new_aedt_session) and aedt_process_id: #if it isn't a new aedt session and a process ID is given | ||||||
proc = [aedt_process_id] | ||||||
elif not proc: | ||||||
proc = processID2 | ||||||
if proc == processID2 and len(processID2) > 1: | ||||||
self._dispatch_win32(version) | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,9 @@ class Hfss(FieldAnalysis3D, object): | |
Port number of which start the oDesktop communication on already existing server. | ||
This parameter is ignored in new server creation. It works only on 2022R2. | ||
Remote Server must be up and running with command `"ansysedt.exe -grpcsrv portnum"`. | ||
aedt_process_id : int, optional | ||
Only used when new_desktop_session == False, specifies by process id which instance | ||
of electronics desktop to point PyAEDT at. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @camuher I like this approach. Anyway you should add the aedt_process_id to any of the tools (q2d, q3d, maxwell3d etc...) otherwise you will be able to initialize the app using process id only from Hfss There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @maxcapodi78 thank you for the quick reply. As specified in my latest commit I've added it to almost all the tools(and parent classes as needed) which makes for a uniform variable across the board. The only one I couldn't add it to was siwave whose init differs significantly from the structure used by the other tools. I hope this is sufficient to address your request. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @camuher There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @maxcapodi78 I've merged to be up to date with main now. I also addressed the error that caused the UT for rmxport and twinbuilder to fail. I hadn't added the variable to their parent classes. There were also miscellaneous edits to make the code more uniform with the style. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @camuher I still see some style error. I suggest to install pre-commit on your environment. It will automatically fix style errors on commit. PS can you ping me on Teams? I'd like to know who you are :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
Examples | ||
-------- | ||
|
@@ -150,6 +153,7 @@ def __init__( | |
student_version=False, | ||
machine="", | ||
port=0, | ||
aedt_process_id = None, | ||
): | ||
FieldAnalysis3D.__init__( | ||
self, | ||
|
@@ -165,6 +169,7 @@ def __init__( | |
student_version, | ||
machine, | ||
port, | ||
aedt_process_id, | ||
) | ||
self.field_setups = self._get_rad_fields() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaxJPRey in my latest commit i've followed this style while addressing Massimo's comment.