diff --git a/ozwadmin-main/controllercommands.cpp b/ozwadmin-main/controllercommands.cpp index f927a98..00cc360 100644 --- a/ozwadmin-main/controllercommands.cpp +++ b/ozwadmin-main/controllercommands.cpp @@ -1,23 +1,32 @@ #include #include "controllercommands.h" +#include "util.h" ControllerCommands::ControllerCommands(QMainWindow *parent) : - QObject(parent) + QObject(parent), + m_msgBox(parent) { - + connect(OZWCore::get()->getQTOZWManager(), &QTOZWManager::controllerCommand, this, &ControllerCommands::controllerCommandNotification); } + void ControllerCommands::addNode() { + + + this->m_command = ControllerCommands::Command_addNode; QMessageBox::StandardButton ret = QMessageBox::question(qobject_cast(this->parent()), "Include Secure?", "Do you wish to include the new device with encryption?", QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel); if (ret == QMessageBox::Cancel) { return; } - this->m_msgBox = new QMessageBox(QMessageBox::Information, "Adding Node", "Starting....", QMessageBox::Cancel, qobject_cast(this->parent())); - this->m_msgBox->setDetailedText("Waiting for the Controller to Enter AddNode Mode..."); - connect(this->m_msgBox, &QMessageBox::rejected, this, &ControllerCommands::cancelCommand); - this->m_msgBox->show(); + this->m_msgBox.setIcon(QMessageBox::Information); + this->m_msgBox.setWindowTitle("Adding Node"); + this->m_msgBox.setText("Starting..."); + this->m_msgBox.setStandardButtons(QMessageBox::Cancel); + this->m_msgBox.setDetailedText("Waiting for the Controller to Enter AddNode Mode..."); + connect(&this->m_msgBox, &QMessageBox::rejected, this, &ControllerCommands::cancelCommand); + this->m_msgBox.show(); if (ret == QMessageBox::Yes) { OZWCore::get()->getQTOZWManager()->addNode(true); } else if (ret == QMessageBox::No) { @@ -25,18 +34,306 @@ void ControllerCommands::addNode() { } } void ControllerCommands::delNode() { + this->m_command = ControllerCommands::Command_delNode; + this->m_msgBox.setIcon(QMessageBox::Information); + this->m_msgBox.setWindowTitle("Exclude Node"); + this->m_msgBox.setText("Starting..."); + this->m_msgBox.setStandardButtons(QMessageBox::Cancel); + this->m_msgBox.setDetailedText("Waiting for the Controller to Enter Exclusion Mode..."); + connect(&this->m_msgBox, &QMessageBox::rejected, this, &ControllerCommands::cancelCommand); + this->m_msgBox.show(); OZWCore::get()->getQTOZWManager()->removeNode(); } void ControllerCommands::healNetwork() { + this->m_command = ControllerCommands::Command_healNetwork; QMessageBox::StandardButton ret = QMessageBox::information(qobject_cast(this->parent()), "Heal Network", "Healing the Network Should only be performed after Adding/Removing or Physically Moving Mains Powered Devices. Are you sure?", QMessageBox::Ok|QMessageBox::Cancel); if (ret == QMessageBox::Ok) { + this->m_msgBox.setIcon(QMessageBox::Information); + this->m_msgBox.setWindowTitle("Heal Network"); + this->m_msgBox.setText("Starting..."); + this->m_msgBox.setStandardButtons(QMessageBox::Cancel); + this->m_msgBox.setDetailedText("Waiting for the Controller to Enter Heal Network Mode..."); + connect(&this->m_msgBox, &QMessageBox::rejected, this, &ControllerCommands::cancelCommand); + this->m_msgBox.show(); OZWCore::get()->getQTOZWManager()->healNetwork(false); } } void ControllerCommands::cancelCommand() { - QMessageBox::StandardButton ret = QMessageBox::question(qobject_cast(this->parent()), "Cancel Command", "Are you sure you wish to cancel the command?"); - if (ret == QMessageBox::Yes) { - OZWCore::get()->getQTOZWManager()->cancelControllerCommand(); + switch (this->m_command) { + case ControllerCommands::Command_none: + case ControllerCommands::Command_healNetwork: + case ControllerCommands::Command_cancel: + { + /* These Don't need to be Canceled */ + break; + } + default: + { + QMessageBox::StandardButton ret = QMessageBox::question(qobject_cast(this->parent()), "Cancel Command", "Are you sure you wish to cancel the command?"); + if (ret == QMessageBox::Yes) { + OZWCore::get()->getQTOZWManager()->cancelControllerCommand(); + } else { + this->m_msgBox.show(); + } + break; + } + } } +void ControllerCommands::controllerCommandNotification(quint8 node, NotificationTypes::QTOZW_Notification_Controller_Cmd command, NotificationTypes::QTOZW_Notification_Controller_State state, NotificationTypes::QTOZW_Notification_Controller_Error error) +{ + qCDebug(ozwadmin) << "ControllerCommandNotification: " << node << command << state << error; + switch (this->m_command) { + case ControllerCommands::Command_none: + case ControllerCommands::Command_cancel: + { + qCDebug(ozwadmin) << "Ignoring Notification as we are not in a ControllerCommand Mode"; + return; + } + case ControllerCommands::Command_addNode: { + if (command != NotificationTypes::Ctrl_Cmd_AddNode) { + qCDebug(ozwadmin) << "Ignoring Notification as we are not in addNode Mode"; + return; + } + switch (state) { + case NotificationTypes::Ctrl_State_Starting: { + this->m_msgBox.setText("Add Node Starting..."); + break; + } + case NotificationTypes::Ctrl_State_Waiting: { + this->m_msgBox.setText("Started - Waiting to discover new Node"); + this->m_msgBox.setDetailedText("Please Activate the Pairing Mode on the device you wish to include now"); + break; + } + case NotificationTypes::Ctrl_State_Normal: { + break; + } + case NotificationTypes::Ctrl_State_Cancel: { + break; + } + case NotificationTypes::Ctrl_State_Error: { + break; + } + case NotificationTypes::Ctrl_State_Sleeping: { + break; + } + case NotificationTypes::Ctrl_State_InProgress: { + this->m_msgBox.setIcon(QMessageBox::Information); + if (node) { + this->m_msgBox.setText(QString("Adding Node %1 in Progress").arg(node)); + } else { + this->m_msgBox.setText("Adding Node in Progress"); + } + this->m_msgBox.setDetailedText("OpenZWave is Querying Node Capabilities..."); + this->m_msgBox.setStandardButtons(QMessageBox::NoButton); + break; + } + case NotificationTypes::Ctrl_State_Completed: { + this->m_msgBox.setIcon(QMessageBox::Information); + this->m_msgBox.setText(QString("Add Node Completed for new Node %1").arg(node)); + this->m_msgBox.setDetailedText("Add Node Has Completed. OpenZWave is querying the the Node now"); + this->m_msgBox.setStandardButtons(QMessageBox::Close); + this->m_command = ControllerCommands::Command_none; + break; + } + case NotificationTypes::Ctrl_State_Failed: { + this->m_msgBox.setIcon(QMessageBox::Critical); + this->m_msgBox.setText("AddNode Command Failed"); + this->m_msgBox.setDetailedText("Please Consult the Logs Window for further infomation"); + this->m_msgBox.setStandardButtons(QMessageBox::Close); + break; + } + case NotificationTypes::Ctrl_State_NodeOk: { + break; + } + case NotificationTypes::Ctrl_State_NodeFailed: { + break; + } + case NotificationTypes::Ctrl_State_count: { + break; + } + } + break; + } + case ControllerCommands::Command_delNode: { + if (command != NotificationTypes::Ctrl_Cmd_RemoveNode) { + qCDebug(ozwadmin) << "Ignoring Notification as we are not in delNode Mode"; + return; + } + switch (state) { + case NotificationTypes::Ctrl_State_Starting: { + this->m_msgBox.setText("Delete Node Starting..."); + break; + } + case NotificationTypes::Ctrl_State_Waiting: { + this->m_msgBox.setText("Delete Node Mode Started - Waiting..."); + this->m_msgBox.setDetailedText("Please activate the exclude mode function on the device you wish to exclude now"); + break; + } + case NotificationTypes::Ctrl_State_Normal: { + break; + } + case NotificationTypes::Ctrl_State_Cancel: { + break; + } + case NotificationTypes::Ctrl_State_Error: { + break; + } + case NotificationTypes::Ctrl_State_Sleeping: { + break; + } + case NotificationTypes::Ctrl_State_InProgress: { + this->m_msgBox.setIcon(QMessageBox::Information); + if (node) { + this->m_msgBox.setText(QString("Exectuting Exclusion on Node %1").arg(node)); + } else { + this->m_msgBox.setText("Exectuting Exclusion on Device"); + } + this->m_msgBox.setDetailedText("Node is currently being removed from its Network Association"); + this->m_msgBox.setStandardButtons(QMessageBox::NoButton); + break; + } + case NotificationTypes::Ctrl_State_Completed: { + this->m_msgBox.setIcon(QMessageBox::Information); + if (node) { + this->m_msgBox.setText(QString("Delete Node Completed for Node %1").arg(node)); + } else { + this->m_msgBox.setText(QString("Delete Node Completed").arg(node)); + } + this->m_msgBox.setDetailedText("Delete Node Has Completed"); + this->m_msgBox.setStandardButtons(QMessageBox::Close); + this->m_command = ControllerCommands::Command_none; + break; + } + case NotificationTypes::Ctrl_State_Failed: { + this->m_msgBox.setIcon(QMessageBox::Warning); + this->m_msgBox.setText("Delete Node Command Failed"); + this->m_msgBox.setDetailedText("If you were excluding a device associated from another Network, the Node may have been removed from that network and is ready to be included in a new Network"); + this->m_msgBox.setStandardButtons(QMessageBox::Close); + break; + } + case NotificationTypes::Ctrl_State_NodeOk: { + break; + } + case NotificationTypes::Ctrl_State_NodeFailed: { + break; + } + case NotificationTypes::Ctrl_State_count: { + break; + } + } + break; + } + case ControllerCommands::Command_healNetwork: { + static int sleeping = 0; + static int failed = 0; + if (command != NotificationTypes::Ctrl_Cmd_RequestNodeNeighborUpdate) { + qCDebug(ozwadmin) << "Ignoring Notification as we are not in healNetwork Mode"; + return; + } + switch (state) { + case NotificationTypes::Ctrl_State_Starting: { + sleeping = 0; + failed = 0; + this->m_msgBox.setText("Heal Network Mode Starting..."); + break; + } + case NotificationTypes::Ctrl_State_Waiting: { + break; + } + case NotificationTypes::Ctrl_State_Normal: { + break; + } + case NotificationTypes::Ctrl_State_Cancel: { + break; + } + case NotificationTypes::Ctrl_State_Error: { + break; + } + case NotificationTypes::Ctrl_State_Sleeping: { + sleeping++; + QString details; + if (sleeping > 0) { + this->m_msgBox.setIcon(QMessageBox::Warning); + details.append("Some Devices are Sleeping\n"); + } + if (failed > 0) { + this->m_msgBox.setIcon(QMessageBox::Critical); + details.append("Some Devices Failed\n"); + } + + this->m_msgBox.setIcon(QMessageBox::Warning); + this->m_msgBox.setDetailedText(details); + this->m_msgBox.setStandardButtons(QMessageBox::Close); + break; + } + case NotificationTypes::Ctrl_State_InProgress: { + QString details; + if (sleeping > 0) { + this->m_msgBox.setIcon(QMessageBox::Warning); + details.append("Some Devices are Sleeping\n"); + } + if (failed > 0) { + this->m_msgBox.setIcon(QMessageBox::Critical); + details.append("Some Devices Failed\n"); + } + if (node) { + this->m_msgBox.setText(QString("Exectuting Heal Network on Node %1").arg(node)); + } else { + this->m_msgBox.setText("Exectuting Heal Network"); + } + if (!details.isEmpty()) this->m_msgBox.setDetailedText(details); + this->m_msgBox.setStandardButtons(QMessageBox::Close); + break; + } + case NotificationTypes::Ctrl_State_Completed: { + QString details; + if (sleeping > 0) { + this->m_msgBox.setIcon(QMessageBox::Warning); + details.append("Some Devices are Sleeping\n"); + } + if (failed > 0) { + this->m_msgBox.setIcon(QMessageBox::Critical); + details.append("Some Devices Failed\n"); + } + this->m_msgBox.setText("Heal Network Completed"); + this->m_msgBox.setDetailedText(details); + this->m_msgBox.setStandardButtons(QMessageBox::Close); + this->m_command = ControllerCommands::Command_none; + break; + } + case NotificationTypes::Ctrl_State_Failed: { + if (node == OZWCore::get()->getQTOZWManager()->getControllerNodeId()) { + /* controller Nodes always fail this */ + return; + } + failed++; + QString details; + if (sleeping > 0) { + this->m_msgBox.setIcon(QMessageBox::Warning); + details.append("Some Devices are Sleeping\n"); + } + if (failed > 0) { + this->m_msgBox.setIcon(QMessageBox::Critical); + details.append("Some Devices Failed\n"); + } + this->m_msgBox.setText("Heal Network Finished"); + this->m_msgBox.setDetailedText(details); + this->m_msgBox.setStandardButtons(QMessageBox::Close); + break; + } + case NotificationTypes::Ctrl_State_NodeOk: { + break; + } + case NotificationTypes::Ctrl_State_NodeFailed: { + break; + } + case NotificationTypes::Ctrl_State_count: { + break; + } + } + } + + } +} diff --git a/ozwadmin-main/controllercommands.h b/ozwadmin-main/controllercommands.h index 6824b6f..94c7eef 100644 --- a/ozwadmin-main/controllercommands.h +++ b/ozwadmin-main/controllercommands.h @@ -12,14 +12,18 @@ class ControllerCommands : public QObject Q_OBJECT public: explicit ControllerCommands(QMainWindow *parent = nullptr); - + enum Command {Command_addNode, Command_delNode, Command_healNetwork, Command_cancel, Command_none}; + Q_ENUM(Command); public slots: void addNode(); void delNode(); void healNetwork(); void cancelCommand(); + + void controllerCommandNotification(quint8 node, NotificationTypes::QTOZW_Notification_Controller_Cmd command, NotificationTypes::QTOZW_Notification_Controller_State state, NotificationTypes::QTOZW_Notification_Controller_Error error); private: - QMessageBox *m_msgBox; + QMessageBox m_msgBox; + Command m_command; }; #endif // CONTROLLERCOMMANDS_H diff --git a/ozwadmin-main/eventwindow.cpp b/ozwadmin-main/eventwindow.cpp new file mode 100644 index 0000000..b7ef69c --- /dev/null +++ b/ozwadmin-main/eventwindow.cpp @@ -0,0 +1,40 @@ +#include +#include +#include + +#include "eventwindow.h" +#include "ui_eventwindow.h" + + +EventWindow::EventWindow(QWidget *parent) : + QWidget(parent), + ui(new Ui::EventWindow) +{ + ui->setupUi(this); + ui->eventTable->horizontalHeader()->setStretchLastSection(true); + ui->eventTable->setHorizontalHeaderItem(0, new QTableWidgetItem("Time")); + ui->eventTable->setHorizontalHeaderItem(1, new QTableWidgetItem("Message")); + ui->eventTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + +} + +EventWindow::~EventWindow() +{ + delete ui; +} + +void EventWindow::newEvent(QString Msg) { + QTableWidgetItem *timeStamp = new QTableWidgetItem(QTime::currentTime().toString()); + timeStamp->setFlags(timeStamp->flags() ^ Qt::ItemIsEditable); + QTableWidgetItem *message = new QTableWidgetItem(Msg); + message->setFlags(message->flags() ^ Qt::ItemIsEditable); + + this->ui->eventTable->insertRow ( this->ui->eventTable->rowCount() ); + this->ui->eventTable->setItem(this->ui->eventTable->rowCount() -1, + 0, + timeStamp); + this->ui->eventTable->setItem(this->ui->eventTable->rowCount() -1, + 1, + message); + QTimer::singleShot(10, this->ui->eventTable, &QTableWidget::scrollToBottom); +} diff --git a/ozwadmin-main/eventwindow.h b/ozwadmin-main/eventwindow.h new file mode 100644 index 0000000..f2e8d09 --- /dev/null +++ b/ozwadmin-main/eventwindow.h @@ -0,0 +1,24 @@ +#ifndef EVENTWINDOW_H +#define EVENTWINDOW_H + +#include + +namespace Ui { +class EventWindow; +} + +class EventWindow : public QWidget +{ + Q_OBJECT + +public: + explicit EventWindow(QWidget *parent = nullptr); + ~EventWindow(); + +public slots: + void newEvent(QString); +private: + Ui::EventWindow *ui; +}; + +#endif // EVENTWINDOW_H diff --git a/ozwadmin-main/eventwindow.ui b/ozwadmin-main/eventwindow.ui new file mode 100644 index 0000000..07b8aba --- /dev/null +++ b/ozwadmin-main/eventwindow.ui @@ -0,0 +1,30 @@ + + + EventWindow + + + + 0 + 0 + 640 + 480 + + + + Form + + + + + + 2 + + + + + + + + + + diff --git a/ozwadmin-main/logwindow.cpp b/ozwadmin-main/logwindow.cpp index 7475381..0d856ed 100644 --- a/ozwadmin-main/logwindow.cpp +++ b/ozwadmin-main/logwindow.cpp @@ -4,11 +4,12 @@ #include "ui_logwindow.h" LogWindow::LogWindow(QWidget *parent) : - QDialog(parent), + QWidget(parent), ui(new Ui::LogWindow) { ui->setupUi(this); this->ui->logview->verticalHeader()->hide(); + this->ui->logview->horizontalHeader()->setStretchLastSection(true); this->ui->logview->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); // this->ui->val_system_tbl->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); // this->ui->logview->resizeColumnsToContents(); diff --git a/ozwadmin-main/logwindow.h b/ozwadmin-main/logwindow.h index 9bc4b91..11ab565 100644 --- a/ozwadmin-main/logwindow.h +++ b/ozwadmin-main/logwindow.h @@ -8,7 +8,7 @@ namespace Ui { class LogWindow; } -class LogWindow : public QDialog +class LogWindow : public QWidget { Q_OBJECT diff --git a/ozwadmin-main/logwindow.ui b/ozwadmin-main/logwindow.ui index 0c00bb7..ca755df 100644 --- a/ozwadmin-main/logwindow.ui +++ b/ozwadmin-main/logwindow.ui @@ -1,15 +1,7 @@ LogWindow - - - - 0 - 0 - 640 - 480 - - + OZW Log @@ -42,51 +34,8 @@ - - - - Qt::Horizontal - - - QDialogButtonBox::Close|QDialogButtonBox::Save - - - - - - buttonBox - accepted() - LogWindow - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - LogWindow - reject() - - - 316 - 260 - - - 286 - 274 - - - - + diff --git a/ozwadmin-main/mainwindow.cpp b/ozwadmin-main/mainwindow.cpp index cd1b43e..3168fab 100644 --- a/ozwadmin-main/mainwindow.cpp +++ b/ozwadmin-main/mainwindow.cpp @@ -43,29 +43,34 @@ #include "nodeflagswidget.h" #include "qt-ads/DockAreaWidget.h" #include "ozwcore.h" +#include "eventwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), - ui(new Ui::MainWindow), - sbMsg(this) + ui(new Ui::MainWindow) { + connect(OZWCore::get(), &OZWCore::raiseCriticalError, this, &MainWindow::openCriticalDialog, Qt::DirectConnection); + OZWCore::get()->initilize(); + + this->sbMsg = new statusBarMessages(this); + connect(this->sbMsg, &statusBarMessages::newMessage, this, &MainWindow::setStatusBarMsg); + + this->ui->setupUi(this); this->m_DockManager = new ads::CDockManager(this); this->m_controllerCommands = new ControllerCommands(this); this->connected(false); - - connect(OZWCore::get(), &OZWCore::raiseCriticalError, this, &MainWindow::openCriticalDialog, Qt::DirectConnection); - OZWCore::get()->initilize(); - - - DeviceInfo *di = new DeviceInfo(this); NodeStatus *ni = new NodeStatus(this); + EventWindow *ew = new EventWindow(this); + LogWindow *lw = new LogWindow(this); + connect(this->sbMsg, &statusBarMessages::newMessage, ew, &EventWindow::newEvent); + + statusBar()->showMessage(tr("Starting...")); this->ui->action_Close->setEnabled(false); - connect(ui->actionOpen_Log_Window, SIGNAL(triggered()), this, SLOT(openLogWindow())); connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(OpenConnection())); connect(ui->action_Close, SIGNAL(triggered()), this, SLOT(CloseConnection())); @@ -114,18 +119,24 @@ MainWindow::MainWindow(QWidget *parent) : RightDockWidget->setCurrentDockWidget(DeviceInfoDW); + ads::CDockWidget *eventViewDW = new ads::CDockWidget("Event List"); + eventViewDW->setWidget(ew); + auto BottomDockWidget = this->m_DockManager->addDockWidget(ads::BottomDockWidgetArea, eventViewDW); + + ads::CDockWidget *logWindowDW = new ads::CDockWidget("OZW Logs"); + logWindowDW->setWidget(lw); + this->m_DockManager->addDockWidget(ads::CenterDockWidgetArea, logWindowDW, BottomDockWidget); + BottomDockWidget->setCurrentDockWidget(eventViewDW); + - this->sbMsg.setQTOZWManager(OZWCore::get()->getQTOZWManager()); - QObject::connect(OZWCore::get()->getQTOZWManager(), &QTOZWManager::ready, this, &MainWindow::QTOZW_Ready); OZWCore::get()->getQTOZWManager()->initilizeSource(OZWCore::get()->settings.value("StartServer").toBool()); - this->m_logWindow.setModel(OZWCore::get()->getQTOZWManager()->getLogModel()); userValues->setModel(OZWCore::get()->getQTOZWManager()->getValueModel(), this->ntw->selectionModel()); systemValues->setModel(OZWCore::get()->getQTOZWManager()->getValueModel(), this->ntw->selectionModel()); configValues->setModel(OZWCore::get()->getQTOZWManager()->getValueModel(), this->ntw->selectionModel()); - + lw->setModel(OZWCore::get()->getQTOZWManager()->getLogModel()); di->setQTOZWManager(OZWCore::get()->getQTOZWManager()); ni->setQTOZWManager(OZWCore::get()->getQTOZWManager()); @@ -247,10 +258,6 @@ void MainWindow::NodeSelected(QModelIndex current,QModelIndex previous) { } -void MainWindow::openLogWindow() { - this->m_logWindow.show(); -} - void MainWindow::openMetaDataWindow() { qCDebug(ozwadmin) << "Opening Window"; QModelIndex index = this->ntw->currentIndex(); @@ -299,4 +306,8 @@ void MainWindow::connected(bool connected) { this->ui->action_AddNode->setEnabled(connected); this->ui->action_Delete_Node->setEnabled(connected); this->ui->action_Heal_Network->setEnabled(connected); -} \ No newline at end of file +} + +void MainWindow::setStatusBarMsg(QString Msg) { + this->statusBar()->showMessage(QTime::currentTime().toString("hh:m:ss ap").append(" Event: ").append(Msg), 5000); +} diff --git a/ozwadmin-main/mainwindow.h b/ozwadmin-main/mainwindow.h index 4782ff8..9ea4489 100644 --- a/ozwadmin-main/mainwindow.h +++ b/ozwadmin-main/mainwindow.h @@ -46,7 +46,6 @@ public slots: void CloseConnection(); void resizeColumns(); void NodeSelected(QModelIndex,QModelIndex); - void openLogWindow(); void OpenDeviceDB(); void QTOZW_Ready(); void openAboutWindow(); @@ -55,6 +54,7 @@ public slots: void addNode(); void delNode(); void healNetwork(); + void setStatusBarMsg(QString); QMessageBox::StandardButton openCriticalDialog(QString title, QString msg); @@ -63,10 +63,8 @@ private: ControllerCommands *m_controllerCommands; Ui::MainWindow *ui; - statusBarMessages sbMsg; + statusBarMessages *sbMsg; nodeTableWidget *ntw; - - LogWindow m_logWindow; ads::CDockManager* m_DockManager; }; diff --git a/ozwadmin-main/mainwindow.ui b/ozwadmin-main/mainwindow.ui index a120c90..6e47f7e 100644 --- a/ozwadmin-main/mainwindow.ui +++ b/ozwadmin-main/mainwindow.ui @@ -45,7 +45,6 @@ Window - @@ -73,7 +72,6 @@ - @@ -87,11 +85,6 @@ E&xit - - - Open Log Window - - &Driver Statistics diff --git a/ozwadmin-main/ozwadmin-main.pro b/ozwadmin-main/ozwadmin-main.pro index 78f1cac..3190a90 100644 --- a/ozwadmin-main/ozwadmin-main.pro +++ b/ozwadmin-main/ozwadmin-main.pro @@ -22,6 +22,7 @@ SOURCES += main.cpp\ configuration.cpp \ controllercommands.cpp \ deviceinfo.cpp \ + eventwindow.cpp \ logwindow.cpp \ mainwindow.cpp \ metadatawindow.cpp \ @@ -39,6 +40,7 @@ HEADERS += mainwindow.h \ configuration.h \ controllercommands.h \ deviceinfo.h \ + eventwindow.h \ logwindow.h \ metadatawindow.h \ nodestatus.h \ @@ -54,6 +56,7 @@ HEADERS += mainwindow.h \ FORMS += mainwindow.ui \ configuration.ui \ deviceinfo.ui \ + eventwindow.ui \ logwindow.ui \ metadatawindow.ui \ nodestatus.ui \ diff --git a/ozwadmin-main/statusbarmessages.cpp b/ozwadmin-main/statusbarmessages.cpp index 8a1a0e6..00a65a0 100644 --- a/ozwadmin-main/statusbarmessages.cpp +++ b/ozwadmin-main/statusbarmessages.cpp @@ -1,13 +1,11 @@ #include #include #include "statusbarmessages.h" +#include "ozwcore.h" statusBarMessages::statusBarMessages(QObject *parent) : QObject(parent) { - -} - -void statusBarMessages::setQTOZWManager(QTOZWManager *qtozwm) { + QTOZWManager *qtozwm = OZWCore::get()->getQTOZWManager(); QObject::connect(qtozwm, &QTOZWManager::manufacturerSpecificDBReady, this, &statusBarMessages::manufacturerSpecificDBReady); QObject::connect(qtozwm, &QTOZWManager::ready, this, &statusBarMessages::ready); QObject::connect(qtozwm, &QTOZWManager::starting, this, &statusBarMessages::starting); @@ -40,109 +38,101 @@ void statusBarMessages::setQTOZWManager(QTOZWManager *qtozwm) { QObject::connect(qtozwm, &QTOZWManager::manufacturerSpecificDBReady, this, &statusBarMessages::manufacturerSpecificDBReady); } -void statusBarMessages::setMessage(QString Msg) { - QMainWindow *mw = qobject_cast(parent()); - if (mw) - mw->statusBar()->showMessage(QTime::currentTime().toString("hh:m:ss ap").append(" Event: ").append(Msg), 5000); -} - - - void statusBarMessages::ready() { - setMessage("OpenZwave Ready"); + emit newMessage("OpenZwave Ready"); } void statusBarMessages::valueAdded(quint64 vidKey) { - setMessage(QString("Value Added: %1").arg(vidKey)); + emit newMessage(QString("Value Added: %1").arg(vidKeyDetails(vidKey))); } void statusBarMessages::valueRemoved(quint64 vidKey) { - setMessage(QString("Value Removed: %1").arg(vidKey)); + emit newMessage(QString("Value Removed: %1").arg(vidKeyDetails(vidKey))); } void statusBarMessages::valueChanged(quint64 vidKey) { - setMessage(QString("Value Changed: %1").arg(vidKey)); + emit newMessage(QString("Value Changed: %1").arg(vidKeyDetails(vidKey))); } void statusBarMessages::valueRefreshed(quint64 vidKey) { - setMessage(QString("Value Refreshed: %1").arg(vidKey)); + emit newMessage(QString("Value Refreshed: %1").arg(vidKeyDetails(vidKey))); } void statusBarMessages::nodeNew(quint8 node) { - setMessage(QString("New Node: %1").arg(node)); + emit newMessage(QString("New Node: %1").arg(node)); } void statusBarMessages::nodeAdded(quint8 node) { - setMessage(QString("Node Added: %1").arg(node)); + emit newMessage(QString("Node Added: %1").arg(node)); } void statusBarMessages::nodeRemoved(quint8 node) { - setMessage(QString("Node Removed: %1").arg(node)); + emit newMessage(QString("Node Removed: %1").arg(node)); } void statusBarMessages::nodeReset(quint8 node) { - setMessage(QString("Node Reset: %1").arg(node)); + emit newMessage(QString("Node Reset: %1").arg(node)); } void statusBarMessages::nodeNaming(quint8 node) { - setMessage(QString("Node Name Received: %1").arg(node)); + emit newMessage(QString("Node Name Received: %1").arg(node)); } void statusBarMessages::nodeEvent(quint8 node, quint8 event) { - setMessage(QString("Node %1 Basic Event Received: %2").arg(node).arg(event)); + emit newMessage(QString("Node %1 Basic Event Received: %2").arg(node).arg(event)); } void statusBarMessages::nodeProtocolInfo(quint8 node) { - setMessage(QString("Node Basic Protocol Information Received: %2").arg(node)); + emit newMessage(QString("Node Basic Protocol Information Received: %2").arg(node)); } void statusBarMessages::nodeEssentialNodeQueriesComplete(quint8 node) { - setMessage(QString("Essential Node Queries Complete: %2").arg(node)); + emit newMessage(QString("Essential Node Queries Complete: %2").arg(node)); } void statusBarMessages::nodeQueriesComplete(quint8 node) { - setMessage(QString("Node Queries Complete: %2").arg(node)); + emit newMessage(QString("Node Queries Complete: %2").arg(node)); } void statusBarMessages::nodeGroupChanged(quint8 node, quint8 group) { - setMessage(QString("Node %1 Group Update Received: %2").arg(node).arg(group)); + emit newMessage(QString("Node %1 Group Update Received: %2").arg(node).arg(group)); } void statusBarMessages::driverReady(quint32 homeID) { - setMessage(QString("Driver Ready for HomeID: %2").arg(homeID)); + emit newMessage(QString("Driver Ready for HomeID: %2").arg(homeID)); } void statusBarMessages::driverFailed(quint32 homeID) { - setMessage(QString("Driver Failed for HomeID: %2").arg(homeID)); + emit newMessage(QString("Driver Failed for HomeID: %2").arg(homeID)); } void statusBarMessages::driverReset(quint32 homeID) { - setMessage(QString("Driver Reset for HomeID: %2").arg(homeID)); + emit newMessage(QString("Driver Reset for HomeID: %2").arg(homeID)); } void statusBarMessages::driverRemoved(quint32 homeID) { - setMessage(QString("Driver Removed for HomeID: %2").arg(homeID)); + emit newMessage(QString("Driver Removed for HomeID: %2").arg(homeID)); } void statusBarMessages::driverAllNodesQueriedSomeDead() { - setMessage(QString("ZWave Network Node Queries Completed - Some Dead Nodes")); + emit newMessage(QString("ZWave Network Node Queries Completed - Some Dead Nodes")); } void statusBarMessages::driverAllNodesQueried() { - setMessage(QString("ZWave Network Node Queries Completed")); + emit newMessage(QString("ZWave Network Node Queries Completed")); } void statusBarMessages::driverAwakeNodesQueried() { - setMessage(QString("ZWave Network Awake Node Queries Completed")); + emit newMessage(QString("ZWave Network Awake Node Queries Completed")); } void statusBarMessages::controllerCommand(quint8 node, NotificationTypes::QTOZW_Notification_Controller_Cmd command, NotificationTypes::QTOZW_Notification_Controller_State state, NotificationTypes::QTOZW_Notification_Controller_Error error) { Q_UNUSED(node); - Q_UNUSED(command); - Q_UNUSED(state); - Q_UNUSED(error); - setMessage(QString("ZWave Controller Command Executed")); + QMetaEnum commandEnum = QMetaEnum::fromType(); + QMetaEnum stateEnum = QMetaEnum::fromType(); + QMetaEnum errorEnum = QMetaEnum::fromType(); + emit newMessage(QString("ZWave Controller Command Executed: %1 State: %2 Error: %3").arg(commandEnum.valueToKey(command)).arg(stateEnum.valueToKey(state)).arg(errorEnum.valueToKey(error))); } void statusBarMessages::ozwNotification(quint8 node, NotificationTypes::QTOZW_Notification_Code event) { Q_UNUSED(node); - Q_UNUSED(event); - setMessage(QString("ZWave Network Notification Received")); + QMetaEnum eventEnum = QMetaEnum::fromType(); + emit newMessage(QString("ZWave Network Notification Received: %1").arg(eventEnum.valueToKey(event))); } void statusBarMessages::ozwUserAlert(quint8 node, NotificationTypes::QTOZW_Notification_User event, quint8 retry) { Q_UNUSED(node); - Q_UNUSED(event); Q_UNUSED(retry); - setMessage(QString("ZWave User Alert Received")); + QMetaEnum eventEnum = QMetaEnum::fromType(); + emit newMessage(QString("ZWave User Alert Received: %1").arg(eventEnum.valueToKey(event))); } void statusBarMessages::manufacturerSpecificDBReady() { - setMessage(QString("Manufacturer Specific Database Loaded")); + emit newMessage(QString("Manufacturer Specific Database Loaded")); } void statusBarMessages::starting() { - setMessage(QString("Starting Z-Wave Network")); + emit newMessage(QString("Starting Z-Wave Network")); } void statusBarMessages::started(quint32 homeID) { - setMessage(QString("Started Z-Wave Network: %1").arg(homeID)); + emit newMessage(QString("Started Z-Wave Network: %1").arg(homeID)); } void statusBarMessages::stopped(quint32 homeID) { - setMessage(QString("Stopped Z-Wave Network: %1").arg(homeID)); + emit newMessage(QString("Stopped Z-Wave Network: %1").arg(homeID)); } #if 0 void statusBarMessages::remoteConnectionStatus(connectionStatus status, QAbstractSocket::SocketError error) { @@ -150,3 +140,10 @@ void statusBarMessages::remoteConnectionStatus(connectionStatus status, QAbstrac } #endif +QString statusBarMessages::vidKeyDetails(quint64 key) { + quint8 node = OZWCore::get()->getQTOZWManager()->getNodeId(key); + quint8 instance = OZWCore::get()->getQTOZWManager()->getInstance(key); + QString label = OZWCore::get()->getQTOZWManager()->getValueLabel(key); + QString status(QString("Node %1, Instance %2, Label %3").arg(node).arg(instance).arg(label)); + return status; +} diff --git a/ozwadmin-main/statusbarmessages.h b/ozwadmin-main/statusbarmessages.h index ac9dd27..9b7ee4f 100644 --- a/ozwadmin-main/statusbarmessages.h +++ b/ozwadmin-main/statusbarmessages.h @@ -11,9 +11,8 @@ class statusBarMessages : public QObject Q_OBJECT public: explicit statusBarMessages(QObject *parent = nullptr); - void setQTOZWManager(QTOZWManager *m_qtozwmanager); signals: - + void newMessage(QString); public slots: void ready(); void valueAdded(quint64 vidKey); @@ -46,9 +45,9 @@ public slots: void stopped(quint32 homeID); // void remoteConnectionStatus(WebSocketIoDevice::connectionStatus status, QAbstractSocket::SocketError error); + QString vidKeyDetails(quint64); private: - void setMessage(QString); };