EduArt Sensor Ring Library 4.0.0
Loading...
Searching...
No Matches
eduart::sensorring::SensorRingFactory Class Reference

Factory for creating a SensorRing. More...

#include <SensorRingFactory.hpp>

Collaboration diagram for eduart::sensorring::SensorRingFactory:
[legend]

Public Types

using EnumerationMap = std::unordered_map<com::ComInterfaceID, std::vector<board::EnumerationInformation> >
 Per-interface enumeration results, keyed by interface ID.

Public Member Functions

 SensorRingFactory (ValidationMode mode=ValidationMode::Relaxed)
 Construct the factory with a validation mode.
void addInterface (com::SocketCanParams params)
 Add a SocketCAN interface to scan during build().
void addInterface (com::UsbTingoParams params)
 Add a USBtingo interface to scan during build().
void expectBoard (board::SensorBoardParams params={})
 Declare an expected board on the current interface.
void expectDevice (device::DeviceType type)
 Declare an expected device type without overriding default parameters.
void expectDevice (device::VL53L8CX_Params params)
 Declare an expected device on the most recently added board.
void expectDevice (device::TMF8829_Params params)
 Declare an expected device on the most recently added board.
void expectDevice (device::HTPA32_Params params)
 Declare an expected device on the most recently added board.
void expectDevice (device::WS2812b_Params params)
 Declare an expected device on the most recently added board.
void expectDevice (device::DepthSensorParams params)
 Declare an expected device by category (matches any sensor of that category).
void expectDevice (device::ThermalSensorParams params)
 Declare an expected device by category (matches any sensor of that category).
void expectDevice (device::LightParams params)
 Declare an expected device by category (matches any sensor of that category).
void setDefaultDeviceParams (device::VL53L8CX_Params params)
 Set default params applied to a specific discovered device type that has no explicit params from expectDevice().
void setDefaultDeviceParams (device::TMF8829_Params params)
 Set default params applied to a specific discovered device type that has no explicit params from expectDevice().
void setDefaultDeviceParams (device::HTPA32_Params params)
 Set default params applied to a specific discovered device type that has no explicit params from expectDevice().
void setDefaultDeviceParams (device::WS2812b_Params params)
 Set default params applied to a specific discovered device type that has no explicit params from expectDevice().
void setDefaultDeviceParams (device::DepthSensorParams params)
 Set default params applied to an entire category of discovered devices.
void setDefaultDeviceParams (device::ThermalSensorParams params)
 Set default params applied to an entire category of discovered devices.
void setDefaultDeviceParams (device::LightParams params)
 Set default params applied to an entire category of discovered devices.
std::unique_ptr< SensorRing > build ()
 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, 9, 0 }
 Minimum sensor board firmware version required by this library version.

Detailed Description

Factory for creating a SensorRing.

Usage:

  1. Call addInterface() for every communication bus to use.
  2. Optionally call expectBoard() (once per expected board, in index order) to declare what hardware should be present and which device params to apply.
  3. Optionally call setDefaultDeviceParams() to set params applied to every device of that type that does not have explicit params from expectBoard().
  4. Call build() to enumerate hardware, validate against expectations, and construct the SensorRing.

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:

  • Strict: boards are matched by index; any mismatch fails the build.
  • Relaxed (default): for each expectation, the factory searches all unclaimed boards for the first one with a compatible board type and the required device types. Boards that are not claimed by any expectation remain unconfigured.

Constructor & Destructor Documentation

◆ SensorRingFactory()

eduart::sensorring::SensorRingFactory::SensorRingFactory ( ValidationMode mode = ValidationMode::Relaxed)
explicit

Construct the factory with a validation mode.

Parameters
[in]modeValidation mode (default: Relaxed). In Relaxed mode, mismatched boards are skipped instead of aborting.

Member Function Documentation

◆ addInterface() [1/2]

void eduart::sensorring::SensorRingFactory::addInterface ( com::SocketCanParams params)

Add a SocketCAN interface to scan during build().

All subsequent expectBoard() calls apply to this interface until the next addInterface() call.

Parameters
[in]paramsSocketCAN configuration parameters.

◆ addInterface() [2/2]

void eduart::sensorring::SensorRingFactory::addInterface ( com::UsbTingoParams params)

Add a USBtingo interface to scan during build().

All subsequent expectBoard() calls apply to this interface until the next addInterface() call.

