Skip to content
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

Status simplification #16

Merged
merged 4 commits into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 28 additions & 23 deletions queueUI/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,40 +46,45 @@ def __init__(self):
print("Settings are saved in:", settings.fileName())

self.RM = REManagerAPI()

self.run_engine_state_change()
self.REOpenButton.clicked.connect(self.openRunEngine)
self.RECloseButton.clicked.connect(self.closeRunEngine)

# RE Function:
def openRunEngine(self):
"""Checks the status of the RE. Then opens the RE."""
if not self.RM.status().get("worker_environment_exists"):
# BUG: Status bar in app window does not print the statement below
self.setStatus("RE Environment is opening.", timeout=0)
self.RM.environment_open()
self.RM.wait_for_idle()
self.REEnvironmentStatusLabel.setText("Open")
self.REOpenButton.setEnabled(False)
self.RECloseButton.setEnabled(True)
self.setStatus("RE Environment is now open.", timeout=0)

# print(f"status = {self.RM.status().get('worker_environment_exists')}")
else:
pass
def openRunEngine(self):
"""Open RE"""
self.RM.environment_open()
self.RM.wait_for_idle()
self.run_engine_state_change()

def closeRunEngine(self):
"""Checks the status of the RE. Then closes the RunEngine."""
if self.RM.status().get("worker_environment_exists"):
self.setStatus("RE Environment is closing.", timeout=0)
self.RM.environment_close()
self.RM.wait_for_idle()
self.REEnvironmentStatusLabel.setText("Closed")
"""Close RE"""
self.RM.environment_close()
self.RM.wait_for_idle()
self.run_engine_state_change()
olliviergassant marked this conversation as resolved.
Show resolved Hide resolved

def run_engine_state(self, status, status_string):
"""Set RE State"""
self.setStatus(f"RE Environment is {status_string}.", timeout=0)
if status is True:
self.RECloseButton.setEnabled(True)
self.REOpenButton.setEnabled(False)
else:
self.RECloseButton.setEnabled(False)
self.REOpenButton.setEnabled(True)
self.setStatus("RE Environment is now closed.", timeout=0)

# print(f"status = {self.RM.status().get('worker_environment_exists')}")
self.setStatus(f"RE Environment is now {status_string}", timeout=0)

def run_engine_state_change(self):
"""Check RE state"""
if self.RM.status().get("worker_environment_exists"):
status_string = "open"
self.run_engine_state(True, status_string)
else:
pass
status_string = "closed"
self.run_engine_state(False, status_string)

def destroyRunEngine(self):
"""Destroys the RunEngine."""
Expand Down
Loading