This commit is contained in:
edo-neo 2025-08-21 10:54:21 +02:00
parent f3386630c3
commit 2b70218fd4
2 changed files with 7 additions and 25 deletions

View File

@ -544,13 +544,13 @@ class HikrobotSmartCamera(Component):
self.log.error(f"Error getting current scheme: {e}") self.log.error(f"Error getting current scheme: {e}")
return None return None
def switch_scheme_sync(self, solution_name, timeout=30): def switch_scheme_sync(self, solution_name, timeout=None):
""" """
Synchronously switch to a different scheme/solution and wait for completion. Synchronously switch to a different scheme/solution and wait for completion.
Args: Args:
solution_name: The name of the solution to switch to solution_name: The name of the solution to switch to
timeout: Maximum time to wait for the switch to complete (in seconds) timeout: Not used, kept for backward compatibility
Returns: Returns:
bool: True if successful, False otherwise bool: True if successful, False otherwise
@ -571,18 +571,10 @@ class HikrobotSmartCamera(Component):
self.log.error(f"Failed to initiate scheme switch to: {solution_name}") self.log.error(f"Failed to initiate scheme switch to: {solution_name}")
return False return False
# Wait for the scheme switching to complete # Wait for the scheme switching to complete (no timeout)
self.log.info(f"Waiting for scheme switch to complete (timeout: {timeout}s)") self.log.info(f"Waiting for scheme switch to complete (no timeout)")
start_time = time.time()
while self.current_operation == "switch_scheme": while self.current_operation == "switch_scheme":
# Check if we've exceeded the timeout
if time.time() - start_time > timeout:
self.log.error(f"Scheme switching timed out after {timeout} seconds")
self.progress_timer.stop()
self.current_operation = None
return False
# Sleep a bit to avoid busy waiting # Sleep a bit to avoid busy waiting
time.sleep(0.5) time.sleep(0.5)

View File

@ -34,11 +34,7 @@ class SchemeProgressDialog(QDialog):
self.status_label = QLabel("Status: Initializing...") self.status_label = QLabel("Status: Initializing...")
layout.addWidget(self.status_label) layout.addWidget(self.status_label)
# Set a timeout in case the progress signal doesn't complete # No timeout - wait indefinitely for the scheme switching to complete
self.timer = QTimer(self)
self.timer.setSingleShot(True)
self.timer.timeout.connect(self.handle_timeout)
self.timer.start(30000) # 30 second timeout
def update_progress(self, progress, status): def update_progress(self, progress, status):
""" """
@ -52,12 +48,6 @@ class SchemeProgressDialog(QDialog):
elif status == "Failed": elif status == "Failed":
self.reject() self.reject()
def handle_timeout(self):
"""
Handle the case where the progress signal doesn't complete within the timeout.
"""
self.status_label.setText("Status: Timeout - Continuing anyway")
self.accept() # Continue with the cycle even if timeout occurs
class Test_Vision(Test_Test): class Test_Vision(Test_Test):
@ -350,8 +340,8 @@ class Test_Vision(Test_Test):
self.log.info(f"Testing scheme switch to: {test_recipe}") self.log.info(f"Testing scheme switch to: {test_recipe}")
# Use the synchronous scheme switching method directly # Use the synchronous scheme switching method directly (no timeout)
success = self.components["hikrobot_sc"].switch_scheme_sync(test_recipe, timeout=30) success = self.components["hikrobot_sc"].switch_scheme_sync(test_recipe)
if success: if success:
self.log.info(f"Successfully switched to scheme: {test_recipe}") self.log.info(f"Successfully switched to scheme: {test_recipe}")