Parameters
[in]paramsUSBtingo configuration parameters.

◆ build()

std::unique_ptr< SensorRing > eduart::sensorring::SensorRingFactory::build ( )

Enumerate hardware on all added interfaces, validate against expectations, and construct the SensorRing.

Uses the ValidationMode set in the constructor.

Returns
Unique pointer to the SensorRing, or nullptr on failure.

◆ enumerate()

EnumerationMap eduart::sensorring::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().

Returns
Per-interface enumeration results.

◆ expectBoard()

void eduart::sensorring::SensorRingFactory::expectBoard ( board::SensorBoardParams params = {})

Declare an expected board on the current interface.

Boards are matched against enumeration results using the configured ValidationMode. Use expectDevice() after this call to declare which devices should be instantiated on this board.

If no expectDevice() calls follow, all devices reported by the hardware are instantiated with default (or setDefaultDeviceParams()) configuration.

Parameters
[in]paramsBoard-level parameters (type, name, pose, etc.).

◆ expectDevice() [1/8]

void eduart::sensorring::SensorRingFactory::expectDevice ( device::DepthSensorParams params)

Declare an expected device by category (matches any sensor of that category).

Use these when you don't care which specific sensor is present, only that a device of the given category exists. Default params (or hardware defaults) will be applied to whatever concrete device is discovered.

Parameters
paramsConfiguration for a generic device of that category.

◆ expectDevice() [2/8]

void eduart::sensorring::SensorRingFactory::expectDevice ( device::DeviceType type)

Declare an expected device type without overriding default parameters.

Use this when you want to restrict which devices are instantiated on a board while still letting setDefaultDeviceParams() supply the effective configuration for the matched concrete device.

Supported values are concrete device types (e.g. VL53L8CX) and category wildcards (AnyDepth, AnyThermal, AnyLight).

Parameters
typeDevice type to expect on the most recently added board.

◆ expectDevice() [3/8]

void eduart::sensorring::SensorRingFactory::expectDevice ( device::HTPA32_Params params)

Declare an expected device on the most recently added board.

Only the device types declared via expectDevice() are instantiated for that board. The provided params override any defaults set via setDefaultDeviceParams().

Must be called after expectBoard(). Multiple expectDevice() calls accumulate devices for the same board.

Parameters
paramsConfiguration for a concrete device type.

◆ expectDevice() [4/8]

void eduart::sensorring::SensorRingFactory::expectDevice ( device::LightParams params)

Declare an expected device by category (matches any sensor of that category).

Use these when you don't care which specific sensor is present, only that a device of the given category exists. Default params (or hardware defaults) will be applied to whatever concrete device is discovered.

Parameters
paramsConfiguration for a generic device of that category.

◆ expectDevice() [5/8]

void eduart::sensorring::SensorRingFactory::expectDevice ( device::ThermalSensorParams params)

Declare an expected device by category (matches any sensor of that category).

Use these when you don't care which specific sensor is present, only that a device of the given category exists. Default params (or hardware defaults) will be applied to whatever concrete device is discovered.

Parameters
paramsConfiguration for a generic device of that category.

◆ expectDevice() [6/8]

void eduart::sensorring::SensorRingFactory::expectDevice ( device::TMF8829_Params params)

Declare an expected device on the most recently added board.

Only the device types declared via expectDevice() are instantiated for that board. The provided params override any defaults set via setDefaultDeviceParams().

Must be called after expectBoard(). Multiple expectDevice() calls accumulate devices for the same board.

Parameters
paramsConfiguration for a concrete device type.

◆ expectDevice() [7/8]

void eduart::sensorring::SensorRingFactory::expectDevice ( device::VL53L8CX_Params params)

Declare an expected device on the most recently added board.

Only the device types declared via expectDevice() are instantiated for that board. The provided params override any defaults set via setDefaultDeviceParams().

Must be called after expectBoard(). Multiple expectDevice() calls accumulate devices for the same board.

Parameters
paramsConfiguration for a concrete device type.

◆ expectDevice() [8/8]

void eduart::sensorring::SensorRingFactory::expectDevice ( device::WS2812b_Params params)

Declare an expected device on the most recently added board.

Only the device types declared via expectDevice() are instantiated for that board. The provided params override any defaults set via setDefaultDeviceParams().

Must be called after expectBoard(). Multiple expectDevice() calls accumulate devices for the same board.

