8 #include "ui_infobarwebreadersstatuscomponent.h"
17 using namespace swift::misc::network;
21 CInfoBarWebReadersStatusBase::CInfoBarWebReadersStatusBase(QWidget *parent) : QFrame(parent) {}
25 Q_ASSERT_X(
sGui, Q_FUNC_INFO,
"No sGui");
29 m_timer.setInterval(30 * 1000);
31 m_timer.setObjectName(
"CInfoBarWebReadersStatusBase::CheckSwiftDbTimer");
33 Q_ASSERT_X(c, Q_FUNC_INFO,
"Failed connect");
39 Q_ASSERT_X(c, Q_FUNC_INFO,
"Failed connect");
49 if (!m_ledConsolidation) {
return; }
50 m_ledConsolidation->
setOn(running);
56 m_ledDataReady->
setValues(CLedWidget::Yellow, CLedWidget::Black, shape,
"all data ready",
"data missing", 14);
57 if (m_ledConsolidation)
59 m_ledConsolidation->
setValues(CLedWidget::Blue, CLedWidget::Black, shape,
"consolidation running",
"idle",
63 m_ledIcaoAircraft->
setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape,
"reading",
"idle",
65 m_ledIcaoAirline->
setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape,
"reading",
"idle",
67 m_ledCountries->
setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape,
"reading",
"idle",
69 m_ledModels->
setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape,
"reading",
"idle",
71 m_ledLiveries->
setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape,
"reading",
"idle",
73 m_ledDistributors->
setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape,
"reading",
"idle",
88 m_ledDataReady->
setOn(allData);
93 if (m_ledConsolidation) { m_ledConsolidation->setVisible(show); }
104 Q_ASSERT_X(led, Q_FUNC_INFO,
"no LED");
105 const int resetTimeMs = qRound(2.5 * 1000);
108 case CEntityFlags::ReadSkipped:
109 case CEntityFlags::ReadFinished:
110 case CEntityFlags::ReadFinishedRestricted:
112 led->
blink(resetTimeMs);
114 case CEntityFlags::ReadStarted:
115 case CEntityFlags::ReadParsing: led->
setOn(
true);
break;
116 case CEntityFlags::ReadFailed: led->
setTriState(2 * resetTimeMs);
break;
117 default:
SWIFT_VERIFY_X(
false, Q_FUNC_INFO,
"read state not handled");
break;
123 QList<CLedWidget *> leds;
124 if (entities.testFlag(CEntityFlags::CountryEntity)) { leds << m_ledCountries; }
125 if (entities.testFlag(CEntityFlags::DistributorEntity)) { leds << m_ledDistributors; }
126 if (entities.testFlag(CEntityFlags::AircraftIcaoEntity)) { leds << m_ledIcaoAircraft; }
127 if (entities.testFlag(CEntityFlags::AirlineIcaoEntity)) { leds << m_ledIcaoAirline; }
128 if (entities.testFlag(CEntityFlags::LiveryEntity)) { leds << m_ledLiveries; }
129 if (entities.testFlag(CEntityFlags::ModelEntity)) { leds << m_ledModels; }
135 if (!
sGui) {
return false; }
149 m_ledDataReady = ledDataReady;
150 m_ledConsolidation = ledConsolidation;
151 m_ledIcaoAircraft = ledIcaoAircraft;
152 m_ledIcaoAirline = ledIcaoAirline;
153 m_ledCountries = ledCountries;
154 m_ledDistributors = ledDistributors;
155 m_ledLiveries = ledLiveries;
156 m_ledModels = ledModels;
163 this->
setLeds(ui->led_DataReady, ui->led_Consolidation, ui->led_IcaoAircraft, ui->led_IcaoAirline,
164 ui->led_Countries, ui->led_Distributors, ui->led_Liveries, ui->led_Models);
172 ui->lbl_Consolidation->setVisible(show);
bool hasWebDataServices() const
Web data services available?
CWebDataServices * getWebDataServices() const
Get the web data services.
int getDistributorsCount() const
Distributors count.
int getModelsCount() const
Models count.
int getCountriesCount() const
Country count.
int getAircraftIcaoCodesCount() const
Aircraft ICAO codes count.
int getAirlineIcaoCodesCount() const
Airline ICAO codes count.
int getLiveriesCount() const
Liveries count.
Info bar displaying status of web readers(swift DB, ...)
virtual ~CInfoBarWebReadersStatusBase()
Destructor.
void initLeds()
Init the LEDs.
void checkData()
Check data status.
virtual void showConsolidationStatus(bool show)
Show the consolidation status.
virtual void consolidationRunning(bool running)
Consolidation is running.
bool hasAllData() const
All data read.
void setLeds(swift::gui::CLedWidget *ledDataReady, CLedWidget *ledConsolidation, swift::gui::CLedWidget *ledIcaoAircraft, swift::gui::CLedWidget *ledIcaoAirline, swift::gui::CLedWidget *ledCountries, swift::gui::CLedWidget *ledDistributors, swift::gui::CLedWidget *ledLiveries, swift::gui::CLedWidget *ledModels)
Initial setup of leds.
void setLedReadStates(const QList< CLedWidget * > &leds, swift::misc::network::CEntityFlags::ReadState readState)
Set LED states.
void setLedReadState(CLedWidget *led, swift::misc::network::CEntityFlags::ReadState readState)
Set the LED read state.
void dataRead(swift::misc::network::CEntityFlags::Entity entities, swift::misc::network::CEntityFlags::ReadState readState, int count)
Data have been read.
QList< CLedWidget * > entitiesToLeds(swift::misc::network::CEntityFlags::Entity entities) const
Maps entity to its id.
Info bar displaying status of web readers(swift DB, ...)
CInfoBarWebReadersStatusComponent(QWidget *parent=nullptr)
Constructor.
virtual void showConsolidationStatus(bool show)
Show the consolidation status.
virtual ~CInfoBarWebReadersStatusComponent()
Destructor.
ReadState
State of operation.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Backend services of the swift project, like dealing with the network or the simulators.
High level reusable GUI components.
Free functions in swift::misc.
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.