feat: Implement configurable pump control preprocessing logic #5

Merged
solipsism merged 34 commits from feature/pump-control-preprocessing into master 2025-11-17 14:23:42 +00:00
Contributor

This PR implements three configurable pump control logics for converting MPC outputs to pump actuation signals.

Features:

  • MPC-Driven Adaptive Hysteresis (primary with live level data)
  • State-Preserving MPC (minimizes pump switching)
  • Backup Fixed-Band Control (fallback when sensors fail)

Integration:

  • Extended preprocessing system with new pump_control_logic rule type
  • Added PumpControlPreprocessorCalculator to setpoint manager
  • Configurable through dashboard protocol mappings

Benefits:

  • Improved pump longevity through state preservation
  • Better energy efficiency by minimizing switching
  • Enhanced safety with multiple protection layers
  • Flexible configuration per pump

See docs/PUMP_CONTROL_LOGIC_CONFIGURATION.md for detailed configuration options.

This PR implements three configurable pump control logics for converting MPC outputs to pump actuation signals. **Features:** - MPC-Driven Adaptive Hysteresis (primary with live level data) - State-Preserving MPC (minimizes pump switching) - Backup Fixed-Band Control (fallback when sensors fail) **Integration:** - Extended preprocessing system with new pump_control_logic rule type - Added PumpControlPreprocessorCalculator to setpoint manager - Configurable through dashboard protocol mappings **Benefits:** - Improved pump longevity through state preservation - Better energy efficiency by minimizing switching - Enhanced safety with multiple protection layers - Flexible configuration per pump See docs/PUMP_CONTROL_LOGIC_CONFIGURATION.md for detailed configuration options.
solipsism added 34 commits 2025-11-17 12:08:58 +00:00
1339b8bc55 Fix discovery service persistence issue
- Add discovery_results table to database schema
- Create persistent discovery service with database storage
- Update dashboard API to use persistent discovery service
- Initialize persistent discovery service on application startup
- Fix 404 errors when polling discovery scan results
a41d638268 Fix discovery service persistence and API issues
- Add persistent discovery service auto-initialization in start_dashboard.py
- Fix 'is_scanning' field in discovery status API
- Fix scan results API to handle dictionary data correctly
- Fix database schema issues for discovery_results table
- Add debugging for service initialization

Resolves issues with discovery service not persisting across restarts
and API endpoints returning incorrect data formats.
c741ac8553 Fix discovery count doubling and apply results errors
- Fix total_discovered_endpoints count to use DISTINCT device_id instead of counting all endpoints
- Fix apply_discovery_results endpoint to handle dictionary data correctly
- Replace object attribute access with dict.get() methods for scan results

Resolves issues where discovery count doubled with each scan and
apply results failed with '[object Object]' errors.
5a2cdc2324 Complete legacy system removal and tag metadata integration
- Remove legacy configuration classes: PumpStationConfig, PumpConfig, SafetyLimitsConfig
- Update ProtocolMapping model with tag metadata validators
- Replace text inputs with dropdowns in UI templates
- Add tag metadata loading functions to JavaScript
- Remove legacy API endpoints and add tag metadata endpoints
- Update security permissions to remove configure_safety_limits
- Clean up configuration manager and hardware discovery
- All integration tests pass successfully

Co-authored-by: openhands <openhands@all-hands.dev>
86e92f6111 Improve protocol mappings UI with human-readable names
- Update displayProtocolMappings to show station/equipment/data type names from tag metadata
- Ensure tag metadata is loaded before displaying protocol mappings
- Update table headers to indicate Name & ID format
- Users now see descriptive names instead of raw IDs in the mappings table

Co-authored-by: openhands <openhands@all-hands.dev>
de26bfe9d0 Update summary with UI improvements for human-readable names
Co-authored-by: openhands <openhands@all-hands.dev>
afeac4bf84 Add sample metadata initialization for demonstration
- Create metadata initializer to load sample data on application startup
- Add sample metadata file with realistic water system configuration
- Update main application to initialize metadata during startup
- Sample includes 2 stations, 4 equipment, 4 data types with descriptive tags
- Provides realistic data for protocol mappings UI testing

Co-authored-by: openhands <openhands@all-hands.dev>
b6dda1b10d Update summary with sample metadata information
Co-authored-by: openhands <openhands@all-hands.dev>
305a9d2a96 Improve sample metadata consistency and coverage
- Add Control Station to demonstrate more location types
- Add Control Valve and PLC Controller to use more equipment types
- Add Valve Position and Emergency Stop data types
- Better coverage of core tag categories
- More realistic industrial automation scenario
- Maintains same custom tags but with better categorization

Co-authored-by: openhands <openhands@all-hands.dev>
87cc40a802 Fix protocol discovery form prefilling issues
- Update field IDs to match actual form (station_id, equipment_id, data_type_id)
- Add validation methods to check if metadata IDs exist
- Use actual sample metadata IDs instead of hardcoded defaults
- Fix station/equipment/data type dropdown population
- Update Apply All functionality to use real metadata
- Ensure discovery results properly prefill protocol mapping form

Co-authored-by: openhands <openhands@all-hands.dev>
04404674ee Fix protocol discovery modal integration and timing issues
- Add robust modal opening with multiple fallback methods
- Implement proper timing waits for modal and dropdown loading
- Add comprehensive logging for debugging
- Fix field population sequence and validation
- Add waitForStationsLoaded method to handle async dropdown loading
- Ensure all form fields are properly populated including mapping_id
- Set default database source based on device name

Co-authored-by: openhands <openhands@all-hands.dev>
f0d6aca5ed Complete migration to simplified protocol signals architecture
- Replace complex ID system with intuitive signal name + tags approach
- Update main dashboard protocol mapping interface to use simplified system
- Add comprehensive API endpoints for protocol signals management
- Create simplified configuration manager and data models
- Implement discovery integration with auto-population of signal forms
- Add migration scripts and comprehensive test suite
- Update JavaScript files to use simplified system
- Create modern UI with filtering, tag cloud, and responsive design

Key improvements:
- Human-readable signal names instead of complex IDs
- Flexible tag-based categorization and filtering
- Seamless discovery to signal conversion
- Cleaner architecture with reduced complexity
- Better user experience and maintainability
a639e3159a Fix discovery to protocol mapping integration
- Fix global function references between discovery.js and protocol_mapping.js
- Add 'Apply All as Protocol Signals' functionality to discovery results
- Implement bulk signal creation from discovery results
- Add proper CSS styling for discovery results and notifications
- Expose key functions to global scope for cross-script communication
- Improve modal auto-population with better timing and error handling

Now discovery results properly:
- Populate the signal form when clicking 'Use This Signal'
- Create all signals at once when clicking 'Apply All as Protocol Signals'
- Show clear notifications for success/failure
- Refresh the protocol signals display automatically
698c114609 Fix discovery scan button integration and add debugging
- Add event binding for discovery scan button
- Implement startDiscoveryScan method with proper UI updates
- Add comprehensive debug logging to track discovery flow
- Fix discovery results container detection
- Improve error handling and user feedback

Now the discovery workflow should work properly:
1. Click 'Start Discovery Scan' button
2. See progress status and results
3. Click 'Use This Signal' to populate form
4. Click 'Apply All as Protocol Signals' to create all
ece4952330 Fix discovery service integration and JavaScript execution issues
- Add simplified protocol signals table for discovery integration
- Add signal modal for discovery data population
- Fix JavaScript null element reference issues with fallback selectors
- Improve auto-populate function to work with both signal and mapping forms
- Add error handling for missing DOM elements
- Fix global function exposure for discovery integration
- Update template to include discovery-compatible UI elements
add4952e74 Fix JavaScript errors and auto-populate issues
- Fix loadProtocolMappings reference error in dashboard.js by calling loadAllSignals()
- Add debugging to populateModalFields to identify field availability issues
- Ensure protocol mapping tab is activated before auto-populating from discovery
- Add delay to ensure tab content is loaded before attempting auto-population
5596f6eaf1 Fix duplicate ID issue and modal field population
- Fix duplicate protocol_type ID by renaming mapping-modal field to mapping_protocol_type
- Update populateModalFields to search for fields within modal context instead of globally
- Add debugging to show which fields are found in the modal
- Ensure protocol type and address fields are properly populated from discovery data
70351940d6 Remove mock data fallbacks from Signal Overview
- Modified get_signals() API to only show real protocol mappings data
- Removed all fallback mock data that could confuse users
- Returns empty signals list when no protocol mappings configured
- Removed _create_fallback_signals() function
- Updated documentation to reflect no-fallback approach

This ensures users only see real protocol data and are not confused by mock signals.
15961f715c Fix Apply All protocol mappings and add duplicate detection
- Fix Apply All to properly create all 3 signals instead of just 1
- Add duplicate detection to prevent creating signals with same names
- Add Clear All Signals button for testing
- Update cache-busting versions for JavaScript files
495a52a583 Fix Signal Overview to include simplified protocol signals
- Update get_signals API to include signals from simplified protocol signals
- Maintain backward compatibility with old protocol mappings
- Generate realistic values based on signal names and protocol types
92227083ea feat: Implement configurable pump control preprocessing logic
- Add three configurable control logics for MPC output conversion:
  - MPC-Driven Adaptive Hysteresis (primary with live level data)
  - State-Preserving MPC (minimizes pump switching)
  - Backup Fixed-Band Control (fallback when sensors fail)

- Integrate with existing preprocessing system via protocol mappings
- Add new PumpControlPreprocessorCalculator to setpoint manager
- Include comprehensive documentation and configuration examples
- Add safety overrides and state tracking to prevent excessive cycling

This enables flexible pump control strategies that can be configured
per pump through the dashboard or database configuration.
solipsism merged commit b3970fe07e into master 2025-11-17 14:23:42 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: calejocontrol/CalejoControl#5
No description provided.