Browse Source

Fix issue with status update

TODO: it seems some weird issue in protobuf or GRPC.
Further investigation required.
Alexey Edelev 5 years ago
parent
commit
8e5b9f29ad
2 changed files with 21 additions and 8 deletions
  1. 15 6
      gui/main.qml
  2. 6 2
      gui/visualizermodel.cpp

+ 15 - 6
gui/main.qml

@@ -152,15 +152,24 @@ ApplicationWindow {
         }
     }
 
-    Button {
-        id: start
-        text: "Start"
+    Row {
         anchors.right: parent.right
         anchors.top: parent.top
         anchors.margins: 20
-        enabled: visualizerModel.networkState.state === NetworkState.Idle
-        onClicked: {
-            visualizerModel.start();
+        spacing: 10
+        Text {
+            color: "#ffffff"
+            text: "Active state: " + visualizerModel.networkState.state
+        }
+
+        Button {
+            id: start
+            text: "Start"
+
+            enabled: visualizerModel.networkState.state === NetworkState.Idle
+            onClicked: {
+                visualizerModel.start();
+            }
         }
     }
 }

+ 6 - 2
gui/visualizermodel.cpp

@@ -36,7 +36,7 @@ using namespace QtProtobuf;
 
 VisualizerModel::VisualizerModel(std::shared_ptr<RemoteControlClient> &client, QObject *parent) : QObject(parent)
   , m_client(client)
-  , m_networkState(new NetworkState)
+  , m_networkState(new NetworkState{NetworkState::None})
 {
     m_client->getConfiguration({}, this, [this](QGrpcAsyncReply *reply) {
         qDeleteAll(m_layers);
@@ -84,9 +84,13 @@ VisualizerModel::VisualizerModel(std::shared_ptr<RemoteControlClient> &client, Q
         layer->m_weights.updateValues(Dense(weights.matrix().matrix()));
         layer->m_weightTrigger.updateLayer();
     });
+
+    QObject::connect(client.get(), &remotecontrol::RemoteControlClient::StateUpdated, [this](const remotecontrol::NetworkState &state) {
+        m_networkState->setState(state.state());
+    });
     client->subscribeActivationsUpdates({});
     client->subscribeWeightsUpdates({});
-    client->subscribeStateUpdates({}, m_networkState);
+    client->subscribeStateUpdates({});
 }
 
 ValueIndicator *VisualizerModel::activation(int layer, int row)