mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 11:25:33 +08:00
Issue #100 [FG] Get COM values from simulator
This commit is contained in:
committed by
Mat Sutcliffe
parent
c1b75f7532
commit
2a69f10ce2
@@ -242,6 +242,25 @@ namespace BlackSimPlugin
|
|||||||
m_dbusInterface->callDBusAsync(QLatin1String("getCom2ActiveKhz"), setterCallback(o_com2Active));
|
m_dbusInterface->callDBusAsync(QLatin1String("getCom2ActiveKhz"), setterCallback(o_com2Active));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double CFGSwiftBusServiceProxy::getCom1Volume() const
|
||||||
|
{
|
||||||
|
return m_dbusInterface->callDBusRet<double>(QLatin1String("getCom1Volume"));
|
||||||
|
}
|
||||||
|
void CFGSwiftBusServiceProxy::getCom1VolumeAsync(double *o_com1Volume)
|
||||||
|
{
|
||||||
|
m_dbusInterface->callDBusAsync(QLatin1String("getCom1Volume"), setterCallbackWithDefault(o_com1Volume, 0.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
double CFGSwiftBusServiceProxy::getCom2Volume() const
|
||||||
|
{
|
||||||
|
return m_dbusInterface->callDBusRet<double>(QLatin1String("getCom2Volume"));
|
||||||
|
}
|
||||||
|
void CFGSwiftBusServiceProxy::getCom2VolumeAsync(double *o_com2Volume)
|
||||||
|
{
|
||||||
|
m_dbusInterface->callDBusAsync(QLatin1String("getCom2Volume"), setterCallbackWithDefault(o_com2Volume, 0.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int CFGSwiftBusServiceProxy::getCom2StandbyKhz() const
|
int CFGSwiftBusServiceProxy::getCom2StandbyKhz() const
|
||||||
{
|
{
|
||||||
return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom2StandbyKhz"));
|
return m_dbusInterface->callDBusRet<int>(QLatin1String("getCom2StandbyKhz"));
|
||||||
|
|||||||
@@ -84,6 +84,25 @@ namespace BlackSimPlugin
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::function<void(QDBusPendingCallWatcher *)> setterCallbackWithDefault(T *obj, T defaultValue)
|
||||||
|
{
|
||||||
|
return [this, obj, defaultValue](QDBusPendingCallWatcher * watcher)
|
||||||
|
{
|
||||||
|
QDBusPendingReply<T> reply = *watcher;
|
||||||
|
if (reply.isError())
|
||||||
|
{
|
||||||
|
if (reply.error().type() == QDBusError::UnknownMethod)
|
||||||
|
*obj = defaultValue;
|
||||||
|
else
|
||||||
|
emit this->asyncMethodError(reply.error());
|
||||||
|
}
|
||||||
|
else { *obj = reply; }
|
||||||
|
watcher->deleteLater();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Emitted if an asynchronous method call caused a DBus error
|
//! Emitted if an asynchronous method call caused a DBus error
|
||||||
BLACK_NO_RELAY void asyncMethodError(QDBusError error);
|
BLACK_NO_RELAY void asyncMethodError(QDBusError error);
|
||||||
@@ -214,6 +233,18 @@ namespace BlackSimPlugin
|
|||||||
void getCom1StandbyKhzAsync(int *o_com1Standby);
|
void getCom1StandbyKhzAsync(int *o_com1Standby);
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
//! Get Com1 volume [0..1]
|
||||||
|
//! @{
|
||||||
|
double getCom1Volume() const;
|
||||||
|
void getCom1VolumeAsync(double *o_com1Volume);
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
//! Get Com2 volume [0..1]
|
||||||
|
//! @{
|
||||||
|
double getCom2Volume() const;
|
||||||
|
void getCom2VolumeAsync(double *o_com2Volume);
|
||||||
|
//! @}
|
||||||
|
|
||||||
//! Get the current COM2 active frequency in kHz
|
//! Get the current COM2 active frequency in kHz
|
||||||
//! @{
|
//! @{
|
||||||
int getCom2ActiveKhz() const;
|
int getCom2ActiveKhz() const;
|
||||||
|
|||||||
@@ -210,6 +210,8 @@ namespace BlackSimPlugin
|
|||||||
m_serviceProxy->getTransponderIdentAsync(&m_flightgearData.xpdrIdent);
|
m_serviceProxy->getTransponderIdentAsync(&m_flightgearData.xpdrIdent);
|
||||||
m_serviceProxy->getAllWheelsOnGroundAsync(&m_flightgearData.onGroundAll);
|
m_serviceProxy->getAllWheelsOnGroundAsync(&m_flightgearData.onGroundAll);
|
||||||
m_serviceProxy->getGroundElevationAsync(&m_flightgearData.groundElevation);
|
m_serviceProxy->getGroundElevationAsync(&m_flightgearData.groundElevation);
|
||||||
|
m_serviceProxy->getCom1VolumeAsync(&m_flightgearData.volumeCom1);
|
||||||
|
m_serviceProxy->getCom2VolumeAsync(&m_flightgearData.volumeCom2);
|
||||||
|
|
||||||
CAircraftSituation situation;
|
CAircraftSituation situation;
|
||||||
situation.setPosition({ m_flightgearData.latitudeDeg, m_flightgearData.longitudeDeg, 0 });
|
situation.setPosition({ m_flightgearData.latitudeDeg, m_flightgearData.longitudeDeg, 0 });
|
||||||
@@ -235,10 +237,12 @@ namespace BlackSimPlugin
|
|||||||
// updates
|
// updates
|
||||||
com1.setFrequencyActive(CFrequency(m_flightgearData.com1ActiveKhz, CFrequencyUnit::kHz()));
|
com1.setFrequencyActive(CFrequency(m_flightgearData.com1ActiveKhz, CFrequencyUnit::kHz()));
|
||||||
com1.setFrequencyStandby(CFrequency(m_flightgearData.com1StandbyKhz, CFrequencyUnit::kHz()));
|
com1.setFrequencyStandby(CFrequency(m_flightgearData.com1StandbyKhz, CFrequencyUnit::kHz()));
|
||||||
|
com1.setVolumeReceive(qRound(m_flightgearData.volumeCom1*100));
|
||||||
const bool changedCom1 = myAircraft.getCom1System() != com1;
|
const bool changedCom1 = myAircraft.getCom1System() != com1;
|
||||||
|
|
||||||
com2.setFrequencyActive(CFrequency(m_flightgearData.com2ActiveKhz, CFrequencyUnit::kHz()));
|
com2.setFrequencyActive(CFrequency(m_flightgearData.com2ActiveKhz, CFrequencyUnit::kHz()));
|
||||||
com2.setFrequencyStandby(CFrequency(m_flightgearData.com2StandbyKhz, CFrequencyUnit::kHz()));
|
com2.setFrequencyStandby(CFrequency(m_flightgearData.com2StandbyKhz, CFrequencyUnit::kHz()));
|
||||||
|
com2.setVolumeReceive(qRound(m_flightgearData.volumeCom2*100));
|
||||||
const bool changedCom2 = myAircraft.getCom2System() != com2;
|
const bool changedCom2 = myAircraft.getCom2System() != com2;
|
||||||
|
|
||||||
transponder = CTransponder::getStandardTransponder(m_flightgearData.xpdrCode, xpdrMode(m_flightgearData.xpdrMode, m_flightgearData.xpdrIdent));
|
transponder = CTransponder::getStandardTransponder(m_flightgearData.xpdrCode, xpdrMode(m_flightgearData.xpdrMode, m_flightgearData.xpdrIdent));
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ namespace BlackSimPlugin
|
|||||||
double speedBrakeRatio; //!< Speed break ratio [%]
|
double speedBrakeRatio; //!< Speed break ratio [%]
|
||||||
double pressureAltitudeFt; //!< Pressure altitude [inhg]
|
double pressureAltitudeFt; //!< Pressure altitude [inhg]
|
||||||
double groundElevation; //!< Ground Elevation [m]
|
double groundElevation; //!< Ground Elevation [m]
|
||||||
|
double volumeCom1; //!< Volume com1 [0..1]
|
||||||
|
double volumeCom2; //!< Volume com2 [0..1]
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Flightgear ISimulator implementation
|
//! Flightgear ISimulator implementation
|
||||||
@@ -242,7 +244,7 @@ namespace BlackSimPlugin
|
|||||||
void resetFlightgearData()
|
void resetFlightgearData()
|
||||||
{
|
{
|
||||||
m_flightgearData = { "", "", 0, 0, 0, 0, 0, 0, 0, false, 122800, 122800, 122800, 122800, 2000, 0, false, false, false, false,
|
m_flightgearData = { "", "", 0, 0, 0, 0, 0, 0, 0, false, 122800, 122800, 122800, 122800, 2000, 0, false, false, false, false,
|
||||||
false, false, 0, 0, {}, 0.0, 0.0, 0.0
|
false, false, 0, 0, {}, 0.0, 0.0, 0.0, 1.0, 1.0
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user