Ref T609, tristate LED showing if synced with simulator com

This commit is contained in:
Klaus Basan
2019-04-20 01:03:53 +02:00
parent 90373c3a34
commit 2d654e2fef
7 changed files with 51 additions and 13 deletions

View File

@@ -343,7 +343,7 @@ namespace BlackCore
const bool c = m_simulatorPlugin.second->setTimeSynchronization(enable, offset);
if (!c) { return false; }
CLogMessage(this).info(enable ? QStringLiteral("Set time syncronization to %1").arg(offset.toQString()) : QStringLiteral("Disabled time syncrhonization"));
CLogMessage(this).info(enable ? QStringLiteral("Set time synchronization to %1").arg(offset.toQString()) : QStringLiteral("Disabled time syncrhonization"));
return true;
}

View File

@@ -8,6 +8,7 @@
#include "blackcore/context/contextaudio.h"
#include "blackcore/context/contextnetwork.h"
#include "blackcore/context/contextsimulator.h"
#include "blackcore/context/contextownaircraft.h"
#include "blackgui/components/cockpitcomcomponent.h"
#include "blackgui/components/selcalcodeselector.h"
@@ -72,11 +73,14 @@ namespace BlackGui
connect(ui->editor_Com, &CCockpitComForm::transponderStateIdentEnded, this, &CCockpitComComponent::transponderStateIdentEnded);
// hook up with changes from own aircraft context
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CCockpitComComponent::updateCockpitFromContext, Qt::QueuedConnection);
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedSelcal, this, &CCockpitComComponent::updateSelcalFromContext, Qt::QueuedConnection);
if (sGui)
{
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CCockpitComComponent::updateCockpitFromContext, Qt::QueuedConnection);
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedSelcal, this, &CCockpitComComponent::updateSelcalFromContext, Qt::QueuedConnection);
// hook up with audio context
connect(sGui->getIContextAudio(), &IContextAudio::changedVoiceRooms, this, &CCockpitComComponent::updateVoiceRoomStatusFromContext, Qt::QueuedConnection);
// hook up with audio context
connect(sGui->getIContextAudio(), &IContextAudio::changedVoiceRooms, this, &CCockpitComComponent::updateVoiceRoomStatusFromContext, Qt::QueuedConnection);
}
}
CCockpitComComponent::~CCockpitComComponent()
@@ -110,10 +114,13 @@ namespace BlackGui
ui->editor_Com->setTransponder(transponder);
// selected stations
if (sGui && sGui->getIContextNetwork())
if (sGui)
{
const CAtcStationList selectedStations = sGui->getIContextNetwork()->getSelectedAtcStations();
ui->editor_Com->setSelectedAtcStations(selectedStations);
if (sGui->getIContextNetwork())
{
const CAtcStationList selectedStations = sGui->getIContextNetwork()->getSelectedAtcStations();
ui->editor_Com->setSelectedAtcStations(selectedStations);
}
}
}

View File

@@ -26,7 +26,6 @@
#include <QScopedPointer>
class QPaintEvent;
class QWidget;
namespace Ui { class CCockpitComComponent; }
namespace BlackMisc { namespace Aviation { class CComSystem; } }

View File

