Pre-update de Qt
This commit is contained in:
@@ -0,0 +1,251 @@
|
||||
#include "GeneralStatusPage.h"
|
||||
#include "ui_GeneralStatusPage.h"
|
||||
#include "QStringList"
|
||||
#include <QScrollBar>
|
||||
#include <QLibrary>
|
||||
#include "OtarcikCan.h"
|
||||
|
||||
CGeneralStatusPage::CGeneralStatusPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::CGeneralStatusPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->mClearGenMsgTxtBtn,&QPushButton::clicked,this,&CGeneralStatusPage::ClearGenMsgAreaBtnPressed);
|
||||
connect(ui->mQuitAppBtn,&QPushButton::clicked,this,&CGeneralStatusPage::QuitAppBtnPressed);
|
||||
SetMQTTConnectionStatus(false);
|
||||
SetCANConnectionStatus(false);
|
||||
|
||||
ui->mCANModuleStatusTableWdgt->setColumnCount(3);
|
||||
ui->mCANModuleStatusTableWdgt->setHorizontalHeaderLabels(QStringList() << "Nom" << "Statut" << "Buffer");
|
||||
|
||||
mCPUStateUpdtTimer = new QTimer;
|
||||
mCPUStateUpdtTimer->setSingleShot(false);
|
||||
mCPUStateUpdtTimer->setInterval(5000);
|
||||
connect(mCPUStateUpdtTimer,&QTimer::timeout,this,&CGeneralStatusPage::UpdateBoardStatusTimerExpired);
|
||||
mCPUStateUpdtTimer->start();
|
||||
|
||||
mCPUInterface = 0;
|
||||
|
||||
#ifndef ENABLE_DEVELOPMENT_DEBUG_TOOLS
|
||||
ui->mDevDebugToolsGroupBx->hide();
|
||||
#else
|
||||
connect(ui->mForceMQTTDisconnectChkBx,&QCheckBox::toggled,this,&CGeneralStatusPage::ForceMQTTDisconnectCheckBoxClicked);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
CGeneralStatusPage::~CGeneralStatusPage()
|
||||
{
|
||||
delete ui;
|
||||
delete mCPUStateUpdtTimer;
|
||||
}
|
||||
|
||||
int CGeneralStatusPage::SetGeneralMsgText(QStringList Txt)
|
||||
{
|
||||
Q_UNUSED(Txt)
|
||||
/*if you're populating the text box programatically, is to use textEdit->setTextColor(QColor&).You can create the QColor object yourself, or use one of the predefined colours in the Qt namespace (Qt::black, Qt::red, etc). It will apply the specified colour to any text you add, until it is called again with a different one.*/
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CGeneralStatusPage::AddGeneralMsgBoxLineEntry(QString LineTxt)
|
||||
{
|
||||
|
||||
//Limit the number of lines in the MsgBox to avoid overruns...
|
||||
if(mGenMsgListBoxTextLines.size() >= GENERAL_MESSAGES_MAX_LOG_LINES)
|
||||
{
|
||||
mGenMsgListBoxTextLines.removeFirst();
|
||||
mGenMsgListBoxTextLines.append(LineTxt);
|
||||
|
||||
ui->mGenMsgTextEdit->clear();
|
||||
for(int i = 0; i < mGenMsgListBoxTextLines.size(); i++)
|
||||
{
|
||||
AddColoredLineToGenMsgBox(mGenMsgListBoxTextLines[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mGenMsgListBoxTextLines.append(LineTxt);
|
||||
AddColoredLineToGenMsgBox(LineTxt);
|
||||
}
|
||||
|
||||
ui->mGenMsgTextEdit->verticalScrollBar()->setValue(ui->mGenMsgTextEdit->verticalScrollBar()->maximum());
|
||||
|
||||
|
||||
return RET_OK;
|
||||
|
||||
}
|
||||
|
||||
int CGeneralStatusPage::AddColoredLineToGenMsgBox(QString Line)
|
||||
{
|
||||
if(Line.isEmpty())
|
||||
{
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
if(Line.at(0) == QChar('%'))
|
||||
{
|
||||
if(Line.at(1) == QChar('E')) //The line is describing an error... write it red
|
||||
{
|
||||
ui->mGenMsgTextEdit->setTextColor(Qt::red);
|
||||
}
|
||||
else if(Line.at(1) == QChar('W')) //The line is describing a warning... write it yellow
|
||||
{
|
||||
ui->mGenMsgTextEdit->setTextColor(Qt::blue);
|
||||
}
|
||||
else if(Line.at(1) == QChar('S')) //The line is describing a warning... write it yellow
|
||||
{
|
||||
ui->mGenMsgTextEdit->setTextColor(Qt::darkGreen);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("GeneralStatusPage: Logic error in general message box line encoding... you should check into that");
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
Line.remove(0,2);
|
||||
}
|
||||
|
||||
ui->mGenMsgTextEdit->insertPlainText(Line);
|
||||
ui->mGenMsgTextEdit->setTextColor(Qt::black);
|
||||
|
||||
return RET_OK;
|
||||
|
||||
}
|
||||
|
||||
void CGeneralStatusPage::ClearGenMsgAreaBtnPressed()
|
||||
{
|
||||
mGenMsgListBoxTextLines.clear();
|
||||
ui->mGenMsgTextEdit->clear();
|
||||
}
|
||||
|
||||
int CGeneralStatusPage::SetMQTTConnectionStatus(bool Connected)
|
||||
{
|
||||
if(Connected)
|
||||
{
|
||||
ui->mClientMQTTConnStatLbl->setText("CONNECTÉ");
|
||||
QPalette pal = QPalette(ui->mClientMQTTConnStatLbl->palette());
|
||||
pal.setColor(QPalette::WindowText,QColor(Qt::darkGreen));
|
||||
ui->mClientMQTTConnStatLbl->setPalette(pal);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->mClientMQTTConnStatLbl->setText("DÉCONNECTÉ");
|
||||
QPalette pal = QPalette(ui->mClientMQTTConnStatLbl->palette());
|
||||
pal.setColor(QPalette::WindowText,QColor(Qt::red));
|
||||
ui->mClientMQTTConnStatLbl->setPalette(pal);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CGeneralStatusPage::SetCANConnectionStatus(bool Connected)
|
||||
{
|
||||
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CGeneralStatusPage::ClearCANModuleStatusTable()
|
||||
{
|
||||
ui->mCANModuleStatusTableWdgt->clearContents();
|
||||
ui->mCANModuleStatusTableWdgt->setRowCount(0);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CGeneralStatusPage::UpdateMQTTBufferingStatus(QString Mode, QString FIFOSize, QString RemainingTime)
|
||||
{
|
||||
ui->mBufferingMode->setText(Mode);
|
||||
ui->mBufferSizeValue->setText(FIFOSize);
|
||||
// ui->mBufferTimeRemaining->setText(RemainingTime);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CGeneralStatusPage::UpdateCANModuleStatus(QString ModuleName, QString ModuleStatus, QString Buffer)
|
||||
{
|
||||
QList<QTableWidgetItem *> Items = ui->mCANModuleStatusTableWdgt->findItems(ModuleName,Qt::MatchFixedString);
|
||||
|
||||
if(Items.isEmpty())
|
||||
{
|
||||
//first update, we add the item to the table
|
||||
QTableWidgetItem *NewItem;
|
||||
int row = ui->mCANModuleStatusTableWdgt->rowCount();
|
||||
ui->mCANModuleStatusTableWdgt->setRowCount(row + 1);
|
||||
|
||||
NewItem = new QTableWidgetItem(ModuleName);
|
||||
ui->mCANModuleStatusTableWdgt->setItem(row,0,NewItem);
|
||||
|
||||
NewItem = new QTableWidgetItem(ModuleStatus);
|
||||
ui->mCANModuleStatusTableWdgt->setItem(row,1,NewItem);
|
||||
|
||||
if(Buffer == "NOUPDATE")
|
||||
Buffer = "?";
|
||||
NewItem = new QTableWidgetItem(Buffer);
|
||||
ui->mCANModuleStatusTableWdgt->setItem(row,2,NewItem);
|
||||
}
|
||||
else if(Items.size() == 1)
|
||||
{
|
||||
int row = ui->mCANModuleStatusTableWdgt->row(Items.at(0));
|
||||
|
||||
if(ModuleStatus != "NOUPDATE")
|
||||
{
|
||||
ui->mCANModuleStatusTableWdgt->item(row,1)->setText(ModuleStatus);
|
||||
}
|
||||
if(Buffer != "NOUPDATE")
|
||||
{
|
||||
ui->mCANModuleStatusTableWdgt->item(row,2)->setText(Buffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Two CAN modules with same name in the Modules Status Table");
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CGeneralStatusPage::QuitAppBtnPressed()
|
||||
{
|
||||
mProgramPtr->QuitApplicationRequest();
|
||||
}
|
||||
|
||||
int CGeneralStatusPage::UpdateBoardStatus(CComputerBoardState CPUState)
|
||||
{
|
||||
QString BoardState = QString("System Temp: %1C\nCPU VCore: %2V\nSystem 3.3V: %3V\nSystem 5V: %4V").arg(CPUState.mSystemTemperature).arg(CPUState.mCPUVcore).arg(CPUState.mSystem3V3).arg(CPUState.mSystem5V);
|
||||
ui->mSystemStateLbl->setText(BoardState);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CGeneralStatusPage::InternetStatusChanged(bool InternetConnected)
|
||||
{
|
||||
if(InternetConnected == true)
|
||||
{
|
||||
ui->mInternetPresentStatLbl->setText("Détecté");
|
||||
QPalette pal = QPalette(ui->mInternetPresentStatLbl->palette());
|
||||
pal.setColor(QPalette::WindowText,QColor(Qt::darkGreen));
|
||||
ui->mInternetPresentStatLbl->setPalette(pal);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->mInternetPresentStatLbl->setText("Déconnecté");
|
||||
QPalette pal = QPalette(ui->mInternetPresentStatLbl->palette());
|
||||
pal.setColor(QPalette::WindowText,QColor(Qt::red));
|
||||
ui->mInternetPresentStatLbl->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
void CGeneralStatusPage::UpdateBoardStatusTimerExpired()
|
||||
{
|
||||
UpdateBoardStatus(mCPUInterface->GetComputerBoardState());
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DEVELOPMENT_DEBUG_TOOLS
|
||||
void CGeneralStatusPage::ForceMQTTDisconnectCheckBoxClicked(bool checked)
|
||||
{
|
||||
mProgramPtr->ForceMQTTDisconnect(checked);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user