# x10interface.h

Go to the documentation of this file.

    00001 /*
    00002  * SmartHome server: Plug-in x10
    00003  *
    00004  * Copyright (C) 2010 Daniel Pisi <dan.pisi@gmail.com>
    00005  *
    00006  * This program is free software; you can redistribute it and/or modify it
    00007  * under the terms of version 2 of the GNU General Public License
    00008  * as published by the Free Software Foundation.
    00009  *
    00010  */
    00011
    00018 #ifndef X10INTERFACE_H
    00019 #define X10INTERFACE_H
    00020
    00021 #include <QObject>
    00022 #include <QDateTime>
    00023 #include <QQueue>
    00024 #include <QRegExp>
    00025 #include <QStringList>
    00026 #include <QTimer>
    00027 #include "qextserialport.h"
    00028 #include "x10packet.h"
    00029
    00030 // -----------------------------------------------------------------------------
    00031
    00036 class X10Interface : public QObject
    00037 {
    00038 Q_OBJECT
    00039
    00040 public:
    00041     enum X10State
    00042     {
    00043         stReady = 0, stCmdSent, stChecksumOk
    00044     };
    00045
    00046     X10Interface(QString device, QObject *parent = 0);
    00047
    00048     bool onOffDevices(QString devices, bool on);
    00049     bool dimLights(QString devices, int dim);
    00050     bool onOffAllLights(char house, bool on);
    00051
    00052     void sendTime();
    00053     X10State state() { return mState; };
    00054
    00055 signals:
    00056     void transmissionDone();
    00057     void transmissionFailed(QString reason);
    00058
    00059 private slots:
    00060     void onReadyRead();
    00061     void onTimeout();
    00062
    00063 private:
    00064     void sendNextPacket();
    00065     bool enqueueAddressing(QString devices);
    00066
    00067     QextSerialPort *mX10Port;
    00068     X10State mState;
    00069     QQueue<X10PacketPtr> mPacketQueue;
    00070     QTimer *mTimer;
    00071 };
    00072 // -----------------------------------------------------------------------------
    00073
    00074 #endif // X10INTERFACE_H

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends