# shxbee.h

Go to the documentation of this file.

    00001 /*
    00002  * SmartHome server: Plug-in xbee
    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 SHXBEE_H
    00019 #define SHXBEE_H
    00020
    00021 #include <QtCore/QCoreApplication>
    00022 #include <QtPlugin>
    00023 #include <QObject>
    00024 #include <QString>
    00025 #include <QMap>
    00026 #include "shobjecthelper.h"
    00027 #include "xbinterface.h"
    00028 #include "xbmessage.h"
    00029 #include "shbase.h"
    00030 #include "shpin.h"
    00031
    00032 // -----------------------------------------------------------------------------
    00033
    00038 class XbModuleData
    00039 {
    00040 public:
    00041     XbModuleData();
    00042
    00043     quint16 lastDigitalSample;
    00044     quint16 inputs, outputs;
    00045 };
    00046 // -----------------------------------------------------------------------------
    00047
    00052 class ShXbee : public ShObjectHelper
    00053 {
    00054     Q_OBJECT
    00055     Q_INTERFACES(ShObject)
    00056
    00057 public:
    00058     ShXbee(QObject *parent = 0);
    00059     virtual ~ShXbee() {};
    00060     virtual bool init(QString param);
    00061     virtual void updatePins(const QList<ShPin> &pins);
    00062     virtual void processMessage(ShMessagePtr message);
    00063
    00064     void setInputMonitoring();
    00065
    00066 private slots:
    00067     void processPacket(QByteArray data);
    00068     void messageProcessed(int id);
    00069     void messageError(int id, QString reason);
    00070     void messageTimeout();
    00071
    00072 private:
    00073     quint8 nextFrameId();
    00074     bool   sendPacket(int id, ShMessagePtr message, XbPacket *packet);
    00075
    00076     XbInterface *mInterface;
    00077     quint8       mLastFrameId;
    00078     QMap<int, XbMessagePtr>  mMsgPool;
    00079     QMap<quint64, XbModuleData>  mModules;
    00080 };
    00081 // -----------------------------------------------------------------------------
    00082
    00083 #endif // SHXBEE_H

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends