mirror of
https://github.com/Fishwaldo/qt-openzwave.git
synced 2025-03-16 03:51:25 +00:00
Source Reorg
This commit is contained in:
parent
11ecc7f27d
commit
7a9ea429e4
39 changed files with 855 additions and 830 deletions
|
@ -20,7 +20,8 @@ public:
|
|||
Q_ENUM(associationColumns)
|
||||
|
||||
enum associationFlags {
|
||||
isMultiInstance
|
||||
isMultiInstance,
|
||||
FlagCount
|
||||
};
|
||||
|
||||
Q_ENUM(associationFlags)
|
||||
|
@ -39,20 +40,4 @@ protected:
|
|||
|
||||
QMap<qint32, QMap<QTOZW_Associations::associationColumns, QVariant> > m_associationData;
|
||||
};
|
||||
|
||||
class QTOZW_Associations_internal : public QTOZW_Associations {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QTOZW_Associations_internal(QObject *parent=nullptr);
|
||||
public Q_SLOTS:
|
||||
void addGroup(quint8 _nodeID, quint8 _groupIDX);
|
||||
void setGroupData(quint8 _nodeID, quint8 _groupIDX, QTOZW_Associations::associationColumns column, QVariant data);
|
||||
void setGroupFlags(quint8 _nodeID, quint8 _groupIDX, QTOZW_Associations::associationFlags _flags, bool _value);
|
||||
void delNode(quint8 _nodeID);
|
||||
void addAssociation(quint8 _nodeID, quint8 _groupIDX, quint8 _targetNode, quint8 _targetInstance);
|
||||
void delAssociation(quint8 _nodeID, quint8 _groupIDX, quint8 _targetNode, quint8 _targetInstance);
|
||||
bool findAssociation(quint8 _nodeID, quint8 _groupIDX, quint8 _targetNode, quint8 _targetInstance);
|
||||
void resetModel();
|
||||
};
|
||||
|
||||
#endif // QTOZWASSOCIATIONS_H
|
|
@ -3,127 +3,18 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
#include "rep_qtozwmanager_source.h"
|
||||
#include "rep_qtozwmanager_replica.h"
|
||||
#include "qtozwnotification.h"
|
||||
#include <QtRemoteObjects>
|
||||
|
||||
#include "qtozwnodemodel.h"
|
||||
#include "qtozwvalueidmodel.h"
|
||||
#include "qtozwassociations.h"
|
||||
|
||||
void setupOZW();
|
||||
#include "qtozwassociationmodel.h"
|
||||
|
||||
enum QTOZW_UserRoles {
|
||||
ModelDataChanged = Qt::UserRole
|
||||
};
|
||||
|
||||
|
||||
namespace OpenZWave {
|
||||
|
||||
/* forward Declaration */
|
||||
class Manager;
|
||||
class Options;
|
||||
class Notification;
|
||||
}
|
||||
|
||||
|
||||
class QTOZWManager_Internal : public QTOZWManagerSimpleSource
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
friend class OZWNotification;
|
||||
QTOZWManager_Internal(QObject *parent = nullptr);
|
||||
|
||||
QTOZW_Nodes *getNodeModel();
|
||||
QTOZW_ValueIds *getValueModel();
|
||||
QTOZW_Associations *getAssociationModel();
|
||||
|
||||
public Q_SLOTS:
|
||||
bool open(QString serialPort);
|
||||
bool refreshNodeInfo(quint8 _node);
|
||||
bool requestNodeState(quint8 _node);
|
||||
bool requestNodeDynamic(quint8 _node);
|
||||
|
||||
bool setConfigParam(quint8 _node, quint8 _param, int32_t _value, quint8 const _size);
|
||||
void requestConfigParam(quint8 _node, quint8 _param);
|
||||
void requestAllConfigParam(quint8 _node);
|
||||
|
||||
void softResetController();
|
||||
void hardResetController();
|
||||
|
||||
bool cancelControllerCommand();
|
||||
|
||||
void testNetworkNode(quint8 _node, quint32 const _count);
|
||||
void testNetwork(quint32 const _count);
|
||||
void healNetworkNode(quint8 _node, bool _doRR);
|
||||
void healNetwork(bool _doRR);
|
||||
bool addNode(bool _doSecure);
|
||||
bool removeNode();
|
||||
bool removeFailedNode(quint8 _node);
|
||||
bool hasNodeFailed(quint8 _node);
|
||||
bool requestNodeNeighborUpdate(quint8 _node);
|
||||
bool assignReturnRoute(quint8 _node);
|
||||
bool deleteAllReturnRoute(quint8 _node);
|
||||
bool sendNodeInfomation(quint8 _node);
|
||||
bool replaceFailedNode(quint8 _node);
|
||||
bool requestNetworkUpdate(quint8 _node);
|
||||
|
||||
bool checkLatestConfigFileRevision(quint8 const _node);
|
||||
bool checkLatestMFSRevision();
|
||||
bool downloadLatestConfigFileRevision(quint8 const _node);
|
||||
bool downloadLatestMFSRevision();
|
||||
|
||||
|
||||
/* these slots are called from our OZWNotification Class. Applications should not call them */
|
||||
void pvt_valueAdded(quint64 vidKey);
|
||||
void pvt_valueRemoved(quint64 vidKey);
|
||||
void pvt_valueChanged(quint64 vidKey);
|
||||
void pvt_valueRefreshed(quint64 vidKey);
|
||||
void pvt_valuePollingEnabled(quint64 vidKey);
|
||||
void pvt_valuePollingDisabled(quint64 vidKey);
|
||||
void pvt_nodeGroupChanged(quint8 node, quint8 group);
|
||||
void pvt_nodeNew(quint8 node);
|
||||
void pvt_nodeAdded(quint8 node);
|
||||
void pvt_nodeRemoved(quint8 node);
|
||||
void pvt_nodeReset(quint8 node);
|
||||
void pvt_nodeNaming(quint8 node);
|
||||
void pvt_nodeEvent(quint8 node, quint8 event);
|
||||
void pvt_nodeProtocolInfo(quint8 node);
|
||||
void pvt_nodeEssentialNodeQueriesComplete(quint8 node);
|
||||
void pvt_nodeQueriesComplete(quint8 node);
|
||||
void pvt_driverReady(quint32 homeID);
|
||||
void pvt_driverFailed(quint32 homeID);
|
||||
void pvt_driverReset(quint32 homeID);
|
||||
void pvt_driverRemoved(quint32 homeID);
|
||||
void pvt_driverAllNodesQueriedSomeDead();
|
||||
void pvt_driverAllNodesQueried();
|
||||
void pvt_driverAwakeNodesQueried();
|
||||
void pvt_controllerCommand(quint8 command);
|
||||
void pvt_ozwNotification(OpenZWave::Notification::NotificationCode event);
|
||||
void pvt_ozwUserAlert(OpenZWave::Notification::UserAlertNotification event);
|
||||
void pvt_manufacturerSpecificDBReady();
|
||||
|
||||
void pvt_nodeModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
|
||||
void pvt_valueModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
|
||||
|
||||
private:
|
||||
|
||||
bool checkHomeId();
|
||||
bool checkNodeId(quint8 _node);
|
||||
bool checkValueKey(quint64 _vidKey);
|
||||
bool convertValueID(quint64 vidKey);
|
||||
|
||||
|
||||
OpenZWave::Options *m_options;
|
||||
OpenZWave::Manager *m_manager;
|
||||
QTOZW_Nodes_internal *m_nodeModel;
|
||||
QTOZW_ValueIds_internal *m_valueModel;
|
||||
QTOZW_Associations_internal *m_associationsModel;
|
||||
QVector<quint8> m_validNodes;
|
||||
QVector<quint64> m_validValues;
|
||||
QMap<quint8, QMap<quint8, bool > > m_associationDefaultsSet;
|
||||
|
||||
};
|
||||
|
||||
class QTOZWManager_Internal;
|
||||
class QTOZWManagerReplica;
|
||||
|
||||
|
||||
class QTOZWManager : public QObject {
|
|
@ -66,18 +66,4 @@ protected:
|
|||
|
||||
QMap<int32_t, QMap<NodeColumns, QVariant> > m_nodeData;
|
||||
};
|
||||
|
||||
class QTOZW_Nodes_internal : public QTOZW_Nodes {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QTOZW_Nodes_internal(QObject *parent=nullptr);
|
||||
public Q_SLOTS:
|
||||
void addNode(quint8 _nodeID);
|
||||
void setNodeData(quint8 _nodeID, QTOZW_Nodes::NodeColumns column, QVariant data);
|
||||
void setNodeFlags(quint8 _nodeID, QTOZW_Nodes::nodeFlags _flags, bool _value);
|
||||
void delNode(quint8 _nodeID);
|
||||
void resetModel();
|
||||
|
||||
};
|
||||
|
||||
#endif // QTOZWNODEMODEL_H
|
|
@ -97,21 +97,4 @@ protected:
|
|||
QMap<int32_t, QMap<ValueIdColumns, QVariant> > m_valueData;
|
||||
};
|
||||
|
||||
class QTOZW_ValueIds_internal : public QTOZW_ValueIds {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QTOZW_ValueIds_internal(QObject *parent=nullptr);
|
||||
public Q_SLOTS:
|
||||
void addValue(quint64 _vidKey);
|
||||
void setValueData(quint64 _vidKey, QTOZW_ValueIds::ValueIdColumns column, QVariant data);
|
||||
void setValueFlags(quint64 _vidKey, QTOZW_ValueIds::ValueIDFlags _flags, bool _value);
|
||||
void delValue(quint64 _vidKey);
|
||||
void delNodeValues(quint8 _node);
|
||||
void resetModel();
|
||||
};
|
||||
|
||||
QString BitSettoQString(QBitArray ba);
|
||||
quint32 BitSettoInteger(QBitArray ba);
|
||||
|
||||
|
||||
#endif // QTOZWVALUEIDMODEL_H
|
23
qt-openzwave/include/qtozwassociationmodel_p.h
Normal file
23
qt-openzwave/include/qtozwassociationmodel_p.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef QTOZWASSOCIATIONMODEL_P_H
|
||||
#define QTOZWASSOCIATIONMODEL_P_H
|
||||
|
||||
#include <QObject>
|
||||
#include "qt-openzwave/qtozwassociationmodel.h"
|
||||
|
||||
class QTOZW_Associations_internal : public QTOZW_Associations {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QTOZW_Associations_internal(QObject *parent=nullptr);
|
||||
public Q_SLOTS:
|
||||
void addGroup(quint8 _nodeID, quint8 _groupIDX);
|
||||
void setGroupData(quint8 _nodeID, quint8 _groupIDX, QTOZW_Associations::associationColumns column, QVariant data);
|
||||
void setGroupFlags(quint8 _nodeID, quint8 _groupIDX, QTOZW_Associations::associationFlags _flags, bool _value);
|
||||
void delNode(quint8 _nodeID);
|
||||
void addAssociation(quint8 _nodeID, quint8 _groupIDX, quint8 _targetNode, quint8 _targetInstance);
|
||||
void delAssociation(quint8 _nodeID, quint8 _groupIDX, quint8 _targetNode, quint8 _targetInstance);
|
||||
bool findAssociation(quint8 _nodeID, quint8 _groupIDX, quint8 _targetNode, quint8 _targetInstance);
|
||||
void resetModel();
|
||||
};
|
||||
|
||||
|
||||
#endif // QTOZWASSOCIATIONMODEL_P_H
|
121
qt-openzwave/include/qtozwmanager_p.h
Normal file
121
qt-openzwave/include/qtozwmanager_p.h
Normal file
|
@ -0,0 +1,121 @@
|
|||
#ifndef QTOZWMANAGER_P_H
|
||||
#define QTOZWMANAGER_P_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
#include "qtozw_logging.h"
|
||||
#include "rep_qtozwmanager_source.h"
|
||||
#include "rep_qtozwmanager_replica.h"
|
||||
#include "qtozwnotification.h"
|
||||
#include "qtozwnodemodel_p.h"
|
||||
#include "qtozwvalueidmodel_p.h"
|
||||
#include "qtozwassociationmodel_p.h"
|
||||
|
||||
/* OZW Includes */
|
||||
#include "Manager.h"
|
||||
#include "Options.h"
|
||||
#include "Notification.h"
|
||||
#include "platform/Log.h"
|
||||
#include "OZWException.h"
|
||||
|
||||
|
||||
class QTOZWManager_Internal : public QTOZWManagerSimpleSource
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
friend class OZWNotification;
|
||||
QTOZWManager_Internal(QObject *parent = nullptr);
|
||||
|
||||
QTOZW_Nodes *getNodeModel();
|
||||
QTOZW_ValueIds *getValueModel();
|
||||
QTOZW_Associations *getAssociationModel();
|
||||
|
||||
public Q_SLOTS:
|
||||
bool open(QString serialPort);
|
||||
bool refreshNodeInfo(quint8 _node);
|
||||
bool requestNodeState(quint8 _node);
|
||||
bool requestNodeDynamic(quint8 _node);
|
||||
|
||||
bool setConfigParam(quint8 _node, quint8 _param, int32_t _value, quint8 const _size);
|
||||
void requestConfigParam(quint8 _node, quint8 _param);
|
||||
void requestAllConfigParam(quint8 _node);
|
||||
|
||||
void softResetController();
|
||||
void hardResetController();
|
||||
|
||||
bool cancelControllerCommand();
|
||||
|
||||
void testNetworkNode(quint8 _node, quint32 const _count);
|
||||
void testNetwork(quint32 const _count);
|
||||
void healNetworkNode(quint8 _node, bool _doRR);
|
||||
void healNetwork(bool _doRR);
|
||||
bool addNode(bool _doSecure);
|
||||
bool removeNode();
|
||||
bool removeFailedNode(quint8 _node);
|
||||
bool hasNodeFailed(quint8 _node);
|
||||
bool requestNodeNeighborUpdate(quint8 _node);
|
||||
bool assignReturnRoute(quint8 _node);
|
||||
bool deleteAllReturnRoute(quint8 _node);
|
||||
bool sendNodeInfomation(quint8 _node);
|
||||
bool replaceFailedNode(quint8 _node);
|
||||
bool requestNetworkUpdate(quint8 _node);
|
||||
|
||||
bool checkLatestConfigFileRevision(quint8 const _node);
|
||||
bool checkLatestMFSRevision();
|
||||
bool downloadLatestConfigFileRevision(quint8 const _node);
|
||||
bool downloadLatestMFSRevision();
|
||||
|
||||
|
||||
/* these slots are called from our OZWNotification Class. Applications should not call them */
|
||||
void pvt_valueAdded(quint64 vidKey);
|
||||
void pvt_valueRemoved(quint64 vidKey);
|
||||
void pvt_valueChanged(quint64 vidKey);
|
||||
void pvt_valueRefreshed(quint64 vidKey);
|
||||
void pvt_valuePollingEnabled(quint64 vidKey);
|
||||
void pvt_valuePollingDisabled(quint64 vidKey);
|
||||
void pvt_nodeGroupChanged(quint8 node, quint8 group);
|
||||
void pvt_nodeNew(quint8 node);
|
||||
void pvt_nodeAdded(quint8 node);
|
||||
void pvt_nodeRemoved(quint8 node);
|
||||
void pvt_nodeReset(quint8 node);
|
||||
void pvt_nodeNaming(quint8 node);
|
||||
void pvt_nodeEvent(quint8 node, quint8 event);
|
||||
void pvt_nodeProtocolInfo(quint8 node);
|
||||
void pvt_nodeEssentialNodeQueriesComplete(quint8 node);
|
||||
void pvt_nodeQueriesComplete(quint8 node);
|
||||
void pvt_driverReady(quint32 homeID);
|
||||
void pvt_driverFailed(quint32 homeID);
|
||||
void pvt_driverReset(quint32 homeID);
|
||||
void pvt_driverRemoved(quint32 homeID);
|
||||
void pvt_driverAllNodesQueriedSomeDead();
|
||||
void pvt_driverAllNodesQueried();
|
||||
void pvt_driverAwakeNodesQueried();
|
||||
void pvt_controllerCommand(quint8 command);
|
||||
void pvt_ozwNotification(OpenZWave::Notification::NotificationCode event);
|
||||
void pvt_ozwUserAlert(OpenZWave::Notification::UserAlertNotification event);
|
||||
void pvt_manufacturerSpecificDBReady();
|
||||
|
||||
void pvt_nodeModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
|
||||
void pvt_valueModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
|
||||
|
||||
private:
|
||||
|
||||
bool checkHomeId();
|
||||
bool checkNodeId(quint8 _node);
|
||||
bool checkValueKey(quint64 _vidKey);
|
||||
bool convertValueID(quint64 vidKey);
|
||||
|
||||
|
||||
OpenZWave::Options *m_options;
|
||||
OpenZWave::Manager *m_manager;
|
||||
QTOZW_Nodes_internal *m_nodeModel;
|
||||
QTOZW_ValueIds_internal *m_valueModel;
|
||||
QTOZW_Associations_internal *m_associationsModel;
|
||||
QVector<quint8> m_validNodes;
|
||||
QVector<quint64> m_validValues;
|
||||
QMap<quint8, QMap<quint8, bool > > m_associationDefaultsSet;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // QTOZWMANAGER_P_H
|
20
qt-openzwave/include/qtozwnodemodel_p.h
Normal file
20
qt-openzwave/include/qtozwnodemodel_p.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef QTOZWNODEMODEL_P_H
|
||||
#define QTOZWNODEMODEL_P_H
|
||||
|
||||
#include <QObject>
|
||||
#include "qt-openzwave/qtozwnodemodel.h"
|
||||
|
||||
class QTOZW_Nodes_internal : public QTOZW_Nodes {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QTOZW_Nodes_internal(QObject *parent=nullptr);
|
||||
public Q_SLOTS:
|
||||
void addNode(quint8 _nodeID);
|
||||
void setNodeData(quint8 _nodeID, QTOZW_Nodes::NodeColumns column, QVariant data);
|
||||
void setNodeFlags(quint8 _nodeID, QTOZW_Nodes::nodeFlags _flags, bool _value);
|
||||
void delNode(quint8 _nodeID);
|
||||
void resetModel();
|
||||
};
|
||||
|
||||
|
||||
#endif // QTOZWNODEMODEL_P_H
|
25
qt-openzwave/include/qtozwvalueidmodel_p.h
Normal file
25
qt-openzwave/include/qtozwvalueidmodel_p.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef QTOZWVALUEIDMODEL_P_H
|
||||
#define QTOZWVALUEIDMODEL_P_H
|
||||
|
||||
#include <QObject>
|
||||
#include "qt-openzwave/qtozwvalueidmodel.h"
|
||||
|
||||
class QTOZW_ValueIds_internal : public QTOZW_ValueIds {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QTOZW_ValueIds_internal(QObject *parent=nullptr);
|
||||
public Q_SLOTS:
|
||||
void addValue(quint64 _vidKey);
|
||||
void setValueData(quint64 _vidKey, QTOZW_ValueIds::ValueIdColumns column, QVariant data);
|
||||
void setValueFlags(quint64 _vidKey, QTOZW_ValueIds::ValueIDFlags _flags, bool _value);
|
||||
void delValue(quint64 _vidKey);
|
||||
void delNodeValues(quint8 _node);
|
||||
void resetModel();
|
||||
};
|
||||
|
||||
|
||||
QString BitSettoQString(QBitArray ba);
|
||||
quint32 BitSettoInteger(QBitArray ba);
|
||||
|
||||
|
||||
#endif // QTOZWVALUEIDMODEL_P_H
|
|
@ -24,8 +24,6 @@ qtConfig(static) {
|
|||
# this is a static build
|
||||
}
|
||||
|
||||
#INCLUDEPATH += $$absolute_path($$top_srcdir/../open-zwave/cpp/src/)/
|
||||
|
||||
DEFINES += QTOPENZWAVE_LIBRARY
|
||||
|
||||
|
||||
|
@ -40,29 +38,36 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
qtopenzwave.cpp \
|
||||
qtozwassociations.cpp \
|
||||
qtozwmanager.cpp \
|
||||
qtozwnotification.cpp \
|
||||
qtozwproxymodels.cpp \
|
||||
qtozwnodemodel.cpp \
|
||||
qtozwvalueidmodel.cpp
|
||||
SOURCES += source/qtopenzwave.cpp \
|
||||
source/qtozwassociationmodel.cpp \
|
||||
source/qtozwassociationmodel_p.cpp \
|
||||
source/qtozwmanager.cpp \
|
||||
source/qtozwmanager_p.cpp \
|
||||
source/qtozwnodemodel_p.cpp \
|
||||
source/qtozwnotification.cpp \
|
||||
source/qtozwproxymodels.cpp \
|
||||
source/qtozwnodemodel.cpp \
|
||||
source/qtozwvalueidmodel.cpp \
|
||||
source/qtozwvalueidmodel_p.cpp
|
||||
|
||||
HEADERS += \
|
||||
qtopenzwave.h \
|
||||
qt-openzwave_global.h \ \
|
||||
qtozw_logging.h \
|
||||
qtozwassociations.h \
|
||||
qtozwproxymodels.h \
|
||||
qtozwmanager.h \
|
||||
qtozwnotification.h \
|
||||
qtozwnodemodel.h \
|
||||
qtozwvalueidmodel.h
|
||||
HEADERS += include/qt-openzwave/qtopenzwave.h \
|
||||
include/qt-openzwave_global.h \ \
|
||||
include/qtozw_logging.h \
|
||||
include/qt-openzwave/qtozwassociationmodel.h \
|
||||
include/qtozwassociationmodel_p.h \
|
||||
include/qtozwmanager_p.h \
|
||||
include/qtozwnodemodel_p.h \
|
||||
include/qt-openzwave/qtozwproxymodels.h \
|
||||
include/qt-openzwave/qtozwmanager.h \
|
||||
include/qtozwnotification.h \
|
||||
include/qt-openzwave/qtozwnodemodel.h \
|
||||
include/qt-openzwave/qtozwvalueidmodel.h \
|
||||
include/qtozwvalueidmodel_p.h
|
||||
|
||||
INCLUDEPATH += include/
|
||||
|
||||
REPC_SOURCE = qtozwmanager.rep
|
||||
REPC_REPLICA = qtozwmanager.rep
|
||||
REPC_SOURCE = source/qtozwmanager.rep
|
||||
REPC_REPLICA = source/qtozwmanager.rep
|
||||
|
||||
unix {
|
||||
target.path = /usr/local/lib
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "qtopenzwave.h"
|
||||
#include "qt-openzwave/qtopenzwave.h"
|
||||
#include "qtozw_logging.h"
|
||||
|
||||
|
100
qt-openzwave/source/qtozwassociationmodel.cpp
Normal file
100
qt-openzwave/source/qtozwassociationmodel.cpp
Normal file
|
@ -0,0 +1,100 @@
|
|||
#include <QDebug>
|
||||
#include <QBitArray>
|
||||
#include "qtozw_logging.h"
|
||||
#include "qt-openzwave/qtozwassociationmodel.h"
|
||||
#include "qt-openzwave/qtopenzwave.h"
|
||||
|
||||
|
||||
QTOZW_Associations::QTOZW_Associations(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
int QTOZW_Associations::rowCount(const QModelIndex &parent) const {
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
return this->m_associationData.count();
|
||||
}
|
||||
int QTOZW_Associations::columnCount(const QModelIndex &parent) const {
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
return QTOZW_Associations::associationColumns::Count;
|
||||
}
|
||||
QVariant QTOZW_Associations::data(const QModelIndex &index, int role) const {
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (index.row() >= this->rowCount(index.parent()) || index.row() < 0)
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
QMap<associationColumns, QVariant> node = this->m_associationData[index.row()];
|
||||
if (node.size() == 0) {
|
||||
qCWarning(associationModel) << "data: Cant find any Node on Row " << index.row();
|
||||
return QVariant();
|
||||
}
|
||||
return node[static_cast<associationColumns>(index.column())];
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
}
|
||||
|
||||
QVariant QTOZW_Associations::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
if (orientation == Qt::Horizontal) {
|
||||
switch (static_cast<associationColumns>(section)) {
|
||||
case NodeID:
|
||||
return tr("NodeID");
|
||||
|
||||
case GroupID:
|
||||
return tr("Group ID");
|
||||
|
||||
case GroupName:
|
||||
return tr("Group Name");
|
||||
|
||||
case GroupHelp:
|
||||
return tr("Help");
|
||||
|
||||
case MaxAssocations:
|
||||
return tr("Max Assocations");
|
||||
|
||||
case Members:
|
||||
return tr("Members");
|
||||
|
||||
case Flags:
|
||||
return tr("Flags");
|
||||
|
||||
case Count:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant QTOZW_Associations::getassocationData(quint8 _node, quint8 _groupIDX, associationColumns _column) {
|
||||
int32_t row = this->getassocationRow(_node, _groupIDX);
|
||||
if (row >= 0)
|
||||
return this->m_associationData[row][_column];
|
||||
qCWarning(associationModel) << "Can't find Group " << _groupIDX << " for node " << _node << " in m_associationData";
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int32_t QTOZW_Associations::getassocationRow(quint8 _node, quint8 _groupIDX) {
|
||||
if (this->m_associationData.count() == 0) {
|
||||
return -1;
|
||||
}
|
||||
QMap<int32_t, QMap<associationColumns, QVariant> >::iterator it;
|
||||
for (it = m_associationData.begin(); it != m_associationData.end(); ++it) {
|
||||
QMap<associationColumns, QVariant> group = it.value();
|
||||
if (group.value(associationColumns::NodeID) == _node) {
|
||||
if (group.value(associationColumns::GroupID) == _groupIDX) {
|
||||
qCDebug(associationModel) << "getAssociationRow: Found Association at Row " << it.key();
|
||||
return it.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
qCWarning(associationModel) << "Can't Find Group " << _groupIDX << " for node " << _node << " in m_associationData";
|
||||
return -1;
|
||||
}
|
|
@ -1,103 +1,6 @@
|
|||
#include <QDebug>
|
||||
#include <QBitArray>
|
||||
#include "qtozw_logging.h"
|
||||
#include "qtozwassociations.h"
|
||||
#include "qtopenzwave.h"
|
||||
|
||||
|
||||
QTOZW_Associations::QTOZW_Associations(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
int QTOZW_Associations::rowCount(const QModelIndex &parent) const {
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
return this->m_associationData.count();
|
||||
}
|
||||
int QTOZW_Associations::columnCount(const QModelIndex &parent) const {
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
return QTOZW_Associations::associationColumns::Count;
|
||||
}
|
||||
QVariant QTOZW_Associations::data(const QModelIndex &index, int role) const {
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (index.row() >= this->rowCount(index.parent()) || index.row() < 0)
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
QMap<associationColumns, QVariant> node = this->m_associationData[index.row()];
|
||||
if (node.size() == 0) {
|
||||
qCWarning(associationModel) << "data: Cant find any Node on Row " << index.row();
|
||||
return QVariant();
|
||||
}
|
||||
return node[static_cast<associationColumns>(index.column())];
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
}
|
||||
|
||||
QVariant QTOZW_Associations::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
if (orientation == Qt::Horizontal) {
|
||||
switch (static_cast<associationColumns>(section)) {
|
||||
case NodeID:
|
||||
return tr("NodeID");
|
||||
|
||||
case GroupID:
|
||||
return tr("Group ID");
|
||||
|
||||
case GroupName:
|
||||
return tr("Group Name");
|
||||
|
||||
case GroupHelp:
|
||||
return tr("Help");
|
||||
|
||||
case MaxAssocations:
|
||||
return tr("Max Assocations");
|
||||
|
||||
case Members:
|
||||
return tr("Members");
|
||||
|
||||
case Flags:
|
||||
return tr("Flags");
|
||||
|
||||
case Count:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant QTOZW_Associations::getassocationData(quint8 _node, quint8 _groupIDX, associationColumns _column) {
|
||||
int32_t row = this->getassocationRow(_node, _groupIDX);
|
||||
if (row >= 0)
|
||||
return this->m_associationData[row][_column];
|
||||
qCWarning(associationModel) << "Can't find Group " << _groupIDX << " for node " << _node << " in m_associationData";
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int32_t QTOZW_Associations::getassocationRow(quint8 _node, quint8 _groupIDX) {
|
||||
if (this->m_associationData.count() == 0) {
|
||||
return -1;
|
||||
}
|
||||
QMap<int32_t, QMap<associationColumns, QVariant> >::iterator it;
|
||||
for (it = m_associationData.begin(); it != m_associationData.end(); ++it) {
|
||||
QMap<associationColumns, QVariant> group = it.value();
|
||||
if (group.value(associationColumns::NodeID) == _node) {
|
||||
if (group.value(associationColumns::GroupID) == _groupIDX) {
|
||||
qCDebug(associationModel) << "getAssociationRow: Found Association at Row " << it.key();
|
||||
return it.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
qCWarning(associationModel) << "Can't Find Group " << _groupIDX << " for node " << _node << " in m_associationData";
|
||||
return -1;
|
||||
}
|
||||
#include "qtozwassociationmodel_p.h"
|
||||
|
||||
QTOZW_Associations_internal::QTOZW_Associations_internal(QObject *parent)
|
||||
: QTOZW_Associations(parent)
|
||||
|
@ -114,7 +17,7 @@ void QTOZW_Associations_internal::addGroup(quint8 _nodeID, quint8 _groupIDX) {
|
|||
newNode[associationColumns::NodeID] = _nodeID;
|
||||
newNode[associationColumns::GroupID] = _groupIDX;
|
||||
newNode[associationColumns::Members] = QStringList();
|
||||
QBitArray flags(static_cast<int>(QTOZW_Nodes::flagCount));
|
||||
QBitArray flags(static_cast<int>(associationFlags::FlagCount));
|
||||
newNode[associationColumns::Flags] = flags;
|
||||
|
||||
this->beginInsertRows(QModelIndex(), this->rowCount(QModelIndex()), this->rowCount(QModelIndex()));
|
||||
|
@ -153,7 +56,7 @@ void QTOZW_Associations_internal::setGroupFlags(quint8 _nodeID, quint8 _groupIDX
|
|||
qCWarning(associationModel) << "setGroupFlags: Can't Find Group " << _groupIDX << "on node " << _nodeID;
|
||||
return;
|
||||
}
|
||||
QBitArray flags(static_cast<int>(QTOZW_Nodes::flagCount));
|
||||
QBitArray flags(static_cast<int>(associationFlags::FlagCount));
|
||||
flags = this->m_associationData[row][associationColumns::Flags].toBitArray();
|
||||
flags.setBit(_flags, _value);
|
||||
this->m_associationData[row][associationColumns::Flags] = flags;
|
278
qt-openzwave/source/qtozwmanager.cpp
Normal file
278
qt-openzwave/source/qtozwmanager.cpp
Normal file
|
@ -0,0 +1,278 @@
|
|||
#include <unistd.h>
|
||||
#include <QDebug>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QAbstractItemModelReplica>
|
||||
#include "qt-openzwave/qtozwmanager.h"
|
||||
#include "qtozwmanager_p.h"
|
||||
#include "qtozw_logging.h"
|
||||
|
||||
|
||||
QTOZWManager::QTOZWManager(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_running(false)
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool QTOZWManager::initilizeBase() {
|
||||
return true;
|
||||
}
|
||||
bool QTOZWManager::initilizeSource(bool enableServer) {
|
||||
initilizeBase();
|
||||
this->m_connectionType = connectionType::Local;
|
||||
this->d_ptr_internal = new QTOZWManager_Internal(this);
|
||||
if (enableServer) {
|
||||
this->m_sourceNode = new QRemoteObjectHost(QUrl(QStringLiteral("tcp://0.0.0.0:1983")), this);
|
||||
QObject::connect(this->m_sourceNode, &QRemoteObjectHost::error, this, &QTOZWManager::onSourceError);
|
||||
//this->m_sourceNode->setHeartbeatInterval(1000);
|
||||
this->m_sourceNode->enableRemoting<QTOZWManagerSourceAPI>(this->d_ptr_internal);
|
||||
QVector<int> roles;
|
||||
roles << Qt::DisplayRole << Qt::EditRole << Qt::ToolTipRole;
|
||||
this->m_sourceNode->enableRemoting(this->d_ptr_internal->getNodeModel(), "QTOZW_nodeModel", roles);
|
||||
this->m_sourceNode->enableRemoting(this->d_ptr_internal->getValueModel(), "QTOZW_valueModel", roles);
|
||||
this->m_sourceNode->enableRemoting(this->d_ptr_internal->getAssociationModel(), "QTOZW_associationModel", roles);
|
||||
}
|
||||
connectSignals();
|
||||
emit this->ready();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QTOZWManager::initilizeReplica(QUrl remote) {
|
||||
initilizeBase();
|
||||
this->m_connectionType = connectionType::Remote;
|
||||
this->m_replicaNode = new QRemoteObjectNode(this);
|
||||
QObject::connect(this->m_replicaNode, &QRemoteObjectNode::error, this, &QTOZWManager::onReplicaError);
|
||||
if (this->m_replicaNode->connectToNode(remote)) {
|
||||
this->d_ptr_replica = this->m_replicaNode->acquire<QTOZWManagerReplica>("QTOZWManager");
|
||||
QObject::connect(this->d_ptr_replica, &QTOZWManagerReplica::stateChanged, this, &QTOZWManager::onManagerStateChange);
|
||||
this->m_nodeModel = this->m_replicaNode->acquireModel("QTOZW_nodeModel", QtRemoteObjects::InitialAction::PrefetchData);
|
||||
QObject::connect(qobject_cast<QAbstractItemModelReplica*>(this->m_nodeModel), &QAbstractItemModelReplica::initialized, this, &QTOZWManager::onNodeInitialized);
|
||||
this->m_valueModel= this->m_replicaNode->acquireModel("QTOZW_valueModel", QtRemoteObjects::InitialAction::PrefetchData);
|
||||
QObject::connect(qobject_cast<QAbstractItemModelReplica*>(this->m_valueModel), &QAbstractItemModelReplica::initialized, this, &QTOZWManager::onValueInitialized);
|
||||
this->m_associationModel= this->m_replicaNode->acquireModel("QTOZW_associationModel", QtRemoteObjects::InitialAction::PrefetchData);
|
||||
QObject::connect(qobject_cast<QAbstractItemModelReplica*>(this->m_associationModel), &QAbstractItemModelReplica::initialized, this, &QTOZWManager::onAssociationInitialized);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QTOZWManager::onReplicaError(QRemoteObjectNode::ErrorCode error) {
|
||||
qCWarning(manager) << "Replica Error: " << error;
|
||||
/* raise this upto the application */
|
||||
}
|
||||
|
||||
void QTOZWManager::onSourceError(QRemoteObjectHost::ErrorCode error) {
|
||||
qCWarning(manager) << "Host Error: " << error;
|
||||
/* raise this upto the application */
|
||||
}
|
||||
|
||||
void QTOZWManager::onManagerStateChange(QRemoteObjectReplica::State state) {
|
||||
this->m_managerState = state;
|
||||
this->checkReplicaReady();
|
||||
}
|
||||
void QTOZWManager::onNodeInitialized() {
|
||||
this->m_nodeState = true;
|
||||
this->checkReplicaReady();
|
||||
}
|
||||
void QTOZWManager::onValueInitialized() {
|
||||
this->m_valuesState = true;
|
||||
this->checkReplicaReady();
|
||||
}
|
||||
void QTOZWManager::onAssociationInitialized() {
|
||||
this->m_associationsState = true;
|
||||
this->checkReplicaReady();
|
||||
}
|
||||
|
||||
void QTOZWManager::checkReplicaReady() {
|
||||
if ((this->m_managerState == QRemoteObjectReplica::State::Valid) &&
|
||||
(this->m_nodeState == true) &&
|
||||
(this->m_valuesState == true) &&
|
||||
(this->m_associationsState == true)) {
|
||||
/* have to connect all the d_ptr SIGNALS to our SIGNALS now */
|
||||
connectSignals();
|
||||
emit this->ready();
|
||||
}
|
||||
}
|
||||
|
||||
bool QTOZWManager::isRunning() {
|
||||
return this->m_running;
|
||||
}
|
||||
|
||||
void QTOZWManager::setStarted() {
|
||||
qCDebug(manager) << "setStarted";
|
||||
this->m_running = true;
|
||||
}
|
||||
|
||||
void QTOZWManager::setStopped() {
|
||||
this->m_running = false;
|
||||
}
|
||||
|
||||
QAbstractItemModel *QTOZWManager::getNodeModel() {
|
||||
if (this->m_connectionType == connectionType::Local) {
|
||||
return this->d_ptr_internal->getNodeModel();
|
||||
} else {
|
||||
return this->m_nodeModel;
|
||||
}
|
||||
}
|
||||
QAbstractItemModel *QTOZWManager::getValueModel() {
|
||||
if (this->m_connectionType == connectionType::Local) {
|
||||
return this->d_ptr_internal->getValueModel();
|
||||
} else {
|
||||
return this->m_valueModel;
|
||||
}
|
||||
|
||||
}
|
||||
QAbstractItemModel *QTOZWManager::getAssociationModel() {
|
||||
if (this->m_connectionType == connectionType::Local) {
|
||||
return this->d_ptr_internal->getAssociationModel();
|
||||
} else {
|
||||
return this->m_associationModel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define CONNECT_DPTR(x) if (this->m_connectionType == connectionType::Local) { \
|
||||
QObject::connect(this->d_ptr_internal, &QTOZWManager_Internal::x, this, &QTOZWManager::x);\
|
||||
} else { \
|
||||
QObject::connect(this->d_ptr_replica, &QTOZWManagerReplica::x, this, &QTOZWManager::x); \
|
||||
};
|
||||
|
||||
#define CONNECT_DPTR1(x, y) if (this->m_connectionType == connectionType::Local) { \
|
||||
QObject::connect(this->d_ptr_internal, &QTOZWManager_Internal::x, this, &QTOZWManager::y);\
|
||||
} else { \
|
||||
QObject::connect(this->d_ptr_replica, &QTOZWManagerReplica::x, this, &QTOZWManager::y); \
|
||||
};
|
||||
|
||||
|
||||
void QTOZWManager::connectSignals() {
|
||||
CONNECT_DPTR(valueAdded);
|
||||
CONNECT_DPTR(valueRemoved);
|
||||
CONNECT_DPTR(valueChanged);
|
||||
CONNECT_DPTR(valueRefreshed);
|
||||
CONNECT_DPTR(nodeNew);
|
||||
CONNECT_DPTR(nodeAdded);
|
||||
CONNECT_DPTR(nodeRemoved);
|
||||
CONNECT_DPTR(nodeReset);
|
||||
CONNECT_DPTR(nodeNaming);
|
||||
CONNECT_DPTR(nodeEvent);
|
||||
CONNECT_DPTR(nodeProtocolInfo);
|
||||
CONNECT_DPTR(nodeEssentialNodeQueriesComplete);
|
||||
CONNECT_DPTR(nodeQueriesComplete);
|
||||
CONNECT_DPTR(driverReady);
|
||||
CONNECT_DPTR(driverFailed);
|
||||
CONNECT_DPTR(driverReset);
|
||||
CONNECT_DPTR(driverRemoved);
|
||||
CONNECT_DPTR(driverAllNodesQueriedSomeDead);
|
||||
CONNECT_DPTR(driverAllNodesQueried);
|
||||
CONNECT_DPTR(driverAwakeNodesQueried);
|
||||
CONNECT_DPTR(controllerCommand);
|
||||
// CONNECT_DPTR(ozwNotification);
|
||||
// CONNECT_DPTR(ozwUserAlert);
|
||||
CONNECT_DPTR(manufacturerSpecificDBReady);
|
||||
CONNECT_DPTR(starting);
|
||||
CONNECT_DPTR(started);
|
||||
CONNECT_DPTR(stopped);
|
||||
// CONNECT_DPTR(error);
|
||||
|
||||
/* some extra internal Signals we need to track */
|
||||
CONNECT_DPTR1(started, setStarted);
|
||||
CONNECT_DPTR1(stopped, setStopped)
|
||||
|
||||
}
|
||||
|
||||
#define CALL_DPTR(x) if (this->m_connectionType == QTOZWManager::connectionType::Local) this->d_ptr_internal->x; else this->d_ptr_replica->x;
|
||||
#define CALL_DPTR_RTN(x, y) if (this->m_connectionType == QTOZWManager::connectionType::Local) \
|
||||
return this->d_ptr_internal->x; \
|
||||
else { \
|
||||
QRemoteObjectPendingReply<y> res = this->d_ptr_replica->x; \
|
||||
res.waitForFinished(); \
|
||||
return res.returnValue(); \
|
||||
}
|
||||
|
||||
|
||||
bool QTOZWManager::open(QString serialPort) {
|
||||
CALL_DPTR_RTN(open(serialPort), bool);
|
||||
}
|
||||
bool QTOZWManager::refreshNodeInfo(quint8 _node) {
|
||||
CALL_DPTR_RTN(refreshNodeInfo(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::requestNodeState(quint8 _node) {
|
||||
CALL_DPTR_RTN(requestNodeState(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::requestNodeDynamic(quint8 _node) {
|
||||
CALL_DPTR_RTN(requestNodeDynamic(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::setConfigParam(quint8 _node, quint8 _param, qint32 _value, quint8 const _size) {
|
||||
CALL_DPTR_RTN(setConfigParam(_node, _param, _value, _size), bool);
|
||||
}
|
||||
void QTOZWManager::requestConfigParam(quint8 _node, quint8 _param) {
|
||||
CALL_DPTR(requestConfigParam(_node, _param));
|
||||
}
|
||||
void QTOZWManager::requestAllConfigParam(quint8 _node) {
|
||||
CALL_DPTR(requestAllConfigParam(_node));
|
||||
}
|
||||
void QTOZWManager::softResetController() {
|
||||
CALL_DPTR(softResetController());
|
||||
}
|
||||
void QTOZWManager::hardResetController() {
|
||||
CALL_DPTR(hardResetController());
|
||||
}
|
||||
bool QTOZWManager::cancelControllerCommand() {
|
||||
CALL_DPTR_RTN(cancelControllerCommand(), bool);
|
||||
}
|
||||
void QTOZWManager::testNetworkNode(quint8 _node, quint32 const _count) {
|
||||
CALL_DPTR(testNetworkNode(_node, _count));
|
||||
}
|
||||
void QTOZWManager::testNetwork(quint32 const _count) {
|
||||
CALL_DPTR(testNetwork(_count));
|
||||
}
|
||||
void QTOZWManager::healNetworkNode(quint8 _node, bool _doRR) {
|
||||
CALL_DPTR(healNetworkNode(_node, _doRR));
|
||||
}
|
||||
void QTOZWManager::healNetwork(bool _doRR) {
|
||||
CALL_DPTR(healNetwork(_doRR));
|
||||
}
|
||||
bool QTOZWManager::addNode(bool _doSecure) {
|
||||
CALL_DPTR_RTN(addNode(_doSecure), bool);
|
||||
}
|
||||
bool QTOZWManager::removeNode() {
|
||||
CALL_DPTR_RTN(removeNode(), bool);
|
||||
}
|
||||
bool QTOZWManager::removeFailedNode(quint8 _node) {
|
||||
CALL_DPTR_RTN(removeFailedNode(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::hasNodeFailed(quint8 _node) {
|
||||
CALL_DPTR_RTN(hasNodeFailed(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::requestNodeNeighborUpdate(quint8 _node) {
|
||||
CALL_DPTR_RTN(requestNodeNeighborUpdate(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::assignReturnRoute(quint8 _node) {
|
||||
CALL_DPTR_RTN(assignReturnRoute(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::deleteAllReturnRoute(quint8 _node) {
|
||||
CALL_DPTR_RTN(deleteAllReturnRoute(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::sendNodeInfomation(quint8 _node) {
|
||||
CALL_DPTR_RTN(sendNodeInfomation(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::replaceFailedNode(quint8 _node) {
|
||||
CALL_DPTR_RTN(replaceFailedNode(_node), bool)
|
||||
}
|
||||
bool QTOZWManager::requestNetworkUpdate(quint8 _node) {
|
||||
CALL_DPTR_RTN(requestNetworkUpdate(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::checkLatestConfigFileRevision(quint8 const _node) {
|
||||
CALL_DPTR_RTN(checkLatestConfigFileRevision(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::checkLatestMFSRevision() {
|
||||
CALL_DPTR_RTN(checkLatestMFSRevision(), bool);
|
||||
}
|
||||
bool QTOZWManager::downloadLatestConfigFileRevision(quint8 const _node) {
|
||||
CALL_DPTR_RTN(downloadLatestConfigFileRevision(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::downloadLatestMFSRevision() {
|
||||
CALL_DPTR_RTN(downloadLatestMFSRevision(), bool);
|
||||
}
|
|
@ -1,22 +1,22 @@
|
|||
#include <unistd.h>
|
||||
#include <QDebug>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QAbstractItemModelReplica>
|
||||
#include "qtozw_logging.h"
|
||||
#include "qtozwmanager.h"
|
||||
#include "qtozwnodemodel.h"
|
||||
#include "qtozwassociations.h"
|
||||
#include "qtozwmanager_p.h"
|
||||
#include "qt-openzwave/qtozwmanager.h"
|
||||
|
||||
/* XXX TODO: this needs to go into OZW */
|
||||
QString nodeBasicStr (uint8 basic)
|
||||
{
|
||||
switch (basic) {
|
||||
case 1:
|
||||
return "Controller";
|
||||
case 2:
|
||||
return "Static Controller";
|
||||
case 3:
|
||||
return "Slave";
|
||||
case 4:
|
||||
return "Routing Slave";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
#include "qtozwnotification.h"
|
||||
|
||||
#include "Manager.h"
|
||||
#include "Options.h"
|
||||
#include "Notification.h"
|
||||
#include "platform/Log.h"
|
||||
#include "OZWException.h"
|
||||
|
||||
QString nodeBasicStr (uint8 basic);
|
||||
|
||||
QTOZWManager_Internal::QTOZWManager_Internal(QObject *parent)
|
||||
: QTOZWManagerSimpleSource (parent)
|
||||
|
@ -1258,291 +1258,3 @@ void QTOZWManager_Internal::pvt_valueModelDataChanged(const QModelIndex &topLeft
|
|||
this->setErrorString(e.GetMsg().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* XXX TODO: this needs to go into OZW */
|
||||
QString nodeBasicStr (uint8 basic)
|
||||
{
|
||||
switch (basic) {
|
||||
case 1:
|
||||
return "Controller";
|
||||
case 2:
|
||||
return "Static Controller";
|
||||
case 3:
|
||||
return "Slave";
|
||||
case 4:
|
||||
return "Routing Slave";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
QTOZWManager::QTOZWManager(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_running(false)
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool QTOZWManager::initilizeBase() {
|
||||
return true;
|
||||
}
|
||||
bool QTOZWManager::initilizeSource(bool enableServer) {
|
||||
initilizeBase();
|
||||
this->m_connectionType = connectionType::Local;
|
||||
this->d_ptr_internal = new QTOZWManager_Internal(this);
|
||||
if (enableServer) {
|
||||
this->m_sourceNode = new QRemoteObjectHost(QUrl(QStringLiteral("tcp://0.0.0.0:1983")), this);
|
||||
QObject::connect(this->m_sourceNode, &QRemoteObjectHost::error, this, &QTOZWManager::onSourceError);
|
||||
//this->m_sourceNode->setHeartbeatInterval(1000);
|
||||
this->m_sourceNode->enableRemoting<QTOZWManagerSourceAPI>(this->d_ptr_internal);
|
||||
QVector<int> roles;
|
||||
roles << Qt::DisplayRole << Qt::EditRole << Qt::ToolTipRole;
|
||||
this->m_sourceNode->enableRemoting(this->d_ptr_internal->getNodeModel(), "QTOZW_nodeModel", roles);
|
||||
this->m_sourceNode->enableRemoting(this->d_ptr_internal->getValueModel(), "QTOZW_valueModel", roles);
|
||||
this->m_sourceNode->enableRemoting(this->d_ptr_internal->getAssociationModel(), "QTOZW_associationModel", roles);
|
||||
}
|
||||
connectSignals();
|
||||
emit this->ready();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QTOZWManager::initilizeReplica(QUrl remote) {
|
||||
initilizeBase();
|
||||
this->m_connectionType = connectionType::Remote;
|
||||
this->m_replicaNode = new QRemoteObjectNode(this);
|
||||
QObject::connect(this->m_replicaNode, &QRemoteObjectNode::error, this, &QTOZWManager::onReplicaError);
|
||||
if (this->m_replicaNode->connectToNode(remote)) {
|
||||
this->d_ptr_replica = this->m_replicaNode->acquire<QTOZWManagerReplica>("QTOZWManager");
|
||||
QObject::connect(this->d_ptr_replica, &QTOZWManagerReplica::stateChanged, this, &QTOZWManager::onManagerStateChange);
|
||||
this->m_nodeModel = this->m_replicaNode->acquireModel("QTOZW_nodeModel");
|
||||
QObject::connect(qobject_cast<QAbstractItemModelReplica*>(this->m_nodeModel), &QAbstractItemModelReplica::initialized, this, &QTOZWManager::onNodeInitialized);
|
||||
this->m_valueModel= this->m_replicaNode->acquireModel("QTOZW_valueModel");
|
||||
QObject::connect(qobject_cast<QAbstractItemModelReplica*>(this->m_valueModel), &QAbstractItemModelReplica::initialized, this, &QTOZWManager::onValueInitialized);
|
||||
this->m_associationModel= this->m_replicaNode->acquireModel("QTOZW_associationModel");
|
||||
QObject::connect(qobject_cast<QAbstractItemModelReplica*>(this->m_associationModel), &QAbstractItemModelReplica::initialized, this, &QTOZWManager::onAssociationInitialized);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QTOZWManager::onReplicaError(QRemoteObjectNode::ErrorCode error) {
|
||||
qCWarning(manager) << "Replica Error: " << error;
|
||||
/* raise this upto the application */
|
||||
}
|
||||
|
||||
void QTOZWManager::onSourceError(QRemoteObjectHost::ErrorCode error) {
|
||||
qCWarning(manager) << "Host Error: " << error;
|
||||
/* raise this upto the application */
|
||||
}
|
||||
|
||||
void QTOZWManager::onManagerStateChange(QRemoteObjectReplica::State state) {
|
||||
this->m_managerState = state;
|
||||
this->checkReplicaReady();
|
||||
}
|
||||
void QTOZWManager::onNodeInitialized() {
|
||||
this->m_nodeState = true;
|
||||
this->checkReplicaReady();
|
||||
}
|
||||
void QTOZWManager::onValueInitialized() {
|
||||
this->m_valuesState = true;
|
||||
this->checkReplicaReady();
|
||||
}
|
||||
void QTOZWManager::onAssociationInitialized() {
|
||||
this->m_associationsState = true;
|
||||
this->checkReplicaReady();
|
||||
}
|
||||
|
||||
void QTOZWManager::checkReplicaReady() {
|
||||
if ((this->m_managerState == QRemoteObjectReplica::State::Valid) &&
|
||||
(this->m_nodeState == true) &&
|
||||
(this->m_valuesState == true) &&
|
||||
(this->m_associationsState == true)) {
|
||||
/* have to connect all the d_ptr SIGNALS to our SIGNALS now */
|
||||
connectSignals();
|
||||
emit this->ready();
|
||||
}
|
||||
}
|
||||
|
||||
bool QTOZWManager::isRunning() {
|
||||
return this->m_running;
|
||||
}
|
||||
|
||||
void QTOZWManager::setStarted() {
|
||||
qCDebug(manager) << "setStarted";
|
||||
this->m_running = true;
|
||||
}
|
||||
|
||||
void QTOZWManager::setStopped() {
|
||||
this->m_running = false;
|
||||
}
|
||||
|
||||
QAbstractItemModel *QTOZWManager::getNodeModel() {
|
||||
if (this->m_connectionType == connectionType::Local) {
|
||||
return this->d_ptr_internal->getNodeModel();
|
||||
} else {
|
||||
return this->m_nodeModel;
|
||||
}
|
||||
}
|
||||
QAbstractItemModel *QTOZWManager::getValueModel() {
|
||||
if (this->m_connectionType == connectionType::Local) {
|
||||
return this->d_ptr_internal->getValueModel();
|
||||
} else {
|
||||
return this->m_valueModel;
|
||||
}
|
||||
|
||||
}
|
||||
QAbstractItemModel *QTOZWManager::getAssociationModel() {
|
||||
if (this->m_connectionType == connectionType::Local) {
|
||||
return this->d_ptr_internal->getAssociationModel();
|
||||
} else {
|
||||
return this->m_associationModel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define CONNECT_DPTR(x) if (this->m_connectionType == connectionType::Local) { \
|
||||
QObject::connect(this->d_ptr_internal, &QTOZWManager_Internal::x, this, &QTOZWManager::x);\
|
||||
} else { \
|
||||
QObject::connect(this->d_ptr_replica, &QTOZWManagerReplica::x, this, &QTOZWManager::x); \
|
||||
};
|
||||
|
||||
#define CONNECT_DPTR1(x, y) if (this->m_connectionType == connectionType::Local) { \
|
||||
QObject::connect(this->d_ptr_internal, &QTOZWManager_Internal::x, this, &QTOZWManager::y);\
|
||||
} else { \
|
||||
QObject::connect(this->d_ptr_replica, &QTOZWManagerReplica::x, this, &QTOZWManager::y); \
|
||||
};
|
||||
|
||||
|
||||
void QTOZWManager::connectSignals() {
|
||||
CONNECT_DPTR(valueAdded);
|
||||
CONNECT_DPTR(valueRemoved);
|
||||
CONNECT_DPTR(valueChanged);
|
||||
CONNECT_DPTR(valueRefreshed);
|
||||
CONNECT_DPTR(nodeNew);
|
||||
CONNECT_DPTR(nodeAdded);
|
||||
CONNECT_DPTR(nodeRemoved);
|
||||
CONNECT_DPTR(nodeReset);
|
||||
CONNECT_DPTR(nodeNaming);
|
||||
CONNECT_DPTR(nodeEvent);
|
||||
CONNECT_DPTR(nodeProtocolInfo);
|
||||
CONNECT_DPTR(nodeEssentialNodeQueriesComplete);
|
||||
CONNECT_DPTR(nodeQueriesComplete);
|
||||
CONNECT_DPTR(driverReady);
|
||||
CONNECT_DPTR(driverFailed);
|
||||
CONNECT_DPTR(driverReset);
|
||||
CONNECT_DPTR(driverRemoved);
|
||||
CONNECT_DPTR(driverAllNodesQueriedSomeDead);
|
||||
CONNECT_DPTR(driverAllNodesQueried);
|
||||
CONNECT_DPTR(driverAwakeNodesQueried);
|
||||
CONNECT_DPTR(controllerCommand);
|
||||
// CONNECT_DPTR(ozwNotification);
|
||||
// CONNECT_DPTR(ozwUserAlert);
|
||||
CONNECT_DPTR(manufacturerSpecificDBReady);
|
||||
CONNECT_DPTR(starting);
|
||||
CONNECT_DPTR(started);
|
||||
CONNECT_DPTR(stopped);
|
||||
// CONNECT_DPTR(error);
|
||||
|
||||
/* some extra internal Signals we need to track */
|
||||
CONNECT_DPTR1(started, setStarted);
|
||||
CONNECT_DPTR1(stopped, setStopped)
|
||||
|
||||
}
|
||||
|
||||
#define CALL_DPTR(x) if (this->m_connectionType == QTOZWManager::connectionType::Local) this->d_ptr_internal->x; else this->d_ptr_replica->x;
|
||||
#define CALL_DPTR_RTN(x, y) if (this->m_connectionType == QTOZWManager::connectionType::Local) \
|
||||
return this->d_ptr_internal->x; \
|
||||
else { \
|
||||
QRemoteObjectPendingReply<y> res = this->d_ptr_replica->x; \
|
||||
res.waitForFinished(); \
|
||||
return res.returnValue(); \
|
||||
}
|
||||
|
||||
|
||||
bool QTOZWManager::open(QString serialPort) {
|
||||
CALL_DPTR_RTN(open(serialPort), bool);
|
||||
}
|
||||
bool QTOZWManager::refreshNodeInfo(quint8 _node) {
|
||||
CALL_DPTR_RTN(refreshNodeInfo(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::requestNodeState(quint8 _node) {
|
||||
CALL_DPTR_RTN(requestNodeState(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::requestNodeDynamic(quint8 _node) {
|
||||
CALL_DPTR_RTN(requestNodeDynamic(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::setConfigParam(quint8 _node, quint8 _param, qint32 _value, quint8 const _size) {
|
||||
CALL_DPTR_RTN(setConfigParam(_node, _param, _value, _size), bool);
|
||||
}
|
||||
void QTOZWManager::requestConfigParam(quint8 _node, quint8 _param) {
|
||||
CALL_DPTR(requestConfigParam(_node, _param));
|
||||
}
|
||||
void QTOZWManager::requestAllConfigParam(quint8 _node) {
|
||||
CALL_DPTR(requestAllConfigParam(_node));
|
||||
}
|
||||
void QTOZWManager::softResetController() {
|
||||
CALL_DPTR(softResetController());
|
||||
}
|
||||
void QTOZWManager::hardResetController() {
|
||||
CALL_DPTR(hardResetController());
|
||||
}
|
||||
bool QTOZWManager::cancelControllerCommand() {
|
||||
CALL_DPTR_RTN(cancelControllerCommand(), bool);
|
||||
}
|
||||
void QTOZWManager::testNetworkNode(quint8 _node, quint32 const _count) {
|
||||
CALL_DPTR(testNetworkNode(_node, _count));
|
||||
}
|
||||
void QTOZWManager::testNetwork(quint32 const _count) {
|
||||
CALL_DPTR(testNetwork(_count));
|
||||
}
|
||||
void QTOZWManager::healNetworkNode(quint8 _node, bool _doRR) {
|
||||
CALL_DPTR(healNetworkNode(_node, _doRR));
|
||||
}
|
||||
void QTOZWManager::healNetwork(bool _doRR) {
|
||||
CALL_DPTR(healNetwork(_doRR));
|
||||
}
|
||||
bool QTOZWManager::addNode(bool _doSecure) {
|
||||
CALL_DPTR_RTN(addNode(_doSecure), bool);
|
||||
}
|
||||
bool QTOZWManager::removeNode() {
|
||||
CALL_DPTR_RTN(removeNode(), bool);
|
||||
}
|
||||
bool QTOZWManager::removeFailedNode(quint8 _node) {
|
||||
CALL_DPTR_RTN(removeFailedNode(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::hasNodeFailed(quint8 _node) {
|
||||
CALL_DPTR_RTN(hasNodeFailed(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::requestNodeNeighborUpdate(quint8 _node) {
|
||||
CALL_DPTR_RTN(requestNodeNeighborUpdate(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::assignReturnRoute(quint8 _node) {
|
||||
CALL_DPTR_RTN(assignReturnRoute(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::deleteAllReturnRoute(quint8 _node) {
|
||||
CALL_DPTR_RTN(deleteAllReturnRoute(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::sendNodeInfomation(quint8 _node) {
|
||||
CALL_DPTR_RTN(sendNodeInfomation(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::replaceFailedNode(quint8 _node) {
|
||||
CALL_DPTR_RTN(replaceFailedNode(_node), bool)
|
||||
}
|
||||
bool QTOZWManager::requestNetworkUpdate(quint8 _node) {
|
||||
CALL_DPTR_RTN(requestNetworkUpdate(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::checkLatestConfigFileRevision(quint8 const _node) {
|
||||
CALL_DPTR_RTN(checkLatestConfigFileRevision(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::checkLatestMFSRevision() {
|
||||
CALL_DPTR_RTN(checkLatestMFSRevision(), bool);
|
||||
}
|
||||
bool QTOZWManager::downloadLatestConfigFileRevision(quint8 const _node) {
|
||||
CALL_DPTR_RTN(downloadLatestConfigFileRevision(_node), bool);
|
||||
}
|
||||
bool QTOZWManager::downloadLatestMFSRevision() {
|
||||
CALL_DPTR_RTN(downloadLatestMFSRevision(), bool);
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
#include <QDebug>
|
||||
#include <QBitArray>
|
||||
#include "qtozw_logging.h"
|
||||
#include "qtozwnodemodel.h"
|
||||
#include "qtopenzwave.h"
|
||||
#include "qt-openzwave/qtozwnodemodel.h"
|
||||
#include "qt-openzwave/qtopenzwave.h"
|
||||
|
||||
|
||||
QTOZW_Nodes::QTOZW_Nodes(QObject *parent)
|
||||
|
@ -178,84 +178,3 @@ int32_t QTOZW_Nodes::getNodeRow(quint8 _node) {
|
|||
qCWarning(nodeModel) << "Can't Find NodeID " << _node << " in NodeData";
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QTOZW_Nodes_internal::QTOZW_Nodes_internal(QObject *parent)
|
||||
: QTOZW_Nodes(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QTOZW_Nodes_internal::addNode(quint8 _nodeID)
|
||||
{
|
||||
if (this->getNodeRow(_nodeID) >= 0) {
|
||||
qCWarning(nodeModel) << "Node " << _nodeID << " Already Exists";
|
||||
return;
|
||||
}
|
||||
QMap<QTOZW_Nodes::NodeColumns, QVariant> newNode;
|
||||
newNode[QTOZW_Nodes::NodeID] = _nodeID;
|
||||
QBitArray flags(static_cast<int>(QTOZW_Nodes::flagCount));
|
||||
newNode[QTOZW_Nodes::NodeFlags] = flags;
|
||||
|
||||
this->beginInsertRows(QModelIndex(), this->rowCount(QModelIndex()), this->rowCount(QModelIndex()));
|
||||
this->m_nodeData[this->rowCount(QModelIndex())] = newNode;
|
||||
this->endInsertRows();
|
||||
}
|
||||
|
||||
void QTOZW_Nodes_internal::setNodeData(quint8 _nodeID, QTOZW_Nodes::NodeColumns column, QVariant data)
|
||||
{
|
||||
int row = this->getNodeRow(_nodeID);
|
||||
if (row == -1) {
|
||||
qCWarning(nodeModel) << "setNodeData: Node " << _nodeID << " does not exist";
|
||||
return;
|
||||
}
|
||||
if (this->m_nodeData[row][column] != data) {
|
||||
this->m_nodeData[row][column] = data;
|
||||
QVector<int> roles;
|
||||
roles << Qt::DisplayRole;
|
||||
this->dataChanged(this->createIndex(row, column), this->createIndex(row, column), roles);
|
||||
}
|
||||
}
|
||||
|
||||
void QTOZW_Nodes_internal::setNodeFlags(quint8 _nodeID, QTOZW_Nodes::nodeFlags _flags, bool _value)
|
||||
{
|
||||
int row = this->getNodeRow(_nodeID);
|
||||
if (row == -1) {
|
||||
qCWarning(nodeModel) << "setNodeData: Node " << _nodeID << " does not exist";
|
||||
return;
|
||||
}
|
||||
QBitArray flag = this->m_nodeData[row][QTOZW_Nodes::NodeFlags].toBitArray();
|
||||
if (flag.at(_flags) != _value) {
|
||||
flag.setBit(_flags, _value);
|
||||
this->m_nodeData[row][QTOZW_Nodes::NodeFlags] = flag;
|
||||
QVector<int> roles;
|
||||
roles << Qt::DisplayRole;
|
||||
this->dataChanged(this->createIndex(row, QTOZW_Nodes::NodeFlags), this->createIndex(row, QTOZW_Nodes::NodeFlags), roles);
|
||||
}
|
||||
}
|
||||
void QTOZW_Nodes_internal::delNode(quint8 _nodeID) {
|
||||
QMap<int32_t, QMap<NodeColumns, QVariant> >::iterator it;
|
||||
QMap<int32_t, QMap<NodeColumns, QVariant> > newNodeMap;
|
||||
int32_t newrow = 0;
|
||||
for (it = this->m_nodeData.begin(); it != this->m_nodeData.end(); ++it) {
|
||||
if (it.value()[QTOZW_Nodes::NodeColumns::NodeID] == _nodeID) {
|
||||
qCDebug(nodeModel) << "Removing Node " << it.value()[QTOZW_Nodes::NodeColumns::NodeID] << it.key();
|
||||
this->beginRemoveRows(QModelIndex(), it.key(), it.key());
|
||||
this->m_nodeData.erase(it);
|
||||
this->endRemoveRows();
|
||||
continue;
|
||||
} else {
|
||||
newNodeMap[newrow] = it.value();
|
||||
newrow++;
|
||||
}
|
||||
}
|
||||
this->m_nodeData.swap(newNodeMap);
|
||||
}
|
||||
|
||||
void QTOZW_Nodes_internal::resetModel() {
|
||||
this->beginRemoveRows(QModelIndex(), 0, this->m_nodeData.count());
|
||||
this->m_nodeData.clear();
|
||||
this->endRemoveRows();
|
||||
}
|
82
qt-openzwave/source/qtozwnodemodel_p.cpp
Normal file
82
qt-openzwave/source/qtozwnodemodel_p.cpp
Normal file
|
@ -0,0 +1,82 @@
|
|||
#include <QBitArray>
|
||||
#include "qtozw_logging.h"
|
||||
#include "qtozwnodemodel_p.h"
|
||||
|
||||
|
||||
QTOZW_Nodes_internal::QTOZW_Nodes_internal(QObject *parent)
|
||||
: QTOZW_Nodes(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QTOZW_Nodes_internal::addNode(quint8 _nodeID)
|
||||
{
|
||||
if (this->getNodeRow(_nodeID) >= 0) {
|
||||
qCWarning(nodeModel) << "Node " << _nodeID << " Already Exists";
|
||||
return;
|
||||
}
|
||||
QMap<QTOZW_Nodes::NodeColumns, QVariant> newNode;
|
||||
newNode[QTOZW_Nodes::NodeID] = _nodeID;
|
||||
QBitArray flags(static_cast<int>(QTOZW_Nodes::flagCount));
|
||||
newNode[QTOZW_Nodes::NodeFlags] = flags;
|
||||
|
||||
this->beginInsertRows(QModelIndex(), this->rowCount(QModelIndex()), this->rowCount(QModelIndex()));
|
||||
this->m_nodeData[this->rowCount(QModelIndex())] = newNode;
|
||||
this->endInsertRows();
|
||||
}
|
||||
|
||||
void QTOZW_Nodes_internal::setNodeData(quint8 _nodeID, QTOZW_Nodes::NodeColumns column, QVariant data)
|
||||
{
|
||||
int row = this->getNodeRow(_nodeID);
|
||||
if (row == -1) {
|
||||
qCWarning(nodeModel) << "setNodeData: Node " << _nodeID << " does not exist";
|
||||
return;
|
||||
}
|
||||
if (this->m_nodeData[row][column] != data) {
|
||||
this->m_nodeData[row][column] = data;
|
||||
QVector<int> roles;
|
||||
roles << Qt::DisplayRole;
|
||||
this->dataChanged(this->createIndex(row, column), this->createIndex(row, column), roles);
|
||||
}
|
||||
}
|
||||
|
||||
void QTOZW_Nodes_internal::setNodeFlags(quint8 _nodeID, QTOZW_Nodes::nodeFlags _flags, bool _value)
|
||||
{
|
||||
int row = this->getNodeRow(_nodeID);
|
||||
if (row == -1) {
|
||||
qCWarning(nodeModel) << "setNodeData: Node " << _nodeID << " does not exist";
|
||||
return;
|
||||
}
|
||||
QBitArray flag = this->m_nodeData[row][QTOZW_Nodes::NodeFlags].toBitArray();
|
||||
if (flag.at(_flags) != _value) {
|
||||
flag.setBit(_flags, _value);
|
||||
this->m_nodeData[row][QTOZW_Nodes::NodeFlags] = flag;
|
||||
QVector<int> roles;
|
||||
roles << Qt::DisplayRole;
|
||||
this->dataChanged(this->createIndex(row, QTOZW_Nodes::NodeFlags), this->createIndex(row, QTOZW_Nodes::NodeFlags), roles);
|
||||
}
|
||||
}
|
||||
void QTOZW_Nodes_internal::delNode(quint8 _nodeID) {
|
||||
QMap<int32_t, QMap<NodeColumns, QVariant> >::iterator it;
|
||||
QMap<int32_t, QMap<NodeColumns, QVariant> > newNodeMap;
|
||||
int32_t newrow = 0;
|
||||
for (it = this->m_nodeData.begin(); it != this->m_nodeData.end(); ++it) {
|
||||
if (it.value()[QTOZW_Nodes::NodeColumns::NodeID] == _nodeID) {
|
||||
qCDebug(nodeModel) << "Removing Node " << it.value()[QTOZW_Nodes::NodeColumns::NodeID] << it.key();
|
||||
this->beginRemoveRows(QModelIndex(), it.key(), it.key());
|
||||
this->m_nodeData.erase(it);
|
||||
this->endRemoveRows();
|
||||
continue;
|
||||
} else {
|
||||
newNodeMap[newrow] = it.value();
|
||||
newrow++;
|
||||
}
|
||||
}
|
||||
this->m_nodeData.swap(newNodeMap);
|
||||
}
|
||||
|
||||
void QTOZW_Nodes_internal::resetModel() {
|
||||
this->beginRemoveRows(QModelIndex(), 0, this->m_nodeData.count());
|
||||
this->m_nodeData.clear();
|
||||
this->endRemoveRows();
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
#include <QDebug>
|
||||
#include "qtozwproxymodels.h"
|
||||
#include "qtozwvalueidmodel.h"
|
||||
#include "qtozwnodemodel.h"
|
||||
#include "qtozwassociations.h"
|
||||
#include "qt-openzwave/qtozwproxymodels.h"
|
||||
#include "qt-openzwave/qtozwvalueidmodel.h"
|
||||
#include "qt-openzwave/qtozwnodemodel.h"
|
||||
#include "qt-openzwave/qtozwassociationmodel.h"
|
||||
|
||||
|
||||
QTOZW_proxyNodeModel::QTOZW_proxyNodeModel(QObject *parent) : QSortFilterProxyModel(parent)
|
|
@ -3,8 +3,8 @@
|
|||
#include <QDataStream>
|
||||
|
||||
#include "qtozw_logging.h"
|
||||
#include "qtozwvalueidmodel.h"
|
||||
#include "qtozwmanager.h"
|
||||
#include "qt-openzwave/qtozwvalueidmodel.h"
|
||||
#include "qt-openzwave/qtozwmanager.h"
|
||||
|
||||
|
||||
QDataStream & operator<<( QDataStream & dataStream, const QTOZW_ValueIDList & list )
|
||||
|
@ -183,122 +183,3 @@ int32_t QTOZW_ValueIds::getValueRow(quint64 _vidKey) {
|
|||
qCWarning(valueModel) << "Can't Find ValueID " << _vidKey << " in valueData";
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
QTOZW_ValueIds_internal::QTOZW_ValueIds_internal(QObject *parent)
|
||||
: QTOZW_ValueIds(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QTOZW_ValueIds_internal::addValue(quint64 _vidKey)
|
||||
{
|
||||
if (this->getValueRow(_vidKey) >= 0) {
|
||||
qCWarning(valueModel) << "ValueID " << _vidKey << " Already Exists";
|
||||
return;
|
||||
}
|
||||
QMap<ValueIdColumns, QVariant> newValue;
|
||||
newValue[QTOZW_ValueIds::ValueIDKey] = _vidKey;
|
||||
QBitArray flags(static_cast<int>(ValueIDFlags::FlagCount));
|
||||
newValue[QTOZW_ValueIds::ValueFlags] = flags;
|
||||
|
||||
this->beginInsertRows(QModelIndex(), this->rowCount(QModelIndex()), this->rowCount(QModelIndex()));
|
||||
this->m_valueData[this->rowCount(QModelIndex())] = newValue;
|
||||
this->endInsertRows();
|
||||
}
|
||||
|
||||
void QTOZW_ValueIds_internal::setValueData(quint64 _vidKey, QTOZW_ValueIds::ValueIdColumns column, QVariant data)
|
||||
{
|
||||
int row = this->getValueRow(_vidKey);
|
||||
if (row == -1) {
|
||||
qCWarning(valueModel) << "setValueData: Value " << _vidKey << " does not exist";
|
||||
return;
|
||||
}
|
||||
if (this->m_valueData[row][column] != data) {
|
||||
this->m_valueData[row][column] = data;
|
||||
this->dataChanged(this->createIndex(row, column), this->createIndex(row, column));
|
||||
}
|
||||
}
|
||||
|
||||
void QTOZW_ValueIds_internal::setValueFlags(quint64 _vidKey, QTOZW_ValueIds::ValueIDFlags _flags, bool _value)
|
||||
{
|
||||
int row = this->getValueRow(_vidKey);
|
||||
if (row == -1) {
|
||||
qCWarning(valueModel) << "setValueFlags: Value " << _vidKey << " does not exist";
|
||||
return;
|
||||
}
|
||||
if (this->m_valueData[row][QTOZW_ValueIds::ValueFlags].toBitArray().at(_flags) != _value) {
|
||||
QBitArray flags = this->m_valueData[row][QTOZW_ValueIds::ValueFlags].value<QBitArray>();
|
||||
flags.setBit(_flags, _value);
|
||||
this->m_valueData[row][QTOZW_ValueIds::ValueFlags] = flags;
|
||||
this->dataChanged(this->createIndex(row, QTOZW_ValueIds::ValueFlags), this->createIndex(row, QTOZW_ValueIds::ValueFlags));
|
||||
}
|
||||
}
|
||||
|
||||
void QTOZW_ValueIds_internal::delValue(quint64 _vidKey) {
|
||||
QMap<int32_t, QMap<ValueIdColumns, QVariant> >::iterator it;
|
||||
QMap<int32_t, QMap<ValueIdColumns, QVariant> > newValueMap;
|
||||
int32_t newrow = 0;
|
||||
for (it = this->m_valueData.begin(); it != this->m_valueData.end(); ++it) {
|
||||
if (it.value()[QTOZW_ValueIds::ValueIdColumns::ValueIDKey] == _vidKey) {
|
||||
qCDebug(valueModel) << "Removing Value " << it.value()[QTOZW_ValueIds::ValueIdColumns::Label] << it.key();
|
||||
this->beginRemoveRows(QModelIndex(), it.key(), it.key());
|
||||
this->m_valueData.erase(it);
|
||||
this->endRemoveRows();
|
||||
continue;
|
||||
} else {
|
||||
newValueMap[newrow] = it.value();
|
||||
newrow++;
|
||||
}
|
||||
}
|
||||
this->m_valueData.swap(newValueMap);
|
||||
}
|
||||
|
||||
void QTOZW_ValueIds_internal::delNodeValues(quint8 _node) {
|
||||
QMap<int32_t, QMap<ValueIdColumns, QVariant> >::iterator it;
|
||||
QMap<int32_t, QMap<ValueIdColumns, QVariant> > newValueMap;
|
||||
qint32 newrow = 0;
|
||||
for (it = this->m_valueData.begin(); it != this->m_valueData.end(); ++it) {
|
||||
if (it.value()[QTOZW_ValueIds::ValueIdColumns::Node] == _node) {
|
||||
qCDebug(valueModel) << "Removing Value " << it.value()[QTOZW_ValueIds::ValueIdColumns::Label] << it.key();
|
||||
this->beginRemoveRows(QModelIndex(), it.key(), it.key());
|
||||
this->m_valueData.erase(it);
|
||||
this->endRemoveRows();
|
||||
continue;
|
||||
} else {
|
||||
newValueMap[newrow] = it.value();
|
||||
newrow++;
|
||||
}
|
||||
}
|
||||
this->m_valueData.swap(newValueMap);
|
||||
}
|
||||
|
||||
void QTOZW_ValueIds_internal::resetModel() {
|
||||
this->beginRemoveRows(QModelIndex(), 0, this->m_valueData.count());
|
||||
this->m_valueData.clear();
|
||||
this->endRemoveRows();
|
||||
}
|
||||
|
||||
|
||||
QString BitSettoQString(QBitArray ba) {
|
||||
QString result;
|
||||
for (int i = ba.size()-1; i >= 0 ; --i) {
|
||||
if (ba.testBit(i))
|
||||
result[ba.size() - i] = '1';
|
||||
else
|
||||
result[ba.size() - i] = '0';
|
||||
}
|
||||
return result;
|
||||
#if 0
|
||||
result.prepend("0b");
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
quint32 BitSettoInteger(QBitArray ba) {
|
||||
quint32 value = 0;
|
||||
for (int i = 0; i <= ba.size()-1; ++i) {
|
||||
value += (quint32)((ba.at(i) ? 1 : 0) << i);
|
||||
}
|
||||
return value;
|
||||
}
|
123
qt-openzwave/source/qtozwvalueidmodel_p.cpp
Normal file
123
qt-openzwave/source/qtozwvalueidmodel_p.cpp
Normal file
|
@ -0,0 +1,123 @@
|
|||
#include "qtozw_logging.h"
|
||||
#include "qtozwvalueidmodel_p.h"
|
||||
|
||||
QTOZW_ValueIds_internal::QTOZW_ValueIds_internal(QObject *parent)
|
||||
: QTOZW_ValueIds(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QTOZW_ValueIds_internal::addValue(quint64 _vidKey)
|
||||
{
|
||||
if (this->getValueRow(_vidKey) >= 0) {
|
||||
qCWarning(valueModel) << "ValueID " << _vidKey << " Already Exists";
|
||||
return;
|
||||
}
|
||||
QMap<ValueIdColumns, QVariant> newValue;
|
||||
newValue[QTOZW_ValueIds::ValueIDKey] = _vidKey;
|
||||
QBitArray flags(static_cast<int>(ValueIDFlags::FlagCount));
|
||||
newValue[QTOZW_ValueIds::ValueFlags] = flags;
|
||||
|
||||
this->beginInsertRows(QModelIndex(), this->rowCount(QModelIndex()), this->rowCount(QModelIndex()));
|
||||
this->m_valueData[this->rowCount(QModelIndex())] = newValue;
|
||||
this->endInsertRows();
|
||||
}
|
||||
|
||||
void QTOZW_ValueIds_internal::setValueData(quint64 _vidKey, QTOZW_ValueIds::ValueIdColumns column, QVariant data)
|
||||
{
|
||||
int row = this->getValueRow(_vidKey);
|
||||
if (row == -1) {
|
||||
qCWarning(valueModel) << "setValueData: Value " << _vidKey << " does not exist";
|
||||
return;
|
||||
}
|
||||
if (this->m_valueData[row][column] != data) {
|
||||
this->m_valueData[row][column] = data;
|
||||
this->dataChanged(this->createIndex(row, column), this->createIndex(row, column));
|
||||
}
|
||||
}
|
||||
|
||||
void QTOZW_ValueIds_internal::setValueFlags(quint64 _vidKey, QTOZW_ValueIds::ValueIDFlags _flags, bool _value)
|
||||
{
|
||||
int row = this->getValueRow(_vidKey);
|
||||
if (row == -1) {
|
||||
qCWarning(valueModel) << "setValueFlags: Value " << _vidKey << " does not exist";
|
||||
return;
|
||||
}
|
||||
if (this->m_valueData[row][QTOZW_ValueIds::ValueFlags].toBitArray().at(_flags) != _value) {
|
||||
QBitArray flags = this->m_valueData[row][QTOZW_ValueIds::ValueFlags].value<QBitArray>();
|
||||
flags.setBit(_flags, _value);
|
||||
this->m_valueData[row][QTOZW_ValueIds::ValueFlags] = flags;
|
||||
this->dataChanged(this->createIndex(row, QTOZW_ValueIds::ValueFlags), this->createIndex(row, QTOZW_ValueIds::ValueFlags));
|
||||
}
|
||||
}
|
||||
|
||||
void QTOZW_ValueIds_internal::delValue(quint64 _vidKey) {
|
||||
QMap<int32_t, QMap<ValueIdColumns, QVariant> >::iterator it;
|
||||
QMap<int32_t, QMap<ValueIdColumns, QVariant> > newValueMap;
|
||||
int32_t newrow = 0;
|
||||
for (it = this->m_valueData.begin(); it != this->m_valueData.end(); ++it) {
|
||||
if (it.value()[QTOZW_ValueIds::ValueIdColumns::ValueIDKey] == _vidKey) {
|
||||
qCDebug(valueModel) << "Removing Value " << it.value()[QTOZW_ValueIds::ValueIdColumns::Label] << it.key();
|
||||
this->beginRemoveRows(QModelIndex(), it.key(), it.key());
|
||||
this->m_valueData.erase(it);
|
||||
this->endRemoveRows();
|
||||
continue;
|
||||
} else {
|
||||
newValueMap[newrow] = it.value();
|
||||
newrow++;
|
||||
}
|
||||
}
|
||||
this->m_valueData.swap(newValueMap);
|
||||
}
|
||||
|
||||
void QTOZW_ValueIds_internal::delNodeValues(quint8 _node) {
|
||||
QMap<int32_t, QMap<ValueIdColumns, QVariant> >::iterator it;
|
||||
QMap<int32_t, QMap<ValueIdColumns, QVariant> > newValueMap;
|
||||
qint32 newrow = 0;
|
||||
for (it = this->m_valueData.begin(); it != this->m_valueData.end(); ++it) {
|
||||
if (it.value()[QTOZW_ValueIds::ValueIdColumns::Node] == _node) {
|
||||
qCDebug(valueModel) << "Removing Value " << it.value()[QTOZW_ValueIds::ValueIdColumns::Label] << it.key();
|
||||
this->beginRemoveRows(QModelIndex(), it.key(), it.key());
|
||||
this->m_valueData.erase(it);
|
||||
this->endRemoveRows();
|
||||
continue;
|
||||
} else {
|
||||
newValueMap[newrow] = it.value();
|
||||
newrow++;
|
||||
}
|
||||
}
|
||||
this->m_valueData.swap(newValueMap);
|
||||
}
|
||||
|
||||
void QTOZW_ValueIds_internal::resetModel() {
|
||||
this->beginRemoveRows(QModelIndex(), 0, this->m_valueData.count());
|
||||
this->m_valueData.clear();
|
||||
this->endRemoveRows();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString BitSettoQString(QBitArray ba) {
|
||||
QString result;
|
||||
for (int i = ba.size()-1; i >= 0 ; --i) {
|
||||
if (ba.testBit(i))
|
||||
result[ba.size() - i] = '1';
|
||||
else
|
||||
result[ba.size() - i] = '0';
|
||||
}
|
||||
return result;
|
||||
#if 0
|
||||
result.prepend("0b");
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
quint32 BitSettoInteger(QBitArray ba) {
|
||||
quint32 value = 0;
|
||||
for (int i = 0; i <= ba.size()-1; ++i) {
|
||||
value += (quint32)((ba.at(i) ? 1 : 0) << i);
|
||||
}
|
||||
return value;
|
||||
}
|
|
@ -2,11 +2,11 @@ QT -= gui
|
|||
|
||||
QT += remoteobjects
|
||||
|
||||
CONFIG += c++11 console
|
||||
CONFIG += c++11 console silent
|
||||
CONFIG -= app_bundle
|
||||
|
||||
LIBS += -L../qt-openzwave/ -lqt-openzwave -lresolv
|
||||
INCLUDEPATH += ../qt-openzwave
|
||||
INCLUDEPATH += ../qt-openzwave/include
|
||||
|
||||
include(../qt-openzwave.pri)
|
||||
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include "qtopenzwave.h"
|
||||
#include "qtozwmanager.h"
|
||||
|
||||
#include <qt-openzwave/qtopenzwave.h>
|
||||
#include <qt-openzwave/qtozwmanager.h>
|
||||
|
||||
class qtozwdaemon : public QObject
|
||||
{
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include "bitsetwidget.h"
|
||||
#include "ui_bitsetwidget.h"
|
||||
#include <QCheckBox>
|
||||
#include <QDebug>
|
||||
|
||||
#include "bitsetwidget.h"
|
||||
#include "ui_bitsetwidget.h"
|
||||
|
||||
BitSetWidget::BitSetWidget(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::BitSetWidget)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define BITSETWIDGET_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <qtozwvalueidmodel.h>
|
||||
#include <qt-openzwave/qtozwvalueidmodel.h>
|
||||
|
||||
namespace Ui {
|
||||
class BitSetWidget;
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
#include <QRemoteObjectNode>
|
||||
#include <QAbstractItemModelReplica>
|
||||
|
||||
#include "qtozwmanager.h"
|
||||
#include <qt-openzwave/qtozwmanager.h>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#include <QAbstractItemModelTester>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "startup.h"
|
||||
#include "qtozw_itemdelegate.h"
|
||||
#include "qtozwproxymodels.h"
|
||||
#include <QAbstractItemModelTester>
|
||||
#include <qt-openzwave/qtozwproxymodels.h>
|
||||
|
||||
#define CONNECTSIGNALS(x) QObject::connect(this->m_qtozwmanager, &QTOZWManager::x, this, &MainWindow::x)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "qtopenzwave.h"
|
||||
#include <qt-openzwave/qtopenzwave.h>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
|
|
|
@ -152,16 +152,8 @@
|
|||
</property>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionE_xit"/>
|
||||
<addaction name="actionlahlah"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuTest">
|
||||
<property name="title">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
<addaction name="actionTest_This"/>
|
||||
</widget>
|
||||
<addaction name="menu_File"/>
|
||||
<addaction name="menuTest"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionE_xit">
|
||||
|
@ -169,16 +161,6 @@
|
|||
<string>E&xit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionTest_This">
|
||||
<property name="text">
|
||||
<string>Test This</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionlahlah">
|
||||
<property name="text">
|
||||
<string>lahlah</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="simpleclient.qrc"/>
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
|
||||
#include <qt-openzwave/qtozwvalueidmodel.h>
|
||||
|
||||
#include "qtozw_itemdelegate.h"
|
||||
#include "qtozwvalueidmodel.h"
|
||||
#include "bitsetwidget.h"
|
||||
|
||||
QTOZW_ItemDelegate::QTOZW_ItemDelegate(QObject *parent) : QStyledItemDelegate(parent)
|
||||
|
|
|
@ -5,7 +5,7 @@ CONFIG += silent
|
|||
DEFINES += remote
|
||||
|
||||
LIBS += -L../qt-openzwave/ -lqt-openzwave -lresolv
|
||||
INCLUDEPATH += ../qt-openzwave
|
||||
INCLUDEPATH += ../qt-openzwave/include/
|
||||
|
||||
include(../qt-openzwave.pri)
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <QMessageBox>
|
||||
|
||||
#include "startup.h"
|
||||
#include "ui_startup.h"
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
Startup::Startup(QWidget *parent) :
|
||||
|
|
Loading…
Add table
Reference in a new issue