#ifndef PHASEPROTOCOLBM_H
#define PHASEPROTOCOLBM_H

#include <QObject>

#include "dto/PhaseDataDto.h"
#include "common/utils/QByteUtil.h"

static const QByteArray PHASE_FRAME_TAIL("\xEE\xEE\xEE\xEE", 4); // 帧尾

static const int PHASE_FRAME_ID_LENGTH = 4; // 帧头id计数器为4个字节
static const int PHASE_MESSURE_CHANNEL = 16;
static const int PHASE_MESSURE_SIZE = 8;
static const int PHASE_FRAM_LENGTH = PHASE_FRAME_ID_LENGTH + PHASE_FRAME_TAIL.size() +
        PHASE_MESSURE_CHANNEL * PHASE_MESSURE_SIZE;

static const qulonglong CALCULATE_OFFSET = 0X0080000000000000;
static const double CALCULATE_FACTOR = 1.6810E-15;

class PhaseProtocolBM : public QObject
{
public:
    explicit PhaseProtocolBM(QObject *parent = nullptr);
    ~PhaseProtocolBM();

    // 解析比相仪测量数据
    static bool parseMessureData(QByteArray rawData, PhaseDataDto * phaseData);

    static QString startMessure();
    static QString stopMessure();

    // 检测帧格式，帧头帧尾
    static bool checkFrame(QByteArray rawData);
};

#endif // PHASEROTOCOLBM_H
