# xbitems.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 XBITEMS_H
    00019 #define XBITEMS_H
    00020
    00021 #include <QtCore/QCoreApplication>
    00022 #include <QDataStream>
    00023 #include "xbstreamitem.h"
    00024
    00025 // -----------------------------------------------------------------------------
    00026
    00031 class XbFrameId
    00032 {
    00033 public:
    00034     XbFrameId(quint8 frameId = 0) { mFrameId = frameId; };
    00035
    00036     quint8 frameId() { return mFrameId; };
    00037     void setFrameId(quint8 frameId) { mFrameId = frameId; };
    00038
    00039 protected:
    00040     quint8 mFrameId;
    00041     XbStreamItem *newFrameIdItem() { return new XbUint8Item(mFrameId); };
    00042 };
    00043 // -----------------------------------------------------------------------------
    00044
    00049 class XbAddr64
    00050 {
    00051 public:
    00052     XbAddr64(quint64 addr64 = 0) { mAddr64 = addr64; };
    00053
    00054     quint64 addr64() { return mAddr64; };
    00055     void setAddr64(quint64 addr64) { mAddr64 = addr64; };
    00056
    00057 protected:
    00058     quint64 mAddr64;
    00059     XbStreamItem *newAddr64Item() { return new XbUint64Item(mAddr64); };
    00060 };
    00061 // -----------------------------------------------------------------------------
    00062
    00067 class XbAddr16
    00068 {
    00069 public:
    00070     XbAddr16(quint16 addr16 = 0xFFFE) { mAddr16 = addr16; };
    00071
    00072     quint16 addr16() { return mAddr16; };
    00073     void setAddr16(quint16 addr16) { mAddr16 = addr16; };
    00074
    00075 protected:
    00076     quint16 mAddr16;
    00077     XbStreamItem *newAddr16Item() { return new XbUint16Item(mAddr16); };
    00078 };
    00079 // -----------------------------------------------------------------------------
    00080
    00085 class XbAddress : public XbAddr64, XbAddr16
    00086 {
    00087 public:
    00088     XbAddress(quint64 addr64 = 0, quint16 addr16 = 0xFFFE) : XbAddr64(addr64), XbAddr16(addr16) {};
    00089
    00090     XbStreamItem *newAddressItem() { return new XbAddressItem(mAddr64, mAddr16); };
    00091 };
    00092
    00093 // -----------------------------------------------------------------------------
    00094
    00099 class XbCommand
    00100 {
    00101 public:
    00102     XbCommand();
    00103
    00104     QByteArray command();
    00105     void setCommand(QByteArray command);
    00106     void setCommand(QByteArray command, quint8 param);
    00107     void setCommand(QByteArray command, XbStreamItem *param);
    00108
    00109     XbStreamItem *cmdParam() { return mCmdParam; };
    00110
    00111 protected:
    00112     quint8  mCommand[2];
    00113     XbStreamItem *mCmdParam;
    00114
    00115     void updateParamType();
    00116
    00117     XbStreamItem *newCommandItem() { return new XbAtCommandItem(*this); };
    00118     XbStreamItem *newCmdParamItem() { return new XbVariantItem(&mCmdParam); };
    00119
    00120     friend class XbAtCommandItem;
    00121 };
    00122 // -----------------------------------------------------------------------------
    00123
    00128 class XbCmdStatus
    00129 {
    00130 public:
    00131     XbCmdStatus(quint8 status = 0) { mCmdStatus = status; };
    00132
    00133     quint8 cmdStatus() { return mCmdStatus; };
    00134
    00135 protected:
    00136     quint8 mCmdStatus;
    00137     XbStreamItem *newCmdStatusItem() { return new XbUint8Item(mCmdStatus); };
    00138 };
    00139 // -----------------------------------------------------------------------------
    00140
    00145 class XbOptions
    00146 {
    00147 public:
    00148     XbOptions(quint8 options = 0) { mOptions = options; };
    00149
    00150     quint8 options() { return mOptions; };
    00151     void setOptions(quint8 options) { mOptions = options; };
    00152
    00153 protected:
    00154     quint8 mOptions;
    00155     XbStreamItem *newOptionsItem() { return new XbUint8Item(mOptions); };
    00156 };
    00157 // -----------------------------------------------------------------------------
    00158
    00163 class XbBcRadius
    00164 {
    00165 public:
    00166     XbBcRadius(quint8 radius = 0) { mBcRadius = radius; };
    00167
    00168     quint8 broadcastRadius() { return mBcRadius; };
    00169     void setBroadcastRadius(quint8 radius) { mBcRadius = radius; };
    00170
    00171 protected:
    00172     quint8 mBcRadius;
    00173     XbStreamItem *newBcRadiusItem() { return new XbUint8Item(mBcRadius); };
    00174 };
    00175 // -----------------------------------------------------------------------------
    00176
    00181 class XbRfData
    00182 {
    00183 public:
    00184     XbRfData(QByteArray rfData = "") { mRfData = rfData; };
    00185
    00186     QByteArray rfData() { return mRfData; };
    00187     void setRfData(QByteArray rfData) { mRfData = rfData; };
    00188
    00189 protected:
    00190     QByteArray mRfData;
    00191     XbStreamItem *newRfDataItem() { return new XbByteArrayItem(mRfData); };
    00192 };
    00193 // -----------------------------------------------------------------------------
    00194
    00199 class XbTxRetryCnt
    00200 {
    00201 public:
    00202     XbTxRetryCnt() { mTxRetryCnt = 0; };
    00203
    00204     quint8 transmitRetryCount() { return mTxRetryCnt; };
    00205
    00206 protected:
    00207     quint8 mTxRetryCnt;
    00208     XbStreamItem *newTxRetryCntItem() { return new XbUint8Item(mTxRetryCnt); };
    00209 };
    00210 // -----------------------------------------------------------------------------
    00211
    00216 class XbDeliveryStatus
    00217 {
    00218 public:
    00219     XbDeliveryStatus() { mDeliveryStatus = 0; };
    00220
    00221     quint8  deliveryStatus() { return mDeliveryStatus; };
    00222     QString deliveryStatusString();
    00223
    00224 protected:
    00225     quint8 mDeliveryStatus;
    00226     XbStreamItem *newDeliveryStatusItem() { return new XbUint8Item(mDeliveryStatus); };
    00227 };
    00228 // -----------------------------------------------------------------------------
    00229
    00234 class XbDiscoveryStatus
    00235 {
    00236 public:
    00237     XbDiscoveryStatus() { mDiscoveryStatus = 0; };
    00238
    00239     quint8 discoveryStatus() { return mDiscoveryStatus; };
    00240
    00241 protected:
    00242     quint8 mDiscoveryStatus;
    00243     XbStreamItem *newDiscoveryStatusItem() { return new XbUint8Item(mDiscoveryStatus); };
    00244 };
    00245 // -----------------------------------------------------------------------------
    00246
    00251 class XbSamplesCnt
    00252 {
    00253 public:
    00254     XbSamplesCnt() { mSamplesCnt = 0; };
    00255
    00256     quint8 samplesCnt() { return mSamplesCnt; };
    00257
    00258 protected:
    00259     quint8 mSamplesCnt;
    00260     XbStreamItem *newSamplesCntItem() { return new XbUint8Item(mSamplesCnt); };
    00261 };
    00262 // -----------------------------------------------------------------------------
    00263
    00268 class XbUint8Block : public XbStreamItem
    00269 {
    00270 public:
    00271     XbUint8Block(quint8 value = 0);
    00272
    00273     quint8 value() { return mValue; };
    00274     void setValue(quint8 value) { mValue = value; };
    00275
    00276     virtual void wr(QDataStream &stream) { stream << mValue; };
    00277     virtual void rd(QDataStream &stream) { stream >> mValue; };
    00278
    00279 private:
    00280     quint8 mValue;
    00281 };
    00282 // -----------------------------------------------------------------------------
    00283
    00288 class XbUint16Block : public XbStreamItem
    00289 {
    00290 public:
    00291     XbUint16Block(quint16 value = 0);
    00292
    00293     quint16 value() { return mValue; };
    00294     void setValue(quint16 value) { mValue = value; };
    00295
    00296     virtual void wr(QDataStream &stream) { stream << mValue; };
    00297     virtual void rd(QDataStream &stream) { stream >> mValue; };
    00298
    00299 private:
    00300     quint16 mValue;
    00301 };
    00302 // -----------------------------------------------------------------------------
    00303
    00308 class XbIoSamplesBlock : public XbStreamItemList
    00309 {
    00310 public:
    00311     XbIoSamplesBlock();
    00312
    00313     quint8 samplesCnt() { return mSamplesCnt; };
    00314
    00315     quint16 digitalMask() { return mDigitalMask; };
    00316     quint8 analogMask() { return mAnalogMask; };
    00317
    00318     quint16 digitalSample() { return mDigitalSample; };
    00319     quint16 analogSample(quint8 input) { return mAnalogSamples.at(input); };
    00320
    00321 protected:
    00322     quint8  mSamplesCnt;
    00323     quint16 mDigitalMask, mDigitalSample;
    00324     quint8  mAnalogMask;
    00325     QList<quint16> mAnalogSamples;
    00326
    00327     friend class XbIoSamplesItem;
    00328 };
    00329 // -----------------------------------------------------------------------------
    00330
    00335 class XbIoSamples
    00336 {
    00337 public:
    00338     XbIoSamples() {};
    00339
    00340     XbIoSamplesBlock *ioSamples() { return &mIoSamplesBlock; };
    00341
    00342 protected:
    00343     XbIoSamplesBlock mIoSamplesBlock;
    00344
    00345     XbStreamItem *newIoSamplesItem() { return new XbIoSamplesItem(mIoSamplesBlock); };
    00346 };
    00347 // -----------------------------------------------------------------------------
    00348
    00349 #endif // XBITEMS_H

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends