Skip to content

Commit

Permalink
ENH: modifying RE control functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
olliviergassant committed Jul 5, 2024
1 parent 70427a1 commit 0b71606
Showing 1 changed file with 27 additions and 49 deletions.
76 changes: 27 additions & 49 deletions queueUI/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,68 +46,46 @@ def __init__(self):
print("Settings are saved in:", settings.fileName())

self.RM = REManagerAPI()
# self.REOpenButton.clicked.connect(self.openRunEngine)
# self.RECloseButton.clicked.connect(self.closeRunEngine)

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

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.RECloseButton.setEnabled(True)
# self.REOpenButton.setEnabled(False)
# self.setStatus("RE Environment is now open.", timeout=0)

# # print(f"status = {self.RM.status().get('worker_environment_exists')}")
# else:
# pass

# 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")
# 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')}")
# else:
# pass

def openRunEngine(self):
"""Open RE"""
self.RM.environment_open()
self.RM.wait_for_idle()
self.run_engine_state_change()

def closeRunEngine(self):
"""Close RE"""
self.RM.environment_close()
self.RM.wait_for_idle()
self.run_engine_state_change()

def run_engine_state(self, status, status_string):
self.setStatus(f"RE Environment is {status_string}.", timeout=0)
self.RM.environment_close()
self.RM.wait_for_idle() #This is same
self.REEnvironmentStatusLabel.setText(f"{status_string}"+"ed") #This is the same
if status is True:
self.RECloseButton.setEnabled(False)
self.REOpenButton.setEnabled(True)
else:
self.RECloseButton.setEnabled(True)
self.REOpenButton.setEnabled(False)

self.setStatus(f"RE Environment is now {status_string}"+"ed.", timeout=0)
"""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(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"
status_string = "open"
self.run_engine_state(True, status_string)
else:
status_string = "closed"
self.run_engine_state(False, status_string)


def destroyRunEngine(self):
"""Destroys the RunEngine."""
# TODO: Remove this function.
Expand Down

0 comments on commit 0b71606

Please sign in to comment.