Enhance DALI device type discovery and query handling
- Introduce DaliDeviceTypeDiscovery struct for managing device type queries. - Implement discoverDeviceTypes method in DaliBase for improved device type detection. - Update DaliComm to handle query responses more robustly, including handling multiple device replies. - Add setDetectedDeviceTypes method in DaliDevice to manage detected device types and capabilities.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "device.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
namespace {
|
||||
@@ -359,3 +360,32 @@ void DaliDevice::merge(const DaliDevice& other) {
|
||||
metadata[kv.first] = kv.second;
|
||||
}
|
||||
}
|
||||
|
||||
void DaliDevice::setDetectedDeviceTypes(
|
||||
const std::optional<int>& rawQueryType, const std::vector<int>& types) {
|
||||
deviceType = types.empty() ? std::nullopt : std::optional<int>(types.front());
|
||||
|
||||
extType.clear();
|
||||
if (types.size() > 1) {
|
||||
extType.assign(types.begin() + 1, types.end());
|
||||
}
|
||||
|
||||
capabilities.supportsDt1 = std::find(types.begin(), types.end(), 1) != types.end();
|
||||
capabilities.supportsDt4 = std::find(types.begin(), types.end(), 4) != types.end();
|
||||
capabilities.supportsDt5 = std::find(types.begin(), types.end(), 5) != types.end();
|
||||
capabilities.supportsDt6 = std::find(types.begin(), types.end(), 6) != types.end();
|
||||
capabilities.supportsDt8 = std::find(types.begin(), types.end(), 8) != types.end();
|
||||
|
||||
if (rawQueryType.has_value()) {
|
||||
metadata["deviceTypeQueryRaw"] = rawQueryType.value();
|
||||
} else {
|
||||
metadata.erase("deviceTypeQueryRaw");
|
||||
}
|
||||
|
||||
DaliValue::Array detectedTypes;
|
||||
detectedTypes.reserve(types.size());
|
||||
for (const int type : types) {
|
||||
detectedTypes.emplace_back(type);
|
||||
}
|
||||
metadata["deviceTypes"] = std::move(detectedTypes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user