3.0 KiB
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:
- Only shows real protocol mappings from the configuration manager
- Generates realistic industrial values based on protocol type and data type
- Returns empty signals list when no protocol mappings are configured (no confusing fallbacks)
- 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
-
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
-
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
-
Realistic Signal Names:
- Format:
{station_id}_{equipment_id}_{data_type_id} - Example:
Main_Station_Booster_Pump_FlowRate
- Format:
-
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 endpointtest_real_data_simulation.py- Demonstrates real data generation
Next Steps
To fully utilize this feature:
- Configure actual protocol mappings through the UI
- Set up real protocol servers (OPC UA, Modbus)
- Connect to actual industrial equipment
- 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.