@@ -8,6 +8,8 @@
#include "cockpitcomform.h"
#include "ui_cockpitcomform.h"
#include "blackgui/guiapplication.h"
#include "blackcore/context/contextsimulator.h"
#include "blackmisc/math/mathutils.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/icons.h"
@@ -38,7 +40,7 @@ namespace BlackGui
connect(ui->tb_ComPanelSelcalTest, &QPushButton::clicked, this, &CCockpitComForm::testSelcal);
connect(ui->frp_ComPanelSelcalSelector, &CSelcalCodeSelector::valueChanged, this, &CCockpitComForm::onSelcalChanged);
// XPdr
// XPDR
connect(ui->cbp_ComPanelTransponderMode, &CTransponderModeSelector::transponderModeChanged, this, &CCockpitComForm::transponderModeChanged);
connect(ui->cbp_ComPanelTransponderMode, &CTransponderModeSelector::transponderStateIdentEnded, this, &CCockpitComForm::transponderStateIdentEnded);
@@ -155,9 +157,13 @@ namespace BlackGui
ui->led_ComPanelCom1R->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "COM1 receive (sim)", "COM1 not receiving", 14);
ui->led_ComPanelCom1S->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "COM1 trasmit (sim)", "COM1 not transmitting", 14);
ui->led_ComPanelCom1R->setTriStateValues(CLedWidget::Blue, "receive not synced");
ui->led_ComPanelCom1S->setTriStateValues(CLedWidget::Blue, "transmit not synced");
ui->led_ComPanelCom2R->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "COM2 receive (sim)", "COM2 not receiving", 14);
ui->led_ComPanelCom2S->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "COM2 trasmit (sim)", "COM2 not transmitting", 14);
ui->led_ComPanelCom2R->setTriStateValues(CLedWidget::Blue, "receive not synced");
ui->led_ComPanelCom2S->setTriStateValues(CLedWidget::Blue, "transmit not synced");
}
CSimulatedAircraft CCockpitComForm::cockpitValuesToAircraftObject()
@@ -223,6 +229,7 @@ namespace BlackGui
ui->ds_ComPanelCom2Standby->setValue(freq);
}
this->updateIntegrateFromSimulatorContext();
this->updateActiveCOMUnitLEDs(m_integratedWithSim, com1.isSendEnabled(), com1.isReceiveEnabled(), com2.isSendEnabled(), com2.isReceiveEnabled());
}
@@ -306,6 +313,17 @@ namespace BlackGui
}
}
void CCockpitComForm::updateIntegrateFromSimulatorContext()
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator())
{
m_integratedWithSim = false;
return;
}
const bool integrated = sGui->getIContextSimulator()->getSimulatorSettings().isComIntegrated();
m_integratedWithSim = integrated;
}
bool CCockpitComForm::isFrequenceEqual(double f1, double f2)
{
return CMathUtils::epsilonEqual(f1, f2);

View File

@@ -91,6 +91,8 @@ namespace BlackGui
//! @}
private:
bool m_integratedWithSim = false; //!< Synced with simulator
//! Init LEDs
void initLeds();
@@ -109,6 +111,9 @@ namespace BlackGui
//! Update UI for COM unit
void updateActiveCOMUnitLEDs(bool integratedWithSim, bool com1S, bool com1R, bool com2S, bool com2R);
//! Update from simulator context
void updateIntegrateFromSimulatorContext();
//! Compare 2 frequencies (consider epsilon)
static bool isFrequenceEqual(double f1, double f2);

View File

@@ -163,12 +163,18 @@ namespace BlackGui
this->setLed();
}
void CLedWidget::setTriStateToolTip(const QString &triState)
void CLedWidget::setTriStateToolTip(const QString &triStateTooltip)
{
m_tooltipTriState = triState;
m_tooltipTriState = triStateTooltip;
this->setLed();
}
void CLedWidget::setTriStateValues(CLedWidget::LedColor color, const QString &tooltip)
{
m_tooltipTriState = tooltip;
m_colorTriState = color;
}
void CLedWidget::setOnColor(LedColor color)
{
if (color == m_colorOn) return;

View File

@@ -119,7 +119,10 @@ namespace BlackGui
void setOffToolTip(const QString &off);
//! Tri-state tool tip
void setTriStateToolTip(const QString &triState);
void setTriStateToolTip(const QString &triStateTooltip);
//! Tri-state
void setTriStateValues(LedColor color, const QString &tooltip);
//! New values dual state
void setValues(LedColor onColor, LedColor offColor, LedShape shape, const QString &toolTipOn, const QString &toolTipOff, int width = -1);