Torc  0.1
torctimercontrol.h
Go to the documentation of this file.
1 #ifndef TORCTIMERCONTROL_H
2 #define TORCTIMERCONTROL_H
3 
4 // Qt
5 #include <QTime>
6 #include <QTimer>
7 
8 // Torc
9 #include "torccontrol.h"
10 
12 {
13  Q_OBJECT
14 
15  public:
16  enum TimerType
17  {
20  Minutely, // yes, small in time...
25  };
26 
28  static TorcTimerControl::TimerType StringToTimerType (const QString &Type);
29 
30  public:
31  TorcTimerControl(const QString &Type, const QVariantMap &Details);
33 
34  TorcControl::Type GetType (void) const override;
35  QStringList GetDescription (void) override;
36  bool Validate (void) override;
37  void Start (void) override;
38  bool AllowInputs (void) const override;
39  quint64 TimeSinceLastTransition (void);
41 
42  public slots:
43  void TimerTimeout (void);
44  bool event (QEvent *Event) override;
45 
46  private:
47  void GenerateTimings (void);
48  void CalculateOutput (void) override;
49  quint64 GetPeriodDuration(void) const;
50  quint64 MsecsSincePeriodStart (void);
51 
52  private:
53  TorcTimerControl::TimerType m_timerType;
54  int m_startDay;
55  quint64 m_startTime;
56  quint64 m_duration;
57  int m_durationDay;
58  int m_periodDay;
59  quint64 m_periodTime;
60  QTimer m_timer;
61  bool m_firstTrigger;
62  bool m_randomStart;
63  bool m_randomDuration;
64  quint64 m_lastElapsed;
65  bool m_newRandom;
66  bool m_active;
67  quint64 m_singleShotStartTime;
68 };
69 
70 #endif // TORCTIMERCONTROL_H
static QString TimerTypeToString(TorcTimerControl::TimerType Type)
static TorcTimerControl::TimerType StringToTimerType(const QString &Type)
bool AllowInputs(void) const override
Timers cannot have inputs.
bool Validate(void) override
TorcTimerControl::TimerType GetTimerType(void) const
quint64 TimeSinceLastTransition(void)
TorcTimerControl(const QString &Type, const QVariantMap &Details)
QStringList GetDescription(void) override
TorcControl::Type GetType(void) const override
void Start(void) override
Initialise the timer.
bool event(QEvent *Event) override