mirror of
https://github.com/Fishwaldo/ozw-admin.git
synced 2025-03-16 03:41:39 +00:00
OSX Builds and Custom OZW Log Class and Window
This commit is contained in:
parent
31398938a0
commit
5222afc727
8 changed files with 505 additions and 150 deletions
209
logwindow.cpp
Normal file
209
logwindow.cpp
Normal file
|
@ -0,0 +1,209 @@
|
|||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QTextBrowser>
|
||||
#include <QPushButton>
|
||||
#include <QFileDialog>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include <QTextStream>
|
||||
#include <QCloseEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QMainWindow>
|
||||
#include <iostream>
|
||||
#include "logwindow.h"
|
||||
|
||||
ozwAdminLog::ozwAdminLog()
|
||||
{
|
||||
|
||||
}
|
||||
ozwAdminLog::~ozwAdminLog()
|
||||
{
|
||||
}
|
||||
void ozwAdminLog::Write( OpenZWave::LogLevel _level, uint8 const _nodeId, char const* _format, va_list _args ) {
|
||||
char lineBuf[1024] = {0};
|
||||
//int lineLen = 0;
|
||||
if( _format != NULL && _format[0] != '\0' )
|
||||
{
|
||||
va_list saveargs;
|
||||
va_copy( saveargs, _args );
|
||||
|
||||
vsnprintf( lineBuf, sizeof(lineBuf), _format, _args );
|
||||
va_end( saveargs );
|
||||
}
|
||||
printf("%s\n", lineBuf);
|
||||
emit newLogMsg(_level, _nodeId, QString(lineBuf));
|
||||
|
||||
}
|
||||
|
||||
void ozwAdminLog::QueueDump() {
|
||||
|
||||
}
|
||||
|
||||
void ozwAdminLog::QueueClear() {
|
||||
|
||||
}
|
||||
|
||||
void ozwAdminLog::SetLoggingState( OpenZWave::LogLevel _saveLevel, OpenZWave::LogLevel _queueLevel, OpenZWave::LogLevel _dumpTrigger ) {
|
||||
Q_UNUSED(_saveLevel);
|
||||
Q_UNUSED(_queueLevel);
|
||||
Q_UNUSED(_dumpTrigger);
|
||||
}
|
||||
|
||||
void ozwAdminLog::SetLogFileName( const std::string &_filename ) {
|
||||
Q_UNUSED(_filename);
|
||||
}
|
||||
|
||||
|
||||
|
||||
LogBrowserDialog::LogBrowserDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
setLayout(layout);
|
||||
|
||||
browser = new QTextBrowser(this);
|
||||
layout->addWidget(browser);
|
||||
|
||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
||||
buttonLayout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addLayout(buttonLayout);
|
||||
|
||||
buttonLayout->addStretch(10);
|
||||
|
||||
clearButton = new QPushButton(this);
|
||||
clearButton->setText("clear");
|
||||
buttonLayout->addWidget(clearButton);
|
||||
connect(clearButton, SIGNAL(clicked()), browser, SLOT(clear()));
|
||||
|
||||
saveButton = new QPushButton(this);
|
||||
saveButton->setText("save output");
|
||||
buttonLayout->addWidget(saveButton);
|
||||
connect(saveButton, SIGNAL(clicked()), this, SLOT(save()));
|
||||
|
||||
resize(200, 400);
|
||||
this->setWindowTitle("Log Window");
|
||||
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||
}
|
||||
|
||||
|
||||
LogBrowserDialog::~LogBrowserDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LogBrowserDialog::outputMessage(OpenZWave::LogLevel type, const QString &msg)
|
||||
{
|
||||
browser->append(msg);
|
||||
return;
|
||||
#if 0
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
break;
|
||||
|
||||
case QtWarningMsg:
|
||||
browser->append(tr("-- WARNING: %1").arg(msg));
|
||||
break;
|
||||
|
||||
case QtCriticalMsg:
|
||||
browser->append(tr("-- CRITICAL: %1").arg(msg));
|
||||
break;
|
||||
|
||||
case QtFatalMsg:
|
||||
browser->append(tr("-- FATAL: %1").arg(msg));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void LogBrowserDialog::save()
|
||||
{
|
||||
QString saveFileName = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
tr("Save Log Output"),
|
||||
tr("%1/logfile.txt").arg(QDir::homePath()),
|
||||
tr("Text Files (*.txt);;All Files (*)")
|
||||
);
|
||||
|
||||
if(saveFileName.isEmpty())
|
||||
return;
|
||||
|
||||
QFile file(saveFileName);
|
||||
if(!file.open(QIODevice::WriteOnly)) {
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
tr("Error"),
|
||||
QString(tr("<nobr>File '%1'<br/>cannot be opened for writing.<br/><br/>"
|
||||
"The log output could <b>not</b> be saved!</nobr>"))
|
||||
.arg(saveFileName));
|
||||
return;
|
||||
}
|
||||
|
||||
QTextStream stream(&file);
|
||||
stream << browser->toPlainText();
|
||||
file.close();
|
||||
}
|
||||
|
||||
|
||||
void LogBrowserDialog::closeEvent(QCloseEvent *e)
|
||||
{
|
||||
QMessageBox::StandardButton answer = QMessageBox::question(
|
||||
this,
|
||||
tr("Close Log Browser?"),
|
||||
tr("Do you really want to close the log browser?"),
|
||||
QMessageBox::Yes | QMessageBox::No
|
||||
);
|
||||
|
||||
if (answer == QMessageBox::Yes)
|
||||
e->accept();
|
||||
else
|
||||
e->ignore();
|
||||
}
|
||||
|
||||
|
||||
void LogBrowserDialog::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
// ignore all keyboard events
|
||||
// protects against accidentally closing of the dialog
|
||||
// without asking the user
|
||||
e->ignore();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
LogBrowser::LogBrowser(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
// qRegisterMetaType<QtMsgType>("QtMsgType");
|
||||
qRegisterMetaType<OpenZWave::LogLevel>("OpenZWave::LogLevel");
|
||||
this->logAdapter = new ozwAdminLog();
|
||||
this->browserDialog = new LogBrowserDialog;
|
||||
|
||||
connect(this, SIGNAL(sendMessage(OpenZWave::LogLevel,QString)), browserDialog, SLOT(outputMessage(OpenZWave::LogLevel,QString)), Qt::QueuedConnection);
|
||||
connect(this->logAdapter, SIGNAL(newLogMsg(OpenZWave::LogLevel,uint8,QString)), this, SLOT(outputMessage(OpenZWave::LogLevel,uint8,QString)));
|
||||
|
||||
OpenZWave::Log::SetLoggingClass(this->logAdapter);
|
||||
|
||||
}
|
||||
|
||||
|
||||
LogBrowser::~LogBrowser()
|
||||
{
|
||||
delete browserDialog;
|
||||
}
|
||||
|
||||
|
||||
void LogBrowser::outputMessage(OpenZWave::LogLevel Level, uint8 node, const QString &msg)
|
||||
{
|
||||
//std::cout << msg.toStdString() << std::endl;
|
||||
emit sendMessage( Level, msg );
|
||||
}
|
||||
|
||||
void LogBrowser::show() {
|
||||
//qobject_cast<QMainWindow *>(this->parent)->mdiArea->addSubWindow(browserDialog);
|
||||
//win->addSubWindow(browserDialog);
|
||||
browserDialog->show();
|
||||
}
|
81
logwindow.h
Normal file
81
logwindow.h
Normal file
|
@ -0,0 +1,81 @@
|
|||
#ifndef LOGWINDOW_H
|
||||
#define LOGWINDOW_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDialog>
|
||||
#include <QMdiArea>
|
||||
#include <platform/Log.h>
|
||||
#include <string>
|
||||
|
||||
/* our Custom Logging Class */
|
||||
|
||||
class ozwAdminLog : public QObject, public OpenZWave::i_LogImpl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ozwAdminLog();
|
||||
virtual ~ozwAdminLog();
|
||||
virtual void Write( OpenZWave::LogLevel _level, uint8 const _nodeId, char const* _format, va_list _args );
|
||||
virtual void QueueDump();
|
||||
virtual void QueueClear();
|
||||
virtual void SetLoggingState( OpenZWave::LogLevel _saveLevel, OpenZWave::LogLevel _queueLevel, OpenZWave::LogLevel _dumpTrigger );
|
||||
virtual void SetLogFileName( const std::string &_filename );
|
||||
signals:
|
||||
void newLogMsg(OpenZWave::LogLevel, uint8, const QString);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class LogBrowserDialog;
|
||||
|
||||
class LogBrowser : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LogBrowser(QObject *parent = 0);
|
||||
~LogBrowser();
|
||||
ozwAdminLog *logAdapter;
|
||||
|
||||
public slots:
|
||||
void outputMessage( OpenZWave::LogLevel Level, uint8, const QString &msg );
|
||||
void show();
|
||||
|
||||
signals:
|
||||
void sendMessage( OpenZWave::LogLevel Level, const QString &msg );
|
||||
|
||||
private:
|
||||
LogBrowserDialog *browserDialog;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class QTextBrowser;
|
||||
class QPushButton;
|
||||
|
||||
class LogBrowserDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogBrowserDialog(QWidget *parent = 0);
|
||||
~LogBrowserDialog();
|
||||
|
||||
public slots:
|
||||
void outputMessage( OpenZWave::LogLevel type, const QString &msg );
|
||||
|
||||
protected slots:
|
||||
void save();
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent( QKeyEvent *e );
|
||||
virtual void closeEvent( QCloseEvent *e );
|
||||
|
||||
QTextBrowser *browser;
|
||||
QPushButton *clearButton;
|
||||
QPushButton *saveButton;
|
||||
};
|
||||
|
||||
#endif // LOGWINDOW_H
|
|
@ -25,6 +25,7 @@
|
|||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "nodes.h"
|
||||
#include "logwindow.h"
|
||||
|
||||
#include "Options.h"
|
||||
#include "Manager.h"
|
||||
|
@ -40,7 +41,6 @@
|
|||
|
||||
|
||||
static pthread_mutex_t g_criticalSection;
|
||||
static pthread_cond_t initCond = PTHREAD_COND_INITIALIZER;
|
||||
static pthread_mutex_t initMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
NodeList *ozwNodes;
|
||||
|
@ -56,6 +56,7 @@ void OnNotification
|
|||
void* _context
|
||||
)
|
||||
{
|
||||
Q_UNUSED(_context);
|
||||
// Must do this inside a critical section to avoid conflicts with the main thread
|
||||
pthread_mutex_lock( &g_criticalSection );
|
||||
|
||||
|
@ -160,6 +161,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
{
|
||||
this->ui->setupUi(this);
|
||||
|
||||
this->logBrowser = new LogBrowser;
|
||||
connect(ui->actionOpen_Log_Window, SIGNAL(triggered()), this, SLOT(openLogWindow()));
|
||||
|
||||
connect(ui->actionOpen_Serial_Port, SIGNAL(triggered()), this, SLOT(OpenSerialPort()));
|
||||
connect(ui->action_Save_Cache, SIGNAL(triggered()), this, SLOT(saveCache()));
|
||||
|
||||
|
@ -247,6 +251,7 @@ void MainWindow::OpenSerialPort() {
|
|||
|
||||
|
||||
void MainWindow::newNode(qint8 nodeID) {
|
||||
Q_UNUSED(nodeID);
|
||||
|
||||
}
|
||||
|
||||
|
@ -310,3 +315,8 @@ void MainWindow::NodeSelected(QModelIndex current,QModelIndex previous) {
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::openLogWindow() {
|
||||
this->logBrowser->show();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <QMainWindow>
|
||||
#include <QSettings>
|
||||
#include <QModelIndex>
|
||||
#include "logwindow.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
|
@ -39,6 +40,7 @@ public slots:
|
|||
void saveCache();
|
||||
void resizeColumns();
|
||||
void NodeSelected(QModelIndex,QModelIndex);
|
||||
void openLogWindow();
|
||||
|
||||
|
||||
|
||||
|
@ -46,6 +48,7 @@ private:
|
|||
Ui::MainWindow *ui;
|
||||
QString m_serialport;
|
||||
QSettings settings;
|
||||
LogBrowser *logBrowser;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -44,8 +44,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>605</width>
|
||||
<height>289</height>
|
||||
<width>588</width>
|
||||
<height>283</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
|
@ -196,8 +196,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>605</width>
|
||||
<height>398</height>
|
||||
<width>588</width>
|
||||
<height>428</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
|
@ -497,9 +497,6 @@
|
|||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>groupBox_3</zorder>
|
||||
<zorder>groupBox_4</zorder>
|
||||
<zorder>groupBox_4</zorder>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -520,8 +517,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>618</width>
|
||||
<height>246</height>
|
||||
<width>588</width>
|
||||
<height>278</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -544,8 +541,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>618</width>
|
||||
<height>246</height>
|
||||
<width>588</width>
|
||||
<height>278</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -568,8 +565,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>618</width>
|
||||
<height>246</height>
|
||||
<width>588</width>
|
||||
<height>278</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -587,7 +584,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>660</width>
|
||||
<height>21</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
|
203
nodes.cpp
203
nodes.cpp
|
@ -27,6 +27,95 @@ Node::Node(qint8 m_nodeid, int homeid)
|
|||
this->m_homeid = homeid;
|
||||
}
|
||||
|
||||
qint8 Node::getNodeID() const {
|
||||
return this->m_nodeid;
|
||||
}
|
||||
|
||||
QString Node::getNodeName() const {
|
||||
return OpenZWave::Manager::Get()->GetNodeName(this->m_homeid, this->m_nodeid).c_str();
|
||||
}
|
||||
void Node::setNodeName(QString name) {
|
||||
if (this->getNodeName() != name) {
|
||||
OpenZWave::Manager::Get()->SetNodeName(this->m_homeid, this->m_nodeid, name.toStdString());
|
||||
emit NodeNameChanged(name);
|
||||
}
|
||||
}
|
||||
QString Node::getNodeLocation() const {
|
||||
return OpenZWave::Manager::Get()->GetNodeLocation(this->m_homeid, this->m_nodeid).c_str();
|
||||
}
|
||||
void Node::setNodeLocation(QString location) {
|
||||
if (this->getNodeLocation() != location) {
|
||||
OpenZWave::Manager::Get()->SetNodeLocation(this->m_homeid, this->m_nodeid, location.toStdString());
|
||||
emit NodeLocationChanged(location);
|
||||
}
|
||||
}
|
||||
QString Node::getNodeManufacturer() const {
|
||||
return OpenZWave::Manager::Get()->GetNodeManufacturerName(this->m_homeid, this->m_nodeid).c_str();
|
||||
}
|
||||
QString Node::getNodeProduct() const {
|
||||
return OpenZWave::Manager::Get()->GetNodeProductName(this->m_homeid, this->m_nodeid).c_str();
|
||||
}
|
||||
QString Node::getNodeBasicType() const {
|
||||
if (OpenZWave::Manager::Get()->IsNodeZWavePlus(this->m_homeid, this->m_nodeid)) {
|
||||
QString mystr(OpenZWave::Manager::Get()->GetNodePlusTypeString(this->m_homeid, this->m_nodeid).c_str());
|
||||
mystr.append(" ");
|
||||
mystr.append(OpenZWave::Manager::Get()->GetNodeRoleString(this->m_homeid, this->m_nodeid).c_str());
|
||||
return mystr;
|
||||
} else {
|
||||
return nodeBasicStr(OpenZWave::Manager::Get()->GetNodeBasic(this->m_homeid, this->m_nodeid));
|
||||
}
|
||||
}
|
||||
QString Node::getNodeGenericType() const {
|
||||
if (OpenZWave::Manager::Get()->IsNodeZWavePlus(this->m_homeid, this->m_nodeid)) {
|
||||
return OpenZWave::Manager::Get()->GetNodeDeviceTypeString(this->m_homeid, this->m_nodeid).c_str();
|
||||
} else {
|
||||
return OpenZWave::Manager::Get()->GetNodeType(this->m_homeid, this->m_nodeid).c_str();
|
||||
}
|
||||
}
|
||||
bool Node::getIsZWPlus() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeZWavePlus(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
bool Node::getIsListening() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeListeningDevice(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
bool Node::getIsBeaming() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeBeamingDevice(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
bool Node::getIsRouting() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeRoutingDevice(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
bool Node::getIsFLiRS() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeFrequentListeningDevice(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
bool Node::getIsSecurity() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeSecurityDevice(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
bool Node::getIsNodeFailed() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeFailed(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
bool Node::getIsNodeAwake() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeAwake(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
QString Node::getNodeProductID() const {
|
||||
return OpenZWave::Manager::Get()->GetNodeProductId(this->m_homeid, this->m_nodeid).c_str();
|
||||
}
|
||||
QString Node::getNodeProductType() const {
|
||||
return OpenZWave::Manager::Get()->GetNodeProductType(this->m_homeid, this->m_nodeid).c_str();
|
||||
}
|
||||
QString Node::getNodeZWVersion() const {
|
||||
return QString::number(OpenZWave::Manager::Get()->GetNodeVersion(this->m_homeid, this->m_nodeid));
|
||||
}
|
||||
QString Node::getNodeBaudRate() const {
|
||||
return QString::number(OpenZWave::Manager::Get()->GetNodeMaxBaudRate(this->m_homeid, this->m_nodeid));
|
||||
}
|
||||
QString Node::getNodeQueryStage() const {
|
||||
return OpenZWave::Manager::Get()->GetNodeQueryStage(this->m_homeid, this->m_nodeid).c_str();
|
||||
}
|
||||
|
||||
OpenZWave::Node::NodeData &Node::getNodeStatistics() {
|
||||
OpenZWave::Manager::Get()->GetNodeStatistics(this->m_homeid, this->m_nodeid, &this->m_stats);
|
||||
return this->m_stats;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -57,22 +146,24 @@ QVariant NodeList::data(const QModelIndex &index, int role) const {
|
|||
return QVariant();
|
||||
}
|
||||
switch ((NodeColumnNames)index.column()) {
|
||||
case NCN_NodeID:
|
||||
return node->getNodeID();
|
||||
case NCN_NodeName:
|
||||
return node->getNodeName();
|
||||
case NCN_NodeLocation:
|
||||
return node->getNodeLocation();
|
||||
case NCN_NodeManufacturerName:
|
||||
return node->getNodeManufacturer();
|
||||
case NCN_NodeProductName:
|
||||
return node->getNodeProduct();
|
||||
case NCN_NodeBasicType:
|
||||
return node->getNodeBasicType();
|
||||
case NCN_NodeGenericType:
|
||||
return node->getNodeGenericType();
|
||||
case NCN_QueryStage:
|
||||
return node->getNodeQueryStage();
|
||||
case NCN_NodeID:
|
||||
return node->getNodeID();
|
||||
case NCN_NodeName:
|
||||
return node->getNodeName();
|
||||
case NCN_NodeLocation:
|
||||
return node->getNodeLocation();
|
||||
case NCN_NodeManufacturerName:
|
||||
return node->getNodeManufacturer();
|
||||
case NCN_NodeProductName:
|
||||
return node->getNodeProduct();
|
||||
case NCN_NodeBasicType:
|
||||
return node->getNodeBasicType();
|
||||
case NCN_NodeGenericType:
|
||||
return node->getNodeGenericType();
|
||||
case NCN_QueryStage:
|
||||
return node->getNodeQueryStage();
|
||||
case NCN_Count:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
|
@ -84,29 +175,32 @@ QVariant NodeList::headerData(int section, Qt::Orientation orientation, int role
|
|||
|
||||
if (orientation == Qt::Horizontal) {
|
||||
switch ((NodeColumnNames)section) {
|
||||
case NCN_NodeID:
|
||||
return tr("NodeID");
|
||||
case NCN_NodeID:
|
||||
return tr("NodeID");
|
||||
|
||||
case NCN_NodeName:
|
||||
return tr("Node Name");
|
||||
case NCN_NodeName:
|
||||
return tr("Node Name");
|
||||
|
||||
case NCN_NodeLocation:
|
||||
return tr("Location");
|
||||
case NCN_NodeLocation:
|
||||
return tr("Location");
|
||||
|
||||
case NCN_NodeManufacturerName:
|
||||
return tr("Manufacturer");
|
||||
case NCN_NodeManufacturerName:
|
||||
return tr("Manufacturer");
|
||||
|
||||
case NCN_NodeProductName:
|
||||
return tr("Product");
|
||||
case NCN_NodeProductName:
|
||||
return tr("Product");
|
||||
|
||||
case NCN_NodeBasicType:
|
||||
return tr("Basic Type");
|
||||
case NCN_NodeBasicType:
|
||||
return tr("Basic Type");
|
||||
|
||||
case NCN_NodeGenericType:
|
||||
return tr("Generic Type");
|
||||
case NCN_NodeGenericType:
|
||||
return tr("Generic Type");
|
||||
|
||||
case NCN_QueryStage:
|
||||
return tr("Query Stage");
|
||||
case NCN_QueryStage:
|
||||
return tr("Query Stage");
|
||||
|
||||
case NCN_Count:
|
||||
return QVariant();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -121,27 +215,28 @@ Qt::ItemFlags NodeList::flags(const QModelIndex &index) const {
|
|||
bool NodeList::setData(const QModelIndex &index, const QVariant &value, int role) {
|
||||
|
||||
if (index.isValid() && role == Qt::EditRole) {
|
||||
int row = index.row();
|
||||
int row = index.row();
|
||||
|
||||
Node *p = this->m_Nodelist.at(row);
|
||||
Node *p = this->m_Nodelist.at(row);
|
||||
|
||||
switch ((NodeColumnNames)index.column()) {
|
||||
case NCN_NodeID:
|
||||
case NCN_NodeManufacturerName:
|
||||
case NCN_NodeProductName:
|
||||
case NCN_NodeBasicType:
|
||||
case NCN_NodeGenericType:
|
||||
case NCN_QueryStage:
|
||||
/* read only */
|
||||
return false;
|
||||
break;
|
||||
case NCN_NodeName:
|
||||
p->setNodeName(value.toString());
|
||||
break;
|
||||
case NCN_NodeLocation:
|
||||
p->setNodeLocation(value.toString());
|
||||
break;
|
||||
}
|
||||
switch ((NodeColumnNames)index.column()) {
|
||||
case NCN_NodeID:
|
||||
case NCN_NodeManufacturerName:
|
||||
case NCN_NodeProductName:
|
||||
case NCN_NodeBasicType:
|
||||
case NCN_NodeGenericType:
|
||||
case NCN_QueryStage:
|
||||
case NCN_Count:
|
||||
/* read only */
|
||||
return false;
|
||||
break;
|
||||
case NCN_NodeName:
|
||||
p->setNodeName(value.toString());
|
||||
break;
|
||||
case NCN_NodeLocation:
|
||||
p->setNodeLocation(value.toString());
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -151,11 +246,17 @@ bool NodeList::setData(const QModelIndex &index, const QVariant &value, int role
|
|||
}
|
||||
|
||||
bool NodeList::insertRows(int position, int rows, const QModelIndex &index) {
|
||||
Q_UNUSED(position);
|
||||
Q_UNUSED(rows);
|
||||
Q_UNUSED(index);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NodeList::removeRows(int position, int rows, const QModelIndex &index) {
|
||||
Q_UNUSED(position);
|
||||
Q_UNUSED(rows);
|
||||
Q_UNUSED(index);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
103
nodes.h
103
nodes.h
|
@ -62,86 +62,29 @@ public:
|
|||
|
||||
Node(qint8 m_nodeid, int homeid);
|
||||
|
||||
qint8 getNodeID() const { return this->m_nodeid; }
|
||||
QString getNodeName() const { return OpenZWave::Manager::Get()->GetNodeName(this->m_homeid, this->m_nodeid).c_str(); }
|
||||
void setNodeName(QString name) {
|
||||
if (this->getNodeName() != name) {
|
||||
OpenZWave::Manager::Get()->SetNodeName(this->m_homeid, this->m_nodeid, name.toStdString());
|
||||
emit NodeNameChanged(name);
|
||||
}
|
||||
}
|
||||
QString getNodeLocation() const { return OpenZWave::Manager::Get()->GetNodeLocation(this->m_homeid, this->m_nodeid).c_str(); }
|
||||
void setNodeLocation(QString location) {
|
||||
if (this->getNodeLocation() != location) {
|
||||
OpenZWave::Manager::Get()->SetNodeLocation(this->m_homeid, this->m_nodeid, location.toStdString());
|
||||
emit NodeLocationChanged(location);
|
||||
}
|
||||
}
|
||||
QString getNodeManufacturer() const { return OpenZWave::Manager::Get()->GetNodeManufacturerName(this->m_homeid, this->m_nodeid).c_str(); }
|
||||
QString getNodeProduct() const { return OpenZWave::Manager::Get()->GetNodeProductName(this->m_homeid, this->m_nodeid).c_str(); }
|
||||
QString getNodeBasicType() const {
|
||||
if (OpenZWave::Manager::Get()->IsNodeZWavePlus(this->m_homeid, this->m_nodeid)) {
|
||||
QString mystr(OpenZWave::Manager::Get()->GetNodePlusTypeString(this->m_homeid, this->m_nodeid).c_str());
|
||||
mystr.append(" ");
|
||||
mystr.append(OpenZWave::Manager::Get()->GetNodeRoleString(this->m_homeid, this->m_nodeid).c_str());
|
||||
return mystr;
|
||||
} else {
|
||||
return nodeBasicStr(OpenZWave::Manager::Get()->GetNodeBasic(this->m_homeid, this->m_nodeid));
|
||||
}
|
||||
}
|
||||
QString getNodeGenericType() const {
|
||||
if (OpenZWave::Manager::Get()->IsNodeZWavePlus(this->m_homeid, this->m_nodeid)) {
|
||||
return OpenZWave::Manager::Get()->GetNodeDeviceTypeString(this->m_homeid, this->m_nodeid).c_str();
|
||||
} else {
|
||||
return OpenZWave::Manager::Get()->GetNodeType(this->m_homeid, this->m_nodeid).c_str();
|
||||
}
|
||||
}
|
||||
bool getIsZWPlus() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeZWavePlus(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
bool getIsListening() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeListeningDevice(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
bool getIsBeaming() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeBeamingDevice(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
bool getIsRouting() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeRoutingDevice(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
bool getIsFLiRS() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeFrequentListeningDevice(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
bool getIsSecurity() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeSecurityDevice(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
bool getIsNodeFailed() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeFailed(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
bool getIsNodeAwake() const {
|
||||
return OpenZWave::Manager::Get()->IsNodeAwake(this->m_homeid, this->m_nodeid);
|
||||
}
|
||||
|
||||
|
||||
QString getNodeProductID() const {
|
||||
return OpenZWave::Manager::Get()->GetNodeProductId(this->m_homeid, this->m_nodeid).c_str();
|
||||
}
|
||||
QString getNodeProductType() const {
|
||||
return OpenZWave::Manager::Get()->GetNodeProductType(this->m_homeid, this->m_nodeid).c_str();
|
||||
}
|
||||
QString getNodeZWVersion() const {
|
||||
return QString::number(OpenZWave::Manager::Get()->GetNodeVersion(this->m_homeid, this->m_nodeid));
|
||||
}
|
||||
QString getNodeBaudRate() const {
|
||||
return QString::number(OpenZWave::Manager::Get()->GetNodeMaxBaudRate(this->m_homeid, this->m_nodeid));
|
||||
}
|
||||
QString getNodeQueryStage() const {
|
||||
return OpenZWave::Manager::Get()->GetNodeQueryStage(this->m_homeid, this->m_nodeid).c_str();
|
||||
}
|
||||
|
||||
OpenZWave::Node::NodeData &getNodeStatistics() {
|
||||
OpenZWave::Manager::Get()->GetNodeStatistics(this->m_homeid, this->m_nodeid, &this->m_stats);
|
||||
return this->m_stats;
|
||||
}
|
||||
qint8 getNodeID() const;
|
||||
QString getNodeName() const;
|
||||
void setNodeName(QString name);
|
||||
QString getNodeLocation() const;
|
||||
void setNodeLocation(QString location);
|
||||
QString getNodeManufacturer() const;
|
||||
QString getNodeProduct() const;
|
||||
QString getNodeBasicType() const;
|
||||
QString getNodeGenericType() const;
|
||||
bool getIsZWPlus() const;
|
||||
bool getIsListening() const;
|
||||
bool getIsBeaming() const;
|
||||
bool getIsRouting() const;
|
||||
bool getIsFLiRS() const;
|
||||
bool getIsSecurity() const;
|
||||
bool getIsNodeFailed() const;
|
||||
bool getIsNodeAwake() const;
|
||||
QString getNodeProductID() const;
|
||||
QString getNodeProductType() const;
|
||||
QString getNodeZWVersion() const;
|
||||
QString getNodeBaudRate() const;
|
||||
QString getNodeQueryStage() const;
|
||||
OpenZWave::Node::NodeData &getNodeStatistics();
|
||||
|
||||
signals:
|
||||
void NodeNameChanged(QString);
|
||||
|
|
|
@ -15,13 +15,24 @@ TEMPLATE = app
|
|||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
nodes.cpp \
|
||||
util.cpp
|
||||
util.cpp \
|
||||
logwindow.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
nodes.h \
|
||||
util.h
|
||||
util.h \
|
||||
logwindow.h
|
||||
|
||||
FORMS += mainwindow.ui
|
||||
|
||||
unix: CONFIG += link_pkgconfig
|
||||
unix: PKGCONFIG += libopenzwave
|
||||
unix:!macx {
|
||||
CONFIG += link_pkgconfig
|
||||
PKGCONFIG += libopenzwave
|
||||
}
|
||||
macx: {
|
||||
CONFIG += c++11
|
||||
INCLUDEPATH += $$PWD/../open-zwave/cpp/src/
|
||||
LIBS += -L$$PWD/../open-zwave -lopenzwave
|
||||
LIBS += $$PWD/../open-zwave/libopenzwave.a -framework IOKit -framework CoreFoundation
|
||||
QMAKE_MAC_SDK = macosx10.11
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue