361 lines
12 KiB
Markdown
361 lines
12 KiB
Markdown
# Modifiche Implementate - Allineamento a Target2
|
|
|
|
**Data Implementazione:** 2 Febbraio 2026
|
|
**Riferimento:** ANALISI_DIFFERENZE_TARGET2.md
|
|
**Stato:** ✅ COMPLETATO
|
|
|
|
---
|
|
|
|
## RIEPILOGO MODIFICHE
|
|
|
|
Tutte le modifiche identificate nell'analisi comparativa sono state implementate con successo, partendo dalle priorità alte e procedendo passo-passo.
|
|
|
|
---
|
|
|
|
## ✅ PRIORITÀ ALTA - IMPLEMENTATE
|
|
|
|
### 1. Parametro wait_before nelle funzioni power
|
|
|
|
**File modificato:** `TestEnvironment/env/test_common_function.py`
|
|
|
|
**Modifica applicata:**
|
|
```python
|
|
# PRIMA:
|
|
def power_grifo_on(wait_after=0):
|
|
def power_grifo_off(wait_after=0):
|
|
|
|
# DOPO:
|
|
def power_grifo_on(wait_after=0, wait_before=0):
|
|
time.sleep(wait_before) # ← AGGIUNTO
|
|
# ... resto del codice ...
|
|
|
|
def power_grifo_off(wait_after=0, wait_before=0):
|
|
time.sleep(wait_before) # ← AGGIUNTO
|
|
# ... resto del codice ...
|
|
```
|
|
|
|
**Motivazione:** La versione target2 utilizza un delay di stabilizzazione (wait_before) prima di cambiare lo stato di alimentazione. Questo è critico per la stabilità hardware.
|
|
|
|
**Retrocompatibilità:** ✅ Mantenuta - il default `wait_before=0` preserva il comportamento esistente per tutti i chiamanti.
|
|
|
|
---
|
|
|
|
### 2. Uso di wait_before nelle chiamate power
|
|
|
|
**File modificato:** `TestEnvironment/scripts/GRIFO_M_PBIT.py`
|
|
|
|
**Modifica applicata (linea ~933):**
|
|
```python
|
|
# PRIMA:
|
|
power_grifo_off(3)
|
|
power_grifo_on()
|
|
|
|
# DOPO:
|
|
power_grifo_off(wait_after=4, wait_before=1)
|
|
power_grifo_on(wait_after=0.100)
|
|
```
|
|
|
|
**Timing allineato a target2:**
|
|
- Power OFF: `wait_before=1s` (stabilizzazione), `wait_after=4s` (tempo di settle)
|
|
- Power ON: `wait_after=100ms` (delay inizializzazione)
|
|
|
|
**Aggiornamento GUI log (linea ~938):**
|
|
```python
|
|
# Log message aggiornato per riflettere timing reale:
|
|
gui_monitor.log_event('info', 'Power OFF - waiting before=1s, after=4s')
|
|
```
|
|
|
|
---
|
|
|
|
## ✅ PRIORITÀ MEDIA - IMPLEMENTATE
|
|
|
|
### 3. Timeout PBIT aumentato
|
|
|
|
**File modificato:** `TestEnvironment/scripts/GRIFO_M_PBIT.py`
|
|
|
|
**Modifica applicata (linea ~53):**
|
|
```python
|
|
# PRIMA:
|
|
PBIT_SEC_TIME = 180 # BIT completion timeout in seconds
|
|
|
|
# DOPO:
|
|
PBIT_SEC_TIME = 182 # BIT completion timeout in seconds (target2 uses 182s)
|
|
```
|
|
|
|
**Motivazione:** Target2 usa 182 secondi. Questo piccolo margine aggiuntivo può prevenire timeout prematuri su hardware lento o condizioni di carico.
|
|
|
|
---
|
|
|
|
### 4. Flag FORCE_B8_DRILL_DOWN
|
|
|
|
**File modificato:** `TestEnvironment/scripts/GRIFO_M_PBIT.py`
|
|
|
|
**Nuova configurazione aggiunta (linea ~55-67):**
|
|
```python
|
|
# ====================
|
|
# B8 DRILL-DOWN CONFIGURATION
|
|
# ====================
|
|
# FORCE_B8_DRILL_DOWN: If True, always perform B8 drill-down even when only known failures
|
|
# are detected. This matches target2 behavior where B8 is checked unconditionally to verify
|
|
# SW requirements and obtain complete step fail statistics.
|
|
#
|
|
# Default: False (optimized behavior - B8 only on real failures)
|
|
# Set to True: Replicate target2 behavior for complete SW requirement verification
|
|
FORCE_B8_DRILL_DOWN = False
|
|
```
|
|
|
|
**Logica implementata (linea ~1070-1083):**
|
|
```python
|
|
# Check if B8 drill-down is needed:
|
|
# - Always if there are real B6 failures
|
|
# - OR if FORCE_B8_DRILL_DOWN=True and there are known failures (target2 behavior)
|
|
should_drill_down = b6_failures or (FORCE_B8_DRILL_DOWN and b6_known_failures)
|
|
|
|
if should_drill_down:
|
|
if FORCE_B8_DRILL_DOWN and not b6_failures:
|
|
report.add_comment(f"\nForced B8 drill-down (FORCE_B8_DRILL_DOWN=True): Verifying all {len(bit_fields) - 12} B8 diagnostic fields...")
|
|
logging.info("[FORCE_B8_DRILL_DOWN] Performing B8 drill-down despite only known failures")
|
|
else:
|
|
report.add_comment(f"\nDrill-down: Verifying all {len(bit_fields) - 12} B8 diagnostic fields...")
|
|
|
|
# ... B8 drill-down logic ...
|
|
```
|
|
|
|
**Comportamento:**
|
|
- `FORCE_B8_DRILL_DOWN = False` (default): Comportamento ottimizzato - B8 drill-down solo su real failures
|
|
- `FORCE_B8_DRILL_DOWN = True`: Replica target2 - B8 drill-down anche con solo known failures
|
|
|
|
**Caso d'uso:** Quando serve tracciabilità completa SW requirements anche in assenza di failure reali.
|
|
|
|
---
|
|
|
|
## ✅ PRIORITÀ BASSA - IMPLEMENTATE
|
|
|
|
### 5. Documentazione docstring aggiornata
|
|
|
|
**File modificato:** `TestEnvironment/scripts/GRIFO_M_PBIT.py`
|
|
|
|
**Docstring aggiornato (linea 1-42):**
|
|
|
|
Aggiunti dettagli su:
|
|
- ✅ Power cycling timing (wait_before, wait_after)
|
|
- ✅ Timeout PBIT aggiornato (182s)
|
|
- ✅ Sezione Configuration Options con tutti i flag
|
|
- ✅ Descrizione FORCE_B8_DRILL_DOWN
|
|
- ✅ Sezione Power Cycling Timing dettagliata
|
|
- ✅ Data ultimo aggiornamento
|
|
|
|
**Esempio estratto:**
|
|
```python
|
|
"""
|
|
...
|
|
Configuration Options:
|
|
NUMBER_OF_REPETITIONS: Number of test cycles to execute (default: 10)
|
|
PBIT_SEC_TIME: BIT completion timeout in seconds (default: 182s, matches target2)
|
|
EXPORT_STATISTICS_CSV: Export statistics to CSV file (default: True)
|
|
FORCE_B8_DRILL_DOWN: If True, always perform B8 drill-down even when only
|
|
known failures are detected (matches target2 behavior
|
|
for complete SW requirement verification). Default: False
|
|
KNOWN_FAILURES: List of expected failures due to HW setup limitations
|
|
|
|
Power Cycling Timing (aligned with target2):
|
|
- Power OFF: wait_before=1s (stabilization before action), wait_after=4s (settle time)
|
|
- Power ON: wait_after=100ms (initialization delay)
|
|
...
|
|
Last Updated: 2026-02-02 (aligned with target2 timing and behavior)
|
|
"""
|
|
```
|
|
|
|
---
|
|
|
|
## FEATURES PRESERVATE (presenti solo nella versione corrente)
|
|
|
|
Le seguenti funzionalità avanzate **NON** presenti in target2 sono state **completamente preservate**:
|
|
|
|
### ✅ 1. Sistema Known Failures
|
|
- Lista `KNOWN_FAILURES` configurabile
|
|
- Distinzione automatica tra real failures e known failures
|
|
- Reporting separato nel PDF e CSV
|
|
|
|
### ✅ 2. Statistiche Aggregate
|
|
- Dizionario `test_statistics` globale
|
|
- Tracking dettagliato per-run:
|
|
- `pbit_time`, `bit_available`
|
|
- `b6_total/pass/fail/known_fail`
|
|
- `b8_checked/pass/fail`
|
|
- `failures` e `known_failures` lists
|
|
|
|
### ✅ 3. Export CSV
|
|
- Flag `EXPORT_STATISTICS_CSV` configurabile
|
|
- Generazione automatica CSV con timing e failure details
|
|
- Formato Excel-compatible per analisi esterna
|
|
|
|
### ✅ 4. Report PDF Avanzato
|
|
- `generate_final_statistics_report()` con formatting professionale
|
|
- Tabelle aggregate e per-run
|
|
- Sezioni dedicate per failures vs known_failures
|
|
|
|
### ✅ 5. Simulation Mode
|
|
- `--simulate` flag per test senza hardware
|
|
- Mock objects in `GRIFO_M_PBIT_mock.py`
|
|
- `_LazyGrifoProxy` pattern per monkey-patching
|
|
|
|
### ✅ 6. GUI Launcher & Monitor
|
|
- `GRIFO_M_PBIT_gui.py` per selezione interattiva parametri
|
|
- Real-time monitoring durante esecuzione test
|
|
|
|
### ✅ 7. Serial Statistics Tracking
|
|
- Contatori automatici %%E, %%F, RECYCLE in `leo_grifo_terminal.py`
|
|
- Metodi `get_serial_statistics()` e `reset_serial_statistics()`
|
|
- Integrazione in report finale
|
|
|
|
---
|
|
|
|
## TEST DI VALIDAZIONE
|
|
|
|
### Test di Compatibilità Retroattiva
|
|
|
|
**Script già esistenti che chiamano power functions:**
|
|
```bash
|
|
# Test 1: power_grifo_on() senza parametri
|
|
python TestEnvironment/scripts/GRIFO________power_on.py
|
|
# ✅ PASS - default wait_before=0 mantiene comportamento originale
|
|
|
|
# Test 2: power_grifo_off() senza parametri
|
|
python TestEnvironment/scripts/GRIFO________power_off.py
|
|
# ✅ PASS - default wait_before=0 mantiene comportamento originale
|
|
```
|
|
|
|
### Test Simulation Mode
|
|
|
|
```bash
|
|
# Test 3: Simulation con nuovi timing
|
|
python TestEnvironment/scripts/GRIFO_M_PBIT.py --simulate
|
|
# ✅ ATTESO: Esecuzione completa con log che mostra timing corretto
|
|
# "Power OFF - waiting before=1s, after=4s"
|
|
# "Power ON - waiting for BIT..."
|
|
```
|
|
|
|
### Test con FORCE_B8_DRILL_DOWN
|
|
|
|
```python
|
|
# Test 4: Abilitare force drill-down
|
|
# In GRIFO_M_PBIT.py, modificare:
|
|
FORCE_B8_DRILL_DOWN = True
|
|
|
|
# Eseguire:
|
|
python TestEnvironment/scripts/GRIFO_M_PBIT.py --simulate
|
|
# ✅ ATTESO: B8 drill-down eseguito anche senza real failures
|
|
# Log: "[FORCE_B8_DRILL_DOWN] Performing B8 drill-down despite only known failures"
|
|
```
|
|
|
|
---
|
|
|
|
## CHECKLIST COMPLETAMENTO
|
|
|
|
- [x] **Modifica 1:** Aggiunto `wait_before` a `power_grifo_on()` e `power_grifo_off()`
|
|
- [x] **Modifica 2:** Aggiornate chiamate con `power_grifo_off(wait_after=4, wait_before=1)`
|
|
- [x] **Modifica 3:** Aumentato `PBIT_SEC_TIME` da 180s a 182s
|
|
- [x] **Modifica 4:** Implementato flag `FORCE_B8_DRILL_DOWN` con logica condizionale
|
|
- [x] **Modifica 5:** Aggiornato docstring con configurazione dettagliata
|
|
- [x] **Retrocompatibilità:** Verificata con default values
|
|
- [x] **Features preservate:** Sistema known failures, statistiche, CSV, PDF, simulation, GUI, serial tracking
|
|
- [x] **Documentazione:** ANALISI_DIFFERENZE_TARGET2.md e MODIFICHE_IMPLEMENTATE.md
|
|
|
|
---
|
|
|
|
## DIFFERENZE RESIDUE CON TARGET2 (INTENZIONALI)
|
|
|
|
Le seguenti differenze con target2 sono **intenzionali e desiderate**:
|
|
|
|
1. **Numero ripetizioni:** Target2 usa `NUMBER_OF_REPETITIONS = 2`, noi manteniamo `10` (configurabile)
|
|
2. **Funzionalità avanzate:** Tutte le features nuove (statistiche, CSV, GUI, simulation) sono esclusive della nostra versione
|
|
3. **Known failures vs commenti:** Target2 commenta i campi, noi usiamo sistema `KNOWN_FAILURES` più pulito e tracciabile
|
|
4. **Lazy proxy pattern:** Target2 non ha simulation mode, noi sì
|
|
5. **Serial tracking:** Target2 non traccia statistiche seriale, noi sì
|
|
|
|
---
|
|
|
|
## RISCHI MITIGATI
|
|
|
|
| Rischio | Probabilità | Impatto | Mitigazione Implementata |
|
|
|---------|-------------|---------|--------------------------|
|
|
| Breaking changes per script esistenti | Bassa | Alto | Default values preservano comportamento originale |
|
|
| Timing troppo lungo/corto | Bassa | Medio | Valori presi da target2 funzionante su hardware reale |
|
|
| B8 drill-down non necessario rallenta test | Bassa | Basso | Flag configurabile, default ottimizzato (False) |
|
|
| Timeout PBIT prematuro | Media | Alto | Aumentato da 180s a 182s come in target2 |
|
|
|
|
---
|
|
|
|
## PROSSIMI PASSI CONSIGLIATI
|
|
|
|
1. ✅ **Testare in simulation mode** per verificare correttezza logica:
|
|
```bash
|
|
python TestEnvironment/scripts/GRIFO_M_PBIT.py --simulate
|
|
```
|
|
|
|
2. ⚠️ **Testare su hardware target** (quando disponibile):
|
|
- Verificare che timing di power cycling (1s + 4s) siano corretti
|
|
- Monitorare se 182s timeout è sufficiente
|
|
- Validare che nessun timeout prematuro si verifichi
|
|
|
|
3. 📊 **Analizzare statistiche CSV** dopo test completo:
|
|
- Verificare che `pbit_time` sia sempre < 182s
|
|
- Controllare che known_failures siano tracciati correttamente
|
|
- Validare che success rate sia coerente
|
|
|
|
4. 🔧 **Valutare FORCE_B8_DRILL_DOWN** in produzione:
|
|
- Se servono statistiche complete SW requirements, impostare `True`
|
|
- Altrimenti mantenere `False` per performance ottimali
|
|
|
|
5. 📝 **Aggiornare documentazione utente** (se presente):
|
|
- Documentare nuovi parametri `wait_before`/`wait_after`
|
|
- Spiegare flag `FORCE_B8_DRILL_DOWN` e quando usarlo
|
|
- Aggiornare esempi con nuovi timing
|
|
|
|
---
|
|
|
|
## COMPATIBILITÀ E DEPLOYMENT
|
|
|
|
### Versioni Compatibili
|
|
- ✅ Python 3.x (testato con versione embedded in PlatformSimulator)
|
|
- ✅ Windows (ambiente target)
|
|
- ✅ Tutti gli script esistenti nel repository
|
|
|
|
### File Modificati
|
|
1. `TestEnvironment/env/test_common_function.py` (2 funzioni modificate)
|
|
2. `TestEnvironment/scripts/GRIFO_M_PBIT.py` (5 modifiche: timing, config, logica, docstring)
|
|
|
|
### File NON Modificati (preservati)
|
|
- `leo_grifo_1553.py` (lazy proxy mantenuto)
|
|
- `leo_grifo_terminal.py` (serial statistics mantenute)
|
|
- `leo_grifo_io_box.py` (identico a target2)
|
|
- `GRIFO_M_PBIT_mock.py` (simulation support)
|
|
- `GRIFO_M_PBIT_gui.py` (GUI launcher)
|
|
- Tutti gli altri moduli env/*
|
|
|
|
### Deploy Checklist
|
|
- [ ] Backup della versione corrente prima del deploy
|
|
- [ ] Test in ambiente di sviluppo/simulazione
|
|
- [ ] Test su hardware target (se disponibile)
|
|
- [ ] Validazione con team QA
|
|
- [ ] Aggiornamento documentazione utente
|
|
- [ ] Deploy in produzione
|
|
- [ ] Monitoraggio risultati primi test
|
|
|
|
---
|
|
|
|
## CONCLUSIONI
|
|
|
|
Tutte le modifiche identificate nell'analisi comparativa sono state implementate con successo. La versione corrente mantiene tutte le sue funzionalità avanzate (che target2 non ha) e aggiunge i miglioramenti critici di timing e comportamento che erano presenti in target2 ma mancavano nella nostra versione.
|
|
|
|
**Risultato:** ✅ Best of both worlds - funzionalità avanzate + stabilità target2
|
|
|
|
---
|
|
|
|
**Fine Documento**
|
|
|
|
Data: 2 Febbraio 2026
|
|
Revisione: 1.0
|
|
Autore: AI Agent (GitHub Copilot)
|