Dev...
This commit is contained in:
@@ -10,6 +10,7 @@ CCANAnalyzer::CCANAnalyzer(QObject *parent) : QObject(parent)
|
||||
mCANDriverIF = new CPCANInterface;
|
||||
mIsCANInitialized = false;
|
||||
mDevicePtr = 0;
|
||||
mDeviceMessagesList = 0;
|
||||
|
||||
mCANReadTimer = new QTimer;
|
||||
mCANReadTimer->setInterval(200);
|
||||
@@ -22,26 +23,31 @@ CCANAnalyzer::~CCANAnalyzer()
|
||||
mCANDriverIF->DeInit();
|
||||
delete mCANDriverIF;
|
||||
delete mCANReadTimer;
|
||||
while (!mLastMessagesList.isEmpty())
|
||||
{
|
||||
delete mLastMessagesList.takeFirst();
|
||||
}
|
||||
}
|
||||
|
||||
int CCANAnalyzer::Init(TPCANHandle CANDeviceChannel,TPCANBaudrate CANDeviceBaudrate)
|
||||
int CCANAnalyzer::Init(TPCANHandle CANDeviceChannel, TPCANBaudrate CANDeviceBaudrate, QList<CCANMessage *> *MsgList)
|
||||
{
|
||||
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("OtarcikCan modules starting...");
|
||||
|
||||
if(mCANDriverIF->Init(CANDeviceChannel,CANDeviceBaudrate) != RET_OK)
|
||||
if(MsgList == 0)
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Could not initialize CAN hardware",true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
mCANDeviceChannel = CANDeviceChannel;
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Démarrage d'un module CAN...");
|
||||
|
||||
mDeviceMessagesList = MsgList;
|
||||
|
||||
if(mCANDriverIF->Init(mCANDeviceChannel,CANDeviceBaudrate) != RET_OK)
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Impossible d'initialiser le matériel CAN",true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
mIsCANInitialized = false;
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
mCANReadTimer->start();
|
||||
// mCANReadTimer->start();
|
||||
mIsCANInitialized = true;
|
||||
}
|
||||
|
||||
@@ -68,50 +74,70 @@ int CCANAnalyzer::ReadCAN()
|
||||
|
||||
void CCANAnalyzer::CANTimerExpired()
|
||||
{
|
||||
QList<CCANMessage *> NewMessagesList = mCANDriverIF->ReadCANFullBuffer(0x51U);
|
||||
QList<CCANMessage *> NewMessagesList = mCANDriverIF->ReadCANFullBuffer(mCANDeviceChannel);
|
||||
|
||||
|
||||
for(int i = 0 ; i < NewMessagesList.size(); i++)
|
||||
{
|
||||
for(int j = 0; j < mDeviceMessagesList->size(); j++)
|
||||
{
|
||||
if(NewMessagesList.at(i)->mCANMsgID == mDeviceMessagesList->at(j)->mCANMsgID)
|
||||
{
|
||||
mDeviceMessagesList->at(j)->UpdateValue(NewMessagesList.at(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Don't leak!!
|
||||
while(!NewMessagesList.isEmpty())
|
||||
{
|
||||
delete NewMessagesList.takeFirst();
|
||||
}
|
||||
|
||||
|
||||
unsigned int DeletedPtrs = 0;
|
||||
if(NewMessagesList.isEmpty())
|
||||
{
|
||||
mCANReadTimer->start();
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < NewMessagesList.size(); i++)
|
||||
{
|
||||
if(mLastMessagesList.isEmpty())
|
||||
{
|
||||
mLastMessagesList.append(NewMessagesList.at(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Check if new message ID for this device already exists in the list.
|
||||
bool found = false;
|
||||
for(int j = 0; j < mLastMessagesList.size(); j++)
|
||||
{
|
||||
if(NewMessagesList[i]->mCANChannel == mLastMessagesList[j]->mCANChannel &&
|
||||
NewMessagesList[i]->mCANMsgID == mLastMessagesList[j]->mCANMsgID)
|
||||
{
|
||||
//This message ID is already populated in the list. Update the value and delete the new instance
|
||||
mLastMessagesList[j]->mCANMsgData = NewMessagesList[i]->mCANMsgData;
|
||||
mLastMessagesList[j]->mCANMsgMicrosecs = NewMessagesList[i]->mCANMsgMicrosecs;
|
||||
mLastMessagesList[j]->mCANMsgMillisecs = NewMessagesList[i]->mCANMsgMillisecs;
|
||||
mLastMessagesList[j]->mCANMsgMillisecsOverflow = NewMessagesList[i]->mCANMsgMillisecsOverflow;
|
||||
// for(int i = 0; i < NewMessagesList.size(); i++)
|
||||
// {
|
||||
// if(mLastMessagesList.isEmpty())
|
||||
// {
|
||||
// mLastMessagesList.append(NewMessagesList.at(i));
|
||||
|
||||
delete NewMessagesList[i];
|
||||
DeletedPtrs++;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
{
|
||||
//This is the first time we receive this message, just add it to the list.
|
||||
mLastMessagesList.append(NewMessagesList[i]);
|
||||
}
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //Check if new message ID for this device already exists in the list.
|
||||
// bool found = false;
|
||||
// for(int j = 0; j < mLastMessagesList.size(); j++)
|
||||
// {
|
||||
// if(NewMessagesList[i]->mCANChannel == mLastMessagesList[j]->mCANChannel &&
|
||||
// NewMessagesList[i]->mCANMsgID == mLastMessagesList[j]->mCANMsgID)
|
||||
// {
|
||||
// //This message ID is already populated in the list. Update the value and delete the new instance
|
||||
// mLastMessagesList[j]->mCANMsgData = NewMessagesList[i]->mCANMsgData;
|
||||
// mLastMessagesList[j]->mCANMsgMicrosecs = NewMessagesList[i]->mCANMsgMicrosecs;
|
||||
// mLastMessagesList[j]->mCANMsgMillisecs = NewMessagesList[i]->mCANMsgMillisecs;
|
||||
// mLastMessagesList[j]->mCANMsgMillisecsOverflow = NewMessagesList[i]->mCANMsgMillisecsOverflow;
|
||||
|
||||
// delete NewMessagesList[i];
|
||||
// DeletedPtrs++;
|
||||
// found = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if(!found)
|
||||
// {
|
||||
// //This is the first time we receive this message, just add it to the list.
|
||||
// mLastMessagesList.append(NewMessagesList[i]);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
|
||||
NewMessagesList.clear();
|
||||
|
||||
|
||||
@@ -22,13 +22,14 @@ public:
|
||||
|
||||
QTimer *mCANReadTimer;
|
||||
|
||||
int Init(TPCANHandle CANDeviceChannel,TPCANBaudrate CANDeviceBaudrate);
|
||||
int Init(TPCANHandle CANDeviceChannel, TPCANBaudrate CANDeviceBaudrate, QList<CCANMessage *> *MsgList);
|
||||
int ReadCAN();
|
||||
|
||||
QList<CCANMessage *> mLastMessagesList;
|
||||
QList<CCANMessage *> *mDeviceMessagesList;
|
||||
|
||||
private:
|
||||
bool mIsCANInitialized;
|
||||
TPCANHandle mCANDeviceChannel;
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#include "CANDBMessage.h"
|
||||
|
||||
CCANDBMessage::CCANDBMessage()
|
||||
{
|
||||
// QTimer *testTimer = new QTimer;
|
||||
|
||||
// connect(testTimer,&QTimer::timeout,this,&CCANDBMessage::SlotTest);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CCANDBMessage::SlotTest()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef CANDBMESSAGE_H
|
||||
#define CANDBMESSAGE_H
|
||||
#include "CANDBSignal.h"
|
||||
#include <QList>
|
||||
#include "CANAnalyzer.h"
|
||||
|
||||
class CCANDBMessage : public CCANAnalyzer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CCANDBMessage();
|
||||
|
||||
public slots:
|
||||
void SlotTest();
|
||||
};
|
||||
|
||||
#endif // CANDBMESSAGE_H
|
||||
@@ -1,6 +0,0 @@
|
||||
#include "CANDBSignal.h"
|
||||
|
||||
CCANDBSignal::CCANDBSignal()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef CANDBSIGNAL_H
|
||||
#define CANDBSIGNAL_H
|
||||
|
||||
|
||||
class CCANDBSignal
|
||||
{
|
||||
public:
|
||||
CCANDBSignal();
|
||||
};
|
||||
|
||||
#endif // CANDBSIGNAL_H
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "defines.h"
|
||||
#include "CANDatabase.h"
|
||||
#include "kvaDbLib.h"
|
||||
#include "GeneralMessagesLogDispatcher.h"
|
||||
|
||||
const char* sigEncToStr(KvaDbSignalEncoding sigEnc);
|
||||
const char* sigRepToStr(KvaDbSignalType sigType);
|
||||
@@ -8,7 +8,7 @@ const char* sigRepToStr(KvaDbSignalType sigType);
|
||||
|
||||
CCANDatabase::CCANDatabase(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
mDatabaseFileLoaded = false;
|
||||
}
|
||||
|
||||
CCANDatabase::~CCANDatabase()
|
||||
@@ -20,214 +20,322 @@ int CCANDatabase::Init(QString DatabaseFileName)
|
||||
{
|
||||
mDatabaseFileName = DatabaseFileName;
|
||||
|
||||
LoadDatabaseFile(DatabaseFileName);
|
||||
|
||||
return RET_OK;
|
||||
return LoadDatabaseFile(DatabaseFileName);
|
||||
}
|
||||
|
||||
int CCANDatabase::LoadDatabaseFile(QString Filename)
|
||||
{
|
||||
KvaDbStatus status;
|
||||
unsigned int flags = 0;
|
||||
mDatabaseFileLoaded = false;
|
||||
|
||||
#define printf qDebug
|
||||
// Open a database handle
|
||||
status = kvaDbOpen(&mDatabaseDriverHandle);
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Impossible d'initialiser la base de données (création du handle impossble"),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
qDebug("Could not create a database handle: %d\n", status);
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
KvaDbStatus status;
|
||||
KvaDbHnd dh = 0;
|
||||
KvaDbMessageHnd mh = 0;
|
||||
KvaDbSignalHnd sh = 0;
|
||||
unsigned int flags = 0;
|
||||
char filename[] = "IVT-S_all-variations_12082020.dbc";
|
||||
// Load the database file
|
||||
|
||||
status = kvaDbReadFile(mDatabaseDriverHandle, Filename.toLocal8Bit().data());
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Erreur de base de données: impossible de charger le fichier %1").arg(Filename),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
qDebug("Could not load '%s': %d\n", Filename.toLocal8Bit().data(), status);
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
status = kvaDbGetFlags(mDatabaseDriverHandle, &flags);
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Erreur de base de données: impossible de charger les flags"),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
qDebug("kvaDbGetFlags failed: %d\n", status);
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Base de données chargée avec succès. Flags: 0x%1").arg(flags),true);
|
||||
qDebug(" Database: flags=0x%x\n", flags);
|
||||
|
||||
mDatabaseFileLoaded = true;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CCANDatabase::BuildMessageList(QList<CCANMessage *> *MsgListPtr)
|
||||
{
|
||||
if(mDatabaseFileLoaded == false)
|
||||
{
|
||||
qDebug("CCANDatabase error: Trying to build an unloaded database");
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
if(MsgListPtr == 0)
|
||||
{
|
||||
qDebug("CCANDatabase error: Trying to load database in an invalid list pointer...");
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
KvaDbStatus status;
|
||||
KvaDbMessageHnd mh = 0;
|
||||
KvaDbSignalHnd sh = 0;
|
||||
unsigned int flags = 0;
|
||||
|
||||
// Get the first message in the database
|
||||
status = kvaDbGetFirstMsg (mDatabaseDriverHandle, &mh);
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Erreur de base de données: impossible de charger le premier message"),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
qDebug ("kvaDbGetFirstMsg failed: %d\n", status);
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
// Go through all messages in the database
|
||||
while (status == kvaDbOK)
|
||||
{
|
||||
CCANMessage *NewMsg = new CCANMessage;
|
||||
char msg_name[100];
|
||||
// char msg_qname[200];
|
||||
char msg_comment[200];
|
||||
int dlc = 0;
|
||||
unsigned int id = 0;
|
||||
|
||||
|
||||
// Open a database handle
|
||||
status = kvaDbOpen (&dh);
|
||||
if (status != kvaDbOK) {
|
||||
printf("Could not create a database handle: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
// Load the database file
|
||||
status = kvaDbReadFile (dh, filename);
|
||||
if (status != kvaDbOK) {
|
||||
printf("Could not load '%s': %d\n", filename, status);
|
||||
return status;
|
||||
}
|
||||
// Clear the strings
|
||||
memset(msg_name, 0, sizeof(msg_name));
|
||||
// memset(msg_qname, 0, sizeof(msg_qname));
|
||||
memset(msg_comment, 0, sizeof(msg_comment));
|
||||
|
||||
status = kvaDbGetFlags(dh, &flags);
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetFlags failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
printf (" Database: flags=0x%x\n", flags);
|
||||
// Get the properties for each message
|
||||
status = kvaDbGetMsgName (mh, msg_name, sizeof (msg_name));
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
qDebug ("kvaDbGetMsgName failed: %d\n", status);
|
||||
// return RET_GENERAL_ERROR;
|
||||
}
|
||||
NewMsg->mCANMsgName = QString(msg_name);
|
||||
|
||||
// status = kvaDbGetMsgQualifiedName (mh, msg_qname, sizeof (msg_qname));
|
||||
// if (status != kvaDbOK)
|
||||
// {
|
||||
// qDebug ("kvaDbGetMsgQualifiedName failed: %d\n", status);
|
||||
// return RET_GENERAL_ERROR;
|
||||
// }
|
||||
|
||||
status = kvaDbGetMsgComment (mh, msg_comment, sizeof (msg_comment));
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
qDebug ("kvaDbGetMsgComment failed: %d\n", status);
|
||||
// return RET_GENERAL_ERROR;
|
||||
}
|
||||
NewMsg->mCANMsgComment = QString(msg_comment);
|
||||
|
||||
status = kvaDbGetMsgId (mh, &id, &flags);
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
qDebug ("kvaDbGetMsgId failed: %d\n", status);
|
||||
// return RET_GENERAL_ERROR;
|
||||
}
|
||||
NewMsg->mCANMsgID = id;
|
||||
NewMsg->mCANMsgFlags = flags;
|
||||
|
||||
status = kvaDbGetMsgDlc (mh, &dlc);
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
qDebug ("kvaDbGetMsgDlc failed: %d\n", status);
|
||||
// return RET_GENERAL_ERROR;
|
||||
}
|
||||
NewMsg->mCANMsgLength = dlc;
|
||||
|
||||
|
||||
// Get the first message in the database
|
||||
status = kvaDbGetFirstMsg (dh, &mh);
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetFirstMsg failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
// Go through all messages in the database
|
||||
while (status == kvaDbOK) {
|
||||
char msg_name[100];
|
||||
char msg_qname[200];
|
||||
char msg_comment[200];
|
||||
int dlc = 0;
|
||||
unsigned int id = 0;
|
||||
|
||||
// Clear the strings
|
||||
memset(msg_name, 0, sizeof(msg_name));
|
||||
memset(msg_qname, 0, sizeof(msg_qname));
|
||||
memset(msg_comment, 0, sizeof(msg_comment));
|
||||
|
||||
// Get the properties for each message
|
||||
status = kvaDbGetMsgName (mh, msg_name, sizeof (msg_name));
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetMsgName failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = kvaDbGetMsgQualifiedName (mh, msg_qname, sizeof (msg_qname));
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetMsgQualifiedName failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = kvaDbGetMsgComment (mh, msg_comment, sizeof (msg_comment));
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetMsgComment failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = kvaDbGetMsgId (mh, &id, &flags);
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetMsgId failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = kvaDbGetMsgDlc (mh, &dlc);
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetMsgDlc failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
// Print the properties for each message
|
||||
printf (" Msg: name='%s'\n", msg_name);
|
||||
printf (" qname='%s', comment='%s'\n", msg_qname, msg_comment);
|
||||
printf (" id=%x, dlc=%d, flags=%x\n", id, dlc, flags);
|
||||
// // Print the properties for each message
|
||||
// qDebug (" Msg: name='%s'\n", msg_name);
|
||||
// qDebug (" qname='%s', comment='%s'\n", msg_qname, msg_comment);
|
||||
// qDebug (" id=%x, dlc=%d, flags=%x\n", id, dlc, flags);
|
||||
|
||||
|
||||
// Go through all signals for this message
|
||||
status = kvaDbGetFirstSignal (mh, &sh);
|
||||
while (status == kvaDbOK) {
|
||||
char signal_name[100];
|
||||
char signal_qname[200];
|
||||
char signal_comment[200];
|
||||
char signal_unit[100];
|
||||
KvaDbSignalEncoding sigEnc;
|
||||
KvaDbSignalType sigType;
|
||||
int startbit = 0;
|
||||
int length = 0;
|
||||
double minval = 0;
|
||||
double maxval = 0;
|
||||
double factor = 0;
|
||||
double offset = 0;
|
||||
// Go through all signals for this message
|
||||
status = kvaDbGetFirstSignal (mh, &sh);
|
||||
while (status == kvaDbOK)
|
||||
{
|
||||
CCANSignal *NewSignal = new CCANSignal;
|
||||
char signal_name[100];
|
||||
char signal_qname[200];
|
||||
char signal_comment[200];
|
||||
char signal_unit[100];
|
||||
KvaDbSignalEncoding sigEnc;
|
||||
KvaDbSignalType sigType;
|
||||
int startbit = 0;
|
||||
int length = 0;
|
||||
double minval = 0;
|
||||
double maxval = 0;
|
||||
double factor = 0;
|
||||
double offset = 0;
|
||||
|
||||
// Reset the strings
|
||||
memset(signal_name, 0, sizeof(signal_name));
|
||||
memset(signal_qname, 0, sizeof(signal_qname));
|
||||
memset(signal_comment, 0, sizeof(signal_comment));
|
||||
memset(signal_unit, 0, sizeof(signal_unit));
|
||||
// Reset the strings
|
||||
memset(signal_name, 0, sizeof(signal_name));
|
||||
memset(signal_qname, 0, sizeof(signal_qname));
|
||||
memset(signal_comment, 0, sizeof(signal_comment));
|
||||
memset(signal_unit, 0, sizeof(signal_unit));
|
||||
|
||||
// Get the properties for each signal.
|
||||
status = kvaDbGetSignalName (sh, signal_name, sizeof (signal_name));
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetSignalName failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
// Get the properties for each signal.
|
||||
status = kvaDbGetSignalName (sh, signal_name, sizeof (signal_name));
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
qDebug ("kvaDbGetSignalName failed: %d\n", status);
|
||||
// return status;
|
||||
}
|
||||
NewSignal->mSignalName = QString(signal_name);
|
||||
|
||||
status = kvaDbGetSignalQualifiedName (sh, signal_qname, sizeof (signal_qname));
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetSignalQualifiedName failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
// status = kvaDbGetSignalQualifiedName (sh, signal_qname, sizeof (signal_qname));
|
||||
// if (status != kvaDbOK)
|
||||
// {
|
||||
// qDebug ("kvaDbGetSignalQualifiedName failed: %d\n", status);
|
||||
//// return status;
|
||||
// }
|
||||
|
||||
status = kvaDbGetSignalComment (sh, signal_comment, sizeof (signal_comment));
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetSignalComment failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = kvaDbGetSignalUnit (sh, signal_unit, sizeof (signal_unit));
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetSignalUnit failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
status = kvaDbGetSignalComment (sh, signal_comment, sizeof (signal_comment));
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
qDebug ("kvaDbGetSignalComment failed: %d\n", status);
|
||||
// return status;
|
||||
}
|
||||
NewSignal->mSignalComment = QString(signal_comment);
|
||||
|
||||
status = kvaDbGetSignalEncoding (sh, &sigEnc);
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetSignalEncoding failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
status = kvaDbGetSignalUnit (sh, signal_unit, sizeof (signal_unit));
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
qDebug ("kvaDbGetSignalUnit failed: %d\n", status);
|
||||
// return status;
|
||||
}
|
||||
NewSignal->mSignalUnit = QString(signal_unit);
|
||||
|
||||
status = kvaDbGetSignalRepresentationType(sh, &sigType);
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetSignalRepresentationType failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
status = kvaDbGetSignalEncoding (sh, &sigEnc);
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
qDebug ("kvaDbGetSignalEncoding failed: %d\n", status);
|
||||
// return status;
|
||||
}
|
||||
if(sigEnc == kvaDb_Intel)
|
||||
{
|
||||
NewSignal->mEncoding = CCANSignal::CAN_SIGNAL_ENCODING_INTEL;
|
||||
}
|
||||
else if(sigEnc == kvaDb_Motorola)
|
||||
{
|
||||
NewSignal->mEncoding = CCANSignal::CAN_SIGNAL_ENCODING_MOTOROLA;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewSignal->mEncoding = CCANSignal::CAN_SIGNAL_ENCODING_INVALID;
|
||||
qDebug ("kvaDbGetSignalEncoding returned an invalid encoding type: %d\n", sigEnc);
|
||||
}
|
||||
|
||||
status = kvaDbGetSignalValueLimits(sh, &minval, &maxval);
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetSignalValueLimits failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
status = kvaDbGetSignalRepresentationType(sh, &sigType);
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
qDebug ("kvaDbGetSignalRepresentationType failed: %d\n", status);
|
||||
// return status;
|
||||
}
|
||||
switch(sigType)
|
||||
{
|
||||
|
||||
status = kvaDbGetSignalValueScaling(sh, &factor, &offset);
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetSignalValueScaling failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
case kvaDb_Signed: ///< Signed integer
|
||||
{
|
||||
NewSignal->mValueType = CCANSignal::CAN_SIGNAL_TYPE_SIGNED_INT;
|
||||
break;
|
||||
}
|
||||
case kvaDb_Unsigned: ///< Unsigned integer
|
||||
{
|
||||
NewSignal->mValueType = CCANSignal::CAN_SIGNAL_TYPE_UNSIGNED_INT;
|
||||
break;
|
||||
}
|
||||
case kvaDb_Float: ///< Float, strictly 32 bit long
|
||||
{
|
||||
NewSignal->mValueType = CCANSignal::CAN_SIGNAL_TYPE_32_BIT_FLOAT;
|
||||
break;
|
||||
}
|
||||
case kvaDb_Double:
|
||||
{
|
||||
NewSignal->mValueType = CCANSignal::CAN_SIGNAL_TYPE_64_BIT_DOUBLE;
|
||||
break;
|
||||
}
|
||||
case kvaDb_Invalid: ///< Invalid representation
|
||||
default:
|
||||
{
|
||||
qDebug ("kvaDbGetSignalRepresentationType returned invalid type: %d\n", sigType);
|
||||
NewSignal->mValueType = CCANSignal::CAN_SIGNAL_TYPE_INVALID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
status = kvaDbGetSignalValueSize(sh, &startbit, &length);
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbGetSignalValueSize failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
status = kvaDbGetSignalValueLimits(sh, &minval, &maxval);
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
qDebug ("kvaDbGetSignalValueLimits failed: %d\n", status);
|
||||
// return status;
|
||||
}
|
||||
NewSignal->mMinValue = minval;
|
||||
NewSignal->mMaxValue = maxval;
|
||||
|
||||
printf(" Signal: name='%s', unit='%s'\n", signal_name, signal_unit);
|
||||
printf(" qname='%s'\n", signal_qname);
|
||||
printf(" comment='%s'\n", signal_comment);
|
||||
printf(" encoding='%s'\n", sigEncToStr(sigEnc));
|
||||
printf(" representation='%s'\n", sigRepToStr(sigType));
|
||||
printf(" value min=%.02f, value max=%.02f\n", minval, maxval);
|
||||
printf(" scale faktor=%.02f, offset=%.02f\n", factor, offset);
|
||||
printf(" startbit=%d, length=%d\n", startbit, length);
|
||||
status = kvaDbGetNextSignal (mh, &sh);
|
||||
}
|
||||
status = kvaDbGetSignalValueScaling(sh, &factor, &offset);
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
qDebug ("kvaDbGetSignalValueScaling failed: %d\n", status);
|
||||
// return status;
|
||||
}
|
||||
NewSignal->mValueFactor = factor;
|
||||
NewSignal->mValueOffset = offset;
|
||||
|
||||
status = kvaDbGetNextMsg (dh, &mh);
|
||||
}
|
||||
status = kvaDbGetSignalValueSize(sh, &startbit, &length);
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
qDebug ("kvaDbGetSignalValueSize failed: %d\n", status);
|
||||
// return status;
|
||||
}
|
||||
NewSignal->mStartBit = startbit;
|
||||
NewSignal->mSignalSize = length;
|
||||
|
||||
status = kvaDbClose (dh);
|
||||
if (status != kvaDbOK) {
|
||||
printf ("kvaDbClose failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
printf("\n\n");
|
||||
qDebug(" Signal: name='%s', unit='%s'\n", signal_name, signal_unit);
|
||||
qDebug(" qname='%s'\n", signal_qname);
|
||||
qDebug(" comment='%s'\n", signal_comment);
|
||||
qDebug(" encoding='%s'\n", sigEncToStr(sigEnc));
|
||||
qDebug(" representation='%s'\n", sigRepToStr(sigType));
|
||||
qDebug(" value min=%.02f, value max=%.02f\n", minval, maxval);
|
||||
qDebug(" scale faktor=%.02f, offset=%.02f\n", factor, offset);
|
||||
qDebug(" startbit=%d, length=%d\n", startbit, length);
|
||||
|
||||
return RET_OK;
|
||||
NewMsg->AddSignal(NewSignal);
|
||||
status = kvaDbGetNextSignal (mh, &sh);
|
||||
}
|
||||
|
||||
MsgListPtr->append(NewMsg);
|
||||
status = kvaDbGetNextMsg (mDatabaseDriverHandle, &mh);
|
||||
}
|
||||
|
||||
status = kvaDbClose (mDatabaseDriverHandle);
|
||||
if (status != kvaDbOK)
|
||||
{
|
||||
qDebug ("kvaDbClose failed: %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
qDebug("\n\n");
|
||||
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
const char* sigEncToStr(KvaDbSignalEncoding sigEnc)
|
||||
{
|
||||
if (sigEnc == kvaDb_Intel) {
|
||||
return "Intel";
|
||||
} else if (sigEnc == kvaDb_Motorola) {
|
||||
return "Motorola";
|
||||
} else {
|
||||
return "Undefined";
|
||||
}
|
||||
if (sigEnc == kvaDb_Intel) {
|
||||
return "Intel";
|
||||
} else if (sigEnc == kvaDb_Motorola) {
|
||||
return "Motorola";
|
||||
} else {
|
||||
return "Undefined";
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -235,17 +343,17 @@ const char* sigEncToStr(KvaDbSignalEncoding sigEnc)
|
||||
// -----------------------------------------------------------------------
|
||||
const char* sigRepToStr(KvaDbSignalType sigType)
|
||||
{
|
||||
if (sigType == kvaDb_Invalid) {
|
||||
return "Invalid";
|
||||
} else if (sigType == kvaDb_Signed) {
|
||||
return "Signed";
|
||||
} else if (sigType == kvaDb_Unsigned) {
|
||||
return "Unsigned";
|
||||
} else if (sigType == kvaDb_Float) {
|
||||
return "Float";
|
||||
} else if (sigType == kvaDb_Double) {
|
||||
return "Double";
|
||||
} else {
|
||||
return "Undefined";
|
||||
}
|
||||
if (sigType == kvaDb_Invalid) {
|
||||
return "Invalid";
|
||||
} else if (sigType == kvaDb_Signed) {
|
||||
return "Signed";
|
||||
} else if (sigType == kvaDb_Unsigned) {
|
||||
return "Unsigned";
|
||||
} else if (sigType == kvaDb_Float) {
|
||||
return "Float";
|
||||
} else if (sigType == kvaDb_Double) {
|
||||
return "Double";
|
||||
} else {
|
||||
return "Undefined";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
#define CANDATABASE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include "kvaDbLib.h"
|
||||
#include "CANMessage.h"
|
||||
#include "CANSignal.h"
|
||||
|
||||
class CCANDatabase : public QObject
|
||||
{
|
||||
@@ -12,9 +16,12 @@ public:
|
||||
|
||||
int Init(QString DatabaseFileName);
|
||||
int LoadDatabaseFile(QString Filename);
|
||||
int BuildMessageList(QList<CCANMessage*> *MsgListPtr);
|
||||
|
||||
private:
|
||||
QString mDatabaseFileName;
|
||||
KvaDbHnd mDatabaseDriverHandle;
|
||||
bool mDatabaseFileLoaded;
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -2,18 +2,38 @@
|
||||
|
||||
CCANDevice::CCANDevice(QObject *parent)
|
||||
{
|
||||
|
||||
mMessageList.clear();
|
||||
mMessagesListLoaded = false;
|
||||
}
|
||||
|
||||
CCANDevice::~CCANDevice()
|
||||
{
|
||||
|
||||
while (!mMessageList.isEmpty())
|
||||
{
|
||||
delete mMessageList.takeFirst();
|
||||
}
|
||||
}
|
||||
|
||||
int CCANDevice::Init(QString DatabaseFileName, unsigned short CANDeviceID, unsigned short CANDeviceBaudRate)
|
||||
int CCANDevice::Init(QString DatabaseFileName, TPCANHandle CANDeviceID, TPCANBaudrate CANDeviceBaudRate, QString DevDescription, QString DeviceName)
|
||||
{
|
||||
mCANDatabase.Init(DatabaseFileName);
|
||||
mCANAnalyzer.Init(CANDeviceID,CANDeviceBaudRate);
|
||||
mCANDeviceID = CANDeviceID;
|
||||
mCANDeviceBaudrate = CANDeviceBaudRate;
|
||||
mCANDeviceDatabaseFilename = DatabaseFileName;
|
||||
mDeviceDescription = DevDescription;
|
||||
mDeviceName = DeviceName;
|
||||
|
||||
if(mCANDatabase.Init(DatabaseFileName) == RET_OK)
|
||||
{
|
||||
if(mCANDatabase.BuildMessageList(&mMessageList) == RET_OK)
|
||||
{
|
||||
mMessagesListLoaded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
mMessagesListLoaded = false;
|
||||
}
|
||||
}
|
||||
mCANAnalyzer.Init(CANDeviceID,CANDeviceBaudRate,&mMessageList);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "PCANInterface.h"
|
||||
#include "CANDatabase.h"
|
||||
#include <QList>
|
||||
#include "PCANBasic.h"
|
||||
|
||||
class CCANDevice : public QObject
|
||||
{
|
||||
@@ -16,17 +17,22 @@ public:
|
||||
explicit CCANDevice(QObject *parent = 0);
|
||||
~CCANDevice();
|
||||
|
||||
int Init(QString DatabaseFileName, unsigned short CANDeviceID, unsigned short CANDeviceBaudRate);
|
||||
int Init(QString DatabaseFileName, TPCANHandle CANDeviceID, TPCANBaudrate CANDeviceBaudRate, QString DevDescription, QString DeviceName);
|
||||
|
||||
|
||||
private:
|
||||
QString mDeviceDatabaseFileName;
|
||||
unsigned int mCANDeviceID;
|
||||
|
||||
public:
|
||||
TPCANHandle mCANDeviceID;
|
||||
TPCANBaudrate mCANDeviceBaudrate;
|
||||
QString mCANDeviceDatabaseFilename;
|
||||
QString mDeviceDescription;
|
||||
QString mDeviceName;
|
||||
|
||||
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
|
||||
|
||||
QList<CCANMessage*> mMessageList;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "CANMessage.h"
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
CCANMessage::CCANMessage()
|
||||
{
|
||||
|
||||
mSignalsList.clear();
|
||||
}
|
||||
|
||||
CCANMessage::CCANMessage(const CCANMessage &Src)
|
||||
@@ -15,6 +15,13 @@ CCANMessage::CCANMessage(const quint32 Channel, const TPCANMsg CANMsg, const TPC
|
||||
{
|
||||
SetDataFromDriver(Channel,CANMsg,CANTimeStamp);
|
||||
}
|
||||
CCANMessage::~CCANMessage()
|
||||
{
|
||||
while (!mSignalsList.isEmpty())
|
||||
{
|
||||
delete mSignalsList.takeFirst();
|
||||
}
|
||||
}
|
||||
|
||||
int CCANMessage::SetDataFromDriver(quint32 Channel, TPCANMsg CANMsg, TPCANTimestamp CANTimeStamp)
|
||||
{
|
||||
@@ -35,6 +42,51 @@ int CCANMessage::SetDataFromDriver(quint32 Channel, TPCANMsg CANMsg, TPCANTimest
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CCANMessage::AddSignal(CCANSignal *NewSignal)
|
||||
{
|
||||
if(NewSignal == 0)
|
||||
{
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
mSignalsList.append(NewSignal);
|
||||
}
|
||||
|
||||
int CCANMessage::UpdateValue(CCANMessage *NewDeviceMessage)
|
||||
{
|
||||
if(NewDeviceMessage->mCANMsgID != mCANMsgID)
|
||||
{
|
||||
qDebug("CCANMEssage error: Trying to update mismatching message ID");
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
if(NewDeviceMessage->mCANMsgLength != mCANMsgLength)
|
||||
{
|
||||
qDebug("CCANMessage error: New device message length different than database!!!");
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
mCANMsgData = QByteArray(NewDeviceMessage->mCANMsgData);
|
||||
|
||||
mCANRawDataMotorola = mCANRawDataIntel= 0;
|
||||
|
||||
for(int i = 0; i < mCANMsgLength; i++)
|
||||
{
|
||||
mCANRawDataIntel += mCANMsgData[i];
|
||||
mCANRawDataMotorola += mCANMsgData[(mCANMsgLength - 1) - i];
|
||||
|
||||
mCANRawDataIntel <<= 8;
|
||||
mCANRawDataMotorola <<= 8;
|
||||
}
|
||||
|
||||
for(int i = 0; i < mSignalsList.size(); i++)
|
||||
{
|
||||
mSignalsList.at(i)->ComputeNewSignalValue(mCANRawDataMotorola,mCANRawDataIntel);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CCANMessage &source)
|
||||
{
|
||||
out << source.mCANChannel
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <QByteArray>
|
||||
#include <QDataStream>
|
||||
#include "PCANBasic.h"
|
||||
#include "CANSignal.h"
|
||||
#include <QList>
|
||||
|
||||
class CCANMessage
|
||||
{
|
||||
@@ -10,22 +12,32 @@ public:
|
||||
CCANMessage();
|
||||
CCANMessage(const CCANMessage &Src);
|
||||
CCANMessage(const quint32 Channel,const TPCANMsg CANMsg,const TPCANTimestamp CANTimeStamp);
|
||||
~CCANMessage();
|
||||
|
||||
unsigned int mCANChannel;
|
||||
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;
|
||||
|
||||
|
||||
quint32 mCANChannel; //Channel from which the message has been read
|
||||
//Database generated message structure
|
||||
QString mCANMsgName; //Name of message in dbc file
|
||||
QString mCANMsgComment; //misc comment from database
|
||||
unsigned int mCANMsgID; // 11/29-bit message identifier from database
|
||||
quint32 mCANMsgFlags; //Message flags from database
|
||||
unsigned int mCANMsgLength; // Data Length Code of the message (0..8) from database
|
||||
|
||||
quint64 mCANMsgID; // 11/29-bit message identifier
|
||||
quint8 mCANMsgType; // Type of the message, using the PCAN interface driver encoding defined in PCANbasic.h
|
||||
quint8 mCANMsgLength; // Data Length Code of the message (0..8)
|
||||
QByteArray mCANMsgData; // Data of the message, max size = 8 bytes
|
||||
QList<CCANSignal*> mSignalsList;
|
||||
|
||||
//Timestamp
|
||||
quint64 mCANMsgMillisecs; // Base-value: milliseconds: 0.. 2^32-1
|
||||
quint32 mCANMsgMillisecsOverflow; // Roll-arounds of millis
|
||||
quint32 mCANMsgMicrosecs; // Microseconds: 0..999
|
||||
quint64 mCANMsgMillisecs; // Base-value: milliseconds: 0.. 2^32-1
|
||||
quint32 mCANMsgMillisecsOverflow; // Roll-arounds of millis
|
||||
quint32 mCANMsgMicrosecs; // Microseconds: 0..999
|
||||
|
||||
CCANMessage &operator=(const CCANMessage *source);
|
||||
int SetDataFromDriver(quint32 Channel,TPCANMsg CANMsg,TPCANTimestamp CANTimeStamp);
|
||||
int AddSignal(CCANSignal* NewSignal);
|
||||
int UpdateValue(CCANMessage* NewDeviceMessage);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "CANSignal.h"
|
||||
#include "defines.h"
|
||||
|
||||
CCANSignal::CCANSignal()
|
||||
{
|
||||
mEncoding = CAN_SIGNAL_ENCODING_INVALID;
|
||||
|
||||
}
|
||||
|
||||
int CCANSignal::ComputeNewSignalValue(quint64 MotorolaValue, quint64 IntelValue)
|
||||
{
|
||||
if(mEncoding == CAN_SIGNAL_ENCODING_INTEL)
|
||||
{
|
||||
mRawValue = IntelValue;
|
||||
}
|
||||
else if(mEncoding == CAN_SIGNAL_ENCODING_MOTOROLA)
|
||||
{
|
||||
mRawValue = MotorolaValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
mRawValue >>= mStartBit;
|
||||
quint64 mask = ((1 << mSignalSize)-1);
|
||||
mRawValue &= mask;
|
||||
|
||||
mPhysicalValue = ((double) mRawValue * mValueFactor) + mValueOffset;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
#ifndef CANSIGNAL_H
|
||||
#define CANSIGNAL_H
|
||||
#include <QtGlobal>
|
||||
#include <QString>
|
||||
|
||||
class CCANSignal
|
||||
{
|
||||
public:
|
||||
|
||||
enum eCANSignalEncoding
|
||||
{
|
||||
CAN_SIGNAL_ENCODING_INTEL = 0,
|
||||
CAN_SIGNAL_ENCODING_MOTOROLA,
|
||||
CAN_SIGNAL_ENCODING_INVALID,
|
||||
|
||||
CAN_SIGNAL_ENCODING_MAX
|
||||
};
|
||||
|
||||
enum eCANSignalMultiplexing
|
||||
{
|
||||
CAN_SIGNAL_MULTIPLEXING_NONE,
|
||||
CAN_SIGNAL_MULTIPLEXING_SWITCH,
|
||||
CAN_SIGNAL_MULTIPLEXING_MULTIPLEXED,
|
||||
|
||||
CAN_SIGNAL_MULTIPLEXING_MAX
|
||||
};
|
||||
|
||||
enum eCANSIgnalValueType
|
||||
{
|
||||
CAN_SIGNAL_TYPE_INVALID,
|
||||
CAN_SIGNAL_TYPE_SIGNED_INT,
|
||||
CAN_SIGNAL_TYPE_UNSIGNED_INT,
|
||||
CAN_SIGNAL_TYPE_32_BIT_FLOAT,
|
||||
CAN_SIGNAL_TYPE_64_BIT_DOUBLE,
|
||||
|
||||
CAN_SIGNAL_TYPE_MAX
|
||||
};
|
||||
|
||||
public:
|
||||
CCANSignal();
|
||||
|
||||
|
||||
QString mSignalName;
|
||||
QString mSignalComment;
|
||||
unsigned int mEncoding;
|
||||
unsigned int mMultiplexing;
|
||||
unsigned int mStartBit;
|
||||
unsigned int mSignalSize;
|
||||
unsigned int mValueType;
|
||||
double mValueFactor;
|
||||
double mValueOffset;
|
||||
double mMinValue;
|
||||
double mMaxValue;
|
||||
QString mSignalUnit;
|
||||
|
||||
int ComputeNewSignalValue(quint64 MotorolaValue, quint64 IntelValue);
|
||||
|
||||
private:
|
||||
quint64 mRawValue;
|
||||
double mPhysicalValue;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // CANSIGNAL_H
|
||||
|
||||
/*
|
||||
physical_value = raw_value * factor + offset
|
||||
raw_value = (physical_value – offset) / factor
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Signal: name='_BA_Resp_SW_Ver_Revision', unit=''
|
||||
|
||||
qname='IVT-S_all-variations_12082020.IVT_Msg_Response._BA_Resp_SW_Ver_Revision'
|
||||
|
||||
comment=''
|
||||
|
||||
encoding='Motorola'
|
||||
|
||||
representation='Unsigned'
|
||||
|
||||
value min=0.00, value max=0.00
|
||||
|
||||
scale faktor=1.00, offset=0.00
|
||||
|
||||
startbit=24, length=8
|
||||
|
||||
*/
|
||||
@@ -56,7 +56,7 @@ int CGeneralMessagesLogDispatcher::Init()
|
||||
QString temp;
|
||||
mSystemLogFile->write("\n\n");
|
||||
mSystemLogFile->write(QString("********************************************************************\n").toUtf8());
|
||||
mSystemLogFile->write(QString("Otarcik CAN software startup on %1 at %2\n").arg(QDateTime::currentDateTime().date().toString("yyyy-MM-dd")).arg(QDateTime::currentDateTime().time().toString("hh:mm:ss")).toUtf8());
|
||||
mSystemLogFile->write(QString("Démarrage du logiciel Otarcik CAN le %1 à %2\n").arg(QDateTime::currentDateTime().date().toString("yyyy-MM-dd")).arg(QDateTime::currentDateTime().time().toString("hh:mm:ss")).toUtf8());
|
||||
mSystemLogFile->write(QString("********************************************************************\n").toUtf8());
|
||||
}
|
||||
return RET_OK;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Otracik</string>
|
||||
<string>Otarcik</string>
|
||||
</property>
|
||||
<property name="windowOpacity">
|
||||
<double>3.000000000000000</double>
|
||||
|
||||
@@ -1,14 +1,280 @@
|
||||
#include "ProgramSettingsPage.h"
|
||||
#include "ui_ProgramSettingsPage.h"
|
||||
|
||||
#include "CANDevice.h"
|
||||
//#include "CANMessage.h"
|
||||
//#include "CANSignal.h"
|
||||
//#include "PCANBasic.h"
|
||||
|
||||
|
||||
CProgramSettingsPage::CProgramSettingsPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::CProgramSettingsPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
mDevicesList = 0;
|
||||
|
||||
ui->mDBSignalDetailsTable->setColumnCount(10);
|
||||
ui->mDBSignalDetailsTable->setHorizontalHeaderLabels(QStringList() << "Signal" << "Bit No" << "Length" << "Type" << "Max Val" << "Min Val" << "Offset" << "Scale factor" << "Unit" << "Byte order");
|
||||
|
||||
|
||||
|
||||
ui->mCANBaudrateComboBx->clear();
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_1M",QVariant(PCAN_BAUD_1M));
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_800K",QVariant(PCAN_BAUD_800K));
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_500K",QVariant(PCAN_BAUD_500K));
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_250K",QVariant(PCAN_BAUD_250K));
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_125K",QVariant(PCAN_BAUD_125K));
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_100K",QVariant(PCAN_BAUD_100K));
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_95K",QVariant(PCAN_BAUD_95K));
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_83K",QVariant(PCAN_BAUD_83K));
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_50K",QVariant(PCAN_BAUD_50K));
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_47K",QVariant(PCAN_BAUD_47K));
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_33K",QVariant(PCAN_BAUD_33K));
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_20K",QVariant(PCAN_BAUD_20K));
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_10K",QVariant(PCAN_BAUD_10K));
|
||||
ui->mCANBaudrateComboBx->addItem("PCAN_BAUD_5K",QVariant(PCAN_BAUD_5K));
|
||||
|
||||
|
||||
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));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS5",QVariant(PCAN_USBBUS5));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS6",QVariant(PCAN_USBBUS6));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS7",QVariant(PCAN_USBBUS7));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS8",QVariant(PCAN_USBBUS8));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS9",QVariant(PCAN_USBBUS9));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS10",QVariant(PCAN_USBBUS10));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS11",QVariant(PCAN_USBBUS11));
|
||||
ui->mCANIDComboBx->addItem("PCAN_USBBUS12",QVariant(PCAN_USBBUS12));
|
||||
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->mDeviceDescriptionTxtEdit->setEnabled(false);
|
||||
ui->mDatabaseFileSelectBtn->hide();
|
||||
ui->mCANBaudrateComboBx->setEnabled(false);
|
||||
ui->mCANIDComboBx->setEnabled(false);
|
||||
|
||||
connect(ui->mDevicesList,&QListWidget::itemSelectionChanged,this,&CProgramSettingsPage::DeviceSelectionChanged);
|
||||
connect(ui->mDBMessagesListWidget,&QListWidget::itemSelectionChanged,this,&CProgramSettingsPage::MessageSelectionChanged);
|
||||
connect(ui->mModifyDevParamsBtn,&QPushButton::clicked,this,&CProgramSettingsPage::ModifyDeviceBtnPressed);
|
||||
// connect(ui->mDBSignalDetailsTable,&QTableWidget::itemSelectionChanged,this,&CProgramSettingsPage::SignalSelectionChanged);
|
||||
|
||||
}
|
||||
|
||||
CProgramSettingsPage::~CProgramSettingsPage()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
int CProgramSettingsPage::SetDevicesList(QList<CCANDevice *> *DevicesList)
|
||||
{
|
||||
if(DevicesList == 0)
|
||||
{
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
mDevicesList = DevicesList;
|
||||
|
||||
if(mDevicesList == 0)
|
||||
{
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
ui->mDevicesList->clear();
|
||||
for(int i = 0; i < mDevicesList->size(); i++)
|
||||
{
|
||||
QString name = mDevicesList->at(i)->mDeviceName;
|
||||
if(name.isEmpty())
|
||||
{
|
||||
name = QString("Device %1").arg(i+1);
|
||||
}
|
||||
ui->mDevicesList->addItem(name);
|
||||
}
|
||||
ui->mDevicesList->setCurrentRow(0);
|
||||
|
||||
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CProgramSettingsPage::ClearDatabaseData()
|
||||
{
|
||||
ui->mDBMessagesListWidget->clear();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CProgramSettingsPage::UpdatePage()
|
||||
{
|
||||
int index = ui->mDevicesList->currentRow();
|
||||
|
||||
if(index < 0 || index >= mDevicesList->size())
|
||||
{
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
CCANDevice *Device = mDevicesList->at(index);
|
||||
|
||||
|
||||
if(Device != 0)
|
||||
{
|
||||
//update device information
|
||||
ui->mCANBaudrateComboBx->setCurrentIndex(ui->mCANBaudrateComboBx->findData(Device->mCANDeviceBaudrate));
|
||||
ui->mCANIDComboBx->setCurrentIndex(ui->mCANIDComboBx->findData(Device->mCANDeviceID));
|
||||
ui->mDeviceDescriptionTxtEdit->setPlainText(Device->mDeviceDescription);
|
||||
ui->mDatabaseFileNameLbl->setText(QString("Database: %1").arg(Device->mCANDeviceDatabaseFilename));
|
||||
|
||||
//update device database information
|
||||
ui->mDBMessagesListWidget->clear();
|
||||
ui->mDBSignalDetailsTable->clearContents();
|
||||
ui->mDBSignalDetailsTable->setRowCount(0);
|
||||
if(Device->mMessageList.isEmpty())
|
||||
{
|
||||
ui->mDBMessagesListWidget->insertItem(0,"Aucun message");
|
||||
ui->mDBMessageIDLbl->setText("Message ID: ");
|
||||
ui->mDBMessageLengthLbl->setText("Message Length: ");
|
||||
ui->mDBMessageNameLbl->setText("Message Name: ");
|
||||
ui->mDBMessageNbSignalsLbl->setText("Number of signals: ");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->mDBMessagesListWidget->clear();
|
||||
for(int msg = 0; msg < Device->mMessageList.size(); msg++)
|
||||
{
|
||||
ui->mDBMessagesListWidget->insertItem(msg,Device->mMessageList.at(msg)->mCANMsgName);
|
||||
}
|
||||
|
||||
ui->mDBMessagesListWidget->setCurrentRow(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
int CProgramSettingsPage::UpdateMessageInformation()
|
||||
{
|
||||
int index = ui->mDevicesList->currentRow();
|
||||
|
||||
if(index < 0 || index >= mDevicesList->size())
|
||||
{
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
CCANDevice *Device = mDevicesList->at(index);
|
||||
|
||||
|
||||
if(Device != 0)
|
||||
{
|
||||
int MsgIndex = ui->mDBMessagesListWidget->currentRow();
|
||||
|
||||
if(MsgIndex < 0 || MsgIndex >= Device->mMessageList.size())
|
||||
{
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
CCANMessage *Message = Device->mMessageList.at(MsgIndex);
|
||||
|
||||
ui->mDBMessageIDLbl->setText(QString("Message ID: 0x%1").arg(Message->mCANMsgID,0,16));
|
||||
ui->mDBMessageLengthLbl->setText(QString("Message Length: %1").arg(Message->mCANMsgLength));
|
||||
ui->mDBMessageNameLbl->setText(QString("Message Name: %1").arg(Message->mCANMsgName));
|
||||
ui->mDBMessageNbSignalsLbl->setText(QString("Number of signals: %1").arg(Message->mSignalsList.size()));
|
||||
|
||||
ui->mDBSignalDetailsTable->clearContents();
|
||||
ui->mDBSignalDetailsTable->setRowCount(0);
|
||||
|
||||
ui->mDBSignalDetailsTable->setRowCount(Message->mSignalsList.size());
|
||||
for(int Sig = 0; Sig < Message->mSignalsList.size(); Sig++)
|
||||
{
|
||||
CCANSignal *Signal = Message->mSignalsList.at(Sig);
|
||||
QTableWidgetItem *NewItem;
|
||||
|
||||
//Signal name
|
||||
NewItem = new QTableWidgetItem(Signal->mSignalName);
|
||||
ui->mDBSignalDetailsTable->setItem(Sig,0,NewItem);
|
||||
|
||||
//Bit No
|
||||
NewItem = new QTableWidgetItem(QString("%1").arg(Signal->mStartBit));
|
||||
ui->mDBSignalDetailsTable->setItem(Sig,1,NewItem);
|
||||
|
||||
//Length
|
||||
NewItem = new QTableWidgetItem(QString("%1").arg(Signal->mSignalSize));
|
||||
ui->mDBSignalDetailsTable->setItem(Sig,2,NewItem);
|
||||
|
||||
//Type
|
||||
NewItem = new QTableWidgetItem(QString("%1").arg(Signal->mValueType));
|
||||
ui->mDBSignalDetailsTable->setItem(Sig,3,NewItem);
|
||||
|
||||
//Max Val
|
||||
NewItem = new QTableWidgetItem(QString("%1").arg(Signal->mMaxValue,0,'f',1));
|
||||
ui->mDBSignalDetailsTable->setItem(Sig,4,NewItem);
|
||||
|
||||
//Min Val
|
||||
NewItem = new QTableWidgetItem(QString("%1").arg(Signal->mMinValue,0,'f',1));
|
||||
ui->mDBSignalDetailsTable->setItem(Sig,5,NewItem);
|
||||
|
||||
//Offset
|
||||
NewItem = new QTableWidgetItem(QString("%1").arg(Signal->mValueOffset));
|
||||
ui->mDBSignalDetailsTable->setItem(Sig,6,NewItem);
|
||||
|
||||
//Scale Factor
|
||||
NewItem = new QTableWidgetItem(QString("%1").arg(Signal->mValueFactor,0,'f',1));
|
||||
ui->mDBSignalDetailsTable->setItem(Sig,7,NewItem);
|
||||
|
||||
//Unit
|
||||
NewItem = new QTableWidgetItem(Signal->mSignalUnit);
|
||||
ui->mDBSignalDetailsTable->setItem(Sig,8,NewItem);
|
||||
|
||||
//Endian
|
||||
NewItem = new QTableWidgetItem(QString("%1").arg(Signal->mValueType));
|
||||
ui->mDBSignalDetailsTable->setItem(Sig,9,NewItem);
|
||||
|
||||
}
|
||||
ui->mDBSignalDetailsTable->resizeColumnsToContents();
|
||||
}
|
||||
}
|
||||
|
||||
void CProgramSettingsPage::DeviceSelectionChanged()
|
||||
{
|
||||
UpdatePage();
|
||||
}
|
||||
|
||||
void CProgramSettingsPage::SignalSelectionChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CProgramSettingsPage::MessageSelectionChanged()
|
||||
{
|
||||
UpdateMessageInformation();
|
||||
}
|
||||
|
||||
void CProgramSettingsPage::ModifyDeviceBtnPressed()
|
||||
{
|
||||
if(mDeviceChangeModeEnabled)
|
||||
{
|
||||
ui->mDeviceDescriptionTxtEdit->setEnabled(false);
|
||||
ui->mDatabaseFileSelectBtn->hide();
|
||||
ui->mCANBaudrateComboBx->setEnabled(false);
|
||||
ui->mCANIDComboBx->setEnabled(false);
|
||||
ui->mDevicesList->setEnabled(true);
|
||||
ui->mModifyDevParamsBtn->setText("Modifier");
|
||||
mDeviceChangeModeEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->mDeviceDescriptionTxtEdit->setEnabled(true);
|
||||
ui->mDatabaseFileSelectBtn->show();
|
||||
ui->mCANBaudrateComboBx->setEnabled(true);
|
||||
ui->mCANIDComboBx->setEnabled(true);
|
||||
ui->mDevicesList->setEnabled(false);
|
||||
ui->mModifyDevParamsBtn->setText("Sauvegarder");
|
||||
mDeviceChangeModeEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class CCANDevice;
|
||||
class CCANMessage;
|
||||
class CCANSignal;
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class CProgramSettingsPage;
|
||||
}
|
||||
@@ -15,8 +20,22 @@ public:
|
||||
explicit CProgramSettingsPage(QWidget *parent = 0);
|
||||
~CProgramSettingsPage();
|
||||
|
||||
int SetDevicesList(QList<CCANDevice *> *DevicesList);
|
||||
int ClearDatabaseData();
|
||||
int UpdatePage();
|
||||
int UpdateMessageInformation();
|
||||
|
||||
|
||||
private:
|
||||
Ui::CProgramSettingsPage *ui;
|
||||
QList<CCANDevice *> *mDevicesList;
|
||||
bool mDeviceChangeModeEnabled;
|
||||
|
||||
public slots:
|
||||
void DeviceSelectionChanged();
|
||||
void SignalSelectionChanged();
|
||||
void MessageSelectionChanged();
|
||||
void ModifyDeviceBtnPressed();
|
||||
};
|
||||
|
||||
#endif // PROGRAMSETTINGSPAGE_H
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>929</width>
|
||||
<height>529</height>
|
||||
<width>1475</width>
|
||||
<height>604</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -16,9 +16,9 @@
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<y>70</y>
|
||||
<width>161</width>
|
||||
<x>370</x>
|
||||
<y>20</y>
|
||||
<width>231</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -28,37 +28,314 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Otarcik CAN settings</string>
|
||||
<string>Paramètres de la station Otarcik</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinBox">
|
||||
<widget class="QListWidget" name="mDevicesList">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>320</x>
|
||||
<y>160</y>
|
||||
<width>43</width>
|
||||
<height>22</height>
|
||||
<x>50</x>
|
||||
<y>120</y>
|
||||
<width>191</width>
|
||||
<height>301</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>162</y>
|
||||
<width>171</width>
|
||||
<height>20</height>
|
||||
<x>52</x>
|
||||
<y>100</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The PCAN USB module CAN ID that is communicating with the Parker module</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Parker Module CAN device ID:</string>
|
||||
<string>Dispositifs CAN</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="mDeviceParamsGroupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>100</y>
|
||||
<width>311</width>
|
||||
<height>331</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Paramètres</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="mCANIDLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</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>39</y>
|
||||
<width>131</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mCANBaudrateLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>CAN Baudrate:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="mCANBaudrateComboBx">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>70</y>
|
||||
<width>131</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mDeviceDatabaseLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>100</y>
|
||||
<width>111</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fichier database:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mDatabaseFileNameLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>120</y>
|
||||
<width>301</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fichier...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="mDatabaseFileSelectBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>120</y>
|
||||
<width>31</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="mModifyDevParamsBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>300</y>
|
||||
<width>80</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Modifier</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="mDeviceDescriptionTxtEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>180</y>
|
||||
<width>291</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>160</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="mDatabaseGroupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
<y>100</y>
|
||||
<width>851</width>
|
||||
<height>491</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Database</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="mDBMessageNameLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>30</y>
|
||||
<width>381</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Message Name: </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mDBMessageIDLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>50</y>
|
||||
<width>171</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Message ID: </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mDBMessageLengthLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>70</y>
|
||||
<width>191</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Message Length</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mDBMessageNbSignalsLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>90</y>
|
||||
<width>171</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Number of signals: </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListWidget" name="mDBMessagesListWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>40</y>
|
||||
<width>251</width>
|
||||
<height>201</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mDBMessageNameLbl_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1</x>
|
||||
<y>23</y>
|
||||
<width>171</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTableWidget" name="mDBSignalDetailsTable">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>250</y>
|
||||
<width>851</width>
|
||||
<height>241</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
@@ -29,9 +29,9 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
||||
mCANViewerPage = new CCANViewerPage(this);
|
||||
|
||||
setCentralWidget(mMainWindowWidget);
|
||||
mMainWindowWidget->addTab(mGeneralStatusPage,"Status");
|
||||
mMainWindowWidget->addTab(mProgramSettingsPage,"Settings");
|
||||
mMainWindowWidget->addTab(mCANViewerPage,"CAN Data");
|
||||
mMainWindowWidget->addTab(mGeneralStatusPage,"Statut");
|
||||
mMainWindowWidget->addTab(mProgramSettingsPage,"Paramètres");
|
||||
mMainWindowWidget->addTab(mCANViewerPage,"Données CAN");
|
||||
|
||||
resize(1700,768);
|
||||
}
|
||||
|
||||
@@ -15,21 +15,21 @@
|
||||
*/
|
||||
|
||||
#include "OtarcikCan.h"
|
||||
#include "PCANBasic.h"
|
||||
|
||||
COtarcikCan::COtarcikCan(QObject *parent) : QObject(parent)
|
||||
{
|
||||
// mPCANInterface = new CPCANInterface;
|
||||
// mCANDatabase = new CCANDatabase;
|
||||
// mCANAnalyzer = new CCANAnalyzer(mPCANInterface);
|
||||
|
||||
//mCANAnalyzer->mProgramPtr = this;
|
||||
}
|
||||
|
||||
COtarcikCan::~COtarcikCan()
|
||||
{
|
||||
// delete mCANAnalyzer;
|
||||
// delete mPCANInterface;
|
||||
// delete mCANDatabase;
|
||||
|
||||
while (!mCANDevicesList.isEmpty())
|
||||
{
|
||||
delete mCANDevicesList.takeFirst();
|
||||
}
|
||||
mCANDevicesList.clear();
|
||||
|
||||
}
|
||||
|
||||
@@ -40,10 +40,17 @@ int COtarcikCan::Start()
|
||||
CGeneralMessagesLogDispatcher::instance()->BindGuiPageHandle(mMainWindow.mGeneralStatusPage);
|
||||
CGeneralMessagesLogDispatcher::instance()->Init();
|
||||
|
||||
// mCANAnalyzer->Init(mPCANInterface,mCANDatabase);
|
||||
CCANDevice *NewCANDevice = new CCANDevice();
|
||||
mCANDevicesList.append(NewCANDevice);
|
||||
|
||||
// mCANDatabase->Init();
|
||||
// mCANDatabase->LoadDatabaseFile("");
|
||||
NewCANDevice->Init("IVT-S_all-variations_12082020.dbc",PCAN_USBBUS1,PCAN_BAUD_500K,"Puck CAN USB branchée sur le module Parker qui contrôle la patente", "Module Parker");
|
||||
|
||||
NewCANDevice = new CCANDevice();
|
||||
mCANDevicesList.append(NewCANDevice);
|
||||
|
||||
NewCANDevice->Init("Database.dbc",PCAN_USBBUS3,PCAN_BAUD_800K,"Puck CAN USB branchée sur une autre patente", "Module Cossin");
|
||||
|
||||
mMainWindow.mProgramSettingsPage->SetDevicesList(&mCANDevicesList);
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#include "MainWindow.h"
|
||||
#include "PCANInterface.h"
|
||||
#include "GeneralMessagesLogDispatcher.h"
|
||||
#include "CANDatabase.h"
|
||||
#include "CANAnalyzer.h"
|
||||
#include "CANDevice.h"
|
||||
#include <QList>
|
||||
|
||||
class COtarcikCan : public QObject
|
||||
@@ -23,10 +22,7 @@ public:
|
||||
int UpdateCANViewerDataRequest(QList<CCANMessage*> MsgList);
|
||||
|
||||
private:
|
||||
|
||||
// CCANAnalyzer *mCANAnalyzer;
|
||||
// CPCANInterface *mPCANInterface;
|
||||
// CCANDatabase *mCANDatabase;
|
||||
QList<CCANDevice*> mCANDevicesList;
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
@@ -34,9 +34,8 @@ int CPCANInterface::Init(TPCANHandle CANDeviceChannel, TPCANBaudrate CANBaudRate
|
||||
mInterfaceCANHandle = CANDeviceChannel;
|
||||
|
||||
TPCANStatus Result;
|
||||
// Result = CAN_Initialize(PCAN_USBBUS1, PCAN_BAUD_500K);
|
||||
Result = CAN_Initialize(CANDeviceChannel, CANBaudRate);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Initializing PCAN USB module. Channel:%1, Baudrate:%2").arg(PCAN_USBBUS1).arg(PCAN_BAUD_500K));
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Initialisation d'un module PCAN. Channel:%1, Baudrate:%2").arg(CANDeviceChannel).arg(CANBaudRate));
|
||||
|
||||
if(Result != PCAN_ERROR_OK)
|
||||
{
|
||||
@@ -45,14 +44,14 @@ int CPCANInterface::Init(TPCANHandle CANDeviceChannel, TPCANBaudrate CANBaudRate
|
||||
char strMsg[256];
|
||||
CAN_GetErrorText(Result, 0, strMsg);
|
||||
qDebug("%s",strMsg);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Could not initialize PCAN USB module. Error:%1").arg(strMsg),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Impossible d'initialiser un module USB PCAN. Erreur:%1").arg(strMsg),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
CANInterfaceOpened = false;
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
CANInterfaceOpened = true;
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("PCAN USB init SUCCESS");
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Initialisation du module PCAN USB avec succès");
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
@@ -60,17 +59,17 @@ int CPCANInterface::Init(TPCANHandle CANDeviceChannel, TPCANBaudrate CANBaudRate
|
||||
int CPCANInterface::DeInit()
|
||||
{
|
||||
TPCANStatus Result;
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Uninitializing PCAN USB module ID %1").arg(mInterfaceCANHandle));
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Déinitialisation du module PCAN USB ID %1").arg(mInterfaceCANHandle));
|
||||
Result = CAN_Uninitialize(mInterfaceCANHandle) != PCAN_ERROR_OK;
|
||||
if(Result)
|
||||
{
|
||||
char strMsg[256];
|
||||
CAN_GetErrorText(Result, 0, strMsg);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Could not uninitialize PCAN USB module. Error:%1").arg(strMsg),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Impossible de déinitialiser un module USB PCAN.. Error:%1").arg(strMsg),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
}
|
||||
else
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Uninitializing PCAN USB module...");
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Module PCAN USB déinitialisé avec succès...");
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
|
||||
Reference in New Issue
Block a user