![]() |
EduArt Sensor Ring Library 3.0.0
|
Factory for creating a SensorRing. More...
#include <SensorRingFactory.hpp>
Public Types | |
| using | DeviceParamsVariant = std::variant<device::VL53L8CX_Params, device::HTPA32_Params, device::WS2812b_Params> |
| Currently supported devices for explicit configuration in expectBoard(). | |
| using | EnumerationMap = std::unordered_map<com::ComInterfaceID, std::vector<device::EnumerationInformation> > |
| Per-interface enumeration results, keyed by interface ID. | |
Public Member Functions | |
| void | addInterface (com::ComInterfaceID interface) |
| Add a communication interface (bus) to scan during build(). | |
| void | expectBoard (device::SensorBoardParams params) |
| Declare an expected board on the current interface. | |
| void | expectBoard (device::SensorBoardParams params, std::vector< DeviceParamsVariant > device_params) |
| Declare an expected board together with explicit per-device params. | |
| void | setDefaultDeviceParams (DeviceParamsVariant params) |
| Set default params applied to every device of the given type that has no explicit params from expectBoard(). | |
| std::unique_ptr< SensorRing > | build (ValidationMode mode=ValidationMode::Strict) |
| Enumerate hardware on all added interfaces, validate against expectations, and construct the SensorRing. | |
| EnumerationMap | enumerate () |
| Enumerate hardware on all added interfaces without building a SensorRing. | |
| const EnumerationMap & | getLatestEnumerationResult () const |
| Return the enumeration results from the last enumerate() or build() call. | |
| std::string | printTopology () const |
| Format the latest enumeration results as a human-readable topology string. | |
| void | reset () |
| Reset the factory to its initial state. Enumeration results are preserved. | |
Static Public Attributes | |
| static constexpr Version | MIN_FIRMWARE_VERSION = { 0, 8, 0 } |
| Minimum sensor board firmware version required by this library version. | |
Factory for creating a SensorRing.
Usage:
If no expectBoard() calls are made for an interface, build() operates in pure auto-discovery mode: every board found on the bus is used with default (or setDefaultDeviceParams) configuration.
When expectations are present, the validation mode controls how mismatches are handled:
| void eduart::ring::SensorRingFactory::addInterface | ( | com::ComInterfaceID | interface | ) |
Add a communication interface (bus) to scan during build().
All subsequent expectBoard() calls apply to this interface until the next addInterface() call.
| std::unique_ptr< SensorRing > eduart::ring::SensorRingFactory::build | ( | ValidationMode | mode = ValidationMode::Strict | ) |
Enumerate hardware on all added interfaces, validate against expectations, and construct the SensorRing.
| [in] | mode | Validation mode (default: Strict). In Relaxed mode, mismatched boards are skipped instead of aborting. |
| EnumerationMap eduart::ring::SensorRingFactory::enumerate | ( | ) |
Enumerate hardware on all added interfaces without building a SensorRing.
Useful for interactive applications that want to discover connected boards before committing to a build. Results are stored and retrievable via getLatestEnumerationResult(). Also called internally by build().
| void eduart::ring::SensorRingFactory::expectBoard | ( | device::SensorBoardParams | params | ) |
Declare an expected board on the current interface.
Matched by index order against enumeration results. If params.board_type is not Undefined it is validated against the hardware-reported type. All devices reported by the hardware are instantiated; setDefaultDeviceParams() applies.
| void eduart::ring::SensorRingFactory::expectBoard | ( | device::SensorBoardParams | params, |
| std::vector< DeviceParamsVariant > | device_params ) |
Declare an expected board together with explicit per-device params.
Only the device types present in device_params are instantiated; the hardware must have at least those devices or build() fails. If params.board_type is not Undefined it is additionally validated.
| const EnumerationMap & eduart::ring::SensorRingFactory::getLatestEnumerationResult | ( | ) | const |
Return the enumeration results from the last enumerate() or build() call.
| std::string eduart::ring::SensorRingFactory::printTopology | ( | ) | const |
Format the latest enumeration results as a human-readable topology string.
| void eduart::ring::SensorRingFactory::setDefaultDeviceParams | ( | DeviceParamsVariant | params | ) |
Set default params applied to every device of the given type that has no explicit params from expectBoard().
May be called multiple times for different device types.