/**
  ******************************************************************************
  * @file           : TimeWorker.h
  * @author         : xin
  * @brief          : None
  * @attention      : None
  * @date           : 2023/4/11
  ******************************************************************************
  */

//
// Created by xin on 2023/4/11.
//

#ifndef ASDRADSTATION_TIMEWORKER_H
#define ASDRADSTATION_TIMEWORKER_H
#include "QObject"
#include "QTimer"
#include "QTime"
#include <nlohmann/json.hpp>

using json = nlohmann::json;
typedef bool (*TaskToExec)();

class TimeWorker : public QObject {
    Q_OBJECT
public:
    TimeWorker();
    void SetTask(TaskToExec task);
    void SetIntervalTime(long time);
    void Start();
    void Stop();
    void SetWorkTime(QTime start,QTime end);
    void SetWorkTime(QString start,QString end);
    void ReadjsonConfig(QString path);
     void ReadConfig(json j);

private:

    QList<TaskToExec> m_TaskList;
    TaskToExec m_Task;
    bool isinit=false;
    bool m_isWork=false;
    long m_IntervalTime=60000; //ms
    QTimer *m_Timer;
    QTime m_StartTime;
    QTime m_EndTime;
public slots:
    void onTimerTrigger();


};


#endif //ASDRADSTATION_TIMEWORKER_H
