Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/core/context/contextownaircraft.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,16 @@ namespace swift::core::context
//! Set XPDR mode
virtual bool setTransponderMode(swift::misc::aviation::CTransponder::TransponderMode mode) = 0;

//! Tune in a COM frequency
//! Tune in a COM frequency (active)
virtual bool updateActiveComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit comUnit,
const swift::misc::CIdentifier &originator) = 0;

//! Tune in a COM frequency (standby)
virtual bool updateStandbyComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit comUnit,
const swift::misc::CIdentifier &originator) = 0;

//! Set current pilot
virtual bool updateOwnAircraftPilot(const swift::misc::network::CUser &pilot) = 0;

Expand Down
12 changes: 12 additions & 0 deletions src/core/context/contextownaircraftempty.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ namespace swift::core::context
return false;
}

//! \copydoc IContextOwnAircraft::updateStandbyComFrequency
bool updateStandbyComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit comUnit,
const swift::misc::CIdentifier &originator) override
{
Q_UNUSED(frequency);
Q_UNUSED(comUnit);
Q_UNUSED(originator);
logEmptyContextWarning(Q_FUNC_INFO);
return false;
}

//! \copydoc IContextOwnAircraft::updateOwnAircraftPilot
bool updateOwnAircraftPilot(const swift::misc::network::CUser &pilot) override
{
Expand Down
20 changes: 20 additions & 0 deletions src/core/context/contextownaircraftimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,26 @@ namespace swift::core::context
return changed;
}

bool CContextOwnAircraft::updateStandbyComFrequency(const CFrequency &frequency, CComSystem::ComUnit unit,
const CIdentifier &originator)
{
if (unit != CComSystem::Com1 && unit != CComSystem::Com2) { return false; }
if (!CComSystem::isValidComFrequency(frequency)) { return false; }
CComSystem com1, com2;
CTransponder xpdr;
{
QReadLocker l(&m_lockAircraft);
com1 = m_ownAircraft.getCom1System();
com2 = m_ownAircraft.getCom2System();
xpdr = m_ownAircraft.getTransponder();
}
if (unit == CComSystem::Com1) { com1.setFrequencyStandby(frequency); }
else { com2.setFrequencyStandby(frequency); }

const bool changed = this->updateCockpit(com1, com2, xpdr, originator);
return changed;
}

bool CContextOwnAircraft::updateOwnAircraftPilot(const CUser &pilot)
{
{
Expand Down
5 changes: 5 additions & 0 deletions src/core/context/contextownaircraftimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ namespace swift::core
swift::misc::aviation::CComSystem::ComUnit comUnit,
const swift::misc::CIdentifier &originator) override;

//! \copydoc IContextOwnAircraft::updateStandbyComFrequency
bool updateStandbyComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit comUnit,
const swift::misc::CIdentifier &originator) override;

//! \copydoc IContextOwnAircraft::updateOwnAircraftPilot
bool updateOwnAircraftPilot(const swift::misc::network::CUser &pilot) override;

Expand Down
8 changes: 8 additions & 0 deletions src/core/context/contextownaircraftproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ namespace swift::core::context
originator);
}

bool CContextOwnAircraftProxy::updateStandbyComFrequency(const physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit comUnit,
const CIdentifier &originator)
{
return m_dBusInterface->callDBusRet<bool>(QLatin1String("updateStandbyComFrequency"), frequency, comUnit,
originator);
}

bool CContextOwnAircraftProxy::updateOwnAircraftPilot(const swift::misc::network::CUser &pilot)
{
return m_dBusInterface->callDBusRet<bool>(QLatin1String("updateOwnAircraftPilot"), pilot);
Expand Down
5 changes: 5 additions & 0 deletions src/core/context/contextownaircraftproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ namespace swift::core
swift::misc::aviation::CComSystem::ComUnit comUnit,
const swift::misc::CIdentifier &originator) override;

//! \copydoc swift::core::context::IContextOwnAircraft::updateStandbyComFrequency
bool updateStandbyComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit comUnit,
const swift::misc::CIdentifier &originator) override;

//! \copydoc swift::core::context::IContextOwnAircraft::updateOwnAircraftPilot
bool updateOwnAircraftPilot(const swift::misc::network::CUser &pilot) override;

