Buffering MQTT fonctionnel.
This commit is contained in:
parent
71215e98b7
commit
f535ae0578
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -258,7 +258,6 @@ Makefile: Otarcik_CAN.pro C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/win32-g++/qma
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5Gui.prl \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5Mqtt.prl \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5Network.prl \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5SerialPort.prl \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5Core.prl \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/qtmain.prl \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/build_pass.prf
|
||||
@ -451,7 +450,6 @@ C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5Widgets.prl:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5Gui.prl:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5Mqtt.prl:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5Network.prl:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5SerialPort.prl:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5Core.prl:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/qtmain.prl:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/build_pass.prf:
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -4,7 +4,7 @@
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += gui network serialport mqtt
|
||||
QT += gui network mqtt
|
||||
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
@ -66,7 +66,7 @@ SOURCES += Sources/main.cpp \
|
||||
Sources/DeviceDetectionConfig.cpp \
|
||||
Sources/LANDevicePresenceConfig.cpp \
|
||||
Sources/LANDeviceMonitor.cpp \
|
||||
Sources/LANDevicesPresenceMonitor.cpp
|
||||
Sources/LANDevicesPresenceMonitor.cpp \
|
||||
|
||||
HEADERS += Sources/MainWindow.h \
|
||||
Sources/PCANInterface.h \
|
||||
@ -103,7 +103,8 @@ HEADERS += Sources/MainWindow.h \
|
||||
Sources/DeviceDetectionConfig.h \
|
||||
Sources/LANDevicePresenceConfig.h \
|
||||
Sources/LANDeviceMonitor.h \
|
||||
Sources/LANDevicesPresenceMonitor.h
|
||||
Sources/LANDevicesPresenceMonitor.h \
|
||||
|
||||
|
||||
FORMS += Sources/Gui/MainWindow.ui \
|
||||
Sources/Gui/GeneralStatusPage.ui \
|
||||
|
||||
@ -131,7 +131,7 @@
|
||||
[START_SIGNALS] LANDevice3SeemsDead,1,5,4,B,1,0,1,0.000000,1.000000,,
|
||||
[START_SIGNALS] LANDevice4SeemsDead,1,5,5,B,1,0,1,0.000000,1.000000,,
|
||||
[START_SIGNALS] LANDevice5SeemsDead,1,5,6,B,1,0,1,0.000000,1.000000,,
|
||||
[START_SIGNALS] PC_Time,16,3,0,U,65535,0,1,0.000000,0.000100,,
|
||||
[START_SIGNALS] PC_Time,16,3,0,U,65535,0,1,0.000000,0.001000,,
|
||||
[START_SIGNALS] PC_Date,16,1,0,U,65535,0,1,0.000000,1.000000,d,
|
||||
[END_MSG]
|
||||
|
||||
|
||||
@ -8,9 +8,10 @@ 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,SIGNAL(messageSent(qint32)),this,SLOT(MQTTMessageSent(qint32)));
|
||||
connect(&mMQTTClient,&QMqttClient::messageStatusChanged,this,&CMQTTClientWrapper::MQTTMessageStatusChanged);
|
||||
connect(&mMQTTClient,&QMqttClient::messageSent,this,&CMQTTClientWrapper::MQTTMessageSent);
|
||||
// connect(&mMQTTClient,SIGNAL(messageSent(qint32)),this,SLOT(MQTTMessageSent(qint32)));
|
||||
// connect(&mMQTTClient,&QMqttClient::messageStatusChanged,this,&CMQTTClientWrapper::MQTTMessageStatusChanged);
|
||||
// connect(&mMQTTClient,SIGNAL(messageStatusChanged(qint32,QMqtt::MessageStatus,QMqttMessageStatusProperties)),this,SLOT(MQTTMessageStatusChanged(qint32,QMqtt::MessageStatus,QMqttMessageStatusProperties)));
|
||||
mMQTTRefreshTimer = new QTimer;
|
||||
mMQTTRefreshTimer->setSingleShot(true);
|
||||
connect(mMQTTRefreshTimer,&QTimer::timeout,this,&CMQTTClientWrapper::MQTTSendTimerExpired);
|
||||
@ -275,7 +276,7 @@ void CMQTTClientWrapper::MQTTSendTimerExpired()
|
||||
{
|
||||
for(int i = 0; i < MessagesList->size(); i++)
|
||||
{
|
||||
qint32 res = mMQTTClient.publish(MessagesList->at(i).mMessageTopic,MessagesList->at(i).mMessagePayload.toLocal8Bit(),0,true);
|
||||
qint32 res = mMQTTClient.publish(MessagesList->at(i).mMessageTopic,MessagesList->at(i).mMessagePayload.toLocal8Bit(),1,true);
|
||||
QString LogMsg = QString("Envoi d'un message MQTT. Topic: %1 Payload: %2 Result: %3").arg(MessagesList->at(i).mMessageTopic).arg(MessagesList->at(i).mMessagePayload).arg(res);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(LogMsg,"CMQTTClientWrapper",true,3);
|
||||
|
||||
@ -363,7 +364,7 @@ int CMQTTClientWrapper::SendNextQueueMessage()
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
CMQTTMessage *Msg = mMQTTMessagesQueue.takeFirst();
|
||||
mMQTTClient.publish(Msg->mMessageTopic,Msg->mMessagePayload.toLocal8Bit(),0,true);
|
||||
mMQTTClient.publish(Msg->mMessageTopic,Msg->mMessagePayload.toLocal8Bit(),1,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);
|
||||
|
||||
@ -378,12 +379,23 @@ int CMQTTClientWrapper::SendNextQueueMessage()
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Tous les messages MQTT de la FIFO ont été envoyés au serveur, passage en mode de transmission normal","CMQTTClientWrapper",true,2);
|
||||
}
|
||||
|
||||
UpdateGUIBufferingStatus();
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CMQTTClientWrapper::UpdateGUIBufferingStatus()
|
||||
{
|
||||
//mProgramPtr->UpdateMQTTBufferingStatusRequest(mBufferingModeText,mCircularBufferStatusText,mRemainingBufferingTimeText);
|
||||
if(mMessagesQueueMode == MQTT_QUEUE_MSG_MODE)
|
||||
{
|
||||
mBufferingModeText = "Buffering";
|
||||
}
|
||||
else
|
||||
{
|
||||
mBufferingModeText = "Transmitting";
|
||||
}
|
||||
mCircularBufferStatusText = QString("%1").arg(mMQTTMessagesQueue.size());
|
||||
mProgramPtr->UpdateMQTTBufferingStatusRequest(mBufferingModeText,mCircularBufferStatusText,0);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@ -396,7 +408,7 @@ void CMQTTClientWrapper::MQTTClientError(QMqttClient::ClientError error)
|
||||
void CMQTTClientWrapper::MQTTMessageSent(qint32 MsgID)
|
||||
{
|
||||
Q_UNUSED(MsgID)
|
||||
qDebug("MQTT msg ID %d sent",MsgID);
|
||||
// qDebug("MQTT msg ID %d sent",MsgID);
|
||||
#ifndef MQTT_USE_TIMER_TO_FLUSH_QUEUE
|
||||
if(mMessagesQueueMode != MQTT_QUEUE_MSG_MODE)
|
||||
{
|
||||
@ -408,7 +420,7 @@ 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);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Message MQTT de la FIFO transmis, transmission du prochain...","CMQTTClientWrapper",true,3);
|
||||
SendNextQueueMessage();
|
||||
|
||||
#endif
|
||||
@ -425,7 +437,7 @@ CMQTTMessage CMQTTClientWrapper::GetSystemStatusMessage()
|
||||
{
|
||||
CComputerBoardState tmp = mCPUInterface->GetComputerBoardState();
|
||||
QString MsgPayload = "{";
|
||||
QString MsgTopic = "GeneralPCStatus";
|
||||
QString MsgTopic = mMQTTParams.mMQTTTopicPrefix + "GeneralPCStatus";
|
||||
|
||||
//Millisecs to EPOCH timestamp format
|
||||
qint64 TimeStamp = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#ifndef LANDEVICEPRESENCECONFIG_H
|
||||
#define LANDEVICEPRESENCECONFIG_H
|
||||
#include <QDataStream>
|
||||
#include <QString>
|
||||
|
||||
class CLANDevicePresenceConfig
|
||||
{
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
#define MQTT_CLIENT_RECONNECT_TIMEOUT 5000 //Time in ms between reconnect attemps to MQTT broker when connection is lost
|
||||
#define MQTT_CLIENT_MSG_QUEUE_FLUSH_TIMEOUT 500 //The delay in ms between the TX messages when flushing the msg queue after a server reconnection
|
||||
#define MQTT_CLIENT_MSG_QUEUE_SIZE 500 //The maximum number of messages to be queued. Older messages are lost when adding a new one in a full queue
|
||||
#define MQTT_CLIENT_MSG_QUEUE_SIZE 5000 //The maximum number of messages to be queued. Older messages are lost when adding a new one in a full queue
|
||||
#define MQTT_TIMESTAMP_IN_PAYLOAD //Defining this adds the local timestamp to each MQTT payloads.
|
||||
//#define MQTT_USE_TIMER_TO_FLUSH_QUEUE //Use a timer based transmission of MQTT msgs while emtpying the queue instead of the "MessageSent" event.
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include <QApplication>
|
||||
#include "OtarcikCan.h"
|
||||
#include "windows.h"
|
||||
#include <QTextCodec>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
Binary file not shown.
50
Otarcik_CAN/debug/object_script.Otarcik_CAN.Debug
Normal file
50
Otarcik_CAN/debug/object_script.Otarcik_CAN.Debug
Normal file
@ -0,0 +1,50 @@
|
||||
debug/main.o
|
||||
debug/MainWindow.o
|
||||
debug/PCANInterface.o
|
||||
debug/OtarcikCan.o
|
||||
debug/GeneralStatusPage.o
|
||||
debug/GeneralMessagesLogDispatcher.o
|
||||
debug/CANViewerPage.o
|
||||
debug/CANDatabase.o
|
||||
debug/SystemConfig.o
|
||||
debug/CANbusSettingsPage.o
|
||||
debug/LoggingSettingsPage.o
|
||||
debug/CANAnalyzer.o
|
||||
debug/CANDevice.o
|
||||
debug/CANDeviceConfig.o
|
||||
debug/CANMessage.o
|
||||
debug/CANSignal.o
|
||||
debug/CANDataLogger.o
|
||||
debug/CloudParams.o
|
||||
debug/MQTTMessage.o
|
||||
debug/MQTTClientWrapper.o
|
||||
debug/CCANWatchdogSettingsPage.o
|
||||
debug/CANWatchdogConfig.o
|
||||
debug/GeneralSystemParams.o
|
||||
debug/CANWatchdog.o
|
||||
debug/ComputerBoardInterface.o
|
||||
debug/CPUWatchdogConfig.o
|
||||
debug/SysLogger.o
|
||||
debug/InternetMonitor.o
|
||||
debug/ComputerBoardState.o
|
||||
debug/DeviceDetectionConfig.o
|
||||
debug/LANDevicePresenceConfig.o
|
||||
debug/LANDeviceMonitor.o
|
||||
debug/LANDevicesPresenceMonitor.o
|
||||
debug/moc_MainWindow.o
|
||||
debug/moc_PCANInterface.o
|
||||
debug/moc_OtarcikCan.o
|
||||
debug/moc_GeneralStatusPage.o
|
||||
debug/moc_CANViewerPage.o
|
||||
debug/moc_CANDatabase.o
|
||||
debug/moc_CANbusSettingsPage.o
|
||||
debug/moc_LoggingSettingsPage.o
|
||||
debug/moc_CANAnalyzer.o
|
||||
debug/moc_CANDevice.o
|
||||
debug/moc_MQTTClientWrapper.o
|
||||
debug/moc_CCANWatchdogSettingsPage.o
|
||||
debug/moc_CANWatchdog.o
|
||||
debug/moc_SysLogger.o
|
||||
debug/moc_InternetMonitor.o
|
||||
debug/moc_LANDeviceMonitor.o
|
||||
debug/moc_LANDevicesPresenceMonitor.o
|
||||
50
Otarcik_CAN/release/object_script.Otarcik_CAN.Release
Normal file
50
Otarcik_CAN/release/object_script.Otarcik_CAN.Release
Normal file
@ -0,0 +1,50 @@
|
||||
release/main.o
|
||||
release/MainWindow.o
|
||||
release/PCANInterface.o
|
||||
release/OtarcikCan.o
|
||||
release/GeneralStatusPage.o
|
||||
release/GeneralMessagesLogDispatcher.o
|
||||
release/CANViewerPage.o
|
||||
release/CANDatabase.o
|
||||
release/SystemConfig.o
|
||||
release/CANbusSettingsPage.o
|
||||
release/LoggingSettingsPage.o
|
||||
release/CANAnalyzer.o
|
||||
release/CANDevice.o
|
||||
release/CANDeviceConfig.o
|
||||
release/CANMessage.o
|
||||
release/CANSignal.o
|
||||
release/CANDataLogger.o
|
||||
release/CloudParams.o
|
||||
release/MQTTMessage.o
|
||||
release/MQTTClientWrapper.o
|
||||
release/CCANWatchdogSettingsPage.o
|
||||
release/CANWatchdogConfig.o
|
||||
release/GeneralSystemParams.o
|
||||
release/CANWatchdog.o
|
||||
release/ComputerBoardInterface.o
|
||||
release/CPUWatchdogConfig.o
|
||||
release/SysLogger.o
|
||||
release/InternetMonitor.o
|
||||
release/ComputerBoardState.o
|
||||
release/DeviceDetectionConfig.o
|
||||
release/LANDevicePresenceConfig.o
|
||||
release/LANDeviceMonitor.o
|
||||
release/LANDevicesPresenceMonitor.o
|
||||
release/moc_MainWindow.o
|
||||
release/moc_PCANInterface.o
|
||||
release/moc_OtarcikCan.o
|
||||
release/moc_GeneralStatusPage.o
|
||||
release/moc_CANViewerPage.o
|
||||
release/moc_CANDatabase.o
|
||||
release/moc_CANbusSettingsPage.o
|
||||
release/moc_LoggingSettingsPage.o
|
||||
release/moc_CANAnalyzer.o
|
||||
release/moc_CANDevice.o
|
||||
release/moc_MQTTClientWrapper.o
|
||||
release/moc_CCANWatchdogSettingsPage.o
|
||||
release/moc_CANWatchdog.o
|
||||
release/moc_SysLogger.o
|
||||
release/moc_InternetMonitor.o
|
||||
release/moc_LANDeviceMonitor.o
|
||||
release/moc_LANDevicesPresenceMonitor.o
|
||||
Loading…
x
Reference in New Issue
Block a user