From e77a367ac9fd59deacc15206fa7777e8bbadae89 Mon Sep 17 00:00:00 2001 From: victor Date: Wed, 5 Apr 2017 18:05:51 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AA=A8=EB=93=9C=EB=B2=84=EC=8A=A4=20?= =?UTF-8?q?=EC=A3=BC=EC=86=8C=20=EC=84=A4=EB=AA=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/gui/packet/mainwindow.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/app/gui/packet/mainwindow.cpp b/app/gui/packet/mainwindow.cpp index e9ddf62..d7128ec 100644 --- a/app/gui/packet/mainwindow.cpp +++ b/app/gui/packet/mainwindow.cpp @@ -14,6 +14,8 @@ MainWindow::MainWindow(QWidget *parent) : if (!sock->bind(4000)) exit(EXIT_FAILURE); + bzero(&control, sizeof(control)); + bzero(&state, sizeof(state)); connect(sock, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams())); @@ -84,6 +86,12 @@ MainWindow::MainWindow(QWidget *parent) : ui->controlTable->setItem(0x0F, 3, new QTableWidgetItem("Convection RPM")); ui->controlTable->setItem(0x10, 3, new QTableWidgetItem("Cool Down On/Off")); ui->controlTable->setItem(0x11, 3, new QTableWidgetItem("InterTemp")); +// ui->controlTable->setItem(0x12, 3, new QTableWidgetItem("InterTemp")); +// ui->controlTable->setItem(0x13, 3, new QTableWidgetItem("InterTemp")); + ui->controlTable->setItem(0x14, 3, new QTableWidgetItem("Wash Type")); + ui->controlTable->setItem(0x15, 3, new QTableWidgetItem("Wash Total")); + ui->controlTable->setItem(0x16, 3, new QTableWidgetItem("Wash Steps")); + ui->controlTable->setItem(0x17, 3, new QTableWidgetItem("Wash Step Type")); ui->stateTable->setItem(0x00, 3, new QTableWidgetItem("Firmware V")); ui->stateTable->setItem(0x01, 3, new QTableWidgetItem("Firmware Y")); @@ -97,8 +105,8 @@ MainWindow::MainWindow(QWidget *parent) : ui->stateTable->setItem(0x09, 3, new QTableWidgetItem("Current Humidity")); ui->stateTable->setItem(0x0A, 3, new QTableWidgetItem("Current Time")); ui->stateTable->setItem(0x0B, 3, new QTableWidgetItem("Wash State")); -// ui->stateTable->setItem(0x0C, 3, new QTableWidgetItem("Oven Mode")); -// ui->stateTable->setItem(0x0D, 3, new QTableWidgetItem("Oven Mode")); + ui->stateTable->setItem(0x0C, 3, new QTableWidgetItem("Wash Type")); + ui->stateTable->setItem(0x0D, 3, new QTableWidgetItem("Wash Steps")); // ui->stateTable->setItem(0x0E, 3, new QTableWidgetItem("Oven Mode")); // ui->stateTable->setItem(0x0F, 3, new QTableWidgetItem("Oven Mode")); ui->stateTable->setItem(0x10, 3, new QTableWidgetItem("Door Open/Close")); @@ -161,12 +169,15 @@ void MainWindow::processDatagram(QByteArray &datagram) switch (packet->header) { case HDR_OVEN_CONTROL: + qDebug() << "Received Control"; processControl((oven_control_t *) packet->body); break; case HDR_OVEN_STATE: + qDebug() << "Received State"; processState((oven_state_t *) packet->body); break; case HDR_ERROR_CODE: + qDebug() << "Received Error"; break; } } @@ -189,6 +200,7 @@ void MainWindow::updateControl(oven_control_t *control) U16 *operand = (U16 *) control; for (int row = 0; row < ui->controlTable->rowCount(); row++) { + qDebug() << "Diff"; U16 b = *(base + row); U16 o = *(operand + row); if (b != o) @@ -225,7 +237,8 @@ void MainWindow::updateState(oven_state_t *state) void MainWindow::on_pushControlButton_clicked() { - U16 *base = (U16 *) &this->control; + oven_control_t control = this->control; + U16 *base = (U16 *) &control; for (int row = 0; row < ui->controlTable->rowCount(); row++) { QTableWidgetItem *val = (QTableWidgetItem *) ui->controlTable->item(row, 4); @@ -235,7 +248,7 @@ void MainWindow::on_pushControlButton_clicked() gui_oven_control_t c; c.header = HDR_OVEN_CONTROL; - memcpy(&c.control, &this->control, sizeof(this->control)); + memcpy(&c.control, &control, sizeof(this->control)); QByteArray datagram = QByteArray::fromRawData((char *) &c, sizeof(c)); sock->writeDatagram(datagram, QHostAddress("192.168.10.139"), 4000); -- 2.1.4