versione che funziona in TB con test del target

This commit is contained in:
VALLONGOL 2026-02-04 14:23:49 +01:00
parent ca86e5da0b
commit 45c40f76e5
2 changed files with 421 additions and 1 deletions

View File

@ -72,7 +72,7 @@ EXPORT_STATISTICS_CSV = True # Export statistics to CSV file for Excel/external
# Target detection test runs AFTER PBIT completion (if PBIT passed). # Target detection test runs AFTER PBIT completion (if PBIT passed).
# Enable via ask_production_config() or simulation configuration. # Enable via ask_production_config() or simulation configuration.
# This verifies radar can detect simulated targets using B9 message monitoring. # This verifies radar can detect simulated targets using B9 message monitoring.
TARGET_DETECTION_TIMEOUT_SEC = 10.0 # Target detection timeout: max seconds to wait for target visibility TARGET_DETECTION_TIMEOUT_SEC = 20.0 # Target detection timeout: max seconds to wait for target visibility
TARGET_EXPECTED_RANGE = 2536 # Expected target range in ICD units (from target3) TARGET_EXPECTED_RANGE = 2536 # Expected target range in ICD units (from target3)
TARGET_RANGE_TOLERANCE_LOW = 1000 # Range tolerance: lower bound (default: -1000 units) TARGET_RANGE_TOLERANCE_LOW = 1000 # Range tolerance: lower bound (default: -1000 units)
TARGET_RANGE_TOLERANCE_HIGH = 200 # Range tolerance: upper bound (default: +200 units) TARGET_RANGE_TOLERANCE_HIGH = 200 # Range tolerance: upper bound (default: +200 units)

View File

