From f5d68501b23a9a6b087ec9368e17197e28b6b990 Mon Sep 17 00:00:00 2001 From: Keith Vetter Date: Fri, 30 Aug 2024 14:07:41 -0500 Subject: [PATCH] Realtime report needs update for Trick job thread id I was taking a job name like: JOB_thread_process_event_3.ep.process_event_C3.266.03 and parsing out the thread ID from the name. I assumed Trick's naming convention added the CX for the thread ID. I think Trick used to adhere to that, but maybe I made a bad assumption. This issue came up because there were jobs with the _CX.num.num suffix where the X was NOT the thread ID. Instead of getting the threadID from the job name, use the filename the job comes from. For example, if the job comes from: log_trick_frame_userjobs_C5.trk it belongs to thread 5. Another example is the following job name: JOB_thread_process_event_3.ep.process_event_C3.266.03(automatic_1.000) which came from file: log_frame_trickjobs.trk Even though the job has "C3.266.03", it's not in child thread 3, it's in thread 0, since log_frame_trickjobs.trk logs jobs in thread 0. --- libkoviz/job.cpp | 50 +++++++++++++++++++----------------------------- libkoviz/job.h | 5 +++-- 2 files changed, 23 insertions(+), 32 deletions(-) diff --git a/libkoviz/job.cpp b/libkoviz/job.cpp index d2b37b53..f1673aac 100644 --- a/libkoviz/job.cpp +++ b/libkoviz/job.cpp @@ -156,7 +156,7 @@ double Job::stddev_runtime() return _stddev_runtime; } -void Job::_parseJobId(const QString &jobId) +void Job::_parseJobId(const QString &jobId, const QString &fileName) { QString name(jobId); @@ -178,14 +178,14 @@ void Job::_parseJobId(const QString &jobId) // e.g. 1828.00 from example name int idx4 = name.lastIndexOf(QChar('.'),idx1); int idx5 = name.lastIndexOf(QChar('.'),idx4-1); + _job_name = name.mid(0,idx5); // _job_name may be reset below _job_num = name.mid(idx5+1,idx1-idx5-1); _isFrameTimerJob = false; - if ( ( - jobId.startsWith("trick_frame_userjobs_C") || + if ((jobId.startsWith("trick_frame_userjobs_C") || jobId.startsWith("frame_userjobs_C") || jobId.startsWith("snap_userjobs_C")) && - jobId.endsWith("frame_time") ) { + jobId.endsWith("frame_time")) { _isFrameTimerJob = true; } @@ -220,23 +220,22 @@ void Job::_parseJobId(const QString &jobId) } else { _thread_id = 0 ; - QString stid; - int idx6; - for ( idx6 = idx5-1 ; idx6 > 0 ; idx6-- ) { - if ( isdigit(name.at(idx6).toLatin1()) ) { - stid.prepend(name.at(idx6)); - } else { - if ( name.at(idx6) == 'C' && name.at(idx6-1) == '_' ) { - _thread_id = stid.toInt(); - idx6--; - } else { - idx6++; - } - break; - } + QFileInfo fi(fileName); + QString fname = fi.fileName(); + QRegularExpression rgx("log_trick_frame_userjobs_C(\\d+).trk"); + QRegularExpressionMatch match = rgx.match(fname); + if (match.hasMatch()) { + QString number = match.captured(1); + _thread_id = number.toInt(); + } else if ((fname == "log_frame.trk") || + (fname == "log_frame_trickjobs.trk") || + (fname == "log_frame_userjobs_main.trk")) { + _thread_id = 0; + } else { + fprintf(stderr, "koviz [error]: Job::_parseJobId(): cannot find " + "file to determine thread id!\n"); + exit(-1); } - - _job_name = name.mid(0,idx6); } } @@ -251,7 +250,6 @@ double Job::freq() // Parse long logname and set job members accordingly // An example logname: // JOB_schedbus.SimBus##read_ALDS15_ObcsRouter_C1.1828.00(read_simbus_0.100) - Job::Job(CurveModel* curve) : _curve(curve),_npoints(0),_isFrameTimerJob(false), _is_stats(false) @@ -263,15 +261,7 @@ Job::Job(CurveModel* curve) : _npoints = curve->rowCount(); _log_name = curve->y()->name(); - _parseJobId(_log_name); -} - -Job::Job(const QString &jobId) : - _curve(0),_npoints(0),_isFrameTimerJob(false), - _log_name(jobId), - _is_stats(false) -{ - _parseJobId(_log_name); + _parseJobId(_log_name,curve->fileName()); } QString Job::job_id() const diff --git a/libkoviz/job.h b/libkoviz/job.h index f8f26f6b..6aab852b 100644 --- a/libkoviz/job.h +++ b/libkoviz/job.h @@ -3,6 +3,8 @@ #include #include +#include +#include #include #include @@ -19,7 +21,6 @@ class Job // job_id is logged job name // e.g. JOB_bus.SimBus##read_ObcsRouter_C1.1828.00(read_simbus_0.100) Job(CurveModel* curve); - Job(const QString& job_id); bool isFrameTimerJob() { return _isFrameTimerJob; } @@ -42,7 +43,7 @@ class Job private: Job() {} - void _parseJobId(const QString& job_id); + void _parseJobId(const QString& job_id, const QString& fileName); CurveModel* _curve; int _npoints;