Merge PR #99: Fixes event based params in rule actions editing
This commit is contained in:
commit
f79f278a9a
@ -219,7 +219,7 @@ void NymeaConfiguration::deleteMqttPolicy(const QString &clientId)
|
|||||||
|
|
||||||
void NymeaConfiguration::getConfigurationsResponse(const QVariantMap ¶ms)
|
void NymeaConfiguration::getConfigurationsResponse(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
qDebug() << "have config reply" << params;
|
// qDebug() << "have config reply" << params;
|
||||||
QVariantMap basicConfig = params.value("params").toMap().value("basicConfiguration").toMap();
|
QVariantMap basicConfig = params.value("params").toMap().value("basicConfiguration").toMap();
|
||||||
m_debugServerEnabled = basicConfig.value("debugServerEnabled").toBool();
|
m_debugServerEnabled = basicConfig.value("debugServerEnabled").toBool();
|
||||||
emit debugServerEnabledChanged();
|
emit debugServerEnabledChanged();
|
||||||
@ -328,7 +328,7 @@ void NymeaConfiguration::deleteMqttConfigReply(const QVariantMap ¶ms)
|
|||||||
|
|
||||||
void NymeaConfiguration::getMqttPoliciesReply(const QVariantMap ¶ms)
|
void NymeaConfiguration::getMqttPoliciesReply(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
qDebug() << "Mqtt polices:" << params;
|
// qDebug() << "Mqtt polices:" << params;
|
||||||
m_mqttPolicies->clear();
|
m_mqttPolicies->clear();
|
||||||
foreach (const QVariant &policyVariant, params.value("params").toMap().value("mqttPolicies").toList()) {
|
foreach (const QVariant &policyVariant, params.value("params").toMap().value("mqttPolicies").toList()) {
|
||||||
QVariantMap policyMap = policyVariant.toMap();
|
QVariantMap policyMap = policyVariant.toMap();
|
||||||
|
|||||||
@ -154,15 +154,16 @@ void RuleManager::getRuleDetailsReply(const QVariantMap ¶ms)
|
|||||||
QVariantMap ruleMap = params.value("params").toMap().value("rule").toMap();
|
QVariantMap ruleMap = params.value("params").toMap().value("rule").toMap();
|
||||||
Rule* rule = m_rules->getRule(ruleMap.value("id").toUuid());
|
Rule* rule = m_rules->getRule(ruleMap.value("id").toUuid());
|
||||||
if (!rule) {
|
if (!rule) {
|
||||||
qDebug() << "Got rule details for a rule we don't know";
|
qWarning() << "Got rule details for a rule we don't know";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// qDebug() << "got rule details for rule" << qUtf8Printable(QJsonDocument::fromVariant(ruleMap).toJson());
|
|
||||||
parseEventDescriptors(ruleMap.value("eventDescriptors").toList(), rule);
|
parseEventDescriptors(ruleMap.value("eventDescriptors").toList(), rule);
|
||||||
parseRuleActions(ruleMap.value("actions").toList(), rule);
|
parseRuleActions(ruleMap.value("actions").toList(), rule);
|
||||||
parseRuleExitActions(ruleMap.value("exitActions").toList(), rule);
|
parseRuleExitActions(ruleMap.value("exitActions").toList(), rule);
|
||||||
parseTimeDescriptor(ruleMap.value("timeDescriptor").toMap(), rule);
|
parseTimeDescriptor(ruleMap.value("timeDescriptor").toMap(), rule);
|
||||||
rule->setStateEvaluator(parseStateEvaluator(ruleMap.value("stateEvaluator").toMap()));
|
rule->setStateEvaluator(parseStateEvaluator(ruleMap.value("stateEvaluator").toMap()));
|
||||||
|
qDebug() << "** Rule details received:" << rule;
|
||||||
|
// qDebug() << "Rule JSON:" << qUtf8Printable(QJsonDocument::fromVariant(ruleMap).toJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuleManager::onAddRuleReply(const QVariantMap ¶ms)
|
void RuleManager::onAddRuleReply(const QVariantMap ¶ms)
|
||||||
@ -179,7 +180,12 @@ void RuleManager::removeRuleReply(const QVariantMap ¶ms)
|
|||||||
|
|
||||||
void RuleManager::onEditRuleReply(const QVariantMap ¶ms)
|
void RuleManager::onEditRuleReply(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
qDebug() << "Edit rule reply:" << params.value("params").toMap().value("ruleError").toString();
|
if (params.value("status").toString() == "error") {
|
||||||
|
qDebug() << "Bad request editing rule:" << params.value("error").toString();
|
||||||
|
}
|
||||||
|
if (params.value("params").toMap().value("ruleError").toString() != "RuleErrorNoError") {
|
||||||
|
qDebug() << "Bad rule:" << params.value("params").toMap().value("ruleError").toString();
|
||||||
|
}
|
||||||
emit editRuleReply(params.value("params").toMap().value("ruleError").toString());
|
emit editRuleReply(params.value("params").toMap().value("ruleError").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +238,7 @@ void RuleManager::parseEventDescriptors(const QVariantList &eventDescriptorList,
|
|||||||
|
|
||||||
StateEvaluator *RuleManager::parseStateEvaluator(const QVariantMap &stateEvaluatorMap)
|
StateEvaluator *RuleManager::parseStateEvaluator(const QVariantMap &stateEvaluatorMap)
|
||||||
{
|
{
|
||||||
qDebug() << "Parsing state evaluator. Child count:" << stateEvaluatorMap.value("childEvaluators").toList().count();
|
// qDebug() << "Parsing state evaluator. Child count:" << stateEvaluatorMap.value("childEvaluators").toList().count();
|
||||||
if (!stateEvaluatorMap.contains("stateDescriptor")) {
|
if (!stateEvaluatorMap.contains("stateDescriptor")) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,8 @@
|
|||||||
#include "timeeventitem.h"
|
#include "timeeventitem.h"
|
||||||
#include "calendaritems.h"
|
#include "calendaritems.h"
|
||||||
#include "calendaritem.h"
|
#include "calendaritem.h"
|
||||||
|
#include "ruleactionparams.h"
|
||||||
|
#include "ruleactionparam.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@ -167,13 +169,40 @@ QDebug operator <<(QDebug &dbg, Rule *rule)
|
|||||||
EventDescriptor *ed = rule->eventDescriptors()->get(i);
|
EventDescriptor *ed = rule->eventDescriptors()->get(i);
|
||||||
dbg << " " << i << ":";
|
dbg << " " << i << ":";
|
||||||
if (!ed->deviceId().isNull() && !ed->eventTypeId().isNull()) {
|
if (!ed->deviceId().isNull() && !ed->eventTypeId().isNull()) {
|
||||||
dbg << "Device ID:" << ed->deviceId() << "Event Type ID:" << ed->eventTypeId() << endl;;
|
dbg << "Device ID:" << ed->deviceId() << "Event Type ID:" << ed->eventTypeId() << endl;
|
||||||
} else {
|
} else {
|
||||||
dbg << "Interface Name:" << ed->interfaceName() << "Event Name:" << ed->interfaceEvent() << endl;;
|
dbg << "Interface Name:" << ed->interfaceName() << "Event Name:" << ed->interfaceEvent() << endl;
|
||||||
|
}
|
||||||
|
for (int j = 0; j < ed->paramDescriptors()->rowCount(); j++) {
|
||||||
|
ParamDescriptor *epd = ed->paramDescriptors()->get(j);
|
||||||
|
QString operatorString;
|
||||||
|
switch (epd->operatorType()) {
|
||||||
|
case ParamDescriptor::ValueOperatorLess:
|
||||||
|
operatorString = "<";
|
||||||
|
break;
|
||||||
|
case ParamDescriptor::ValueOperatorEquals:
|
||||||
|
operatorString = "=";
|
||||||
|
break;
|
||||||
|
case ParamDescriptor::ValueOperatorGreater:
|
||||||
|
operatorString = ">";
|
||||||
|
break;
|
||||||
|
case ParamDescriptor::ValueOperatorNotEquals:
|
||||||
|
operatorString = "!=";
|
||||||
|
break;
|
||||||
|
case ParamDescriptor::ValueOperatorLessOrEqual:
|
||||||
|
operatorString = "<=";
|
||||||
|
break;
|
||||||
|
case ParamDescriptor::ValueOperatorGreaterOrEqual:
|
||||||
|
operatorString = ">=";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dbg << " Param" << j << ": ID:" << epd->paramTypeId() << operatorString << " Value:" << epd->value() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dbg << "State Evaluator:" << endl;
|
if (rule->stateEvaluator()) {
|
||||||
printStateEvaluator(dbg, rule->stateEvaluator());
|
dbg << "State Evaluator:" << endl;
|
||||||
|
printStateEvaluator(dbg, rule->stateEvaluator());
|
||||||
|
}
|
||||||
|
|
||||||
if (rule->actions()->rowCount() > 0) {
|
if (rule->actions()->rowCount() > 0) {
|
||||||
dbg << "Actions:" << endl;
|
dbg << "Actions:" << endl;
|
||||||
@ -182,9 +211,17 @@ QDebug operator <<(QDebug &dbg, Rule *rule)
|
|||||||
RuleAction *ra = rule->actions()->get(i);
|
RuleAction *ra = rule->actions()->get(i);
|
||||||
dbg << " " << i << ":";
|
dbg << " " << i << ":";
|
||||||
if (!ra->deviceId().isNull() && !ra->actionTypeId().isNull()) {
|
if (!ra->deviceId().isNull() && !ra->actionTypeId().isNull()) {
|
||||||
dbg << "Device ID:" << ra->deviceId() << "Action Type ID:" << ra->actionTypeId() << endl;;
|
dbg << "Device ID:" << ra->deviceId() << "Action Type ID:" << ra->actionTypeId() << endl;
|
||||||
} else {
|
} else {
|
||||||
dbg << "Interface Name:" << ra->interfaceName() << "Action Name:" << ra->interfaceAction() << endl;;
|
dbg << "Interface Name:" << ra->interfaceName() << "Action Name:" << ra->interfaceAction() << endl;
|
||||||
|
}
|
||||||
|
for (int j = 0; j < ra->ruleActionParams()->rowCount(); j++) {
|
||||||
|
RuleActionParam *rap = ra->ruleActionParams()->get(j);
|
||||||
|
if (rap->eventTypeId().isNull()) {
|
||||||
|
dbg << " Param" << j << ": ID:" << rap->paramTypeId() << " Value:" << rap->value() << endl;
|
||||||
|
} else {
|
||||||
|
dbg << " Param" << j << ": ID:" << rap->paramTypeId() << " Source Event Type ID:" << rap->eventTypeId() << "Source Event Param ID:" << rap->eventParamTypeId() << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +236,14 @@ QDebug operator <<(QDebug &dbg, Rule *rule)
|
|||||||
} else {
|
} else {
|
||||||
dbg << "Interface Name:" << ra->interfaceName() << "Action Name:" << ra->interfaceAction() << endl;;
|
dbg << "Interface Name:" << ra->interfaceName() << "Action Name:" << ra->interfaceAction() << endl;;
|
||||||
}
|
}
|
||||||
|
for (int j = 0; j < ra->ruleActionParams()->rowCount(); j++) {
|
||||||
|
RuleActionParam *rap = ra->ruleActionParams()->get(j);
|
||||||
|
if (rap->eventTypeId().isNull()) {
|
||||||
|
dbg << " Param" << j << ": ID:" << rap->paramTypeId() << " Value:" << rap->value() << endl;
|
||||||
|
} else {
|
||||||
|
dbg << " Param" << j << ": ID:" << rap->paramTypeId() << " Source Event Type ID:" << rap->eventTypeId() << "Source Event Param ID:" << rap->eventParamTypeId() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return dbg;
|
return dbg;
|
||||||
}
|
}
|
||||||
@ -209,9 +254,9 @@ QDebug printStateEvaluator(QDebug &dbg, StateEvaluator *stateEvaluator, int inde
|
|||||||
for (int i = 0; i < indentLevel; i++) { dbg << " "; }
|
for (int i = 0; i < indentLevel; i++) { dbg << " "; }
|
||||||
dbg << "State Descriptor:";
|
dbg << "State Descriptor:";
|
||||||
if (!stateEvaluator->stateDescriptor()->deviceId().isNull() && !stateEvaluator->stateDescriptor()->stateTypeId().isNull()) {
|
if (!stateEvaluator->stateDescriptor()->deviceId().isNull() && !stateEvaluator->stateDescriptor()->stateTypeId().isNull()) {
|
||||||
dbg << "Device ID:" << stateEvaluator->stateDescriptor()->deviceId().toString() << stateEvaluator->stateDescriptor()->stateTypeId().toString();
|
dbg << "Device ID:" << stateEvaluator->stateDescriptor()->deviceId().toString() << "State Type ID:" << stateEvaluator->stateDescriptor()->stateTypeId().toString();
|
||||||
} else {
|
} else {
|
||||||
dbg << "Interface name:" << stateEvaluator->stateDescriptor()->interfaceName() << stateEvaluator->stateDescriptor()->interfaceState();
|
dbg << "Interface name:" << stateEvaluator->stateDescriptor()->interfaceName() << "State Name:" << stateEvaluator->stateDescriptor()->interfaceState();
|
||||||
}
|
}
|
||||||
switch (stateEvaluator->stateDescriptor()->valueOperator()) {
|
switch (stateEvaluator->stateDescriptor()->valueOperator()) {
|
||||||
case StateDescriptor::ValueOperatorLess:
|
case StateDescriptor::ValueOperatorLess:
|
||||||
|
|||||||
@ -57,5 +57,7 @@ RuleActionParam *RuleActionParam::clone() const
|
|||||||
ret->setParamTypeId(paramTypeId());
|
ret->setParamTypeId(paramTypeId());
|
||||||
ret->setParamName(paramName());
|
ret->setParamName(paramName());
|
||||||
ret->setValue(value());
|
ret->setValue(value());
|
||||||
|
ret->setEventTypeId(eventTypeId());
|
||||||
|
ret->setEventParamTypeId(eventParamTypeId());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ MeaListItemDelegate {
|
|||||||
canDelete: true
|
canDelete: true
|
||||||
progressive: false
|
progressive: false
|
||||||
|
|
||||||
property var ruleAction: null
|
property RuleAction ruleAction: null
|
||||||
|
|
||||||
property var device: ruleAction.deviceId ? engine.deviceManager.devices.getDevice(ruleAction.deviceId) : null
|
property var device: ruleAction.deviceId ? engine.deviceManager.devices.getDevice(ruleAction.deviceId) : null
|
||||||
property var iface: ruleAction.interfaceName ? Interfaces.findByName(ruleAction.interfaceName) : null
|
property var iface: ruleAction.interfaceName ? Interfaces.findByName(ruleAction.interfaceName) : null
|
||||||
@ -28,6 +28,7 @@ MeaListItemDelegate {
|
|||||||
var ret = [];
|
var ret = [];
|
||||||
for (var i = 0; i < root.ruleAction.ruleActionParams.count; i++) {
|
for (var i = 0; i < root.ruleAction.ruleActionParams.count; i++) {
|
||||||
var ruleActionParam = root.ruleAction.ruleActionParams.get(i)
|
var ruleActionParam = root.ruleAction.ruleActionParams.get(i)
|
||||||
|
print("populating subtext:", ruleActionParam.eventTypeId, ruleActionParam.eventParamTypeId)
|
||||||
var paramString = qsTr("%1: %2")
|
var paramString = qsTr("%1: %2")
|
||||||
.arg(root.actionType.paramTypes.getParamType(ruleActionParam.paramTypeId).displayName)
|
.arg(root.actionType.paramTypes.getParamType(ruleActionParam.paramTypeId).displayName)
|
||||||
.arg(ruleActionParam.eventParamTypeId.length > 0 ? qsTr("value from event") : ruleActionParam.value)
|
.arg(ruleActionParam.eventParamTypeId.length > 0 ? qsTr("value from event") : ruleActionParam.value)
|
||||||
|
|||||||
Reference in New Issue
Block a user