S7_snap7_Stremer_n_Recorder/.tests
Miguel a9e4e0d3ae Add comprehensive tests for PE/PA fixed implementation and optimized batch reading
- Introduced `test_optimized_reader.py` to validate the functionality and configuration of `OptimizedBatchReader`.
- Created `test_pe_pa_fixed.py` to test the corrected PE/PA reading functionality using appropriate Snap7 area codes.
- Developed `test_real_plc.py` to assess the performance of optimized batch reading against legacy methods with actual PLC configurations.
- Implemented `test_simple_validation.py` for a final validation of core functionalities, ensuring correct implementation of PE/PA area codes and batch reading.
2025-08-20 00:09:42 +02:00
..
README.md Add comprehensive tests for PE/PA fixed implementation and optimized batch reading 2025-08-20 00:09:42 +02:00
__init__.py Add comprehensive tests for PE/PA fixed implementation and optimized batch reading 2025-08-20 00:09:42 +02:00
test_comparison_simple.py Add comprehensive tests for PE/PA fixed implementation and optimized batch reading 2025-08-20 00:09:42 +02:00
test_data_integrity.py Add comprehensive tests for PE/PA fixed implementation and optimized batch reading 2025-08-20 00:09:42 +02:00
test_final_validation.py Add comprehensive tests for PE/PA fixed implementation and optimized batch reading 2025-08-20 00:09:42 +02:00
test_network_latency_pe_pa.py Add comprehensive tests for PE/PA fixed implementation and optimized batch reading 2025-08-20 00:09:42 +02:00
test_pe_pa_fixed.py Add comprehensive tests for PE/PA fixed implementation and optimized batch reading 2025-08-20 00:09:42 +02:00

README.md

Tests Directory

Este directorio contiene los tests funcionales y validaciones del sistema PLC S7-315 Streamer & Logger.

Tests Incluidos

🔧 test_pe_pa_fixed.py

  • Propósito: Validación funcional del fix PE/PA con área 0x81/0x82
  • Estado: Funcional - Test principal que validó la corrección
  • Uso: python test_pe_pa_fixed.py
  • Nota: Test fundamental para validar que PE/PA funcionan correctamente

📊 test_comparison_simple.py

  • Propósito: Comparación entre sistema legacy y optimizado
  • Estado: Funcional - Test de comparación de rendimiento
  • Uso: python test_comparison_simple.py
  • Nota: Demuestra que ambos sistemas logran 100% éxito en PE/PA

🌐 test_network_latency_pe_pa.py

  • Propósito: Demostración del impacto de latencia de red industrial
  • Estado: Funcional - Test crítico para entender optimización
  • Uso: python test_network_latency_pe_pa.py
  • Nota: Simula condiciones industriales reales (20ms latencia) y demuestra por qué los tests con PLC simulado no reflejan beneficios de optimización

🧪 test_final_validation.py

  • Propósito: Validación completa de todas las áreas de memoria
  • Estado: Funcional - Test comprehensivo del sistema
  • Uso: python test_final_validation.py
  • Nota: Test completo que valida DB, M, T, C, PE, PA

🔍 test_data_integrity.py

  • Propósito: Verificación de integridad de datos entre métodos de lectura
  • Estado: Funcional - Test de calidad de datos
  • Uso: python test_data_integrity.py
  • Nota: Compara individual vs batch reading para detectar corrupción de datos

Instrucciones de Uso

Pre-requisitos

# Activar entorno conda
conda activate plc_streamer

# Asegurar que snap7.dll está disponible
# Verificar conexión a PLC 10.1.33.11

Ejecución desde directorio raíz:

# Test individual
python .tests/test_pe_pa_fixed.py

# Test de comparación
python .tests/test_comparison_simple.py

# Test de latencia industrial
python .tests/test_network_latency_pe_pa.py

# Validación completa
python .tests/test_final_validation.py

# Test de integridad
python .tests/test_data_integrity.py

Tests Eliminados (Obsoletos)

Los siguientes tests fueron eliminados por ser obsoletos o redundantes:

  • test_legacy_vs_optimized.py - Problemas de import, reemplazado por test_comparison_simple.py
  • test_industrial_network.py - Fallaba con variables DB, reemplazado por test_network_latency_pe_pa.py
  • test_simple_validation.py - Básico y redundante
  • test_real_plc.py - Básico y redundante
  • test_large_dataset.py - Específico de volumen, obsoleto
  • test_io_comprehensive.py - Redundante con final_validation

Notas Importantes

🎯 Lección Clave sobre Tests de Latencia

Los tests con PLC simulado (latencia ~0ms) NO reflejan las condiciones reales industriales donde la optimización read_multi_vars es efectiva.

Condiciones reales industriales:

  • Latencia: 10-30ms por request
  • Jitter de red: ±5-10ms
  • Overhead de protocolo significativo

Uso recomendado:

  • test_network_latency_pe_pa.py simula estas condiciones y demuestra que la optimización sería 33% más rápida en producción real con variables DB.

🔧 PE/PA vs DB Optimization

  • PE/PA: Limitadas a individual reads (protocolo snap7)
  • DB: Pueden usar read_multi_vars optimization
  • Recomendación: Usar variables DB cuando sea posible para máximo rendimiento en redes industriales