Plusieurs développements, dont l'implémentation du endian Intel

This commit is contained in:
2023-06-13 17:54:05 -04:00
parent 48e9ca3f9c
commit 9f79fb6390
37 changed files with 4363 additions and 383 deletions
+4 -2
View File
@@ -91,7 +91,9 @@ void CCANAnalyzer::CANTimerExpired()
{
QList<CCANMessage *> NewMessagesList = mCANDriverIF->ReadCANFullBuffer(mCANDeviceHandle);
qDebug("CAN Buffer size: %d",NewMessagesList.size());
int BufferSize = NewMessagesList.size();
// qDebug("CAN Buffer size: %d",BufferSize);
for(int i = 0 ; i < NewMessagesList.size(); i++)
@@ -113,7 +115,7 @@ void CCANAnalyzer::CANTimerExpired()
}
mDevicePtr->NewMessageParsed();
mDevicePtr->NewMessageParsed(BufferSize);
if(NewMessagesList.isEmpty())
+4 -1
View File
@@ -72,12 +72,14 @@ int CCANDevice::Init()
{
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Le dispositif [%1] n'a pas pu s'initialiser").arg(mDeviceConfigInfo.mDeviceName),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
mProgramPtr->SetCANConnectionStatusRequest(false);
mProgramPtr->UpdateCANModuleStatusRequest(mDeviceConfigInfo.mDeviceName,"Déconnecté","NOUPDATE");
return RET_GENERAL_ERROR;
}
mCANDataLogger.SetMQTTTopicDevice(QString("CANBus/%1/").arg(mDeviceConfigInfo.mDeviceName));
mCANDataLogger.SetMQTTClient(mCANMQTTClient);
mProgramPtr->SetCANConnectionStatusRequest(true);
mProgramPtr->UpdateCANModuleStatusRequest(mDeviceConfigInfo.mDeviceName,"Connecté","NOUPDATE");
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Dispositif [%1] initialisé avec succès!").arg(mDeviceConfigInfo.mDeviceName),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_SUCCESS_STATUS);
return RET_OK;
@@ -97,10 +99,11 @@ int CCANDevice::Init(QString DatabaseFileName, TPCANHandle CANDeviceID, TPCANBau
return RET_OK;
}
int CCANDevice::NewMessageParsed()
int CCANDevice::NewMessageParsed(int BufferSize)
{
mCANDataLogger.LogNewData(&mMessageList);
mProgramPtr->UpdateCANViewerDataRequest(&mMessageList);
mProgramPtr->UpdateCANModuleStatusRequest(mDeviceConfigInfo.mDeviceName,"NOUPDATE",QString("%1").arg(BufferSize));
for(int i = 0; i < mMessageList.size(); i++)
mMessageList.at(i)->mPendingData = false;
+1 -1
View File
@@ -43,7 +43,7 @@ public:
// CCANDevice &operator=(const CCANDevice *source);
int NewMessageParsed();
int NewMessageParsed(int BufferSize = 0);
private:
bool mConfigSet;
@@ -40,19 +40,19 @@ QDataStream &operator<<(QDataStream &out, const CCANDeviceConfig &source)
return out;
}
CCANDeviceConfig& CCANDeviceConfig::operator=(const CCANDeviceConfig *source)
CCANDeviceConfig& CCANDeviceConfig::operator=(const CCANDeviceConfig &source)
{
if(source == this)
if(&source == this)
{
return *this;
}
this->mCANDeviceID = source->mCANDeviceID;
this->mCANDeviceBaudrate = source->mCANDeviceBaudrate;
this->mCANDeviceDatabaseFilename = source->mCANDeviceDatabaseFilename;
this->mDeviceDescription = source->mDeviceDescription;
this->mDeviceName = source->mDeviceName;
this->mDevicePollPeriod = source->mDevicePollPeriod;
this->mCANDeviceID = source.mCANDeviceID;
this->mCANDeviceBaudrate = source.mCANDeviceBaudrate;
this->mCANDeviceDatabaseFilename = source.mCANDeviceDatabaseFilename;
this->mDeviceDescription = source.mDeviceDescription;
this->mDeviceName = source.mDeviceName;
this->mDevicePollPeriod = source.mDevicePollPeriod;
return *this;
}
+1 -1
View File
@@ -19,7 +19,7 @@ public:
QString mDeviceName;
unsigned int mDevicePollPeriod;
CCANDeviceConfig &operator=(const CCANDeviceConfig *source);
CCANDeviceConfig &operator=(const CCANDeviceConfig &source);
};
QDataStream &operator<<(QDataStream &out, const CCANDeviceConfig &source);
+71 -6
View File
@@ -1,5 +1,6 @@
#include "CANSignal.h"
#include "defines.h"
#include <QtEndian>
CCANSignal::CCANSignal():
@@ -14,12 +15,18 @@ int CCANSignal::ComputeNewSignalValue(quint64 NewValue, quint16 MessageSize)
{
if(mEncoding == CAN_SIGNAL_ENCODING_INTEL)
{
//TODO: trouver un device qui crache du intel??
mRawValue = NewValue;
mRawValue = qFromBigEndian(NewValue);
// mRawValue = NewValue;
mRawValue >>= mStartBit;
quint64 mask = 1;
mask <<= mSignalSize;
mask -= 1;
mRawValue &= mask;
}
else if(mEncoding == CAN_SIGNAL_ENCODING_MOTOROLA)
{
//mRawValue = MotorolaValue;
mRawValue = NewValue;
int StartIndex = mStartBit - (mStartBit % 8) + 7 - (mStartBit % 8);
int shift = ((MessageSize * 8) - StartIndex -1);
@@ -36,9 +43,67 @@ int CCANSignal::ComputeNewSignalValue(quint64 NewValue, quint16 MessageSize)
}
mPhysicalValue = ((signed) mRawValue * mValueFactor) + mValueOffset;
// mPhysicalValueUINT = ((quint64)((quint64) mRawValue * mValueFactor)) + (quint64)mValueOffset;
// mPhysicalValue = (qint64)((qint64) mRawValue * mValueFactor) + (qint64)mValueOffset;
//JFM 2023-06-13 - Ajout casting des variables en fonction du data size.
//L'idée c'est de contenir la valeur physique dans un double, ce qui permet de ne pas avoir à gérer le type
//à chaque fois qu'on accède à la donnée. Mais pour que ça marche, il faut initialiser ce double comme il faut
//en castant en fonction de la taille et du signe de la donnée
qint64 SignedRawValue = 0;
if(mSignalSize <= 8)
{
if(mValueType == CAN_SIGNAL_TYPE_SIGNED_INT)
{
SignedRawValue = (double)((qint8)mRawValue);
}
else
{
SignedRawValue = (double)((quint8)mRawValue);
}
}
else if(mSignalSize <= 16)
{
if(mValueType == CAN_SIGNAL_TYPE_SIGNED_INT)
{
SignedRawValue = (double)((qint16)mRawValue);
}
else
{
SignedRawValue = (double)((quint16)mRawValue);
}
// qint16 RawShort = (qint16)mRawValue;
// SignedRawValue = (double)RawShort;
}
else if(mSignalSize <= 32)
{
if(mValueType == CAN_SIGNAL_TYPE_SIGNED_INT)
{
SignedRawValue = (double)((qint32)mRawValue);
}
else
{
SignedRawValue = (double)((quint32)mRawValue);
}
//SignedRawValue = (signed)mRawValue;
}
else
{
if(mValueType == CAN_SIGNAL_TYPE_SIGNED_INT)
{
SignedRawValue = (double)((signed)mRawValue);
}
else
{
SignedRawValue = (double)(mRawValue);
}
}
mPhysicalValue = (double)SignedRawValue;
mPhysicalValue *= mValueFactor;
mPhysicalValue += mValueOffset;
//JFM 2023-06-13 tentative de corriger le casting avec la vraie patente
//mPhysicalValue = ((signed) mRawValue * mValueFactor) + mValueOffset;
return RET_OK;
@@ -0,0 +1,55 @@
#include "CANWatchdog.h"
#include "GeneralMessagesLogDispatcher.h"
CCANWatchdog::CCANWatchdog()
{
mCANDriverIF = new CPCANInterface;
mIsCANInitialized = false;
mWatchdogTimer = new QTimer;
mWatchdogTimer->setSingleShot(false);
connect(mWatchdogTimer,&QTimer::timeout,this,&CCANWatchdog::WatchdogTimeoutTimerExpired);
}
int CCANWatchdog::Init(quint8 CANDeviceID, WORD CANDeviceBaudrate, unsigned int WDTPeriod)
{
if(WDTPeriod < 200)
{
WDTPeriod = 200;
qDebug("CANWatchdog:: Trying to init with WDT period lower tan 200ms");
}
mCANDeviceID = CANDeviceID;
mWDTPeriod = WDTPeriod;
mCANDeviceBaudrate = CANDeviceBaudrate;
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Démarrage du Watchdog CAN...");
if(mCANDriverIF->GetDeviceHandle(mCANDeviceID,mCANDeviceHandle) != RET_OK)
{
QString Log = QString("Impossible de trouver le module CAN Watchdog sur le channel %1").arg(mCANDeviceID);
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(Log,true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
mIsCANInitialized = false;
return RET_GENERAL_ERROR;
}
if(mCANDriverIF->Init(mCANDeviceHandle,mCANDeviceBaudrate) != RET_OK)
{
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Impossible d'initialiser la puck CAN du Watchdog",true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
mIsCANInitialized = false;
return RET_GENERAL_ERROR;
}
else
{
// mCANReadTimer->start(mCANPollPeriod);
mIsCANInitialized = true;
}
return RET_OK;
}
void CCANWatchdog::WatchdogTimeoutTimerExpired()
{
}
+32
View File
@@ -0,0 +1,32 @@
#ifndef CANWATCHDOG_H
#define CANWATCHDOG_H
#include <QObject>
#include "PCANInterface.h"
#include <QTimer>
class CCANWatchdog: public QObject
{
Q_OBJECT
public:
CCANWatchdog();
int Init(quint8 CANDeviceID, TPCANBaudrate CANDeviceBaudrate, unsigned int WDTPeriod);
CPCANInterface *mCANDriverIF;
unsigned int mWDTPeriod;
quint8 mCANDeviceID;
TPCANBaudrate mCANDeviceBaudrate;
QTimer *mWatchdogTimer;
private:
bool mIsCANInitialized;
TPCANHandle mCANDeviceHandle;
public slots:
void WatchdogTimeoutTimerExpired();
};
#endif // CANWATCHDOG_H
@@ -0,0 +1,35 @@
#include "CANWatchdogConfig.h"
CCANWatchdogConfig::CCANWatchdogConfig()
{
}
CCANWatchdogConfig& CCANWatchdogConfig::operator=(const CCANWatchdogConfig &source)
{
if(&source == this)
return *this;
this->mCANDeviceID = source.mCANDeviceID;
this->mCANDeviceBaudrate = source.mCANDeviceBaudrate;
this->mWatchdogTimeout = source.mWatchdogTimeout;
return *this;
}
QDataStream &operator>>(QDataStream &in, CCANWatchdogConfig &dest)
{
in >> dest.mCANDeviceID
>> dest.mCANDeviceBaudrate
>> dest.mWatchdogTimeout;
return in;
}
QDataStream &operator<<(QDataStream &out, const CCANWatchdogConfig &source)
{
out << source.mCANDeviceID
<< source.mCANDeviceBaudrate
<< source.mWatchdogTimeout;
return out;
}
@@ -0,0 +1,25 @@
#ifndef CANWATCHDOGCONFIG_H
#define CANWATCHDOGCONFIG_H
#include <QDataStream>
#include <QString>
#include "PCANBasic.h"
class CCANWatchdogConfig
{
public:
CCANWatchdogConfig();
quint8 mCANDeviceID;
TPCANBaudrate mCANDeviceBaudrate;
unsigned int mWatchdogTimeout;
CCANWatchdogConfig &operator=(const CCANWatchdogConfig &source);
};
QDataStream &operator<<(QDataStream &out, const CCANWatchdogConfig &source);
QDataStream &operator>>(QDataStream &in, CCANWatchdogConfig &dest);
#endif // CANWATCHDOGCONFIG_H
@@ -28,19 +28,19 @@ QDataStream &operator<<(QDataStream &out, const CCloudParams &source)
return out;
}
CCloudParams& CCloudParams::operator=(const CCloudParams *source)
CCloudParams& CCloudParams::operator=(const CCloudParams &source)
{
if(source == this)
if(&source == this)
{
return *this;
}
this->mMQTTBrokerHostName = source->mMQTTBrokerHostName;
this->mMQTTBrokerPassword = source->mMQTTBrokerPassword;
this->mMQTTBrokerPort = source->mMQTTBrokerPort;
this->mMQTTBrokerUserName = source->mMQTTBrokerUserName;
this->mMQTTTopicPrefix = source->mMQTTTopicPrefix;
this->mMQTTTransmitTimeout = source->mMQTTTransmitTimeout;
this->mMQTTBrokerHostName = source.mMQTTBrokerHostName;
this->mMQTTBrokerPassword = source.mMQTTBrokerPassword;
this->mMQTTBrokerPort = source.mMQTTBrokerPort;
this->mMQTTBrokerUserName = source.mMQTTBrokerUserName;
this->mMQTTTopicPrefix = source.mMQTTTopicPrefix;
this->mMQTTTransmitTimeout = source.mMQTTTransmitTimeout;
return *this;
}
@@ -14,7 +14,7 @@ public:
quint32 mMQTTBrokerPort;
quint32 mMQTTTransmitTimeout;
CCloudParams &operator=(const CCloudParams *source);
CCloudParams &operator=(const CCloudParams &source);
};
QDataStream &operator<<(QDataStream &out, const CCloudParams &source);
+12 -2
View File
@@ -150,6 +150,10 @@ void CCANViewerPage::MessageSelectionChanged()
//Phys value
//JFM 2023-06-13 changé pour forcer toujours à float
NewItem = new QTableWidgetItem(QString("%1").arg(Msg->mSignalsList.at(signal).mPhysicalValue,0,'f',1));
/*
if(Msg->mSignalsList.at(signal).mValueType == CCANSignal::CAN_SIGNAL_TYPE_UNSIGNED_INT)
{
NewItem = new QTableWidgetItem(QString("%1").arg((quint64)Msg->mSignalsList.at(signal).mPhysicalValue));
@@ -163,7 +167,7 @@ void CCANViewerPage::MessageSelectionChanged()
Msg->mSignalsList.at(signal).mValueType == CCANSignal::CAN_SIGNAL_TYPE_64_BIT_DOUBLE)
{
NewItem = new QTableWidgetItem(QString("%1").arg(Msg->mSignalsList.at(signal).mPhysicalValue,0,'f',1));
}
}*/
ui->mCANSignalTableWidget->setItem(signal,1,NewItem);
//Raw value
@@ -198,6 +202,12 @@ int CCANViewerPage::UpdateSignalsTable()
ui->mCANSignalTableWidget->item(row,0)->setText(Msg->mSignalsList.at(signal).mSignalName);
//Phys value
//JFM 2023-06-13 changé pour forcer toujours à float
//Mais cette fonciton n'est jamais appelée et NE FONCTIONNE PAS.
//TODO: Corriger les index des colonnes des items à afficher
ui->mCANSignalTableWidget->item(row,0)->setText(QString("%1").arg(Msg->mSignalsList.at(signal).mPhysicalValue,0,'f',1));
/*
if(Msg->mSignalsList.at(signal).mValueType == CCANSignal::CAN_SIGNAL_TYPE_UNSIGNED_INT)
{
ui->mCANSignalTableWidget->item(row,0)->setText(QString("%1").arg((quint64)Msg->mSignalsList.at(signal).mPhysicalValue));
@@ -210,7 +220,7 @@ int CCANViewerPage::UpdateSignalsTable()
Msg->mSignalsList.at(signal).mValueType == CCANSignal::CAN_SIGNAL_TYPE_64_BIT_DOUBLE)
{
ui->mCANSignalTableWidget->item(row,0)->setText(QString("%1").arg(Msg->mSignalsList.at(signal).mPhysicalValue,0,'f',1));
}
}*/
//Raw value
ui->mCANSignalTableWidget->item(row,0)->setText(QString("0x%1").arg(Msg->mSignalsList.at(signal).mRawValue,0,16));
@@ -64,6 +64,7 @@ CCANbusSettingsPage::CCANbusSettingsPage(QWidget *parent) :
ui->mDatabaseFileSelectBtn->hide();
ui->mCANBaudrateComboBx->setEnabled(false);
//ui->mCANIDComboBx->setEnabled(false);
ui->mCANDeviceIDSpinBx->setValue(1);
ui->mCANDeviceIDSpinBx->setEnabled(false); //JFM 2023-06-02
ui->mDevicePollPeriodSpinBx->setEnabled(false);
ui->mCancelModifyParamsBtn->hide();
@@ -1,11 +1,13 @@
#include "CCANWatchdogSettingsPage.h"
#include "ui_CCANWatchdogSettingsPage.h"
#include "CANDevice.h"
#include "OtarcikCan.h"
CCANWatchdogSettingsPage::CCANWatchdogSettingsPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::CCANWatchdogSettingsPage)
{
mProgramHandle = 0;
ui->setupUi(this);
connect(ui->mCANWatchdogChangBtn,&QPushButton::pressed,this,&CCANWatchdogSettingsPage::ChangeSettingsButtonPressed);
@@ -67,6 +69,7 @@ void CCANWatchdogSettingsPage::ChangeSettingsButtonPressed()
}
else
{
mIsSettingsChangeMode = false;
ui->mCANWatchdogCancelBtn->setVisible(false);
@@ -74,5 +77,28 @@ void CCANWatchdogSettingsPage::ChangeSettingsButtonPressed()
ui->mCANWatchdogDeviceIDSpinBx->setEnabled(false);
ui->mCANWatchdogTimeoutSpinBx->setEnabled(false);
ui->mCANWatchdogChangBtn->setText("Modifier");
//Save data...
mCANWatchdogConfig.mCANDeviceID = ui->mCANWatchdogDeviceIDSpinBx->value();
mCANWatchdogConfig.mWatchdogTimeout = ui->mCANWatchdogTimeoutSpinBx->value();
mCANWatchdogConfig.mCANDeviceBaudrate = ui->mCANWatchdogBaudrateComboBx->currentData().toInt();
mProgramHandle->SaveCANWatchdogSettingsRequest(&mCANWatchdogConfig);
}
}
int CCANWatchdogSettingsPage::SetCANWatchdogConfig(CCANWatchdogConfig *Config)
{
if(Config == 0)
{
return RET_GENERAL_ERROR;
}
mCANWatchdogConfig = *Config;
ui->mCANWatchdogDeviceIDSpinBx->setValue(mCANWatchdogConfig.mCANDeviceID);
ui->mCANWatchdogTimeoutSpinBx->setValue(mCANWatchdogConfig.mWatchdogTimeout);
ui->mCANWatchdogBaudrateComboBx->setCurrentIndex(ui->mCANWatchdogBaudrateComboBx->findData(mCANWatchdogConfig.mCANDeviceBaudrate));
return RET_OK;
}
@@ -2,6 +2,9 @@
#define CCANWATCHDOGSETTINGSPAGE_H
#include <QWidget>
#include "CANWatchdogConfig.h"
class COtarcikCan;
namespace Ui {
class CCANWatchdogSettingsPage;
@@ -15,10 +18,15 @@ public:
explicit CCANWatchdogSettingsPage(QWidget *parent = 0);
~CCANWatchdogSettingsPage();
bool mIsSettingsChangeMode;
COtarcikCan *mProgramHandle;
int SetCANWatchdogConfig(CCANWatchdogConfig* Config);
private:
Ui::CCANWatchdogSettingsPage *ui;
CCANWatchdogConfig mCANWatchdogConfig;
public slots:
void ChangeSettingsButtonPressed();
void CancelButtonPressed();
@@ -13,6 +13,9 @@ CGeneralStatusPage::CGeneralStatusPage(QWidget *parent) :
connect(ui->mClearGenMsgTxtBtn,&QPushButton::clicked,this,&CGeneralStatusPage::ClearGenMsgAreaBtnPressed);
SetMQTTConnectionStatus(false);
SetCANConnectionStatus(false);
ui->mCANModuleStatusTableWdgt->setColumnCount(3);
ui->mCANModuleStatusTableWdgt->setHorizontalHeaderLabels(QStringList() << "Nom" << "Statut" << "Buffer");
}
CGeneralStatusPage::~CGeneralStatusPage()
@@ -138,3 +141,46 @@ int CGeneralStatusPage::SetCANConnectionStatus(bool Connected)
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;
}
@@ -32,6 +32,7 @@ public:
int SetMQTTConnectionStatus(bool Connected);
int SetCANConnectionStatus(bool Connected);
int UpdateCANModuleStatus(QString ModuleName, QString ModuleStatus, QString Buffer);
private:
+31 -11
View File
@@ -50,8 +50,8 @@
<widget class="QLabel" name="mPuckCANLbl">
<property name="geometry">
<rect>
<x>390</x>
<y>520</y>
<x>1220</x>
<y>210</y>
<width>81</width>
<height>16</height>
</rect>
@@ -68,8 +68,8 @@
<widget class="QLabel" name="mClientMQTTLbl">
<property name="geometry">
<rect>
<x>370</x>
<y>550</y>
<x>1200</x>
<y>240</y>
<width>101</width>
<height>16</height>
</rect>
@@ -86,8 +86,8 @@
<widget class="QLabel" name="mPuckCANConStatLbl">
<property name="geometry">
<rect>
<x>470</x>
<y>520</y>
<x>1300</x>
<y>210</y>
<width>121</width>
<height>16</height>
</rect>
@@ -106,8 +106,8 @@
<widget class="QLabel" name="mClientMQTTConnStatLbl">
<property name="geometry">
<rect>
<x>470</x>
<y>550</y>
<x>1300</x>
<y>240</y>
<width>121</width>
<height>16</height>
</rect>
@@ -123,15 +123,35 @@
<string>Déconnecté</string>
</property>
</widget>
<widget class="QTableWidget" name="tableWidget">
<widget class="QTableWidget" name="mCANModuleStatusTableWdgt">
<property name="geometry">
<rect>
<x>1190</x>
<y>40</y>
<width>371</width>
<height>131</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>1200</x>
<y>20</y>
<width>371</width>
<height>441</height>
<width>221</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Statut des module CAN </string>
</property>
</widget>
</widget>
<resources/>
+17 -1
View File
@@ -16,6 +16,7 @@
#include "OtarcikCan.h"
#include "PCANBasic.h"
#include "QtEndian"
COtarcikCan::COtarcikCan(QObject *parent) : QObject(parent)
{
@@ -44,9 +45,9 @@ COtarcikCan::~COtarcikCan()
int COtarcikCan::Start()
{
mMainWindow.mCANbusSettingsPage->mProgramPtr = this;
mMainWindow.mDataLoggingSettingsPage->mProgramHandle = this;
mMainWindow.mCANWatchdogSettingsPage->mProgramHandle = this;
mMainWindow.show();
@@ -74,6 +75,8 @@ int COtarcikCan::Start()
mCANBusMQTTClient.ConnectToBroker();
mCANBusMQTTClient.SetCANDevicesList(&mCANDevicesList);
mMainWindow.mCANWatchdogSettingsPage->SetCANWatchdogConfig(mSystemConfig.GetCANWatchdogConfig());
mGPTimer->setSingleShot(false);
mGPTimer->start(5000);
@@ -203,3 +206,16 @@ int COtarcikCan::SetMQTTConnectionSatusRequest(bool Connected)
{
return mMainWindow.mGeneralStatusPage->SetMQTTConnectionStatus(Connected);
}
int COtarcikCan::UpdateCANModuleStatusRequest(QString ModuleName, QString ModuleStatus, QString Buffer)
{
return mMainWindow.mGeneralStatusPage->UpdateCANModuleStatus(ModuleName,ModuleStatus,Buffer);
}
int COtarcikCan::SaveCANWatchdogSettingsRequest(CCANWatchdogConfig *CANWatchdogConfig)
{
mSystemConfig.SetCANWatchdogConfig(CANWatchdogConfig);
return mSystemConfig.SaveConfig();
}
+3
View File
@@ -34,6 +34,9 @@ public:
int SetCANConnectionStatusRequest(bool Connected);
int SetMQTTConnectionSatusRequest(bool Connected);
int UpdateCANModuleStatusRequest(QString ModuleName, QString ModuleStatus, QString Buffer);
int SaveCANWatchdogSettingsRequest(CCANWatchdogConfig *CANWatchdogConfig);
private:
QList<CCANDevice*> mCANDevicesList;
+19
View File
@@ -73,6 +73,9 @@ int CSystemConfig::LoadConfig()
//Load general program settings
*InputStream >> mSaveLocalLogFile;
//Load CAN Watchdog parameters
*InputStream >> mCANWatchdogParams;
ConfigFile->close();
delete ConfigFile;
@@ -124,6 +127,9 @@ int CSystemConfig::SaveConfig()
//Save the general system parameters
*OutputStream << mSaveLocalLogFile;
//Save the CAN Watchdog params
*OutputStream << mCANWatchdogParams;
ConfigFile->flush();
ConfigFile->close();
@@ -166,6 +172,19 @@ CCloudParams *CSystemConfig::GetCloudParams()
return &mCloudLoggingParams;
}
CCANWatchdogConfig *CSystemConfig::GetCANWatchdogConfig()
{
return &mCANWatchdogParams;
}
int CSystemConfig::SetCANWatchdogConfig(CCANWatchdogConfig *Config)
{
if(Config == 0)
return RET_GENERAL_ERROR;
mCANWatchdogParams = *Config;
}
int CSystemConfig::SetCloudParams(CCloudParams *CloudParams)
{
if(CloudParams == 0)
+7
View File
@@ -7,6 +7,7 @@
#include <QDataStream>
#include "CANDeviceConfig.h"
#include "CloudParams.h"
#include "CANWatchdogConfig.h"
#define OTARCIK_CURRENT_CONFIG_FILE_VERSION 0x01
#define OTARCIK_CONFIG_FILE_MAGIC_NBR 0xDEADBEEF
@@ -30,6 +31,7 @@ public:
//Can devices configs
QList<CCANDeviceConfig*> mCANDeviceConfigList;
@@ -39,6 +41,11 @@ public:
//Misc general system settings
bool mSaveLocalLogFile;
//CAN Module watchdog settings
CCANWatchdogConfig mCANWatchdogParams;
CCANWatchdogConfig *GetCANWatchdogConfig();
int SetCANWatchdogConfig(CCANWatchdogConfig *Config);
};