Robin Thoni пре 8 година
комит
6bfaa301bf

+ 34
- 0
.gitignore Прегледај датотеку

@@ -0,0 +1,34 @@
1
+# C++ objects and libs
2
+
3
+*.slo
4
+*.lo
5
+*.o
6
+*.a
7
+*.la
8
+*.lai
9
+*.so
10
+*.dll
11
+*.dylib
12
+
13
+# Qt-es
14
+
15
+/.qmake.cache
16
+/.qmake.stash
17
+*.pro.user
18
+*.pro.user.*
19
+*.qbs.user
20
+*.qbs.user.*
21
+*.moc
22
+moc_*.cpp
23
+qrc_*.cpp
24
+ui_*.h
25
+Makefile*
26
+*-build-*
27
+
28
+# QtCreator
29
+
30
+*.autosave
31
+
32
+#QtCtreator Qml
33
+*.qmlproject.user
34
+*.qmlproject.user.*

+ 7
- 0
gpioanalyser.pro Прегледај датотеку

@@ -0,0 +1,7 @@
1
+TEMPLATE = subdirs
2
+
3
+SUBDIRS += \
4
+    viewer
5
+!android {
6
+    SUBDIRS += server
7
+}

+ 22
- 0
server/gpiomanager.cpp Прегледај датотеку

@@ -0,0 +1,22 @@
1
+#include "gpiomanager.h"
2
+#include <wiringPi.h>
3
+
4
+GpioManager::GpioManager(QObject *parent) : InputManager(parent)
5
+{
6
+}
7
+
8
+bool GpioManager::init(const QVariant &pins)
9
+{
10
+    if (!wiringPiSetupPhys())
11
+        return false;
12
+    auto list = pins.toList();
13
+    foreach (auto pin, list)
14
+        pinMode(pin.toInt(), INPUT);
15
+    return true;
16
+}
17
+
18
+QVariant GpioManager::read(const QVariant &pin)
19
+{
20
+    return digitalRead(pin.toInt());
21
+}
22
+

+ 17
- 0
server/gpiomanager.h Прегледај датотеку

@@ -0,0 +1,17 @@
1
+#ifndef GPIOMANAGER_H
2
+#define GPIOMANAGER_H
3
+
4
+#include "inputmanager.h"
5
+
6
+class GpioManager : public InputManager
7
+{
8
+public:
9
+    GpioManager(QObject* parent = 0);
10
+
11
+public slots:
12
+    bool init(const QVariant &pins) override;
13
+
14
+    QVariant read(const QVariant &pin) override;
15
+};
16
+
17
+#endif // GPIOMANAGER_H

+ 10
- 0
server/inputmanager.cpp Прегледај датотеку

@@ -0,0 +1,10 @@
1
+#include "inputmanager.h"
2
+
3
+InputManager::InputManager(QObject *parent) : QObject(parent)
4
+{
5
+}
6
+
7
+InputManager::~InputManager()
8
+{
9
+}
10
+

+ 20
- 0
server/inputmanager.h Прегледај датотеку

@@ -0,0 +1,20 @@
1
+#ifndef INPUTMANAGER_H
2
+#define INPUTMANAGER_H
3
+
4
+#include <QObject>
5
+#include <QVariant>
6
+
7
+class InputManager : public QObject
8
+{
9
+    Q_OBJECT
10
+public:
11
+    InputManager(QObject* parent = 0);
12
+    virtual ~InputManager();
13
+
14
+public slots:
15
+    virtual bool init(const QVariant& device) = 0;
16
+
17
+    virtual QVariant read(const QVariant& channel) = 0;
18
+};
19
+
20
+#endif // INPUTMANAGER_H

+ 12
- 0
server/main.cpp Прегледај датотеку

@@ -0,0 +1,12 @@
1
+#include <QCoreApplication>
2
+#include "mainclass.h"
3
+
4
+int main(int argc, char *argv[])
5
+{
6
+    QCoreApplication a(argc, argv);
7
+
8
+    MainClass m;
9
+    m.main();
10
+
11
+    return a.exec();
12
+}

+ 11
- 0
server/mainclass.cpp Прегледај датотеку

@@ -0,0 +1,11 @@
1
+#include "mainclass.h"
2
+
3
+MainClass::MainClass(QObject *parent) : QObject(parent)
4
+{
5
+
6
+}
7
+
8
+void MainClass::main()
9
+{
10
+
11
+}

+ 18
- 0
server/mainclass.h Прегледај датотеку

