refs #199, further slot logging for network / simulator , added log method for bool values

This commit is contained in:
Klaus Basan
2014-04-10 18:08:55 +02:00
parent 4776b1e650
commit 6580ec48d5
6 changed files with 43 additions and 8 deletions

View File

@@ -50,6 +50,7 @@ namespace BlackCore
void CContextAudio::setOwnAircraft(const CAircraft &ownAircraft)
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, ownAircraft.toQString());
this->m_voice->setMyAircraftCallsign(ownAircraft.getCallsign());
}
@@ -59,6 +60,7 @@ namespace BlackCore
CVoiceRoomList CContextAudio::getComVoiceRoomsWithAudioStatus() const
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
return this->m_voice->getComVoiceRoomsWithAudioStatus();
}
@@ -68,6 +70,7 @@ namespace BlackCore
CVoiceRoom CContextAudio::getCom1VoiceRoom(bool withAudioStatus) const
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, withAudioStatus);
if (withAudioStatus)
return this->m_voice->getComVoiceRoomsWithAudioStatus()[0];
else
@@ -80,6 +83,7 @@ namespace BlackCore
CVoiceRoom CContextAudio::getCom2VoiceRoom(bool withAudioStatus) const
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, withAudioStatus);
if (withAudioStatus)
return this->m_voice->getComVoiceRoomsWithAudioStatus()[1];
else
@@ -92,6 +96,7 @@ namespace BlackCore
CVoiceRoomList CContextAudio::getComVoiceRooms() const
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
return this->m_voice->getComVoiceRooms();
}
@@ -101,6 +106,7 @@ namespace BlackCore
void CContextAudio::leaveAllVoiceRooms()
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
this->m_voice->leaveAllVoiceRooms();
}
@@ -110,6 +116,7 @@ namespace BlackCore
CAudioDeviceList CContextAudio::getAudioDevices() const
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
return this->m_voice->audioDevices();
}
@@ -119,6 +126,7 @@ namespace BlackCore
CAudioDeviceList CContextAudio::getCurrentAudioDevices() const
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
CAudioDeviceList devices;
devices.push_back(this->m_voice->getCurrentInputDevice());
devices.push_back(this->m_voice->getCurrentOutputDevice());
@@ -132,6 +140,7 @@ namespace BlackCore
{
Q_ASSERT(this->m_voice);
Q_ASSERT(audioDevice.getType() != CAudioDevice::Unknown);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, audioDevice.toQString());
if (audioDevice.getType() == CAudioDevice::InputDevice)
{
this->m_voice->setInputDevice(audioDevice);
@@ -148,6 +157,7 @@ namespace BlackCore
void CContextAudio::setVolumes(const CComSystem &com1, const CComSystem &com2)
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, com1.toQString(), com2.toQString());
this->m_voice->setRoomOutputVolume(IVoice::COM1, com1.getVolumeOutput());
this->m_voice->setRoomOutputVolume(IVoice::COM2, com2.getVolumeOutput());
this->m_voice->switchAudioOutput(IVoice::COM1, com1.isEnabled());
@@ -160,6 +170,7 @@ namespace BlackCore
bool CContextAudio::isMuted() const
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
return this->m_voice->isMuted();
}
@@ -169,6 +180,7 @@ namespace BlackCore
void CContextAudio::setComVoiceRooms(const CVoiceRoom &voiceRoomCom1, const CVoiceRoom &voiceRoomCom2)
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, voiceRoomCom1.toQString(), voiceRoomCom2.toQString());
CVoiceRoomList currentRooms = this->m_voice->getComVoiceRoomsWithAudioStatus();
CVoiceRoom currentRoom1 = currentRooms[0];
CVoiceRoom currentRoom2 = currentRooms[1];
@@ -190,6 +202,7 @@ namespace BlackCore
CCallsignList CContextAudio::getCom1RoomCallsigns() const
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
return this->m_voice->getVoiceRoomCallsigns(IVoice::COM1);
}
@@ -199,6 +212,7 @@ namespace BlackCore
CCallsignList CContextAudio::getCom2RoomCallsigns() const
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
return this->m_voice->getVoiceRoomCallsigns(IVoice::COM2);
}
@@ -209,6 +223,8 @@ namespace BlackCore
{
Q_ASSERT(this->m_voice);
Q_ASSERT(this->getRuntime());
if (!this->getRuntime()->getIContextNetwork()) return Network::CUserList();
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
return this->getIContextNetwork()->getUsersForCallsigns(this->getCom1RoomCallsigns());
}
@@ -219,9 +235,9 @@ namespace BlackCore
{
Q_ASSERT(this->m_voice);
Q_ASSERT(this->getRuntime());
Q_ASSERT(this->getRuntime()->getIContextNetwork());
return this->getRuntime()->getIContextNetwork()->
getUsersForCallsigns(this->getCom2RoomCallsigns());
if (!this->getRuntime()->getIContextNetwork()) return Network::CUserList();
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
return this->getRuntime()->getIContextNetwork()->getUsersForCallsigns(this->getCom2RoomCallsigns());
}
/*
@@ -230,6 +246,7 @@ namespace BlackCore
void CContextAudio::playSelcalTone(const CSelcal &selcal) const
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, selcal.toQString());
CAudioDevice outputDevice = m_voice->getCurrentOutputDevice();
BlackSound::CSoundGenerator::playSelcal(90, selcal, outputDevice);
}
@@ -240,6 +257,7 @@ namespace BlackCore
void CContextAudio::playNotification(uint notification) const
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO, QString::number(notification));
BlackSound::CSoundGenerator::playNotificationSound(90, static_cast<BlackSound::CSoundGenerator::Notification>(notification));
}
@@ -249,6 +267,7 @@ namespace BlackCore
void CContextAudio::runMicrophoneTest()
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
this->m_voice->runMicrophoneTest();
}
@@ -258,6 +277,7 @@ namespace BlackCore
void CContextAudio::runSquelchTest()
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
this->m_voice->runSquelchTest();
}
@@ -267,6 +287,7 @@ namespace BlackCore
QString CContextAudio::getMicrophoneTestResult() const
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
return this->m_voice->micTestResultAsString();
}
@@ -276,9 +297,13 @@ namespace BlackCore
double CContextAudio::getSquelchValue() const
{
Q_ASSERT(this->m_voice);
if (this->getRuntime()->isSlotLogForAudioEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
return static_cast<double>(this->m_voice->inputSquelch());
}
/*
* Settings changed
*/
void CContextAudio::settingsChanged(uint typeValue)
{
if (!this->getIContextSettings()) return;

View File

@@ -20,6 +20,7 @@ namespace BlackCore
{
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTAUDIO_INTERFACENAME)
Q_OBJECT
friend class CRuntime;
public:

View File

@@ -179,6 +179,7 @@ namespace BlackCore
*/
bool CContextNetwork::isConnected() const
{
if (this->getRuntime()->isSlotLogForNetworkEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
return this->m_network->isConnected();
}

View File

@@ -217,6 +217,11 @@ namespace BlackCore
qDebug() << func << p1 << p2 << p3 << p4; return;
}
void CRuntime::logSlot(const char *func, bool boolValue) const
{
qDebug() << func << boolValue;
}
/*
* Init runtime
*/

View File

@@ -93,9 +93,11 @@ namespace BlackCore
//! Slot logging
//! \todo to be replace if initializer lists becomes available
//! \sa signalLog(QOb)
void logSlot(const char *func, const QString &p1 = "", const QString &p2 = "", const QString &p3 = "", const QString &p4 = "") const;
//! Slot logging for bool value
void logSlot(const char *func, bool boolValue) const;
//! shutdown
void gracefulShutdown();
@@ -157,6 +159,9 @@ namespace BlackCore
//! \remarks only applicable for local object
CContextSimulator *getCContextSimulator() const;
//! Init
void init(const CRuntimeConfig &config);
private:
bool m_init; /*!< flag */
CDBusServer *m_dbusServer;
@@ -179,8 +184,6 @@ namespace BlackCore
IContextSimulator *m_contextSimulator;
QMultiMap<QString, QMetaObject::Connection> m_logSignalConnections;
//! Init
void init(const CRuntimeConfig &config);
//! initialization of DBus connection (where applicable)
void initDBusConnection();

View File

@@ -18,7 +18,6 @@ using namespace BlackMisc::Geo;
namespace BlackCore
{
// Init this context
CContextSimulator::CContextSimulator(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextSimulator(mode, runtime),
m_simulator(nullptr), m_updateTimer(nullptr)
{
@@ -27,17 +26,18 @@ namespace BlackCore
connect(m_updateTimer, &QTimer::timeout, this, &CContextSimulator::updateOwnAircraft);
}
// Cleanup
CContextSimulator::~CContextSimulator() {}
bool CContextSimulator::isConnected() const
{
if (this->getRuntime()->isSlotLogForSimulatorEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
if (!m_simulator) return false;
return m_simulator->isConnected();
}
BlackMisc::Aviation::CAircraft CContextSimulator::getOwnAircraft() const
{
if (this->getRuntime()->isSlotLogForSimulatorEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
return m_ownAircraft;
}