Finish demo UI and connect it to AFVClient

this includes:
- enable/disable check boxes, 
- ptt button
- loopback check box
- map zoom buttons
- showing the received callsign
- VHF effects checkbox
ref T731
This commit is contained in:
Roland Rossgotterer
2019-09-19 16:36:22 +02:00
committed by Mat Sutcliffe
parent 852247e893
commit acb5b11966
4 changed files with 156 additions and 47 deletions

View File

@@ -44,6 +44,12 @@ namespace BlackCore
{ 1, 122800000, 48.5, 11.5, 1000.0, 1000.0 }
};
m_enabledTransceivers =
{
{ 0 },
{ 1 }
};
qDebug() << "UserClient instantiated";
}
@@ -61,11 +67,15 @@ namespace BlackCore
m_callsign = callsign;
m_connection->connectTo(cid, password, callsign);
updateTransceivers();
if (m_connection->isConnected()) { emit connectionStatusChanged(Connected); }
else { emit connectionStatusChanged(Disconnected); }
}
void AFVClient::disconnectFrom()
{
m_connection->disconnectFrom();
emit connectionStatusChanged(Disconnected);
}
QStringList AFVClient::availableInputDevices() const
@@ -177,6 +187,14 @@ namespace BlackCore
m_output->stop();
}
void AFVClient::enableTransceiver(quint16 id, bool enable)
{
if (enable) { m_enabledTransceivers.insert(id); }
else { m_enabledTransceivers.remove(id); }
updateTransceivers();
}
void AFVClient::updateComFrequency(quint16 id, quint32 frequency)
{
if (id != 0 && id != 1) { return; }
@@ -203,6 +221,7 @@ namespace BlackCore
transceiver.HeightAglM = height;
transceiver.HeightMslM = height;
}
updateTransceivers();
}
void AFVClient::updateTransceivers()
@@ -219,7 +238,15 @@ namespace BlackCore
updateComFrequency(1, ownAircraft.getCom2System().getFrequencyActive().value(CFrequencyUnit::Hz()));
}
m_connection->updateTransceivers(m_callsign, m_transceivers);
QVector<TransceiverDto> enabledTransceivers;
for (const TransceiverDto &transceiver : m_transceivers)
{
if (m_enabledTransceivers.contains(transceiver.id))
{
enabledTransceivers.push_back(transceiver);
}
}
m_connection->updateTransceivers(m_callsign, enabledTransceivers);
if (soundcardSampleProvider)
{
@@ -388,6 +415,11 @@ namespace BlackCore
// m_outputVolume = (float)System.Math.Pow(10, value / 20);
// TODO outputSampleProvider.Volume = outputVolume;
}
AFVClient::ConnectionStatus AFVClient::getConnectionStatus() const
{
return m_connection->isConnected() ? Connected : Disconnected;
}
} // ns
} // ns
} // ns

View File

@@ -40,10 +40,14 @@ namespace BlackCore
Q_OBJECT
Q_PROPERTY(float inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU)
Q_PROPERTY(float outputVolumePeakVU READ getOutputVolumePeakVU NOTIFY outputVolumePeakVU)
Q_PROPERTY(ConnectionStatus connectionStatus READ getConnectionStatus NOTIFY connectionStatusChanged)
Q_PROPERTY(QString receivingCallsignsCom1 READ getReceivingCallsignsCom1 NOTIFY receivingCallsignsChanged)
Q_PROPERTY(QString receivingCallsignsCom2 READ getReceivingCallsignsCom2 NOTIFY receivingCallsignsChanged)
public:
enum ConnectionStatus { Disconnected, Connected };
Q_ENUM(ConnectionStatus)
//! Ctor
AFVClient(const QString &apiServer, QObject *parent = nullptr);
@@ -65,7 +69,7 @@ namespace BlackCore
Q_INVOKABLE QStringList availableInputDevices() const;
Q_INVOKABLE QStringList availableOutputDevices() const;
void setBypassEffects(bool value);
Q_INVOKABLE void setBypassEffects(bool value);
bool isStarted() const { return m_isStarted; }
QDateTime getStartDateTimeUt() const { return m_startDateTimeUtc; }
@@ -74,15 +78,16 @@ namespace BlackCore
Q_INVOKABLE void start(const QString &inputDeviceName, const QString &outputDeviceName);
void stop();
Q_INVOKABLE void enableTransceiver(quint16 id, bool enable);
Q_INVOKABLE void updateComFrequency(quint16 id, quint32 frequency);
Q_INVOKABLE void updatePosition(double latitude, double longitude, double height);
void setTransmittingTransceivers(quint16 transceiverID);
void setTransmittingTransceivers(const QVector<TxTransceiverDto> &transceivers);
void setPtt(bool active);
Q_INVOKABLE void setPtt(bool active);
void setLoopBack(bool on) { m_loopbackOn = on; }
Q_INVOKABLE void setLoopBack(bool on) { m_loopbackOn = on; }
float inputVolumeDb() const
{
@@ -97,10 +102,13 @@ namespace BlackCore
float getInputVolumePeakVU() const { return m_inputVolumeStream.PeakVU; }
float getOutputVolumePeakVU() const { return m_outputVolumeStream.PeakVU; }
ConnectionStatus getConnectionStatus() const;
signals:
void receivingCallsignsChanged(const Audio::TransceiverReceivingCallsignsChangedArgs &args);
void inputVolumePeakVU(float value);
void outputVolumePeakVU(float value);
void connectionStatusChanged(ConnectionStatus status);
private:
void opusDataAvailable(const Audio::OpusDataAvailableArgs &args);
@@ -146,6 +154,7 @@ namespace BlackCore
QTimer m_voiceServerPositionTimer;
QVector<TransceiverDto> m_transceivers;
QSet<quint16> m_enabledTransceivers;
Audio::InputVolumeStreamArgs m_inputVolumeStream;
Audio::OutputVolumeStreamArgs m_outputVolumeStream;