| 
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -10,6 +10,7 @@ | 
															
														
														
													
														
															
																 | 
																 | 
																#include <QPushButton>
 | 
																 | 
																 | 
																#include <QPushButton>
 | 
															
														
														
													
														
															
																 | 
																 | 
																#include <QTime>
 | 
																 | 
																 | 
																#include <QTime>
 | 
															
														
														
													
														
															
																 | 
																 | 
																#include <QLocale>
 | 
																 | 
																 | 
																#include <QLocale>
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																#include <QVector>
 | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																#include "mqttclient.h"
 | 
																 | 
																 | 
																#include "mqttclient.h"
 | 
															
														
														
													
														
															
																 | 
																 | 
																#include "zoneitem.h"
 | 
																 | 
																 | 
																#include "zoneitem.h"
 | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																			
																		
																	
																 | 
																@ -19,33 +20,40 @@ | 
															
														
														
													
														
															
																 | 
																 | 
																MainWindow::MainWindow(QWidget *parent) : | 
																 | 
																 | 
																MainWindow::MainWindow(QWidget *parent) : | 
															
														
														
													
														
															
																 | 
																 | 
																	QMainWindow(parent) | 
																 | 
																 | 
																	QMainWindow(parent) | 
															
														
														
													
														
															
																 | 
																 | 
																{ | 
																 | 
																 | 
																{ | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	ZoneItem *zone; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																	Settings *s = Settings::getInstance(); | 
																 | 
																 | 
																	Settings *s = Settings::getInstance(); | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																	mqttclient = new MQTTSubcriber(QHostAddress("192.168.1.2"), 1883); | 
																 | 
																 | 
																	mqttclient = new MQTTSubcriber(QHostAddress("192.168.1.2"), 1883); | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																	for (int i = 0; i < NB_ZONES; i++) { | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																		m_zones[i] = new ZoneItem(s->m_rooms_names[i], this); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	for (int i = 0; i < s->nbZones(); i++) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		zone = new ZoneItem(s->m_rooms.at(i).name, this); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		m_zones << zone; | 
															
														
														
													
														
															
																 | 
																 | 
																	} | 
																 | 
																 | 
																	} | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																	connect(mqttclient, SIGNAL(new_temperature(unsigned, double)), | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																				   this, SLOT(temperature_slot(unsigned, double))); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																	connect(mqttclient, SIGNAL(new_hygro(unsigned, double)), | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																				   this, SLOT(hygro_slot(unsigned, double))); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	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(unsigned, bool)), | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																				   this, SLOT(availability_slot(unsigned, bool))); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	connect(mqttclient, SIGNAL(new_availability(int, bool)), | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																				   this, SLOT(availability_slot(int, bool))); | 
															
														
														
													
														
															
																 | 
																 | 
																	/*
 | 
																 | 
																 | 
																	/*
 | 
															
														
														
													
														
															
																 | 
																 | 
																	 * Sensors-related layout | 
																 | 
																 | 
																	 * Sensors-related layout | 
															
														
														
													
														
															
																 | 
																 | 
																	 */ | 
																 | 
																 | 
																	 */ | 
															
														
														
													
														
															
																 | 
																 | 
																	QGridLayout *mainLayout = new QGridLayout; | 
																 | 
																 | 
																	QGridLayout *mainLayout = new QGridLayout; | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																	mainLayout->addWidget(m_zones[0], 0, 0); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																	mainLayout->addWidget(m_zones[1], 0, 1); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																	mainLayout->addWidget(new QPushButton(tr("Menu")), 0, 2); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																	mainLayout->addWidget(m_zones[2], 1, 0); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																	mainLayout->addWidget(m_zones[3], 1, 1); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																	mainLayout->addWidget(new QPushButton(tr("Auto")), 1, 2); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	if (s->nbZones() < 4) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		// TODO
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		qDebug() << "bad configuration" ; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	} else { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		mainLayout->addWidget(m_zones.at(0), 0, 0); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		mainLayout->addWidget(m_zones.at(1), 0, 1); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		mainLayout->addWidget(new QPushButton(tr("Menu")), 0, 2); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		mainLayout->addWidget(m_zones.at(2), 1, 0); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		mainLayout->addWidget(m_zones.at(3), 1, 1); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		mainLayout->addWidget(new QPushButton(tr("Auto")), 1, 2); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	} | 
															
														
														
													
														
															
																 | 
																 | 
																	QWidget *mainWidget = new QWidget; | 
																 | 
																 | 
																	QWidget *mainWidget = new QWidget; | 
															
														
														
													
														
															
																 | 
																 | 
																	mainWidget->setLayout(mainLayout); | 
																 | 
																 | 
																	mainWidget->setLayout(mainLayout); | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																			
																		
																	
																 | 
																@ -64,26 +72,32 @@ MainWindow::~MainWindow() | 
															
														
														
													
														
															
																 | 
																 | 
																{ | 
																 | 
																 | 
																{ | 
															
														
														
													
														
															
																 | 
																 | 
																} | 
																 | 
																 | 
																} | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																void MainWindow::temperature_slot(unsigned idx, double val) | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																void MainWindow::temperature_slot(int idx, double val) | 
															
														
														
													
														
															
																 | 
																 | 
																{ | 
																 | 
																 | 
																{ | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	Settings *s = Settings::getInstance(); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																	qDebug() << "temperature idx:" << idx << " val: " << val << endl; | 
																 | 
																 | 
																	qDebug() << "temperature idx:" << idx << " val: " << val << endl; | 
															
														
														
													
														
															
																 | 
																 | 
																	if (idx < NB_ZONES) { | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																		m_zones[idx]->set_temperature_value(val); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	if (idx < s->nbZones()) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		m_zones.at(idx)->set_temperature_value(val); | 
															
														
														
													
														
															
																 | 
																 | 
																	} | 
																 | 
																 | 
																	} | 
															
														
														
													
														
															
																 | 
																 | 
																} | 
																 | 
																 | 
																} | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																void MainWindow::hygro_slot(unsigned idx, double val) | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																void MainWindow::hygro_slot(int idx, double val) | 
															
														
														
													
														
															
																 | 
																 | 
																{ | 
																 | 
																 | 
																{ | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	Settings *s = Settings::getInstance(); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																	qDebug() << "hygro idx:" << idx << " val: " << val << endl; | 
																 | 
																 | 
																	qDebug() << "hygro idx:" << idx << " val: " << val << endl; | 
															
														
														
													
														
															
																 | 
																 | 
																	if (idx < NB_ZONES) { | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																		m_zones[idx]->set_hygro_value(val); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	if (idx < s->nbZones()) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		m_zones.at(idx)->set_hygro_value(val); | 
															
														
														
													
														
															
																 | 
																 | 
																	} | 
																 | 
																 | 
																	} | 
															
														
														
													
														
															
																 | 
																 | 
																} | 
																 | 
																 | 
																} | 
															
														
														
													
														
															
																 | 
																 | 
																void MainWindow::availability_slot(unsigned idx, bool ok) | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																void MainWindow::availability_slot(int idx, bool ok) | 
															
														
														
													
														
															
																 | 
																 | 
																{ | 
																 | 
																 | 
																{ | 
															
														
														
													
														
															
																 | 
																 | 
																	if ((idx < NB_ZONES) && !ok) { | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																		m_zones[idx]->set_hygro_value(0); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																		m_zones[idx]->set_temperature_value(0); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	Settings *s = Settings::getInstance(); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																	if ((idx < s->nbZones()) && !ok) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		m_zones.at(idx)->set_hygro_value(0); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																		m_zones.at(idx)->set_temperature_value(0); | 
															
														
														
													
														
															
																 | 
																 | 
																	} | 
																 | 
																 | 
																	} | 
															
														
														
													
														
															
																 | 
																 | 
																} | 
																 | 
																 | 
																} | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																 | 
																
  |