Browse Source

add retry logic for batch

Tuan Nguyen 1 năm trước cách đây
mục cha
commit
0986b55109
1 tập tin đã thay đổi với 10 bổ sung0 xóa
  1. 10 0
      app.py

+ 10 - 0
app.py

@@ -384,6 +384,16 @@ def run_theta_rho_file(file_path, schedule_hours=None):
                             # Update execution progress with formatted ETA
                             # Update execution progress with formatted ETA
                             execution_progress = (i + batch_size, total_coordinates, estimated_remaining_time)
                             execution_progress = (i + batch_size, total_coordinates, estimated_remaining_time)
                             break
                             break
+                        elif response.startswith("IGNORE"):  # Retry the previous batch
+                            print("Received IGNORE. Resending the previous batch...")
+                            # Calculate the previous batch indices
+                            prev_start = max(0, i - batch_size)  # Ensure we don't go below 0
+                            prev_end = i  # End of the previous batch is `i`
+                            previous_batch = coordinates[prev_start:prev_end]
+
+                            # Resend the previous batch
+                            send_coordinate_batch(ser, previous_batch)
+                            break  # Exit the retry loop after resending
                         else:
                         else:
                             print(f"Arduino response: {response}")
                             print(f"Arduino response: {response}")