Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve non verbose mode plugin: #412

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 88 additions & 9 deletions plugin/nonverboseplugin/nonverboseplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <QMessageBox>
#include <QDir>
#include <QDebug>
#include <QProgressDialog>

#include "nonverboseplugin.h"
#include "dlt_protocol.h"
Expand All @@ -34,9 +35,14 @@ extern const char *control_type[];
extern const char *service_id[];
extern const char *return_type[];

NonverbosePlugin::NonverbosePlugin()
{
dltControl = 0;
}

QString NonverbosePlugin::name()
{
return QString("Non Verbose Mode Plugin");
return QString(NON_VERBOSE_PLUGIN_NAME);
}

QString NonverbosePlugin::pluginVersion(){
Expand Down Expand Up @@ -123,12 +129,35 @@ bool NonverbosePlugin::parseFile(QString filename)
DltFibexPdu *pdu = 0;
DltFibexFrame *frame = 0;

qDebug() << "Start loading Fibex XML " << filename;
qDebug() << NON_VERBOSE_PLUGIN_NAME << ": Start loading Fibex XML " << filename;

QXmlStreamReader xml(&file);

QProgressDialog progress("Load Fibex file "+filename, "Abort Load", 0, xml.device()->size(), 0);
if(!dltControl->silentmode)
{
progress.setWindowModality(Qt::WindowModal);
progress.setWindowTitle(name());
progress.raise();
progress.activateWindow();
}

int progressCounter = 0;

while (!xml.atEnd()) {
xml.readNext();

progressCounter++;
if(!dltControl->silentmode && ((progressCounter%1000) == 0))
{
progress.setValue(xml.device()->pos());

if (progress.wasCanceled())
{
break;
}
}

if(xml.isStartElement())
{
if(xml.name() == QString("PDU"))
Expand Down Expand Up @@ -433,15 +462,15 @@ bool NonverbosePlugin::parseFile(QString filename)

file.close();

qDebug() << "Finish loading Fibex XML.";
qDebug() << NON_VERBOSE_PLUGIN_NAME << ": Finish loading Fibex XML.";

if (warning_text.length()){
warning_text.chop(2); // remove last ", "
m_error_string.append("Duplicated FRAMES ignored: \n").append(warning_text);
ret = true;//it is not breaking the plugin functionality, but could cause wrong decoding.
}

qDebug() << "Start Creating Links";
qDebug() << NON_VERBOSE_PLUGIN_NAME << ": Start Creating Links";
/* create PDU Ref links */
foreach(DltFibexFrame *frame, framemapwithkey)
{
Expand All @@ -457,10 +486,14 @@ bool NonverbosePlugin::parseFile(QString filename)
}
}
}
qDebug() << "Finish Creating Links";
qDebug() << NON_VERBOSE_PLUGIN_NAME << ": Finish Creating Links";

pdumap.clear();

qDebug() << NON_VERBOSE_PLUGIN_NAME << ": Size of framemapwithkey" << framemapwithkey.size();
qDebug() << NON_VERBOSE_PLUGIN_NAME << ": Size of framemap" << framemap.size();
qDebug() << NON_VERBOSE_PLUGIN_NAME << ": Size of pdumap" << pdumap.size();

return ret;
}

Expand All @@ -478,7 +511,7 @@ QStringList NonverbosePlugin::infoConfig()
QString text;
text += frame->id + QString(" AppI:%1 CtI:%2 Len:%3 MT:%4 MI:%5").arg(frame->appid).arg(frame->ctid).arg(frame->byteLength).arg(frame->messageType).arg(frame->messageInfo);
int c = 0;
foreach(DltFibexPduRef *ref, frame->pdureflist)
/* foreach(DltFibexPduRef *ref, frame->pdureflist)
{
if(c == 0)
text += " (";
Expand All @@ -489,7 +522,7 @@ QStringList NonverbosePlugin::infoConfig()
text += ")";
else
text += ", ";
}
} */
list.append(text);
}
return list;
Expand Down Expand Up @@ -541,12 +574,12 @@ bool NonverbosePlugin::decodeMsg(QDltMsg &msg, int triggeredByUser)
if(!msg.getApid().isEmpty() && !msg.getCtid().isEmpty())
{
// search in full key, if msg already contains AppId and CtId
frame = framemapwithkey[DltFibexKey(idtext,msg.getApid(),msg.getCtid())];
frame = framemapwithkey.value(DltFibexKey(idtext,msg.getApid(),msg.getCtid()),0);
}
else
{
// search only for id
frame = framemap[idtext];
frame = framemap.value(idtext,0);
}
if(!frame)
return false;
Expand Down Expand Up @@ -626,6 +659,52 @@ bool NonverbosePlugin::decodeMsg(QDltMsg &msg, int triggeredByUser)
return true;
}

