dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
telemetrymanager.cpp
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
28 #include "telemetrymanager.h"
30 #include <coreplugin/icore.h>
31 
33  : m_connected(false)
34 {
35  // Get UAVObjectManager instance
36  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
37  objMngr = pm->getObject<UAVObjectManager>();
38 
39  settings = pm->getObject<Core::Internal::GeneralSettings>();
40 }
41 
43 {
44 }
45 
46 void TelemetryManager::start(QIODevice *dev)
47 {
48  utalk = new UAVTalk(dev, objMngr);
49  telemetry = new Telemetry(utalk, objMngr);
50  telemetryMon = new TelemetryMonitor(objMngr, telemetry);
51  connect(telemetryMon, &TelemetryMonitor::connected, this, &TelemetryManager::onConnect);
52  connect(telemetryMon, &TelemetryMonitor::disconnected, this, &TelemetryManager::onDisconnect);
53 }
54 
56 {
57  telemetryMon->disconnect(this);
58  telemetryMon->deleteLater();
59  telemetryMon = NULL;
60  telemetry->deleteLater();
61  telemetry = NULL;
62  utalk->deleteLater();
63  utalk = NULL;
64  onDisconnect();
65 }
66 
67 void TelemetryManager::onConnect()
68 {
69  m_connected = true;
70  emit connected();
71  emit connectedChanged(m_connected);
72 }
73 
74 void TelemetryManager::onDisconnect()
75 {
76  m_connected = false;
77  emit disconnected();
78  emit connectedChanged(m_connected);
79 }
80 
81 QByteArray *TelemetryManager::downloadFile(quint32 fileId, quint32 maxSize,
82  std::function<void(quint32)>progressCb)
83 {
84  if (!telemetry) {
85  return NULL;
86  }
87 
88  return telemetry->downloadFile(fileId, maxSize, progressCb);
89 }
void connectedChanged(bool)
function[]
Core plugin system that manages the plugins, their life cycle and their registered objects...
Definition: pluginmanager.h:53
QByteArray * downloadFile(quint32 fileId, quint32 maxSize, std::function< void(quint32)>progressCb=nullptr)
Definition: telemetry.cpp:406
QByteArray * downloadFile(quint32 fileId, quint32 maxSize, std::function< void(quint32)>progressCb)
void start(QIODevice *dev)