#ifndef DEVSTATUSWINDOW_H
#define DEVSTATUSWINDOW_H

#include <QWidget>

#include "device/SignalGenerator.h"
#include "device/FrequencyTuning.h"
#include "device/TimeSwitcher.h"
#include "device/FreqSwitcher.h"
#include "device/TimeReplicator.h"
#include "device/FreqReplicator.h"
#include "device/BCodeTerminal.h"
#include "common/HttpRequestController.h"
#include "common/utils/QKafkaConsumer.h"

QT_BEGIN_NAMESPACE
namespace Ui { class DevStatusWindow; }
QT_END_NAMESPACE

class DevStatusWindow : public QWidget
{
    Q_OBJECT

public:
    DevStatusWindow(QWidget *parent = nullptr);
    ~DevStatusWindow();

public slots:
    void drawFrameDataOnPage(DeviceFrameBaseDto * frameData);

    void devSettingCommandRecieved(QString commandJsonStr);

private slots:
    void on_devTypeSelect_currentIndexChanged(int index);

    void on_sigGenButt_clicked();
    void on_freqTunButt_clicked();
    void on_tmSwiButt_clicked();
    void on_freqSwiButt_clicked();
    void on_tmRepButt_clicked();
    void on_freqRepButt_clicked();
    void on_bctButt_clicked();

    void on_exitButt_clicked();
    void on_minButt_clicked();

    void on_ftSetFreqTurnButt_clicked();
    void on_ftSetPhaseTunnButt_clicked();
    void on_ftSetPhaseShiftButt_clicked();
    void on_ftSetSynchButt_clicked();
    void on_ftSetPulseWidthButt_clicked();

    void on_sgLeapSecondSetButt_clicked();
    void on_sgSingleSynchSetButt_clicked();
    void on_sgDateSetButt_clicked();
    void on_sgSecondWidthSetButt_clicked();
    void on_sgBacRatioSetButt_clicked();
    void on_sgBacRangeSetButt_clicked();
    void on_sgOppsPhaseShiftSetButt_clicked();
    void on_sgLeapTimestampSetButt_clicked();
    void on_sgMJDDateSetButt_clicked();
    void on_sgTimeSetButt_clicked();
    void on_sgKeyControlSetButt_clicked();
    void on_sgTimeTypeSetButt_clicked();

private:
    int initHttpToken();
    int initDictDeviceTypes();
    QJsonObject initDeviceList();

    Ui::DevStatusWindow *ui;

    HttpRequestController * httpReq;

    SignalGenerator * sigGenDevice;
    FrequencyTuning * freqTunDevice;
    TimeSwitcher * timeSwitDevice;
    FreqSwitcher * freqSwitDevice;
    TimeReplicator * timeRepDevice;
    FreqReplicator * freqRepDevice;
    BCodeTerminal * bCodeTermDevice;

    QKafkaConsumer * kafkaConsumer;
};
#endif // DEVSTATUSWINDOW_H
