#ifndef EXPERTWIN_H
#define EXPERTWIN_H

#include "basewin.h"
#define HAVE_REMOTE
#include "pcap.h"
#include <QThread>
#include <QLabel>
#include <QSpinBox>
#include <QComboBox>
#include <QJsonObject>

class ReceThread : public QThread {
    Q_OBJECT
public:
    explicit ReceThread(pcap *pcap);
    ~ReceThread() {
        pcap_close(pcap);
    }
    pcap *pcap;
    std::atomic<char> status{0};
    bool showImg{true};
protected:
    void run();
signals:
    void onMsg(QByteArray);
    void onErr(char *);
};

class ExpertWin : public BaseWin {
    Q_OBJECT
public:
    explicit ExpertWin(QWidget *parent = nullptr);

    QByteArray savedData();
    void addMapData(QByteArray &);

    int screenWidth{1280}, screenHeight{720};
    double rate{1};

    QLabel *fdModuleWidth, *fdModuleHeight, *fdGroupNum, *fdScanNum;
    QLabel *fdChipType, *fdDecodeMode;
    QJsonObject mModule {
        {"ModuleWidth", 16},
        {"ModuleHeight", 8},
        {"GroupNum", 2},
        {"ScanNum", 4},
        {"ChipType", "通用"},
        {"DecodeMode", "138译码"},
        {"GroupMode", "三线并行"}
    };
    QJsonObject mBox {
        {"ModuleRow", 1},
        {"ModuleCol", 1},
        {"Direction", 1},
        {"SectorCount", 1}
    };

    QSpinBox *fdCardWidth, *fdCardHeight;
    QComboBox *fdDirection, *fdSectorCount;
protected:
    void closeEvent(QCloseEvent *) override;
};

#endif // EXPERTWIN_H
