From 7321aecd85b08143dea8b0535235b0eec33a26fd Mon Sep 17 00:00:00 2001 From: edo Date: Thu, 21 Aug 2025 14:38:04 +0200 Subject: [PATCH] dev --- config/machine_settings/st-ten-12.ini | 2 +- .../{test_absence.pbtxt => test_absent.pbtxt} | 0 .../{test_absence.ini => test_absent.ini} | 0 src/components/hikrobot_sc/hikrobot_sc.py | 57 ++----------------- 4 files changed, 7 insertions(+), 52 deletions(-) rename config/vision/labels/{test_absence.pbtxt => test_absent.pbtxt} (100%) rename config/vision/recipes/{test_absence.ini => test_absent.ini} (100%) diff --git a/config/machine_settings/st-ten-12.ini b/config/machine_settings/st-ten-12.ini index dbf5de3..358ecbd 100644 --- a/config/machine_settings/st-ten-12.ini +++ b/config/machine_settings/st-ten-12.ini @@ -16,7 +16,7 @@ vision: present screwdriver: absent digital_io: present barcode_recipe_selection: present -fixture_id: present +fixture_id: absent discard_box: absent # enforce_piece_removal: yes diff --git a/config/vision/labels/test_absence.pbtxt b/config/vision/labels/test_absent.pbtxt similarity index 100% rename from config/vision/labels/test_absence.pbtxt rename to config/vision/labels/test_absent.pbtxt diff --git a/config/vision/recipes/test_absence.ini b/config/vision/recipes/test_absent.ini similarity index 100% rename from config/vision/recipes/test_absence.ini rename to config/vision/recipes/test_absent.ini diff --git a/src/components/hikrobot_sc/hikrobot_sc.py b/src/components/hikrobot_sc/hikrobot_sc.py index 4e66b61..5b1905b 100644 --- a/src/components/hikrobot_sc/hikrobot_sc.py +++ b/src/components/hikrobot_sc/hikrobot_sc.py @@ -319,7 +319,7 @@ class HikrobotSmartCamera(Component): self._debug_camera_state(handle) try: - self.log.info(f"Starting scheme switch to: {solution_name} (Attempt {retry_count+1}/{max_retries+1})") + # Check if the solution name is valid (not empty) if not solution_name or solution_name.strip() == "": @@ -337,13 +337,7 @@ class HikrobotSmartCamera(Component): # Try to get more information about the error self._debug_camera_state(handle) - # Check if this is the generic error and we can retry - if error_code == 0x80030100 and retry_count < max_retries: # MV_VS_E_GC_GENERIC - self.log.warning(f"Detected generic error (0x80030100). Waiting 2 seconds before retry {retry_count+1}/{max_retries}") - time.sleep(2) # Wait before retrying - return self.switch_scheme(solution_name, retry_count + 1, max_retries) - - return False + else: self.log.info(f"Successfully set solution name: {solution_name}") @@ -357,11 +351,7 @@ class HikrobotSmartCamera(Component): # Try to get more information about the error self._debug_camera_state(handle) - # Check if this is the generic error and we can retry - if error_code == 0x80030100 and retry_count < max_retries: # MV_VS_E_GC_GENERIC - self.log.warning(f"Detected generic error (0x80030100). Waiting 2 seconds before retry {retry_count+1}/{max_retries}") - time.sleep(2) # Wait before retrying - return self.switch_scheme(solution_name, retry_count + 1, max_retries) + return False else: @@ -382,11 +372,7 @@ class HikrobotSmartCamera(Component): import traceback self.log.error(f"Exception traceback: {traceback.format_exc()}") - # Retry on exception if we haven't exceeded max retries - if retry_count < max_retries: - self.log.warning(f"Exception occurred. Waiting 2 seconds before retry {retry_count+1}/{max_retries}") - time.sleep(2) # Wait before retrying - return self.switch_scheme(solution_name, retry_count + 1, max_retries) + return False @@ -604,11 +590,7 @@ class HikrobotSmartCamera(Component): self.log.error(f"CAM{cam_idx} Start run failed! [{nRet & 0xFFFFFFFF:#x}]") self.connected = True - - # Now that the camera is connected, switch to the solution if one is set - if self.solution_name is not None: - self.log.info(f"Switching to solution: {self.solution_name}") - self.switch_scheme(self.solution_name) + @Component.reconfig_on_error def _get(self): @@ -885,31 +867,4 @@ class HikrobotSmartCamera(Component): self.log.warning(f"Scheme switch verification failed. Expected: {solution_name}, Got: {new_scheme}") return False - def test_scheme_switch(self, solution_name=None): - """ - Test method to manually trigger a scheme switch. - This can be used for debugging or testing the scheme switching functionality. - - Args: - solution_name: The name of the solution to switch to. If None, uses the current solution_name. - - Returns: - bool: True if successful, False otherwise - """ - if solution_name is None: - if self.solution_name is None: - self.log.error("No solution name provided and no current solution name set") - return False - solution_name = self.solution_name - - self.log.info(f"Testing scheme switch to: {solution_name}") - - if not self.connected: - self.log.info("Camera not connected, connecting first...") - self.config_changed() - if not self.connected: - self.log.error("Failed to connect to camera") - return False - - # Use the synchronous scheme switching method - return self.switch_scheme_sync(solution_name) +