EduArt Sensor Ring Library 4.0.0
Loading...
Searching...
No Matches
SensorBoard.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 EduArt Robotik GmbH
2
9
10#pragma once
11
12#include <chrono>
13#include <memory>
14#include <mutex>
15
21#include "sensorring/platform/SensorringExport.hpp"
23
24using namespace std::chrono_literals;
25
26namespace eduart {
27
28namespace sensorring {
29
30namespace com {
31class ComInterface;
32}
33
34namespace board {
35
40class SENSORRING_EXPORT SensorBoard {
41public:
49 SensorBoard(SensorBoardParams params, com::ComInterfaceID interface, unsigned int idx, std::vector<std::unique_ptr<device::Device> > devices);
52
57 bool isEnumerated() const;
68
73 std::vector<device::Device*> getDevices() const;
74
79 bool configure();
80
85 static bool resetBoards();
86
92
93private:
94 friend struct SensorBoardTestAccess;
95
96 using Mutex = std::mutex;
97 using UniqueLock = std::unique_lock<Mutex>;
98
99 using RecursiveMutex = std::recursive_mutex;
100 using RecursiveLock = std::lock_guard<RecursiveMutex>;
101
107 void comCallback(const com::ComEndpoint source, std::uint8_t command, const std::vector<uint8_t>& data);
108
114 bool setOrientation(Orientation orientation);
115
121 bool getOrientation(Orientation& orientation);
122
123 static constexpr std::chrono::milliseconds GET_PARAMETER_SLEEP = 10ms;
124 static constexpr std::chrono::milliseconds GET_PARAMETER_TIMEOUT = 100ms;
125
126 unsigned int _idx;
127 SensorBoardParams _params;
128
130 std::vector<std::unique_ptr<device::Device> > _device_vec;
131
132 std::atomic<bool> _got_update;
133 com::ComInterface* _interface;
134 mutable RecursiveMutex _com_mutex;
135 subscription::Subscription _com_subscription;
136};
137
138} // namespace board
139
140} // namespace sensorring
141
142} // namespace eduart
Interface type definition.
Base class for all concrete sensor/actuator devices.
Version, commit hash, and board enumeration info reported by hardware.
Defines a pose with translation and orientation.
Parameter structure of a sensor board.
Orientation
Possible orientations of a sensor board. Used to rotate/mirror light animations and thermal images.
Definition SensorBoardParams.hpp:26
SensorBoardType
Hardware variant of a sensor board.
Definition SensorBoardType.hpp:28
RAII wrapper pairing a SubscriberToken with its cancel function.
std::vector< device::Device * > getDevices() const
Return non-owning pointers to all devices on this board.
static void cmdEnumerateBoards(com::ComInterfaceID interface)
Send enumeration command on the given interface so boards respond with CMD_ACTIVE_DEVICE_RESPONSE.
const board::EnumerationInformation & getEnumInfo() const
Return the enumeration info received from the hardware.
bool isEnumerated() const
Report whether this board has completed enumeration.
bool configure()
Re-apply runtime configuration after a board reset.
SensorBoard(SensorBoardParams params, com::ComInterfaceID interface, unsigned int idx, std::vector< std::unique_ptr< device::Device > > devices)
Construct the board with parameters, communication interface, index, and owned devices.
static bool resetBoards()
Reset all boards on all interfaces (broadcast reset command).
SensorBoardType getBoardType() const
Board type from configuration (undefined if not set). Used for topology enforcement.
Move-only RAII wrapper that pairs a SubscriberToken with an unsubscribe callable. Destroying a Subscr...
Definition Subscription.hpp:32
Information reported by a board during enumeration: index, version, commit hash, board type,...
Definition EnumerationInformation.hpp:159
Parameter structure of a sensor board. A sensor board is one circuit board.
Definition SensorBoardParams.hpp:51
Uniquely identifies a communication endpoint as a (Direction, BoardAddress, DeviceId) tuple.
Definition ComEndpoint.hpp:37
Uniquely identifies a communication interface by type and name.
Definition ComInterfaceID.hpp:51