#include "IspindelData.h"


CIspindelData::CIspindelData()
{
    mIspindelID = mRSSI = mInterval = 0;
    mIspindelName = mTemperatureUnits = "";
    mAngle = mBattery = mGravity = mTemperature = 0.0;
    mSampleDateTime = QDateTime::currentDateTime();
}

QDataStream &operator<<(QDataStream &out, const CIspindelData &source)
{
    out << source.mAngle
        << source.mBattery
        << source.mGravity
        << source.mInterval
        << source.mIspindelID
        << source.mIspindelName
        << source.mRSSI
        << source.mTemperature
        << source.mTemperatureUnits
        << source.mSampleDateTime;

    return out;
}

QDataStream &operator>>(QDataStream &in, CIspindelData &dest)
{
    in >> dest.mAngle
       >> dest.mBattery
       >> dest.mGravity
       >> dest.mInterval
       >> dest.mIspindelID
       >> dest.mIspindelName
       >> dest.mRSSI
       >> dest.mTemperature
       >> dest.mTemperatureUnits
       >> dest.mSampleDateTime;

    return in;
}

QByteArray CIspindelData::ToByteArray()
{
    QByteArray Array;
    QDataStream Strm(&Array,QIODevice::WriteOnly | QIODevice::Unbuffered);

    Strm << *this;

    return Array;
}


