firmware-base/docs/ValueWrapper.md
2025-06-04 08:19:09 +02:00

36 lines
1.5 KiB
Markdown

---
title: "ValueWrapper - Threshold-based Value Change Notification"
description: "A template class that wraps values with threshold-based change notification logic, designed for efficient Modbus communication"
keywords: ["ESP32", "Modbus", "ValueWrapper", "Threshold", "Notification", "C++", "Template"]
---
## ValueWrapper
**Path**: [`src/ValueWrapper.h`](../../src/ValueWrapper.h)
**Revision History**: Initial documentation
ValueWrapper is a template class that wraps a value (of any type T) and provides threshold-based change notification. When the value changes beyond a specified threshold, it automatically generates Modbus notification messages, reducing network traffic by only sending significant changes.
## REQUIREMENTS
- C++17 compiler support
- No specific hardware pins required
## FEATURES
- Supports any data type, including primitives and enums
- Two threshold check modes:
- DIFFERENCE: Notifies when absolute difference exceeds threshold
- INTERVAL_STEP: Notifies when value crosses interval boundaries
- Automatic Modbus message generation when thresholds are crossed
- Callback support for additional logic on value changes
- Type-safe conversion operations
- Specialized handling for different data types (signed, unsigned, enum)
## DEPENDENCIES
- [Component](./Component.md): Base component functionality
- [ModbusTypes](./modbus/ModbusTypes.md): Modbus data structures
- [enums](./enums.md): System-wide enumeration definitions
- [Logger](./Logger.md): Logging facility