285 lines
6.9 KiB
Markdown
285 lines
6.9 KiB
Markdown
# GRIFO_M_PBIT - Simulation Mode
|
|
|
|
## Quick Start
|
|
|
|
### Run Test with Hardware (Production Mode)
|
|
```bash
|
|
cd __OLD\__TEST_GENOVA\GrifoAutomaticTestEnv\TestEnvironment\scripts
|
|
python GRIFO_M_PBIT.py
|
|
```
|
|
|
|
### Run Test without Hardware (Simulation Mode)
|
|
```bash
|
|
cd __OLD\__TEST_GENOVA\GrifoAutomaticTestEnv\TestEnvironment\scripts
|
|
python GRIFO_M_PBIT.py --simulate
|
|
```
|
|
|
|
---
|
|
|
|
## What's New
|
|
|
|
✅ **Simulation mode** - Run tests without hardware
|
|
✅ **Zero production code changes** - All changes are opt-in
|
|
✅ **Serial statistics** integrated in final report
|
|
✅ **Complete documentation** of test environment
|
|
|
|
---
|
|
|
|
## Simulation Mode Features
|
|
|
|
### What Gets Mocked
|
|
|
|
- **1553 Bus Interface** - Simulates message reception (B6, B8, B9)
|
|
- **Serial Terminal** - Simulates %%E, %%F, RECYCLE messages
|
|
- **Power Control** - Logs power state changes (no actual hardware control)
|
|
|
|
### Simulation Configuration
|
|
|
|
Edit `GRIFO_M_PBIT_mock.py` to customize:
|
|
|
|
```python
|
|
# BIT completion timing
|
|
PBIT_TIME_MIN = 15.0
|
|
PBIT_TIME_MAX = 25.0
|
|
|
|
# Test scenario
|
|
SIMULATION_SCENARIO = 'normal' # Options: 'normal', 'pedestal_fail', 'random_failures'
|
|
|
|
# Serial message generation
|
|
SIMULATE_SERIAL_ERRORS = True # Generate %%E messages
|
|
SIMULATE_SERIAL_FATAL = False # Generate %%F messages
|
|
SIMULATE_RECYCLE_EVENTS = True # Generate RECYCLE at power-on
|
|
```
|
|
|
|
### Available Scenarios
|
|
|
|
1. **`normal`** - All tests pass (only known failures like pedestal)
|
|
2. **`pedestal_fail`** - Pedestal unit failure (expected HW limitation)
|
|
3. **`random_failures`** - Random B6 failures to test B8 drill-down
|
|
|
|
---
|
|
|
|
## Report Enhancements
|
|
|
|
### Serial Statistics Now Included
|
|
|
|
The final statistics report now shows:
|
|
|
|
**Per-Run Table:**
|
|
```
|
|
Run | Status | PBIT | B6 Status | B8 Checked | Serial (E/F/R) | B8 Fail | Result
|
|
1 | PASS | 18.2s| 12/0/1 | 0 | 1/0/1 | - | ✓ PASS
|
|
2 | PASS | 19.5s| 12/0/1 | 0 | 2/0/1 | - | ✓ PASS
|
|
```
|
|
Legend: E=Errors (%%E), F=Fatal (%%F), R=Recycles
|
|
|
|
**Aggregate Statistics:**
|
|
- Total serial messages received
|
|
- Total %%E errors
|
|
- Total %%F fatal messages
|
|
- Total system recycles detected
|
|
|
|
**Dedicated Recycle Analysis (Section 5.1):**
|
|
- Expected vs unexpected recycles
|
|
- Per-run recycle events with timestamps
|
|
- Warning if unexpected resets detected
|
|
|
|
---
|
|
|
|
## File Changes Summary
|
|
|
|
### New Files
|
|
- `GRIFO_M_PBIT_mock.py` - Simulation mode implementation
|
|
- `GRIFO_Test_Environment_Analysis.md` - Complete technical documentation
|
|
|
|
### Modified Files
|
|
- `GRIFO_M_PBIT.py` - Added simulation mode support (12 lines added)
|
|
- Lines 654-664: Simulation mode detection
|
|
- Lines 734-740: Conditional terminal creation
|
|
|
|
### Unchanged
|
|
- All environment Python modules (`leo_grifo_*.py`)
|
|
- All dependencies and configurations
|
|
- Production test behavior when run normally
|
|
|
|
---
|
|
|
|
## Testing the Simulation
|
|
|
|
### First Test Run
|
|
```bash
|
|
python GRIFO_M_PBIT.py --simulate
|
|
```
|
|
|
|
**Expected Output:**
|
|
```
|
|
================================================================================
|
|
SIMULATION MODE ACTIVATED
|
|
================================================================================
|
|
Scenario: normal
|
|
BIT Time Range: 15.0-25.0s
|
|
Serial Errors: True
|
|
Serial Fatal: False
|
|
Recycle Events: True
|
|
================================================================================
|
|
[MOCK] Replaced leo_grifo_1553.theGrifo1553 with mock
|
|
[MOCK] Replaced leo_grifo_io_box.theBrainBox with mock
|
|
[MOCK] Simulation setup complete - test can now run without hardware
|
|
...
|
|
```
|
|
|
|
### Verify Results
|
|
|
|
1. Check log file: `__OLD/__TEST_GENOVA/GrifoAutomaticTestEnv/TestEnvironment/LOG/GRIFO_M_PBIT.log`
|
|
2. Check PDF report: `__OLD/__TEST_GENOVA/GrifoAutomaticTestEnv/TestEnvironment/pdf_reports/GRIFO_M_PBIT_*.pdf`
|
|
3. Look for simulation markers: `[MOCK]` prefix in logs
|
|
|
|
---
|
|
|
|
## Customizing Test Scenarios
|
|
|
|
### Example: Test B8 Drill-Down Logic
|
|
|
|
1. Edit `GRIFO_M_PBIT_mock.py`:
|
|
```python
|
|
SIMULATION_SCENARIO = 'random_failures'
|
|
```
|
|
|
|
2. Run test:
|
|
```bash
|
|
python GRIFO_M_PBIT.py --simulate
|
|
```
|
|
|
|
3. Report will show:
|
|
- Some runs with B6 failures
|
|
- B8 diagnostic drill-down performed
|
|
- Detailed failure analysis in final report
|
|
|
|
### Example: Test Recycle Detection
|
|
|
|
1. Edit `GRIFO_M_PBIT_mock.py`:
|
|
```python
|
|
SIMULATE_RECYCLE_EVENTS = True
|
|
SIMULATE_SERIAL_FATAL = True # Add extra recycle mid-run
|
|
```
|
|
|
|
2. Check Section 5.1 in final report for recycle analysis
|
|
|
|
---
|
|
|
|
## Troubleshooting
|
|
|
|
### Issue: Import Error for GRIFO_M_PBIT_mock
|
|
|
|
**Cause:** Mock module not in Python path
|
|
**Solution:** Ensure you run from `scripts/` directory
|
|
|
|
### Issue: Simulation Takes Too Long
|
|
|
|
**Cause:** BIT timing too high
|
|
**Solution:** Edit `GRIFO_M_PBIT_mock.py`:
|
|
```python
|
|
PBIT_TIME_MIN = 5.0 # Faster simulation
|
|
PBIT_TIME_MAX = 10.0
|
|
```
|
|
|
|
### Issue: Want to Test Specific Failures
|
|
|
|
**Solution:** Edit `_initialize_field_values()` in `MockGrifo1553Interface`:
|
|
```python
|
|
# Force specific failure
|
|
self._field_values["..._processor_status"] = "true" # Fail
|
|
```
|
|
|
|
---
|
|
|
|
## Documentation
|
|
|
|
### Complete Technical Analysis
|
|
See: `GRIFO_Test_Environment_Analysis.md`
|
|
|
|
Contains:
|
|
- Directory structure analysis
|
|
- Component architecture
|
|
- 1553 interface details
|
|
- Serial communication protocol
|
|
- Message field naming conventions
|
|
- Troubleshooting guide
|
|
|
|
### Original Test Script
|
|
- `GRIFO_M_PBIT.py` - Fully documented with docstrings
|
|
- All 185 diagnostic fields listed with categories
|
|
- Known failures configuration explained
|
|
|
|
---
|
|
|
|
## Performance
|
|
|
|
### Simulation Mode Timing
|
|
|
|
| Test Component | Real Hardware | Simulation |
|
|
|----------------|---------------|------------|
|
|
| BIT Completion | 15-30s | 15-25s (configurable) |
|
|
| Power Cycle | 5-10s | 0.1s |
|
|
| Per Run | 30-40s | 20-30s |
|
|
| **10 Runs Total** | **5-7 minutes** | **3-5 minutes** |
|
|
|
|
### Report Generation
|
|
|
|
Same speed for both modes:
|
|
- PDF generation: ~5-10s
|
|
- Statistics calculation: <1s
|
|
|
|
---
|
|
|
|
## Next Steps
|
|
|
|
### Recommended Actions
|
|
|
|
1. ✅ **Test simulation mode** with current configuration
|
|
2. ✅ **Review generated PDF report** to verify all sections present
|
|
3. ✅ **Experiment with scenarios** to understand test logic
|
|
4. ⏳ **Test with real hardware** when available to verify compatibility
|
|
5. ⏳ **Customize mock** for specific test cases as needed
|
|
|
|
### Future Enhancements
|
|
|
|
Consider adding:
|
|
- JSON configuration file for scenarios
|
|
- CSV export of all field values
|
|
- Integration with `pybusmonitor1553` as UDP message source
|
|
- Recorded message replay capability
|
|
|
|
---
|
|
|
|
## Support
|
|
|
|
### Questions?
|
|
|
|
1. Check `GRIFO_Test_Environment_Analysis.md` for detailed documentation
|
|
2. Review code comments in `GRIFO_M_PBIT_mock.py`
|
|
3. Enable debug logging for troubleshooting:
|
|
```python
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
```
|
|
|
|
### Reporting Issues
|
|
|
|
When reporting issues, include:
|
|
- Command used to run test
|
|
- Contents of log file (first 50 lines)
|
|
- Simulation configuration used
|
|
- Expected vs actual behavior
|
|
|
|
---
|
|
|
|
## License & Credits
|
|
|
|
- Original test framework: GRIFO test team (Genova)
|
|
- Simulation mode: Test Automation Team (2026-01-29)
|
|
- Documentation: Technical analysis and integration guide
|
|
|
|
---
|
|
|
|
**Happy Testing! 🚀**
|