add execute rule actions
This commit is contained in:
parent
3d3e9e0fc0
commit
f9c15d689e
2
guh.pri
2
guh.pri
@ -2,7 +2,7 @@
|
|||||||
GUH_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"')
|
GUH_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"')
|
||||||
|
|
||||||
# define protocol versions
|
# define protocol versions
|
||||||
JSON_PROTOCOL_VERSION=30
|
JSON_PROTOCOL_VERSION=31
|
||||||
REST_API_VERSION=1
|
REST_API_VERSION=1
|
||||||
|
|
||||||
DEFINES += GUH_VERSION_STRING=\\\"$${GUH_VERSION_STRING}\\\" \
|
DEFINES += GUH_VERSION_STRING=\\\"$${GUH_VERSION_STRING}\\\" \
|
||||||
|
|||||||
@ -258,6 +258,33 @@ DeviceManager::DeviceError GuhCore::executeAction(const Action &action)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuhCore::executeRuleActions(const QList<RuleAction> ruleActions)
|
||||||
|
{
|
||||||
|
foreach (const RuleAction &ruleAction, ruleActions) {
|
||||||
|
Action action = ruleAction.toAction();
|
||||||
|
qCDebug(dcRuleEngine) << "executing action" << ruleAction.actionTypeId() << action.params();
|
||||||
|
DeviceManager::DeviceError status = executeAction(action);
|
||||||
|
switch(status) {
|
||||||
|
case DeviceManager::DeviceErrorNoError:
|
||||||
|
break;
|
||||||
|
case DeviceManager::DeviceErrorSetupFailed:
|
||||||
|
qCWarning(dcRuleEngine) << "Error executing action. Device setup failed.";
|
||||||
|
break;
|
||||||
|
case DeviceManager::DeviceErrorAsync:
|
||||||
|
qCDebug(dcRuleEngine) << "Executing asynchronous action.";
|
||||||
|
break;
|
||||||
|
case DeviceManager::DeviceErrorInvalidParameter:
|
||||||
|
qCWarning(dcRuleEngine) << "Error executing action. Invalid action parameter.";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qCWarning(dcRuleEngine) << "Error executing action:" << status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status != DeviceManager::DeviceErrorAsync)
|
||||||
|
m_logger->logAction(action, status == DeviceManager::DeviceErrorNoError ? Logging::LoggingLevelInfo : Logging::LoggingLevelAlert, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*! Calls the metheod DeviceManager::findDeviceClass(\a deviceClassId).
|
/*! Calls the metheod DeviceManager::findDeviceClass(\a deviceClassId).
|
||||||
* \sa DeviceManager::findDeviceClass(), */
|
* \sa DeviceManager::findDeviceClass(), */
|
||||||
DeviceClass GuhCore::findDeviceClass(const DeviceClassId &deviceClassId) const
|
DeviceClass GuhCore::findDeviceClass(const DeviceClassId &deviceClassId) const
|
||||||
@ -344,16 +371,16 @@ Rule GuhCore::findRule(const RuleId &ruleId)
|
|||||||
|
|
||||||
/*! Calls the metheod RuleEngine::addRule(\a id, \a name, \a eventDescriptorList, \a stateEvaluator \a actionList, \a exitActionList, \a enabled).
|
/*! Calls the metheod RuleEngine::addRule(\a id, \a name, \a eventDescriptorList, \a stateEvaluator \a actionList, \a exitActionList, \a enabled).
|
||||||
* \sa RuleEngine::addRule(), */
|
* \sa RuleEngine::addRule(), */
|
||||||
RuleEngine::RuleError GuhCore::addRule(const RuleId &id, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actionList, const QList<RuleAction> &exitActionList, bool enabled)
|
RuleEngine::RuleError GuhCore::addRule(const RuleId &id, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actionList, const QList<RuleAction> &exitActionList, bool enabled, bool executable)
|
||||||
{
|
{
|
||||||
return m_ruleEngine->addRule(id, name, eventDescriptorList, stateEvaluator, actionList, exitActionList, enabled);
|
return m_ruleEngine->addRule(id, name, eventDescriptorList, stateEvaluator, actionList, exitActionList, enabled, executable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Calls the metheod RuleEngine::editRule(\a id, \a name, \a eventDescriptorList, \a stateEvaluator \a actionList, \a exitActionList, \a enabled).
|
/*! Calls the metheod RuleEngine::editRule(\a id, \a name, \a eventDescriptorList, \a stateEvaluator \a actionList, \a exitActionList, \a enabled).
|
||||||
* \sa RuleEngine::editRule(), */
|
* \sa RuleEngine::editRule(), */
|
||||||
RuleEngine::RuleError GuhCore::editRule(const RuleId &id, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actionList, const QList<RuleAction> &exitActionList, bool enabled)
|
RuleEngine::RuleError GuhCore::editRule(const RuleId &id, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actionList, const QList<RuleAction> &exitActionList, bool enabled, bool executable)
|
||||||
{
|
{
|
||||||
return m_ruleEngine->editRule(id, name, eventDescriptorList, stateEvaluator, actionList, exitActionList, enabled);
|
return m_ruleEngine->editRule(id, name, eventDescriptorList, stateEvaluator, actionList, exitActionList, enabled, executable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Calls the metheod RuleEngine::removeRule(\a id).
|
/*! Calls the metheod RuleEngine::removeRule(\a id).
|
||||||
@ -388,6 +415,16 @@ RuleEngine::RuleError GuhCore::disableRule(const RuleId &ruleId)
|
|||||||
return m_ruleEngine->disableRule(ruleId);
|
return m_ruleEngine->disableRule(ruleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RuleEngine::RuleError GuhCore::executeRuleActions(const RuleId &ruleId)
|
||||||
|
{
|
||||||
|
return m_ruleEngine->executeActions(ruleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
RuleEngine::RuleError GuhCore::executeRuleExitActions(const RuleId &ruleId)
|
||||||
|
{
|
||||||
|
return m_ruleEngine->executeExitActions(ruleId);
|
||||||
|
}
|
||||||
|
|
||||||
/*! Returns a pointer to the \l{DeviceManager} instance owned by GuhCore.*/
|
/*! Returns a pointer to the \l{DeviceManager} instance owned by GuhCore.*/
|
||||||
DeviceManager *GuhCore::deviceManager() const
|
DeviceManager *GuhCore::deviceManager() const
|
||||||
{
|
{
|
||||||
@ -491,30 +528,7 @@ void GuhCore::gotEvent(const Event &event)
|
|||||||
actions.append(ruleAction);
|
actions.append(ruleAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now execute all the associated actions
|
executeRuleActions(actions);
|
||||||
foreach (const RuleAction &ruleAction, actions) {
|
|
||||||
Action action = ruleAction.toAction();
|
|
||||||
qCDebug(dcRuleEngine) << "executing action" << ruleAction.actionTypeId();
|
|
||||||
DeviceManager::DeviceError status = executeAction(action);
|
|
||||||
switch(status) {
|
|
||||||
case DeviceManager::DeviceErrorNoError:
|
|
||||||
break;
|
|
||||||
case DeviceManager::DeviceErrorSetupFailed:
|
|
||||||
qCWarning(dcRuleEngine) << "Error executing action. Device setup failed.";
|
|
||||||
break;
|
|
||||||
case DeviceManager::DeviceErrorAsync:
|
|
||||||
qCDebug(dcRuleEngine) << "Executing asynchronous action.";
|
|
||||||
break;
|
|
||||||
case DeviceManager::DeviceErrorInvalidParameter:
|
|
||||||
qCWarning(dcRuleEngine) << "Error executing action. Invalid action parameter.";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
qCWarning(dcRuleEngine) << "Error executing action:" << status;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status != DeviceManager::DeviceErrorAsync)
|
|
||||||
m_logger->logAction(action, status == DeviceManager::DeviceErrorNoError ? Logging::LoggingLevelInfo : Logging::LoggingLevelAlert, status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Return the instance of the log engine */
|
/*! Return the instance of the log engine */
|
||||||
|
|||||||
@ -83,15 +83,19 @@ public:
|
|||||||
|
|
||||||
DeviceManager::DeviceError executeAction(const Action &action);
|
DeviceManager::DeviceError executeAction(const Action &action);
|
||||||
|
|
||||||
|
void executeRuleActions(const QList<RuleAction> ruleActions);
|
||||||
|
|
||||||
QList<Rule> rules() const;
|
QList<Rule> rules() const;
|
||||||
QList<RuleId> ruleIds() const;
|
QList<RuleId> ruleIds() const;
|
||||||
Rule findRule(const RuleId &ruleId);
|
Rule findRule(const RuleId &ruleId);
|
||||||
RuleEngine::RuleError addRule(const RuleId &id, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actionList, const QList<RuleAction> &exitActionList, bool enabled = true);
|
RuleEngine::RuleError addRule(const RuleId &id, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actionList, const QList<RuleAction> &exitActionList, bool enabled = true, bool executable = true);
|
||||||
RuleEngine::RuleError editRule(const RuleId &id, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actionList, const QList<RuleAction> &exitActionList, bool enabled = true);
|
RuleEngine::RuleError editRule(const RuleId &id, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actionList, const QList<RuleAction> &exitActionList, bool enabled = true, bool executable = true);
|
||||||
RuleEngine::RuleError removeRule(const RuleId &id);
|
RuleEngine::RuleError removeRule(const RuleId &id);
|
||||||
QList<RuleId> findRules(const DeviceId &deviceId);
|
QList<RuleId> findRules(const DeviceId &deviceId);
|
||||||
RuleEngine::RuleError enableRule(const RuleId &ruleId);
|
RuleEngine::RuleError enableRule(const RuleId &ruleId);
|
||||||
RuleEngine::RuleError disableRule(const RuleId &ruleId);
|
RuleEngine::RuleError disableRule(const RuleId &ruleId);
|
||||||
|
RuleEngine::RuleError executeRuleActions(const RuleId &ruleId);
|
||||||
|
RuleEngine::RuleError executeRuleExitActions(const RuleId &ruleId);
|
||||||
|
|
||||||
LogEngine* logEngine() const;
|
LogEngine* logEngine() const;
|
||||||
JsonRPCServer *jsonRPCServer() const;
|
JsonRPCServer *jsonRPCServer() const;
|
||||||
|
|||||||
@ -209,6 +209,7 @@ void JsonTypes::init()
|
|||||||
s_rule.insert("id", basicTypeToString(Uuid));
|
s_rule.insert("id", basicTypeToString(Uuid));
|
||||||
s_rule.insert("name", basicTypeToString(String));
|
s_rule.insert("name", basicTypeToString(String));
|
||||||
s_rule.insert("enabled", basicTypeToString(Bool));
|
s_rule.insert("enabled", basicTypeToString(Bool));
|
||||||
|
s_rule.insert("executable", basicTypeToString(Bool));
|
||||||
s_rule.insert("active", basicTypeToString(Bool));
|
s_rule.insert("active", basicTypeToString(Bool));
|
||||||
s_rule.insert("eventDescriptors", QVariantList() << eventDescriptorRef());
|
s_rule.insert("eventDescriptors", QVariantList() << eventDescriptorRef());
|
||||||
s_rule.insert("actions", QVariantList() << ruleActionRef());
|
s_rule.insert("actions", QVariantList() << ruleActionRef());
|
||||||
@ -220,6 +221,8 @@ void JsonTypes::init()
|
|||||||
s_ruleDescription.insert("name", basicTypeToString(String));
|
s_ruleDescription.insert("name", basicTypeToString(String));
|
||||||
s_ruleDescription.insert("enabled", basicTypeToString(Bool));
|
s_ruleDescription.insert("enabled", basicTypeToString(Bool));
|
||||||
s_ruleDescription.insert("active", basicTypeToString(Bool));
|
s_ruleDescription.insert("active", basicTypeToString(Bool));
|
||||||
|
s_ruleDescription.insert("executable", basicTypeToString(Bool));
|
||||||
|
|
||||||
|
|
||||||
// LogEntry
|
// LogEntry
|
||||||
s_logEntry.insert("timestamp", basicTypeToString(Int));
|
s_logEntry.insert("timestamp", basicTypeToString(Int));
|
||||||
@ -579,6 +582,8 @@ QVariantMap JsonTypes::packRule(const Rule &rule)
|
|||||||
ruleMap.insert("name", rule.name());
|
ruleMap.insert("name", rule.name());
|
||||||
ruleMap.insert("enabled", rule.enabled());
|
ruleMap.insert("enabled", rule.enabled());
|
||||||
ruleMap.insert("active", rule.active());
|
ruleMap.insert("active", rule.active());
|
||||||
|
ruleMap.insert("executable", rule.executable());
|
||||||
|
|
||||||
QVariantList eventDescriptorList;
|
QVariantList eventDescriptorList;
|
||||||
foreach (const EventDescriptor &eventDescriptor, rule.eventDescriptors()) {
|
foreach (const EventDescriptor &eventDescriptor, rule.eventDescriptors()) {
|
||||||
eventDescriptorList.append(JsonTypes::packEventDescriptor(eventDescriptor));
|
eventDescriptorList.append(JsonTypes::packEventDescriptor(eventDescriptor));
|
||||||
@ -616,6 +621,7 @@ QVariantMap JsonTypes::packRuleDescription(const Rule &rule)
|
|||||||
ruleDescriptionMap.insert("name", rule.name());
|
ruleDescriptionMap.insert("name", rule.name());
|
||||||
ruleDescriptionMap.insert("enabled", rule.enabled());
|
ruleDescriptionMap.insert("enabled", rule.enabled());
|
||||||
ruleDescriptionMap.insert("active", rule.active());
|
ruleDescriptionMap.insert("active", rule.active());
|
||||||
|
ruleDescriptionMap.insert("executable", rule.executable());
|
||||||
return ruleDescriptionMap;
|
return ruleDescriptionMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
* *
|
* *
|
||||||
* Copyright (C) 2015 Simon Stuerz <simon.stuerz@guh.guru> *
|
* Copyright (C) 2015 Simon Stuerz <simon.stuerz@guh.guru> *
|
||||||
* Copyright (C) 2014 Michael Zanetti <michael_zanetti@gmx.net> *
|
* Copyright (C) 2014 Michael Zanetti <michael_zanetti@gmx.net> *
|
||||||
|
|||||||
@ -71,6 +71,7 @@ RulesHandler::RulesHandler(QObject *parent) :
|
|||||||
params.insert("o:stateEvaluator", JsonTypes::stateEvaluatorRef());
|
params.insert("o:stateEvaluator", JsonTypes::stateEvaluatorRef());
|
||||||
params.insert("o:exitActions", QVariantList() << JsonTypes::ruleActionRef());
|
params.insert("o:exitActions", QVariantList() << JsonTypes::ruleActionRef());
|
||||||
params.insert("o:enabled", JsonTypes::basicTypeToString(JsonTypes::Bool));
|
params.insert("o:enabled", JsonTypes::basicTypeToString(JsonTypes::Bool));
|
||||||
|
params.insert("o:executable", JsonTypes::basicTypeToString(JsonTypes::Bool));
|
||||||
params.insert("name", JsonTypes::basicTypeToString(JsonTypes::String));
|
params.insert("name", JsonTypes::basicTypeToString(JsonTypes::String));
|
||||||
QVariantList actions;
|
QVariantList actions;
|
||||||
actions.append(JsonTypes::ruleActionRef());
|
actions.append(JsonTypes::ruleActionRef());
|
||||||
@ -92,6 +93,7 @@ RulesHandler::RulesHandler(QObject *parent) :
|
|||||||
params.insert("o:stateEvaluator", JsonTypes::stateEvaluatorRef());
|
params.insert("o:stateEvaluator", JsonTypes::stateEvaluatorRef());
|
||||||
params.insert("o:exitActions", QVariantList() << JsonTypes::ruleActionRef());
|
params.insert("o:exitActions", QVariantList() << JsonTypes::ruleActionRef());
|
||||||
params.insert("o:enabled", JsonTypes::basicTypeToString(JsonTypes::Bool));
|
params.insert("o:enabled", JsonTypes::basicTypeToString(JsonTypes::Bool));
|
||||||
|
params.insert("o:executable", JsonTypes::basicTypeToString(JsonTypes::Bool));
|
||||||
actions.append(JsonTypes::ruleActionRef());
|
actions.append(JsonTypes::ruleActionRef());
|
||||||
params.insert("actions", actions);
|
params.insert("actions", actions);
|
||||||
setParams("EditRule", params);
|
setParams("EditRule", params);
|
||||||
@ -129,6 +131,20 @@ RulesHandler::RulesHandler(QObject *parent) :
|
|||||||
returns.insert("ruleError", JsonTypes::ruleErrorRef());
|
returns.insert("ruleError", JsonTypes::ruleErrorRef());
|
||||||
setReturns("DisableRule", returns);
|
setReturns("DisableRule", returns);
|
||||||
|
|
||||||
|
params.clear(); returns.clear();
|
||||||
|
setDescription("ExecuteActions", "Execute the action list of the rule with the given ruleId.");
|
||||||
|
params.insert("ruleId", JsonTypes::basicTypeToString(JsonTypes::Uuid));
|
||||||
|
setParams("ExecuteActions", params);
|
||||||
|
returns.insert("ruleError", JsonTypes::ruleErrorRef());
|
||||||
|
setReturns("ExecuteActions", returns);
|
||||||
|
|
||||||
|
params.clear(); returns.clear();
|
||||||
|
setDescription("ExecuteExitActions", "Execute the exit action list of the rule with the given ruleId.");
|
||||||
|
params.insert("ruleId", JsonTypes::basicTypeToString(JsonTypes::Uuid));
|
||||||
|
setParams("ExecuteExitActions", params);
|
||||||
|
returns.insert("ruleError", JsonTypes::ruleErrorRef());
|
||||||
|
setReturns("ExecuteExitActions", returns);
|
||||||
|
|
||||||
// Notifications
|
// Notifications
|
||||||
params.clear(); returns.clear();
|
params.clear(); returns.clear();
|
||||||
setDescription("RuleRemoved", "Emitted whenever a Rule was removed.");
|
setDescription("RuleRemoved", "Emitted whenever a Rule was removed.");
|
||||||
@ -227,9 +243,10 @@ JsonReply* RulesHandler::AddRule(const QVariantMap ¶ms)
|
|||||||
|
|
||||||
QString name = params.value("name", QString()).toString();
|
QString name = params.value("name", QString()).toString();
|
||||||
bool enabled = params.value("enabled", true).toBool();
|
bool enabled = params.value("enabled", true).toBool();
|
||||||
|
bool executable = params.value("executable", true).toBool();
|
||||||
|
|
||||||
RuleId newRuleId = RuleId::createRuleId();
|
RuleId newRuleId = RuleId::createRuleId();
|
||||||
RuleEngine::RuleError status = GuhCore::instance()->addRule(newRuleId, name, eventDescriptorList, stateEvaluator, actions, exitActions, enabled);
|
RuleEngine::RuleError status = GuhCore::instance()->addRule(newRuleId, name, eventDescriptorList, stateEvaluator, actions, exitActions, enabled, executable);
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
if (status == RuleEngine::RuleErrorNoError) {
|
if (status == RuleEngine::RuleErrorNoError) {
|
||||||
returns.insert("ruleId", newRuleId.toString());
|
returns.insert("ruleId", newRuleId.toString());
|
||||||
@ -281,9 +298,10 @@ JsonReply *RulesHandler::EditRule(const QVariantMap ¶ms)
|
|||||||
|
|
||||||
QString name = params.value("name", QString()).toString();
|
QString name = params.value("name", QString()).toString();
|
||||||
bool enabled = params.value("enabled", true).toBool();
|
bool enabled = params.value("enabled", true).toBool();
|
||||||
|
bool executable = params.value("executable", true).toBool();
|
||||||
|
|
||||||
RuleId ruleId = RuleId(params.value("ruleId").toString());
|
RuleId ruleId = RuleId(params.value("ruleId").toString());
|
||||||
RuleEngine::RuleError status = GuhCore::instance()->editRule(ruleId, name, eventDescriptorList, stateEvaluator, actions, exitActions, enabled);
|
RuleEngine::RuleError status = GuhCore::instance()->editRule(ruleId, name, eventDescriptorList, stateEvaluator, actions, exitActions, enabled, executable);
|
||||||
QVariantMap returns;
|
QVariantMap returns;
|
||||||
if (status == RuleEngine::RuleErrorNoError) {
|
if (status == RuleEngine::RuleErrorNoError) {
|
||||||
returns.insert("rule", JsonTypes::packRule(GuhCore::instance()->findRule(ruleId)));
|
returns.insert("rule", JsonTypes::packRule(GuhCore::instance()->findRule(ruleId)));
|
||||||
@ -326,6 +344,24 @@ JsonReply *RulesHandler::DisableRule(const QVariantMap ¶ms)
|
|||||||
return createReply(statusToReply(GuhCore::instance()->disableRule(RuleId(params.value("ruleId").toString()))));
|
return createReply(statusToReply(GuhCore::instance()->disableRule(RuleId(params.value("ruleId").toString()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JsonReply *RulesHandler::ExecuteActions(const QVariantMap ¶ms)
|
||||||
|
{
|
||||||
|
QVariantMap returns;
|
||||||
|
RuleId ruleId(params.value("ruleId").toString());
|
||||||
|
RuleEngine::RuleError status = GuhCore::instance()->executeRuleActions(ruleId);
|
||||||
|
returns.insert("ruleError", JsonTypes::ruleErrorToString(status));
|
||||||
|
return createReply(returns);
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonReply *RulesHandler::ExecuteExitActions(const QVariantMap ¶ms)
|
||||||
|
{
|
||||||
|
QVariantMap returns;
|
||||||
|
RuleId ruleId(params.value("ruleId").toString());
|
||||||
|
RuleEngine::RuleError status = GuhCore::instance()->executeRuleExitActions(ruleId);
|
||||||
|
returns.insert("ruleError", JsonTypes::ruleErrorToString(status));
|
||||||
|
return createReply(returns);
|
||||||
|
}
|
||||||
|
|
||||||
void RulesHandler::ruleRemovedNotification(const RuleId &ruleId)
|
void RulesHandler::ruleRemovedNotification(const RuleId &ruleId)
|
||||||
{
|
{
|
||||||
QVariantMap params;
|
QVariantMap params;
|
||||||
|
|||||||
@ -34,16 +34,19 @@ public:
|
|||||||
|
|
||||||
QString name() const override;
|
QString name() const override;
|
||||||
|
|
||||||
Q_INVOKABLE JsonReply* GetRules(const QVariantMap ¶ms);
|
Q_INVOKABLE JsonReply *GetRules(const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE JsonReply* GetRuleDetails(const QVariantMap ¶ms);
|
Q_INVOKABLE JsonReply *GetRuleDetails(const QVariantMap ¶ms);
|
||||||
|
|
||||||
Q_INVOKABLE JsonReply* AddRule(const QVariantMap ¶ms);
|
Q_INVOKABLE JsonReply *AddRule(const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE JsonReply* EditRule(const QVariantMap ¶ms);
|
Q_INVOKABLE JsonReply *EditRule(const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE JsonReply* RemoveRule(const QVariantMap ¶ms);
|
Q_INVOKABLE JsonReply *RemoveRule(const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE JsonReply* FindRules(const QVariantMap ¶ms);
|
Q_INVOKABLE JsonReply *FindRules(const QVariantMap ¶ms);
|
||||||
|
|
||||||
Q_INVOKABLE JsonReply* EnableRule(const QVariantMap ¶ms);
|
Q_INVOKABLE JsonReply *EnableRule(const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE JsonReply* DisableRule(const QVariantMap ¶ms);
|
Q_INVOKABLE JsonReply *DisableRule(const QVariantMap ¶ms);
|
||||||
|
|
||||||
|
Q_INVOKABLE JsonReply *ExecuteActions(const QVariantMap ¶ms);
|
||||||
|
Q_INVOKABLE JsonReply *ExecuteExitActions(const QVariantMap ¶ms);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void RuleRemoved(const QVariantMap ¶ms);
|
void RuleRemoved(const QVariantMap ¶ms);
|
||||||
|
|||||||
@ -57,7 +57,9 @@ public:
|
|||||||
|
|
||||||
enum LoggingEventType {
|
enum LoggingEventType {
|
||||||
LoggingEventTypeTrigger,
|
LoggingEventTypeTrigger,
|
||||||
LoggingEventTypeActiveChange
|
LoggingEventTypeActiveChange,
|
||||||
|
LoggingEventTypeActionsExecuted,
|
||||||
|
LoggingEventTypeExitActionsExecuted
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -170,6 +170,14 @@ HttpReply *RulesResource::proccessPostRequest(const HttpRequest &request, const
|
|||||||
if (urlTokens.count() == 5 && urlTokens.at(4) == "disable")
|
if (urlTokens.count() == 5 && urlTokens.at(4) == "disable")
|
||||||
return disableRule(m_ruleId);
|
return disableRule(m_ruleId);
|
||||||
|
|
||||||
|
// POST /api/v1/rules/{ruleId}/executeactions
|
||||||
|
if (urlTokens.count() == 5 && urlTokens.at(4) == "executeactions")
|
||||||
|
return executeActions(m_ruleId);
|
||||||
|
|
||||||
|
// POST /api/v1/rules/{ruleId}/executeexitactions
|
||||||
|
if (urlTokens.count() == 5 && urlTokens.at(4) == "executeexitactions")
|
||||||
|
return executeExitActions(m_ruleId);
|
||||||
|
|
||||||
return createErrorReply(HttpReply::NotImplemented);
|
return createErrorReply(HttpReply::NotImplemented);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,6 +314,30 @@ HttpReply *RulesResource::disableRule(const RuleId &ruleId) const
|
|||||||
return createRuleErrorReply(HttpReply::Ok, status);
|
return createRuleErrorReply(HttpReply::Ok, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HttpReply *RulesResource::executeActions(const RuleId &ruleId) const
|
||||||
|
{
|
||||||
|
qCDebug(dcRest) << "Execute actions of rule with id" << ruleId.toString();
|
||||||
|
|
||||||
|
RuleEngine::RuleError status = GuhCore::instance()->executeRuleActions(ruleId);
|
||||||
|
|
||||||
|
if (status != RuleEngine::RuleErrorNoError)
|
||||||
|
return createRuleErrorReply(HttpReply::InternalServerError, status);
|
||||||
|
|
||||||
|
return createRuleErrorReply(HttpReply::Ok, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpReply *RulesResource::executeExitActions(const RuleId &ruleId) const
|
||||||
|
{
|
||||||
|
qCDebug(dcRest) << "Execute exit actions of rule with id" << ruleId.toString();
|
||||||
|
|
||||||
|
RuleEngine::RuleError status = GuhCore::instance()->executeRuleExitActions(ruleId);
|
||||||
|
|
||||||
|
if (status != RuleEngine::RuleErrorNoError)
|
||||||
|
return createRuleErrorReply(HttpReply::InternalServerError, status);
|
||||||
|
|
||||||
|
return createRuleErrorReply(HttpReply::Ok, status);
|
||||||
|
}
|
||||||
|
|
||||||
HttpReply *RulesResource::editRule(const RuleId &ruleId, const QByteArray &payload) const
|
HttpReply *RulesResource::editRule(const RuleId &ruleId, const QByteArray &payload) const
|
||||||
{
|
{
|
||||||
qCDebug(dcRest) << "Edit rule with id" << ruleId.toString();
|
qCDebug(dcRest) << "Edit rule with id" << ruleId.toString();
|
||||||
|
|||||||
@ -64,6 +64,9 @@ private:
|
|||||||
HttpReply *addRule(const QByteArray &payload) const;
|
HttpReply *addRule(const QByteArray &payload) const;
|
||||||
HttpReply *enableRule(const RuleId &ruleId) const;
|
HttpReply *enableRule(const RuleId &ruleId) const;
|
||||||
HttpReply *disableRule(const RuleId &ruleId) const;
|
HttpReply *disableRule(const RuleId &ruleId) const;
|
||||||
|
HttpReply *executeActions(const RuleId &ruleId) const;
|
||||||
|
HttpReply *executeExitActions(const RuleId &ruleId) const;
|
||||||
|
|
||||||
|
|
||||||
// Put methods
|
// Put methods
|
||||||
HttpReply *editRule(const RuleId &ruleId, const QByteArray &payload) const;
|
HttpReply *editRule(const RuleId &ruleId, const QByteArray &payload) const;
|
||||||
|
|||||||
@ -52,7 +52,8 @@ Rule::Rule(const RuleId &id, const QString &name, const QList<EventDescriptor> &
|
|||||||
m_stateEvaluator(stateEvaluator),
|
m_stateEvaluator(stateEvaluator),
|
||||||
m_actions(actions),
|
m_actions(actions),
|
||||||
m_enabled(false),
|
m_enabled(false),
|
||||||
m_active(false)
|
m_active(false),
|
||||||
|
m_executable(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -66,7 +67,8 @@ Rule::Rule(const RuleId &id, const QString &name, const QList<EventDescriptor> &
|
|||||||
m_actions(actions),
|
m_actions(actions),
|
||||||
m_exitActions(exitActions),
|
m_exitActions(exitActions),
|
||||||
m_enabled(false),
|
m_enabled(false),
|
||||||
m_active(false)
|
m_active(false),
|
||||||
|
m_executable(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +82,8 @@ Rule::Rule(const RuleId &id, const QString &name, const StateEvaluator &stateEva
|
|||||||
m_actions(actions),
|
m_actions(actions),
|
||||||
m_exitActions(exitActions),
|
m_exitActions(exitActions),
|
||||||
m_enabled(false),
|
m_enabled(false),
|
||||||
m_active(false)
|
m_active(false),
|
||||||
|
m_executable(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,13 +123,13 @@ QString Rule::name() const
|
|||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Returns wheter the rule is enabled or not. */
|
/*! Returns true if the rule is enabled. */
|
||||||
bool Rule::enabled() const {
|
bool Rule::enabled() const {
|
||||||
return m_enabled;
|
return m_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Set the disabled flag of this rule. In order to actually disable the rule you still need to
|
/*! Set the \a enabled flag of this rule. In order to actually enable/disable the rule you still need to
|
||||||
* update the RulesEngine */
|
* update the \l{RulesEngine} */
|
||||||
void Rule::setEnabled(bool enabled)
|
void Rule::setEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
m_enabled = enabled;
|
m_enabled = enabled;
|
||||||
@ -138,6 +141,18 @@ bool Rule::active() const
|
|||||||
return m_active;
|
return m_active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Set the rule \a executable. */
|
||||||
|
void Rule::setExecutable(const bool &executable)
|
||||||
|
{
|
||||||
|
m_executable = executable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Returns true if the rule is executable. */
|
||||||
|
bool Rule::executable() const
|
||||||
|
{
|
||||||
|
return m_executable;
|
||||||
|
}
|
||||||
|
|
||||||
void Rule::setName(const QString &name)
|
void Rule::setName(const QString &name)
|
||||||
{
|
{
|
||||||
m_name = name;
|
m_name = name;
|
||||||
|
|||||||
@ -51,6 +51,9 @@ public:
|
|||||||
|
|
||||||
bool active() const;
|
bool active() const;
|
||||||
|
|
||||||
|
void setExecutable(const bool &executable);
|
||||||
|
bool executable() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class RuleEngine;
|
friend class RuleEngine;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
@ -66,6 +69,7 @@ private:
|
|||||||
|
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
bool m_active;
|
bool m_active;
|
||||||
|
bool m_executable;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,6 +110,7 @@ RuleEngine::RuleEngine(QObject *parent) :
|
|||||||
|
|
||||||
QString name = settings.value("name", idString).toString();
|
QString name = settings.value("name", idString).toString();
|
||||||
bool enabled = settings.value("enabled", true).toBool();
|
bool enabled = settings.value("enabled", true).toBool();
|
||||||
|
bool executable = settings.value("executable", true).toBool();
|
||||||
|
|
||||||
qCDebug(dcRuleEngine) << "load rule" << name << idString;
|
qCDebug(dcRuleEngine) << "load rule" << name << idString;
|
||||||
|
|
||||||
@ -195,6 +196,7 @@ RuleEngine::RuleEngine(QObject *parent) :
|
|||||||
|
|
||||||
Rule rule = Rule(RuleId(idString), name, eventDescriptorList, stateEvaluator, actions, exitActions);
|
Rule rule = Rule(RuleId(idString), name, eventDescriptorList, stateEvaluator, actions, exitActions);
|
||||||
rule.setEnabled(enabled);
|
rule.setEnabled(enabled);
|
||||||
|
rule.setExecutable(executable);
|
||||||
appendRule(rule);
|
appendRule(rule);
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
@ -265,7 +267,7 @@ RuleEngine::RuleError RuleEngine::addRule(const RuleId &ruleId, const QString &n
|
|||||||
/*! Add a new \l{Rule} with the given \a ruleId, \a name, \a eventDescriptorList, \a stateEvaluator, the list of \a actions the list of \a exitActions and the \a enabled value to the engine.
|
/*! Add a new \l{Rule} with the given \a ruleId, \a name, \a eventDescriptorList, \a stateEvaluator, the list of \a actions the list of \a exitActions and the \a enabled value to the engine.
|
||||||
If \a fromEdit is true, the notification Rules.RuleAdded will not be emitted.
|
If \a fromEdit is true, the notification Rules.RuleAdded will not be emitted.
|
||||||
*/
|
*/
|
||||||
RuleEngine::RuleError RuleEngine::addRule(const RuleId &ruleId, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actions, const QList<RuleAction> &exitActions, bool enabled, bool fromEdit)
|
RuleEngine::RuleError RuleEngine::addRule(const RuleId &ruleId, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actions, const QList<RuleAction> &exitActions, bool enabled, bool executable, bool fromEdit)
|
||||||
{
|
{
|
||||||
if (ruleId.isNull()) {
|
if (ruleId.isNull()) {
|
||||||
return RuleErrorInvalidRuleId;
|
return RuleErrorInvalidRuleId;
|
||||||
@ -343,6 +345,7 @@ RuleEngine::RuleError RuleEngine::addRule(const RuleId &ruleId, const QString &n
|
|||||||
|
|
||||||
Rule rule = Rule(ruleId, name, eventDescriptorList, stateEvaluator, actions, exitActions);
|
Rule rule = Rule(ruleId, name, eventDescriptorList, stateEvaluator, actions, exitActions);
|
||||||
rule.setEnabled(enabled);
|
rule.setEnabled(enabled);
|
||||||
|
rule.setExecutable(executable);
|
||||||
appendRule(rule);
|
appendRule(rule);
|
||||||
saveRule(rule);
|
saveRule(rule);
|
||||||
if (!fromEdit)
|
if (!fromEdit)
|
||||||
@ -354,13 +357,13 @@ RuleEngine::RuleError RuleEngine::addRule(const RuleId &ruleId, const QString &n
|
|||||||
/*! Edit a \l{Rule} with the given \a ruleId, \a name, \a eventDescriptorList, \a stateEvaluator,
|
/*! Edit a \l{Rule} with the given \a ruleId, \a name, \a eventDescriptorList, \a stateEvaluator,
|
||||||
the list of \a actions the list of \a exitActions and the \a enabled in the engine.
|
the list of \a actions the list of \a exitActions and the \a enabled in the engine.
|
||||||
*/
|
*/
|
||||||
RuleEngine::RuleError RuleEngine::editRule(const RuleId &ruleId, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actions, const QList<RuleAction> &exitActions, bool enabled)
|
RuleEngine::RuleError RuleEngine::editRule(const RuleId &ruleId, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actions, const QList<RuleAction> &exitActions, bool enabled, bool executable)
|
||||||
{
|
{
|
||||||
if (ruleId.isNull()) {
|
if (ruleId.isNull())
|
||||||
return RuleErrorInvalidRuleId;
|
return RuleErrorInvalidRuleId;
|
||||||
}
|
|
||||||
|
|
||||||
// store rule in case the add new rule fails
|
|
||||||
|
// Store rule in case the add new rule fails
|
||||||
Rule rule = findRule(ruleId);
|
Rule rule = findRule(ruleId);
|
||||||
|
|
||||||
if (rule.id().isNull()) {
|
if (rule.id().isNull()) {
|
||||||
@ -368,15 +371,15 @@ RuleEngine::RuleError RuleEngine::editRule(const RuleId &ruleId, const QString &
|
|||||||
return RuleErrorRuleNotFound;
|
return RuleErrorRuleNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
// first remove old rule with this id
|
// First remove old rule with this id
|
||||||
RuleError removeResult = removeRule(ruleId, true);
|
RuleError removeResult = removeRule(ruleId, true);
|
||||||
if (removeResult != RuleErrorNoError) {
|
if (removeResult != RuleErrorNoError) {
|
||||||
// no need to restore, rule is still in system
|
// no need to restore, rule is still in system
|
||||||
return removeResult;
|
return removeResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the rule is removed, now add it with the same id and new vonfiguration
|
// The rule is removed, now add it with the same id and new vonfiguration
|
||||||
RuleError addResult = addRule(ruleId, name, eventDescriptorList, stateEvaluator, actions, exitActions, enabled, true);
|
RuleError addResult = addRule(ruleId, name, eventDescriptorList, stateEvaluator, actions, exitActions, enabled, executable, true);
|
||||||
if (addResult != RuleErrorNoError) {
|
if (addResult != RuleErrorNoError) {
|
||||||
// restore rule
|
// restore rule
|
||||||
appendRule(rule);
|
appendRule(rule);
|
||||||
@ -468,6 +471,62 @@ RuleEngine::RuleError RuleEngine::disableRule(const RuleId &ruleId)
|
|||||||
return RuleErrorNoError;
|
return RuleErrorNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RuleEngine::RuleError RuleEngine::executeActions(const RuleId &ruleId)
|
||||||
|
{
|
||||||
|
// check if rule exits
|
||||||
|
if (!m_rules.contains(ruleId)) {
|
||||||
|
qCWarning(dcRuleEngine) << "Not executing rule actions: rule not found.";
|
||||||
|
return RuleErrorRuleNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rule rule = m_rules.value(ruleId);
|
||||||
|
|
||||||
|
// check if rule is executable
|
||||||
|
if (!rule.executable()) {
|
||||||
|
qCWarning(dcRuleEngine) << "Not executing rule actions: rule is not executable.";
|
||||||
|
return RuleErrorNotExecutable;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if an Action is eventBased
|
||||||
|
foreach (const RuleAction &ruleAction, rule.actions()) {
|
||||||
|
if (ruleAction.isEventBased()) {
|
||||||
|
qCWarning(dcRuleEngine) << "Not executing rule actions: rule action depends on an event:" << ruleAction.actionTypeId() << ruleAction.ruleActionParams();
|
||||||
|
return RuleErrorContainsEventBasesAction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qCDebug(dcRuleEngine) << "Executing rule actions of rule" << rule.name() << rule.id();
|
||||||
|
GuhCore::instance()->executeRuleActions(rule.actions());
|
||||||
|
return RuleErrorNoError;
|
||||||
|
}
|
||||||
|
|
||||||
|
RuleEngine::RuleError RuleEngine::executeExitActions(const RuleId &ruleId)
|
||||||
|
{
|
||||||
|
// check if rule exits
|
||||||
|
if (!m_rules.contains(ruleId)) {
|
||||||
|
qCWarning(dcRuleEngine) << "Not executing rule exit actions: rule not found.";
|
||||||
|
return RuleErrorRuleNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rule rule = m_rules.value(ruleId);
|
||||||
|
|
||||||
|
// check if rule is executable
|
||||||
|
if (!rule.executable()) {
|
||||||
|
qCWarning(dcRuleEngine) << "Not executing rule exit actions: rule is not executable.";
|
||||||
|
return RuleErrorNotExecutable;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rule.exitActions().isEmpty()) {
|
||||||
|
qCWarning(dcRuleEngine) << "Not executing rule exit actions: rule has no exit actions.";
|
||||||
|
return RuleErrorNoExitActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
qCDebug(dcRuleEngine) << "Executing rule exit actions of rule" << rule.name() << rule.id();
|
||||||
|
GuhCore::instance()->executeRuleActions(rule.exitActions());
|
||||||
|
return RuleErrorNoError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! Returns the \l{Rule} with the given \a ruleId. If the \l{Rule} does not exist, it will return \l{Rule::Rule()} */
|
/*! Returns the \l{Rule} with the given \a ruleId. If the \l{Rule} does not exist, it will return \l{Rule::Rule()} */
|
||||||
Rule RuleEngine::findRule(const RuleId &ruleId)
|
Rule RuleEngine::findRule(const RuleId &ruleId)
|
||||||
{
|
{
|
||||||
@ -580,6 +639,7 @@ void RuleEngine::saveRule(const Rule &rule)
|
|||||||
settings.beginGroup(rule.id().toString());
|
settings.beginGroup(rule.id().toString());
|
||||||
settings.setValue("name", rule.name());
|
settings.setValue("name", rule.name());
|
||||||
settings.setValue("enabled", rule.enabled());
|
settings.setValue("enabled", rule.enabled());
|
||||||
|
settings.setValue("executable", rule.executable());
|
||||||
settings.beginGroup("events");
|
settings.beginGroup("events");
|
||||||
for (int i = 0; i < rule.eventDescriptors().count(); i++) {
|
for (int i = 0; i < rule.eventDescriptors().count(); i++) {
|
||||||
const EventDescriptor &eventDescriptor = rule.eventDescriptors().at(i);
|
const EventDescriptor &eventDescriptor = rule.eventDescriptors().at(i);
|
||||||
|
|||||||
@ -49,7 +49,10 @@ public:
|
|||||||
RuleErrorInvalidRuleFormat,
|
RuleErrorInvalidRuleFormat,
|
||||||
RuleErrorMissingParameter,
|
RuleErrorMissingParameter,
|
||||||
RuleErrorInvalidRuleActionParameter,
|
RuleErrorInvalidRuleActionParameter,
|
||||||
RuleErrorTypesNotMatching
|
RuleErrorTypesNotMatching,
|
||||||
|
RuleErrorNotExecutable,
|
||||||
|
RuleErrorContainsEventBasesAction,
|
||||||
|
RuleErrorNoExitActions
|
||||||
};
|
};
|
||||||
|
|
||||||
enum RemovePolicy {
|
enum RemovePolicy {
|
||||||
@ -62,9 +65,8 @@ public:
|
|||||||
QList<Rule> evaluateEvent(const Event &event);
|
QList<Rule> evaluateEvent(const Event &event);
|
||||||
|
|
||||||
RuleError addRule(const RuleId &ruleId, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const QList<RuleAction> &actions, bool enabled = true);
|
RuleError addRule(const RuleId &ruleId, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const QList<RuleAction> &actions, bool enabled = true);
|
||||||
RuleError addRule(const RuleId &ruleId, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actions, const QList<RuleAction> &exitActions, bool enabled = true, bool fromEdit = false);
|
RuleError addRule(const RuleId &ruleId, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actions, const QList<RuleAction> &exitActions, bool enabled = true, bool executable = true, bool fromEdit = false);
|
||||||
RuleError editRule(const RuleId &ruleId, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actions, const QList<RuleAction> &exitActions, bool enabled = true);
|
RuleError editRule(const RuleId &ruleId, const QString &name, const QList<EventDescriptor> &eventDescriptorList, const StateEvaluator &stateEvaluator, const QList<RuleAction> &actions, const QList<RuleAction> &exitActions, bool enabled = true, bool executable = true);
|
||||||
|
|
||||||
|
|
||||||
QList<Rule> rules() const;
|
QList<Rule> rules() const;
|
||||||
QList<RuleId> ruleIds() const;
|
QList<RuleId> ruleIds() const;
|
||||||
@ -74,6 +76,9 @@ public:
|
|||||||
RuleError enableRule(const RuleId &ruleId);
|
RuleError enableRule(const RuleId &ruleId);
|
||||||
RuleError disableRule(const RuleId &ruleId);
|
RuleError disableRule(const RuleId &ruleId);
|
||||||
|
|
||||||
|
RuleError executeActions(const RuleId &ruleId);
|
||||||
|
RuleError executeExitActions(const RuleId &ruleId);
|
||||||
|
|
||||||
Rule findRule(const RuleId &ruleId);
|
Rule findRule(const RuleId &ruleId);
|
||||||
QList<RuleId> findRules(const DeviceId &deviceId);
|
QList<RuleId> findRules(const DeviceId &deviceId);
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
30
|
31
|
||||||
{
|
{
|
||||||
"methods": {
|
"methods": {
|
||||||
"Actions.ExecuteAction": {
|
"Actions.ExecuteAction": {
|
||||||
@ -322,6 +322,7 @@
|
|||||||
"o:eventDescriptorList": [
|
"o:eventDescriptorList": [
|
||||||
"$ref:EventDescriptor"
|
"$ref:EventDescriptor"
|
||||||
],
|
],
|
||||||
|
"o:executable": "Bool",
|
||||||
"o:exitActions": [
|
"o:exitActions": [
|
||||||
"$ref:RuleAction"
|
"$ref:RuleAction"
|
||||||
],
|
],
|
||||||
@ -353,6 +354,7 @@
|
|||||||
"o:eventDescriptorList": [
|
"o:eventDescriptorList": [
|
||||||
"$ref:EventDescriptor"
|
"$ref:EventDescriptor"
|
||||||
],
|
],
|
||||||
|
"o:executable": "Bool",
|
||||||
"o:exitActions": [
|
"o:exitActions": [
|
||||||
"$ref:RuleAction"
|
"$ref:RuleAction"
|
||||||
],
|
],
|
||||||
@ -373,6 +375,24 @@
|
|||||||
"ruleError": "$ref:RuleError"
|
"ruleError": "$ref:RuleError"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Rules.ExecuteActions": {
|
||||||
|
"description": "Execute the action list of the rule with the given ruleId.",
|
||||||
|
"params": {
|
||||||
|
"ruleId": "Uuid"
|
||||||
|
},
|
||||||
|
"returns": {
|
||||||
|
"ruleError": "$ref:RuleError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Rules.ExecuteExitActions": {
|
||||||
|
"description": "Execute the exit action list of the rule with the given ruleId.",
|
||||||
|
"params": {
|
||||||
|
"ruleId": "Uuid"
|
||||||
|
},
|
||||||
|
"returns": {
|
||||||
|
"ruleError": "$ref:RuleError"
|
||||||
|
}
|
||||||
|
},
|
||||||
"Rules.FindRules": {
|
"Rules.FindRules": {
|
||||||
"description": "Find a list of rules containing any of the given parameters.",
|
"description": "Find a list of rules containing any of the given parameters.",
|
||||||
"params": {
|
"params": {
|
||||||
@ -638,7 +658,9 @@
|
|||||||
],
|
],
|
||||||
"LoggingEventType": [
|
"LoggingEventType": [
|
||||||
"LoggingEventTypeTrigger",
|
"LoggingEventTypeTrigger",
|
||||||
"LoggingEventTypeActiveChange"
|
"LoggingEventTypeActiveChange",
|
||||||
|
"LoggingEventTypeActionsExecuted",
|
||||||
|
"LoggingEventTypeExitActionsExecuted"
|
||||||
],
|
],
|
||||||
"LoggingLevel": [
|
"LoggingLevel": [
|
||||||
"LoggingLevelInfo",
|
"LoggingLevelInfo",
|
||||||
@ -693,6 +715,7 @@
|
|||||||
"eventDescriptors": [
|
"eventDescriptors": [
|
||||||
"$ref:EventDescriptor"
|
"$ref:EventDescriptor"
|
||||||
],
|
],
|
||||||
|
"executable": "Bool",
|
||||||
"exitActions": [
|
"exitActions": [
|
||||||
"$ref:RuleAction"
|
"$ref:RuleAction"
|
||||||
],
|
],
|
||||||
@ -716,6 +739,7 @@
|
|||||||
"RuleDescription": {
|
"RuleDescription": {
|
||||||
"active": "Bool",
|
"active": "Bool",
|
||||||
"enabled": "Bool",
|
"enabled": "Bool",
|
||||||
|
"executable": "Bool",
|
||||||
"id": "Uuid",
|
"id": "Uuid",
|
||||||
"name": "String"
|
"name": "String"
|
||||||
},
|
},
|
||||||
@ -730,7 +754,10 @@
|
|||||||
"RuleErrorInvalidRuleFormat",
|
"RuleErrorInvalidRuleFormat",
|
||||||
"RuleErrorMissingParameter",
|
"RuleErrorMissingParameter",
|
||||||
"RuleErrorInvalidRuleActionParameter",
|
"RuleErrorInvalidRuleActionParameter",
|
||||||
"RuleErrorTypesNotMatching"
|
"RuleErrorTypesNotMatching",
|
||||||
|
"RuleErrorNotExecutable",
|
||||||
|
"RuleErrorContainsEventBasesAction",
|
||||||
|
"RuleErrorNoExitActions"
|
||||||
],
|
],
|
||||||
"SetupMethod": [
|
"SetupMethod": [
|
||||||
"SetupMethodJustAdd",
|
"SetupMethodJustAdd",
|
||||||
|
|||||||
Reference in New Issue
Block a user