trikRuntime
controller.h
Go to the documentation of this file.
1 /* Copyright 2013 - 2015 Yurii Litvinov and CyberTech Labs Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
22 
23 #include "lazyMainWidget.h"
24 
25 namespace trikWiFi {
26 class TrikWiFi;
27 }
28 
29 namespace trikGui {
30 
31 class RunningWidget;
32 class AutoRunner;
33 
35 class Controller : public QObject
36 {
37  Q_OBJECT
38 
39 public:
40 
43  explicit Controller(const QString &configPath);
44 
45  ~Controller() override;
46 
48  void runFile(const QString &filePath);
49 
51  void runScript(const QString &script);
52 
55 
59 
61  trikWiFi::TrikWiFi &wiFi();
62 
64  void doCloseRunningWidget(MainWidget &widget);
65 
67  bool communicatorConnectionStatus();
68 
70  bool gamepadConnectionStatus() const;
71 
72 public slots:
74  void abortExecution();
75 
76 signals:
78  void showRunningWidget(const QString &fileName, int scriptId);
79 
81  void hideRunningWidget(int scriptId);
82 
84  void showError(const QString &error, int scriptId);
85 
87  void hideGraphicsWidget();
88 
90  void hideScriptWidgets();
91 
94  void brickStopped();
95 
97  void gamepadDisconnected();
98 
100  void gamepadConnected();
101 
103  void wiFiConnected();
104 
106  void wiFiDisconnected();
107 
110  void communicatorStatusChanged(bool status);
111 
113  void mailboxStatusChanged(bool connected);
114 
115 private slots:
116  void scriptExecutionCompleted(const QString &error, int scriptId);
117 
118  void scriptExecutionFromFileStarted(const QString &fileName, int scriptId);
119  void directScriptExecutionStarted(int scriptId);
120 
121  void updateCommunicatorStatus();
122 
123 private:
124  QScopedPointer<trikControl::BrickInterface> mBrick;
125  QScopedPointer<trikNetwork::MailboxInterface> mMailbox;
126  QScopedPointer<trikScriptRunner::TrikScriptRunner> mScriptRunner;
127  QScopedPointer<trikCommunicator::TrikCommunicator> mCommunicator;
128  QScopedPointer<trikTelemetry::TrikTelemetry> mTelemetry;
129  QScopedPointer<trikWiFi::TrikWiFi> mWiFi;
130  QScopedPointer<AutoRunner> mAutoRunner;
131 
132  QHash<int, RunningWidget *> mRunningWidgets; // Has ownership.
133 };
134 
135 }
Provides backend features like Qt Script runner for frontend.
Definition: controller.h:35
Abstract class for widgets which will be used for conversation with user.
Definition: mainWidget.h:28
Class for WiFi management.
Definition: trikWiFi.h:31
Definition: abstractIndicator.h:21
Definition: controller.h:25
Allows communication between robots.
Definition: mailboxInterface.h:31
script
Definition: system.py:83
Interface representing TRIK controller board and devices installed on it, also provides access to per...
Definition: brickInterface.h:46