#ifndef DEVICEBASE_H
#define DEVICEBASE_H

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

#include "protocol/dto/DeviceFrameBaseDto.h"
#include "protocol/DeviceStatusProtocolBase.h"

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

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

    void initSerialPort();
    bool isSerialOpen();
    virtual void sendDataToSerial(QByteArray data);
    virtual void afterFramePhase(DeviceFrameBaseDto * frameDto) = 0;

    DeviceStatusProtocolBase * protocol;

protected:
    QString deviceId;
    QString devCode;
    QString comName;
    int baudRate;

    QSerialPortUtil serialUtil;
    QKafkaUtil kafkaUtil;
    QByteArray dataBuff;
};

#endif // DEVICEBASE_H
