|
CuteHMI - Data Acquisition (CuteHMI.DataAcquisition.0)
|
1 #ifndef H_EXTENSIONS_CUTEHMI_DATAACQUISITION_0_INCLUDE_CUTEHMI_DATAACQUISITION_INTERNAL_EVENTTABLE_HPP
2 #define H_EXTENSIONS_CUTEHMI_DATAACQUISITION_0_INCLUDE_CUTEHMI_DATAACQUISITION_INTERNAL_EVENTTABLE_HPP
5 #include "TableObject.hpp"
6 #include "TagCache.hpp"
7 #include "TableNameTraits.hpp"
12 namespace dataacquisition {
56 worker([
this, tagName, tuple, tableName](
QSqlDatabase & db) {
59 CUTEHMI_DEBUG(
"Storing '" << tableName <<
"' values...");
61 query.prepare(QString(
"INSERT INTO %1.%2(tag_id, value, time) VALUES (:tagId, :value, :time)").arg(schema()->name()).arg(tableName));
62 query.bindValue(
":tagId", tagCache()->getId(tagName, db));
63 query.bindValue(
":value", tuple.value);
64 query.bindValue(
":time", tuple.time);
67 pushError(query.lastError());
71 CUTEHMI_DEBUG(
"Storing '" << tableName <<
"' values...");
73 query.prepare(QString(
"INSERT INTO [%1.%2](tag_id, value, time) VALUES (:tagId, :value, :time)").arg(schema()->name()).arg(tableName));
74 query.bindValue(
":tagId", tagCache()->getId(tagName, db));
75 query.bindValue(
":value", tuple.value);
76 query.bindValue(
":time", tuple.time);
79 pushError(query.lastError());
82 emit errored(CUTEHMI_ERROR(tr(
"Driver '%1' is not supported.").arg(db.
driverName())));
void insert(const QString &tagName, const Tuple &tuple)
Definition: EventTable.hpp:52
static QString Affixed(const QString &name)
Definition: TagCache.hpp:13
T value
Definition: EventTable.hpp:24
Definition: TableObject.hpp:13
T type
Definition: EventTable.hpp:20
EventTable(TagCache *tagCache, Schema *schema, QObject *parent=nullptr)
Definition: EventTable.hpp:45
QDateTime time
Definition: EventTable.hpp:25
TagCache * tagCache() const
Definition: EventTable.hpp:87
Schema schema
Definition: TableObject.hpp:22
Definition: EventTable.hpp:16
Database schema.
Definition: Schema.hpp:13
QString driverName() const const
Definition: EventTable.hpp:22
QObject * parent() const const