Expand Down
4 changes: 4 additions & 0 deletions src/core/context/contextsimulatorimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,12 +802,15 @@ namespace swift::core::context
{
Q_UNUSED(from)
SWIFT_VERIFY_X(this->getIContextNetwork(), Q_FUNC_INFO, "Missing network context");
SWIFT_VERIFY_X(this->getIContextOwnAircraft(), Q_FUNC_INFO, "Missing own aircraft context");
if (to.isConnected() && this->getIContextNetwork())
{
m_networkSessionId = this->getIContextNetwork()->getConnectedServer().getServerSessionId(false);
if (m_simulatorPlugin.second) // check in case the plugin has been unloaded
{
m_simulatorPlugin.second->setFlightNetworkConnected(true);
m_simulatorPlugin.second->setOwnCallsign(
this->getIContextOwnAircraft()->getOwnAircraft().getCallsign());
}
}
else if (to.isDisconnected())
Expand All @@ -821,6 +824,7 @@ namespace swift::core::context
{
m_simulatorPlugin.second->removeAllRemoteAircraft(); // also removes aircraft
m_simulatorPlugin.second->setFlightNetworkConnected(false);
m_simulatorPlugin.second->setOwnCallsign({});
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/core/simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ namespace swift::core

void ISimulator::setFlightNetworkConnected(bool connected) { m_networkConnected = connected; }

void ISimulator::setOwnCallsign(const CCallsign &callsign)
{
Q_UNUSED(callsign)
// void
}

void ISimulator::clearAllRemoteAircraftData()
{
// rendering related stuff
Expand Down
3 changes: 3 additions & 0 deletions src/core/simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ namespace swift::core
//! \sa ISimulator::isFlightNetworkConnected
virtual void setFlightNetworkConnected(bool connected);

//! Own callsign has changed
virtual void setOwnCallsign(const swift::misc::aviation::CCallsign &callsign);

//! Is the flight network connected
bool isFlightNetworkConnected() const { return m_networkConnected; }

Expand Down
5 changes: 3 additions & 2 deletions src/gui/components/atcstationcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,12 @@ namespace swift::gui::components
}

void CAtcStationComponent::setComFrequency(const physical_quantities::CFrequency &frequency,
CComSystem::ComUnit unit)
CComSystem::ComUnit unit, bool active)
{
if (unit != CComSystem::Com1 && unit != CComSystem::Com2) { return; }
if (!CComSystem::isValidComFrequency(frequency)) { return; }
sGui->getIContextOwnAircraft()->updateActiveComFrequency(frequency, unit, identifier());
if (active) { sGui->getIContextOwnAircraft()->updateActiveComFrequency(frequency, unit, identifier()); }
else { sGui->getIContextOwnAircraft()->updateStandbyComFrequency(frequency, unit, identifier()); }
}

void CAtcStationComponent::settingsChanged()
Expand Down
2 changes: 1 addition & 1 deletion src/gui/components/atcstationcomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ namespace swift::gui

//! Set COM frequency
void setComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit unit);
swift::misc::aviation::CComSystem::ComUnit unit, bool active);

//! Airports read from web readers
void airportsRead();
Expand Down
25 changes: 12 additions & 13 deletions src/gui/views/atcstationtreeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,24 @@ namespace swift::gui::views

auto *menu = new QMenu(this); // menu

auto *com1 = new QAction(CIcons::appCockpit16(), "Tune in COM1", this);
auto *com2 = new QAction(CIcons::appCockpit16(), "Tune in COM2", this);
auto *com1 = new QAction(CIcons::appCockpit16(), "Tune in COM1 (active)", this);
auto *com2 = new QAction(CIcons::appCockpit16(), "Tune in COM2 (active)", this);
auto *com1_stby = new QAction(CIcons::appCockpit16(), "Tune in COM1 (standby)", this);
auto *com2_stby = new QAction(CIcons::appCockpit16(), "Tune in COM2 (standby)", this);
auto *text = new QAction(CIcons::appTextMessages16(), "Show text messages", this);
auto *resize = new QAction(CIcons::resize16(), "Resize", this);

connect(com1, &QAction::triggered, this, &CAtcStationTreeView::tuneInAtcCom1);
connect(com2, &QAction::triggered, this, &CAtcStationTreeView::tuneInAtcCom2);
connect(com1, &QAction::triggered, this, [this]() { tuneInAtc(CComSystem::Com1, true); });
connect(com2, &QAction::triggered, this, [this]() { tuneInAtc(CComSystem::Com2, true); });
connect(com1_stby, &QAction::triggered, this, [this]() { tuneInAtc(CComSystem::Com1, false); });
connect(com2_stby, &QAction::triggered, this, [this]() { tuneInAtc(CComSystem::Com2, false); });
connect(text, &QAction::triggered, this, &CAtcStationTreeView::requestTextMessage);
connect(resize, &QAction::triggered, this, &CAtcStationTreeView::fullResizeToContentsImpl);

menu->addAction(com1);
menu->addAction(com2);
menu->addAction(com1_stby);
menu->addAction(com2_stby);
menu->addAction(text);
menu->addSeparator();
menu->addAction(resize);
Expand Down Expand Up @@ -160,18 +166,11 @@ namespace swift::gui::views
}
}

