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



CChaletMainStatus::CChaletMainStatus()
{
    mInverterRelayStatus = CHALET_POWER_RELAY_UNKNOWN_STATE;
    mWiFiModuleStatus = WIFI_UNKNOWN_STATE;
    mCurrentSensorStatus = CHALET_CURRENT_SENSOR_UNKNOWN_STATE;
    mBatteryCurrent = 0;
    mBatteryVoltage = 0;
    mIsOnline = false;
    mLostRequestPercentage = 0;
    mChaletTemperature = -100;

}

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

    Strm >> *this;
    /*

    Strm >> mInverterRelayStatus;
    Strm >> mWiFiModuleStatus;
    Strm >> mBatteryVoltage;
    Strm >> mBatteryCurrent;
    Strm >> mBatterySOC;
    Strm >> mIsOnline;
    Strm >> mCurrentSensorStatus;
    Strm >> mLostRequestPercentage;*/

    return RET_OK;
}
QDataStream &operator>>(QDataStream &in, CChaletMainStatus &dest)
{
    in  >> dest.mInverterRelayStatus
        >> dest.mWiFiModuleStatus
        >> dest.mBatteryVoltage
        >> dest.mBatteryCurrent
        >> dest.mBatterySOC
        >> dest.mIsOnline
        >> dest.mCurrentSensorStatus
        >> dest.mLostRequestPercentage
        >> dest.mThisStatusDateTime
        >> dest.mLastLoraStatus
        >> dest.mStatusToggleBit
        >> dest.mChaletTemperature
        >> dest.mTotalNbChaletRxCmds
        >> dest.mTotalMasterTxCmds
        >> dest.mMasterLostRequestCount;

    return in;
}
//QByteArray CChaletMainStatus::ToByteArray()
//{
//    QByteArray Data;
//    Data.resize(10);

//    Data.append(mInverterRelayStatus);
//    Data.append(mWiFiModuleStatus);

//    return Data;
//}
