|
@ -12,7 +12,6 @@ |
|
|
#include <QLocale>
|
|
|
#include <QLocale>
|
|
|
#include <QVector>
|
|
|
#include <QVector>
|
|
|
|
|
|
|
|
|
#include "mqttclient.h"
|
|
|
|
|
|
#include "zoneitem.h"
|
|
|
#include "zoneitem.h"
|
|
|
#include "settings.h"
|
|
|
#include "settings.h"
|
|
|
#include "mainwindow.h"
|
|
|
#include "mainwindow.h"
|
|
@ -24,20 +23,11 @@ MainWindow::MainWindow(QWidget *parent) : |
|
|
|
|
|
|
|
|
Settings *s = Settings::getInstance(); |
|
|
Settings *s = Settings::getInstance(); |
|
|
|
|
|
|
|
|
mqttclient = new MQTTClient(QHostAddress(s->m_broker.address), s->m_broker.port); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < s->nbZones(); i++) { |
|
|
for (int i = 0; i < s->nbZones(); i++) { |
|
|
zone = new ZoneItem(s->m_rooms.at(i).name, this); |
|
|
zone = new ZoneItem(s->m_rooms.at(i).name, this); |
|
|
m_zones << zone; |
|
|
m_zones << zone; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
connect(mqttclient, SIGNAL(new_temperature(int, double)), |
|
|
|
|
|
this, SLOT(temperature_slot(int, double))); |
|
|
|
|
|
connect(mqttclient, SIGNAL(new_hygro(int, double)), |
|
|
|
|
|
this, SLOT(hygro_slot(int, double))); |
|
|
|
|
|
|
|
|
|
|
|
connect(mqttclient, SIGNAL(new_availability(int, bool)), |
|
|
|
|
|
this, SLOT(availability_slot(int, bool))); |
|
|
|
|
|
/*
|
|
|
/*
|
|
|
* Sensors-related layout |
|
|
* Sensors-related layout |
|
|
*/ |
|
|
*/ |
|
@ -61,6 +51,7 @@ MainWindow::MainWindow(QWidget *parent) : |
|
|
|
|
|
|
|
|
QWidget *mainWidget = new QWidget; |
|
|
QWidget *mainWidget = new QWidget; |
|
|
mainWidget->setLayout(mainLayout); |
|
|
mainWidget->setLayout(mainLayout); |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
* Top widget |
|
|
* Top widget |
|
|
*/ |
|
|
*/ |
|
@ -69,11 +60,16 @@ MainWindow::MainWindow(QWidget *parent) : |
|
|
setWindowTitle(tr("Sorico's thermostat")); |
|
|
setWindowTitle(tr("Sorico's thermostat")); |
|
|
m_backLoop.start(); |
|
|
m_backLoop.start(); |
|
|
|
|
|
|
|
|
mqttclient->connectToHost(); |
|
|
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(new_pwr_state(enum power_states)), |
|
|
connect(this, SIGNAL(new_pwr_state(enum power_states)), |
|
|
&m_backLoop, SLOT(onNewPowerState(enum power_states))); |
|
|
&m_backLoop, SLOT(onNewPowerState(enum power_states))); |
|
|
|
|
|
|
|
|
|
|
|
connect(&m_backLoop, SIGNAL(new_temperature(int, double)), |
|
|
|
|
|
this, SLOT(temperature_slot(int, double))); |
|
|
|
|
|
connect(&m_backLoop, SIGNAL(new_hygro(int, double)), |
|
|
|
|
|
this, SLOT(hygro_slot(int, double))); |
|
|
|
|
|
connect(&m_backLoop, SIGNAL(new_availability(int, bool)), |
|
|
|
|
|
this, SLOT(availability_slot(int, bool))); |
|
|
|
|
|
|
|
|
connect(&m_state_btn, SIGNAL(clicked()), this, SLOT(change_state())); |
|
|
connect(&m_state_btn, SIGNAL(clicked()), this, SLOT(change_state())); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|