Skip to content

Commit

Permalink
Improve progress output. (#571)
Browse files Browse the repository at this point in the history
Fix add multiple filter to dlt commander.
Enable filter when providing a filter file by the commandline.

Signed-off-by: Alexander Wenzel <[email protected]>
  • Loading branch information
alexmucde authored Oct 24, 2024
1 parent cefef97 commit 97d8b3c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 39 deletions.
2 changes: 1 addition & 1 deletion commander/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int main(int argc, char *argv[])
for ( const auto& i : filterFiles )
{
qDebug() << "Load DLT Filter:" << i;
if(!filterList.LoadFilter(i,true))
if(!filterList.LoadFilter(i,false))
qDebug() << "ERROR: Failed loading filter:" << i;
dltFile.setFilterList(filterList);
dltFile.enableFilter(true);
Expand Down
1 change: 1 addition & 0 deletions qdlt/qdltexporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ void QDltExporter::exportMessages(QDltFile *from, QFile *to, QDltPluginManager *
} // for loop

emit progress("",3,100);
qDebug() << "Exported:" << 100 << "%";

if (!finish())
{
Expand Down
76 changes: 38 additions & 38 deletions src/dltfileindexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ bool DltFileIndexer::index(int num)
emit(progressMax(100));
emit(progress(0));

unsigned int progressCounter = 1;
unsigned int percent = 0;
unsigned long fileSize = f.size();

qDebug() << "Create index: Start";
do
Expand Down Expand Up @@ -326,17 +329,15 @@ bool DltFileIndexer::index(int num)
return false;
}

if( 0 == (abspos%modulo) && ( file_size > 0 ) )
if(fileSize)
percent = (f.pos()*100)/fileSize;

if(percent>=progressCounter)
{
iPercent = ( abspos*100 )/file_size;
if( true == QDltOptManager::getInstance()->issilentMode() )
{
qDebug() << "Create index:" << iPercent << "%";
}
else
{
emit(progress((iPercent)));
}
progressCounter += 1;
emit(progress(percent));
if((percent>0) && ((percent%10)==0))
qDebug() << "CI:" << percent << "%";
}

} // end of for loop to read within one segment accross "number"
Expand Down Expand Up @@ -435,7 +436,7 @@ bool DltFileIndexer::indexFilter(QStringList filenames)
}

// Initialise progress bar
emit(progressText(QString("IF %1/%2").arg(currentRun).arg(maxRun)));
emit(progressText(QString("CFI %1/%2").arg(currentRun).arg(maxRun)));
emit(progressMax(100));
emit(progress(0));

Expand Down Expand Up @@ -468,6 +469,10 @@ bool DltFileIndexer::indexFilter(QStringList filenames)
qDebug() << "### Create filter index";
qDebug() << "Create filter index: Start";

/* init fileprogress */
int progressCounter = 1;
emit progress(0);

// Start reading messages
for(ix=start;ix<end;ix++)
{
Expand All @@ -485,22 +490,14 @@ bool DltFileIndexer::indexFilter(QStringList filenames)
indexerThread.processMessage(msg, ix);
}

// Update progress
if (ix > 0 )
if( 0 == (ix % modvalue) )
if((end-start)!=0)
iPercent = ( (ix-start)*100 )/(end-start);
if(iPercent>=progressCounter)
{
iPercent = ( (ix-start)*100 )/(end-start);
if( ( true == QDltOptManager::getInstance()->issilentMode() ) )
{
// QDebug deb = qDebug();
// deb.noquote();
// deb << "\33[2K\rT IF Indexed:" << iPercent << "%";
qDebug().noquote() << "Create filter index:" << iPercent << "%";
}
else
{
emit(progress(iPercent));
}
progressCounter += 1;
emit progress(iPercent); // every 1%
if((iPercent>0) && ((iPercent%10)==0))
qDebug() << "CFI:" << iPercent << "%"; // every 10%
}

// stop if requested
Expand All @@ -516,6 +513,7 @@ bool DltFileIndexer::indexFilter(QStringList filenames)
}
}
emit(progress(100));
qDebug() << "IF:" << 100 << "%";
// destroy threads
if(true == useIndexerThread)
{
Expand Down Expand Up @@ -1067,41 +1065,43 @@ bool DltFileIndexer::loadIndex(QString filename, QVector<qint64> &index)
if (false == QDltOptManager::getInstance()->issilentMode() )
{
emit(progressText(QString("LI %1/%2").arg(currentRun).arg(maxRun)));
emit(progress(0));
emit(progressMax(100)); // should be 100
}
else
{
qDebug().noquote() << "Load index: Start";
}

unsigned int progressCounter = 1;
unsigned int percent = 0;
unsigned long fileSize = file.size();
emit(progress(0));
do
{
length = file.read((char*)&value,sizeof(value));
if(length==sizeof(value))
{
index.append(value);
}
if( 0 == (indexcount%modvalue) && ( file.size() > 0 ) )

if(fileSize)
percent = (file.pos()*100)/fileSize;

if(percent>=progressCounter)
{
if (false == QDltOptManager::getInstance()->issilentMode() )
{
emit(progress((indexcount * 800 )/file.size()));
}
else
{
qDebug().noquote() << "Load index:" << ( indexcount * 8 *100 )/file.size() << "%";
}
progressCounter += 1;
emit(progress(percent));
if((percent>0) && ((percent%10)==0))
qDebug() << "LI:" << percent << "%";
}
indexcount++;

}
while(length==sizeof(value));

// now that it is doen we have to set the 100 %
if (false == QDltOptManager::getInstance()->issilentMode() )
{
emit(progress(file.size()));
emit(progress(fileSize));
}
else
{
Expand Down
8 changes: 8 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,14 @@ void MainWindow::initFileHandling()
if(!QDltOptManager::getInstance()->getFilterFiles().isEmpty())
{
qDebug() << "### Load filter";

// enable filters if they are not enabled
if(QDltSettingsManager::getInstance()->value("startup/filtersEnabled", true).toBool()==false)
{
qDebug("Enable filters, as they were disabled and at least one filter is provided by the commandline!");
QDltSettingsManager::getInstance()->setValue("startup/filtersEnabled", true);
}

for ( const auto& filter : QDltOptManager::getInstance()->getFilterFiles() )
{
qDebug() << "Load filter:" << filter;
Expand Down

0 comments on commit 97d8b3c

Please sign in to comment.