Ajout config CPU Watchdog dans la page des settings
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#include "CPUWatchdogConfig.h"
|
||||
|
||||
CCPUWatchdogConfig::CCPUWatchdogConfig()
|
||||
{
|
||||
mWatchdogEnabled = false;
|
||||
mWatchdogTimeout = 600; //10 minutes
|
||||
|
||||
}
|
||||
|
||||
CCPUWatchdogConfig& CCPUWatchdogConfig::operator=(const CCPUWatchdogConfig &source)
|
||||
{
|
||||
if(&source == this)
|
||||
return *this;
|
||||
|
||||
this->mWatchdogEnabled = source.mWatchdogEnabled;
|
||||
this->mWatchdogTimeout = source.mWatchdogTimeout;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, CCPUWatchdogConfig &dest)
|
||||
{
|
||||
in >> dest.mWatchdogEnabled
|
||||
>> dest.mWatchdogTimeout;
|
||||
return in;
|
||||
}
|
||||
QDataStream &operator<<(QDataStream &out, const CCPUWatchdogConfig &source)
|
||||
{
|
||||
out << source.mWatchdogEnabled
|
||||
<< source.mWatchdogTimeout;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef CPUWATCHDOGCONFIG_H
|
||||
#define CPUWATCHDOGCONFIG_H
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QString>
|
||||
|
||||
|
||||
class CCPUWatchdogConfig
|
||||
{
|
||||
public:
|
||||
CCPUWatchdogConfig();
|
||||
|
||||
bool mWatchdogEnabled;
|
||||
unsigned int mWatchdogTimeout;
|
||||
|
||||
CCPUWatchdogConfig &operator=(const CCPUWatchdogConfig &source);
|
||||
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CCPUWatchdogConfig &source);
|
||||
QDataStream &operator>>(QDataStream &in, CCPUWatchdogConfig &dest);
|
||||
#endif // CPUWATCHDOGCONFIG_H
|
||||
@@ -2,10 +2,12 @@
|
||||
#include "defines.h"
|
||||
#include "AxUfiAPI.h"
|
||||
#include "GeneralMessagesLogDispatcher.h"
|
||||
#include "CPUWatchdogConfig.h"
|
||||
|
||||
CComputerBoardInterface::CComputerBoardInterface()
|
||||
{
|
||||
|
||||
mWatchdogTimeout = CPU_DEFAULT_WATCHDOG_TIMEOUT;
|
||||
mWatchdogEnabled = false;
|
||||
}
|
||||
|
||||
int CComputerBoardInterface::Init()
|
||||
@@ -13,6 +15,7 @@ int CComputerBoardInterface::Init()
|
||||
if(LoadLibrary() == RET_OK)
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Librairie Axiomtek chargée avec succès"),true,1,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_SUCCESS_STATUS);
|
||||
StopCPUWatchdog();
|
||||
return RET_OK;
|
||||
}
|
||||
else
|
||||
@@ -48,23 +51,25 @@ int CComputerBoardInterface::DeInit()
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CComputerBoardInterface::StartCPUWatchdog(int TimeoutInSeconds)
|
||||
int CComputerBoardInterface::StartCPUWatchdog()
|
||||
{
|
||||
if(TimeoutInSeconds > (255*60) ) //Max of 255 minutes
|
||||
{
|
||||
// if(TimeoutInSeconds > (255*60) ) //Max of 255 minutes
|
||||
// {
|
||||
// return RET_GENERAL_ERROR;
|
||||
// }
|
||||
if(mWatchdogEnabled == false)
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
int Ret;
|
||||
|
||||
quint16 RawTimeout = bWDT_SECOND;
|
||||
if(TimeoutInSeconds <= 60)
|
||||
if(mWatchdogTimeout <= 60)
|
||||
{
|
||||
RawTimeout = TimeoutInSeconds;
|
||||
RawTimeout = mWatchdogTimeout;
|
||||
}
|
||||
else
|
||||
{
|
||||
RawTimeout = TimeoutInSeconds/60;
|
||||
RawTimeout = mWatchdogTimeout/60;
|
||||
RawTimeout |= bWDT_MINUTE; //set the counter time base in minutes (high byte = 1)
|
||||
}
|
||||
|
||||
@@ -76,7 +81,7 @@ int CComputerBoardInterface::StartCPUWatchdog(int TimeoutInSeconds)
|
||||
{
|
||||
if(AxWDTexec(bWDT_ENABLE) == true)
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Watchdog CPU démarré. Timeout: %1 secondes").arg(TimeoutInSeconds));
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Watchdog CPU démarré. Timeout: %1 secondes").arg(mWatchdogTimeout));
|
||||
Ret = RET_OK;
|
||||
}
|
||||
else
|
||||
@@ -96,7 +101,10 @@ int CComputerBoardInterface::StopCPUWatchdog()
|
||||
{
|
||||
Ret = RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Watchdog CPU arrêté"));
|
||||
}
|
||||
return Ret;
|
||||
}
|
||||
|
||||
@@ -106,3 +114,9 @@ int CComputerBoardInterface::KickCPUWatchdog()
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CComputerBoardInterface::SetWatchdogSettings(CCPUWatchdogConfig *Settings)
|
||||
{
|
||||
mWatchdogEnabled = Settings->mWatchdogEnabled;
|
||||
mWatchdogTimeout = Settings->mWatchdogTimeout;
|
||||
}
|
||||
|
||||
@@ -5,19 +5,27 @@
|
||||
#define CPU_DEFAULT_WATCHDOG_TIMEOUT 600 //10 minutes.
|
||||
#define CPU_LIBRARY_NAME "dtSBC87853x64"
|
||||
|
||||
class CCPUWatchdogConfig;
|
||||
|
||||
class CComputerBoardInterface
|
||||
{
|
||||
public:
|
||||
CComputerBoardInterface();
|
||||
int Init();
|
||||
int DeInit();
|
||||
int StartCPUWatchdog(int TimeoutInSeconds = CPU_DEFAULT_WATCHDOG_TIMEOUT); //Timeout in seconds
|
||||
int StartCPUWatchdog(/*int TimeoutInSeconds = CPU_DEFAULT_WATCHDOG_TIMEOUT*/); //Timeout in seconds
|
||||
int StopCPUWatchdog();
|
||||
int KickCPUWatchdog();
|
||||
|
||||
|
||||
int SetWatchdogSettings(CCPUWatchdogConfig *Settings);
|
||||
|
||||
private:
|
||||
int LoadLibrary();
|
||||
int UnloadLibrary();
|
||||
|
||||
int mWatchdogTimeout;
|
||||
bool mWatchdogEnabled;
|
||||
};
|
||||
|
||||
#endif // COMPUTERBOARDINTERFACE_H
|
||||
|
||||
@@ -156,8 +156,8 @@
|
||||
<widget class="QPushButton" name="mQuitAppBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1529</x>
|
||||
<y>560</y>
|
||||
<x>1230</x>
|
||||
<y>310</y>
|
||||
<width>131</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
|
||||
@@ -26,6 +26,8 @@ CLoggingSettingsPage::CLoggingSettingsPage(QWidget *parent) :
|
||||
connect(ui->mChangeParamsBtn,&QPushButton::clicked,this,&CLoggingSettingsPage::ModifyParamsBtnPressed);
|
||||
connect(ui->mLogZoneVerbositySpinBx,QOverload<int>::of(&QSpinBox::valueChanged),this,&CLoggingSettingsPage::VerbosityParamsChanged);
|
||||
connect(ui->mLogFileVerbositySpinBx,QOverload<int>::of(&QSpinBox::valueChanged),this,&CLoggingSettingsPage::VerbosityParamsChanged);
|
||||
connect(ui->mWDActiveChkBx,&QCheckBox::stateChanged,this,&CLoggingSettingsPage::EnableCPUWDCheckBxClicked);
|
||||
connect(ui->mWDTimerTimeoutSpinBx,QOverload<int>::of(&QSpinBox::valueChanged),this,&CLoggingSettingsPage::CPUWDTimeoutChanged);
|
||||
|
||||
}
|
||||
|
||||
@@ -61,6 +63,20 @@ int CLoggingSettingsPage::SetGeneralSettingsParams(const CGeneralSystemParams *G
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CLoggingSettingsPage::SetCPUWatchdogSettings(const CCPUWatchdogConfig *CPUWatchdogParams)
|
||||
{
|
||||
if(CPUWatchdogParams == 0)
|
||||
{
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
mCPUWatchdogParams = *CPUWatchdogParams;
|
||||
|
||||
UpdateCPUWatchdogParams();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CLoggingSettingsPage::ModifyParamsBtnPressed()
|
||||
{
|
||||
if(EditMode == false)
|
||||
@@ -153,6 +169,20 @@ int CLoggingSettingsPage::UpdateGeneralParams()
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CLoggingSettingsPage::UpdateCPUWatchdogParams()
|
||||
{
|
||||
disconnect(ui->mWDActiveChkBx,&QCheckBox::stateChanged,this,&CLoggingSettingsPage::EnableCPUWDCheckBxClicked);
|
||||
disconnect(ui->mWDTimerTimeoutSpinBx,QOverload<int>::of(&QSpinBox::valueChanged),this,&CLoggingSettingsPage::CPUWDTimeoutChanged);
|
||||
|
||||
ui->mWDActiveChkBx->setChecked(mCPUWatchdogParams.mWatchdogEnabled);
|
||||
ui->mWDTimerTimeoutSpinBx->setValue(mCPUWatchdogParams.mWatchdogTimeout);
|
||||
|
||||
connect(ui->mWDActiveChkBx,&QCheckBox::stateChanged,this,&CLoggingSettingsPage::EnableCPUWDCheckBxClicked);
|
||||
connect(ui->mWDTimerTimeoutSpinBx,QOverload<int>::of(&QSpinBox::valueChanged),this,&CLoggingSettingsPage::CPUWDTimeoutChanged);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CLoggingSettingsPage::VerbosityParamsChanged(int value)
|
||||
{
|
||||
Q_UNUSED(value)
|
||||
@@ -165,3 +195,17 @@ void CLoggingSettingsPage::VerbosityParamsChanged(int value)
|
||||
qDebug("LogZone: %i, LogFile %i",mGeneralSystemParams.mLocalLogVerbosity,mGeneralSystemParams.mLogFileVerbosity);
|
||||
|
||||
}
|
||||
|
||||
void CLoggingSettingsPage::EnableCPUWDCheckBxClicked(int state)
|
||||
{
|
||||
Q_UNUSED(state)
|
||||
mCPUWatchdogParams.mWatchdogEnabled = ui->mWDActiveChkBx->isChecked();
|
||||
mProgramHandle->SaveCPUWatchdogSettingsRequest(&mCPUWatchdogParams);
|
||||
}
|
||||
|
||||
void CLoggingSettingsPage::CPUWDTimeoutChanged(int value)
|
||||
{
|
||||
Q_UNUSED(value)
|
||||
mCPUWatchdogParams.mWatchdogTimeout = ui->mWDTimerTimeoutSpinBx->value();
|
||||
mProgramHandle->SaveCPUWatchdogSettingsRequest(&mCPUWatchdogParams);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <QWidget>
|
||||
#include "CloudParams.h"
|
||||
#include "GeneralSystemParams.h"
|
||||
#include "CPUWatchdogConfig.h"
|
||||
|
||||
|
||||
class COtarcikCan;
|
||||
@@ -22,6 +23,7 @@ public:
|
||||
|
||||
int SetCloudParams(const CCloudParams *CloudParams);
|
||||
int SetGeneralSettingsParams(const CGeneralSystemParams *GeneralParams);
|
||||
int SetCPUWatchdogSettings(const CCPUWatchdogConfig *CPUWatchdogParams);
|
||||
|
||||
|
||||
COtarcikCan *mProgramHandle;
|
||||
@@ -29,13 +31,14 @@ public:
|
||||
private:
|
||||
int UpdateCloudConfig();
|
||||
int UpdateGeneralParams();
|
||||
|
||||
int UpdateCPUWatchdogParams();
|
||||
|
||||
Ui::CLoggingSettingsPage *ui;
|
||||
|
||||
bool EditMode;
|
||||
CCloudParams mCloudParams;
|
||||
CGeneralSystemParams mGeneralSystemParams;
|
||||
CCPUWatchdogConfig mCPUWatchdogParams;
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +46,8 @@ public slots:
|
||||
void ModifyParamsBtnPressed();
|
||||
void CancelBtnPressed();
|
||||
void VerbosityParamsChanged(int value);
|
||||
void EnableCPUWDCheckBxClicked(int state);
|
||||
void CPUWDTimeoutChanged(int value);
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -425,6 +425,66 @@
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>590</x>
|
||||
<y>240</y>
|
||||
<width>351</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Watchdog CPU</string>
|
||||
</property>
|
||||
<widget class="QSpinBox" name="mWDTimerTimeoutSpinBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>60</y>
|
||||
<width>101</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>15300</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>60</y>
|
||||
<width>91</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Timeout (s)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="mWDActiveChkBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>171</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Activer watchdog</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -39,7 +39,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
||||
mMainWindowWidget->addTab(mCANViewerPage,"Données CAN");
|
||||
mProgramsSettingsTabWidget->addTab(mCANbusSettingsPage,"CAN Bus");
|
||||
// mProgramsSettingsTabWidget->addTab(mCANWatchdogSettingsPage,"Watchdog");
|
||||
mProgramsSettingsTabWidget->addTab(mDataLoggingSettingsPage,"Archivage");
|
||||
mProgramsSettingsTabWidget->addTab(mDataLoggingSettingsPage,"Général");
|
||||
|
||||
setWindowFlags(Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint);
|
||||
resize(1700,768);
|
||||
|
||||
@@ -86,12 +86,16 @@ int COtarcikCan::Start()
|
||||
mMainWindow.mDataLoggingSettingsPage->SetGeneralSettingsParams(&mGeneralSystemParams);
|
||||
CGeneralMessagesLogDispatcher::instance()->SetLogVerbosities(mGeneralSystemParams.mLogFileVerbosity,mGeneralSystemParams.mLocalLogVerbosity);
|
||||
|
||||
mCPUWatchdogParams = *mSystemConfig.GetCPUWatchdogSettings();
|
||||
mCPUInterface.SetWatchdogSettings(&mCPUWatchdogParams);
|
||||
mMainWindow.mDataLoggingSettingsPage->SetCPUWatchdogSettings(mSystemConfig.GetCPUWatchdogSettings());
|
||||
|
||||
// mMainWindow.mCANWatchdogSettingsPage->SetCANWatchdogConfig(mSystemConfig.GetCANWatchdogConfig());
|
||||
|
||||
// mGPTimer->setSingleShot(false);
|
||||
// mGPTimer->start(5000);
|
||||
|
||||
mCPUInterface.StartCPUWatchdog(25);
|
||||
mCPUInterface.StartCPUWatchdog();
|
||||
mWatchdogTimer->start();
|
||||
|
||||
}
|
||||
@@ -221,6 +225,22 @@ int COtarcikCan::SaveGeneralParametersSettingsRequest(CGeneralSystemParams *Gene
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int COtarcikCan::SaveCPUWatchdogSettingsRequest(CCPUWatchdogConfig *CPUWatchdogParams)
|
||||
{
|
||||
mCPUWatchdogParams = *CPUWatchdogParams;
|
||||
mSystemConfig.SetCPUWatchdogPArams(&mCPUWatchdogParams);
|
||||
mSystemConfig.SaveConfig();
|
||||
|
||||
mCPUInterface.SetWatchdogSettings(&mCPUWatchdogParams);
|
||||
mCPUInterface.StopCPUWatchdog();
|
||||
if(mCPUWatchdogParams.mWatchdogEnabled == true)
|
||||
{
|
||||
mCPUInterface.StartCPUWatchdog();
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void COtarcikCan::GPTimerExpired()
|
||||
{
|
||||
// mCANBusMQTTClient.SendMQTTTestMessage();
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
int SaveCANDevicesConfigRequest(QList<CCANDeviceConfig*> *DevicesConfigList);
|
||||
int SaveCloudLoggingConfigRequest(CCloudParams *CloudParams);
|
||||
int SaveGeneralParametersSettingsRequest(CGeneralSystemParams *GeneralParams);
|
||||
int SaveCPUWatchdogSettingsRequest(CCPUWatchdogConfig *CPUWatchdogParams);
|
||||
|
||||
int SetCANConnectionStatusRequest(bool Connected);
|
||||
int SetMQTTConnectionSatusRequest(bool Connected);
|
||||
@@ -47,6 +48,7 @@ private:
|
||||
QList<CCANDevice*> mCANDevicesList;
|
||||
CCloudParams mCloudLoggingParams;
|
||||
CGeneralSystemParams mGeneralSystemParams;
|
||||
CCPUWatchdogConfig mCPUWatchdogParams;
|
||||
|
||||
int PopulateCANDevicesList(QList<CCANDeviceConfig*> *DevicesConfigsList);
|
||||
|
||||
|
||||
@@ -78,6 +78,12 @@ int CSystemConfig::LoadConfig()
|
||||
//Load CAN Watchdog parameters
|
||||
*InputStream >> mCANWatchdogParams;
|
||||
|
||||
//Load CPU Watchdog parameters
|
||||
if(FileVersion > 1)
|
||||
{
|
||||
*InputStream >> mCPUWatchdogParams;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ConfigFile->close();
|
||||
@@ -133,6 +139,9 @@ int CSystemConfig::SaveConfig()
|
||||
//Save the CAN Watchdog params
|
||||
*OutputStream << mCANWatchdogParams;
|
||||
|
||||
//Save the CPU Watchdog params
|
||||
*OutputStream << mCPUWatchdogParams;
|
||||
|
||||
ConfigFile->flush();
|
||||
ConfigFile->close();
|
||||
|
||||
@@ -190,6 +199,10 @@ CGeneralSystemParams *CSystemConfig::GetGeneralSystemSettings()
|
||||
return &mGeneralSystemParams;
|
||||
}
|
||||
|
||||
CCPUWatchdogConfig *CSystemConfig::GetCPUWatchdogSettings()
|
||||
{
|
||||
return &mCPUWatchdogParams;
|
||||
}
|
||||
|
||||
int CSystemConfig::SetCANWatchdogConfig(CCANWatchdogConfig *Config)
|
||||
{
|
||||
@@ -216,3 +229,12 @@ int CSystemConfig::SetGeneralSystemParams(CGeneralSystemParams *GeneralParams)
|
||||
mGeneralSystemParams = *GeneralParams;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CSystemConfig::SetCPUWatchdogPArams(CCPUWatchdogConfig *CPUWatchdogParams)
|
||||
{
|
||||
if(CPUWatchdogParams == 0)
|
||||
return RET_GENERAL_ERROR;
|
||||
|
||||
mCPUWatchdogParams = *CPUWatchdogParams;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
#include "CloudParams.h"
|
||||
#include "CANWatchdogConfig.h"
|
||||
#include "GeneralSystemParams.h"
|
||||
#include "CPUWatchdogConfig.h"
|
||||
|
||||
#define OTARCIK_CURRENT_CONFIG_FILE_VERSION 0x01
|
||||
#define OTARCIK_CURRENT_CONFIG_FILE_VERSION 0x02
|
||||
#define OTARCIK_CONFIG_FILE_MAGIC_NBR 0xDEADBEEF
|
||||
//class CCANDeviceConfig;
|
||||
|
||||
@@ -32,6 +33,8 @@ public:
|
||||
int SetCloudParams(CCloudParams *CloudParams);
|
||||
CGeneralSystemParams *GetGeneralSystemSettings();
|
||||
int SetGeneralSystemParams(CGeneralSystemParams *GeneralParams);
|
||||
CCPUWatchdogConfig *GetCPUWatchdogSettings();
|
||||
int SetCPUWatchdogPArams(CCPUWatchdogConfig *CPUWatchdogParams);
|
||||
|
||||
|
||||
|
||||
@@ -50,6 +53,9 @@ public:
|
||||
CCANWatchdogConfig *GetCANWatchdogConfig();
|
||||
int SetCANWatchdogConfig(CCANWatchdogConfig *Config);
|
||||
|
||||
//Hardware watchdog settings
|
||||
CCPUWatchdogConfig mCPUWatchdogParams;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user