2 ******************************************************************************
4 * @file oplinkwatchdog.cpp
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
8 * @addtogroup OPLinkWatchdog
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "oplinkwatchdog.h"
29 #include "extensionsystem/pluginmanager.h"
30 #include "uavobjects/uavobjectmanager.h"
31 #include "oplinkstatus.h"
34 OPLinkWatchdog::OPLinkWatchdog() : QObject(),
37 ExtensionSystem::PluginManager
*pm
= ExtensionSystem::PluginManager::instance();
40 UAVObjectManager
*objManager
= pm
->getObject
<UAVObjectManager
>();
42 m_opLinkStatus
= OPLinkStatus::GetInstance(objManager
);
43 Q_ASSERT(m_opLinkStatus
);
44 connect(m_opLinkStatus
, SIGNAL(objectUpdated(UAVObject
*)), this, SLOT(onOPLinkStatusUpdate()));
45 m_watchdog
= new QTimer(this);
46 connect(m_watchdog
, SIGNAL(timeout()), this, SLOT(onTimeout()));
47 onOPLinkStatusUpdate();
50 OPLinkWatchdog::~OPLinkWatchdog()
53 void OPLinkWatchdog::onOPLinkStatusUpdate()
56 quint8 type
= m_opLinkStatus
->getBoardType();
60 m_opLinkType
= OPLINK_MINI
;
63 emit
opLinkMiniConnected();
66 m_opLinkType
= OPLINK_REVOLUTION
;
69 emit
opLinkRevolutionConnected();
72 m_isConnected
= false;
73 m_opLinkType
= OPLINK_UNKNOWN
;
77 qDebug() << "OPLinkWatchdog - OPLink connected";
79 m_watchdog
->start(m_opLinkStatus
->getMetadata().flightTelemetryUpdatePeriod
* 3);
82 void OPLinkWatchdog::onTimeout()
85 m_isConnected
= false;
86 m_opLinkType
= OPLINK_UNKNOWN
;
87 qDebug() << "OPLinkWatchdog - OPLink disconnected";