Newer
Older
ZXSSCJ / CounterAcqBM / protocol / dto / CounterDataDto.cpp
#include "CounterDataDto.h"
#include "common/utils/SettingConfig.h"

CounterDataDto::CounterDataDto(QObject *parent) : QObject(parent)
{

}

QJsonObject CounterDataDto::toJSON()
{
    QJsonObject jsonObj;

    QJsonObject dataObj;
    dataObj.insert("channelRefNo", this->channelRefId);
    dataObj.insert("dataValue", QString("%1").arg(this->channelClockValueStr));
    dataObj.insert("rawValue", QString("%1").arg(this->channelData));
    dataObj.insert("frameId", this->frameId);

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

    return jsonObj;
}

QJsonObject CounterDataDto::toJSON(int i)
{
    QJsonObject jsonObj;

    QJsonObject dataObj;
    dataObj.insert("channelRefNo", this->channelRefId);
    dataObj.insert("dataValue", QString("%1").arg(this->channelDataArray.at(i)));
    dataObj.insert("rawValue", QString("%1").arg(this->channelDataArray.at(i)));
    dataObj.insert("frameId", this->frameId);

    jsonObj.insert("channelNo", (i + 1));
    jsonObj.insert("ts", this->milisecond);
    jsonObj.insert("data", dataObj);

    return jsonObj;
}

void CounterDataDto::clone(CounterDataDto *copy)
{
    copy->frameId = this->frameId;
    copy->level = this->level;
    copy->load = this->load;
    copy->channelData = this->channelData;
    copy->channelRefId = this->channelRefId;
    copy->channelActive = this->channelActive;
    copy->channelId = channelId;
    copy->type = 0;

    copy->channelClockValue = this->channelClockValue;
    copy->channelClockValueStr = this->channelClockValueStr;

    copy->rawFrame = this->rawFrame;

    copy->timestamp = this->timestamp;
    copy->milisecond = this->milisecond;
    copy->devCode = this->devCode;
    copy->devStatus = this->devStatus;
}