@@ -0,0 +1,18 @@
1
+#ifndef MAINCLASS_H
2
+#define MAINCLASS_H
3
+
4
+#include <QObject>
5
+
6
+class MainClass : public QObject
7
+{
8
+    Q_OBJECT
9
+public:
10
+    explicit MainClass(QObject *parent = 0);
11
+
12
+signals:
13
+
14
+public slots:
15
+    void main();
16
+};
17
+
18
+#endif // MAINCLASS_H

+ 29
- 0
server/server.pro Прегледај датотеку

@@ -0,0 +1,29 @@
1
+#-------------------------------------------------
2
+#
3
+# Project created by QtCreator 2015-07-24T22:17:25
4
+#
5
+#-------------------------------------------------
6
+
7
+QT       += core network
8
+
9
+QT       -= gui
10
+
11
+LIBS += -lptsocket -lwiringPi
12
+
13
+TARGET = gpioanalyser-server
14
+CONFIG   += console
15
+CONFIG   -= app_bundle
16
+QMAKE_CXXFLAGS += -std=c++11
17
+
18
+TEMPLATE = app
19
+
20
+
21
+SOURCES += main.cpp \
22
+    mainclass.cpp \
23
+    inputmanager.cpp \
24
+    gpiomanager.cpp
25
+
26
+HEADERS += \
27
+    mainclass.h \
28
+    inputmanager.h \
29
+    gpiomanager.h

+ 11
- 0
viewer/main.cpp Прегледај датотеку

@@ -0,0 +1,11 @@
1
+#include "mainwindow.h"
2
+#include <QApplication>
3
+
4
+int main(int argc, char *argv[])
5
+{
6
+    QApplication a(argc, argv);
7
+    MainWindow w;
8
+    w.show();
9
+
10
+    return a.exec();
11
+}

+ 14
- 0
viewer/mainwindow.cpp Прегледај датотеку

@@ -0,0 +1,14 @@
1
+#include "mainwindow.h"
2
+#include "ui_mainwindow.h"
3
+
4
+MainWindow::MainWindow(QWidget *parent) :
5
+    QMainWindow(parent),
6
+    ui(new Ui::MainWindow)
7
+{
8
+    ui->setupUi(this);
9
+}
10
+
11
+MainWindow::~MainWindow()
12
+{
13
+    delete ui;
14
+}

+ 22
- 0
viewer/mainwindow.h Прегледај датотеку

@@ -0,0 +1,22 @@
1
+#ifndef MAINWINDOW_H
2
+#define MAINWINDOW_H
3
+
4
+#include <QMainWindow>
5
+
6
+namespace Ui {
7
+class MainWindow;
8
+}
9
+
10
+class MainWindow : public QMainWindow
11
+{
12
+    Q_OBJECT
13
+
14
+public:
15
+    explicit MainWindow(QWidget *parent = 0);
16
+    ~MainWindow();
17
+
18
+private:
19
+    Ui::MainWindow *ui;
20
+};
21
+
22
+#endif // MAINWINDOW_H

+ 21
- 0
viewer/mainwindow.ui Прегледај датотеку

@@ -0,0 +1,21 @@
1
+<ui version="4.0">
2
+ <class>MainWindow</class>
3
+ <widget class="QMainWindow" name="MainWindow" >
4
+  <property name="geometry" >
5
+   <rect>
6
+    <x>0</x>
7
+    <y>0</y>
8
+    <width>800</width>
9
+    <height>480</height>
10
+   </rect>
11
+  </property>
12
+  <property name="windowTitle" >
13
+   <string>MainWindow</string>
14
+  </property>
15
+  <widget class="QWidget" name="centralWidget" />
16
+ </widget>
17
+ <layoutDefault spacing="6" margin="11" />
18
+ <pixmapfunction></pixmapfunction>
19
+ <resources/>
20
+ <connections/>
21
+</ui>

+ 30
- 0
viewer/viewer.pro Прегледај датотеку

@@ -0,0 +1,30 @@
1
+#-------------------------------------------------
2
+#
3
+# Project created by QtCreator 2015-07-24T22:17:08
4
+#
5
+#-------------------------------------------------
6
+
7
+QT       += core gui network
8
+
9
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10
+
11
+TARGET = viewer
12
+TEMPLATE = app
13
+
14
+LIBS += -lptsocket
15
+
16
+SOURCES += main.cpp\
17
+        mainwindow.cpp
18
+
19
+HEADERS  += mainwindow.h
20
+
21
+FORMS    += mainwindow.ui
22
+
23
+CONFIG += mobility
24
+MOBILITY = 
25
+
26
+contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
27
+    ANDROID_EXTRA_LIBS = \
28
+        $$PWD/../../../tools/Android/android-ndk-r10e/platforms/android-9/arch-arm/usr/lib/libptsocket.so
29
+}
30
+

Loading…
Откажи
Сачувај