dev
This commit is contained in:
parent
d738f9293c
commit
93063eba51
|
|
@ -126,13 +126,14 @@ class HikrobotSmartCamera(Component):
|
|||
|
||||
self._progress_check_count += 1
|
||||
if self._progress_check_count >= 20:
|
||||
self.log.warning(f"Force completing operation after timeout: {self.current_operation}")
|
||||
current_op = self.current_operation
|
||||
self.log.warning(f"Force completing operation after timeout: {current_op}")
|
||||
self.progress_timer.stop()
|
||||
self.current_operation = None
|
||||
self._progress_check_count = 0
|
||||
|
||||
# If we were switching schemes, try to refresh the module list anyway
|
||||
if self.current_operation == "switch_scheme":
|
||||
if current_op == "switch_scheme":
|
||||
self.log.info("Attempting to refresh module list after timeout")
|
||||
self.refresh_module_list()
|
||||
|
||||
|
|
@ -544,13 +545,13 @@ class HikrobotSmartCamera(Component):
|
|||
self.log.error(f"Error getting current scheme: {e}")
|
||||
return None
|
||||
|
||||
def switch_scheme_sync(self, solution_name, timeout=None):
|
||||
def switch_scheme_sync(self, solution_name, timeout=30):
|
||||
"""
|
||||
Synchronously switch to a different scheme/solution and wait for completion.
|
||||
|
||||
Args:
|
||||
solution_name: The name of the solution to switch to
|
||||
timeout: Not used, kept for backward compatibility
|
||||
timeout: Maximum time in seconds to wait for scheme switching to complete (default: 30)
|
||||
|
||||
Returns:
|
||||
bool: True if successful, False otherwise
|
||||
|
|
@ -571,13 +572,23 @@ class HikrobotSmartCamera(Component):
|
|||
self.log.error(f"Failed to initiate scheme switch to: {solution_name}")
|
||||
return False
|
||||
|
||||
# Wait for the scheme switching to complete (no timeout)
|
||||
self.log.info(f"Waiting for scheme switch to complete (no timeout)")
|
||||
# Wait for the scheme switching to complete with timeout
|
||||
self.log.info(f"Waiting for scheme switch to complete (timeout: {timeout}s)")
|
||||
|
||||
start_time = time.time()
|
||||
while self.current_operation == "switch_scheme":
|
||||
# Sleep a bit to avoid busy waiting
|
||||
time.sleep(0.5)
|
||||
|
||||
# Check if we've exceeded the timeout
|
||||
if timeout is not None and (time.time() - start_time) > timeout:
|
||||
self.log.warning(f"Scheme switch timeout after {timeout} seconds")
|
||||
# Force stop the progress monitoring
|
||||
if self.progress_timer.isActive():
|
||||
self.progress_timer.stop()
|
||||
self.current_operation = None
|
||||
break
|
||||
|
||||
# Verify the switch was successful by checking the current scheme
|
||||
new_scheme = self.get_current_scheme()
|
||||
if new_scheme == solution_name:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user