first work to add timedescriptor support, unfinished
This commit is contained in:
parent
613cea8c6f
commit
e0545ad01e
@ -44,7 +44,12 @@ HEADERS += types/types.h \
|
|||||||
types/paramdescriptor.h \
|
types/paramdescriptor.h \
|
||||||
types/paramdescriptors.h \
|
types/paramdescriptors.h \
|
||||||
types/interface.h \
|
types/interface.h \
|
||||||
types/interfaces.h
|
types/interfaces.h \
|
||||||
|
types/timedescriptor.h \
|
||||||
|
types/timeeventitem.h \
|
||||||
|
types/calendaritem.h \
|
||||||
|
types/timeeventitems.h \
|
||||||
|
types/calendaritems.h
|
||||||
|
|
||||||
SOURCES += types/vendor.cpp \
|
SOURCES += types/vendor.cpp \
|
||||||
types/vendors.cpp \
|
types/vendors.cpp \
|
||||||
@ -80,7 +85,12 @@ SOURCES += types/vendor.cpp \
|
|||||||
types/paramdescriptor.cpp \
|
types/paramdescriptor.cpp \
|
||||||
types/paramdescriptors.cpp \
|
types/paramdescriptors.cpp \
|
||||||
types/interface.cpp \
|
types/interface.cpp \
|
||||||
types/interfaces.cpp
|
types/interfaces.cpp \
|
||||||
|
types/timedescriptor.cpp \
|
||||||
|
types/timeeventitem.cpp \
|
||||||
|
types/calendaritem.cpp \
|
||||||
|
types/timeeventitems.cpp \
|
||||||
|
types/calendaritems.cpp
|
||||||
|
|
||||||
# install header file with relative subdirectory
|
# install header file with relative subdirectory
|
||||||
for(header, HEADERS) {
|
for(header, HEADERS) {
|
||||||
|
|||||||
6
libnymea-common/types/calendaritem.cpp
Normal file
6
libnymea-common/types/calendaritem.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "calendaritem.h"
|
||||||
|
|
||||||
|
CalendarItem::CalendarItem(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
17
libnymea-common/types/calendaritem.h
Normal file
17
libnymea-common/types/calendaritem.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef CALENDARITEM_H
|
||||||
|
#define CALENDARITEM_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class CalendarItem : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit CalendarItem(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CALENDARITEM_H
|
||||||
6
libnymea-common/types/calendaritems.cpp
Normal file
6
libnymea-common/types/calendaritems.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "calendaritems.h"
|
||||||
|
|
||||||
|
CalendarItems::CalendarItems(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
17
libnymea-common/types/calendaritems.h
Normal file
17
libnymea-common/types/calendaritems.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef CALENDARITEMS_H
|
||||||
|
#define CALENDARITEMS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class CalendarItems : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit CalendarItems(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CALENDARITEMS_H
|
||||||
@ -6,6 +6,7 @@
|
|||||||
#include "stateevaluators.h"
|
#include "stateevaluators.h"
|
||||||
#include "ruleaction.h"
|
#include "ruleaction.h"
|
||||||
#include "ruleactions.h"
|
#include "ruleactions.h"
|
||||||
|
#include "timedescriptor.h"
|
||||||
|
|
||||||
Rule::Rule(const QUuid &id, QObject *parent) :
|
Rule::Rule(const QUuid &id, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
@ -82,6 +83,11 @@ RuleActions *Rule::exitActions() const
|
|||||||
return m_exitActions;
|
return m_exitActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TimeDescriptor *Rule::timeDescriptor() const
|
||||||
|
{
|
||||||
|
return m_timeDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
void Rule::setStateEvaluator(StateEvaluator *stateEvaluator)
|
void Rule::setStateEvaluator(StateEvaluator *stateEvaluator)
|
||||||
{
|
{
|
||||||
if (m_stateEvaluator) {
|
if (m_stateEvaluator) {
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
class EventDescriptors;
|
class EventDescriptors;
|
||||||
class RuleActions;
|
class RuleActions;
|
||||||
class StateEvaluator;
|
class StateEvaluator;
|
||||||
|
class TimeDescriptor;
|
||||||
|
|
||||||
class Rule : public QObject
|
class Rule : public QObject
|
||||||
{
|
{
|
||||||
@ -19,6 +20,7 @@ class Rule : public QObject
|
|||||||
Q_PROPERTY(StateEvaluator* stateEvaluator READ stateEvaluator NOTIFY stateEvaluatorChanged)
|
Q_PROPERTY(StateEvaluator* stateEvaluator READ stateEvaluator NOTIFY stateEvaluatorChanged)
|
||||||
Q_PROPERTY(RuleActions* actions READ actions CONSTANT)
|
Q_PROPERTY(RuleActions* actions READ actions CONSTANT)
|
||||||
Q_PROPERTY(RuleActions* exitActions READ exitActions CONSTANT)
|
Q_PROPERTY(RuleActions* exitActions READ exitActions CONSTANT)
|
||||||
|
Q_PROPERTY(TimeDescriptor* timeDescriptor READ timeDescriptor CONSTANT)
|
||||||
public:
|
public:
|
||||||
explicit Rule(const QUuid &id = QUuid(), QObject *parent = nullptr);
|
explicit Rule(const QUuid &id = QUuid(), QObject *parent = nullptr);
|
||||||
|
|
||||||
@ -37,6 +39,7 @@ public:
|
|||||||
StateEvaluator *stateEvaluator() const;
|
StateEvaluator *stateEvaluator() const;
|
||||||
RuleActions* actions() const;
|
RuleActions* actions() const;
|
||||||
RuleActions* exitActions() const;
|
RuleActions* exitActions() const;
|
||||||
|
TimeDescriptor* timeDescriptor() const;
|
||||||
|
|
||||||
void setStateEvaluator(StateEvaluator* stateEvaluator);
|
void setStateEvaluator(StateEvaluator* stateEvaluator);
|
||||||
|
|
||||||
@ -59,6 +62,7 @@ private:
|
|||||||
StateEvaluator *m_stateEvaluator = nullptr;
|
StateEvaluator *m_stateEvaluator = nullptr;
|
||||||
RuleActions *m_actions = nullptr;
|
RuleActions *m_actions = nullptr;
|
||||||
RuleActions *m_exitActions = nullptr;
|
RuleActions *m_exitActions = nullptr;
|
||||||
|
TimeDescriptor *m_timeDescriptor = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RULE_H
|
#endif // RULE_H
|
||||||
|
|||||||
6
libnymea-common/types/timedescriptor.cpp
Normal file
6
libnymea-common/types/timedescriptor.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "timedescriptor.h"
|
||||||
|
|
||||||
|
TimeDescriptor::TimeDescriptor(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
17
libnymea-common/types/timedescriptor.h
Normal file
17
libnymea-common/types/timedescriptor.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef TIMEDESCRIPTOR_H
|
||||||
|
#define TIMEDESCRIPTOR_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class TimeDescriptor : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TimeDescriptor(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TIMEDESCRIPTOR_H
|
||||||
32
libnymea-common/types/timeeventitem.cpp
Normal file
32
libnymea-common/types/timeeventitem.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include "timeeventitem.h"
|
||||||
|
|
||||||
|
TimeEventItem::TimeEventItem(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QDateTime TimeEventItem::dateTime() const
|
||||||
|
{
|
||||||
|
return m_dateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimeEventItem::setDateTime(const QDateTime &dateTime)
|
||||||
|
{
|
||||||
|
if (m_dateTime != dateTime) {
|
||||||
|
m_dateTime = dateTime;
|
||||||
|
emit dateTimeChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime TimeEventItem::time() const
|
||||||
|
{
|
||||||
|
return m_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimeEventItem::setTime(const QTime &time)
|
||||||
|
{
|
||||||
|
if (m_time != time) {
|
||||||
|
m_time = time;
|
||||||
|
emit timeChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
33
libnymea-common/types/timeeventitem.h
Normal file
33
libnymea-common/types/timeeventitem.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef TIMEEVENTITEM_H
|
||||||
|
#define TIMEEVENTITEM_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
|
class TimeEventItem : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY dateTimeChanged)
|
||||||
|
Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY timeChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit TimeEventItem(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
QDateTime dateTime() const;
|
||||||
|
void setDateTime(const QDateTime &dateTime);
|
||||||
|
|
||||||
|
QTime time() const;
|
||||||
|
void setTime(const QTime &time);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void dateTimeChanged();
|
||||||
|
void timeChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QDateTime m_dateTime;
|
||||||
|
QTime m_time;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TIMEEVENTITEM_H
|
||||||
6
libnymea-common/types/timeeventitems.cpp
Normal file
6
libnymea-common/types/timeeventitems.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "timeeventitems.h"
|
||||||
|
|
||||||
|
TimeEventItems::TimeEventItems(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
17
libnymea-common/types/timeeventitems.h
Normal file
17
libnymea-common/types/timeeventitems.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef TIMEEVENTITEMS_H
|
||||||
|
#define TIMEEVENTITEMS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class TimeEventItems : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TimeEventItems(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TIMEEVENTITEMS_H
|
||||||
@ -12,6 +12,7 @@
|
|||||||
#include "types/stateevaluator.h"
|
#include "types/stateevaluator.h"
|
||||||
#include "types/stateevaluators.h"
|
#include "types/stateevaluators.h"
|
||||||
#include "types/statedescriptor.h"
|
#include "types/statedescriptor.h"
|
||||||
|
#include "types/timeeventitem.h"
|
||||||
|
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
@ -139,10 +140,11 @@ void RuleManager::getRuleDetailsReply(const QVariantMap ¶ms)
|
|||||||
qDebug() << "Got rule details for a rule we don't know";
|
qDebug() << "Got rule details for a rule we don't know";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// qDebug() << "got rule details for rule" << ruleMap;
|
qDebug() << "got rule details for rule" << ruleMap;
|
||||||
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);
|
||||||
rule->setStateEvaluator(parseStateEvaluator(ruleMap.value("stateEvaluator").toMap()));
|
rule->setStateEvaluator(parseStateEvaluator(ruleMap.value("stateEvaluator").toMap()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,3 +255,13 @@ void RuleManager::parseRuleExitActions(const QVariantList &ruleActions, Rule *ru
|
|||||||
rule->exitActions()->addRuleAction(ruleAction);
|
rule->exitActions()->addRuleAction(ruleAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RuleManager::parseTimeDescriptor(const QVariantMap &timeDescriptor, Rule *rule)
|
||||||
|
{
|
||||||
|
foreach (const QVariant &timeEventItemVariant, timeDescriptor.value("timeEventItems").toList()) {
|
||||||
|
TimeEventItem *timeEventItem = new TimeEventItem();
|
||||||
|
timeEventItem->setDateTime(QDateTime::fromSecsSinceEpoch(timeEventItemVariant.toMap().value("datetime").toULongLong()));
|
||||||
|
timeEventItem->setTime(QTime::fromString(timeEventItemVariant.toMap().value("time").toString()));
|
||||||
|
// timeEventItem->setRepeatingOption();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -45,6 +45,7 @@ private:
|
|||||||
StateEvaluator* parseStateEvaluator(const QVariantMap &stateEvaluatorMap);
|
StateEvaluator* parseStateEvaluator(const QVariantMap &stateEvaluatorMap);
|
||||||
void parseRuleActions(const QVariantList &ruleActions, Rule *rule);
|
void parseRuleActions(const QVariantList &ruleActions, Rule *rule);
|
||||||
void parseRuleExitActions(const QVariantList &ruleActions, Rule *rule);
|
void parseRuleExitActions(const QVariantList &ruleActions, Rule *rule);
|
||||||
|
void parseTimeDescriptor(const QVariantMap &timeDescriptor, Rule *rule);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void addRuleReply(const QString &ruleError);
|
void addRuleReply(const QString &ruleError);
|
||||||
|
|||||||
@ -33,6 +33,7 @@ Page {
|
|||||||
property alias paramType: paramDescriptorDelegate.paramType
|
property alias paramType: paramDescriptorDelegate.paramType
|
||||||
property alias value: paramDescriptorDelegate.value
|
property alias value: paramDescriptorDelegate.value
|
||||||
property alias considerParam: paramCheckBox.checked
|
property alias considerParam: paramCheckBox.checked
|
||||||
|
property alias operatorType: paramDescriptorDelegate.operatorType
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: paramCheckBox
|
id: paramCheckBox
|
||||||
text: "Only consider event if"
|
text: "Only consider event if"
|
||||||
@ -63,6 +64,7 @@ Page {
|
|||||||
for (var i = 0; i < delegateRepeater.count; i++) {
|
for (var i = 0; i < delegateRepeater.count; i++) {
|
||||||
var paramDelegate = delegateRepeater.itemAt(i);
|
var paramDelegate = delegateRepeater.itemAt(i);
|
||||||
if (paramDelegate.considerParam) {
|
if (paramDelegate.considerParam) {
|
||||||
|
print("setting param descriptor to", paramDelegate.operatorType)
|
||||||
root.eventDescriptor.paramDescriptors.setParamDescriptor(paramDelegate.paramType.id, paramDelegate.value, paramDelegate.operatorType)
|
root.eventDescriptor.paramDescriptors.setParamDescriptor(paramDelegate.paramType.id, paramDelegate.value, paramDelegate.operatorType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user