From f566867f882a849c30da6386deb5d01556d055a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Thu, 18 Jun 2015 16:16:55 +0200 Subject: [PATCH] fix rule engine remove debug from tune --- .../deviceplugins/tune/deviceplugintune.cpp | 3 +-- server/guhcore.cpp | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/plugins/deviceplugins/tune/deviceplugintune.cpp b/plugins/deviceplugins/tune/deviceplugintune.cpp index b7a60a98..8f982d92 100644 --- a/plugins/deviceplugins/tune/deviceplugintune.cpp +++ b/plugins/deviceplugins/tune/deviceplugintune.cpp @@ -151,11 +151,10 @@ void DevicePluginTune::tuneConnectionStatusChanged(const bool &connected) void DevicePluginTune::updateMood(const QVariantMap &message) { QVariantMap mood = message.value("mood").toMap(); - qDebug () << QJsonDocument::fromVariant(message).toJson(); + //qDebug () << QJsonDocument::fromVariant(message).toJson(); Device *device = deviceManager()->findConfiguredDevice(DeviceId(mood.value("deviceId").toString())); if (device) { QVariantMap states = mood.value("states").toMap(); - //qDebug() << "======>" << device->name() << states.value("active").toBool() << states.value("value").toInt(); device->setStateValue(activeStateTypeId, states.value("active").toBool()); device->setStateValue(valueStateTypeId, states.value("value").toInt()); } diff --git a/server/guhcore.cpp b/server/guhcore.cpp index 018b4f34..9fc87f6f 100644 --- a/server/guhcore.cpp +++ b/server/guhcore.cpp @@ -92,6 +92,12 @@ This signal is emitted when a \a rule was added to the system. */ +/*! \fn void ruleActiveChanged(const Rule &rule); + This signal is emitted when a \a rule changed the active state. + A \l{Rule} is active, when all \l{State}{States} match with the \l{StateDescriptor} conditions. + + \sa Rule::active() +*/ #include "guhcore.h" #include "jsonrpcserver.h" @@ -431,7 +437,7 @@ void GuhCore::gotEvent(const Event &event) if (action.isEventBased()) { eventBasedActions.append(action); } else { - actions.append(rule.actions()); + actions.append(action); } } } else { @@ -454,12 +460,13 @@ void GuhCore::gotEvent(const Event &event) if (event.eventTypeId() == ruleActionParam.eventTypeId()) { QVariant eventValue = event.params().first().value(); - // TODO: get param names... + // TODO: get param names...when an event has more than one parameter - // TODO: limits / scale calculation -> actionValue = eventValue * x + // TODO: limits / scale calculation -> actionValue = eventValue * x + // something like a EventParamDescriptor ruleActionParam.setValue(eventValue); - qDebug() << ruleActionParam.value(); + qDebug() << "take over event param value" << ruleActionParam.value(); } newParams.append(ruleActionParam); } @@ -476,10 +483,13 @@ void GuhCore::gotEvent(const Event &event) case DeviceManager::DeviceErrorNoError: break; case DeviceManager::DeviceErrorSetupFailed: - qDebug() << "Error executing action. Device setup failed."; + qWarning() << "Error executing action. Device setup failed."; + break; + case DeviceManager::DeviceErrorAsync: + qDebug() << "Executing asynchronous action."; break; case DeviceManager::DeviceErrorInvalidParameter: - qDebug() << "Error executing action. Invalid action parameter."; + qWarning() << "Error executing action. Invalid action parameter."; break; default: qDebug() << "Error executing action:" << status;