EduArt Sensor Ring Library 3.0.0
Loading...
Searching...
No Matches
EnumerationInformation.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 EduArt Robotik GmbH
2
9
10#pragma once
11
12#include <cstdint>
13#include <iostream>
14#include <string>
15#include <vector>
16
19#include "sensorring/platform/SensorringExport.hpp"
20
21namespace eduart {
22
27struct SENSORRING_EXPORT Version {
29 unsigned int major = 0;
31 unsigned int minor = 0;
33 unsigned int patch = 0;
34
39 std::string toString() const;
40
47 friend std::ostream& operator<<(std::ostream& os, const Version& v) noexcept;
48
54 bool operator==(const Version& other) const noexcept;
55
61 bool operator<(const Version& other) const noexcept;
62};
63
68struct SENSORRING_EXPORT CommitHash {
70 std::uint32_t hash = 0;
71
80 static CommitHash fromBits(std::uint8_t a, std::uint8_t b, std::uint8_t c, std::uint8_t d) noexcept;
81
86 std::string toString() const;
87
94 friend std::ostream& operator<<(std::ostream& os, const CommitHash& ch) noexcept;
95
101 bool operator==(const CommitHash& other) const noexcept;
102};
103
104namespace device {
105
110enum class ConnectionState {
111 Undefined,
112 Connected,
113 Unconnected
114};
115
128
134SENSORRING_EXPORT std::string toString(ConnectionState state);
135
141SENSORRING_EXPORT std::string toString(ConfigurationState state);
142
146SENSORRING_EXPORT std::ostream& operator<<(std::ostream& os, const ConnectionState state) noexcept;
147
151SENSORRING_EXPORT std::ostream& operator<<(std::ostream& os, const ConfigurationState state) noexcept;
152
157struct SENSORRING_EXPORT EnumerationInformation {
159 unsigned int idx = 0;
160
163
166
168 SensorBoardType type = SensorBoardType::Undefined;
169
171 std::uint16_t device_options = 0;
172
174 std::vector<DeviceType> devices;
175
177 ConnectionState state = ConnectionState::Undefined;
178
181
183 std::vector<DeviceType> configured_devices;
184
189 bool isUndefined() const noexcept;
190
196 static EnumerationInformation fromBuffer(const std::vector<uint8_t>& buffer);
197
203 bool hasDevice(DeviceType type) const noexcept;
204
210 bool operator==(unsigned int other) const noexcept;
211
217 bool operator==(const EnumerationInformation& other) const noexcept;
218
224 bool operator<(const EnumerationInformation& other) const noexcept;
225
230 std::string toString() const;
231};
232
233} // namespace device
234
235} // namespace eduart
SENSORRING_EXPORT std::ostream & operator<<(std::ostream &os, DeviceState state) noexcept
Output stream operator for DeviceState.
SENSORRING_EXPORT std::string toString(DeviceState state) noexcept
Convert a DeviceState value to its string representation.
Enumeration of supported device hardware types.
DeviceType
Supported device hardware types used for device registration and grouping.
Definition DeviceType.hpp:25
ConfigurationState
Whether a board or device was declared by the user via the factory.
Definition EnumerationInformation.hpp:120
@ Configured
The board/device was declared by the user (expectBoard) and matched by the factory.
Definition EnumerationInformation.hpp:124
@ Undefined
State has not been determined yet.
Definition EnumerationInformation.hpp:122
@ Unconfigured
The board/device was discovered by hardware but not declared by the user.
Definition EnumerationInformation.hpp:126
ConnectionState
Physical connection state of a board after enumeration.
Definition EnumerationInformation.hpp:110
Board type enum for sensor board hardware variants (matches firmware).
SensorBoardType
Definition SensorBoardType.hpp:21
32-bit commit hash (e.g. from firmware) with byte-wise construction and string output.
Definition EnumerationInformation.hpp:68
std::string toString() const
Format hash as hex string.
static CommitHash fromBits(std::uint8_t a, std::uint8_t b, std::uint8_t c, std::uint8_t d) noexcept
Build a CommitHash from four bytes (e.g. from enumeration response).
bool operator==(const CommitHash &other) const noexcept
Compare two commit hashes for equality.
std::uint32_t hash
32-bit hash value.
Definition EnumerationInformation.hpp:70
friend std::ostream & operator<<(std::ostream &os, const CommitHash &ch) noexcept
Stream hash as hex string.
Semantic version (major, minor, patch) for firmware or board.
Definition EnumerationInformation.hpp:27
std::string toString() const
Format version as "major.minor.patch".
friend std::ostream & operator<<(std::ostream &os, const Version &v) noexcept
Stream version as "major.minor.patch".
bool operator==(const Version &other) const noexcept
Compare two versions for equality.
unsigned int patch
Patch version number.
Definition EnumerationInformation.hpp:33
unsigned int major
Major version number.
Definition EnumerationInformation.hpp:29
unsigned int minor
Minor version number.
Definition EnumerationInformation.hpp:31
bool operator<(const Version &other) const noexcept
Lexicographic less-than comparison (major, minor, patch).
Information reported by a board during enumeration: index, version, commit hash, board type,...
Definition EnumerationInformation.hpp:157
bool isUndefined() const noexcept
Return true if this instance has not been filled from a valid enumeration response.
std::uint16_t device_options
Bitmask describing which devices are physically populated on the board.
Definition EnumerationInformation.hpp:171
static EnumerationInformation fromBuffer(const std::vector< uint8_t > &buffer)
Parse enumeration info from the raw response buffer (e.g. CMD_ACTIVE_DEVICE_RESPONSE payload).
unsigned int idx
Board index.
Definition EnumerationInformation.hpp:159
bool hasDevice(DeviceType type) const noexcept
Check if a specific device type is reported as populated.
std::vector< DeviceType > configured_devices
Device types that were instantiated by the factory (subset of devices).
Definition EnumerationInformation.hpp:183
ConnectionState state
Configuration/connection state after enumeration.
Definition EnumerationInformation.hpp:177
ConfigurationState config_state
Configuration state set by the factory during build().
Definition EnumerationInformation.hpp:180
CommitHash hash
Commit hash from enumeration response.
Definition EnumerationInformation.hpp:165
SensorBoardType type
Detected or configured board type.
Definition EnumerationInformation.hpp:168
std::string toString() const
Format this board's enumeration info as a human-readable string.
std::vector< DeviceType > devices
Devices on the board.
Definition EnumerationInformation.hpp:174
Version version
Firmware/board version from enumeration response.
Definition EnumerationInformation.hpp:162