Changement de l'identification des pucks CAN par device ID plutôt que par Handle
This commit is contained in:
@@ -26,7 +26,7 @@ CCANAnalyzer::~CCANAnalyzer()
|
||||
delete mCANReadTimer;
|
||||
}
|
||||
|
||||
int CCANAnalyzer::Init(TPCANHandle CANDeviceChannel, TPCANBaudrate CANDeviceBaudrate, QList<CCANMessage *> *MsgList, unsigned int PollPeriod)
|
||||
int CCANAnalyzer::Init(quint8 CANDeviceChannel, TPCANBaudrate CANDeviceBaudrate, QList<CCANMessage *> *MsgList, unsigned int PollPeriod)
|
||||
{
|
||||
if(MsgList == 0)
|
||||
{
|
||||
@@ -39,13 +39,22 @@ int CCANAnalyzer::Init(TPCANHandle CANDeviceChannel, TPCANBaudrate CANDeviceBaud
|
||||
}
|
||||
|
||||
|
||||
|
||||
mCANDeviceChannel = CANDeviceChannel;
|
||||
mCANPollPeriod = PollPeriod;
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Démarrage d'un module CAN...");
|
||||
|
||||
mDeviceMessagesList = MsgList;
|
||||
|
||||
if(mCANDriverIF->Init(mCANDeviceChannel,CANDeviceBaudrate) != RET_OK)
|
||||
if(mCANDriverIF->GetDeviceHandle(mCANDeviceChannel,mCANDeviceHandle) != RET_OK)
|
||||
{
|
||||
QString Log = QString("Impossible de trouver le module CAN avec le channel %1").arg(mCANDeviceChannel);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(Log,true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
mIsCANInitialized = false;
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
if(mCANDriverIF->Init(mCANDeviceHandle,CANDeviceBaudrate) != RET_OK)
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Impossible d'initialiser le matériel CAN",true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
mIsCANInitialized = false;
|
||||
@@ -80,9 +89,9 @@ int CCANAnalyzer::ReadCAN()
|
||||
|
||||
void CCANAnalyzer::CANTimerExpired()
|
||||
{
|
||||
QList<CCANMessage *> NewMessagesList = mCANDriverIF->ReadCANFullBuffer(mCANDeviceChannel);
|
||||
QList<CCANMessage *> NewMessagesList = mCANDriverIF->ReadCANFullBuffer(mCANDeviceHandle);
|
||||
|
||||
// qDebug("CAN Buffer size: %d",NewMessagesList.size());
|
||||
qDebug("CAN Buffer size: %d",NewMessagesList.size());
|
||||
|
||||
|
||||
for(int i = 0 ; i < NewMessagesList.size(); i++)
|
||||
|
||||
@@ -23,14 +23,15 @@ public:
|
||||
QTimer *mCANReadTimer;
|
||||
unsigned int mCANPollPeriod;
|
||||
|
||||
int Init(TPCANHandle CANDeviceChannel, TPCANBaudrate CANDeviceBaudrate, QList<CCANMessage *> *MsgList, unsigned int PollPeriod);
|
||||
int Init(quint8 CANDeviceChannel, TPCANBaudrate CANDeviceBaudrate, QList<CCANMessage *> *MsgList, unsigned int PollPeriod);
|
||||
int ReadCAN();
|
||||
|
||||
QList<CCANMessage *> *mDeviceMessagesList;
|
||||
|
||||
private:
|
||||
bool mIsCANInitialized;
|
||||
TPCANHandle mCANDeviceChannel;
|
||||
TPCANHandle mCANDeviceHandle;
|
||||
quint8 mCANDeviceChannel;
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
@@ -67,14 +67,17 @@ int CCANDevice::Init()
|
||||
mMessagesListLoaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(mCANAnalyzer.Init(mDeviceConfigInfo.mCANDeviceID,mDeviceConfigInfo.mCANDeviceBaudrate,&mMessageList,mDeviceConfigInfo.mDevicePollPeriod) != RET_OK)
|
||||
{
|
||||
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);
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
mCANDataLogger.SetMQTTTopicDevice(QString("CANBus/%1/").arg(mDeviceConfigInfo.mDeviceName));
|
||||
mCANDataLogger.SetMQTTClient(mCANMQTTClient);
|
||||
mProgramPtr->SetCANConnectionStatusRequest(true);
|
||||
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Dispositif [%1] initialisé avec succès!").arg(mDeviceConfigInfo.mDeviceName),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_SUCCESS_STATUS);
|
||||
return RET_OK;
|
||||
|
||||
@@ -11,7 +11,8 @@ public:
|
||||
CCANDeviceConfig();
|
||||
CCANDeviceConfig(CCANDeviceConfig &Other);
|
||||
|
||||
TPCANHandle mCANDeviceID;
|
||||
//TPCANHandle mCANDeviceID;
|
||||
quint8 mCANDeviceID;
|
||||
TPCANBaudrate mCANDeviceBaudrate;
|
||||
QString mCANDeviceDatabaseFilename;
|
||||
QString mDeviceDescription;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#include "MQTTClientWrapper.h"
|
||||
|
||||
#include "OtarcikCan.h"
|
||||
|
||||
CMQTTClientWrapper::CMQTTClientWrapper()
|
||||
{
|
||||
connect(&mMQTTClient,&QMqttClient::stateChanged,this,&CMQTTClientWrapper::StateChanged);
|
||||
mMQTTRefreshTimer = new QTimer;
|
||||
mMQTTRefreshTimer->setSingleShot(true);
|
||||
mProgramPtr = 0;
|
||||
}
|
||||
|
||||
CMQTTClientWrapper::~CMQTTClientWrapper()
|
||||
@@ -79,10 +80,12 @@ void CMQTTClientWrapper::StateChanged()
|
||||
case QMqttClient::Disconnected:
|
||||
{
|
||||
qDebug("MQTT client Disconnected");
|
||||
mProgramPtr->SetMQTTConnectionSatusRequest(false);
|
||||
break;
|
||||
}
|
||||
case QMqttClient::Connected:
|
||||
{
|
||||
mProgramPtr->SetMQTTConnectionSatusRequest(true);
|
||||
qDebug("MQTT client Connected");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "MQTTMessage.h"
|
||||
#include <QList>
|
||||
|
||||
class COtarcikCan;
|
||||
|
||||
class CMQTTClientWrapper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -20,9 +22,11 @@ public:
|
||||
int DisconnectFromBroker();
|
||||
int SendMQTTTestMessage();
|
||||
|
||||
COtarcikCan *mProgramPtr;
|
||||
QString mMQTTClientID;
|
||||
QTimer *mMQTTRefreshTimer;
|
||||
|
||||
|
||||
private:
|
||||
QMqttClient mMQTTClient;
|
||||
CCloudParams mMQTTParams;
|
||||
|
||||
@@ -42,7 +42,7 @@ CCANbusSettingsPage::CCANbusSettingsPage(QWidget *parent) :
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_5K",QVariant(PCAN_BAUD_5K));
|
||||
|
||||
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS1",QVariant(PCAN_USBBUS1));
|
||||
/* ui->mCANIDComboBx->addItem("PCAN_USBBUS1",QVariant(PCAN_USBBUS1));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS2",QVariant(PCAN_USBBUS2));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS3",QVariant(PCAN_USBBUS3));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS4",QVariant(PCAN_USBBUS4));
|
||||
@@ -57,13 +57,14 @@ CCANbusSettingsPage::CCANbusSettingsPage(QWidget *parent) :
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS13",QVariant(PCAN_USBBUS13));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS14",QVariant(PCAN_USBBUS14));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS15",QVariant(PCAN_USBBUS15));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS16",QVariant(PCAN_USBBUS16));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS16",QVariant(PCAN_USBBUS16));*/
|
||||
|
||||
|
||||
ui->mDeviceDescriptionTxtEdit->setEnabled(false);
|
||||
ui->mDatabaseFileSelectBtn->hide();
|
||||
ui->mCANBaudrateComboBx->setEnabled(false);
|
||||
ui->mCANIDComboBx->setEnabled(false);
|
||||
//ui->mCANIDComboBx->setEnabled(false);
|
||||
ui->mCANDeviceIDSpinBx->setEnabled(false); //JFM 2023-06-02
|
||||
ui->mDevicePollPeriodSpinBx->setEnabled(false);
|
||||
ui->mCancelModifyParamsBtn->hide();
|
||||
ui->mDeviceNameEditBx->setEnabled(false);
|
||||
@@ -147,7 +148,10 @@ int CCANbusSettingsPage::UpdatePage()
|
||||
//update device information
|
||||
ui->mDeviceNameEditBx->setPlainText(DevConfigInfo->mDeviceName);
|
||||
ui->mCANBaudrateComboBx->setCurrentIndex(ui->mCANBaudrateComboBx->findData(DevConfigInfo->mCANDeviceBaudrate));
|
||||
ui->mCANIDComboBx->setCurrentIndex(ui->mCANIDComboBx->findData(DevConfigInfo->mCANDeviceID));
|
||||
|
||||
//ui->mCANIDComboBx->setCurrentIndex(ui->mCANIDComboBx->findData(DevConfigInfo->mCANDeviceID)); //JFM 2023-06-02
|
||||
ui->mCANDeviceIDSpinBx->setValue(DevConfigInfo->mCANDeviceID);
|
||||
|
||||
ui->mDeviceDescriptionTxtEdit->setPlainText(DevConfigInfo->mDeviceDescription);
|
||||
|
||||
QFileInfo FileInfo(DevConfigInfo->mCANDeviceDatabaseFilename);
|
||||
@@ -359,7 +363,10 @@ int CCANbusSettingsPage::ModifyDeviceConfig()
|
||||
CCANDeviceConfig *ModifiedDevice = mCurModifiedDevConfig; //mDeviceConfigList.at(index);
|
||||
|
||||
ModifiedDevice->mCANDeviceBaudrate = ui->mCANBaudrateComboBx->currentData().toInt();
|
||||
|
||||
ModifiedDevice->mCANDeviceID = ui->mCANIDComboBx->currentData().toInt();
|
||||
ModifiedDevice->mCANDeviceID = ui->mCANDeviceIDSpinBx->value(); //JFM 2023-06-02
|
||||
|
||||
ModifiedDevice->mCANDeviceDatabaseFilename = ui->mDatabaseFileNameLbl->toolTip(); //The full path is stored in the tooltip!
|
||||
ModifiedDevice->mDeviceDescription = ui->mDeviceDescriptionTxtEdit->toPlainText();
|
||||
ModifiedDevice->mDeviceName = ui->mDeviceNameEditBx->toPlainText();
|
||||
@@ -373,7 +380,8 @@ int CCANbusSettingsPage::ModifyDeviceConfig()
|
||||
ui->mDeviceDescriptionTxtEdit->setEnabled(false);
|
||||
ui->mDatabaseFileSelectBtn->hide();
|
||||
ui->mCANBaudrateComboBx->setEnabled(false);
|
||||
ui->mCANIDComboBx->setEnabled(false);
|
||||
// ui->mCANIDComboBx->setEnabled(false); //JFM 2023-06-02
|
||||
ui->mCANDeviceIDSpinBx->setEnabled(false);
|
||||
ui->mDevicesList->setEnabled(true);
|
||||
ui->mDevicePollPeriodSpinBx->setEnabled(false);
|
||||
ui->mModifyDevParamsBtn->setText("Modifier");
|
||||
@@ -392,7 +400,9 @@ int CCANbusSettingsPage::ModifyDeviceConfig()
|
||||
ui->mDeviceDescriptionTxtEdit->setEnabled(true);
|
||||
ui->mDatabaseFileSelectBtn->show();
|
||||
ui->mCANBaudrateComboBx->setEnabled(true);
|
||||
ui->mCANIDComboBx->setEnabled(true);
|
||||
// ui->mCANIDComboBx->setEnabled(true); //JFM 2023-06-02
|
||||
ui->mCANDeviceIDSpinBx->setEnabled(true);
|
||||
|
||||
ui->mDevicesList->setEnabled(false);
|
||||
ui->mDevicePollPeriodSpinBx->setEnabled(true);
|
||||
ui->mModifyDevParamsBtn->setText("Sauvegarder");
|
||||
@@ -411,7 +421,9 @@ void CCANbusSettingsPage::CancelModifyDevBtnPressed()
|
||||
ui->mDeviceDescriptionTxtEdit->setEnabled(false);
|
||||
ui->mDatabaseFileSelectBtn->hide();
|
||||
ui->mCANBaudrateComboBx->setEnabled(false);
|
||||
ui->mCANIDComboBx->setEnabled(false);
|
||||
//ui->mCANIDComboBx->setEnabled(false);
|
||||
ui->mCANDeviceIDSpinBx->setEnabled(false);
|
||||
|
||||
ui->mDevicesList->setEnabled(true);
|
||||
ui->mDevicePollPeriodSpinBx->setEnabled(false);
|
||||
ui->mModifyDevParamsBtn->setText("Modifier");
|
||||
@@ -449,7 +461,10 @@ void CCANbusSettingsPage::AddDeviceBtnPressed()
|
||||
//update device information
|
||||
ui->mDeviceNameEditBx->setPlainText(NewDevConfig->mDeviceName);
|
||||
ui->mCANBaudrateComboBx->setCurrentIndex(ui->mCANBaudrateComboBx->findData(NewDevConfig->mCANDeviceBaudrate));
|
||||
ui->mCANIDComboBx->setCurrentIndex(ui->mCANIDComboBx->findData(NewDevConfig->mCANDeviceID));
|
||||
|
||||
ui->mCANIDComboBx->setCurrentIndex(ui->mCANIDComboBx->findData(NewDevConfig->mCANDeviceID)); //JFM 2023-06-02
|
||||
ui->mCANDeviceIDSpinBx->setValue(NewDevConfig->mCANDeviceID);
|
||||
|
||||
ui->mDeviceDescriptionTxtEdit->setPlainText(NewDevConfig->mDeviceDescription);
|
||||
ui->mDatabaseFileNameLbl->setText(NewDevConfig->mCANDeviceDatabaseFilename);
|
||||
ui->mDatabaseFileNameLbl->setToolTip(NewDevConfig->mCANDeviceDatabaseFilename);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<rect>
|
||||
<x>370</x>
|
||||
<y>20</y>
|
||||
<width>231</width>
|
||||
<width>321</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -28,7 +28,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Paramètres de la station Otarcik</string>
|
||||
<string>Paramètres CAN de la station Otarcik</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListWidget" name="mDevicesList">
|
||||
@@ -70,9 +70,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>60</y>
|
||||
<y>66</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
<height>10</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
@@ -81,20 +81,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Driver CAN ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="mCANIDComboBx">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>59</y>
|
||||
<width>131</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
<string>CAN Device ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mCANBaudrateLbl">
|
||||
@@ -253,6 +240,22 @@
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="mCANDeviceIDSpinBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>60</y>
|
||||
<width>71</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="mDatabaseGroupBox">
|
||||
<property name="geometry">
|
||||
@@ -403,6 +406,19 @@
|
||||
<string>Supprimer</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="mCANIDComboBx">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>790</x>
|
||||
<y>20</y>
|
||||
<width>131</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "ui_GeneralStatusPage.h"
|
||||
#include "QStringList"
|
||||
#include <QScrollBar>
|
||||
#include <QLibrary>
|
||||
|
||||
CGeneralStatusPage::CGeneralStatusPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@@ -10,6 +11,8 @@ CGeneralStatusPage::CGeneralStatusPage(QWidget *parent) :
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->mClearGenMsgTxtBtn,&QPushButton::clicked,this,&CGeneralStatusPage::ClearGenMsgAreaBtnPressed);
|
||||
SetMQTTConnectionStatus(false);
|
||||
SetCANConnectionStatus(false);
|
||||
}
|
||||
|
||||
CGeneralStatusPage::~CGeneralStatusPage()
|
||||
@@ -95,3 +98,43 @@ 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)
|
||||
{
|
||||
if(Connected)
|
||||
{
|
||||
ui->mPuckCANConStatLbl->setText("CONNECTÉE");
|
||||
QPalette pal = QPalette(ui->mPuckCANConStatLbl->palette());
|
||||
pal.setColor(QPalette::WindowText,QColor(Qt::darkGreen));
|
||||
ui->mPuckCANConStatLbl->setPalette(pal);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->mPuckCANConStatLbl->setText("DÉCONNECTÉE");
|
||||
QPalette pal = QPalette(ui->mPuckCANConStatLbl->palette());
|
||||
pal.setColor(QPalette::WindowText,QColor(Qt::red));
|
||||
ui->mPuckCANConStatLbl->setPalette(pal);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ public:
|
||||
int SetGeneralMsgText(QStringList Txt);
|
||||
int AddGeneralMsgBoxLineEntry(QString LineTxt);
|
||||
|
||||
int SetMQTTConnectionStatus(bool Connected);
|
||||
int SetCANConnectionStatus(bool Connected);
|
||||
|
||||
|
||||
private:
|
||||
Ui::CGeneralStatusPage *ui;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1725</width>
|
||||
<height>527</height>
|
||||
<height>628</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -47,6 +47,82 @@
|
||||
<string>Nettoyer</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mPuckCANLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>390</x>
|
||||
<y>520</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Puck CAN:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mClientMQTTLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>370</x>
|
||||
<y>550</y>
|
||||
<width>101</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Client MQTT:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mPuckCANConStatLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>470</x>
|
||||
<y>520</y>
|
||||
<width>121</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Déconnectée</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mClientMQTTConnStatLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>470</x>
|
||||
<y>550</y>
|
||||
<width>121</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Déconnecté</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -21,6 +21,7 @@ COtarcikCan::COtarcikCan(QObject *parent) : QObject(parent)
|
||||
{
|
||||
mGPTimer = new QTimer;
|
||||
connect(mGPTimer,SIGNAL(timeout()),this,SLOT(GPTimerExpired()));
|
||||
mCANBusMQTTClient.mProgramPtr = this;
|
||||
}
|
||||
|
||||
COtarcikCan::~COtarcikCan()
|
||||
@@ -190,3 +191,13 @@ void COtarcikCan::GPTimerExpired()
|
||||
{
|
||||
// mCANBusMQTTClient.SendMQTTTestMessage();
|
||||
}
|
||||
|
||||
int COtarcikCan::SetCANConnectionStatusRequest(bool Connected)
|
||||
{
|
||||
mMainWindow.mGeneralStatusPage->SetCANConnectionStatus(Connected);
|
||||
}
|
||||
|
||||
int COtarcikCan::SetMQTTConnectionSatusRequest(bool Connected)
|
||||
{
|
||||
mMainWindow.mGeneralStatusPage->SetMQTTConnectionStatus(Connected);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ public:
|
||||
int SaveCANDevicesConfigRequest(QList<CCANDeviceConfig*> *DevicesConfigList);
|
||||
int SaveCloudLoggingConfigRequest(CCloudParams *CloudParams);
|
||||
|
||||
int SetCANConnectionStatusRequest(bool Connected);
|
||||
int SetMQTTConnectionSatusRequest(bool Connected);
|
||||
|
||||
private:
|
||||
QList<CCANDevice*> mCANDevicesList;
|
||||
CCloudParams mCloudLoggingParams;
|
||||
|
||||
@@ -28,14 +28,30 @@ CPCANInterface::CPCANInterface(QObject *parent) : QObject(parent)
|
||||
CANInterfaceOpened = false;
|
||||
}
|
||||
|
||||
int CPCANInterface::Init(TPCANHandle CANDeviceChannel, TPCANBaudrate CANBaudRate)
|
||||
int CPCANInterface::GetDeviceHandle(quint8 DeviceID, TPCANHandle &Handle)
|
||||
{
|
||||
TPCANHandle TempHandle;
|
||||
QString Parameters = QString("devicetype=pcan_usb, deviceid=%1").arg(DeviceID);
|
||||
if(CAN_LookUpChannel(Parameters.toLocal8Bit().data(),&TempHandle) != PCAN_ERROR_OK)
|
||||
{
|
||||
Handle = 0;
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
Handle = TempHandle;
|
||||
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Module PCAN trouvé à l'adresse %1 avec le handle 0x%2").arg(DeviceID).arg(Handle,0,16));
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CPCANInterface::Init(TPCANHandle CANDeviceHandle, TPCANBaudrate CANBaudRate)
|
||||
{
|
||||
mInterfaceBaudrate = CANBaudRate;
|
||||
mInterfaceCANHandle = CANDeviceChannel;
|
||||
mInterfaceCANHandle = CANDeviceHandle;
|
||||
|
||||
TPCANStatus Result;
|
||||
Result = CAN_Initialize(CANDeviceChannel, CANBaudRate);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Initialisation d'un module PCAN. Channel:%1, Baudrate:%2").arg(CANDeviceChannel).arg(CANBaudRate));
|
||||
Result = CAN_Initialize(CANDeviceHandle, CANBaudRate);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Initialisation d'un module PCAN. Handle:0x%1, Baudrate:%2").arg(CANDeviceHandle,0,16).arg(CANBaudRate));
|
||||
|
||||
if(Result != PCAN_ERROR_OK)
|
||||
{
|
||||
|
||||
@@ -15,9 +15,10 @@ class CPCANInterface : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CPCANInterface(QObject *parent = 0);
|
||||
int Init(TPCANHandle CANDeviceChannel, TPCANBaudrate CANBaudRate);
|
||||
int Init(TPCANHandle CANDeviceHandle, TPCANBaudrate CANBaudRate);
|
||||
int DeInit();
|
||||
bool IsInterfaceOpened(){return CANInterfaceOpened;}
|
||||
int GetDeviceHandle(quint8 DeviceID, TPCANHandle &Handle);
|
||||
|
||||
bool CANInterfaceOpened;
|
||||
QList<CCANMessage*> ReadCANFullBuffer(unsigned short Channel);
|
||||
|
||||
Reference in New Issue
Block a user