Skip to content

ESP32 Modbus - PlotBase Class

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.

  • ESP32 microcontroller
  • ArduinoJson library
  • Component class framework
  • Configuration support
  • PlotStatus: An enumeration defining possible states of a plot:

    • IDLE: Not started or stopped before completion
    • RUNNING: Actively running
    • PAUSED: Started, but currently paused
    • STOPPED: Explicitly stopped by user/logic
    • FINISHED: 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
  • 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

PlotBase

Component

ArduinoJson

Arduino

config

start()

pause()

stop()

elapsedMs >= durationMs

resume()

stop()

start()

start()

IDLE

RUNNING

PAUSED

STOPPED

FINISHED

  • Consider introducing event callbacks for state changes
  • Optimize time calculations for resource-constrained environments
  • Evaluate memory usage for larger plot configurations
  • Validate JSON input more thoroughly to prevent potential buffer overflows
  • Consider adding authentication for plot control in networked contexts
  • Ensure time-based operations comply with real-time requirements if used in critical systems
  • Add option for deterministic timing for regulatory applications
  • 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