Example #1
0
/*! Returns the \l{State} with the given \a stateTypeId of this Device. */
State Device::state(const StateTypeId &stateTypeId) const
{
    for (int i = 0; i < m_states.count(); ++i) {
        if (m_states.at(i).stateTypeId() == stateTypeId) {
            return m_states.at(i);
        }
    }
    return State(StateTypeId(), DeviceId());
}
Example #2
0
void HttpDaemon::readClient()
{
    if (disabled)
        return;

    // This slot is called when the client sent data to the server. The
    // server looks if it was a get request and sends a very simple HTML
    // document back.
    QTcpSocket* socket = (QTcpSocket*)sender();
    if (socket->canReadLine()) {
        QByteArray data = socket->readLine();
        QStringList tokens = QString(data).split(QRegExp("[ \r\n][ \r\n]*"));
        qDebug() << "incoming data" << tokens[1];
        QUrl url("http://foo.bar" + tokens[1]);
        QUrlQuery query(url);
        qDebug() << "query is" << url.path();
        if (url.path() == "/setstate") {
            emit setState(StateTypeId(query.queryItems().first().first), QVariant(query.queryItems().first().second));
        } else if (url.path() == "/generateevent") {
            qDebug() << "got generateevent" << query.queryItemValue("eventtypeid");
            emit triggerEvent(EventTypeId(query.queryItemValue("eventtypeid")));
        } else if (url.path() == "/actionhistory") {
            QTextStream os(socket);
            os.setAutoDetectUnicode(true);
            os << generateHeader();
            for (int i = 0; i < m_actionList.count(); ++i) {
                os << m_actionList.at(i).first.toString() << '\n';
            }
            socket->close();
            return;
        } else if (url.path() == "/clearactionhistory") {
            m_actionList.clear();
        }
        if (tokens[0] == "GET") {
            QTextStream os(socket);
            os.setAutoDetectUnicode(true);
            os << generateWebPage();
            socket->close();

            qDebug() << "Wrote to client";

            if (socket->state() == QTcpSocket::UnconnectedState) {
                delete socket;
                qDebug() << "Connection closed";
            }
        }
    }
}
Example #3
0
                        \li 269f25eb-d0b7-4144-b9ef-801f4ff3e90c
                    \endtable
*/


#include "deviceplugineq-3.h"

#include "plugin/device.h"
#include "devicemanager.h"
#include "types/param.h"

#include <QDebug>


DeviceClassId cubeDeviceClassId = DeviceClassId("1e892268-8bd7-442c-a001-bd4e2e6b2949");
StateTypeId connectionStateTypeId = StateTypeId("d0a9a369-cf8c-47c4-a12e-f2d076bf12fd");
StateTypeId portalEnabeldStateTypeId = StateTypeId("2c2367da-c229-40ed-9d47-a6e73cd6dc3b");

DeviceClassId wallThermostateDeviceClassId = DeviceClassId("ffbfec5d-06e8-4082-b62b-92cc5c3e8c4e");

StateTypeId confortTempStateTypeId = StateTypeId("850380ee-a787-43e7-adb8-768a21a6e64d");
StateTypeId ecoTempStateTypeId = StateTypeId("24dfd20d-bc8d-48e4-8162-b20ae0465c41");
StateTypeId maxSetpointTempStateTypeId = StateTypeId("a8536ddf-a6e4-41c2-89c1-e7102608f5f6");
StateTypeId minSetpointTempStateTypeId = StateTypeId("ceb0ad05-37ad-4b79-a4d9-540c34a7e3e4");
StateTypeId errorOccuredStateTypeId = StateTypeId("9880247b-cf9a-453c-b0c3-d910eba8a253");
StateTypeId initializedStateTypeId = StateTypeId("a9e29f03-063e-4686-8aac-2f6d8f8a4937");
StateTypeId batteryLowStateTypeId = StateTypeId("53b89f32-8894-4290-92a0-6a470c6b69ab");
StateTypeId linkStatusOKStateTypeId = StateTypeId("aff38be8-7ea6-4fd8-b0fa-e987ab05c719");
StateTypeId panelLockedStateTypeId = StateTypeId("979df197-09a1-46f9-9217-9d323b1062bd");
StateTypeId gatewayKnownStateTypeId = StateTypeId("1d6bd962-5c31-47ad-80a4-dda87bff98f5");
StateTypeId dtsActiveStateTypeId = StateTypeId("1b402ba6-a8ae-45b1-8acf-2b0a89f71889");