#include "FreqSwitcherStatusDto.h"

FreqSwitcherStatusDto::FreqSwitcherStatusDto(QObject *parent) : DeviceFrameBaseDto(parent)
{

}

QJsonObject FreqSwitcherStatusDto::toJSON()
{
    QJsonObject jsonObj;

    QJsonObject dataObj;
    dataObj.insert("devStatus", devStatus);
    dataObj.insert("refSelectType", refSelectType);
    dataObj.insert("lockPhaseType", lockPhaseType);
    dataObj.insert("digitalLockPhaseStatus", digitalLockPhaseStatus);
    dataObj.insert("refFreqSrc", refFreqSrc);
    dataObj.insert("freqAdjustAcc", freqAdjustAcc);
    dataObj.insert("phaseAdjustAcc", phaseAdjustAcc);

    QJsonArray freqRefStatusArray;
    QJsonArray localFreqDiffArray;
    QJsonArray freqRefWeightArray;
    QJsonArray inputFreqTypeArray;
    QJsonArray outTenStatusArray;
    QJsonArray outFiveStatusArray;
    for (int i = 0; i < 5; i++)
    {
        freqRefStatusArray.append(freqRefStatusList.at(i));
        localFreqDiffArray.append(localFreqDiffList.at(i));
        freqRefWeightArray.append(freqRefWeightList.at(i));
        inputFreqTypeArray.append(inputFreqTypeList.at(i));
    }
    for (int i = 0; i < 6; i++)
    {
        outTenStatusArray.append(outTenStatusList.at(i));
        outFiveStatusArray.append(outFiveStatusList.at(i));
    }
    dataObj.insert("freqRefStatusArray", freqRefStatusArray);
    dataObj.insert("localFreqDiffArray", localFreqDiffArray);
    dataObj.insert("freqRefWeightArray", freqRefWeightArray);
    dataObj.insert("inputFreqTypeArray", inputFreqTypeArray);
    dataObj.insert("outTenStatusArray", outTenStatusArray);
    dataObj.insert("outFiveStatusArray", outFiveStatusArray);

    jsonObj.insert("ts", this->milisecond);
    jsonObj.insert("frameType", this->frameType);
    jsonObj.insert("data", dataObj);

    return jsonObj;
}
