Bläddra i källkod

add retry logic for batch

Tuan Nguyen 1 år sedan
förälder
incheckning
0986b55109
1 ändrade filer med 10 tillägg och 0 borttagningar
  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
                             execution_progress = (i + batch_size, total_coordinates, estimated_remaining_time)
                             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:
                             print(f"Arduino response: {response}")