Parameters
paramsConfiguration for a concrete device type.

◆ getLatestEnumerationResult()

const EnumerationMap & eduart::sensorring::SensorRingFactory::getLatestEnumerationResult ( ) const

Return the enumeration results from the last enumerate() or build() call.

Returns
Per-interface enumeration results. Empty if neither method has been called yet.

◆ printTopology()

std::string eduart::sensorring::SensorRingFactory::printTopology ( ) const

Format the latest enumeration results as a human-readable topology string.

Returns
Formatted topology string. Empty if no enumeration has been performed.

◆ setDefaultDeviceParams() [1/7]

void eduart::sensorring::SensorRingFactory::setDefaultDeviceParams ( device::DepthSensorParams params)

Set default params applied to an entire category of discovered devices.

Sets a Category default (Priority 2). Applied when a discovered device of this category has no concrete default explicitly set.

Concrete params always override category params. Category params always override hard-coded defaults. Each call replaces any previously set default for this category.

Parameters
paramsDefault configuration applied to any generic device.

◆ setDefaultDeviceParams() [2/7]

void eduart::sensorring::SensorRingFactory::setDefaultDeviceParams ( device::HTPA32_Params params)

Set default params applied to a specific discovered device type that has no explicit params from expectDevice().

Sets a Concrete default (Priority 1). These take precedence over any category-level defaults or hard-coded zero-initialised defaults.

This applies across all build paths (auto-discovery, configured boards without explicit device expectations, and wildcard resolution fallbacks). Each call replaces any previously set default for this specific type.

Parameters
paramsDefault configuration applied to the concrete device type.

◆ setDefaultDeviceParams() [3/7]

void eduart::sensorring::SensorRingFactory::setDefaultDeviceParams ( device::LightParams params)

Set default params applied to an entire category of discovered devices.

Sets a Category default (Priority 2). Applied when a discovered device of this category has no concrete default explicitly set.

Concrete params always override category params. Category params always override hard-coded defaults. Each call replaces any previously set default for this category.

Parameters
paramsDefault configuration applied to any generic device.

◆ setDefaultDeviceParams() [4/7]

void eduart::sensorring::SensorRingFactory::setDefaultDeviceParams ( device::ThermalSensorParams params)

Set default params applied to an entire category of discovered devices.

Sets a Category default (Priority 2). Applied when a discovered device of this category has no concrete default explicitly set.

Concrete params always override category params. Category params always override hard-coded defaults. Each call replaces any previously set default for this category.

Parameters
paramsDefault configuration applied to any generic device.

◆ setDefaultDeviceParams() [5/7]

void eduart::sensorring::SensorRingFactory::setDefaultDeviceParams ( device::TMF8829_Params params)

Set default params applied to a specific discovered device type that has no explicit params from expectDevice().

Sets a Concrete default (Priority 1). These take precedence over any category-level defaults or hard-coded zero-initialised defaults.

This applies across all build paths (auto-discovery, configured boards without explicit device expectations, and wildcard resolution fallbacks). Each call replaces any previously set default for this specific type.

Parameters
paramsDefault configuration applied to the concrete device type.

◆ setDefaultDeviceParams() [6/7]

void eduart::sensorring::SensorRingFactory::setDefaultDeviceParams ( device::VL53L8CX_Params params)

Set default params applied to a specific discovered device type that has no explicit params from expectDevice().

Sets a Concrete default (Priority 1). These take precedence over any category-level defaults or hard-coded zero-initialised defaults.

This applies across all build paths (auto-discovery, configured boards without explicit device expectations, and wildcard resolution fallbacks). Each call replaces any previously set default for this specific type.

Parameters
paramsDefault configuration applied to the concrete device type.

◆ setDefaultDeviceParams() [7/7]

void eduart::sensorring::SensorRingFactory::setDefaultDeviceParams ( device::WS2812b_Params params)

Set default params applied to a specific discovered device type that has no explicit params from expectDevice().

Sets a Concrete default (Priority 1). These take precedence over any category-level defaults or hard-coded zero-initialised defaults.

This applies across all build paths (auto-discovery, configured boards without explicit device expectations, and wildcard resolution fallbacks). Each call replaces any previously set default for this specific type.

Parameters
paramsDefault configuration applied to the concrete device type.

The documentation for this class was generated from the following file: