#ifndef FINGER_H
#define FINGER_H

#include <QObject>
#include <QThread>
#include "libs/include/libzkfp.h"
#include "libs/include/libzkfperrdef.h"
#include "libs/include/libzkfptype.h"

enum class fingerWorkStat {
    init,
    opendev,
    adcquireFingerprint,
    sleep,
};


class finger : public QThread
{
    Q_OBJECT

public slots:
    void slot_set_thread_stop(void);
    void slot_fingerWork(bool stat);

signals:
    void signal_fingerStat(bool stat, QByteArray img, int size);

public:
    explicit finger(QObject *parent = nullptr);

private:
    bool threadstatus = true;
    fingerWorkStat workstat = fingerWorkStat::init;
    bool fingerInit = false;
    HANDLE fingerHandle = 0;
    int m_nFakeFunOn = 1;
    int m_imgFPWidth = 300;
    int m_imgFPHeight = 400;
    int m_impDpi = 0;
    unsigned char *m_pImgBuf;
    QByteArray m_pBmpBuf;
    int m_pBmpSize = 0;
    unsigned char szFinger[MAX_TEMPLATE_SIZE];
    unsigned int szFingerLen = MAX_TEMPLATE_SIZE;
    bool finger_workStat = false;

    void finger_toImage(unsigned char *data);
    void finger_init(void);
    void finger_opendev(void);
    // void finger_dbinit(void);
    // void finger_dbmerge(void);
    // void finger_dbadd(void);
    // void finger_dbmatch(void);
    void finger_acquirefingerprint(void);
    // void finger_dbidentify(void);

protected:
    void run() override;

};

#endif // FINGER_H
