#ifndef INTERACTIVECORE_H
#define INTERACTIVECORE_H

#include <QObject>
#include <QVariant>
#include <QTimerEvent>
#include "template_singleton.h"
#include "InteractiveTask.h"

#define TIMER_DATA_CHCHE_REFRESH 1000 * 10  // 定时刷新数据缓存，间隔10秒

class InteractiveCore : public QObject
{
    SINGLETON_DEFINE(InteractiveCore)       // 定义为单例类
    Q_OBJECT
private:
    explicit InteractiveCore(QObject *parent = nullptr);

public:
    Q_INVOKABLE void appendTask(InteractiveTask::TaskType type, QVariant request, QJSValue callback);

public slots:
    void slot_completed(InteractiveTask *task);
    void slot_failstart(InteractiveTask *task);

    // 临时槽函数，实现原有开关柜门功能
    // void slot_tid_update_Ex(quint16 count, QList<QString> tidList, const QVariant &user);

protected:
    void timerEvent(QTimerEvent *event);

private:

    int m_timerDataChcheRefresh;
};

#endif // INTERACTIVECORE_H
