#include "AvReceiverData.h"
#include <QDataStream>

CAvReceiverMainStatus::CAvReceiverMainStatus()
{
   mDataValid = false;
   mReceiverOnline = false;
}

QByteArray CAvReceiverMainStatus::ToByteArray()
{

    QByteArray Output;
    Output.clear();
    QDataStream Strm(&Output,QIODevice::WriteOnly);

    Strm << mMainPwrStatus;
    Strm <<  mMainSleepStatus;
    Strm <<  mMainVolume;
    Strm <<  mIsMute;
    Strm <<  mInput;
    Strm <<  mProgram;

    Strm <<  mDataValid;
    Strm <<  mReceiverOnline;

   return Output;

}

int CAvReceiverMainStatus::FromByteArray(QByteArray Data)
{
    QDataStream Strm(Data);
    Strm.device()->seek(0);

    Strm >> mMainPwrStatus;
    Strm >>  mMainSleepStatus;
    Strm >>  mMainVolume;
    Strm >>  mIsMute;
    Strm >>  mInput;
    Strm >>  mProgram;

    Strm >>  mDataValid;
    Strm >>  mReceiverOnline;

    return RET_OK;

}
QDataStream &operator<<(QDataStream &out, const CAvReceiverMainStatus &source)
{
    out << source.mMainPwrStatus
        << source.mMainSleepStatus
        << source.mMainVolume
        << source.mIsMute
        << source.mInput
        << source.mProgram
        << source.mDataValid
        << source.mReceiverOnline;

    return out;
}

QDataStream &operator>>(QDataStream &in, CAvReceiverMainStatus &dest)
{
    in >> dest.mMainPwrStatus
       >> dest.mMainSleepStatus
       >> dest.mMainVolume
       >> dest.mIsMute
       >> dest.mInput
       >> dest.mProgram
       >> dest.mDataValid
       >> dest.mReceiverOnline;
    return in;
}
