-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work on Condor data source. Still WIP.
- Loading branch information
Showing
8 changed files
with
162 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import QtQuick 2.0 | ||
import QtQuick.Controls 1.4 | ||
import QtQuick.Layouts 1.0 | ||
|
||
TextArea { | ||
Layout.fillWidth: true | ||
Layout.fillHeight: true | ||
readOnly: true | ||
text: transformer.dataSource ? transformer.dataSource.helpText : "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#include "condordatasource.h" | ||
#include <QNetworkDatagram> | ||
#include <QDebug> | ||
#include <datarefs/dataref.h> | ||
|
||
CondorDatasource::CondorDatasource() : DataSource() { | ||
m_port = 55278; | ||
|
||
m_supportedRefs << "sim/cockpit2/gauges/indicators/heading_electric_deg_mag_pilot" | ||
<< "sim/cockpit2/gauges/indicators/airspeed_kts_pilot" | ||
<< "sim/cockpit2/gauges/indicators/pitch_vacuum_deg_pilot" | ||
<< "sim/cockpit2/gauges/indicators/roll_vacuum_deg_pilot" | ||
<< "sim/flightmodel/misc/h_ind" | ||
<< "sim/flightmodel/position/vh_ind" | ||
<< "sim/cockpit2/gauges/indicators/slip_deg"; | ||
} | ||
|
||
|
||
void CondorDatasource::connectToSource() { | ||
setNetworkError(QString()); | ||
|
||
connect(&m_udpSocket, &QUdpSocket::readyRead, this, &CondorDatasource::readPendingDatagrams); | ||
if(m_udpSocket.bind(QHostAddress::LocalHost, m_port)) { | ||
setHelpText(QString("Listening to UDP transmissions on port %1. Please run Condor.\nSee config help at http://www.condorsoaring.com/manual/#simkits-and-udp-outputs").arg(m_port)); | ||
} else { | ||
setNetworkError(QString("Unable to bind to UDP port %1!").arg(m_port)); | ||
} | ||
} | ||
|
||
void CondorDatasource::readPendingDatagrams() { | ||
while (m_udpSocket.hasPendingDatagrams()) { | ||
QNetworkDatagram datagram = m_udpSocket.receiveDatagram(); | ||
QString data = QString::fromUtf8(datagram.data()); | ||
qDebug() << Q_FUNC_INFO << "RX datagram" << data; | ||
|
||
QStringList lines = data.split("\n"); | ||
for(QString line : lines) { | ||
QStringList splitLine = line.split("="); | ||
if(splitLine.length() == 2) { | ||
QString param = splitLine[0]; | ||
QString value = splitLine[1]; | ||
rxValue(param, value); | ||
} | ||
} | ||
} | ||
} | ||
|
||
void CondorDatasource::rxValue(QString ¶m, QString &value) { | ||
qDebug() << Q_FUNC_INFO << param << value; | ||
} | ||
|
||
DataRef *CondorDatasource::subscribeRef(QString &name) | ||
{ | ||
if(m_supportedRefs.contains(name)) { | ||
FloatDataRef *newRef = new FloatDataRef(this, name, nullptr); | ||
floatRefs.append(newRef); | ||
return newRef; | ||
} | ||
return nullptr; | ||
} | ||
|
||
void CondorDatasource::unsubscribeRef(DataRef *ref) | ||
{ | ||
qDebug() << Q_FUNC_INFO << ref->name(); | ||
if(ref->type() == extplaneRefTypeFloat) | ||
floatRefs.removeOne(qobject_cast<FloatDataRef*> (ref)); | ||
ref->deleteLater(); | ||
} | ||
|
||
void CondorDatasource::updateDataRef(DataRef *ref) | ||
{} | ||
|
||
void CondorDatasource::changeDataRef(DataRef *ref) | ||
{} | ||
|
||
void CondorDatasource::keyStroke(int keyid) | ||
{} | ||
|
||
void CondorDatasource::buttonPress(int buttonid) | ||
{} | ||
|
||
void CondorDatasource::buttonRelease(int buttonid) | ||
{} | ||
|
||
void CondorDatasource::command(QString &name, extplaneCommandType type) | ||
{} | ||
|
||
bool CondorDatasource::loadSituation(QString sitFileLocation) | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef CONDORDATASOURCE_H | ||
#define CONDORDATASOURCE_H | ||
|
||
#include <QObject> | ||
#include <QUdpSocket> | ||
#include <datarefs/floatdataref.h> | ||
#include "datasource.h" | ||
|
||
/** | ||
* @brief The CondorDatasource class decodes Condor (2) UDP datagrams | ||
* | ||
* Use to transform data from Condor or Condor 2 (same protocol) to ExtPlane. | ||
* | ||
* @see https://github.com/kbobrowski/CondorUDP2COM/blob/master/CondorUDP2COM.py | ||
*/ | ||
|
||
class CondorDatasource : public DataSource | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit CondorDatasource(); | ||
virtual void connectToSource(); | ||
// From DataSource: | ||
DataRef *subscribeRef(QString &name); | ||
void unsubscribeRef(DataRef *ref); | ||
void updateDataRef(DataRef *ref); | ||
void changeDataRef(DataRef *ref); | ||
void keyStroke(int keyid); | ||
void buttonPress(int buttonid); | ||
void buttonRelease(int buttonid); | ||
void command(QString &name, extplaneCommandType type); | ||
bool loadSituation(QString sitFileLocation); | ||
// | ||
|
||
private slots: | ||
void readPendingDatagrams(); | ||
|
||
private: | ||
void rxValue(QString ¶m, QString &value); | ||
unsigned int m_port; | ||
QUdpSocket m_udpSocket; | ||
QStringList m_supportedRefs; | ||
QList<FloatDataRef*> floatRefs; // All float datarefs used | ||
}; | ||
|
||
#endif // CONDORDATASOURCE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters