ESP32 Modbus - PlotBase Class
PlotBase
Section titled “PlotBase”Path: src/modbus/PlotBase.h
Revision History: Initial documentation
The PlotBase class serves as a base class for representing time-based signal plots. It inherits from the Component class and handles common timeline aspects like duration, running state, and JSON configuration loading. The class provides functionality for controlling the timeline of a plot with start, stop, pause, resume, and seek operations.
REQUIREMENTS
Section titled “REQUIREMENTS”- ESP32 microcontroller
- ArduinoJson library
- Component class framework
- Configuration support
PROVIDES
Section titled “PROVIDES”-
PlotStatus: An enumeration defining possible states of a plot:
IDLE
: Not started or stopped before completionRUNNING
: Actively runningPAUSED
: Started, but currently pausedSTOPPED
: Explicitly stopped by user/logicFINISHED
: Reached or exceeded duration
-
PlotBase: Base class for implementing time-based signal plots with methods for:
- Timeline control (start, stop, pause, resume, seek)
- Status reporting
- Duration and elapsed time tracking
- JSON configuration loading
FEATURES
Section titled “FEATURES”- Time-based signal plotting foundation
- Timeline control with pause and resume capabilities
- Proper handling of millis() rollover
- JSON configuration support
- User data storage capability
- Extensible base for various plot types
- Status reporting via enumerated type
- Current control point information retrieval
DEPENDENCIES
Section titled “DEPENDENCIES”BEHAVIOUR
Section titled “BEHAVIOUR”PERFORMANCE
Section titled “PERFORMANCE”- Consider introducing event callbacks for state changes
- Optimize time calculations for resource-constrained environments
- Evaluate memory usage for larger plot configurations
SECURITY
Section titled “SECURITY”- Validate JSON input more thoroughly to prevent potential buffer overflows
- Consider adding authentication for plot control in networked contexts
COMPLIANCE
Section titled “COMPLIANCE”- Ensure time-based operations comply with real-time requirements if used in critical systems
- Add option for deterministic timing for regulatory applications
RECOMMENDATIONS
Section titled “RECOMMENDATIONS”- Create plot types for common industrial signal patterns (steps, ramps, sawtooth, etc.)
- Implement a plot manager class for coordinating multiple related plots
- Add serialization support to save/restore plot state