#ifndef PHASEWINDOW_H
#define PHASEWINDOW_H

#include <QWidget>
#include <QMessageBox>
#include <QSystemTrayIcon>
#include <QStandardItemModel>
#include <QVBoxLayout>

#include "PhaseDevice.h"
#include "common/utils/SettingConfig.h"
#include "common/utils/QKafkaConsumer.h"
#include "common/HttpRequestController.h"
#include "common/HttpServer.h"

namespace Ui {
class PhaseWindow;
}

class PhaseWindow : public QWidget
{
    Q_OBJECT

public:
    explicit PhaseWindow(QWidget *parent = nullptr);
    ~PhaseWindow();

public slots:
    void drawPhaseDataOnPage(PhaseDataDto * phaseData);
    void drawPhaseAllenOnPage(QString devCode, QVector<QStringList> channelAllenResultStr);

private slots:
    void on_minButt_clicked();
    void on_startButt_clicked();
    void on_endButt_clicked();
    void onTrayIconActived(QSystemTrayIcon::ActivationReason reason);

    void on_devSelect_currentIndexChanged(int index);

    void onPhaseCommandReceived(QJsonObject command);
    void onPhaseMaserHeartHandle();

private:
    int initHttpToken();
    void initDeviceList();
    void getChannelList(QString deviceId);

    Ui::PhaseWindow *ui;

    QSystemTrayIcon * trayIcon;

    QKafkaConsumer * kafkaConsumer;
    HttpRequestController * httpReq;

    QTimer * heartTimer;

    QList<PhaseDevice *> deviceList;

    void generateWidgetForDevice();
};

#endif // PHASEWINDOW_H
