82 lines
2.6 KiB
Markdown
82 lines
2.6 KiB
Markdown
# Addon
|
|
|
|
**Path**: [`src/modbus/Addon.h`](../src/modbus/Addon.h)
|
|
|
|
**Revision History**: Initial documentation
|
|
|
|
Addon is a base class that extends the Component class, providing a foundation for creating modular extensions within the modbus system. It serves as a backward compatibility layer while ensuring consistent behavior across different types of add-ons.
|
|
|
|
## REQUIREMENTS
|
|
|
|
- ESP-32 microcontroller
|
|
- Platform.io development environment
|
|
|
|
## PROVIDES
|
|
|
|
- `Addon` class: Base class for creating modular components
|
|
- `Addons` type: A Vector container for storing Addon pointers
|
|
- `AddonFnPtr` type: Function pointer type for addon methods
|
|
- `byId()` utility function: Find an addon by its ID in a collection
|
|
|
|
## FEATURES
|
|
|
|
- Inheritance from Component class for consistent behavior
|
|
- Default run flags for standard execution modes
|
|
- Support for identifying addons through unique IDs
|
|
- Vector-based storage and retrieval of addons
|
|
|
|
## DEPENDENCIES
|
|
|
|
- [Component.h](../src/modbus/Component.h)
|
|
- [enums.h](../src/modbus/enums.h)
|
|
- [error_codes.h](../src/modbus/error_codes.h)
|
|
- [macros.h](../src/modbus/macros.h)
|
|
- [WString.h](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/WString.h)
|
|
- [Vector.h](https://github.com/janelia-arduino/Vector)
|
|
- [Arduino.h](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/Arduino.h)
|
|
|
|
```mermaid
|
|
graph TD
|
|
Addon --> Component
|
|
Addon --> enums
|
|
Addon --> error_codes
|
|
Addon --> macros
|
|
Addon --> WString
|
|
Addon --> Vector
|
|
```
|
|
|
|
## BEHAVIOUR
|
|
|
|
The Addon class extends Component, inheriting its lifecycle methods and adding specific functionality for modular components.
|
|
|
|
```mermaid
|
|
graph TD
|
|
Start[Initialize Addon] --> Construct[Constructor sets name, id, flags]
|
|
Construct --> Setup[Setup phase]
|
|
Setup --> Loop[Loop function execution]
|
|
Loop --> Info[Info reporting]
|
|
Info --> Loop
|
|
```
|
|
|
|
## TODOS
|
|
|
|
### PERFORMANCE
|
|
|
|
- Consider optimizing the `byId()` function for large collections using more efficient data structures or search algorithms
|
|
- Evaluate memory usage when multiple addons are instantiated
|
|
|
|
### SECURITY
|
|
|
|
- Add validation for addon IDs to prevent duplication
|
|
- Consider implementing access control mechanisms for sensitive addons
|
|
|
|
### COMPLIANCE
|
|
|
|
- Ensure compatibility with industrial Modbus-485 specifications
|
|
- Maintain backward compatibility with existing addon implementations
|
|
|
|
### RECOMMENDATIONS
|
|
|
|
- Use meaningful, unique IDs for each addon to simplify management
|
|
- Consider implementing a registration system to avoid manual management of addon collections
|
|
- Document specific addon implementations with clear usage examples |