Merge PR #778: Add support for discoveryType
This commit is contained in:
commit
7c4625337d
@ -119,6 +119,9 @@ QList<int> ThingDiscovery::discoverThingsByInterface(const QString &interfaceNam
|
||||
if (!thingClass->interfaces().contains(interfaceName) && !thingClass->providedInterfaces().contains(interfaceName)) {
|
||||
continue;
|
||||
}
|
||||
if (thingClass->discoveryType() == ThingClass::DiscoveryTypeWeak) {
|
||||
continue;
|
||||
}
|
||||
if (!thingClass->createMethods().contains("CreateMethodDiscovery")) {
|
||||
continue;
|
||||
}
|
||||
@ -198,7 +201,7 @@ void ThingDiscovery::discoverThingsResponse(int commandId, const QVariantMap &pa
|
||||
Param* p = new Param(paramVariant.toMap().value("paramTypeId").toString(), paramVariant.toMap().value("value"));
|
||||
descriptor->params()->addParam(p);
|
||||
}
|
||||
qCDebug(dcThingManager()) << "Found thing. Descriptor:" << descriptor->name() << descriptor->id();
|
||||
qCInfo(dcThingManager()) << "Found thing. Descriptor:" << descriptor->name() << descriptor->id();
|
||||
m_foundThings.append(descriptor);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
|
||||
@ -244,6 +244,7 @@ void ThingManager::getVendorsResponse(int /*commandId*/, const QVariantMap ¶
|
||||
|
||||
void ThingManager::getThingClassesResponse(int /*commandId*/, const QVariantMap ¶ms)
|
||||
{
|
||||
qCDebug(dcThingManager) << "GetThingClasses response:" << qUtf8Printable(QJsonDocument::fromVariant(params).toJson());
|
||||
if (params.keys().contains("thingClasses")) {
|
||||
QVariantList thingClassList = params.value("thingClasses").toList();
|
||||
foreach (QVariant thingClassVariant, thingClassList) {
|
||||
@ -774,6 +775,8 @@ ThingClass *ThingManager::unpackThingClass(const QVariantMap &thingClassMap)
|
||||
createMethods.append(method.toString());
|
||||
}
|
||||
thingClass->setCreateMethods(createMethods);
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<ThingClass::DiscoveryType>();
|
||||
thingClass->setDiscoveryType(static_cast<ThingClass::DiscoveryType>(metaEnum.keyToValue(thingClassMap.value("discoveryType").toByteArray())));
|
||||
thingClass->setSetupMethod(stringToSetupMethod(thingClassMap.value("setupMethod").toString()));
|
||||
thingClass->setInterfaces(thingClassMap.value("interfaces").toStringList());
|
||||
thingClass->setProvidedInterfaces(thingClassMap.value("providedInterfaces").toStringList());
|
||||
|
||||
@ -97,6 +97,16 @@ void ThingClass::setCreateMethods(const QStringList &createMethods)
|
||||
m_createMethods = createMethods;
|
||||
}
|
||||
|
||||
ThingClass::DiscoveryType ThingClass::discoveryType() const
|
||||
{
|
||||
return m_discoveryType;
|
||||
}
|
||||
|
||||
void ThingClass::setDiscoveryType(ThingClass::DiscoveryType discoveryType)
|
||||
{
|
||||
m_discoveryType = discoveryType;
|
||||
}
|
||||
|
||||
ThingClass::SetupMethod ThingClass::setupMethod() const
|
||||
{
|
||||
return m_setupMethod;
|
||||
|
||||
@ -49,6 +49,7 @@ class ThingClass : public QObject
|
||||
Q_PROPERTY(QString displayName READ displayName CONSTANT)
|
||||
Q_PROPERTY(QUuid id READ id CONSTANT)
|
||||
Q_PROPERTY(QUuid vendorId READ vendorId CONSTANT)
|
||||
Q_PROPERTY(DiscoveryType discoveryTye READ discoveryType CONSTANT)
|
||||
Q_PROPERTY(QStringList createMethods READ createMethods CONSTANT)
|
||||
Q_PROPERTY(SetupMethod setupMethod READ setupMethod CONSTANT)
|
||||
Q_PROPERTY(QStringList interfaces READ interfaces CONSTANT)
|
||||
@ -64,6 +65,11 @@ class ThingClass : public QObject
|
||||
Q_PROPERTY(ActionTypes *browserItemActionTypes READ browserItemActionTypes NOTIFY browserItemActionTypesChanged)
|
||||
|
||||
public:
|
||||
enum DiscoveryType {
|
||||
DiscoveryTypeWeak,
|
||||
DiscoveryTypePrecise
|
||||
};
|
||||
Q_ENUM(DiscoveryType)
|
||||
|
||||
enum SetupMethod {
|
||||
SetupMethodJustAdd,
|
||||
@ -95,6 +101,9 @@ public:
|
||||
QStringList createMethods() const;
|
||||
void setCreateMethods(const QStringList &createMethods);
|
||||
|
||||
DiscoveryType discoveryType() const;
|
||||
void setDiscoveryType(DiscoveryType discoveryType);
|
||||
|
||||
SetupMethod setupMethod() const;
|
||||
void setSetupMethod(SetupMethod setupMethod);
|
||||
|
||||
@ -148,6 +157,7 @@ private:
|
||||
QString m_name;
|
||||
QString m_displayName;
|
||||
QStringList m_createMethods;
|
||||
DiscoveryType m_discoveryType = DiscoveryTypePrecise;
|
||||
SetupMethod m_setupMethod;
|
||||
QStringList m_interfaces;
|
||||
QStringList m_providedInterfaces;
|
||||
|
||||
@ -70,11 +70,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// qt.qml.connections warnings are disabled since the replace only exists
|
||||
// in Qt 5.12. Remove that once 5.12 is the minimum supported version.
|
||||
QLoggingCategory::setFilterRules("RemoteProxyClientJsonRpcTraffic.debug=false\n"
|
||||
"RemoteProxyClientJsonRpc.debug=false\n"
|
||||
"RemoteProxyClientWebSocket.debug=false\n"
|
||||
"RemoteProxyClientConnection.debug=false\n"
|
||||
"RemoteProxyClientConnectionTraffic.debug=false\n"
|
||||
QLoggingCategory::setFilterRules("*.debug=false\n"
|
||||
"qt.qml.connections.warning=false\n"
|
||||
);
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
|
||||
@ -71,8 +71,8 @@ ChartView {
|
||||
for (var i = 0; i < consumers.count; i++) {
|
||||
var consumer = consumers.get(i)
|
||||
colorMap[consumer] = root.colors[i % root.colors.length]
|
||||
var currentPowerState = consumer.stateByName("currentPower")
|
||||
var slice = consumersBalanceSeries.append(consumer.name, currentPowerState.value)
|
||||
let currentPowerState = consumer.stateByName("currentPower")
|
||||
let slice = consumersBalanceSeries.append(consumer.name, currentPowerState.value)
|
||||
slice.color = root.colors[i % root.colors.length]
|
||||
currentPowerState.valueChanged.connect(function() {
|
||||
slice.value = currentPowerState.value
|
||||
|
||||
Reference in New Issue
Block a user