diff --git a/src/blackmisc/aviation/modulator.cpp b/src/blackmisc/aviation/modulator.cpp index 71b07f5c6..4ee31ab13 100644 --- a/src/blackmisc/aviation/modulator.cpp +++ b/src/blackmisc/aviation/modulator.cpp @@ -72,13 +72,17 @@ namespace BlackMisc template void CModulator::setVolumeReceive(int volume) { - m_volumeReceive = volume; + if (volume >= 100) { m_volumeReceive = 100; } + else if (volume <= 0) { m_volumeReceive = 0; } + else { m_volumeReceive = volume; } } template void CModulator::setVolumeTransmit(int volume) { - m_volumeTransmit = volume; + if (volume >= 100) { m_volumeTransmit = 100; } + else if (volume <= 0) { m_volumeTransmit = 0; } + else { m_volumeTransmit = volume; } } template diff --git a/src/plugins/simulator/xplane/simulatorxplane.h b/src/plugins/simulator/xplane/simulatorxplane.h index 1bd588a7a..a017b953f 100644 --- a/src/plugins/simulator/xplane/simulatorxplane.h +++ b/src/plugins/simulator/xplane/simulatorxplane.h @@ -75,17 +75,23 @@ namespace BlackSimPlugin QString aircraftModelPath; //!< Aircraft model path QString aircraftIcaoCode; //!< Aircraft ICAO code double latitudeDeg; //!< Longitude [deg] - double longitudeDeg; //!< Latitude [deg] - double altitudeM; //!< Altitude [m] + double longitudeDeg; //!< Latitude [deg] + double altitudeM; //!< Altitude [m] double groundspeedMs; //!< Ground speed [m/s] double pitchDeg; //!< Pitch [deg] - double rollDeg; //!< Roll [deg] + double rollDeg; //!< Roll [deg] double trueHeadingDeg; //!< True heading [deg] bool onGroundAll; //!< All wheels on ground? - int com1ActiveKhz; //!< COM1 active [kHz] + int com1ActiveKhz; //!< COM1 active [kHz] int com1StandbyKhz; //!< COM1 standby [kHz] - int com2ActiveKhz; //!< COM2 active [kHz] + bool isCom1Receiving; //!< COM1 receiving + bool isCom1Transmitting; //!< COM1 transmittings + double com1Volume; //!< COM1 volume 0..1 + int com2ActiveKhz; //!< COM2 active [kHz] int com2StandbyKhz; //!< COM2 standby [kHz] + bool isCom2Receiving; //!< COM2 receiving + bool isCom2Transmitting; //!< COM2 transmittings + double com2Volume; //!< COM2 volume 0..1 int xpdrCode; //!< Transpondder code int xpdrMode; //!< Transponder mode (off=0,stdby=1,on=2,test=3) bool xpdrIdent; //!< Is transponder in ident? @@ -95,7 +101,7 @@ namespace BlackSimPlugin bool strobeLightsOn; //!< Strobe lights on? bool taxiLightsOn; //!< Taxi lights on? double flapsReployRatio; //!< Flaps deployment ratio [%] - double gearReployRatio; //!< Gear deployment ratio [%] + double gearReployRatio; //!< Gear deployment ratio [%] QList enginesN1Percentage; //!< N1 per engine [%] double speedBrakeRatio; //!< Speed break ratio [%] double seaLevelPressureInHg; //!< Sea level pressure [inhg] @@ -257,10 +263,11 @@ namespace BlackSimPlugin //! Reset the XPlane data void resetXPlaneData() { - m_xplaneData = { "", "", 0, 0, 0, 0, 0, 0, 0, false, 122800, 122800, 122800, 122800, 2000, 0, false, false, false, false, + m_xplaneData = { "", "", 0, 0, 0, 0, 0, 0, 0, false, + 122800, 122800, true, true, 1.0, 122800, 122800, true, true, 1.0, + 2000, 0, false, false, false, false, false, false, 0, 0, {}, 0.0, 0.0 }; - } }; diff --git a/src/plugins/simulator/xplane/xswiftbusserviceproxy.cpp b/src/plugins/simulator/xplane/xswiftbusserviceproxy.cpp index 8c23918dc..5e1e6bcf8 100644 --- a/src/plugins/simulator/xplane/xswiftbusserviceproxy.cpp +++ b/src/plugins/simulator/xplane/xswiftbusserviceproxy.cpp @@ -314,11 +314,42 @@ namespace BlackSimPlugin { return m_dbusInterface->callDBusRet(QLatin1String("getCom1StandbyKhz")); } + void CXSwiftBusServiceProxy::getCom1StandbyKhzAsync(int *o_com1Standby) { m_dbusInterface->callDBusAsync(QLatin1String("getCom1StandbyKhz"), setterCallback(o_com1Standby)); } + bool CXSwiftBusServiceProxy::isCom1Receiving() const + { + return m_dbusInterface->callDBusRet(QLatin1String("isCom1Receiving")); + } + + void CXSwiftBusServiceProxy::isCom1ReceivingAsync(bool *o_com1Rec) + { + m_dbusInterface->callDBusAsync(QLatin1String("isCom1Receiving"), setterCallback(o_com1Rec)); + } + + bool CXSwiftBusServiceProxy::isCom1Transmitting() const + { + return m_dbusInterface->callDBusRet(QLatin1String("isCom1Transmitting")); + } + + void CXSwiftBusServiceProxy::isCom1TransmittingAsync(bool *o_com1Tx) + { + m_dbusInterface->callDBusAsync(QLatin1String("isCom1Transmitting"), setterCallback(o_com1Tx)); + } + + double CXSwiftBusServiceProxy::getCom1Volume() const + { + return m_dbusInterface->callDBusRet(QLatin1String("getCom1Volume")); + } + + void CXSwiftBusServiceProxy::getCom1VolumeAsync(double *o_com1Volume) + { + m_dbusInterface->callDBusAsync(QLatin1String("getCom1Volume"), setterCallback(o_com1Volume)); + } + int CXSwiftBusServiceProxy::getCom2ActiveKhz() const { return m_dbusInterface->callDBusRet(QLatin1String("getCom2ActiveKhz")); @@ -337,6 +368,36 @@ namespace BlackSimPlugin m_dbusInterface->callDBusAsync(QLatin1String("getCom2StandbyKhz"), setterCallback(o_com2Standby)); } + bool CXSwiftBusServiceProxy::isCom2Receiving() const + { + return m_dbusInterface->callDBusRet(QLatin1String("isCom2Receiving")); + } + + void CXSwiftBusServiceProxy::isCom2ReceivingAsync(bool *o_com2Rec) + { + m_dbusInterface->callDBusAsync(QLatin1String("isCom2Receiving"), setterCallback(o_com2Rec)); + } + + bool CXSwiftBusServiceProxy::isCom2Transmitting() const + { + return m_dbusInterface->callDBusRet(QLatin1String("isCom2Transmitting")); + } + + void CXSwiftBusServiceProxy::isCom2TransmittingAsync(bool *o_com2Tx) + { + m_dbusInterface->callDBusAsync(QLatin1String("isCom2Transmitting"), setterCallback(o_com2Tx)); + } + + double CXSwiftBusServiceProxy::getCom2Volume() const + { + return m_dbusInterface->callDBusRet(QLatin1String("getCom2Volume")); + } + + void CXSwiftBusServiceProxy::getCom2VolumeAsync(double *o_com2Volume) + { + m_dbusInterface->callDBusAsync(QLatin1String("getCom2Volume"), setterCallback(o_com2Volume)); + } + int CXSwiftBusServiceProxy::getTransponderCode() const { return m_dbusInterface->callDBusRet(QLatin1String("getTransponderCode")); diff --git a/src/plugins/simulator/xplane/xswiftbusserviceproxy.h b/src/plugins/simulator/xplane/xswiftbusserviceproxy.h index fdc61f215..ff17fc2b0 100644 --- a/src/plugins/simulator/xplane/xswiftbusserviceproxy.h +++ b/src/plugins/simulator/xplane/xswiftbusserviceproxy.h @@ -271,6 +271,24 @@ namespace BlackSimPlugin void getCom1StandbyKhzAsync(int *o_com1Standby); //! @} + //! \copydoc XSwiftBus::CService::isCom1Receiving + //! @{ + bool isCom1Receiving() const; + void isCom1ReceivingAsync(bool *o_com1Rec); + //! @} + + //! \copydoc XSwiftBus::CService::isCom1Transmitting + //! @{ + bool isCom1Transmitting() const; + void isCom1TransmittingAsync(bool *o_com1Tx); + //! @} + + //! \copydoc XSwiftBus::CService::getCom1Volume + //! @{ + double getCom1Volume() const; + void getCom1VolumeAsync(double *o_com1Volume); + //! @} + //! \copydoc XSwiftBus::CService::getCom2ActiveKhz //! @{ int getCom2ActiveKhz() const; @@ -283,6 +301,24 @@ namespace BlackSimPlugin void getCom2StandbyKhzAsync(int *o_com2Standby); //! @} + //! \copydoc XSwiftBus::CService::isCom2Receiving + //! @{ + bool isCom2Receiving() const; + void isCom2ReceivingAsync(bool *o_com2Rec); + //! @} + + //! \copydoc XSwiftBus::CService::isCom2Transmitting + //! @{ + bool isCom2Transmitting() const; + void isCom2TransmittingAsync(bool *o_com2Tx); + //! @} + + //! \copydoc XSwiftBus::CService::getCom2Volume + //! @{ + double getCom2Volume() const; + void getCom2VolumeAsync(double *o_com2Volume); + //! @} + //! \copydoc XSwiftBus::CService::getTransponderCode //! @{ int getTransponderCode() const; diff --git a/src/xswiftbus/service.cpp b/src/xswiftbus/service.cpp index 4a55b4fd8..5cbc4e226 100644 --- a/src/xswiftbus/service.cpp +++ b/src/xswiftbus/service.cpp @@ -507,6 +507,48 @@ namespace XSwiftBus sendDBusReply(sender, serial, getCom2StandbyKhz()); }); } + else if (message.getMethodName() == "isCom1Receiving") + { + queueDBusCall([ = ]() + { + sendDBusReply(sender, serial, isCom1Receiving()); + }); + } + else if (message.getMethodName() == "isCom1Transmitting") + { + queueDBusCall([ = ]() + { + sendDBusReply(sender, serial, isCom1Transmitting()); + }); + } + else if (message.getMethodName() == "getCom1Volume") + { + queueDBusCall([ = ]() + { + sendDBusReply(sender, serial, getCom1Volume()); + }); + } + else if (message.getMethodName() == "isCom2Receiving") + { + queueDBusCall([ = ]() + { + sendDBusReply(sender, serial, isCom2Receiving()); + }); + } + else if (message.getMethodName() == "isCom2Transmitting") + { + queueDBusCall([ = ]() + { + sendDBusReply(sender, serial, isCom2Transmitting()); + }); + } + else if (message.getMethodName() == "getCom2Volume") + { + queueDBusCall([ = ]() + { + sendDBusReply(sender, serial, getCom2Volume()); + }); + } else if (message.getMethodName() == "getTransponderCode") { queueDBusCall([ = ]() diff --git a/src/xswiftbus/service.h b/src/xswiftbus/service.h index 0198630d5..55a64281e 100644 --- a/src/xswiftbus/service.h +++ b/src/xswiftbus/service.h @@ -149,12 +149,42 @@ namespace XSwiftBus //! Get the current COM1 standby frequency in kHz int getCom1StandbyKhz() const { return m_com1Standby.get(); } + //! Get the COM1 power on/off + bool getCom1Power() const { return m_com1Power.get(); } + + //! Get the COM1 listening yes/no + bool getCom1Listening() const { return m_com1Listening.get(); } + + //! Get the COM1 volume 0..1 + float getCom1Volume() const { return m_com1Volume.get(); } + + //! Is COM1 receiving? + bool isCom1Receiving() const { return this->getCom1Power() && this->getCom1Listening(); } + + //! Is COM1 transmitting? + bool isCom1Transmitting() const { return this->getCom1Power(); } + //! Get the current COM2 active frequency in kHz int getCom2ActiveKhz() const { return m_com2Active.get(); } //! Get the current COM2 standby frequency in kHz int getCom2StandbyKhz() const { return m_com2Standby.get(); } + //! Get the COM2 power on/off + bool getCom2Power() const { return m_com2Power.get(); } + + //! Get the COM2 listening yes/no + bool getCom2Listening() const { return m_com2Listening.get(); } + + //! Get the COM2 volume 0..1 + float getCom2Volume() const { return m_com2Volume.get(); } + + //! Is COM2 receiving? + bool isCom2Receiving() const { return this->getCom2Power() && this->getCom2Listening(); } + + //! Is COM2 transmitting? + bool isCom2Transmitting() const { return this->getCom2Power(); } + //! Get the current transponder code in decimal int getTransponderCode() const { return m_xpdrCode.get(); } @@ -267,6 +297,7 @@ namespace XSwiftBus void readAirportsDatabase(); std::vector findClosestAirports(int number, double latitude, double longitude); + //! Redraw message box after reading from the settings void updateMessageBoxFromSettings(); StringDataRef m_liveryPath; @@ -288,8 +319,14 @@ namespace XSwiftBus DataRef m_onGroundAll; DataRef m_com1Active; DataRef m_com1Standby; + DataRef m_com1Power; + DataRef m_com1Volume; // 0..1 + DataRef m_com1Listening; DataRef m_com2Active; DataRef m_com2Standby; + DataRef m_com2Power; + DataRef m_com2Volume; // 0..1 + DataRef m_com2Listening; DataRef m_xpdrCode; DataRef m_xpdrMode; DataRef m_xpdrIdent;