MainWindow::MainWindow(QWidget *parent, Reception *reception) : QMainWindow(parent), _ui(new Ui::MainWindow), _reception(reception) { QTimer *timer = new QTimer(this); QTimer *day = new QTimer(this); timer->start(500); day->start(this->_reception->getPreparePizza() * this->_reception->getReplaceStock() * 30); this->_ui->setupUi(this); QObject::connect(this->_ui->actionQuit, SIGNAL(triggered()), this, SLOT(quitWindow())); QObject::connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(quitWindow())); QObject::connect(this->_ui->tableKitchen, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), SLOT(switchItem(QListWidgetItem *, QListWidgetItem *))); QObject::connect(this->_ui->sliderPizzaNumber, SIGNAL(valueChanged(int)), this->_ui->pizzaNumber, SLOT(display(int))); QObject::connect(this->_ui->buttonOrder, SIGNAL(clicked()), SLOT(getOrderFromForm())); QObject::connect(this->_ui->linePizzaOrder, SIGNAL(returnPressed()), SLOT(getOrderFromLine())); QObject::connect(this->_ui->actionOpenMan, SIGNAL(triggered()), this, SLOT(openMan())); QObject::connect(this->_ui->actionOpenQt, SIGNAL(triggered()), this, SLOT(openQt())); QObject::connect(this->_ui->actionOpenLog, SIGNAL(triggered()), this, SLOT(openLog())); QObject::connect(this->_ui->actionAchievment, SIGNAL(triggered()), this, SLOT(openAchievment())); QObject::connect(timer, SIGNAL(timeout()), SLOT(refresh())); QObject::connect(day, SIGNAL(timeout()), SLOT(newDay())); };
void Inverter::readyRead() { // read the data from the socket QByteArray data = m_socket->readAll(); // if we have actually read some data if (data.length()) { const char * outData = data.data(); // check what message is being returned if (data[2] == (char)0x01 && data[3] == (char)0x83) { m_cycle = MSG_DATA; // response to general detail msg qDebug() << "version" << &outData[10]; qDebug() << "model" << &outData[25]; qDebug() << "desc" << &outData[35]; qDebug() << "serial" << &outData[51]; qDebug() << "software" << &outData[67]; // print out some nice CSV headings to std::out if (m_stdout) std::cout << "Date,Time,Temperature,Panel V, Panel I, Panel P, Grid V, Grid I, Grid P, Energy" << std::endl; } else { short mode = data[22]; // check inverter operation mode if (mode == 1) { dataMsg dataMsgPtr; // The values that the inverter sends us only relate to - // 1 - the power being generated from the PV array // 2 - the power being exported to the grid // There is no way to get consumtion data from these. // heat sink temperature dataMsgPtr.temperature = (float)(((short)outData[ 7] << 8 & 0xff00) | (outData[ 8] & 0x00ff)) / 10.0f; // PV array outputs dataMsgPtr.panel1V = (float)(((short)outData[ 9] << 8 & 0xff00) | (outData[10] & 0x00ff)) / 10.0f; dataMsgPtr.panel1I = (float)(((short)outData[13] << 8 & 0xff00) | (outData[14] & 0x00ff)) / 10.0f; dataMsgPtr.panel1P = dataMsgPtr.panel1V * dataMsgPtr.panel1I; // grid supply stats dataMsgPtr.gridI = (float)(((short)outData[49] << 8 & 0xff00) | (outData[50] & 0x00ff)) / 10.0f; dataMsgPtr.gridV = (float)(((short)outData[51] << 8 & 0xff00) | (outData[52] & 0x00ff)) / 10.0f; dataMsgPtr.gridF = (float)(((short)outData[53] << 8 & 0xff00) | (outData[54] & 0x00ff)); dataMsgPtr.gridP = (float)(((short)outData[55] << 8 & 0xff00) | (outData[56] & 0x00ff)); // "today" energy dataMsgPtr.energy = (float)( ((int)(outData[23]) << 8 & 0x0000ff00) | ((int)(outData[24]) << 0 & 0x000000ff)) * 10.0f; if (m_stdout) std::cout << dataMsgPtr.timeStamp.date().toString("yyyy/MM/dd").toStdString() << "," << dataMsgPtr.timeStamp.time().toString("HH:mm:ss").toStdString() << "," << dataMsgPtr.temperature << "," << dataMsgPtr.panel1V << "," << dataMsgPtr.panel1I << "," << dataMsgPtr.panel1P << "," << dataMsgPtr.gridV << "," << dataMsgPtr.gridI << "," << dataMsgPtr.gridP << "," << dataMsgPtr.energy << std::endl; emit newData(dataMsgPtr); } else emit newDay(); } } }