void CAtcStationTreeView::tuneInAtcCom1()
void CAtcStationTreeView::tuneInAtc(const misc::aviation::CComSystem::ComUnit unit, const bool active)
{
const CAtcStation s(this->selectedObject());
if (s.getCallsign().isEmpty()) { return; }
emit this->requestComFrequency(s.getFrequency(), CComSystem::Com1);
}

void CAtcStationTreeView::tuneInAtcCom2()
{
const CAtcStation s(this->selectedObject());
if (s.getCallsign().isEmpty()) { return; }
emit this->requestComFrequency(s.getFrequency(), CComSystem::Com2);
emit this->requestComFrequency(s.getFrequency(), unit, active);
}

void CAtcStationTreeView::requestTextMessage()
Expand Down
5 changes: 2 additions & 3 deletions src/gui/views/atcstationtreeview.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace swift::gui

//! Request COM frequency
void requestComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit unit);
swift::misc::aviation::CComSystem::ComUnit unit, bool active);

//! Request a text message to
void requestTextMessageWidget(const swift::misc::aviation::CCallsign &callsign);
Expand Down Expand Up @@ -107,8 +107,7 @@ namespace swift::gui

//! @{
//! Tune in/invoke
void tuneInAtcCom1();
void tuneInAtcCom2();
void tuneInAtc(misc::aviation::CComSystem::ComUnit unit, bool active);
void requestTextMessage();
//! @}

Expand Down
35 changes: 17 additions & 18 deletions src/gui/views/atcstationview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,33 +57,32 @@ namespace swift::gui::views

if (this->hasSelection())
{
if (m_actions.isEmpty()) { m_actions = QList<QAction *>({ nullptr, nullptr, nullptr }); }
if (m_actions.isEmpty()) { m_actions = QList<QAction *>({ nullptr, nullptr, nullptr, nullptr, nullptr }); }

m_actions[0] =
menuActions.addAction(m_actions[0], CIcons::appCockpit16(), "Tune in COM1",
CMenuAction::pathClientCom(), { this, &CAtcStationView::tuneInAtcCom1 });
m_actions[1] =
menuActions.addAction(m_actions[1], CIcons::appCockpit16(), "Tune in COM2",
CMenuAction::pathClientCom(), { this, &CAtcStationView::tuneInAtcCom2 });
m_actions[2] =
menuActions.addAction(m_actions[2], CIcons::appTextMessages16(), "Show text messages",
m_actions[0] = menuActions.addAction(m_actions[0], CIcons::appCockpit16(), "Tune in COM1 (active)",
CMenuAction::pathClientCom(),
{ this, [this]() { tuneInAtc(CComSystem::Com1, true); } });
m_actions[1] = menuActions.addAction(m_actions[1], CIcons::appCockpit16(), "Tune in COM2 (active)",
CMenuAction::pathClientCom(),
{ this, [this]() { tuneInAtc(CComSystem::Com2, true); } });
m_actions[2] = menuActions.addAction(m_actions[2], CIcons::appCockpit16(), "Tune in COM1 (standby)",
CMenuAction::pathClientCom(),
{ this, [this]() { tuneInAtc(CComSystem::Com1, false); } });
m_actions[3] = menuActions.addAction(m_actions[3], CIcons::appCockpit16(), "Tune in COM2 (standby)",
CMenuAction::pathClientCom(),
{ this, [this]() { tuneInAtc(CComSystem::Com2, false); } });
m_actions[4] =
menuActions.addAction(m_actions[4], CIcons::appTextMessages16(), "Show text messages",
CMenuAction::pathClientCom(), { this, &CAtcStationView::requestTextMessage });
}
CViewBase::customMenu(menuActions);
}

void CAtcStationView::tuneInAtcCom1()
void CAtcStationView::tuneInAtc(const misc::aviation::CComSystem::ComUnit unit, const bool active)
{
const CAtcStation s(this->selectedObject());
if (s.getCallsign().isEmpty()) { return; }
emit this->requestComFrequency(s.getFrequency(), CComSystem::Com1);
}

void CAtcStationView::tuneInAtcCom2()
{
const CAtcStation s(this->selectedObject());
if (s.getCallsign().isEmpty()) { return; }
emit this->requestComFrequency(s.getFrequency(), CComSystem::Com2);
emit this->requestComFrequency(s.getFrequency(), unit, active);
}

void CAtcStationView::requestTextMessage()
Expand Down
5 changes: 2 additions & 3 deletions src/gui/views/atcstationview.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace swift::gui

//! Request COM frequency
void requestComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit unit);
swift::misc::aviation::CComSystem::ComUnit unit, bool active);

