Fix ac charts also showing actions
This commit is contained in:
parent
b04ca3efe0
commit
7d671c652d
@ -120,11 +120,11 @@ quint64 BoolSeriesAdapter::findIndex(qulonglong timestamp)
|
||||
int range = idx;
|
||||
int i = 0;
|
||||
while (true) {
|
||||
qWarning() << "CNT:" << m_series->count()
|
||||
<< "first:" << QDateTime::fromMSecsSinceEpoch(m_series->at(1).x())
|
||||
<< "last:" << QDateTime::fromMSecsSinceEpoch(m_series->at(m_series->count()- 2).x())
|
||||
<< "current:" << idx << QDateTime::fromMSecsSinceEpoch(m_series->at(idx).x())
|
||||
<< "search:" << QDateTime::fromMSecsSinceEpoch(timestamp);
|
||||
// qWarning() << "CNT:" << m_series->count()
|
||||
// << "first:" << QDateTime::fromMSecsSinceEpoch(m_series->at(1).x())
|
||||
// << "last:" << QDateTime::fromMSecsSinceEpoch(m_series->at(m_series->count()- 2).x())
|
||||
// << "current:" << idx << QDateTime::fromMSecsSinceEpoch(m_series->at(idx).x())
|
||||
// << "search:" << QDateTime::fromMSecsSinceEpoch(timestamp);
|
||||
if (timestamp >= m_series->at(idx).x() && timestamp < m_series->at(idx-1).x()) {
|
||||
return idx;
|
||||
}
|
||||
|
||||
@ -44,7 +44,6 @@ NYMEA_LOGGING_CATEGORY(dcLogEngine, "LogEngine")
|
||||
|
||||
LogsModel::LogsModel(QObject *parent) : QAbstractListModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Engine *LogsModel::engine() const
|
||||
@ -209,6 +208,19 @@ void LogsModel::setViewStartTime(const QDateTime &viewStartTime)
|
||||
}
|
||||
}
|
||||
|
||||
LogsModel::SourceFilters LogsModel::sourceFilter() const
|
||||
{
|
||||
return m_sourceFilter;
|
||||
}
|
||||
|
||||
void LogsModel::setSourceFilter(SourceFilters sourceFilter)
|
||||
{
|
||||
if (m_sourceFilter != sourceFilter) {
|
||||
m_sourceFilter = sourceFilter;
|
||||
emit sourceFilterChanged();
|
||||
}
|
||||
}
|
||||
|
||||
int LogsModel::fetchBlockSize() const
|
||||
{
|
||||
return m_blockSize;
|
||||
@ -403,6 +415,24 @@ void LogsModel::fetchMore(const QModelIndex &parent)
|
||||
}
|
||||
params.insert("typeIds", typeIds);
|
||||
}
|
||||
QVariantList loggingSourceFilter;
|
||||
QMetaEnum loggingSourcesEnum = QMetaEnum::fromType<LogEntry::LoggingSource>();
|
||||
if (m_sourceFilter.testFlag(SourceSystem)) {
|
||||
loggingSourceFilter.append(loggingSourcesEnum.valueToKey(LogEntry::LoggingSourceSystem));
|
||||
}
|
||||
if (m_sourceFilter.testFlag(SourceRules)) {
|
||||
loggingSourceFilter.append(loggingSourcesEnum.valueToKey(LogEntry::LoggingSourceRules));
|
||||
}
|
||||
if (m_sourceFilter.testFlag(SourceEvents)) {
|
||||
loggingSourceFilter.append(loggingSourcesEnum.valueToKey(LogEntry::LoggingSourceEvents));
|
||||
}
|
||||
if (m_sourceFilter.testFlag(SourceStates)) {
|
||||
loggingSourceFilter.append(loggingSourcesEnum.valueToKey(LogEntry::LoggingSourceStates));
|
||||
}
|
||||
if (m_sourceFilter.testFlag(SourceActions)) {
|
||||
loggingSourceFilter.append(loggingSourcesEnum.valueToKey(LogEntry::LoggingSourceActions));
|
||||
}
|
||||
params.insert("loggingSources", loggingSourceFilter);
|
||||
if (!m_startTime.isNull() && !m_endTime.isNull()) {
|
||||
QVariantList timeFilters;
|
||||
QVariantMap timeFilter;
|
||||
@ -416,7 +446,7 @@ void LogsModel::fetchMore(const QModelIndex &parent)
|
||||
params.insert("offset", m_list.count() - m_generatedEntries);
|
||||
|
||||
qCInfo(dcLogEngine()) << "Fetching logs from:" << m_list.count() - m_generatedEntries << "max" << m_blockSize;
|
||||
qCDebug(dcLogEngine()) << qUtf8Printable(QJsonDocument::fromVariant(params).toJson());
|
||||
qCCritical(dcLogEngine()) << qUtf8Printable(QJsonDocument::fromVariant(params).toJson());
|
||||
|
||||
m_engine->jsonRpcClient()->sendCommand("Logging.GetLogEntries", params, this, "logsReply");
|
||||
m_fetchStartTime = QDateTime::currentDateTime();
|
||||
|
||||
@ -55,6 +55,7 @@ class LogsModel : public QAbstractListModel, public QQmlParserStatus
|
||||
Q_PROPERTY(QDateTime startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged)
|
||||
Q_PROPERTY(QDateTime endTime READ endTime WRITE setEndTime NOTIFY endTimeChanged)
|
||||
Q_PROPERTY(QDateTime viewStartTime READ viewStartTime WRITE setViewStartTime NOTIFY viewStartTimeChanged)
|
||||
Q_PROPERTY(SourceFilters sourceFilter READ sourceFilter WRITE setSourceFilter NOTIFY sourceFilterChanged)
|
||||
Q_PROPERTY(int fetchBlockSize READ fetchBlockSize WRITE setFetchBlockSize NOTIFY fetchBlockSizeChanged)
|
||||
|
||||
public:
|
||||
@ -67,6 +68,18 @@ public:
|
||||
RoleLoggingEventType,
|
||||
RoleErrorCode
|
||||
};
|
||||
enum SourceFilter {
|
||||
SourceNone = 0x00,
|
||||
SourceSystem = 0x01,
|
||||
SourceRules = 0x02,
|
||||
SourceEvents = 0x04,
|
||||
SourceStates = 0x08,
|
||||
SourceActions = 0x10,
|
||||
SourceAll = 0xff
|
||||
};
|
||||
Q_DECLARE_FLAGS(SourceFilters, SourceFilter)
|
||||
Q_FLAG(SourceFilters)
|
||||
|
||||
explicit LogsModel(QObject *parent = nullptr);
|
||||
virtual ~LogsModel() = default;
|
||||
|
||||
@ -100,6 +113,9 @@ public:
|
||||
QDateTime viewStartTime() const;
|
||||
void setViewStartTime(const QDateTime &viewStartTime);
|
||||
|
||||
SourceFilters sourceFilter() const;
|
||||
void setSourceFilter(SourceFilters sourceFilter);
|
||||
|
||||
int fetchBlockSize() const;
|
||||
void setFetchBlockSize(int fetchBlockSize);
|
||||
|
||||
@ -117,6 +133,7 @@ signals:
|
||||
void startTimeChanged();
|
||||
void endTimeChanged();
|
||||
void viewStartTimeChanged();
|
||||
void sourceFilterChanged();
|
||||
void fetchBlockSizeChanged();
|
||||
|
||||
void logEntryAdded(LogEntry *entry);
|
||||
@ -133,6 +150,7 @@ protected:
|
||||
QDateTime m_startTime;
|
||||
QDateTime m_endTime;
|
||||
QDateTime m_viewStartTime;
|
||||
SourceFilters m_sourceFilter = SourceAll;
|
||||
|
||||
bool m_busy = false;
|
||||
bool m_live = false;
|
||||
|
||||
@ -53,11 +53,11 @@ class LogEntry : public QObject
|
||||
|
||||
public:
|
||||
enum LoggingSource {
|
||||
LoggingSourceSystem,
|
||||
LoggingSourceEvents,
|
||||
LoggingSourceActions,
|
||||
LoggingSourceStates,
|
||||
LoggingSourceRules
|
||||
LoggingSourceSystem = 0x01,
|
||||
LoggingSourceEvents = 0x02,
|
||||
LoggingSourceActions = 0x04,
|
||||
LoggingSourceStates = 0x08,
|
||||
LoggingSourceRules = 0x10
|
||||
};
|
||||
Q_ENUM(LoggingSource)
|
||||
Q_DECLARE_FLAGS(LoggingSources, LoggingSource)
|
||||
|
||||
@ -208,6 +208,7 @@ Page {
|
||||
engine: typeIds.length > 0 ? _engine : null
|
||||
thingId: thing.id
|
||||
live: true
|
||||
sourceFilter: LogsModel.SourceStates
|
||||
// graphSeries: series
|
||||
viewStartTime: new Date(d.startTime.getTime() - d.range * 60000)
|
||||
|
||||
@ -256,6 +257,7 @@ Page {
|
||||
objectName: "temp: " + thing.name
|
||||
engine: typeIds.length > 0 ? _engine : null
|
||||
thingId: thing.id
|
||||
sourceFilter: LogsModel.SourceStates
|
||||
live: true
|
||||
// graphSeries: series
|
||||
viewStartTime: new Date(d.startTime.getTime() - d.range * 60000)
|
||||
@ -305,6 +307,7 @@ Page {
|
||||
objectName: "hum: " + thing.name
|
||||
engine: typeIds.length > 0 ? _engine : null
|
||||
thingId: thing.id
|
||||
sourceFilter: LogsModel.SourceStates
|
||||
live: true
|
||||
// graphSeries: series
|
||||
viewStartTime: new Date(d.startTime.getTime() - d.range * 60000)
|
||||
@ -351,6 +354,7 @@ Page {
|
||||
objectName: "voc: " + thing.name
|
||||
engine: typeIds.length > 0 ? _engine : null
|
||||
thingId: thing.id
|
||||
sourceFilter: LogsModel.SourceStates
|
||||
live: true
|
||||
// graphSeries: series
|
||||
viewStartTime: new Date(d.startTime.getTime() - d.range * 60000)
|
||||
@ -411,6 +415,7 @@ Page {
|
||||
ret.push(thing.thingClass.stateTypes.findByName("closed").id)
|
||||
return ret;
|
||||
}
|
||||
sourceFilter: LogsModel.SourceStates
|
||||
live: true
|
||||
viewStartTime: new Date(d.startTime.getTime() - d.range * 60000)
|
||||
}
|
||||
@ -465,13 +470,12 @@ Page {
|
||||
typeIds: {
|
||||
var ret = [];
|
||||
var heatingOnStateType = thing.thingClass.stateTypes.findByName("heatingOn")
|
||||
print("**** has heatingOn")
|
||||
if (heatingOnStateType) {
|
||||
print("**** true")
|
||||
ret.push(heatingOnStateType.id)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
sourceFilter: LogsModel.SourceStates
|
||||
live: true
|
||||
// graphSeries: heatingUpperSeries
|
||||
viewStartTime: dateTimeAxis.min
|
||||
|
||||
@ -478,11 +478,11 @@ Item {
|
||||
return Math.abs(Math.min(0, entry.production))
|
||||
}
|
||||
function addEntry(entry) {
|
||||
print("appending!", entry.timestamp, entry.value)
|
||||
// print("appending!", entry.timestamp, entry.value)
|
||||
append(entry.timestamp.getTime(), calculateValue(entry))
|
||||
}
|
||||
function insertEntry(index, entry) {
|
||||
print("inserting!", index, entry.timestamp, entry.value)
|
||||
// print("inserting!", index, entry.timestamp, entry.value)
|
||||
insert(index, entry.timestamp.getTime(), calculateValue(entry))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user