mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
OP-89
hitlil2 compiles and succesfully connects to IL2 and OP :) git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@914 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
931857c98d
commit
a56a9346b4
@ -42,7 +42,7 @@ HITLIL2::~HITLIL2()
|
||||
void HITLIL2::loadConfiguration(IUAVGadgetConfiguration* config)
|
||||
{
|
||||
HITLIL2Configuration *m = qobject_cast<HITLIL2Configuration*>(config);
|
||||
m_widget->setIlHostName( m->il2HostName() );
|
||||
m_widget->setIl2HostName( m->il2HostName() );
|
||||
m_widget->setIl2Port( m->il2Port() );
|
||||
m_widget->setIl2ManualControl( m->il2ManualControl() );
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
HITLIL2Configuration::HITLIL2Configuration(QString classId, const QByteArray &state, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_fgPathBin(""), m_fgPathData(""), m_fgManualControl(false)
|
||||
m_il2HostName(""), m_il2Port(0), m_il2ManualControl(false)
|
||||
{
|
||||
if (state.count() > 0) {
|
||||
QDataStream stream(state);
|
||||
@ -42,7 +42,7 @@ HITLIL2Configuration::HITLIL2Configuration(QString classId, const QByteArray &st
|
||||
stream >> il2Port;
|
||||
m_il2Port = il2Port;
|
||||
stream >> il2ManualControl;
|
||||
m_il2ManualControl = fgManualControl;
|
||||
m_il2ManualControl = il2ManualControl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void setIl2HostName(QString HostName) { m_il2HostName = iHostName; }
|
||||
void setIl2HostName(QString HostName) { m_il2HostName = HostName; }
|
||||
void setIl2Port(int Port) { m_il2Port = Port; }
|
||||
void setIl2ManualControl(bool val) { m_il2ManualControl = val; }
|
||||
|
||||
|
@ -45,8 +45,8 @@ QWidget *HITLIL2OptionsPage::createPage(QWidget *parent)
|
||||
|
||||
|
||||
// Restore the contents from the settings:
|
||||
m_optionsPage->Il2Port->setValue(m_config->Il2Port());
|
||||
m_optionsPage->Il2HostName->setText(m_config->Il2HostName());
|
||||
m_optionsPage->Il2Port->setValue(m_config->il2Port());
|
||||
m_optionsPage->Il2HostName->setText(m_config->il2HostName());
|
||||
m_optionsPage->il2ManualControl->setChecked(m_config->il2ManualControl());
|
||||
|
||||
|
||||
|
@ -32,11 +32,12 @@
|
||||
|
||||
HITLIL2Widget::HITLIL2Widget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
il2Process = NULL;
|
||||
widget = new Ui_HITLIL2Widget();
|
||||
widget->setupUi(this);
|
||||
connect(widget->startButton, SIGNAL(clicked()), this, SLOT(startButtonClicked()));
|
||||
connect(widget->stopButton, SIGNAL(clicked()), this, SLOT(stopButtonClicked()));
|
||||
/* Note to myself: failure to initialize pointers can cause segfaults */
|
||||
il2Bridge=NULL;
|
||||
}
|
||||
|
||||
HITLIL2Widget::~HITLIL2Widget()
|
||||
@ -47,7 +48,7 @@ HITLIL2Widget::~HITLIL2Widget()
|
||||
void HITLIL2Widget::startButtonClicked()
|
||||
{
|
||||
// Stop running process if one is active
|
||||
if (il2Process != NULL)
|
||||
if (il2Bridge != NULL)
|
||||
{
|
||||
stopButtonClicked();
|
||||
}
|
||||
@ -57,11 +58,11 @@ void HITLIL2Widget::startButtonClicked()
|
||||
|
||||
// Start bridge
|
||||
qxtLog->info("HITLIL2: Starting bridge, initializing IL2 and Autopilot connections");
|
||||
il2Bridge = new IL2Bridge(il2HostName,il2Port);
|
||||
il2Bridge = new Il2Bridge(il2HostName,il2Port);
|
||||
connect(il2Bridge, SIGNAL(autopilotConnected()), this, SLOT(onAutopilotConnect()));
|
||||
connect(il2Bridge, SIGNAL(autopilotDisconnected()), this, SLOT(onAutopilotDisconnect()));
|
||||
connect(il2Bridge, SIGNAL(il2Connected()), this, SLOT(onFGConnect()));
|
||||
connect(il2Bridge, SIGNAL(il2Disconnected()), this, SLOT(onFGDisconnect()));
|
||||
connect(il2Bridge, SIGNAL(il2Connected()), this, SLOT(onIl2Connect()));
|
||||
connect(il2Bridge, SIGNAL(il2Disconnected()), this, SLOT(onIl2Disconnect()));
|
||||
|
||||
// Initialize connection status
|
||||
if ( il2Bridge->isAutopilotConnected() )
|
||||
@ -72,27 +73,23 @@ void HITLIL2Widget::startButtonClicked()
|
||||
{
|
||||
onAutopilotDisconnect();
|
||||
}
|
||||
if ( il2Bridge->isFGConnected() )
|
||||
if ( il2Bridge->isIl2Connected() )
|
||||
{
|
||||
onFGConnect();
|
||||
onIl2Connect();
|
||||
}
|
||||
else
|
||||
{
|
||||
onFGDisconnect();
|
||||
onIl2Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void HITLIL2Widget::stopButtonClicked()
|
||||
{
|
||||
// NOTE: Does not currently work, may need to send control+c to through the terminal
|
||||
if (il2Process != NULL)
|
||||
if (il2Bridge != NULL)
|
||||
{
|
||||
il2Process->disconnect(this);
|
||||
il2Process->kill();
|
||||
delete il2Process;
|
||||
il2Bridge->disconnect(this);
|
||||
delete il2Bridge;
|
||||
il2Process = NULL;
|
||||
il2Bridge = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,21 +103,11 @@ void HITLIL2Widget::setIl2Port(int il2Port)
|
||||
this->il2Port = il2Port;
|
||||
}
|
||||
|
||||
void HITLIL2Widget::setFGManualControl(bool val)
|
||||
void HITLIL2Widget::setIl2ManualControl(bool val)
|
||||
{
|
||||
this->il2ManualControl = val;
|
||||
}
|
||||
|
||||
void HITLIL2Widget::processReadyRead()
|
||||
{
|
||||
QByteArray bytes = il2Process->readAllStandardOutput();
|
||||
QString str(bytes);
|
||||
if ( !str.contains("Error reading data") ) // ignore error
|
||||
{
|
||||
widget->textBrowser->append(str);
|
||||
}
|
||||
}
|
||||
|
||||
void HITLIL2Widget::onAutopilotConnect()
|
||||
{
|
||||
QPalette pal(widget->apLabel->palette());
|
||||
@ -151,7 +138,7 @@ void HITLIL2Widget::onIl2Connect()
|
||||
qxtLog->info("HITL-IL2: IL2 connected");
|
||||
}
|
||||
|
||||
void HITLIL2Widget::onFGDisconnect()
|
||||
void HITLIL2Widget::onIl2Disconnect()
|
||||
{
|
||||
QPalette pal(widget->il2Label->palette());
|
||||
pal.setColor(QPalette::Window, Qt::red);
|
||||
|
@ -50,7 +50,6 @@ public slots:
|
||||
private slots:
|
||||
void startButtonClicked();
|
||||
void stopButtonClicked();
|
||||
void processReadyRead();
|
||||
void onAutopilotConnect();
|
||||
void onAutopilotDisconnect();
|
||||
void onIl2Connect();
|
||||
|
@ -124,7 +124,7 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="fgLabel">
|
||||
<widget class="QLabel" name="il2Label">
|
||||
<property name="text">
|
||||
<string>IL2 Disconnected</string>
|
||||
</property>
|
||||
|
@ -36,7 +36,7 @@ Il2Bridge::Il2Bridge(QString il2HostName, int il2Port)
|
||||
updatePeriod = 50;
|
||||
il2Timeout = 2000;
|
||||
autopilotConnectionStatus = false;
|
||||
fgConnectionStatus = false;
|
||||
il2ConnectionStatus = false;
|
||||
|
||||
// Get required UAVObjects
|
||||
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
|
||||
@ -74,8 +74,8 @@ Il2Bridge::Il2Bridge(QString il2HostName, int il2Port)
|
||||
// Setup FG connection timer
|
||||
il2Timer = new QTimer(this);
|
||||
connect(il2Timer, SIGNAL(timeout()), this, SLOT(onIl2ConnectionTimeout()));
|
||||
fgTimer->setInterval(fgTimeout);
|
||||
fgTimer->start();
|
||||
il2Timer->setInterval(il2Timeout);
|
||||
il2Timer->start();
|
||||
}
|
||||
|
||||
Il2Bridge::~Il2Bridge()
|
||||
@ -128,16 +128,18 @@ void Il2Bridge::receiveUpdate()
|
||||
il2ConnectionStatus = true;
|
||||
emit il2Connected();
|
||||
}
|
||||
|
||||
//QMessageBox msgBox;
|
||||
//msgBox.setText((const QString )"live!");
|
||||
//msgBox.exec();
|
||||
// Process data
|
||||
while ( outSocket->bytesAvailable() > 0 )
|
||||
{
|
||||
// Receive datagram
|
||||
QByteArray datagram;
|
||||
datagram.resize(inSocket->pendingDatagramSize());
|
||||
datagram.resize(outSocket->pendingDatagramSize());
|
||||
QHostAddress sender;
|
||||
quint16 senderPort;
|
||||
inSocket->readDatagram(datagram.data(), datagram.size(),
|
||||
outSocket->readDatagram(datagram.data(), datagram.size(),
|
||||
&sender, &senderPort);
|
||||
QString datastr(datagram);
|
||||
// Process incomming data
|
||||
@ -192,12 +194,12 @@ void Il2Bridge::onAutopilotDisconnect()
|
||||
emit autopilotDisconnected();
|
||||
}
|
||||
|
||||
void Il2Bridge::onFGConnectionTimeout()
|
||||
void Il2Bridge::onIl2ConnectionTimeout()
|
||||
{
|
||||
if ( fgConnectionStatus )
|
||||
if ( il2ConnectionStatus )
|
||||
{
|
||||
fgConnectionStatus = false;
|
||||
emit fgDisconnected();
|
||||
il2ConnectionStatus = false;
|
||||
emit il2Disconnected();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup hitlplugin
|
||||
* @defgroup hitlil2plugin
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
@ -25,12 +25,13 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef FLIGHTGEARBRIDGE_H
|
||||
#define FLIGHTGEARBRIDGE_H
|
||||
#ifndef IL2BRIDGE_H
|
||||
#define IL2BRIDGE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QUdpSocket>
|
||||
#include <QTimer>
|
||||
#include <QMessageBox>
|
||||
#include <math.h>
|
||||
#include "uavtalk/telemetrymanager.h"
|
||||
#include "uavobjects/uavobjectmanager.h"
|
||||
@ -91,4 +92,4 @@ private:
|
||||
void setupObjects();
|
||||
};
|
||||
|
||||
#endif // FLIGHTGEARBRIDGE_H
|
||||
#endif // IL2BRIDGE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user