#ifndef __MAINWINDOW_H__
#define __MAINWINDOW_H__

#include <QMainWindow>
#include <QStackedWidget>
#include <QTimer>
#include <QLabel>

#include "broadcast.h"

#define MAX_CANVAS_COUNT 12

class MainWindow : public QMainWindow
{
    Q_OBJECT

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

protected:
    void init_ui();
    bool reload();
    void clear();
    void setCurrentCanvas(bool isNewComfigure = false);

private:
    QStackedWidget *m_pStackedWidget;
    QTimer m_timer;     // 数据中断检测定时器
    QTimer m_updateScreenTimer;     // 更新画面显示定时器
    int m_frequency;                // 更新频率
    QLabel *m_pErrStrLabel;
    Broadcast m_broadcast;
    QTimer m_reportTimer;
    QString m_packageCount;

public slots:
    void onUpdateScreen(const QJsonObject &obj);
    void onPageSwitdh(int state);
    void onConfigureUpdate(const QString &filename);
    void onReloadCanvas();

private slots:
    void onReport();
    
};

#endif // MAINWINDOW_H