Fixes event based params in rule actions editing
This commit is contained in:
parent
e882cb6794
commit
f8d46f5c64
@ -219,7 +219,7 @@ void NymeaConfiguration::deleteMqttPolicy(const QString &clientId)
|
||||
|
||||
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();
|
||||
m_debugServerEnabled = basicConfig.value("debugServerEnabled").toBool();
|
||||
emit debugServerEnabledChanged();
|
||||
@ -328,7 +328,7 @@ void NymeaConfiguration::deleteMqttConfigReply(const QVariantMap ¶ms)
|
||||
|
||||
void NymeaConfiguration::getMqttPoliciesReply(const QVariantMap ¶ms)
|
||||
{
|
||||
qDebug() << "Mqtt polices:" << params;
|
||||
// qDebug() << "Mqtt polices:" << params;
|
||||
m_mqttPolicies->clear();
|
||||
foreach (const QVariant &policyVariant, params.value("params").toMap().value("mqttPolicies").toList()) {
|
||||
QVariantMap policyMap = policyVariant.toMap();
|
||||
|
||||
@ -154,15 +154,16 @@ void RuleManager::getRuleDetailsReply(const QVariantMap ¶ms)
|
||||
QVariantMap ruleMap = params.value("params").toMap().value("rule").toMap();
|
||||
Rule* rule = m_rules->getRule(ruleMap.value("id").toUuid());
|
||||
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;
|
||||
}
|
||||
// qDebug() << "got rule details for rule" << qUtf8Printable(QJsonDocument::fromVariant(ruleMap).toJson());
|
||||
parseEventDescriptors(ruleMap.value("eventDescriptors").toList(), rule);
|
||||
parseRuleActions(ruleMap.value("actions").toList(), rule);
|
||||
parseRuleExitActions(ruleMap.value("exitActions").toList(), rule);
|
||||
parseTimeDescriptor(ruleMap.value("timeDescriptor").toMap(), rule);
|
||||
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)
|
||||
@ -179,7 +180,12 @@ void RuleManager::removeRuleReply(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());
|
||||
}
|
||||
|
||||
@ -232,7 +238,7 @@ void RuleManager::parseEventDescriptors(const QVariantList &eventDescriptorList,
|
||||
|
||||
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")) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -12,6 +12,8 @@
|
||||
#include "timeeventitem.h"
|
||||
#include "calendaritems.h"
|
||||
#include "calendaritem.h"
|
||||
#include "ruleactionparams.h"
|
||||
#include "ruleactionparam.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@ -167,13 +169,40 @@ QDebug operator <<(QDebug &dbg, Rule *rule)
|
||||
EventDescriptor *ed = rule->eventDescriptors()->get(i);
|
||||
dbg << " " << i << ":";
|
||||
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 {
|
||||
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;
|
||||
printStateEvaluator(dbg, rule->stateEvaluator());
|
||||
if (rule->stateEvaluator()) {
|
||||
dbg << "State Evaluator:" << endl;
|
||||
printStateEvaluator(dbg, rule->stateEvaluator());
|
||||
}
|
||||
|
||||
if (rule->actions()->rowCount() > 0) {
|
||||
dbg << "Actions:" << endl;
|
||||
@ -182,9 +211,17 @@ QDebug operator <<(QDebug &dbg, Rule *rule)
|
||||
RuleAction *ra = rule->actions()->get(i);
|
||||
dbg << " " << i << ":";
|
||||
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 {
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
@ -209,9 +254,9 @@ QDebug printStateEvaluator(QDebug &dbg, StateEvaluator *stateEvaluator, int inde
|
||||
for (int i = 0; i < indentLevel; i++) { dbg << " "; }
|
||||
dbg << "State Descriptor:";
|
||||
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 {
|
||||
dbg << "Interface name:" << stateEvaluator->stateDescriptor()->interfaceName() << stateEvaluator->stateDescriptor()->interfaceState();
|
||||
dbg << "Interface name:" << stateEvaluator->stateDescriptor()->interfaceName() << "State Name:" << stateEvaluator->stateDescriptor()->interfaceState();
|
||||
}
|
||||
switch (stateEvaluator->stateDescriptor()->valueOperator()) {
|
||||
case StateDescriptor::ValueOperatorLess:
|
||||
|
||||
@ -57,5 +57,7 @@ RuleActionParam *RuleActionParam::clone() const
|
||||
ret->setParamTypeId(paramTypeId());
|
||||
ret->setParamName(paramName());
|
||||
ret->setValue(value());
|
||||
ret->setEventTypeId(eventTypeId());
|
||||
ret->setEventParamTypeId(eventParamTypeId());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ MeaListItemDelegate {
|
||||
canDelete: true
|
||||
progressive: false
|
||||
|
||||
property var ruleAction: null
|
||||
property RuleAction ruleAction: null
|
||||
|
||||
property var device: ruleAction.deviceId ? engine.deviceManager.devices.getDevice(ruleAction.deviceId) : null
|
||||
property var iface: ruleAction.interfaceName ? Interfaces.findByName(ruleAction.interfaceName) : null
|
||||
@ -28,6 +28,7 @@ MeaListItemDelegate {
|
||||
var ret = [];
|
||||
for (var i = 0; i < root.ruleAction.ruleActionParams.count; i++) {
|
||||
var ruleActionParam = root.ruleAction.ruleActionParams.get(i)
|
||||
print("populating subtext:", ruleActionParam.eventTypeId, ruleActionParam.eventParamTypeId)
|
||||
var paramString = qsTr("%1: %2")
|
||||
.arg(root.actionType.paramTypes.getParamType(ruleActionParam.paramTypeId).displayName)
|
||||
.arg(ruleActionParam.eventParamTypeId.length > 0 ? qsTr("value from event") : ruleActionParam.value)
|
||||
|
||||
Reference in New Issue
Block a user