#ifndef PHASEDEVICE_H
#define PHASEDEVICE_H

#include <QObject>
#include "common/utils/QSerialPortUtil.h"
#include "common/utils/QLogUtil.h"
#include "common/utils/SettingConfig.h"
#include "common/utils/QKafkaUtil.h"
#include "protocol/PhaseProtocolBM.h"

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

    void initSerialPort();
    void startWork();
    void stopWork();

    void afterFramePhase(PhaseDataDto * phaseData);

    void setComName(QString comName);
    void setBaudRate(int baudRate);
    QString getDevCode();
    void setDevCode(QString devCode);
    void setDeviceId(QString deviceId);

    bool isSerialOpen();
private:
    QString deviceId;
    QString devCode;
    QString comName;
    int baudRate;

    QSerialPortUtil serialUtil;
    QKafkaUtil kafkaUtil;
    QByteArray dataBuff;

signals:
    void sendDataToDraw(PhaseDataDto * phaseData);

public slots:
    void dataReceivedHandler(QByteArray data);

};

#endif // PHASEDEVICE_H
