#include "ckerf_base.h"

QDataStream &operator<<(QDataStream &out, const KERFPARAM &param)
{
    out<<param.iLineCount;
    out<<param.iPixelThres;
    out<<param.iLight1;
    out<<param.iLight2;
    out<<param.dRange;
    out<<param.dWidthMax;
    out<<param.dWidthMin;
    out<<param.dGAPMax;
    out<<param.dGAPMin;
    out<<param.dOffsetMax;
    out<<param.dOffsetMin;
    out<<param.dRangeMin;
    out<<param.ikerfPos;
    out<<param.iExposure;
    out<<param.iGain;
    out<<param.dSpecKerfPos;
    out<<param.iBinaryThres;
    return out;
}

QDataStream &operator>>(QDataStream &in, KERFPARAM &param)
{

    in>>param.iLineCount;
    in>>param.iPixelThres;
    in>>param.iLight1;
    in>>param.iLight2;
    in>>param.dRange;
    in>>param.dWidthMax;
    in>>param.dWidthMin;
    in>>param.dGAPMax;
    in>>param.dGAPMin;
    in>>param.dOffsetMax;
    in>>param.dOffsetMin;
    in>>param.dRangeMin;
    in>>param.ikerfPos;
    in>>param.iExposure;
    in>>param.iGain;
    in>>param.dSpecKerfPos;
    in>>param.iBinaryThres;

    return in;
}

ConfigStreamWriter &operator<<(ConfigStreamWriter &out, const KERFPARAM &param)
{
    out.writeStartElement("param");
    out << param.iLineCount;
    out << param.iPixelThres;
    out << param.iLight1;
    out << param.iLight2;
    out << param.dRange;
    out << param.dWidthMax;
    out << param.dWidthMin;
    out << param.dGAPMax;
    out << param.dGAPMin;
    out << param.dOffsetMax;
    out << param.dOffsetMin;
    out << param.dRangeMin;
    out << param.ikerfPos;
    out << param.iExposure;
    out << param.iGain;
    out << param.dSpecKerfPos;
    out << param.iBinaryThres;
    out.writeEndElement();
    return out;
}

ConfigStreamReader &operator >> (ConfigStreamReader &in, KERFPARAM &param)
{
    in.readNextStartElement();
    in >> param.iLineCount;
    in >> param.iPixelThres;
    in >> param.iLight1;
    in >> param.iLight2;
    in >> param.dRange;
    in >> param.dWidthMax;
    in >> param.dWidthMin;
    in >> param.dGAPMax;
    in >> param.dGAPMin;
    in >> param.dOffsetMax;
    in >> param.dOffsetMin;
    in >> param.dRangeMin;
    in >> param.ikerfPos;
    in >> param.iExposure;
    in >> param.iGain;
    in >> param.dSpecKerfPos;
    in >> param.iBinaryThres;
    in.skipCurrentElement();
    return in;
}

