Développement cloud.
This commit is contained in:
@@ -90,6 +90,7 @@ void CCANAnalyzer::CANTimerExpired()
|
||||
if(NewMessagesList.at(i)->mCANMsgID == mDeviceMessagesList->at(j)->mCANMsgID)
|
||||
{
|
||||
mDeviceMessagesList->at(j)->UpdateValue(NewMessagesList.at(i));
|
||||
mDeviceMessagesList->at(j)->mPendingData = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,6 +101,7 @@ void CCANAnalyzer::CANTimerExpired()
|
||||
delete NewMessagesList.takeFirst();
|
||||
}
|
||||
|
||||
|
||||
mDevicePtr->NewMessageParsed();
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,74 @@
|
||||
#include "CANDataLogger.h"
|
||||
#include "defines.h"
|
||||
|
||||
CCANDataLogger::CCANDataLogger()
|
||||
CCANDataLogger::CCANDataLogger():
|
||||
mTopicDeviceString("")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
int CCANDataLogger::LogNewData(const QList<CCANMessage *> *MsgList)
|
||||
{
|
||||
//MQTT
|
||||
//For each message in the list, we create a CCANMessage
|
||||
|
||||
//First, clear the current list
|
||||
mMQTTMsgList.clear();
|
||||
qDebug("\n\n\n");
|
||||
|
||||
for(int i = 0; i < MsgList->size(); i++)
|
||||
{
|
||||
if(MsgList->at(i)->mPendingData == true)
|
||||
{
|
||||
CCANMessage *Msg = MsgList->at(i);
|
||||
QString MsgPayload = "{";
|
||||
QString MsgTopic = mTopicDeviceString;
|
||||
MsgTopic.append(Msg->mCANMsgName);
|
||||
MsgTopic.append("/");
|
||||
|
||||
//For each signal with new data, insert an entry in the JSon payload string
|
||||
for(int signal = 0; signal < Msg->mSignalsList.size(); signal++)
|
||||
{
|
||||
QString SignalData;
|
||||
CCANSignal *Signal = Msg->mSignalsList.at(signal);
|
||||
if(Signal->mValueType == CCANSignal::CAN_SIGNAL_TYPE_UNSIGNED_INT)
|
||||
{
|
||||
SignalData = QString("\"%1\":%2").arg(Signal->mSignalName).arg((quint64)Signal->mPhysicalValue);
|
||||
}
|
||||
else if(Signal->mValueType == CCANSignal::CAN_SIGNAL_TYPE_SIGNED_INT)
|
||||
{
|
||||
SignalData = QString("\"%1\":%2").arg(Signal->mSignalName).arg((qint64)Signal->mPhysicalValue);
|
||||
}
|
||||
else if(Signal->mValueType == CCANSignal::CAN_SIGNAL_TYPE_32_BIT_FLOAT ||
|
||||
Signal->mValueType == CCANSignal::CAN_SIGNAL_TYPE_64_BIT_DOUBLE)
|
||||
{
|
||||
SignalData = QString("\"%1\":%2").arg(Signal->mSignalName).arg(Signal->mPhysicalValue,0,'f',1);
|
||||
}
|
||||
MsgPayload.append(SignalData);
|
||||
|
||||
if(signal < Msg->mSignalsList.size()-1)
|
||||
{
|
||||
MsgPayload.append(",");
|
||||
}
|
||||
}
|
||||
MsgPayload.append("}");
|
||||
|
||||
qDebug("%s",qPrintable(MsgPayload));
|
||||
|
||||
CMQTTMessage NewMessage(MsgTopic, MsgPayload);
|
||||
mMQTTMsgList.append(NewMessage);
|
||||
|
||||
} //if(MsgList->at(i)->mPendingData == true)
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
|
||||
}
|
||||
|
||||
int CCANDataLogger::SetMQTTTopicDevice(QString DeviceString)
|
||||
{
|
||||
mTopicDeviceString = DeviceString;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,25 @@
|
||||
#ifndef CANDATALOGGER_H
|
||||
#define CANDATALOGGER_H
|
||||
|
||||
#include <QString>
|
||||
#include "MQTTMessage.h"
|
||||
#include <QList>
|
||||
#include "CANMessage.h"
|
||||
|
||||
class CCANDataLogger
|
||||
{
|
||||
public:
|
||||
CCANDataLogger();
|
||||
|
||||
int LogNewData(const QList<CCANMessage*> *MsgList);
|
||||
|
||||
|
||||
//MQTT logging
|
||||
QString mTopicDeviceString;
|
||||
QList<CMQTTMessage> mMQTTMsgList;
|
||||
|
||||
int SetMQTTTopicDevice(QString DeviceString);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // CANDATALOGGER_H
|
||||
#endif // CANDATALOGGER_H
|
||||
|
||||
@@ -72,6 +72,8 @@ int CCANDevice::Init()
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
mCANDataLogger.SetMQTTTopicDevice(QString("CANBus/%1/").arg(mDeviceConfigInfo.mDeviceName));
|
||||
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Dispositif [%1] initialisé avec succès!").arg(mDeviceConfigInfo.mDeviceName),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_SUCCESS_STATUS);
|
||||
return RET_OK;
|
||||
}
|
||||
@@ -92,7 +94,13 @@ int CCANDevice::Init(QString DatabaseFileName, TPCANHandle CANDeviceID, TPCANBau
|
||||
|
||||
int CCANDevice::NewMessageParsed()
|
||||
{
|
||||
return mProgramPtr->UpdateCANViewerDataRequest(&mMessageList);
|
||||
mCANDataLogger.LogNewData(&mMessageList);
|
||||
mProgramPtr->UpdateCANViewerDataRequest(&mMessageList);
|
||||
|
||||
for(int i = 0; i < mMessageList.size(); i++)
|
||||
mMessageList.at(i)->mPendingData = false;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <QList>
|
||||
#include "PCANBasic.h"
|
||||
#include "CANDeviceConfig.h"
|
||||
#include "CANDataLogger.h"
|
||||
|
||||
class COtarcikCan;
|
||||
|
||||
@@ -31,6 +32,7 @@ public:
|
||||
bool mMessagesListLoaded;
|
||||
CCANAnalyzer mCANAnalyzer; //The module that handles the USB puck and decodes the data
|
||||
CCANDatabase mCANDatabase; //The device's database loaded from dbc file
|
||||
CCANDataLogger mCANDataLogger;
|
||||
|
||||
QList<CCANMessage*> mMessageList;
|
||||
|
||||
@@ -41,6 +43,7 @@ public:
|
||||
private:
|
||||
bool mConfigSet;
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
#include "CANMessage.h"
|
||||
#include "defines.h"
|
||||
|
||||
CCANMessage::CCANMessage()
|
||||
CCANMessage::CCANMessage():
|
||||
mPendingData(false)
|
||||
{
|
||||
mSignalsList.clear();
|
||||
}
|
||||
|
||||
CCANMessage::CCANMessage(const CCANMessage &Src)
|
||||
CCANMessage::CCANMessage(const CCANMessage &Src):
|
||||
mPendingData(false)
|
||||
{
|
||||
*this = Src;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
unsigned int mCANMsgType; // Type of the message, using the PCAN interface driver encoding defined in PCANbasic.h
|
||||
QByteArray mCANMsgData; // Raw data structure of the message, max size = 8 bytes
|
||||
quint64 mCANRawDataMotorola, mCANRawDataIntel;
|
||||
bool mPendingData;
|
||||
|
||||
|
||||
//Database generated message structure
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
#include "defines.h"
|
||||
|
||||
|
||||
CCANSignal::CCANSignal()
|
||||
CCANSignal::CCANSignal():
|
||||
mRawValue(0),
|
||||
mPhysicalValue(0.0)
|
||||
{
|
||||
mEncoding = CAN_SIGNAL_ENCODING_INVALID;
|
||||
|
||||
@@ -35,6 +37,8 @@ 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;
|
||||
|
||||
return RET_OK;
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@ public:
|
||||
|
||||
quint64 mRawValue;
|
||||
double mPhysicalValue;
|
||||
// quint64 mPhysicalValueUINT;
|
||||
// qint64 mPhysicalValueINT;
|
||||
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user