Browse Source

input abstract

old
Robin Thoni 9 years ago
parent
commit
88a00a429b
2 changed files with 49 additions and 0 deletions
  1. 23
    0
      server/inputbusiness.cpp
  2. 26
    0
      server/inputbusiness.h

+ 23
- 0
server/inputbusiness.cpp View File

@@ -0,0 +1,23 @@
1
+#include <time.h>
2
+#include "inputbusiness.h"
3
+
4
+InputBusiness::InputBusiness(InputManager *input, const QList<QVariant> &channels, ServerManager *server)
5
+    : m_input(input)
6
+    , m_channels(channels)
7
+    , m_server(server)
8
+{
9
+}
10
+
11
+InputBusiness::~InputBusiness()
12
+{
13
+}
14
+
15
+void InputBusiness::readAndSend()
16
+{
17
+    QList<QVariant> values;
18
+    quint64 timestamp = time(nullptr);
19
+    foreach (auto channel, m_channels)
20
+        values.append(m_input->read(channel));
21
+    m_server->sendData(values, timestamp);
22
+}
23
+

+ 26
- 0
server/inputbusiness.h View File

@@ -0,0 +1,26 @@
1
+#ifndef INPUTBUSINESS_H
2
+#define INPUTBUSINESS_H
3
+
4
+#include <QObject>
5
+#include "inputmanager.h"
6
+#include "servermanager.h"
7
+
8
+class InputBusiness : public QObject
9
+{
10
+    Q_OBJECT
11
+public:
12
+    InputBusiness(InputManager* input, const QList<QVariant>& channels, ServerManager* server);
13
+    virtual ~InputBusiness();
14
+
15
+public slots:
16
+    void readAndSend();
17
+
18
+private:
19
+    InputManager* m_input;
20
+
21
+    QList<QVariant> m_channels;
22
+
23
+    ServerManager* m_server;
24
+};
25
+
26
+#endif // INPUTBUSINESS_H

Loading…
Cancel
Save