Ajout du support pour les fichiers CAN database .dbc

Ajout shortcut pour RDP vers le PC dans le champs
This commit is contained in:
2023-01-09 16:45:23 -05:00
parent c888a889f2
commit 087245571a
47 changed files with 7885 additions and 692 deletions
+247
View File
@@ -0,0 +1,247 @@
#include "defines.h"
#include "CANDatabase.h"
#include "kvaDbLib.h"
const char* sigEncToStr(KvaDbSignalEncoding sigEnc);
const char* sigRepToStr(KvaDbSignalType sigType);
CCANDatabase::CCANDatabase(QObject *parent) : QObject(parent)
{
}
CCANDatabase::~CCANDatabase()
{
}
int CCANDatabase::Init()
{
return RET_OK;
}
int CCANDatabase::LoadDatabaseFile(QString Filename)
{
#define printf qDebug
KvaDbStatus status;
KvaDbHnd dh = 0;
KvaDbMessageHnd mh = 0;
KvaDbSignalHnd sh = 0;
unsigned int flags = 0;
char filename[] = "mazda_3_2019.dbc";
// 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;
}
status = kvaDbGetFlags(dh, &flags);
if (status != kvaDbOK) {
printf ("kvaDbGetFlags failed: %d\n", status);
return status;
}
printf (" Database: flags=0x%x\n", flags);
// 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);
// 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;
// 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;
}
status = kvaDbGetSignalQualifiedName (sh, signal_qname, sizeof (signal_qname));
if (status != kvaDbOK) {
printf ("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 = kvaDbGetSignalEncoding (sh, &sigEnc);
if (status != kvaDbOK) {
printf ("kvaDbGetSignalEncoding failed: %d\n", status);
return status;
}
status = kvaDbGetSignalRepresentationType(sh, &sigType);
if (status != kvaDbOK) {
printf ("kvaDbGetSignalRepresentationType failed: %d\n", status);
return status;
}
status = kvaDbGetSignalValueLimits(sh, &minval, &maxval);
if (status != kvaDbOK) {
printf ("kvaDbGetSignalValueLimits failed: %d\n", status);
return status;
}
status = kvaDbGetSignalValueScaling(sh, &factor, &offset);
if (status != kvaDbOK) {
printf ("kvaDbGetSignalValueScaling failed: %d\n", status);
return status;
}
status = kvaDbGetSignalValueSize(sh, &startbit, &length);
if (status != kvaDbOK) {
printf ("kvaDbGetSignalValueSize failed: %d\n", status);
return status;
}
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 = kvaDbGetNextMsg (dh, &mh);
}
status = kvaDbClose (dh);
if (status != kvaDbOK) {
printf ("kvaDbClose failed: %d\n", status);
return status;
}
printf("\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";
}
}
// -----------------------------------------------------------------------
// Convert signal representation to a string
// -----------------------------------------------------------------------
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";
}
}
+20
View File
@@ -0,0 +1,20 @@
#ifndef CANDATABASE_H
#define CANDATABASE_H
#include <QObject>
class CCANDatabase : public QObject
{
Q_OBJECT
public:
explicit CCANDatabase(QObject *parent = 0);
~CCANDatabase();
int Init();
int LoadDatabaseFile(QString Filename);
signals:
public slots:
};
#endif // CANDATABASE_H
@@ -1,5 +1,25 @@
#include "GeneralMessagesLogDispatcher.h"
/*******************************************************************************
* *
* Gros Gin électronique *
* 2023 *
* *
* Project: Otarcik CAN *
* *
* *
* *
*******************************************************************************/
/*
Description:
This class allows to save system logs to a file and optionnaly to the GUI
logs window
*/
#include "GeneralMessagesLogDispatcher.h"
#include <QDateTime>
//singleton instantiation
@@ -9,17 +29,40 @@ CGeneralMessagesLogDispatcher CGeneralMessagesLogDispatcher::mSingleton;
CGeneralMessagesLogDispatcher::CGeneralMessagesLogDispatcher()
{
mGeneralStatusPageHandle = 0;
mSystemLogFile = 0;
mNbLinesInGUILog = 0;
}
CGeneralMessagesLogDispatcher::~CGeneralMessagesLogDispatcher()
{
if(mSystemLogFile != 0)
{
mSystemLogFile->close();
delete mSystemLogFile;
}
}
int CGeneralMessagesLogDispatcher::AddLogMessage(QString LogLine, bool AddToGUILogPanel)
int CGeneralMessagesLogDispatcher::Init()
{
QString FileName;
FileName = "./SystemLog.txt";
mSystemLogFile = new QFile(FileName);
if(mSystemLogFile)
{
mSystemLogFile->open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text | QIODevice::Unbuffered);
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("********************************************************************\n").toUtf8());
}
return RET_OK;
}
int CGeneralMessagesLogDispatcher::AddLogMessage(QString LogLine, bool AddToGUILogPanel, eGenMsgTextErrorStatus TxtErrStatus)
{
//TODO: Add text to log file...
@@ -27,42 +70,49 @@ int CGeneralMessagesLogDispatcher::AddLogMessage(QString LogLine, bool AddToGUIL
LogLine.remove('\r');
LogLine.append('\n');
LogLine.prepend(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss "));
if(mSystemLogFile == NULL)
{
qDebug("GeneralMessagesLogDispatcher : Trying to add log to invalid system log file pointer ");
return RET_GENERAL_ERROR;
}
if(mSystemLogFile->isOpen() == false)
{
qDebug("GeneralMessagesLogDispatcher : Trying to add log to unopened system log file");
return RET_GENERAL_ERROR;
}
mSystemLogFile->write(LogLine.toUtf8());
if(AddToGUILogPanel == true)
{
if(TxtErrStatus == GEN_MSG_TXT_ERROR_STATUS)
{
LogLine.prepend("%E");
}
else if(TxtErrStatus == GEN_MSG_TXT_WARNING_STATUS)
{
LogLine.prepend("%W");
}
if(mGeneralStatusPageHandle != 0)
{
mGeneralStatusPageHandle->AddGeneralMsgBoxLineEntry(LogLine);
}
else
{
qDebug("Someone forgot to assing their pointers in CGeneralMessagesLogDispatch::AddLogMessage!! This needs to be fixed");
return RET_GENERAL_ERROR;
}
}
if(AddToGUILogPanel == true)
{
if(mNbLinesInGUILog == GENERAL_MESSAGES_MAX_LOG_LINES)
{
//Make shure we are able to remove first line
int FirstLineLength = mGeneralMsgGUILog.indexOf(QChar('\n'));
if(FirstLineLength != -1)
{
mGeneralMsgGUILog.remove(0,FirstLineLength+1);
mGeneralMsgGUILog.append(LogLine);
}
else
{
qDebug("Something fucked-up happened in CGeneralMessagesLogDispatch::AddLogMessage");
return RET_GENERAL_ERROR;
}
}
else
{
mGeneralMsgGUILog.append(LogLine);
mNbLinesInGUILog++;
}
if(mGeneralStatusPageHandle != 0)
{
mGeneralStatusPageHandle->SetGeneralMsgText(mGeneralMsgGUILog);
}
else
{
qDebug("Someone forgot to assing their pointers in CGeneralMessagesLogDispatch::AddLogMessage!! This needs to be fixed");
return RET_GENERAL_ERROR;
}
}
return RET_OK;
}
@@ -4,12 +4,24 @@
#include <QString>
#include "defines.h"
#include "GeneralStatusPage.h"
#include <QFile>
#include <QStringList>
class CGeneralMessagesLogDispatcher
{
public:
enum eGenMsgTextErrorStatus
{
GEN_MSG_TXT_NO_ERROR_STATUS = 0,
GEN_MSG_TXT_WARNING_STATUS,
GEN_MSG_TXT_ERROR_STATUS,
GEN_MSG_TXT_MAX_STATUS
};
//CGeneralMessagesLogDispatcher is a singleton class
static CGeneralMessagesLogDispatcher* instance(){return &mSingleton;}
static CGeneralMessagesLogDispatcher mSingleton;
@@ -17,13 +29,14 @@ public:
CGeneralMessagesLogDispatcher();
virtual ~CGeneralMessagesLogDispatcher();
int AddLogMessage(QString LogLine, bool AddToGUILogPanel = true);
int AddLogMessage(QString LogLine, bool AddToGUILogPanel = true, eGenMsgTextErrorStatus TxtErrStatus = GEN_MSG_TXT_NO_ERROR_STATUS);
CGeneralStatusPage *mGeneralStatusPageHandle;
int BindGuiPageHandle(CGeneralStatusPage *Handle);
int Init();
private:
QString mGeneralMsgGUILog;
unsigned int mNbLinesInGUILog; //Keep the count of lines displayed in the GUI so we don't EVER buffer overrun
QStringList mGeneralMsgGUILog;
QFile *mSystemLogFile;
};
+62 -2
View File
@@ -1,11 +1,13 @@
#include "GeneralStatusPage.h"
#include "ui_GeneralStatusPage.h"
#include "QStringList"
CGeneralStatusPage::CGeneralStatusPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::CGeneralStatusPage)
{
ui->setupUi(this);
}
CGeneralStatusPage::~CGeneralStatusPage()
@@ -13,8 +15,66 @@ CGeneralStatusPage::~CGeneralStatusPage()
delete ui;
}
int CGeneralStatusPage::SetGeneralMsgText(QString Txt)
int CGeneralStatusPage::SetGeneralMsgText(QStringList Txt)
{
ui->mGenMsgTextEdit->setText(Txt);
/*if you're populating the text box programatically, is to use textEdit->setTextColor(QColor&).You can create the QColor object yourself, or use one of the predefined colours in the Qt namespace (Qt::black, Qt::red, etc). It will apply the specified colour to any text you add, until it is called again with a different one.*/
return RET_OK;
}
int CGeneralStatusPage::AddGeneralMsgBoxLineEntry(QString LineTxt)
{
//Limit the number of lines in the MsgBox to avoid overruns...
if(mGenMsgListBoxTextLines.size() >= GENERAL_MESSAGES_MAX_LOG_LINES)
{
mGenMsgListBoxTextLines.removeFirst();
mGenMsgListBoxTextLines.append(LineTxt);
ui->mGenMsgTextEdit->clear();
for(int i = 0; i < mGenMsgListBoxTextLines.size(); i++)
{
AddColoredLineToGenMsgBox(mGenMsgListBoxTextLines[i]);
}
}
else
{
mGenMsgListBoxTextLines.append(LineTxt);
AddColoredLineToGenMsgBox(LineTxt);
}
}
int CGeneralStatusPage::AddColoredLineToGenMsgBox(QString Line)
{
if(Line.isEmpty())
{
return RET_GENERAL_ERROR;
}
if(Line.at(0) == QChar('%'))
{
if(Line.at(1) == QChar('E')) //The line is describing an error... write it red
{
ui->mGenMsgTextEdit->setTextColor(Qt::red);
}
else if(Line.at(1) == QChar('W')) //The line is describing a warning... write it yellow
{
ui->mGenMsgTextEdit->setTextColor(Qt::blue);
}
else
{
qDebug("GeneralStatusPage: Logic error in general message box line encoding... you should check into that");
return RET_GENERAL_ERROR;
}
Line.remove(0,2);
}
ui->mGenMsgTextEdit->insertPlainText(Line);
ui->mGenMsgTextEdit->setTextColor(Qt::black);
return RET_OK;
}
+17 -1
View File
@@ -14,14 +14,30 @@ class CGeneralStatusPage : public QWidget
Q_OBJECT
public:
enum eGeneralStatusPgTxtErrorValue
{
GEN_STATUS_PG_NO_ERROR_TEXT_VALUE = 0,
GEN_STATUS_PG_WARNING_TEXT_VALUE,
GEN_STATUS_PG_ERROR_TEXT_VALUE,
GEN_STATUS_PG_MAX_TEXT_VALUE
};
explicit CGeneralStatusPage(QWidget *parent = 0);
~CGeneralStatusPage();
int SetGeneralMsgText(QString Txt);
int SetGeneralMsgText(QStringList Txt);
int AddGeneralMsgBoxLineEntry(QString LineTxt);
private:
Ui::CGeneralStatusPage *ui;
QStringList mGenMsgListBoxTextLines;
int AddColoredLineToGenMsgBox(QString Line);
};
#endif // GENERALSTATUSPAGE_H
+6 -3
View File
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1147</width>
<width>1456</width>
<height>492</height>
</rect>
</property>
@@ -16,12 +16,15 @@
<widget class="QTextEdit" name="mGenMsgTextEdit">
<property name="geometry">
<rect>
<x>660</x>
<x>460</x>
<y>30</y>
<width>441</width>
<width>651</width>
<height>451</height>
</rect>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</widget>
<resources/>
-415
View File
@@ -13,421 +13,6 @@
<height>511</height>
</rect>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>203</red>
<green>203</green>
<blue>203</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>229</red>
<green>229</green>
<blue>229</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>101</red>
<green>101</green>
<blue>101</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>135</red>
<green>135</green>
<blue>135</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>206</red>
<green>206</green>
<blue>206</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>240</red>
<green>240</green>
<blue>240</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>229</red>
<green>229</green>
<blue>229</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>203</red>
<green>203</green>
<blue>203</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>229</red>
<green>229</green>
<blue>229</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>101</red>
<green>101</green>
<blue>101</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>135</red>
<green>135</green>
<blue>135</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>206</red>
<green>206</green>
<blue>206</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>240</red>
<green>240</green>
<blue>240</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>229</red>
<green>229</green>
<blue>229</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>101</red>
<green>101</green>
<blue>101</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>203</red>
<green>203</green>
<blue>203</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>229</red>
<green>229</green>
<blue>229</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>101</red>
<green>101</green>
<blue>101</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>135</red>
<green>135</green>
<blue>135</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>101</red>
<green>101</green>
<blue>101</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>101</red>
<green>101</green>
<blue>101</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>240</red>
<green>240</green>
<blue>240</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>240</red>
<green>240</green>
<blue>240</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>203</red>
<green>203</green>
<blue>203</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="windowTitle">
<string>Otracik</string>
</property>
@@ -0,0 +1,14 @@
#include "ProgramSettingsPage.h"
#include "ui_ProgramSettingsPage.h"
CProgramSettingsPage::CProgramSettingsPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::CProgramSettingsPage)
{
ui->setupUi(this);
}
CProgramSettingsPage::~CProgramSettingsPage()
{
delete ui;
}
@@ -0,0 +1,22 @@
#ifndef PROGRAMSETTINGSPAGE_H
#define PROGRAMSETTINGSPAGE_H
#include <QWidget>
namespace Ui {
class CProgramSettingsPage;
}
class CProgramSettingsPage : public QWidget
{
Q_OBJECT
public:
explicit CProgramSettingsPage(QWidget *parent = 0);
~CProgramSettingsPage();
private:
Ui::CProgramSettingsPage *ui;
};
#endif // PROGRAMSETTINGSPAGE_H
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CProgramSettingsPage</class>
<widget class="QWidget" name="CProgramSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>929</width>
<height>529</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>350</x>
<y>70</y>
<width>161</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Otarcik CAN settings</string>
</property>
</widget>
<widget class="QSpinBox" name="spinBox">
<property name="geometry">
<rect>
<x>320</x>
<y>160</y>
<width>43</width>
<height>22</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>
</rect>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The PCAN USB module CAN ID that is communicating with the Parker module&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Parker Module CAN device ID:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
+18
View File
@@ -1,3 +1,19 @@
/*******************************************************************************
* *
* Gros Gin électronique *
* 2023 *
* *
* Project: Otarcik CAN *
* *
* *
* *
*******************************************************************************/
/*
Description:
This is a placeholder class that creates the GUI
*/
#include "MainWindow.h"
#include "ui_MainWindow.h"
@@ -9,9 +25,11 @@ CMainWindow::CMainWindow(QWidget *parent) :
mGeneralStatusPage = new CGeneralStatusPage(this);
mMainWindowWidget = new QTabWidget(this);
mProgramSettingsPage = new CProgramSettingsPage(this);
setCentralWidget(mMainWindowWidget);
mMainWindowWidget->addTab(mGeneralStatusPage,"Status");
mMainWindowWidget->addTab(mProgramSettingsPage,"Settings");
resize(1700,768);
}
+5 -1
View File
@@ -3,9 +3,12 @@
#include <QMainWindow>
#include <QTabWidget>
#include "GeneralStatusPage.h"
#include <QTextEdit>
#include "GeneralStatusPage.h"
#include "ProgramSettingsPage.h"
namespace Ui {
class CMainWindow;
}
@@ -20,6 +23,7 @@ public:
QTabWidget *mMainWindowWidget;
CGeneralStatusPage *mGeneralStatusPage;
CProgramSettingsPage *mProgramSettingsPage;
private:
+23 -2
View File
@@ -1,8 +1,25 @@
/*******************************************************************************
* *
* Gros Gin électronique *
* 2023 *
* *
* Project: Otarcik CAN *
* *
* *
* *
*******************************************************************************/
/*
Description:
This is our main program
*/
#include "OtarcikCan.h"
COtarcikCan::COtarcikCan(QObject *parent) : QObject(parent)
{
mPCANInterface = new CPCANInterface;
mCANDatabase = new CCANDatabase;
}
COtarcikCan::~COtarcikCan()
@@ -15,11 +32,15 @@ int COtarcikCan::Start()
w.show();
CGeneralMessagesLogDispatcher::instance()->BindGuiPageHandle(w.mGeneralStatusPage);
CGeneralMessagesLogDispatcher::instance()->Init();
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("OtarcikCan modules starting...");
mPCANInterface->Init();
mCANDatabase->Init();
mCANDatabase->LoadDatabaseFile("");
return 0;
}
+2
View File
@@ -5,6 +5,7 @@
#include "MainWindow.h"
#include "PCANInterface.h"
#include "GeneralMessagesLogDispatcher.h"
#include "CANDatabase.h"
class COtarcikCan : public QObject
{
@@ -18,6 +19,7 @@ public:
private:
CPCANInterface *mPCANInterface;
CCANDatabase *mCANDatabase;
signals:
+34 -5
View File
@@ -1,14 +1,34 @@
/*******************************************************************************
* *
* Gros Gin électronique *
* 2023 *
* *
* Project: Otarcik CAN *
* *
* *
* *
*******************************************************************************/
/*
Description:
This class interfaces the PCAN USB CAN puck
*/
#include "PCANInterface.h"
#include "GeneralMessagesLogDispatcher.h"
CPCANInterface::CPCANInterface(QObject *parent) : QObject(parent)
{
}
int CPCANInterface::Init()
{
QString LogMsg;
TPCANStatus Result;
Result = CAN_Initialize(PCAN_USBBUS1, PCAN_BAUD_500K);
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Initializing PCAN USB module. Channel:%1, Baudrate:%2").arg(PCAN_USBBUS1).arg(PCAN_BAUD_500K));
if(Result != PCAN_ERROR_OK)
{
@@ -17,10 +37,19 @@ int CPCANInterface::Init()
char strMsg[256];
CAN_GetErrorText(Result, 0, strMsg);
qDebug("%s",strMsg);
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(strMsg);
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Could not initialize PCAN USB module. Error:%1").arg(strMsg),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
}
return 0;
else
{
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("PCAN USB init SUCCESS");
}
return RET_OK;
}
int CPCANInterface::DeInit(unsigned short Channel)
{
CAN_Uninitialize(Channel);
return RET_OK;
}
+1
View File
@@ -11,6 +11,7 @@ class CPCANInterface : public QObject
public:
explicit CPCANInterface(QObject *parent = 0);
int Init();
int DeInit(unsigned short Channel);
signals:
+3
View File
@@ -4,11 +4,14 @@
int main(int argc, char *argv[])
{
QApplication::setStyle("windows");
QApplication a(argc, argv);
COtarcikCan OtarcikCanProgram; //Instanciate the program
OtarcikCanProgram.Start();