@ -0,0 +1,420 @@
# ✅ Checklist Pre-Esecuzione Hardware (run_target.bat)
**Data:** 4 Febbraio 2026
**Obiettivo:** Verificare che il codice sia pronto per esecuzione su hardware reale senza sorprese negative
---
## 🎯 SOMMARIO ESECUTIVO
### ✅ VERIFICHE SUPERATE
- [x] Flag `ENABLE_TELLBACK_VERIFICATION = False` (strategia Albertook veloce)
- [x] Timing ottimizzati (1.5s setup invece di 20s)
- [x] Nome report PDF corretto (`GRIFO_M_PBIT_Report_YYYYMMDD_HHMM.pdf`)
- [x] Gestione graceful Ctrl-C (signal handler)
- [x] Nessun errore di sintassi Python
- [x] Import path corretti (gestiti da `__init__.py`)
- [x] Compatibilità ICD 100% (field names verificati)
- [x] Strategia Albertook implementata correttamente
### ⚠️ ATTENZIONE RICHIESTA
- [ ] **VERIFICA HARDWARE FISICO CONNESSO** (1553, serial, power)
- [ ] **CONFIGURAZIONE OPERATORE** (numero runs, GUI, target test)
- [ ] **KNOWN_FAILURES** aggiornato per il setup HW specifico
- [ ] **BACKUP REPORT PRECEDENTI** (sovrascrittura possibile)
---
## 1⃣ PREREQUISITI HARDWARE
### ✅ Hardware Verificato
- **Bus 1553:** Scheda hardware installata e configurata
- **Serial Terminal:** Connessione COM configurata (verifica `leo_grifo_terminal.py`)
- **Power Control:** BrainBox/IO box connessa per power cycling
- **Radar GRIFO:** Alimentazione disponibile e cablaggio completo
### ⚠️ DA VERIFICARE PRIMA DEL TEST
```bash
# 1. Verifica che il file INI di produzione esista
dir PlatformSimulator\LeonardoCompany\x86_64-w64-mingw32\grifo_bus_controller.ini
# 2. Verifica che uPlatSim.exe esista
dir PlatformSimulator\bin\uPlatSim.exe
# 3. Verifica configurazione 1553 (apri INI e controlla indirizzi)
notepad PlatformSimulator\LeonardoCompany\x86_64-w64-mingw32\grifo_bus_controller.ini
```
---
## 2⃣ CONFIGURAZIONE TIMING (IMPLEMENTATA)
### ✅ Timing Albertook Attivi
```python
ENABLE_TELLBACK_VERIFICATION = False # ← Modalità veloce (default)
power_grifo_on(wait_after=1.5) # ← 1.5s invece di 2.1s
# Attese 2s/1s/2s rimosse ← Tempo totale setup: ~1.5s
```
### 🔧 Se Tellback Verification Necessaria
Se durante il test l'hardware **non accetta i comandi** immediatamente, puoi abilitare la verifica:
```python
ENABLE_TELLBACK_VERIFICATION = True # ← Abilita verifica B7 (setup ~11s)
```
**Sintomi che richiedono verifica:**
- Radar non entra in STANDBY
- SILENCE non viene applicato
- Target test fallisce per stato radar errato
- Log mostra comandi ignorati
---
## 3⃣ KNOWN FAILURES CONFIGURATION
### ✅ Configurazione Attuale
```python
KNOWN_FAILURES = [
"radar_health_status_and_bit_report_valid_RdrHealthStatusAndBitReport_pedestal_status",
# ← Pedestal non presente nel setup HW test
]
```
### ⚠️ DA AGGIORNARE SECONDO SETUP
Se il setup HW **non ha** altri componenti fisici, aggiungi alla lista:
```python
KNOWN_FAILURES = [
"radar_health_status_and_bit_report_valid_RdrHealthStatusAndBitReport_pedestal_status",
# Aggiungi qui altri known failures secondo il setup HW:
# "...transmitter_status", # Se TX non collegato
# "...receiver_status", # Se RX non collegato
# ecc.
]
```
**Come identificare known failures:**
1. Esegui **primo test** con lista minima
2. Verifica nel report PDF quali campi falliscono **sempre**
3. Aggiungi i campi ripetitivi alla lista `KNOWN_FAILURES`
4. Riesegui test per conferma
---
## 4⃣ NOME REPORT PDF
### ✅ RISOLTO - Configurazione Corretta
```json
// TestEnvironment/json/GRIFO_M_PBIT.json
{
"file_name": "GRIFO_M_PBIT_Report" // ← Aggiunto campo
}
```
```python
// TestEnvironment/env/leo_grifo_test_report.py (riga 86)
file_name = my_pdf.pdf_name(self.json_test, '') // ← Corretto (era json_template)
```
**Risultato:** `GRIFO_M_PBIT_Report_20260204_1121.pdf`
### 📁 Posizione Report
```
TestEnvironment/pdf_reports/GRIFO_M_PBIT/GRIFO_M_PBIT_Report_YYYYMMDD_HHMM.pdf
```
---
## 5⃣ CONFIGURAZIONE OPERATORE
### ⚠️ RICHIESTA INTERATTIVA ALL'AVVIO
Il test chiede **3 configurazioni** all'operatore (se NON in --simulate):
```python
runs_total, gui_enabled, run_on_target = ask_production_config()
```
**Domande previste:**
1. **"Enter number of test repetitions [10]:"**
- Default: 10 runs
- Consiglio primo test: **3 runs** per verifica rapida
2. **"Enable GUI monitor? (y/n) [n]:"**
- Default: No
- Consiglio: **y** per monitoraggio visuale
3. **"Run target detection test? (y/n) [n]:"**
- Default: No
- Consiglio primo test: **n** (solo PBIT)
- Abilita **dopo** aver verificato che PBIT funzioni
### 📝 Esempio Configurazione Primo Test
```
Enter number of test repetitions [10]: 3
Enable GUI monitor? (y/n) [n]: y
Run target detection test? (y/n) [n]: n
```
---
## 6⃣ FLUSSO TEST HARDWARE
### ✅ Sequenza Implementata (Albertook Style)
```
Per ogni ripetizione (default: 10):
1. Power OFF radar (wait_before=1s, wait_after=4s)
2. Power ON radar (wait_after=1.5s)
3. Setup immediato:
- INTENSITY (A1)
- SILENCE + scan params + STANDBY (A2 raggruppato)
- Nav data (A4 raggruppato)
- INU mode (A5)
4. [OPZIONALE] Verifica tellback B7 (solo se flag=True)
5. PBIT test (timeout 182s)
- Monitoring 1553 bus health
- Verifica B6 (12 campi LRU)
- Drill-down B8 se failures (173 campi diagnostici)
6. Rimozione STANDBY
7. [OPZIONALE] Target test (solo se richiesto)
8. Ripristino STANDBY
9. Statistiche run
Finale:
- Aggregate statistics
- Export CSV (se enabled)
- Generate PDF report
```
### ⏱️ Timing Previsto per Run
- Power cycle: **~5.5s** (1s + 4s off, 1.5s on)
- Setup: **~1.5s** (se tellback=False) o **~11s** (se tellback=True)
- PBIT: **variabile** (max 182s timeout, tipicamente 60-120s)
- Target test: **~10s** (se abilitato)
- **Totale per run:** ~70-200s (dipende da PBIT duration)
**Per 10 runs:** 12-33 minuti ⏱️
---
## 7⃣ GESTIONE INTERRUZIONI
### ✅ Ctrl-C Graceful Shutdown Implementato
```python
def signal_handler(sig, frame):
global interruptRequest
logging.info("Ctrl-C detected, exiting gracefully...")
interruptRequest = True
```
**Comportamento:**
- Ctrl-C durante test: completa run corrente, poi esce
- Report PDF generato anche se interrotto
- Statistiche salvate fino al momento dell'interruzione
- Power OFF finale eseguito (radar non resta acceso)
### ⚠️ NON INTERROMPERE CON Ctrl-Break o Chiusura Finestra
- Usa **solo Ctrl-C** per interruzione graceful
- Ctrl-Break o chiusura forzata = radar potrebbe restare acceso
---
## 8⃣ VERIFICHE POST-TEST
### ✅ Report PDF Generato
```bash
# Verifica presenza report
dir TestEnvironment\pdf_reports\GRIFO_M_PBIT\GRIFO_M_PBIT_Report_*.pdf
# Apri l'ultimo report
start TestEnvironment\pdf_reports\GRIFO_M_PBIT\GRIFO_M_PBIT_Report_*.pdf
```
### ✅ CSV Statistics (se enabled)
```bash
dir TestEnvironment\pdf_reports\GRIFO_M_PBIT\*_statistics.csv
```
### ✅ Log File
```bash
# Verifica log per errori
findstr /i "error" TestEnvironment\LOG\*.log
findstr /i "warning" TestEnvironment\LOG\*.log
```
---
## 9⃣ PROBLEMI COMUNI E SOLUZIONI
### ⚠️ Problema: "1553 communication loss detected"
**Causa:** Bus 1553 non risponde
**Soluzione:**
1. Verifica cablaggio 1553
2. Verifica alimentazione radar
3. Verifica configurazione INI (indirizzo RT corretto)
### ⚠️ Problema: "Serial terminal timeout"
**Causa:** Porta COM non risponde
**Soluzione:**
1. Verifica porta COM in `leo_grifo_terminal.py`
2. Verifica cavo seriale connesso
3. Verifica radar sta inviando messaggi seriali
### ⚠️ Problema: "Power control failed"
**Causa:** BrainBox non risponde
**Soluzione:**
1. Verifica BrainBox connessa e alimentata
2. Verifica configurazione `leo_grifo_io_box.py`
3. Test manuale power control
### ⚠️ Problema: "STANDBY/SILENCE not applied"
**Causa:** Comandi A2 non accettati dal radar
**Soluzione:**
1. Abilita tellback verification: `ENABLE_TELLBACK_VERIFICATION = True`
2. Aumenta attese se necessario
3. Verifica ICD compatibility (già fatto ✅)
### ⚠️ Problema: "B6 failures all runs"
**Causa:** Campi sempre falliti (HW setup limits)
**Soluzione:**
1. Aggiungi campi a `KNOWN_FAILURES` list
2. Riesegui test per conferma
---
## 🔟 COMANDI ESECUZIONE
### 🚀 Esecuzione Standard
```bash
cd C:\src\____GitProjects\SXXXXXXX_PlatSim
run_target.bat
```
### 🐛 Esecuzione Debug (con log verbose)
```bash
# Modifica GRIFO_M_PBIT.py temporaneamente:
# logging.basicConfig(level=logging.DEBUG) # ← cambia da INFO a DEBUG
run_target.bat
```
### 🧪 Test Rapido (3 runs, no target)
```bash
run_target.bat
# Quando chiede:
# Enter number of test repetitions [10]: 3
# Enable GUI monitor? (y/n) [n]: y
# Run target detection test? (y/n) [n]: n
```
---
## 1⃣1⃣ BACKUP RACCOMANDATI
### 📦 Prima del Test
```bash
# Backup report precedenti
xcopy TestEnvironment\pdf_reports\GRIFO_M_PBIT TestEnvironment\pdf_reports\GRIFO_M_PBIT_BACKUP_%DATE:~-4,4%%DATE:~-7,2%%DATE:~-10,2% /E /I /Y
# Backup log precedenti
xcopy TestEnvironment\LOG TestEnvironment\LOG_BACKUP_%DATE:~-4,4%%DATE:~-7,2%%DATE:~-10,2% /E /I /Y
```
---
## 1⃣2⃣ CHECKLIST FINALE PRE-LANCIO
### ✅ Hardware Ready
- [ ] Radar GRIFO alimentato e connesso
- [ ] Bus 1553 hardware installato e configurato
- [ ] Serial terminal (COM) connesso
- [ ] BrainBox power control connessa
- [ ] Cablaggio verificato
### ✅ Software Ready
- [ ] `ENABLE_TELLBACK_VERIFICATION = False` (start con False)
- [ ] `KNOWN_FAILURES` lista aggiornata per setup HW
- [ ] `NUMBER_OF_REPETITIONS = 10` (o valore desiderato)
- [ ] Backup report precedenti eseguito
- [ ] Log directory pulita o archiviata
### ✅ Configurazione Operatore Preparata
- [ ] Numero runs deciso (consiglio: 3 per primo test)
- [ ] GUI enabled/disabled deciso (consiglio: y per primo test)
- [ ] Target test enabled/disabled deciso (consiglio: n per primo test)
### ✅ Verifica Eseguita
- [ ] `run_target.bat` eseguibile trovato
- [ ] `uPlatSim.exe` esiste in `PlatformSimulator\bin`
- [ ] `grifo_bus_controller.ini` esiste e configurato
- [ ] Python embedded presente (`python37.dll`)
---
## 1⃣3⃣ COSA ASPETTARSI
### ✅ Output Normale
```
===============================================================================
GRIFO M-PBIT Test - Production Mode (Target Reale)
===============================================================================
[INFO] Using embedded Python 3.7.x
[INFO] Using uPlatSim.exe with embedded Python interpreter
[INFO] Configuration: grifo_bus_controller.ini (hardware interfaces enabled)
[INFO] Script: GRIFO_M_PBIT.py (NO --simulate flag)
[INFO] Test execution starting...
Enter number of test repetitions [10]: 3
Enable GUI monitor? (y/n) [n]: y
Run target detection test? (y/n) [n]: n
[INFO] Starting repetition 1/3
[INFO] Power OFF - waiting for stabilization...
[INFO] Power ON - setup starting immediately
[Setup] Configuring radar parameters (Albertook style)
[Setup] TELLBACK VERIFICATION DISABLED - Using "fire and forget" mode
[Run 1] Starting PBIT test (timeout: 182s)
...
```
### ⚠️ Output Problematico
```
[ERROR] 1553 communication loss detected (threshold: 20 iterations)
[ERROR] B6 field XYZ failed (not in known failures)
[WARNING] STANDBY removal not verified
```
---
## 🎯 RIEPILOGO FINALE
| Aspetto | Status | Note |
|---------|--------|------|
| **Codice Python** | ✅ OK | Nessun errore sintassi |
| **Strategia Timing** | ✅ OK | Albertook implementato |
| **Flag Tellback** | ✅ OK | Default: False (veloce) |
| **Report PDF** | ✅ OK | Nome corretto |
| **ICD Compatibility** | ✅ OK | 100% verificato |
| **Graceful Shutdown** | ✅ OK | Ctrl-C gestito |
| **Hardware Prereq** | ⚠️ VERIFY | Operatore deve verificare |
| **Known Failures** | ⚠️ REVIEW | Aggiorna secondo setup |
| **Backup** | ⚠️ DO IT | Prima del test |
---
## ✅ CONCLUSIONE
**Il codice è PRONTO per esecuzione hardware** con le seguenti raccomandazioni:
1. **Primo test:** 3 runs, GUI enabled, no target test
2. **Verificare hardware** fisico connesso prima di lanciare
3. **Backup report** precedenti
4. **Aggiornare `KNOWN_FAILURES`** dopo primo test
5. **Se problemi comandi:** abilitare `ENABLE_TELLBACK_VERIFICATION = True`
**Comando per iniziare:**
```bash
cd C:\src\____GitProjects\SXXXXXXX_PlatSim
run_target.bat
```
**Buon test! 🚀**