CalejoControl/demonstration_real_signals.md

3.0 KiB

Signal Overview - Real Data Integration

Summary

Successfully modified the Signal Overview to use real protocol mappings data instead of hardcoded mock data. The system now:

  1. Only shows real protocol mappings from the configuration manager
  2. Generates realistic industrial values based on protocol type and data type
  3. Returns empty signals list when no protocol mappings are configured (no confusing fallbacks)
  4. Provides accurate protocol statistics based on actual configured signals

Changes Made

Modified File: /workspace/CalejoControl/src/dashboard/api.py

Updated get_signals() function:

  • Now reads protocol mappings from configuration_manager.get_protocol_mappings()
  • Generates realistic values based on protocol type (Modbus TCP, OPC UA)
  • Creates signal names from actual station, equipment, and data type IDs
  • Removed all fallback mock data - returns empty signals list when no mappings exist
  • Removed _create_fallback_signals() function - no longer needed

Key Features of Real Data Integration

  1. No Mock Data Fallbacks:

    • Only real protocol data is displayed
    • Empty signals list when no mappings configured (no confusing mock data)
    • Clear indication that protocol mappings need to be configured
  2. Protocol-Specific Value Generation:

    • Modbus TCP: Industrial values like flow rates (m³/h), pressure (bar), power (kW)
    • OPC UA: Status values, temperatures, levels with appropriate units
  3. Realistic Signal Names:

    • Format: {station_id}_{equipment_id}_{data_type_id}
    • Example: Main_Station_Booster_Pump_FlowRate
  4. Dynamic Data Types:

    • Automatically determines data type (Float, Integer, String) based on value
    • Supports industrial units and status strings

Example Output

Real Protocol Data (When mappings exist):

{
  "name": "Main_Station_Booster_Pump_FlowRate",
  "protocol": "modbus_tcp", 
  "address": "30002",
  "data_type": "Float",
  "current_value": "266.5 m³/h",
  "quality": "Good",
  "timestamp": "2025-11-13 19:13:02"
}

No Protocol Mappings Configured:

{
  "signals": [],
  "protocol_stats": {},
  "total_signals": 0,
  "last_updated": "2025-11-13T19:28:59.828302"
}

Protocol Statistics

The system now calculates accurate protocol statistics based on the actual configured signals:

  • Active Signals: Count of signals per protocol
  • Total Signals: Total configured signals per protocol
  • Error Rate: Current error rate (0% for simulated data)

Testing

Created test scripts to verify functionality:

  • test_real_signals2.py - Tests the API endpoint
  • test_real_data_simulation.py - Demonstrates real data generation

Next Steps

To fully utilize this feature:

  1. Configure actual protocol mappings through the UI
  2. Set up real protocol servers (OPC UA, Modbus)
  3. Connect to actual industrial equipment
  4. Monitor real-time data from configured signals

The system is now ready to display real protocol data once protocol mappings are configured through the Configuration Manager.