Pre-update de Qt
This commit is contained in:
@@ -8,7 +8,9 @@ CMQTTClientWrapper::CMQTTClientWrapper()
|
||||
{
|
||||
connect(&mMQTTClient,&QMqttClient::stateChanged,this,&CMQTTClientWrapper::StateChanged);
|
||||
connect(&mMQTTClient,&QMqttClient::errorChanged,this,&CMQTTClientWrapper::MQTTClientError);
|
||||
connect(&mMQTTClient,&QMqttClient::messageSent,this,&CMQTTClientWrapper::MQTTMessageSent);
|
||||
//connect(&mMQTTClient,&QMqttClient::messageSent,this,&CMQTTClientWrapper::MQTTMessageSent);
|
||||
connect(&mMQTTClient,SIGNAL(messageSent(qint32)),this,SLOT(MQTTMessageSent(qint32)));
|
||||
connect(&mMQTTClient,&QMqttClient::messageStatusChanged,this,&CMQTTClientWrapper::MQTTMessageStatusChanged);
|
||||
mMQTTRefreshTimer = new QTimer;
|
||||
mMQTTRefreshTimer->setSingleShot(true);
|
||||
connect(mMQTTRefreshTimer,&QTimer::timeout,this,&CMQTTClientWrapper::MQTTSendTimerExpired);
|
||||
@@ -32,7 +34,8 @@ CMQTTClientWrapper::CMQTTClientWrapper()
|
||||
|
||||
mCircularBufferStatusText = mBufferingModeText = mUploadTimeText = "";
|
||||
|
||||
#ifdef MQTT_USE_TIMER_TO_FLUSH_QUEUE
|
||||
#ifdef ENABLE_DEVELOPMENT_DEBUG_TOOLS
|
||||
mMQTTDisconnectionForced = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -58,6 +61,7 @@ int CMQTTClientWrapper::SetCPUInterface(CComputerBoardInterface *CPUIF)
|
||||
int CMQTTClientWrapper::SetMQTTServerPresenceCANBit(quint64 CANBit)
|
||||
{
|
||||
mMQTTPresenceCANBit = CANBit;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CMQTTClientWrapper::StartMQTTClient()
|
||||
@@ -90,15 +94,29 @@ int CMQTTClientWrapper::ConnectToBroker()
|
||||
|
||||
int CMQTTClientWrapper::DisconnectFromBroker()
|
||||
{
|
||||
#ifndef ENABLE_DEVELOPMENT_DEBUG_TOOLS
|
||||
mMQTTClient.disconnectFromHost();
|
||||
mDisconnectionIsVoluntary = true;
|
||||
mMessagesQueueMode = MQTT_DROP_MSG_MODE; //It's a voluntary disconnection... don't queue the CAN messages.
|
||||
#else
|
||||
mMQTTClient.disconnectFromHost();
|
||||
if(mMQTTDisconnectionForced == true)
|
||||
{
|
||||
mDisconnectionIsVoluntary = false; //emulate an involuntary disconnection
|
||||
}
|
||||
else
|
||||
{
|
||||
mDisconnectionIsVoluntary = true;
|
||||
mMessagesQueueMode = MQTT_DROP_MSG_MODE; //It's a voluntary disconnection... don't queue the CAN messages.
|
||||
}
|
||||
#endif
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CMQTTClientWrapper::NewMQTTMessages(QList<CMQTTMessage> MessagesList)
|
||||
{
|
||||
Q_UNUSED(MessagesList)
|
||||
// if(mMQTTClient.state() != QMqttClient::Connected)
|
||||
// {
|
||||
// return RET_GENERAL_ERROR;
|
||||
@@ -156,7 +174,14 @@ void CMQTTClientWrapper::StateChanged()
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Client MQTT déconnecté.","CMQTTClientWrapper",true,1);
|
||||
mProgramPtr->SetMQTTConnectionSatusRequest(false);
|
||||
#ifndef ENABLE_DEVELOPMENT_DEBUG_TOOLS
|
||||
mMQTTReconnectTimer->start(MQTT_CLIENT_RECONNECT_TIMEOUT);
|
||||
#else
|
||||
if(mMQTTDisconnectionForced == false)
|
||||
{
|
||||
mMQTTReconnectTimer->start(MQTT_CLIENT_RECONNECT_TIMEOUT);
|
||||
}
|
||||
#endif
|
||||
#ifdef MQTT_USE_TIMER_TO_FLUSH_QUEUE
|
||||
mMQTTQueueFlushTimer->stop();
|
||||
#endif
|
||||
@@ -243,7 +268,7 @@ void CMQTTClientWrapper::MQTTSendTimerExpired()
|
||||
QList<CMQTTMessage> *MessagesList = Device->GetMQTTMessagesList();
|
||||
if(mCPUInterface)
|
||||
{
|
||||
CComputerBoardState tmp =mCPUInterface->GetComputerBoardState();
|
||||
MessagesList->append(GetSystemStatusMessage());
|
||||
}
|
||||
|
||||
if(MessagesList != 0)
|
||||
@@ -265,7 +290,7 @@ void CMQTTClientWrapper::MQTTSendTimerExpired()
|
||||
QList<CMQTTMessage> *MessagesList = Device->GetMQTTMessagesList();
|
||||
if(mCPUInterface)
|
||||
{
|
||||
CComputerBoardState tmp =mCPUInterface->GetComputerBoardState();
|
||||
MessagesList->append(GetSystemStatusMessage());
|
||||
}
|
||||
|
||||
if(MessagesList != 0)
|
||||
@@ -289,6 +314,8 @@ void CMQTTClientWrapper::MQTTSendTimerExpired()
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MQTT_DROP_MSG_MODE://Just to please the compiler.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,8 +354,16 @@ void CMQTTClientWrapper::MQTTQueueFlushTimerExipred()
|
||||
|
||||
int CMQTTClientWrapper::SendNextQueueMessage()
|
||||
{
|
||||
if(mMQTTMessagesQueue.size() == 0)
|
||||
{
|
||||
//Should not happen, this is a logical problem with the program
|
||||
mMessagesQueueMode = MQTT_TRANSMIT_MSG_MODE;
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Erreur de logique dans SendNextQueueMessage(). MessageQueue vide!","CMQTTClientWrapper",true,2);
|
||||
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
CMQTTMessage *Msg = mMQTTMessagesQueue.takeFirst();
|
||||
qint32 res = mMQTTClient.publish(Msg->mMessageTopic,Msg->mMessagePayload.toLocal8Bit(),0,true);
|
||||
mMQTTClient.publish(Msg->mMessageTopic,Msg->mMessagePayload.toLocal8Bit(),0,true);
|
||||
QString LogMsg = QString("Envoi d'un message MQTT provenant du buffer. Topic: %1 Payload: %2 FIFO Size: %3").arg(Msg->mMessageTopic).arg(Msg->mMessagePayload).arg(mMQTTMessagesQueue.size());
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(LogMsg,"CMQTTClientWrapper",true,3);
|
||||
|
||||
@@ -349,6 +384,7 @@ int CMQTTClientWrapper::SendNextQueueMessage()
|
||||
int CMQTTClientWrapper::UpdateGUIBufferingStatus()
|
||||
{
|
||||
//mProgramPtr->UpdateMQTTBufferingStatusRequest(mBufferingModeText,mCircularBufferStatusText,mRemainingBufferingTimeText);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CMQTTClientWrapper::MQTTClientError(QMqttClient::ClientError error)
|
||||
@@ -359,6 +395,8 @@ void CMQTTClientWrapper::MQTTClientError(QMqttClient::ClientError error)
|
||||
//This function is used only when flushing the msg queue
|
||||
void CMQTTClientWrapper::MQTTMessageSent(qint32 MsgID)
|
||||
{
|
||||
Q_UNUSED(MsgID)
|
||||
qDebug("MQTT msg ID %d sent",MsgID);
|
||||
#ifndef MQTT_USE_TIMER_TO_FLUSH_QUEUE
|
||||
if(mMessagesQueueMode != MQTT_QUEUE_MSG_MODE)
|
||||
{
|
||||
@@ -370,8 +408,63 @@ void CMQTTClientWrapper::MQTTMessageSent(qint32 MsgID)
|
||||
mMessagesQueueMode = MQTT_TRANSMIT_MSG_MODE;
|
||||
return;
|
||||
}
|
||||
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Message MQTT de la FIFO transmis, transmission du prochain...","CMQTTClientWrapper",true,1);
|
||||
SendNextQueueMessage();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void CMQTTClientWrapper::MQTTMessageStatusChanged(qint32 id, QMqtt::MessageStatus s, const QMqttMessageStatusProperties &properties)
|
||||
{
|
||||
qDebug("Mqtt %d message status changed",id);
|
||||
}
|
||||
|
||||
CMQTTMessage CMQTTClientWrapper::GetSystemStatusMessage()
|
||||
{
|
||||
if(mCPUInterface != 0)
|
||||
{
|
||||
CComputerBoardState tmp = mCPUInterface->GetComputerBoardState();
|
||||
QString MsgPayload = "{";
|
||||
QString MsgTopic = "GeneralPCStatus";
|
||||
|
||||
//Millisecs to EPOCH timestamp format
|
||||
qint64 TimeStamp = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
MsgPayload.append(QString("\"timestamp\":%1,").arg(TimeStamp));
|
||||
MsgPayload.append(QString("\"CPU Temperature\":%1").arg(tmp.mSystemTemperature));
|
||||
MsgPayload.append(QString("\"Board 12V\":%1").arg(tmp.mSystem12V));
|
||||
MsgPayload.append(QString("\"IO Port\":%1,").arg(tmp.mIOPortState));
|
||||
MsgPayload.append("}");
|
||||
|
||||
// qDebug("%s",qPrintable(MsgPayload));
|
||||
|
||||
CMQTTMessage NewMessage(MsgTopic, MsgPayload);
|
||||
return NewMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
return CMQTTMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef ENABLE_DEVELOPMENT_DEBUG_TOOLS
|
||||
int CMQTTClientWrapper::ForceMQTTClientDisconnection(bool Disconnect)
|
||||
{
|
||||
if(Disconnect == true)
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Forcing MQTT client disconnection for debug tests...","CMQTTClientWrapper",true,3);
|
||||
mMQTTDisconnectionForced = true;
|
||||
DisconnectFromBroker();
|
||||
}
|
||||
else
|
||||
{
|
||||
mMQTTDisconnectionForced = false;
|
||||
if(mMessagesQueueMode != MQTT_TRANSMIT_MSG_MODE)
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Reconnecting MQTT client after being forced OFF...","CMQTTClientWrapper",true,3);
|
||||
ConnectToBroker();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -40,6 +40,10 @@ public:
|
||||
int StopMQTTClient();
|
||||
quint64 GetMQTTServerPresenceCANMask();
|
||||
|
||||
#ifdef ENABLE_DEVELOPMENT_DEBUG_TOOLS
|
||||
int ForceMQTTClientDisconnection(bool Disconnect);
|
||||
bool mMQTTDisconnectionForced;
|
||||
#endif
|
||||
|
||||
|
||||
COtarcikCan *mProgramPtr;
|
||||
@@ -56,6 +60,7 @@ private:
|
||||
bool mIsClientConnecting;
|
||||
QString mCircularBufferStatusText, mBufferingModeText, mUploadTimeText;
|
||||
CComputerBoardInterface *mCPUInterface;
|
||||
CMQTTMessage GetSystemStatusMessage();
|
||||
|
||||
int SendNextQueueMessage();
|
||||
quint64 mMQTTPresenceCANBit;
|
||||
@@ -70,6 +75,7 @@ public slots:
|
||||
void MQTTQueueFlushTimerExipred();
|
||||
void MQTTClientError(QMqttClient::ClientError error);
|
||||
void MQTTMessageSent(qint32 MsgID);
|
||||
void MQTTMessageStatusChanged(qint32 id, QMqtt::MessageStatus s, const QMqttMessageStatusProperties &properties);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -29,11 +29,22 @@ int CComputerBoardInterface::Init()
|
||||
|
||||
int CComputerBoardInterface::LoadLibrary()
|
||||
{
|
||||
int result;
|
||||
int result, Direction;
|
||||
Direction = 1;
|
||||
char libname[] = CPU_LIBRARY_NAME;
|
||||
result = AxBoardLoadLibrary(libname);
|
||||
if(result)
|
||||
{
|
||||
AxSetDIODirection(0,&Direction);
|
||||
AxSetDIODirection(1,&Direction);
|
||||
AxSetDIODirection(2,&Direction);
|
||||
AxSetDIODirection(3,&Direction);
|
||||
AxSetDIODirection(4,&Direction);
|
||||
AxSetDIODirection(5,&Direction);
|
||||
AxSetDIODirection(6,&Direction);
|
||||
AxSetDIODirection(7,&Direction);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
@@ -144,7 +155,7 @@ CComputerBoardState CComputerBoardInterface::GetComputerBoardState()
|
||||
// qDebug("CPUState.mSystem3V3 %f",CPUState.mSystem3V3);
|
||||
AxGet5V(&CPUState.mSystem5V);
|
||||
// qDebug("CPUState.mSystem5V %f",CPUState.mSystem5V);
|
||||
// AxGet12V(&tmp);
|
||||
AxGet12V(&CPUState.mSystem12V);
|
||||
// qDebug("AxGet12V %f",tmp);
|
||||
// AxGetNeg5V(&tmp);
|
||||
// qDebug("AxGetNeg5V %f",tmp);
|
||||
@@ -153,6 +164,21 @@ CComputerBoardState CComputerBoardInterface::GetComputerBoardState()
|
||||
// AxGetVbat(&tmp);
|
||||
// qDebug("AxGetVbat %f",tmp);
|
||||
|
||||
unsigned char IOPortState = 0;
|
||||
int temp;
|
||||
for(int i = 0; i < 7; i++)
|
||||
{
|
||||
unsigned char mask = 1;
|
||||
AxGetDI(i,&temp);
|
||||
if(temp != 0)
|
||||
{
|
||||
mask <<= i+1;
|
||||
}
|
||||
IOPortState |= mask;
|
||||
}
|
||||
CPUState.mIOPortState = IOPortState;
|
||||
|
||||
|
||||
return CPUState;
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
CComputerBoardState GetComputerBoardState();
|
||||
|
||||
|
||||
|
||||
int SetWatchdogSettings(CCPUWatchdogConfig *Settings);
|
||||
|
||||
private:
|
||||
|
||||
@@ -6,4 +6,7 @@ CComputerBoardState::CComputerBoardState()
|
||||
mCPUVcore = 0.0;
|
||||
mSystem3V3 = 0.0;
|
||||
mSystem5V = 0.0;
|
||||
mSystem12V = 0.0;
|
||||
|
||||
mIOPortState = 0;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ public:
|
||||
float mCPUVcore;
|
||||
float mSystem3V3;
|
||||
float mSystem5V;
|
||||
float mSystem12V;
|
||||
|
||||
unsigned char mIOPortState;
|
||||
};
|
||||
|
||||
#endif // COMPUTERBOARDSTATE_H
|
||||
|
||||
@@ -27,6 +27,12 @@ CGeneralStatusPage::CGeneralStatusPage(QWidget *parent) :
|
||||
|
||||
mCPUInterface = 0;
|
||||
|
||||
#ifndef ENABLE_DEVELOPMENT_DEBUG_TOOLS
|
||||
ui->mDevDebugToolsGroupBx->hide();
|
||||
#else
|
||||
connect(ui->mForceMQTTDisconnectChkBx,&QCheckBox::toggled,this,&CGeneralStatusPage::ForceMQTTDisconnectCheckBoxClicked);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
CGeneralStatusPage::~CGeneralStatusPage()
|
||||
@@ -235,3 +241,11 @@ void CGeneralStatusPage::UpdateBoardStatusTimerExpired()
|
||||
{
|
||||
UpdateBoardStatus(mCPUInterface->GetComputerBoardState());
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DEVELOPMENT_DEBUG_TOOLS
|
||||
void CGeneralStatusPage::ForceMQTTDisconnectCheckBoxClicked(bool checked)
|
||||
{
|
||||
mProgramPtr->ForceMQTTDisconnect(checked);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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
|
||||
@@ -60,6 +60,11 @@ public slots:
|
||||
void InternetStatusChanged(bool InternetConnected);
|
||||
void UpdateBoardStatusTimerExpired();
|
||||
|
||||
|
||||
#ifdef ENABLE_DEVELOPMENT_DEBUG_TOOLS
|
||||
void ForceMQTTDisconnectCheckBoxClicked(bool checked);
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif // GENERALSTATUSPAGE_H
|
||||
|
||||
@@ -285,6 +285,32 @@
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="mDevDebugToolsGroupBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1489</x>
|
||||
<y>299</y>
|
||||
<width>191</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Debug</string>
|
||||
</property>
|
||||
<widget class="QCheckBox" name="mForceMQTTDisconnectChkBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>181</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Force MQTT disconnect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -41,6 +41,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
||||
// mProgramsSettingsTabWidget->addTab(mCANWatchdogSettingsPage,"Watchdog");
|
||||
mProgramsSettingsTabWidget->addTab(mDataLoggingSettingsPage,"Général");
|
||||
|
||||
|
||||
setWindowFlags(Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint);
|
||||
resize(1700,768);
|
||||
}
|
||||
|
||||
@@ -325,3 +325,12 @@ void COtarcikCan::QuitApplicationRequest()
|
||||
|
||||
QCoreApplication::exit(69);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DEVELOPMENT_DEBUG_TOOLS
|
||||
|
||||
int COtarcikCan::ForceMQTTDisconnect(bool Disconnect)
|
||||
{
|
||||
mCANBusMQTTClient.ForceMQTTClientDisconnection(Disconnect);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -50,7 +50,9 @@ public:
|
||||
int SaveCANWatchdogSettingsRequest(CCANWatchdogConfig *CANWatchdogConfig);
|
||||
int UpdateLANDevicesPresenceStatusRequest(QList<bool> LanDevicesStatus);
|
||||
|
||||
|
||||
#ifdef ENABLE_DEVELOPMENT_DEBUG_TOOLS
|
||||
int ForceMQTTDisconnect(bool Disconnect);
|
||||
#endif
|
||||
|
||||
|
||||
void QuitApplicationRequest();
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
#define MAX_NB_LAN_DEVICE_DETECTION 5
|
||||
|
||||
#define ENABLE_DEVELOPMENT_DEBUG_TOOLS
|
||||
|
||||
enum eOtarcikGeneralReturns
|
||||
{
|
||||
RET_OK = 0,
|
||||
|
||||
Reference in New Issue
Block a user