Torc  0.1
torc1wireds18b20.h
Go to the documentation of this file.
1 #ifndef TORC1WIREDS18B20_H
2 #define TORC1WIREDS18B20_H
3 
4 // Qt
5 #include <QFile>
6 #include <QTimer>
7 
8 // Torc
9 #include "torcqthread.h"
10 #include "torctemperatureinput.h"
11 #include "torc1wirebus.h"
12 
13 #define DS18B20NAME QStringLiteral("ds18b20")
14 
15 class Torc1WireDS18B20;
16 
17 class Torc1WireReader final : public QObject
18 {
19  Q_OBJECT
20  public:
21  Torc1WireReader(const QString &DeviceName);
22  ~Torc1WireReader() = default;
23 
24  public slots:
25  void Read(void);
26 
27  signals:
28  void NewTemperature(double Value, double Valid);
29 
30  private:
31  Q_DISABLE_COPY(Torc1WireReader)
32  QTimer m_timer;
33  QFile m_file;
34 };
35 
36 class Torc1WireReadThread final : public TorcQThread
37 {
38  Q_OBJECT
39 
40  public:
41  Torc1WireReadThread(Torc1WireDS18B20 *Parent, const QString &DeviceName);
42  void Start(void) override;
43  void Finish(void) override;
44 
45  private:
46  Torc1WireDS18B20 *m_parent;
47  Torc1WireReader *m_reader;
48  QString m_deviceName;
49 
50  private:
51  Q_DISABLE_COPY(Torc1WireReadThread)
52 };
53 
55 {
56  Q_OBJECT
57 
58  public:
59  explicit Torc1WireDS18B20(const QVariantMap &Details);
61 
62  QStringList GetDescription (void) override;
63 
64  public slots:
65  void Read (double Value, bool Valid);
66 
67  private:
68  QString m_deviceId;
69  Torc1WireReadThread m_readThread;
70 };
71 
72 #endif // TORC1WIREDS18B20_H
void NewTemperature(double Value, double Valid)
A Torc specific wrapper around QThread.
Definition: torcqthread.h:7
Torc1WireReader(const QString &DeviceName)
~Torc1WireReader()=default