bool NonverbosePlugin::initControl(QDltControl *control)
{
dltControl = control;

return true;
}

bool NonverbosePlugin::initConnections(QStringList list)
{
Q_UNUSED(list);

return false;
}

bool NonverbosePlugin::controlMsg(int , QDltMsg &)
{
return false;
}

bool NonverbosePlugin::stateChanged(int index, QDltConnection::QDltConnectionState connectionState,QString hostname){

Q_UNUSED(index);
Q_UNUSED(connectionState);
Q_UNUSED(hostname);
return false;
}

bool NonverbosePlugin::autoscrollStateChanged(bool enabled)
{
Q_UNUSED(enabled);
return false;
}

void NonverbosePlugin::initMessageDecoder(QDltMessageDecoder* pMessageDecoder)
{
Q_UNUSED(pMessageDecoder);
}

void NonverbosePlugin::initMainTableView(QTableView* pTableView)
{
Q_UNUSED(pTableView);
}

void NonverbosePlugin::configurationChanged()
{}

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_EXPORT_PLUGIN2(nonverboseplugin, NonverbosePlugin);
#endif
18 changes: 17 additions & 1 deletion plugin/nonverboseplugin/nonverboseplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#endif

#define NON_VERBOSE_PLUGIN_VERSION "1.0.0"
#define NON_VERBOSE_PLUGIN_NAME "Non Verbose Mode Plugin"

class DltFibexKey
{
Expand Down Expand Up @@ -104,16 +105,19 @@ class DltFibexFrame
uint32_t pduRefCounter;
};

class NonverbosePlugin : public QObject, QDLTPluginInterface, QDLTPluginDecoderInterface
class NonverbosePlugin : public QObject, QDLTPluginInterface, QDLTPluginDecoderInterface, QDltPluginControlInterface
{
Q_OBJECT
Q_INTERFACES(QDLTPluginInterface)
Q_INTERFACES(QDLTPluginDecoderInterface)
Q_INTERFACES(QDltPluginControlInterface)
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
Q_PLUGIN_METADATA(IID "org.genivi.DLT.NonVerbosePlugin")
#endif

public:
NonverbosePlugin();

/* QDLTPluginInterface interface */
QString name();
QString pluginVersion();
Expand All @@ -128,6 +132,16 @@ class NonverbosePlugin : public QObject, QDLTPluginInterface, QDLTPluginDecoderI
bool isMsg(QDltMsg &msg, int triggeredByUser);
bool decodeMsg(QDltMsg &msg, int triggeredByUser);

/* QDltPluginControlInterface */
bool initControl(QDltControl *control);
bool initConnections(QStringList list);
bool controlMsg(int index, QDltMsg &msg);
bool stateChanged(int index, QDltConnection::QDltConnectionState connectionState,QString hostname);
bool autoscrollStateChanged(bool enabled);
void initMessageDecoder(QDltMessageDecoder* pMessageDecoder);
void initMainTableView(QTableView* pTableView);
void configurationChanged();

/* Faster lookup */
//is it necessary that this is public?
QHash<QString, DltFibexPdu *> pdumap;
Expand All @@ -138,6 +152,8 @@ class NonverbosePlugin : public QObject, QDLTPluginInterface, QDLTPluginDecoderI
bool parseFile(QString filename);
void clear();

QDltControl *dltControl;

QString m_error_string;
};

Expand Down