2020-06-01 03:39:08 +00:00
|
|
|
#ifndef TIMER_H
|
|
|
|
#define TIMER_H
|
|
|
|
|
2020-06-06 03:06:28 +00:00
|
|
|
#include <atomic>
|
2020-06-07 04:31:46 +00:00
|
|
|
|
2020-06-01 03:39:08 +00:00
|
|
|
#include <QObject>
|
2020-06-07 04:31:46 +00:00
|
|
|
#include <QThread>
|
|
|
|
#include <QTimer>
|
2020-06-01 03:39:08 +00:00
|
|
|
|
2020-06-03 04:21:37 +00:00
|
|
|
#include "../../Machines/Utility/MachineForTarget.hpp"
|
2020-06-15 03:22:00 +00:00
|
|
|
#include "functionthread.h"
|
2020-06-03 04:21:37 +00:00
|
|
|
|
2020-06-01 03:39:08 +00:00
|
|
|
class Timer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit Timer(QObject *parent = nullptr);
|
2020-06-07 04:31:46 +00:00
|
|
|
~Timer();
|
|
|
|
|
2020-06-15 03:22:00 +00:00
|
|
|
void startWithMachine(MachineTypes::TimedMachine *machine, std::mutex *machineMutex);
|
2020-06-01 03:39:08 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void tick();
|
2020-06-03 04:21:37 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
MachineTypes::TimedMachine *machine = nullptr;
|
2020-06-06 03:06:28 +00:00
|
|
|
std::mutex *machineMutex = nullptr;
|
2020-06-03 04:21:37 +00:00
|
|
|
int64_t lastTickNanos = 0;
|
2020-06-15 03:22:00 +00:00
|
|
|
FunctionThread thread;
|
2020-06-07 04:31:46 +00:00
|
|
|
std::unique_ptr<QTimer> timer;
|
2020-06-01 03:39:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TIMER_H
|