mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-24 07:55:35 +08:00
Ref T111, show sending and receiving API calls by LED
* monitor and log own signals * indcated receiving and sending
This commit is contained in:
committed by
Mathew Sutcliffe
parent
766c32e25d
commit
f972fdf715
@@ -45,6 +45,9 @@ namespace BlackSimPlugin
|
||||
m_monitorWidget.reset(new CSimulatorEmulatedMonitorDialog(this, sGui->mainApplicationWindow()));
|
||||
connect(qApp, &QApplication::aboutToQuit, this, &CSimulatorEmulated::closeMonitor);
|
||||
this->onSettingsChanged();
|
||||
|
||||
// connect own signals for monitoring
|
||||
this->connectOwnSignals();
|
||||
}
|
||||
|
||||
CSimulatorInfo CSimulatorEmulated::getSimulatorInfo() const
|
||||
@@ -66,44 +69,44 @@ namespace BlackSimPlugin
|
||||
m_monitorWidget->show();
|
||||
});
|
||||
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO);
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::disconnectFrom()
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO);
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
|
||||
m_renderedAircraft.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::logicallyAddRemoteAircraft(const CSimulatedAircraft &remoteAircraft)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, remoteAircraft.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, remoteAircraft.toQString());
|
||||
return CSimulatorCommon::logicallyAddRemoteAircraft(remoteAircraft);
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::logicallyRemoveRemoteAircraft(const CCallsign &callsign)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, callsign.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, callsign.toQString());
|
||||
return CSimulatorCommon::logicallyRemoveRemoteAircraft(callsign);
|
||||
}
|
||||
|
||||
int CSimulatorEmulated::physicallyRemoveMultipleRemoteAircraft(const CCallsignSet &callsigns)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, callsigns.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, callsigns.toQString());
|
||||
return CSimulatorCommon::physicallyRemoveMultipleRemoteAircraft(callsigns);
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::changeRemoteAircraftModel(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, aircraft.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, aircraft.toQString());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::changeRemoteAircraftEnabled(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, aircraft.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, aircraft.toQString());
|
||||
const int c = m_renderedAircraft.setEnabled(aircraft.getCallsign(), aircraft.isEnabled(), true);
|
||||
emit this->aircraftRenderingChanged(m_renderedAircraft.findFirstByCallsign(aircraft.getCallsign(), aircraft));
|
||||
return c > 0;
|
||||
@@ -111,7 +114,7 @@ namespace BlackSimPlugin
|
||||
|
||||
bool CSimulatorEmulated::updateOwnSimulatorCockpit(const CSimulatedAircraft &aircraft, const CIdentifier &originator)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, aircraft.toQString(), originator.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, aircraft.toQString(), originator.toQString());
|
||||
if (originator == identifier()) { return false; } // myself
|
||||
m_myAircraft.setCockpit(aircraft);
|
||||
emit this->internalAircraftChanged();
|
||||
@@ -120,7 +123,7 @@ namespace BlackSimPlugin
|
||||
|
||||
bool CSimulatorEmulated::updateOwnSimulatorSelcal(const CSelcal &selcal, const CIdentifier &originator)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, selcal.toQString(), originator.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, selcal.toQString(), originator.toQString());
|
||||
if (originator == identifier()) { return false; } // myself
|
||||
if (m_myAircraft.getSelcal() == selcal) { return false; }
|
||||
m_myAircraft.setSelcal(selcal);
|
||||
@@ -130,19 +133,19 @@ namespace BlackSimPlugin
|
||||
|
||||
void CSimulatorEmulated::displayStatusMessage(const CStatusMessage &message) const
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, message.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, message.toQString());
|
||||
m_monitorWidget->displayStatusMessage(message);
|
||||
}
|
||||
|
||||
void CSimulatorEmulated::displayTextMessage(const CTextMessage &message) const
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, message.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, message.toQString());
|
||||
m_monitorWidget->displayTextMessage(message);
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::setTimeSynchronization(bool enable, const CTime &offset)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, boolToTrueFalse(enable), offset.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, boolToTrueFalse(enable), offset.toQString());
|
||||
m_timeSyncronized = enable;
|
||||
m_offsetTime = offset;
|
||||
return enable;
|
||||
@@ -150,31 +153,31 @@ namespace BlackSimPlugin
|
||||
|
||||
CTime CSimulatorEmulated::getTimeSynchronizationOffset() const
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO);
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
|
||||
return m_offsetTime;
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::isPhysicallyRenderedAircraft(const CCallsign &callsign) const
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, callsign.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, callsign.toQString());
|
||||
return m_renderedAircraft.containsCallsign(callsign);
|
||||
}
|
||||
|
||||
CCallsignSet CSimulatorEmulated::physicallyRenderedAircraft() const
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO);
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
|
||||
return m_renderedAircraft.getCallsigns();
|
||||
}
|
||||
|
||||
void CSimulatorEmulated::highlightAircraft(const CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const CTime &displayTime)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, aircraftToHighlight.toQString(), boolToTrueFalse(enableHighlight), displayTime.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, aircraftToHighlight.toQString(), boolToTrueFalse(enableHighlight), displayTime.toQString());
|
||||
CSimulatorCommon::highlightAircraft(aircraftToHighlight, enableHighlight, displayTime);
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, commandLine, originator.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, commandLine, originator.toQString());
|
||||
return CSimulatorCommon::parseCommandLine(commandLine, originator);
|
||||
}
|
||||
|
||||
@@ -230,25 +233,25 @@ namespace BlackSimPlugin
|
||||
|
||||
bool CSimulatorEmulated::isConnected() const
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO);
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
|
||||
return m_connected;
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::isPaused() const
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO);
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
|
||||
return m_paused;
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::isSimulating() const
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO);
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
|
||||
return m_simulating;
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::physicallyAddRemoteAircraft(const CSimulatedAircraft &remoteAircraft)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, remoteAircraft.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, remoteAircraft.toQString());
|
||||
CSimulatedAircraft aircraft(remoteAircraft);
|
||||
aircraft.setRendered(true);
|
||||
m_renderedAircraft.push_back(aircraft);
|
||||
@@ -258,20 +261,20 @@ namespace BlackSimPlugin
|
||||
|
||||
bool CSimulatorEmulated::physicallyRemoveRemoteAircraft(const CCallsign &callsign)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, callsign.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, callsign.toQString());
|
||||
const int c = m_renderedAircraft.removeByCallsign(callsign);
|
||||
return c > 0;
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::setInterpolatorMode(CInterpolatorMulti::Mode mode, const CCallsign &callsign)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO, CInterpolatorMulti::modeToString(mode), callsign.toQString());
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, CInterpolatorMulti::modeToString(mode), callsign.toQString());
|
||||
return false;
|
||||
}
|
||||
|
||||
int CSimulatorEmulated::physicallyRemoveAllRemoteAircraft()
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendFunctionCall(Q_FUNC_INFO);
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
|
||||
return CSimulatorCommon::physicallyRemoveAllRemoteAircraft();
|
||||
}
|
||||
|
||||
@@ -319,6 +322,47 @@ namespace BlackSimPlugin
|
||||
this->updateOwnModel(settings.getOwnModel());
|
||||
}
|
||||
|
||||
void CSimulatorEmulated::connectOwnSignals()
|
||||
{
|
||||
//! \fixme signal name not hardcoded would be nice
|
||||
m_connectionGuard.append(connect(this, &ISimulator::simulatorStatusChanged, this, [ = ](SimulatorStatus status)
|
||||
{
|
||||
if (!m_monitorWidget) return;
|
||||
m_monitorWidget->appendSendingCall("simulatorStatusChanged", CSimulatorEmulated::statusToString(status));
|
||||
}));
|
||||
|
||||
m_connectionGuard.append(connect(this, &ISimulator::ownAircraftModelChanged, this, [ = ](CAircraftModel model)
|
||||
{
|
||||
if (!m_monitorWidget) return;
|
||||
m_monitorWidget->appendSendingCall("ownAircraftModelChanged", model.toQString());
|
||||
}));
|
||||
|
||||
m_connectionGuard.append(connect(this, &ISimulator::renderRestrictionsChanged, this, [ = ](bool restricted, bool enabled, int maxAircraft, const BlackMisc::PhysicalQuantities::CLength & maxRenderedDistance)
|
||||
{
|
||||
if (!m_monitorWidget) return;
|
||||
static const QString params("restricted: %1 enabled: %2 max aircraft: %3");
|
||||
m_monitorWidget->appendSendingCall("renderRestrictionsChanged", params.arg(boolToYesNo(restricted), boolToYesNo(enabled)).arg(maxAircraft), maxRenderedDistance.valueRoundedWithUnit(CLengthUnit::m(), 1));
|
||||
}));
|
||||
|
||||
m_connectionGuard.append(connect(this, &ISimulator::aircraftRenderingChanged, this, [ = ](const CSimulatedAircraft & aircraft)
|
||||
{
|
||||
if (!m_monitorWidget) return;
|
||||
m_monitorWidget->appendSendingCall("aircraftRenderingChanged", aircraft.toQString());
|
||||
}));
|
||||
|
||||
m_connectionGuard.append(connect(this, &ISimulator::physicallyAddingRemoteModelFailed, this, [ = ](const CSimulatedAircraft & aircraft)
|
||||
{
|
||||
if (!m_monitorWidget) return;
|
||||
m_monitorWidget->appendSendingCall("physicallyAddingRemoteModelFailed", aircraft.toQString());
|
||||
}));
|
||||
|
||||
m_connectionGuard.append(connect(this, &ISimulator::airspaceSnapshotHandled, this, [ = ]
|
||||
{
|
||||
if (!m_monitorWidget) return;
|
||||
m_monitorWidget->appendSendingCall("airspaceSnapshotHandled");
|
||||
}));
|
||||
}
|
||||
|
||||
CSimulatorEmulatedListener::CSimulatorEmulatedListener(const CSimulatorPluginInfo &info)
|
||||
: ISimulatorListener(info)
|
||||
{ }
|
||||
|
||||
Reference in New Issue
Block a user