Browse Source

Add initial gui implementation

- Only simple subscription implemented
Alexey Edelev 5 years ago
parent
commit
5b8a375c8e
5 changed files with 62 additions and 1 deletions
  1. 1 1
      .gitignore
  2. 3 0
      .gitmodules
  3. 20 0
      gui/CMakeLists.txt
  4. 37 0
      gui/main.cpp
  5. 1 0
      gui/qtprotobuf

+ 1 - 1
.gitignore

@@ -1,4 +1,4 @@
 src
 bin
 pkg
-
+CMakeLists.txt.user

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "gui/qtprotobuf"]
+	path = gui/qtprotobuf
+	url = git@git.semlanik.org:semlanik/qtprotobuf.git

+ 20 - 0
gui/CMakeLists.txt

@@ -0,0 +1,20 @@
+project(NeuralNetworkUi)
+
+cmake_minimum_required(VERSION 2.8)
+
+find_package(Qt5 COMPONENTS Quick Gui Core Qml REQUIRED)
+
+set(QTPROTOBUF_MAKE_TESTS false)
+set(QTPROTOBUF_MAKE_EXAMPLES false)
+add_subdirectory("qtprotobuf")
+find_package(QtProtobufProject CONFIG COMPONENTS QtProtobuf QtGrpc REQUIRED)
+if(Qt5_POSITION_INDEPENDENT_CODE)
+    set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
+endif()
+
+file(GLOB PROTO_FILES ABSOLUTE "${CMAKE_CURRENT_SOURCE_DIR}/../neuralnetwork/remotecontrol/remotecontrol.proto")
+
+generate_qtprotobuf(TARGET NeuralNetworkUi PROTO_FILES ${PROTO_FILES})
+
+add_executable(NeuralNetworkUi main.cpp)
+target_link_libraries(NeuralNetworkUi Qt5::Core Qt5::Gui Qt5::Qml Qt5::Quick QtProtobufProject::QtProtobuf QtProtobufProject::QtGrpc ${QtProtobuf_GENERATED})

+ 37 - 0
gui/main.cpp

@@ -0,0 +1,37 @@
+#include <QGuiApplication>
+#include <QQmlEngine>
+#include <QQuickView>
+#include <QDebug>
+
+#include "remotecontrolclient.h"
+#include "qgrpchttp2channel.h"
+#include "insecurecredentials.h"
+
+class NoneCredencials : public QtProtobuf::CallCredentials
+{
+public:
+    NoneCredencials() : QtProtobuf::CallCredentials(QtProtobuf::AbstractCredentials::CredentialMap{}) {}
+};
+
+
+int main(int argc, char *argv[])
+{
+    QGuiApplication app(argc, argv);
+
+    remotecontrol::RemoteControlClient client;
+    auto chan = std::shared_ptr<QtProtobuf::QGrpcHttp2Channel>(new QtProtobuf::QGrpcHttp2Channel(QUrl("http://localhost:65001"), QtProtobuf::InsecureCredentials()|NoneCredencials()));
+    client.attachChannel(chan);
+    QObject::connect(&client, &remotecontrol::RemoteControlClient::ActivationsUpdated, [](const remotecontrol::LayerMatrix &activations) {
+        qDebug() << "ActivationsUpdated:" << activations.layer();
+    });
+    QObject::connect(&client, &remotecontrol::RemoteControlClient::BiasesUpdated, [](const remotecontrol::LayerMatrix &biases) {
+        qDebug() << "BiasesUpdated:" << biases.layer();
+    });
+    QObject::connect(&client, &remotecontrol::RemoteControlClient::WeightsUpdated, [](const remotecontrol::LayerMatrix &weights) {
+        qDebug() << "WeightsUpdated:" << weights.layer();
+    });
+    client.subscribeActivationsUpdates({});
+    client.subscribeBiasesUpdates({});
+    client.subscribeWeightsUpdates({});
+    return app.exec();
+}

+ 1 - 0
gui/qtprotobuf

@@ -0,0 +1 @@
+Subproject commit 2545e7b9536e831b663468f02b74723176654a91