//! Request a text message to
void requestTextMessageWidget(const swift::misc::aviation::CCallsign &callsign);
Expand All @@ -64,8 +64,7 @@ namespace swift::gui
private:
void emitTestRequest1kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(1000); }
void emitTestRequest3kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(3000); }
void tuneInAtcCom1();
void tuneInAtcCom2();
void tuneInAtc(misc::aviation::CComSystem::ComUnit unit, bool active);
void requestTextMessage();

QList<QAction *> m_actions; //!< real actions
Expand Down
6 changes: 0 additions & 6 deletions src/plugins/simulator/flightgear/fgswiftbusserviceproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ namespace swift::simplugin::flightgear
QString(), "/fgswiftbus/service", "org.swift_project.fgswiftbus.service", "aircraftModelChanged", this,
SIGNAL(aircraftModelChanged(QString, QString, QString, QString, QString, QString, QString)));
Q_ASSERT(s);

s = connection.connect(
QString(), "/fgswiftbus/service", "org.swift_project.fgswiftbus.service", "airportsInRangeUpdated",
this,
SIGNAL(airportsInRangeUpdated(QStringList, QStringList, QList<double>, QList<double>, QList<double>)));
Q_ASSERT(s);
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/plugins/simulator/xplane/simulatorxplane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,16 @@ namespace swift::simplugin::xplane
void CSimulatorXPlane::setFlightNetworkConnected(bool connected)
{
if (connected && !this->isShuttingDownOrDisconnected()) { m_serviceProxy->resetFrameTotals(); }
m_serviceProxy->setFlightNetworkConnected(connected);
CSimulatorPluginCommon::setFlightNetworkConnected(connected);
}

void CSimulatorXPlane::setOwnCallsign(const CCallsign &callsign)
{
m_serviceProxy->setOwnCallsign(callsign.asString());
CSimulatorPluginCommon::setOwnCallsign(callsign);
}

bool CSimulatorXPlane::isSuspiciousTerrainValue(const CElevationPlane &elevation)
{
if (!elevation.hasMSLGeodeticHeight()) { return true; }
Expand Down
1 change: 1 addition & 0 deletions src/plugins/simulator/xplane/simulatorxplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ namespace swift::simplugin::xplane
const swift::misc::aviation::CCallsign &callsign,
bool isWater) override;
void setFlightNetworkConnected(bool connected) override;
void setOwnCallsign(const swift::misc::aviation::CCallsign &callsign) override;
//! @}

//! \copydoc swift::misc::simulation::ISimulationEnvironmentProvider::requestElevation
Expand Down
15 changes: 10 additions & 5 deletions src/plugins/simulator/xplane/xswiftbusserviceproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ namespace swift::simplugin::xplane
SIGNAL(aircraftModelChanged(QString, QString, QString, QString, QString, QString, QString)));
Q_ASSERT(s);

s = connection.connect(
QString(), "/xswiftbus/service", "org.swift_project.xswiftbus.service", "airportsInRangeUpdated", this,
SIGNAL(airportsInRangeUpdated(QStringList, QStringList, QList<double>, QList<double>, QList<double>)));
Q_ASSERT(s);

s = connection.connect(QString(), "/xswiftbus/service", "org.swift_project.xswiftbus.service",
"sceneryLoaded", this, SIGNAL(sceneryLoaded()));
Q_ASSERT(s);
Expand Down Expand Up @@ -363,6 +358,16 @@ namespace swift::simplugin::xplane

void CXSwiftBusServiceProxy::resetFrameTotals() { m_dbusInterface->callDBus(QLatin1String("resetFrameTotals")); }

void CXSwiftBusServiceProxy::setFlightNetworkConnected(bool connected)
{
m_dbusInterface->callDBus(QLatin1String("setFlightNetworkConnected"), connected);
}

void CXSwiftBusServiceProxy::setOwnCallsign(const QString &callsign)
{
m_dbusInterface->callDBus(QLatin1String("setOwnCallsign"), callsign);
}

double CXSwiftBusServiceProxy::getLatitudeDeg() const
{
return m_dbusInterface->callDBusRet<double>(QLatin1String("getLatitudeDeg"));
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/simulator/xplane/xswiftbusserviceproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ namespace swift::simplugin::xplane
//! \copydoc XSwiftBus::CService::resetFrameTotals
void resetFrameTotals();

//! \copydoc XSwiftBus::CService::setFlightNetworkConnected
void setFlightNetworkConnected(bool connected);

//! \copydoc XSwiftBus::CService::setOwnCallsign
void setOwnCallsign(const QString &callsign);

//! @{
//! \copydoc XSwiftBus::CService::getLatitudeDeg
double getLatitudeDeg() const;
Expand Down
Loading
Loading