Esempio n. 1
0
void MainWindow::showDialogChangeTemperature()
{
    QString dialogTitle = _currentTemperatureIndicator->getText();
    quint8 sensorId = _currentTemperatureIndicator->getSensorId();
    bool temperatureIndicatorFunctional = _currentTemperatureIndicator->isSensorFunctional();
    qreal temperatureTarget = _currentTemperatureIndicator->getTemperatureTarget();
    qreal temperatureCurrent = _currentTemperatureIndicator->getTemperatureCurrent();

    DialogTemperatureTarget dialogChangeTemperature(this,
                                                    dialogTitle,
                                                    sensorId,
                                                    temperatureIndicatorFunctional,
                                                    temperatureTarget,
                                                    temperatureCurrent);

    if(dialogChangeTemperature.exec()) {
        qreal temperature = dialogChangeTemperature.getValue();
        _currentTemperatureIndicator->setTemperatureTarget(temperature);

        QString key = QString::number(_currentTemperatureIndicator->getSensorId());
        _programSettingsPersistant->setValue(key, temperature);

        sendTemperatureTarget(_currentTemperatureIndicator);

        updateDialByCurrentTemperatureIndicator();
    }
} // showDialogChangeTemperature()
void MainWindow::showDialogChangeTemperature()
{
    QString dialogTitle = _currentTemperatureIndicator->text();
    quint8 sensorId = _currentTemperatureIndicator->getSensorId();
    bool temperatureIndicatorFunctional = _currentTemperatureIndicator->isSensorFunctional();
    qreal temperatureTarget = _currentTemperatureIndicator->getTemperatureTarget();
    qreal temperatureCurrent = _currentTemperatureIndicator->getTemperatureCurrent();

    DialogTemperatureTarget dialogChangeTemperature(this,
                                                    dialogTitle,
                                                    sensorId,
                                                    temperatureIndicatorFunctional,
                                                    temperatureTarget,
                                                    temperatureCurrent);

    // Remove ? from TitleBar
    Qt::WindowFlags windowFlags = dialogChangeTemperature.windowFlags();
    windowFlags &= ~Qt::WindowContextHelpButtonHint;
    dialogChangeTemperature.setWindowFlags(windowFlags);

    if(dialogChangeTemperature.exec()) {
        qreal temperature = dialogChangeTemperature.getValue();
        _currentTemperatureIndicator->setTemperatureTarget(temperature);
        QString key = QString::number(_currentTemperatureIndicator->getSensorId());
        _programSettingsPersistant->setValue(key, temperature);
        sendTemperatureTarget(_currentTemperatureIndicator);
    }
}
Esempio n. 3
0
void MainWindow::on_dial_valueChanged(int value)
{
    if (nullptr == _currentTemperatureIndicator) {
        return;   
    }

    qreal valueReal = static_cast<qreal>(value * 0.1);

    _currentTemperatureIndicator->setTemperatureTarget(valueReal);
    sendTemperatureTarget(_currentTemperatureIndicator);
} // on_dial_valueChanged
void MainWindow::onConnected()
{
    qDebug()<< "Connected!";
    qDebug() << "Local address" << QString("%1:%2").arg(_socket->localAddress().toString())
                                           .arg(_socket->localPort());
    qDebug() << "Peer address:" << QString("%1:%2").arg(_socket->peerAddress().toString())
                                           .arg(_socket->localPort());

    // Send all target temperatures on connect
    for (TemperatureIndicator* currentTemperatureIndicator: _temperatureIndicators) {
        sendTemperatureTarget(currentTemperatureIndicator);
    }
}
Esempio n. 5
0
// PRIVATE: SLOTS
void MainWindow::onConnected()
{
    qDebug() << "Connected!";
    qDebug() << "Local address:" << QString("%1:%2").arg(_socket->localAddress().toString())
                                            .arg(_socket->localPort());
    qDebug() << "Peer address:" << QString("%1:%2").arg(_socket->peerAddress().toString())
                                           .arg(_socket->localPort());

    _isConnected = true;

    setWindowTitle(_programSettings.application.name);

    // Send all target temperatures on connect
    for (TemperatureIndicator* currentTemperatureIndicator: _temperatureIndicators) {
        sendTemperatureTarget(currentTemperatureIndicator);
    }
} // onConnected()
Esempio n. 6
0
void MainWindow::setScene(QString sceneName)
{
    Scene* scene = _sceneDataModel->getSceneByName(sceneName);
    if (nullptr == scene) {
        qDebug() << "Scene not found in setScene(" << sceneName << ")";

        return;
    }

    for (int sensorIndex = 0;
         sensorIndex < scene->sensors.count();
         sensorIndex ++) {
        qreal temperatureTarget = scene->sensors.at(sensorIndex).temperatureTarget;
        quint8 sensorId = scene->sensors.at(sensorIndex).sensorId;
        TemperatureIndicator* indicator = findTemperatureIndicatorById(sensorId);
        indicator->setTemperatureTarget(temperatureTarget);
        sendTemperatureTarget(indicator);
    }
} // setScene()