mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
OP-51: GCS Antenna Tracker plugin, My (first) quick tester plugin for antennatracker. Not included into build. Heavily based on gps display plugin.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2176 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
74249f8e41
commit
bf8b9fd00c
11
ground/src/plugins/antennatrack/AntennaTrack.pluginspec
Normal file
11
ground/src/plugins/antennatrack/AntennaTrack.pluginspec
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<plugin name="AntennaTrack" version="1.0.0" compatVersion="1.0.0">
|
||||||
|
<vendor>The OpenPilot Project</vendor>
|
||||||
|
<copyright>(C) 2010 SK</copyright>
|
||||||
|
<license>The GNU Public License (GPL) Version 3</license>
|
||||||
|
<description>Plugin for antenna tracker</description>
|
||||||
|
<url>http://www.openpilot.org</url>
|
||||||
|
<dependencyList>
|
||||||
|
<dependency name="Core" version="1.0.0"/>
|
||||||
|
<dependency name="UAVObjects" version="1.0.0"/>
|
||||||
|
</dependencyList>
|
||||||
|
</plugin>
|
25
ground/src/plugins/antennatrack/antennatrack.pro
Normal file
25
ground/src/plugins/antennatrack/antennatrack.pro
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
TEMPLATE = lib
|
||||||
|
TARGET = AntennaTrack
|
||||||
|
include(../../openpilotgcsplugin.pri)
|
||||||
|
include(../../plugins/coreplugin/coreplugin.pri)
|
||||||
|
include(antennatrack_dependencies.pri)
|
||||||
|
include(../../libs/qwt/qwt.pri)
|
||||||
|
HEADERS += antennatrackplugin.h
|
||||||
|
HEADERS += gpsparser.h
|
||||||
|
HEADERS += telemetryparser.h
|
||||||
|
HEADERS += antennatrackgadget.h
|
||||||
|
HEADERS += antennatrackwidget.h
|
||||||
|
HEADERS += antennatrackgadgetfactory.h
|
||||||
|
HEADERS += antennatrackgadgetconfiguration.h
|
||||||
|
HEADERS += antennatrackgadgetoptionspage.h
|
||||||
|
SOURCES += antennatrackplugin.cpp
|
||||||
|
SOURCES += gpsparser.cpp
|
||||||
|
SOURCES += telemetryparser.cpp
|
||||||
|
SOURCES += antennatrackgadget.cpp
|
||||||
|
SOURCES += antennatrackgadgetfactory.cpp
|
||||||
|
SOURCES += antennatrackwidget.cpp
|
||||||
|
SOURCES += antennatrackgadgetconfiguration.cpp
|
||||||
|
SOURCES += antennatrackgadgetoptionspage.cpp
|
||||||
|
OTHER_FILES += AntennaTrack.pluginspec
|
||||||
|
FORMS += antennatrackgadgetoptionspage.ui
|
||||||
|
FORMS += antennatrackwidget.ui
|
@ -0,0 +1,3 @@
|
|||||||
|
include(../../plugins/uavobjects/uavobjects.pri)
|
||||||
|
#include(../../plugins/coreplugin/coreplugin.pri)
|
||||||
|
#include(../../libs/utils/utils.pri)
|
155
ground/src/plugins/antennatrack/antennatrackgadget.cpp
Normal file
155
ground/src/plugins/antennatrack/antennatrackgadget.cpp
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file AntennaTracgadget.cpp
|
||||||
|
* @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
|
||||||
|
* @{
|
||||||
|
* @brief A gadget that communicates with antenna tracker and enables basic configuration
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "antennatrackgadget.h"
|
||||||
|
#include "antennatrackwidget.h"
|
||||||
|
#include "antennatrackgadgetconfiguration.h"
|
||||||
|
|
||||||
|
AntennaTrackGadget::AntennaTrackGadget(QString classId, AntennaTrackWidget *widget, QWidget *parent) :
|
||||||
|
IUAVGadget(classId, parent),
|
||||||
|
m_widget(widget),
|
||||||
|
connected(FALSE)
|
||||||
|
{
|
||||||
|
connect(m_widget->connectButton, SIGNAL(clicked(bool)), this,SLOT(onConnect()));
|
||||||
|
connect(m_widget->disconnectButton, SIGNAL(clicked(bool)), this,SLOT(onDisconnect()));
|
||||||
|
}
|
||||||
|
|
||||||
|
AntennaTrackGadget::~AntennaTrackGadget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
This is called when a configuration is loaded, and updates the plugin's settings.
|
||||||
|
Careful: the plugin is already drawn before the loadConfiguration method is called the
|
||||||
|
first time, so you have to be careful not to assume all the plugin values are initialized
|
||||||
|
the first time you use them
|
||||||
|
*/
|
||||||
|
void AntennaTrackGadget::loadConfiguration(IUAVGadgetConfiguration* config)
|
||||||
|
{
|
||||||
|
// Delete the (old)port, this also closes it.
|
||||||
|
if(port) {
|
||||||
|
delete port;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the (old)parser, this also disconnects all signals.
|
||||||
|
if(parser) {
|
||||||
|
delete parser;
|
||||||
|
}
|
||||||
|
|
||||||
|
AntennaTrackGadgetConfiguration *AntennaTrackConfig = qobject_cast< AntennaTrackGadgetConfiguration*>(config);
|
||||||
|
|
||||||
|
PortSettings portsettings;
|
||||||
|
portsettings.BaudRate=AntennaTrackConfig->speed();
|
||||||
|
portsettings.DataBits=AntennaTrackConfig->dataBits();
|
||||||
|
portsettings.FlowControl=AntennaTrackConfig->flow();
|
||||||
|
portsettings.Parity=AntennaTrackConfig->parity();
|
||||||
|
portsettings.StopBits=AntennaTrackConfig->stopBits();
|
||||||
|
portsettings.Timeout_Millisec=AntennaTrackConfig->timeOut();
|
||||||
|
|
||||||
|
// In case we find no port, buttons disabled
|
||||||
|
m_widget->connectButton->setEnabled(false);
|
||||||
|
m_widget->disconnectButton->setEnabled(false);
|
||||||
|
|
||||||
|
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
|
||||||
|
foreach( QextPortInfo nport, ports ) {
|
||||||
|
if(nport.friendName == AntennaTrackConfig->port())
|
||||||
|
{
|
||||||
|
qDebug() << "Using Serial port";
|
||||||
|
//parser = new NMEAParser();
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
port=new QextSerialPort(nport.portName,portsettings,QextSerialPort::EventDriven);
|
||||||
|
#else
|
||||||
|
port=new QextSerialPort(nport.physName,portsettings,QextSerialPort::EventDriven);
|
||||||
|
#endif
|
||||||
|
m_widget->setPort(port);
|
||||||
|
m_widget->connectButton->setEnabled(true);
|
||||||
|
m_widget->disconnectButton->setEnabled(false);
|
||||||
|
m_widget->connectButton->setHidden(false);
|
||||||
|
m_widget->disconnectButton->setHidden(false);
|
||||||
|
|
||||||
|
connect(port, SIGNAL(readyRead()), this, SLOT(onDataAvailable()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_widget->dataStreamGroupBox->setHidden(false);
|
||||||
|
qDebug() << "Using Telemetry parser";
|
||||||
|
parser = new TelemetryParser();
|
||||||
|
|
||||||
|
connect(parser, SIGNAL(position(double,double,double)), m_widget,SLOT(setPosition(double,double,double)));
|
||||||
|
connect(parser, SIGNAL(home(double,double,double)), m_widget,SLOT(setHomePosition(double,double,double)));
|
||||||
|
connect(parser, SIGNAL(packet(QString)), m_widget, SLOT(dumpPacket(QString)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AntennaTrackGadget::onConnect() {
|
||||||
|
m_widget->textBrowser->append(QString("Connecting to Tracker ...\n"));
|
||||||
|
// TODO: Somehow mark that we're running, and disable connect button while so?
|
||||||
|
|
||||||
|
if (port) {
|
||||||
|
qDebug() << "Opening: " << port->portName() << ".";
|
||||||
|
bool isOpen = port->open(QIODevice::ReadWrite);
|
||||||
|
qDebug() << "Open: " << isOpen;
|
||||||
|
if(isOpen) {
|
||||||
|
m_widget->connectButton->setEnabled(false);
|
||||||
|
m_widget->disconnectButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "Port undefined or invalid.";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AntennaTrackGadget::onDisconnect() {
|
||||||
|
if (port) {
|
||||||
|
qDebug() << "Closing: " << port->portName() << ".";
|
||||||
|
port->close();
|
||||||
|
m_widget->connectButton->setEnabled(true);
|
||||||
|
m_widget->disconnectButton->setEnabled(false);
|
||||||
|
} else {
|
||||||
|
qDebug() << "Port undefined or invalid.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AntennaTrackGadget::onDataAvailable() {
|
||||||
|
int avail = port->bytesAvailable();
|
||||||
|
if( avail > 0 ) {
|
||||||
|
QByteArray serialData;
|
||||||
|
serialData.resize(avail);
|
||||||
|
int bytesRead = port->read(serialData.data(), serialData.size());
|
||||||
|
if( bytesRead > 0 ) {
|
||||||
|
processNewSerialData(serialData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AntennaTrackGadget::processNewSerialData(QByteArray serialData) {
|
||||||
|
int dataLength = serialData.size();
|
||||||
|
const char* data = serialData.constData();
|
||||||
|
m_widget->textBrowser->append(QString(serialData));
|
||||||
|
for(int pos = 0; pos < dataLength; pos++) {
|
||||||
|
//parser->processInputStream(data[pos]);
|
||||||
|
}
|
||||||
|
}
|
72
ground/src/plugins/antennatrack/antennatrackgadget.h
Normal file
72
ground/src/plugins/antennatrack/antennatrackgadget.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file AntennaTrackgadget.h
|
||||||
|
* @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
|
||||||
|
* @{
|
||||||
|
* @brief A gadget that communicates with antenna tracker and enables basic configuration
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ANTENNATRACKGADGET_H_
|
||||||
|
#define ANTENNATRACKGADGET_H_
|
||||||
|
|
||||||
|
#include <qextserialport/src/qextserialport.h>
|
||||||
|
#include <qextserialport/src/qextserialenumerator.h>
|
||||||
|
#include <coreplugin/iuavgadget.h>
|
||||||
|
#include "antennatrackwidget.h"
|
||||||
|
#include "telemetryparser.h"
|
||||||
|
|
||||||
|
class IUAVGadget;
|
||||||
|
class QWidget;
|
||||||
|
class QString;
|
||||||
|
class AntennaTrackWidget;
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
|
|
||||||
|
class AntennaTrackGadget : public Core::IUAVGadget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
AntennaTrackGadget(QString classId, AntennaTrackWidget *widget, QWidget *parent = 0);
|
||||||
|
~AntennaTrackGadget();
|
||||||
|
|
||||||
|
QWidget *widget() { return m_widget; }
|
||||||
|
|
||||||
|
// void setMode(QString mode); // Either UAVTalk or serial port
|
||||||
|
|
||||||
|
void loadConfiguration(IUAVGadgetConfiguration* config);
|
||||||
|
public slots:
|
||||||
|
void onConnect();
|
||||||
|
void onDisconnect();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onDataAvailable();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<AntennaTrackWidget> m_widget;
|
||||||
|
QPointer<QextSerialPort> port;
|
||||||
|
QPointer<GPSParser> parser;
|
||||||
|
bool connected;
|
||||||
|
void processNewSerialData(QByteArray serialData);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // ANTENNATRACKGADGET_H_
|
@ -0,0 +1,109 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file AntennaTracgadgetconfiguration.cpp
|
||||||
|
* @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
|
||||||
|
* @{
|
||||||
|
* @brief A gadget that communicates with antenna tracker and enables basic configuration
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "antennatrackgadgetconfiguration.h"
|
||||||
|
#include <qextserialport/src/qextserialport.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a saved configuration or defaults if non exist.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
AntennaTrackGadgetConfiguration::AntennaTrackGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||||
|
IUAVGadgetConfiguration(classId, parent),
|
||||||
|
m_connectionMode("Serial"),
|
||||||
|
m_defaultPort("Unknown"),
|
||||||
|
m_defaultSpeed(BAUD4800),
|
||||||
|
m_defaultDataBits(DATA_8),
|
||||||
|
m_defaultFlow(FLOW_OFF),
|
||||||
|
m_defaultParity(PAR_NONE),
|
||||||
|
m_defaultStopBits(STOP_1),
|
||||||
|
m_defaultTimeOut(5000)
|
||||||
|
{
|
||||||
|
//if a saved configuration exists load it
|
||||||
|
if(qSettings != 0) {
|
||||||
|
BaudRateType speed;
|
||||||
|
DataBitsType databits;
|
||||||
|
FlowType flow;
|
||||||
|
ParityType parity;
|
||||||
|
StopBitsType stopbits;
|
||||||
|
|
||||||
|
int ispeed = qSettings->value("defaultSpeed").toInt();
|
||||||
|
int idatabits = qSettings->value("defaultDataBits").toInt();
|
||||||
|
int iflow = qSettings->value("defaultFlow").toInt();
|
||||||
|
int iparity = qSettings->value("defaultParity").toInt();
|
||||||
|
int istopbits = qSettings->value("defaultStopBits").toInt();
|
||||||
|
QString port = qSettings->value("defaultPort").toString();
|
||||||
|
QString conMode = qSettings->value("connectionMode").toString();
|
||||||
|
|
||||||
|
databits = (DataBitsType) idatabits;
|
||||||
|
flow = (FlowType)iflow;
|
||||||
|
parity = (ParityType)iparity;
|
||||||
|
stopbits = (StopBitsType)istopbits;
|
||||||
|
speed = (BaudRateType)ispeed;
|
||||||
|
m_defaultPort = port;
|
||||||
|
m_defaultSpeed = speed;
|
||||||
|
m_defaultDataBits = databits;
|
||||||
|
m_defaultFlow = flow;
|
||||||
|
m_defaultParity = parity;
|
||||||
|
m_defaultStopBits = stopbits;
|
||||||
|
m_connectionMode = conMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones a configuration.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
IUAVGadgetConfiguration *AntennaTrackGadgetConfiguration::clone()
|
||||||
|
{
|
||||||
|
AntennaTrackGadgetConfiguration *m = new AntennaTrackGadgetConfiguration(this->classId());
|
||||||
|
|
||||||
|
m->m_defaultSpeed = m_defaultSpeed;
|
||||||
|
m->m_defaultDataBits = m_defaultDataBits;
|
||||||
|
m->m_defaultFlow = m_defaultFlow;
|
||||||
|
m->m_defaultParity = m_defaultParity;
|
||||||
|
m->m_defaultStopBits = m_defaultStopBits;
|
||||||
|
m->m_defaultPort = m_defaultPort;
|
||||||
|
m->m_connectionMode = m_connectionMode;
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves a configuration.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void AntennaTrackGadgetConfiguration::saveConfig(QSettings* settings) const {
|
||||||
|
settings->setValue("defaultSpeed", m_defaultSpeed);
|
||||||
|
settings->setValue("defaultDataBits", m_defaultDataBits);
|
||||||
|
settings->setValue("defaultFlow", m_defaultFlow);
|
||||||
|
settings->setValue("defaultParity", m_defaultParity);
|
||||||
|
settings->setValue("defaultStopBits", m_defaultStopBits);
|
||||||
|
settings->setValue("defaultPort", m_defaultPort);
|
||||||
|
settings->setValue("connectionMode", m_connectionMode);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file AntennaTracgadgetconfiguration.h
|
||||||
|
* @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
|
||||||
|
* @{
|
||||||
|
* @brief A gadget that communicates with antenna tracker and enables basic configuration
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ANTENNATRACKGADGETCONFIGURATION_H
|
||||||
|
#define ANTENNATRACKGADGETCONFIGURATION_H
|
||||||
|
|
||||||
|
#include <coreplugin/iuavgadgetconfiguration.h>
|
||||||
|
#include <qextserialport/src/qextserialport.h>
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
|
|
||||||
|
class AntennaTrackGadgetConfiguration : public IUAVGadgetConfiguration
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit AntennaTrackGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||||
|
|
||||||
|
void setConnectionMode(QString mode) { m_connectionMode = mode; }
|
||||||
|
QString connectionMode() { return m_connectionMode; }
|
||||||
|
|
||||||
|
//set port configuration functions
|
||||||
|
void setSpeed(BaudRateType speed) {m_defaultSpeed=speed;}
|
||||||
|
void setDataBits(DataBitsType databits) {m_defaultDataBits=databits;}
|
||||||
|
void setFlow(FlowType flow) {m_defaultFlow=flow;}
|
||||||
|
void setParity(ParityType parity) {m_defaultParity=parity;}
|
||||||
|
void setStopBits(StopBitsType stopbits) {m_defaultStopBits=stopbits;}
|
||||||
|
void setPort(QString port){m_defaultPort=port;}
|
||||||
|
void setTimeOut(long timeout){m_defaultTimeOut=timeout;}
|
||||||
|
|
||||||
|
//get port configuration functions
|
||||||
|
QString port(){return m_defaultPort;}
|
||||||
|
BaudRateType speed() {return m_defaultSpeed;}
|
||||||
|
FlowType flow() {return m_defaultFlow;}
|
||||||
|
DataBitsType dataBits() {return m_defaultDataBits;}
|
||||||
|
StopBitsType stopBits() {return m_defaultStopBits;}
|
||||||
|
ParityType parity() {return m_defaultParity;}
|
||||||
|
long timeOut(){return m_defaultTimeOut;}
|
||||||
|
|
||||||
|
void saveConfig(QSettings* settings) const;
|
||||||
|
IUAVGadgetConfiguration *clone();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_connectionMode;
|
||||||
|
QString m_defaultPort;
|
||||||
|
BaudRateType m_defaultSpeed;
|
||||||
|
DataBitsType m_defaultDataBits;
|
||||||
|
FlowType m_defaultFlow;
|
||||||
|
ParityType m_defaultParity;
|
||||||
|
StopBitsType m_defaultStopBits;
|
||||||
|
long m_defaultTimeOut;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ANTENNATRACKGADGETCONFIGURATION_H
|
@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file AntennaTracgadgetfactory.cpp
|
||||||
|
* @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
|
||||||
|
* @{
|
||||||
|
* @brief A gadget that communicates with antenna tracker and enables basic configuration
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#include "antennatrackgadgetfactory.h"
|
||||||
|
#include "antennatrackwidget.h"
|
||||||
|
#include "antennatrackgadget.h"
|
||||||
|
#include "antennatrackgadgetconfiguration.h"
|
||||||
|
#include "antennatrackgadgetoptionspage.h"
|
||||||
|
#include <coreplugin/iuavgadget.h>
|
||||||
|
|
||||||
|
AntennaTrackGadgetFactory::AntennaTrackGadgetFactory(QObject *parent) :
|
||||||
|
IUAVGadgetFactory(QString("AntennaTrackGadget"),
|
||||||
|
tr("Antenna Track Gadget"),
|
||||||
|
parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AntennaTrackGadgetFactory::~AntennaTrackGadgetFactory()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::IUAVGadget* AntennaTrackGadgetFactory::createGadget(QWidget *parent)
|
||||||
|
{
|
||||||
|
AntennaTrackWidget* gadgetWidget = new AntennaTrackWidget(parent);
|
||||||
|
return new AntennaTrackGadget(QString("AntennaTrackGadget"), gadgetWidget, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
IUAVGadgetConfiguration *AntennaTrackGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||||
|
{
|
||||||
|
return new AntennaTrackGadgetConfiguration(QString("AntennaTrackGadget"), qSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
IOptionsPage *AntennaTrackGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||||
|
{
|
||||||
|
return new AntennaTrackGadgetOptionsPage(qobject_cast<AntennaTrackGadgetConfiguration*>(config));
|
||||||
|
}
|
||||||
|
|
52
ground/src/plugins/antennatrack/antennatrackgadgetfactory.h
Normal file
52
ground/src/plugins/antennatrack/antennatrackgadgetfactory.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file antennatracgadgetfactory.h
|
||||||
|
* @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
|
||||||
|
* @{
|
||||||
|
* @brief A gadget that communicates with antenna tracker and enables basic configuration
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ANTENNATRACKGADGETFACTORY_H_
|
||||||
|
#define ANTENNATRACKGADGETFACTORY_H_
|
||||||
|
|
||||||
|
#include <coreplugin/iuavgadgetfactory.h>
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class IUAVGadget;
|
||||||
|
class IUAVGadgetFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
|
|
||||||
|
class AntennaTrackGadgetFactory : public IUAVGadgetFactory
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
AntennaTrackGadgetFactory(QObject *parent = 0);
|
||||||
|
~AntennaTrackGadgetFactory();
|
||||||
|
|
||||||
|
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||||
|
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||||
|
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ANTENNATRACKGADGETFACTORY_H_
|
@ -0,0 +1,266 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file AntennaTracgadgetoptionspage.cpp
|
||||||
|
* @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
|
||||||
|
* @{
|
||||||
|
* @brief A gadget that communicates with antenna tracker and enables basic configuration
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "antennatrackgadgetoptionspage.h"
|
||||||
|
#include "antennatrackgadgetconfiguration.h"
|
||||||
|
#include "ui_antennatrackgadgetoptionspage.h"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QtAlgorithms>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
AntennaTrackGadgetOptionsPage::AntennaTrackGadgetOptionsPage(AntennaTrackGadgetConfiguration *config, QObject *parent) :
|
||||||
|
IOptionsPage(parent),
|
||||||
|
m_config(config)
|
||||||
|
{
|
||||||
|
// Taken from the uploader gadget, since we also can use a serial port for this
|
||||||
|
// Gadget
|
||||||
|
|
||||||
|
//the begining of some ugly code
|
||||||
|
//diferent OS's have diferent serial port capabilities
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
//load windows port capabilities
|
||||||
|
BaudRateTypeString
|
||||||
|
<<"BAUD110"
|
||||||
|
<<"BAUD300"
|
||||||
|
<<"BAUD600"
|
||||||
|
<<"BAUD1200"
|
||||||
|
<<"BAUD2400"
|
||||||
|
<<"BAUD4800"
|
||||||
|
<<"BAUD9600"
|
||||||
|
<<"BAUD14400"
|
||||||
|
<<"BAUD19200"
|
||||||
|
<<"BAUD38400"
|
||||||
|
<<"BAUD56000"
|
||||||
|
<<"BAUD57600"
|
||||||
|
<<"BAUD115200"
|
||||||
|
<<"BAUD128000"
|
||||||
|
<<"BAUD256000";
|
||||||
|
DataBitsTypeString
|
||||||
|
<<"DATA_5"
|
||||||
|
<<"DATA_6"
|
||||||
|
<<"DATA_7"
|
||||||
|
<<"DATA_8";
|
||||||
|
ParityTypeString
|
||||||
|
<<"PAR_NONE"
|
||||||
|
<<"PAR_ODD"
|
||||||
|
<<"PAR_EVEN"
|
||||||
|
<<"PAR_MARK" //WINDOWS ONLY
|
||||||
|
<<"PAR_SPACE";
|
||||||
|
StopBitsTypeString
|
||||||
|
<<"STOP_1"
|
||||||
|
<<"STOP_1_5" //WINDOWS ONLY
|
||||||
|
<<"STOP_2";
|
||||||
|
#else
|
||||||
|
//load POSIX port capabilities
|
||||||
|
BaudRateTypeString
|
||||||
|
|
||||||
|
<<"BAUD50" //POSIX ONLY
|
||||||
|
<<"BAUD75" //POSIX ONLY
|
||||||
|
<<"BAUD110"
|
||||||
|
<<"BAUD134" //POSIX ONLY
|
||||||
|
<<"BAUD150" //POSIX ONLY
|
||||||
|
<<"BAUD200" //POSIX ONLY
|
||||||
|
<<"BAUD300"
|
||||||
|
<<"BAUD600"
|
||||||
|
<<"BAUD1200"
|
||||||
|
<<"BAUD1800" //POSIX ONLY
|
||||||
|
<<"BAUD2400"
|
||||||
|
<<"BAUD4800"
|
||||||
|
<<"BAUD9600"
|
||||||
|
<<"BAUD19200"
|
||||||
|
<<"BAUD38400"
|
||||||
|
<<"BAUD57600"
|
||||||
|
<<"BAUD76800" //POSIX ONLY
|
||||||
|
<<"BAUD115200";
|
||||||
|
DataBitsTypeString
|
||||||
|
<<"DATA_5"
|
||||||
|
<<"DATA_6"
|
||||||
|
<<"DATA_7"
|
||||||
|
<<"DATA_8";
|
||||||
|
ParityTypeString
|
||||||
|
<<"PAR_NONE"
|
||||||
|
<<"PAR_ODD"
|
||||||
|
<<"PAR_EVEN"
|
||||||
|
<<"PAR_SPACE";
|
||||||
|
StopBitsTypeString
|
||||||
|
<<"STOP_1"
|
||||||
|
<<"STOP_2";
|
||||||
|
#endif
|
||||||
|
//load all OS's capabilities
|
||||||
|
BaudRateTypeStringALL
|
||||||
|
<<"BAUD50" //POSIX ONLY
|
||||||
|
<<"BAUD75" //POSIX ONLY
|
||||||
|
<<"BAUD110"
|
||||||
|
<<"BAUD134" //POSIX ONLY
|
||||||
|
<<"BAUD150" //POSIX ONLY
|
||||||
|
<<"BAUD200" //POSIX ONLY
|
||||||
|
<<"BAUD300"
|
||||||
|
<<"BAUD600"
|
||||||
|
<<"BAUD1200"
|
||||||
|
<<"BAUD1800" //POSIX ONLY
|
||||||
|
<<"BAUD2400"
|
||||||
|
<<"BAUD4800"
|
||||||
|
<<"BAUD9600"
|
||||||
|
<<"BAUD14400"
|
||||||
|
<<"BAUD19200"
|
||||||
|
<<"BAUD38400"
|
||||||
|
<<"BAUD56000"
|
||||||
|
<<"BAUD57600"
|
||||||
|
<<"BAUD76800" //POSIX ONLY
|
||||||
|
<<"BAUD115200"
|
||||||
|
<<"BAUD128000"
|
||||||
|
<<"BAUD256000";
|
||||||
|
DataBitsTypeStringALL
|
||||||
|
<<"DATA_5"
|
||||||
|
<<"DATA_6"
|
||||||
|
<<"DATA_7"
|
||||||
|
<<"DATA_8";
|
||||||
|
ParityTypeStringALL
|
||||||
|
<<"PAR_NONE"
|
||||||
|
<<"PAR_ODD"
|
||||||
|
<<"PAR_EVEN"
|
||||||
|
<<"PAR_MARK" //WINDOWS ONLY
|
||||||
|
<<"PAR_SPACE";
|
||||||
|
StopBitsTypeStringALL
|
||||||
|
<<"STOP_1"
|
||||||
|
<<"STOP_1_5" //WINDOWS ONLY
|
||||||
|
<<"STOP_2";
|
||||||
|
|
||||||
|
FlowTypeString
|
||||||
|
<<"FLOW_OFF"
|
||||||
|
<<"FLOW_HARDWARE"
|
||||||
|
<<"FLOW_XONXOFF";
|
||||||
|
}
|
||||||
|
bool sortPorts(QextPortInfo const& s1,QextPortInfo const& s2)
|
||||||
|
{
|
||||||
|
return s1.portName<s2.portName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//creates options page widget (uses the UI file)
|
||||||
|
QWidget *AntennaTrackGadgetOptionsPage::createPage(QWidget *parent)
|
||||||
|
{
|
||||||
|
options_page = new Ui::AntennaTrackGadgetOptionsPage();
|
||||||
|
QWidget *optionsPageWidget = new QWidget;
|
||||||
|
options_page->setupUi(optionsPageWidget);
|
||||||
|
|
||||||
|
|
||||||
|
// PORTS
|
||||||
|
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
|
||||||
|
qSort(ports.begin(), ports.end(),sortPorts);
|
||||||
|
foreach( QextPortInfo port, ports ) {
|
||||||
|
qDebug() << "Adding port: " << port.friendName << " (" << port.portName << ")";
|
||||||
|
options_page->portComboBox->addItem(port.friendName, port.friendName);
|
||||||
|
}
|
||||||
|
|
||||||
|
int portIndex = options_page->portComboBox->findData(m_config->port());
|
||||||
|
if(portIndex!=-1){
|
||||||
|
qDebug() << "createPage(): port is " << m_config->port();
|
||||||
|
options_page->portComboBox->setCurrentIndex(portIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// BAUDRATES
|
||||||
|
options_page->portSpeedComboBox->addItems(BaudRateTypeString);
|
||||||
|
|
||||||
|
int portSpeedIndex = options_page->portSpeedComboBox->findText(BaudRateTypeStringALL.at((int)m_config->speed()));
|
||||||
|
if(portSpeedIndex != -1){
|
||||||
|
options_page->portSpeedComboBox->setCurrentIndex(portSpeedIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FLOW CONTROL
|
||||||
|
options_page->flowControlComboBox->addItems(FlowTypeString);
|
||||||
|
|
||||||
|
int flowControlIndex = options_page->flowControlComboBox->findText(FlowTypeString.at((int)m_config->flow()));
|
||||||
|
if(flowControlIndex != -1){
|
||||||
|
options_page->flowControlComboBox->setCurrentIndex(flowControlIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// DATABITS
|
||||||
|
options_page->dataBitsComboBox->addItems(DataBitsTypeString);
|
||||||
|
|
||||||
|
int dataBitsIndex = options_page->dataBitsComboBox->findText(DataBitsTypeStringALL.at((int)m_config->dataBits()));
|
||||||
|
if(dataBitsIndex != -1){
|
||||||
|
options_page->dataBitsComboBox->setCurrentIndex(dataBitsIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// STOPBITS
|
||||||
|
options_page->stopBitsComboBox->addItems(StopBitsTypeString);
|
||||||
|
|
||||||
|
int stopBitsIndex = options_page->stopBitsComboBox->findText(StopBitsTypeStringALL.at((int)m_config->stopBits()));
|
||||||
|
if(stopBitsIndex != -1){
|
||||||
|
options_page->stopBitsComboBox->setCurrentIndex(stopBitsIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// PARITY
|
||||||
|
options_page->parityComboBox->addItems(ParityTypeString);
|
||||||
|
|
||||||
|
int parityIndex = options_page->parityComboBox->findText(ParityTypeStringALL.at((int)m_config->parity()));
|
||||||
|
if(parityIndex != -1){
|
||||||
|
options_page->parityComboBox->setCurrentIndex(parityIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TIMEOUT
|
||||||
|
options_page->timeoutSpinBox->setValue(m_config->timeOut());
|
||||||
|
|
||||||
|
QStringList connectionModes;
|
||||||
|
connectionModes << "Serial";
|
||||||
|
options_page->connectionMode->addItems(connectionModes);
|
||||||
|
int conMode = options_page->connectionMode->findText(m_config->connectionMode());
|
||||||
|
if (conMode != -1)
|
||||||
|
options_page->connectionMode->setCurrentIndex(conMode);
|
||||||
|
|
||||||
|
|
||||||
|
return optionsPageWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the user presses apply or OK.
|
||||||
|
*
|
||||||
|
* Saves the current values
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void AntennaTrackGadgetOptionsPage::apply()
|
||||||
|
{
|
||||||
|
int portIndex = options_page->portComboBox->currentIndex();
|
||||||
|
m_config->setPort(options_page->portComboBox->itemData(portIndex).toString());
|
||||||
|
qDebug() << "apply(): port is " << m_config->port();
|
||||||
|
|
||||||
|
m_config->setSpeed((BaudRateType)BaudRateTypeStringALL.indexOf(options_page->portSpeedComboBox->currentText()));
|
||||||
|
m_config->setFlow((FlowType)FlowTypeString.indexOf(options_page->flowControlComboBox->currentText()));
|
||||||
|
m_config->setDataBits((DataBitsType)DataBitsTypeStringALL.indexOf(options_page->dataBitsComboBox->currentText()));
|
||||||
|
m_config->setStopBits((StopBitsType)StopBitsTypeStringALL.indexOf(options_page->stopBitsComboBox->currentText()));
|
||||||
|
m_config->setParity((ParityType)ParityTypeStringALL.indexOf(options_page->parityComboBox->currentText()));
|
||||||
|
m_config->setTimeOut( options_page->timeoutSpinBox->value());
|
||||||
|
m_config->setConnectionMode(options_page->connectionMode->currentText());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AntennaTrackGadgetOptionsPage::finish()
|
||||||
|
{
|
||||||
|
delete options_page;
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file antennatrackgadgetoptionspage.h
|
||||||
|
* @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
|
||||||
|
* @{
|
||||||
|
* @brief A gadget that communicates with antenna tracker and enables basic configuration
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ANTENNATRACKGADGETOPTIONSPAGE_H
|
||||||
|
#define ANTENNATRACKGADGETOPTIONSPAGE_H
|
||||||
|
|
||||||
|
#include <qextserialport/src/qextserialenumerator.h>
|
||||||
|
#include "coreplugin/dialogs/ioptionspage.h"
|
||||||
|
#include "QString"
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class IUAVGadgetConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
class AntennaTrackGadgetConfiguration;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class AntennaTrackGadgetOptionsPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
|
|
||||||
|
class AntennaTrackGadgetOptionsPage : public IOptionsPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit AntennaTrackGadgetOptionsPage(AntennaTrackGadgetConfiguration *config, QObject *parent = 0);
|
||||||
|
|
||||||
|
QWidget *createPage(QWidget *parent);
|
||||||
|
void apply();
|
||||||
|
void finish();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::AntennaTrackGadgetOptionsPage *options_page;
|
||||||
|
AntennaTrackGadgetConfiguration *m_config;
|
||||||
|
|
||||||
|
QStringList BaudRateTypeString;
|
||||||
|
QStringList BaudRateTypeStringALL;
|
||||||
|
QStringList DataBitsTypeStringALL;
|
||||||
|
QStringList ParityTypeStringALL;
|
||||||
|
QStringList StopBitsTypeStringALL;
|
||||||
|
QStringList DataBitsTypeString;
|
||||||
|
QStringList ParityTypeString;
|
||||||
|
QStringList StopBitsTypeString;
|
||||||
|
QStringList FlowTypeString;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ANTENNATRACKGADGETOPTIONSPAGE_H
|
186
ground/src/plugins/antennatrack/antennatrackgadgetoptionspage.ui
Normal file
186
ground/src/plugins/antennatrack/antennatrackgadgetoptionspage.ui
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>AntennaTrackGadgetOptionsPage</class>
|
||||||
|
<widget class="QWidget" name="AntennaTrackGadgetOptionsPage">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>587</width>
|
||||||
|
<height>359</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QWidget" name="widget" native="true">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Mode:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="connectionMode"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="serialPage">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1">
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="serialLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Serial Connection</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QFormLayout" name="serialFormLayout">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="portComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="portSpeedComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="dataBitsLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Data Bits:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="stopBitsLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Stop Bits:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="parityLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Parity:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QLabel" name="timeoutLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Timeout(ms):</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QComboBox" name="flowControlComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QComboBox" name="dataBitsComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QComboBox" name="stopBitsComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="portLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Port:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="portSpeedLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Port Speed:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QComboBox" name="parityComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="flowControlLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Flow Control:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<widget class="QSpinBox" name="timeoutSpinBox">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100000</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>connectionMode</sender>
|
||||||
|
<signal>currentIndexChanged(int)</signal>
|
||||||
|
<receiver>stackedWidget</receiver>
|
||||||
|
<slot>setCurrentIndex(int)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>77</x>
|
||||||
|
<y>16</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>293</x>
|
||||||
|
<y>194</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
34
ground/src/plugins/antennatrack/antennatrackplugin.cpp
Normal file
34
ground/src/plugins/antennatrack/antennatrackplugin.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "antennatrackplugin.h"
|
||||||
|
#include "antennatrackgadgetfactory.h"
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QtPlugin>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
|
AntennaTrackPlugin::AntennaTrackPlugin() {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
AntennaTrackPlugin::~AntennaTrackPlugin() {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AntennaTrackPlugin::initialize(const QStringList& args, QString *errMsg) {
|
||||||
|
Q_UNUSED(args);
|
||||||
|
Q_UNUSED(errMsg);
|
||||||
|
|
||||||
|
mf = new AntennaTrackGadgetFactory(this);
|
||||||
|
addAutoReleasedObject(mf);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AntennaTrackPlugin::extensionsInitialized() {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
void AntennaTrackPlugin::shutdown() {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_EXPORT_PLUGIN(AntennaTrackPlugin)
|
21
ground/src/plugins/antennatrack/antennatrackplugin.h
Normal file
21
ground/src/plugins/antennatrack/antennatrackplugin.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef ANTENNATRACKPLUGIN_H
|
||||||
|
#define ANTENNATRACKPLUGIN_H
|
||||||
|
|
||||||
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
|
class AntennaTrackGadgetFactory;
|
||||||
|
|
||||||
|
class AntennaTrackPlugin : public ExtensionSystem::IPlugin
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AntennaTrackPlugin();
|
||||||
|
~AntennaTrackPlugin();
|
||||||
|
|
||||||
|
void extensionsInitialized();
|
||||||
|
bool initialize(const QStringList & arguments, QString * errorString);
|
||||||
|
void shutdown();
|
||||||
|
private:
|
||||||
|
AntennaTrackGadgetFactory *mf;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ANTENNATRACKPLUGIN_H
|
206
ground/src/plugins/antennatrack/antennatrackwidget.cpp
Normal file
206
ground/src/plugins/antennatrack/antennatrackwidget.cpp
Normal file
@ -0,0 +1,206 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file Antennatrackwidget.cpp
|
||||||
|
* @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
|
||||||
|
* @{
|
||||||
|
* @brief A gadget that communicates with antenna tracker and enables basic configuration
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "antennatrackwidget.h"
|
||||||
|
#include "extensionsystem/pluginmanager.h"
|
||||||
|
#include "uavobjects/uavobjectmanager.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <QtGui>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize the widget
|
||||||
|
*/
|
||||||
|
AntennaTrackWidget::AntennaTrackWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
setupUi(this);
|
||||||
|
|
||||||
|
azimuth_old=0;
|
||||||
|
elevation_old=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
AntennaTrackWidget::~AntennaTrackWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void AntennaTrackWidget::setPort(QPointer<QextSerialPort> portx)
|
||||||
|
{
|
||||||
|
port=portx;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AntennaTrackWidget::dumpPacket(const QString &packet)
|
||||||
|
{
|
||||||
|
textBrowser->append(packet);
|
||||||
|
if(textBrowser->document()->lineCount() > 200) {
|
||||||
|
QTextCursor tc = textBrowser->textCursor();
|
||||||
|
tc.movePosition(QTextCursor::Start);
|
||||||
|
tc.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor);
|
||||||
|
tc.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
|
||||||
|
tc.removeSelectedText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AntennaTrackWidget::setPosition(double lat, double lon, double alt)
|
||||||
|
{
|
||||||
|
//lat *= 1E-7;
|
||||||
|
//lon *= 1E-7;
|
||||||
|
double deg = floor(fabs(lat));
|
||||||
|
double min = (fabs(lat)-deg)*60;
|
||||||
|
QString str1;
|
||||||
|
str1.sprintf("%.0f%c%.3f' ", deg,0x00b0, min);
|
||||||
|
if (lat>0)
|
||||||
|
str1.append("N");
|
||||||
|
else
|
||||||
|
str1.append("S");
|
||||||
|
coord_value->setText(str1);
|
||||||
|
deg = floor(fabs(lon));
|
||||||
|
min = (fabs(lon)-deg)*60;
|
||||||
|
QString str2;
|
||||||
|
str2.sprintf("%.0f%c%.3f' ", deg,0x00b0, min);
|
||||||
|
if (lon>0)
|
||||||
|
str2.append("E");
|
||||||
|
else
|
||||||
|
str2.append("W");
|
||||||
|
coord_value_2->setText(str2);
|
||||||
|
QString str3;
|
||||||
|
str3.sprintf("%.2f m", alt);
|
||||||
|
coord_value_3->setText(str3);
|
||||||
|
TrackData.Latitude=lat;
|
||||||
|
TrackData.Longitude=lon;
|
||||||
|
TrackData.Altitude=alt;
|
||||||
|
calcAntennaPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AntennaTrackWidget::setHomePosition(double lat, double lon, double alt)
|
||||||
|
{
|
||||||
|
//lat *= 1E-7;
|
||||||
|
//lon *= 1E-7;
|
||||||
|
double deg = floor(fabs(lat));
|
||||||
|
double min = (fabs(lat)-deg)*60;
|
||||||
|
QString str1;
|
||||||
|
str1.sprintf("%.0f%c%.3f' ", deg,0x00b0, min);
|
||||||
|
if (lat>0)
|
||||||
|
str1.append("N");
|
||||||
|
else
|
||||||
|
str1.append("S");
|
||||||
|
speed_value->setText(str1);
|
||||||
|
deg = floor(fabs(lon));
|
||||||
|
min = (fabs(lon)-deg)*60;
|
||||||
|
QString str2;
|
||||||
|
str2.sprintf("%.0f%c%.3f' ", deg,0x00b0, min);
|
||||||
|
if (lon>0)
|
||||||
|
str2.append("E");
|
||||||
|
else
|
||||||
|
str2.append("W");
|
||||||
|
bear_label->setText(str2);
|
||||||
|
QString str3;
|
||||||
|
str3.sprintf("%.2f m", alt);
|
||||||
|
bear_value->setText(str3);
|
||||||
|
TrackData.HomeLatitude=lat;
|
||||||
|
TrackData.HomeLongitude=lon;
|
||||||
|
TrackData.HomeAltitude=alt;
|
||||||
|
calcAntennaPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AntennaTrackWidget::calcAntennaPosition(void)
|
||||||
|
{
|
||||||
|
/** http://www.movable-type.co.uk/scripts/latlong.html **/
|
||||||
|
double lat1, lat2, lon1, lon2, a, c, d, x, y, brng;
|
||||||
|
double azimuth, elevation;
|
||||||
|
double gcsAlt=TrackData.HomeAltitude; // Home MSL altitude
|
||||||
|
double uavAlt=TrackData.Altitude; // UAV MSL altitude
|
||||||
|
double dAlt=uavAlt-gcsAlt; // Altitude difference
|
||||||
|
|
||||||
|
// Convert to radians
|
||||||
|
lat1 = TrackData.HomeLatitude*(M_PI/180); // Home lat
|
||||||
|
lon1 = TrackData.HomeLongitude*(M_PI/180); // Home lon
|
||||||
|
lat2 = TrackData.Latitude*(M_PI/180); // UAV lat
|
||||||
|
lon2 = TrackData.Longitude*(M_PI/180); // UAV lon
|
||||||
|
|
||||||
|
// Bearing
|
||||||
|
/**
|
||||||
|
var y = Math.sin(dLon) * Math.cos(lat2);
|
||||||
|
var x = Math.cos(lat1)*Math.sin(lat2) -
|
||||||
|
Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);
|
||||||
|
var brng = Math.atan2(y, x).toDeg();
|
||||||
|
**/
|
||||||
|
y = sin(lon2-lon1) * cos(lat2);
|
||||||
|
x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(lon2-lon1);
|
||||||
|
brng = atan2((sin(lon2-lon1)*cos(lat2)),(cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon2-lon1)))*(180/M_PI);
|
||||||
|
if(brng<0)
|
||||||
|
brng+=360;
|
||||||
|
|
||||||
|
// bearing to stepper
|
||||||
|
azimuth = brng;
|
||||||
|
|
||||||
|
// Haversine formula for distance
|
||||||
|
/**
|
||||||
|
var R = 6371; // km
|
||||||
|
var dLat = (lat2-lat1).toRad();
|
||||||
|
var dLon = (lon2-lon1).toRad();
|
||||||
|
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
|
||||||
|
Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) *
|
||||||
|
Math.sin(dLon/2) * Math.sin(dLon/2);
|
||||||
|
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
||||||
|
var d = R * c;
|
||||||
|
**/
|
||||||
|
a = sin((lat2-lat1)/2) * sin((lat2-lat1)/2) +
|
||||||
|
cos(lat1) * cos(lat2) *
|
||||||
|
sin((lon2-lon1)/2) * sin((lon2-lon1)/2);
|
||||||
|
c = 2 * atan2(sqrt(a), sqrt(1-a));
|
||||||
|
d = 6371 * 1000 * c;
|
||||||
|
|
||||||
|
// Elevation v depends servo direction
|
||||||
|
if(d!=0)
|
||||||
|
elevation = 90-(atan(dAlt/d)*(180/M_PI));
|
||||||
|
else
|
||||||
|
elevation = 0;
|
||||||
|
//! TODO: sanity check
|
||||||
|
|
||||||
|
QString str3;
|
||||||
|
str3.sprintf("%.0f deg", azimuth);
|
||||||
|
azimuth_value->setText(str3);
|
||||||
|
|
||||||
|
str3.sprintf("%.0f deg", elevation);
|
||||||
|
elevation_value->setText(str3);
|
||||||
|
|
||||||
|
//servo value 2000-4000
|
||||||
|
int servo = (int)(2000.0/180*elevation+2000);
|
||||||
|
int stepper = (int)(400.0/360*(azimuth-azimuth_old));
|
||||||
|
|
||||||
|
// send azimuth and elevation to tracker hardware
|
||||||
|
str3.sprintf("move %d 2000 2000 2000 %d\r", stepper,servo);
|
||||||
|
if(port->isOpen())
|
||||||
|
{
|
||||||
|
if(azimuth_old!=azimuth || elevation!=elevation_old)
|
||||||
|
port->write(str3.toAscii());
|
||||||
|
azimuth_old = azimuth;
|
||||||
|
elevation_old = elevation;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
75
ground/src/plugins/antennatrack/antennatrackwidget.h
Normal file
75
ground/src/plugins/antennatrack/antennatrackwidget.h
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file antennatrackwidget.h
|
||||||
|
* @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
|
||||||
|
* @{
|
||||||
|
* @brief A gadget that communicates with antenna tracker and enables basic configuration
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ANTENNATRACKWIDGET_H_
|
||||||
|
#define ANTENNATRACKWIDGET_H_
|
||||||
|
|
||||||
|
#include "ui_antennatrackwidget.h"
|
||||||
|
#include "antennatrackgadgetconfiguration.h"
|
||||||
|
#include "uavobjects/uavobject.h"
|
||||||
|
#include <QGraphicsView>
|
||||||
|
#include <QtSvg/QSvgRenderer>
|
||||||
|
#include <QtSvg/QGraphicsSvgItem>
|
||||||
|
#include <qextserialport/src/qextserialport.h>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
|
class Ui_AntennaTrackWidget;
|
||||||
|
|
||||||
|
typedef struct struct_TrackData
|
||||||
|
{
|
||||||
|
double Latitude;
|
||||||
|
double Longitude;
|
||||||
|
double Altitude;
|
||||||
|
double HomeLatitude;
|
||||||
|
double HomeLongitude;
|
||||||
|
double HomeAltitude;
|
||||||
|
|
||||||
|
}TrackData_t;
|
||||||
|
|
||||||
|
class AntennaTrackWidget : public QWidget, public Ui_AntennaTrackWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
AntennaTrackWidget(QWidget *parent = 0);
|
||||||
|
~AntennaTrackWidget();
|
||||||
|
TrackData_t TrackData;
|
||||||
|
void setPort(QPointer<QextSerialPort> portx);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void setPosition(double, double, double);
|
||||||
|
void setHomePosition(double, double, double);
|
||||||
|
void dumpPacket(const QString &packet);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void calcAntennaPosition(void);
|
||||||
|
QGraphicsSvgItem * marker;
|
||||||
|
QPointer<QextSerialPort> port;
|
||||||
|
double azimuth_old;
|
||||||
|
double elevation_old;
|
||||||
|
};
|
||||||
|
#endif /* ANTENNATRACKWIDGET_H_ */
|
479
ground/src/plugins/antennatrack/antennatrackwidget.ui
Normal file
479
ground/src/plugins/antennatrack/antennatrackwidget.ui
Normal file
@ -0,0 +1,479 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>AntennaTrackWidget</class>
|
||||||
|
<widget class="QWidget" name="AntennaTrackWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>560</width>
|
||||||
|
<height>376</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayoutTop">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="childrenCollapsible">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<layout class="QGridLayout" name="gridLayout" rowstretch="1,0" columnstretch="1">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QVBoxLayout" name="infoVerticalLayout" stretch="0,0,0,0,0,0,0,0,0,1">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="infoHorizontalLayout1" stretch="0,0,1,0,1,0,1">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lat_label">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Coord:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Minimum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>6</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="coord_value">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unknown</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_5">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Minimum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>6</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="coord_value_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unknown</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_6">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Minimum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>6</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="coord_value_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unknown</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Preferred</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>6</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="infoHorizontalLayout2" stretch="0,0,1,0,1,0,1">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="speed_label">
|
||||||
|
<property name="text">
|
||||||
|
<string>HomeCoord:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_7">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Minimum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>6</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="speed_value">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unknown</string>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_9">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Minimum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>6</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="bear_label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unknown</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_8">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Minimum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>6</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="bear_value">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unknown</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_5">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Preferred</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>4</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_7">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Preferred</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>4</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="infoHorizontalLayout4" stretch="0,0,1">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="status_label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Azimuth</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_10">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Minimum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>6</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="azimuth_value">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unknown</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Preferred</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>6</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="infoHorizontalLayout5" stretch="0,0,1">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="fix_label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Elevation</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_11">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Minimum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>6</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="elevation_value">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unknown</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Ignored</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>6</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout2" stretch="0,0,1">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Preferred</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>9</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="connectButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Connect</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="disconnectButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Disconnect</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QGroupBox" name="dataStreamGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Output</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QTextBrowser" name="textBrowser">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Ignored">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWrapMode">
|
||||||
|
<enum>QTextEdit::WidgetWidth</enum>
|
||||||
|
</property>
|
||||||
|
<property name="acceptRichText">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
43
ground/src/plugins/antennatrack/gpsparser.cpp
Normal file
43
ground/src/plugins/antennatrack/gpsparser.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file gpsparser.cpp
|
||||||
|
* @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
|
||||||
|
* @{
|
||||||
|
* @brief A gadget that communicates with antenna tracker and enables basic configuration
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gpsparser.h"
|
||||||
|
|
||||||
|
GPSParser::GPSParser(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
qRegisterMetaType<QList<int> >("QList<int>");
|
||||||
|
}
|
||||||
|
|
||||||
|
GPSParser::~GPSParser()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPSParser::processInputStream(char c) {
|
||||||
|
{
|
||||||
|
Q_UNUSED(c)}
|
||||||
|
}
|
59
ground/src/plugins/antennatrack/gpsparser.h
Normal file
59
ground/src/plugins/antennatrack/gpsparser.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file gpsparser.h
|
||||||
|
* @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
|
||||||
|
* @{
|
||||||
|
* @brief A gadget that communicates with antenna tracker and enables basic configuration
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GPSPARSER_H
|
||||||
|
#define GPSPARSER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtCore>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
class GPSParser: public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
~GPSParser();
|
||||||
|
virtual void processInputStream(char c);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
GPSParser(QObject *parent = 0);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sv(int); // Satellites in view
|
||||||
|
void position(double,double,double); // Lat, Lon, Alt
|
||||||
|
void home(double,double,double); // Lat, Lon, Alt
|
||||||
|
void datetime(double,double); // Date then time
|
||||||
|
void speedheading(double,double);
|
||||||
|
void packet(QString); // Raw NMEA Packet (or just info)
|
||||||
|
void satellite(int,int,int,int,int); // Index, PRN, Elevation, Azimuth, SNR
|
||||||
|
void fixmode(QString); // Mode of fix: "Auto", "Manual".
|
||||||
|
void fixtype(QString); // Type of fix: "NoGPS", "NoFix", "Fix2D", "Fix3D".
|
||||||
|
void dop(double, double, double); // HDOP, VDOP, PDOP
|
||||||
|
void fixSVs(QList<int>); // SV's used for fix.
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GPSPARSER_H
|
81
ground/src/plugins/antennatrack/telemetryparser.cpp
Normal file
81
ground/src/plugins/antennatrack/telemetryparser.cpp
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file telemetryparser.cpp
|
||||||
|
* @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
|
||||||
|
* @{
|
||||||
|
* @brief A gadget that communicates with antenna tracker and enables basic configuration
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "telemetryparser.h"
|
||||||
|
#include <math.h>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the parser
|
||||||
|
*/
|
||||||
|
TelemetryParser::TelemetryParser(QObject *parent) : GPSParser(parent)
|
||||||
|
{
|
||||||
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
|
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||||
|
UAVDataObject *gpsObj = dynamic_cast<UAVDataObject*>(objManager->getObject("GPSPosition"));
|
||||||
|
if (gpsObj != NULL) {
|
||||||
|
connect(gpsObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateGPS(UAVObject*)));
|
||||||
|
} else {
|
||||||
|
qDebug() << "Error: Object is unknown (GPSPosition).";
|
||||||
|
}
|
||||||
|
|
||||||
|
gpsObj = dynamic_cast<UAVDataObject*>(objManager->getObject("HomeLocation"));
|
||||||
|
if (gpsObj != NULL) {
|
||||||
|
connect(gpsObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateHome(UAVObject*)));
|
||||||
|
} else {
|
||||||
|
qDebug() << "Error: Object is unknown (HomeLocation).";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TelemetryParser::~TelemetryParser()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TelemetryParser::updateHome( UAVObject* object1) {
|
||||||
|
double lat = object1->getField(QString("Latitude"))->getDouble();
|
||||||
|
double lon = object1->getField(QString("Longitude"))->getDouble();
|
||||||
|
double alt = object1->getField(QString("Altitude"))->getDouble();
|
||||||
|
lat *= 1E-7;
|
||||||
|
lon *= 1E-7;
|
||||||
|
emit home(lat,lon,alt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TelemetryParser::updateGPS( UAVObject* object1) {
|
||||||
|
double lat = object1->getField(QString("Latitude"))->getDouble();
|
||||||
|
double lon = object1->getField(QString("Longitude"))->getDouble();
|
||||||
|
double alt = object1->getField(QString("Altitude"))->getDouble();
|
||||||
|
lat *= 1E-7;
|
||||||
|
lon *= 1E-7;
|
||||||
|
emit position(lat,lon,alt);
|
||||||
|
}
|
||||||
|
|
52
ground/src/plugins/antennatrack/telemetryparser.h
Normal file
52
ground/src/plugins/antennatrack/telemetryparser.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file telemetryparser.h
|
||||||
|
* @author Sami Korhonen & the OpenPilot team Copyright (C) 2010.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup AntennaTrackGadgetPlugin Antenna Track Gadget Plugin
|
||||||
|
* @{
|
||||||
|
* @brief A gadget that communicates with antenna tracker and enables basic configuration
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TELEMETRYPARSER_H
|
||||||
|
#define TELEMETRYPARSER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtCore>
|
||||||
|
#include "extensionsystem/pluginmanager.h"
|
||||||
|
#include "uavobjects/uavobjectmanager.h"
|
||||||
|
#include "uavobjects/uavobject.h"
|
||||||
|
#include "gpsparser.h"
|
||||||
|
|
||||||
|
|
||||||
|
class TelemetryParser: public GPSParser
|
||||||
|
{
|
||||||
|
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TelemetryParser(QObject *parent = 0);
|
||||||
|
~TelemetryParser();
|
||||||
|
public slots:
|
||||||
|
void updateGPS(UAVObject* object1);
|
||||||
|
void updateHome(UAVObject* object1);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TELEMETRYPARSER_H
|
@ -151,6 +151,12 @@ plugin_gcscontrol.depends += plugin_uavobjects
|
|||||||
plugin_gcscontrol.depends += plugin_uavtalk
|
plugin_gcscontrol.depends += plugin_uavtalk
|
||||||
SUBDIRS += plugin_gcscontrol
|
SUBDIRS += plugin_gcscontrol
|
||||||
|
|
||||||
|
# Antenna tracker
|
||||||
|
#plugin_antennatrack.subdir = antennatrack
|
||||||
|
#plugin_antennatrack.depends = plugin_coreplugin
|
||||||
|
#plugin_antennatrack.depends = plugin_uavtalk
|
||||||
|
#SUBDIRS += plugin_antennatrack
|
||||||
|
|
||||||
# Empty UAVGadget - Default for new splits
|
# Empty UAVGadget - Default for new splits
|
||||||
plugin_magicwaypoint.subdir = magicwaypoint
|
plugin_magicwaypoint.subdir = magicwaypoint
|
||||||
plugin_magicwaypoint.depends = plugin_coreplugin
|
plugin_magicwaypoint.depends = plugin_coreplugin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user