mirror of
https://github.com/Serial-Studio/Serial-Studio.git
synced 2025-01-15 05:22:53 +08:00
Allow users to enable/disable multithreaded frame parsing
This commit is contained in:
parent
41dba80f07
commit
5197846241
@ -109,10 +109,11 @@ Item {
|
||||
// App settings
|
||||
//
|
||||
property alias language: settings.language
|
||||
property alias tcpPlugins: settings.tcpPlugins
|
||||
property alias endSequence: settings.endSequence
|
||||
property alias startSequence: settings.startSequence
|
||||
property alias tcpPlugins: settings.tcpPlugins
|
||||
property alias separatorSequence: settings.separatorSequence
|
||||
property alias multithreadedFrameProcessing: settings.multithreadedFrameProcessing
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -32,10 +32,11 @@ Control {
|
||||
// Access to properties
|
||||
//
|
||||
property alias endSequence: _endSequence.text
|
||||
property alias tcpPlugins: _tcpPlugins.checked
|
||||
property alias language: _langCombo.currentIndex
|
||||
property alias startSequence: _startSequence.text
|
||||
property alias tcpPlugins: _tcpPlugins.checked
|
||||
property alias separatorSequence: _separatorSequence.text
|
||||
property alias multithreadedFrameProcessing: _multithreadedFrameProcessing.checked
|
||||
|
||||
//
|
||||
// Layout
|
||||
@ -149,6 +150,22 @@ Control {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Multi-threaded frame processing
|
||||
//
|
||||
Label {
|
||||
text: qsTr("Multithreaded frame parsing") + ": "
|
||||
} Switch {
|
||||
id: _multithreadedFrameProcessing
|
||||
Layout.leftMargin: -app.spacing
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
checked: Cpp_JSON_Generator.processFramesInSeparateThread
|
||||
onCheckedChanged: {
|
||||
if (checked != Cpp_JSON_Generator.processFramesInSeparateThread)
|
||||
Cpp_JSON_Generator.processFramesInSeparateThread = checked
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Plugins enabled
|
||||
//
|
||||
|
Binary file not shown.
@ -1988,6 +1988,14 @@
|
||||
<source>Rendering engine</source>
|
||||
<translation>Rendering Motor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Threaded frame parsing</source>
|
||||
<translation type="vanished">Analyse von Multithreading-Rahmen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Multithreaded frame parsing</source>
|
||||
<translation>Analyse von Multithreading-Rahmen</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
|
Binary file not shown.
@ -1536,6 +1536,10 @@
|
||||
<source>Rendering engine</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Multithreaded frame parsing</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
|
Binary file not shown.
@ -2112,6 +2112,14 @@
|
||||
<source>Rendering engine</source>
|
||||
<translation>Motor de renderizado</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Threaded frame parsing</source>
|
||||
<translation type="vanished">Análisis multihilo de tramas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Multithreaded frame parsing</source>
|
||||
<translation>Análisis multihilo de tramas</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
|
Binary file not shown.
@ -1790,6 +1790,14 @@
|
||||
<source>Rendering engine</source>
|
||||
<translation>Механизм рендеринга</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Threaded frame parsing</source>
|
||||
<translation type="vanished">Многопоточный анализ кадров</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Multithreaded frame parsing</source>
|
||||
<translation>Многопоточный анализ кадров</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
|
Binary file not shown.
@ -2044,6 +2044,14 @@
|
||||
<source>Rendering engine</source>
|
||||
<translation>渲染引擎</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Threaded frame parsing</source>
|
||||
<translation type="vanished">多线程框架分析</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Multithreaded frame parsing</source>
|
||||
<translation>多线程框架分析</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
|
@ -45,6 +45,7 @@ static Generator *INSTANCE = nullptr;
|
||||
Generator::Generator()
|
||||
: m_frameCount(0)
|
||||
, m_opMode(kAutomatic)
|
||||
, m_processInSeparateThread(false)
|
||||
{
|
||||
auto io = IO::Manager::getInstance();
|
||||
auto cp = CSV::Player::getInstance();
|
||||
@ -110,6 +111,13 @@ Generator::OperationMode Generator::operationMode() const
|
||||
return m_opMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns @c true if JSON frames shall be generated in a separate thread
|
||||
*/
|
||||
bool Generator::processFramesInSeparateThread() const {
|
||||
return m_processInSeparateThread;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file dialog & lets the user select the JSON file map
|
||||
*/
|
||||
@ -202,6 +210,14 @@ void Generator::setOperationMode(const JSON::Generator::OperationMode mode)
|
||||
emit operationModeChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables multi-threaded frame processing
|
||||
*/
|
||||
void Generator::setProcessFramesInSeparateThread(const bool threaded) {
|
||||
m_processInSeparateThread = threaded;
|
||||
emit processFramesInSeparateThreadChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the last saved JSON map file (if any)
|
||||
*/
|
||||
@ -285,15 +301,21 @@ void Generator::readData(const QByteArray &data)
|
||||
m_frameCount++;
|
||||
|
||||
// Create new worker thread to read JSON data
|
||||
QThread *thread = new QThread;
|
||||
JSONWorker *worker = new JSONWorker(data, m_frameCount, QDateTime::currentDateTime());
|
||||
worker->moveToThread(thread);
|
||||
connect(thread, SIGNAL(started()), worker, SLOT(process()));
|
||||
connect(worker, SIGNAL(finished()), thread, SLOT(quit()));
|
||||
connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
|
||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||
connect(worker, &JSONWorker::jsonReady, this, &Generator::loadJFI);
|
||||
thread->start();
|
||||
if (processFramesInSeparateThread()) {
|
||||
QThread *thread = new QThread;
|
||||
JSONWorker *worker = new JSONWorker(data, m_frameCount, QDateTime::currentDateTime());
|
||||
worker->moveToThread(thread);
|
||||
connect(thread, SIGNAL(started()), worker, SLOT(process()));
|
||||
connect(worker, SIGNAL(finished()), thread, SLOT(quit()));
|
||||
connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
|
||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||
connect(worker, &JSONWorker::jsonReady, this, &Generator::loadJFI);
|
||||
thread->start();
|
||||
}
|
||||
|
||||
// Process frames in main thread
|
||||
else
|
||||
processFrame(data, m_frameCount, QDateTime::currentDateTime());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,12 +103,17 @@ class Generator : public QObject
|
||||
READ operationMode
|
||||
WRITE setOperationMode
|
||||
NOTIFY operationModeChanged)
|
||||
Q_PROPERTY(bool processFramesInSeparateThread
|
||||
READ processFramesInSeparateThread
|
||||
WRITE setProcessFramesInSeparateThread
|
||||
NOTIFY processFramesInSeparateThreadChanged)
|
||||
// clang-format on
|
||||
|
||||
signals:
|
||||
void jsonFileMapChanged();
|
||||
void operationModeChanged();
|
||||
void jsonChanged(const JFI_Object &info);
|
||||
void processFramesInSeparateThreadChanged();
|
||||
|
||||
public:
|
||||
enum OperationMode
|
||||
@ -125,10 +130,12 @@ public:
|
||||
QString jsonMapFilename() const;
|
||||
QString jsonMapFilepath() const;
|
||||
OperationMode operationMode() const;
|
||||
bool processFramesInSeparateThread() const;
|
||||
|
||||
public slots:
|
||||
void loadJsonMap();
|
||||
void loadJsonMap(const QString &path);
|
||||
void setProcessFramesInSeparateThread(const bool threaded);
|
||||
void setOperationMode(const JSON::Generator::OperationMode mode);
|
||||
|
||||
private:
|
||||
@ -152,6 +159,7 @@ private:
|
||||
QSettings m_settings;
|
||||
QString m_jsonMapData;
|
||||
OperationMode m_opMode;
|
||||
bool m_processInSeparateThread;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user