diff --git a/.gitignore b/.gitignore index 9cc3fb2e..1bfdcee3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ -.bak -.o -.so +*.o +*.so .*~ *~ +*.bak *.orig *.new *.old diff --git a/openhantek/src/docks/HorizontalDock.cpp b/openhantek/src/docks/HorizontalDock.cpp index 722b1870..8492e3c6 100644 --- a/openhantek/src/docks/HorizontalDock.cpp +++ b/openhantek/src/docks/HorizontalDock.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include @@ -128,6 +129,8 @@ void HorizontalDock::closeEvent( QCloseEvent *event ) { double HorizontalDock::setSamplerate( double samplerate ) { if ( scope->verboseLevel > 2 ) qDebug() << " HDock::setSamplerate()" << samplerate; + if ( scope->verboseLevel > 3 ) + qDebug() << " ThreadID:" << QThread::currentThreadId(); samplerateRequest = samplerate; QSignalBlocker blocker( timebaseSiSpinBox ); timebaseSiSpinBox->setMaximum( scope->horizontal.maxTimebase ); @@ -227,6 +230,8 @@ void HorizontalDock::samplerateSelected( double samplerate ) { void HorizontalDock::timebaseSelected( double timebase ) { if ( scope->verboseLevel > 2 ) qDebug() << " HDock::timebaseSelected()" << timebase; + if ( scope->verboseLevel > 3 ) + qDebug() << " ThreadID:" << QThread::currentThreadId(); scope->horizontal.timebase = timebase; calculateSamplerateSteps( timebase ); emit timebaseChanged( timebase ); diff --git a/openhantek/src/docks/SpectrumDock.cpp b/openhantek/src/docks/SpectrumDock.cpp index 7fd507b7..0b8ef833 100644 --- a/openhantek/src/docks/SpectrumDock.cpp +++ b/openhantek/src/docks/SpectrumDock.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include @@ -166,6 +167,8 @@ void SpectrumDock::enableSpectrumDock( bool enabled ) { // disable when using XY void SpectrumDock::setSamplerate( double samplerate ) { if ( scope->verboseLevel > 2 ) qDebug() << " SDock::setSamplerate()" << samplerate; + if ( scope->verboseLevel > 3 ) + qDebug() << " ThreadID:" << QThread::currentThreadId(); double maxFreqBase = samplerate / DIVS_TIME / 2; // Nyquist frequency frequencybaseSiSpinBox->setMaximum( maxFreqBase ); if ( frequencybaseSiSpinBox->value() > maxFreqBase ) diff --git a/openhantek/src/hantekdso/capturing.cpp b/openhantek/src/hantekdso/capturing.cpp index a6463472..50a38ba9 100644 --- a/openhantek/src/hantekdso/capturing.cpp +++ b/openhantek/src/hantekdso/capturing.cpp @@ -8,10 +8,17 @@ #include -Capturing::Capturing( HantekDsoControl *hdc ) : hdc( hdc ) { hdc->capturing = true; } +CapturingThread::CapturingThread( HantekDsoControl *hdc ) : hdc( hdc ) { + if ( hdc->verboseLevel > 1 ) { + qDebug() << " CapturingThread::CapturingThread()"; + if ( hdc->verboseLevel > 2 ) + qDebug() << " capturingThread ID: " << currentThreadId(); + } + hdc->capturing = true; +} -void Capturing::run() { +void CapturingThread::run() { forever { if ( !hdc->capturing || QThread::currentThread()->isInterruptionRequested() ) { hdc->quitSampling(); // stop the scope @@ -41,7 +48,7 @@ static double id2sr( uint8_t timediv ) { } -void Capturing::xferSamples() { +void CapturingThread::xferSamples() { QWriteLocker locker( &hdc->raw.lock ); if ( !freeRun ) swap( data, hdc->raw.data ); @@ -58,7 +65,7 @@ void Capturing::xferSamples() { } -void Capturing::capture() { +void CapturingThread::capture() { if ( !hdc->samplingStarted ) return; int errorCode; @@ -165,7 +172,7 @@ void Capturing::capture() { } -unsigned Capturing::getRealSamples() { +unsigned CapturingThread::getRealSamples() { int errorCode; errorCode = hdc->scopeDevice->controlWrite( hdc->getCommand( ControlCode::CONTROL_STARTSAMPLING ) ); if ( errorCode < 0 ) { @@ -189,7 +196,7 @@ unsigned Capturing::getRealSamples() { } -unsigned Capturing::getDemoSamples() { +unsigned CapturingThread::getDemoSamples() { const uint8_t binaryOffset = 0x80; // ADC format: binary offset const int8_t V_zero = 0; // ADC = 0V const int8_t V_plus_1 = 25; // ADC = 1V diff --git a/openhantek/src/hantekdso/capturing.h b/openhantek/src/hantekdso/capturing.h index 22fdec53..b53885f2 100644 --- a/openhantek/src/hantekdso/capturing.h +++ b/openhantek/src/hantekdso/capturing.h @@ -4,11 +4,11 @@ #include "hantekdsocontrol.h" -class Capturing : public QThread { +class CapturingThread : public QThread { Q_OBJECT public: - Capturing( HantekDsoControl *hdc ); + CapturingThread( HantekDsoControl *hdc ); void quitCapturing() { hdc->capturing = false; } private: diff --git a/openhantek/src/hantekdso/hantekdsocontrol.cpp b/openhantek/src/hantekdso/hantekdsocontrol.cpp index 1470ef9a..dbb19ee8 100644 --- a/openhantek/src/hantekdso/hantekdsocontrol.cpp +++ b/openhantek/src/hantekdso/hantekdsocontrol.cpp @@ -23,7 +23,6 @@ HantekDsoControl::HantekDsoControl( ScopeDevice *device, const DSOModel *model, if ( verboseLevel > 1 ) qDebug() << " HantekDsoControl::HantekDsoControl()"; - qRegisterMetaType< DSOsamples * >(); qRegisterMetaType< QList< double > >(); @@ -95,6 +94,8 @@ void HantekDsoControl::controlSetSamplerate( uint8_t sampleIndex ) { uint8_t id = specification->fixedSampleRates[ sampleIndex ].id; if ( verboseLevel > 2 ) qDebug() << " HDC::controlSetSamplerate()" << sampleIndex << "id:" << id; + if ( verboseLevel > 3 ) + qDebug() << " ThreadID:" << QThread::currentThreadId(); modifyCommand< ControlSetSamplerate >( ControlCode::CONTROL_SETSAMPLERATE )->setSamplerate( id, sampleIndex ); if ( sampleIndex != lastIndex ) { // samplerate has changed, start new sampling restartSampling(); @@ -134,6 +135,8 @@ Dso::ErrorCode HantekDsoControl::setSamplerate( double samplerate ) { Dso::ErrorCode HantekDsoControl::setRecordTime( double duration ) { if ( verboseLevel > 2 ) qDebug() << " HDC::setRecordTime()" << duration; + if ( verboseLevel > 3 ) + qDebug() << " ThreadID:" << QThread::currentThreadId(); if ( deviceNotConnected() ) return Dso::ErrorCode::CONNECTION; diff --git a/openhantek/src/hantekdso/hantekdsocontrol.h b/openhantek/src/hantekdso/hantekdsocontrol.h index 84d8e386..c1ed0dcf 100644 --- a/openhantek/src/hantekdso/hantekdsocontrol.h +++ b/openhantek/src/hantekdso/hantekdsocontrol.h @@ -30,7 +30,7 @@ #include #include -class Capturing; +class CapturingThread; class ScopeDevice; struct Raw { @@ -54,7 +54,7 @@ struct Raw { /// TODO Please anyone, refactor this class into smaller pieces (Separation of Concerns!). class HantekDsoControl : public QObject { Q_OBJECT - friend Capturing; + friend CapturingThread; public: /** diff --git a/openhantek/src/main.cpp b/openhantek/src/main.cpp index 479f9a3d..dffb9168 100644 --- a/openhantek/src/main.cpp +++ b/openhantek/src/main.cpp @@ -373,6 +373,9 @@ int main( int argc, char *argv[] ) { qDebug() << startupTime.elapsed() << "ms:" << "use device" << scopeDevice->getModel()->name << "serial number" << scopeDevice->getSerialNumber(); + if ( verboseLevel > 2 ) + qDebug() << " main thread ID: " << QThread::currentThreadId(); + //////// Create DSO control object and move it to a separate thread //////// if ( verboseLevel ) qDebug() << startupTime.elapsed() << "ms:" @@ -383,7 +386,6 @@ int main( int argc, char *argv[] ) { dsoControl.moveToThread( &dsoControlThread ); QObject::connect( &dsoControlThread, &QThread::started, &dsoControl, &HantekDsoControl::stateMachine ); QObject::connect( &dsoControl, &HantekDsoControl::communicationError, QCoreApplication::instance(), &QCoreApplication::quit ); - if ( scopeDevice ) QObject::connect( scopeDevice.get(), &ScopeDevice::deviceDisconnected, QCoreApplication::instance(), &QCoreApplication::quit ); @@ -510,8 +512,8 @@ int main( int argc, char *argv[] ) { dsoControl.enableSamplingUI(); postProcessingThread.start(); dsoControlThread.start(); - Capturing capturing( &dsoControl ); - capturing.start(); + CapturingThread capturingThread( &dsoControl ); // low level capture in separate thread + capturingThread.start(); if ( verboseLevel ) qDebug() << startupTime.elapsed() << "ms:" @@ -536,8 +538,8 @@ int main( int argc, char *argv[] ) { // wait 2 * record time (delay is ms) for dso to finish unsigned waitForDso = unsigned( 2000 * dsoControl.getSamplesize() / dsoControl.getSamplerate() ); waitForDso = qMax( waitForDso, 10000U ); // wait for at least 10 s - capturing.requestInterruption(); - capturing.wait( waitForDso ); + capturingThread.requestInterruption(); + capturingThread.wait( waitForDso ); if ( verboseLevel < 2 ) std::cerr << "has "; // 2nd part diff --git a/openhantek/src/mainwindow.cpp b/openhantek/src/mainwindow.cpp index ba10ee2f..6e359550 100644 --- a/openhantek/src/mainwindow.cpp +++ b/openhantek/src/mainwindow.cpp @@ -219,7 +219,7 @@ MainWindow::MainWindow( HantekDsoControl *dsoControl, DsoSettings *settings, Exp restoreState( dsoSettings->mainWindowState ); // Central oszilloscope widget - dsoWidget = new DsoWidget( &dsoSettings->scope, &dsoSettings->view, spec ); + dsoWidget = new DsoWidget( &dsoSettings->scope, &dsoSettings->view, spec, this ); setCentralWidget( dsoWidget ); if ( dsoControl->getDevice()->isRealHW() ) { // enable online calibration and manual command input diff --git a/openhantek/translations/openhantek_de.ts b/openhantek/translations/openhantek_de.ts index d81fc19b..f14d9220 100644 --- a/openhantek/translations/openhantek_de.ts +++ b/openhantek/translations/openhantek_de.ts @@ -941,7 +941,7 @@ Konnte Kanalpegeldaten des Oszilloskops nicht lesen - + Couldn't get calibration data from oscilloscope's EEPROM. Use a config file for calibration! Konnte Kalibrierdaten des Oszilloskops nicht lesen, benutze eine config-Datei für die Kalibrierung! @@ -949,37 +949,37 @@ HorizontalDock - + Horizontal Horizontal - + Samplerate Samplerate - + Effective samplerate, automatically selected from 'Timebase' setting Wirksame Abtastrate, automatisch beim Einstellen der 'Zeitbasis' ausgewählt - + /s /s - + Timebase Zeitbasis - + Time per horizontal screen division Zeit pro horizontaler Teilung - + Select the frequency of the calibration output, scroll for fast change Setze die Frequenz des Kalibriersignals, schnelle Auswahl mit dem Mausrad @@ -988,17 +988,17 @@ Frequenzbasis - + Format Format - + Select signal over time or XY display Wähle Signal über Zeit oder XY-Anzeige - + Calibration out Kalibriersignal @@ -2543,22 +2543,22 @@ SpectrumDock - + Spectrum Spektrum - + Magnitude per vertical screen division Magnitude pro vertikaler Teilung - + Frequencybase Frequenzbasis - + Frequency range per horizontal screen division Frequenzbereich pro horizontaler Teilung diff --git a/openhantek/translations/openhantek_es.ts b/openhantek/translations/openhantek_es.ts index 91121883..3a7113d7 100644 --- a/openhantek/translations/openhantek_es.ts +++ b/openhantek/translations/openhantek_es.ts @@ -785,7 +785,7 @@ No se pudieron obtener los datos de calibración del osciloscopio - + Couldn't get calibration data from oscilloscope's EEPROM. Use a config file for calibration! No se pudieron obtener los datos de calibración del osciloscopio. ¡Usa un archivo de configuración para la calibración! @@ -793,37 +793,37 @@ HorizontalDock - + Horizontal Horizontal - + Samplerate Muestreo - + Effective samplerate, automatically selected from 'Timebase' setting Frecuencia de muestreo efectiva, seleccionada automáticamente desde la configuración de 'Base de tiempo' - + /s /s - + Timebase Base de tiempos - + Time per horizontal screen division Tiempo por división de pantalla horizontal - + Select the frequency of the calibration output, scroll for fast change Seleccione la frecuencia de la salida de calibración, desplácese para un cambio rápido @@ -832,17 +832,17 @@ Frecuencia base - + Format Formato - + Select signal over time or XY display Selecciona señal en el tiempo o display XY - + Calibration out Salida de calibración @@ -2203,22 +2203,22 @@ SpectrumDock - + Spectrum Espectro - + Magnitude per vertical screen division Magnitud por división de pantalla vertical - + Frequencybase Frecuencia base - + Frequency range per horizontal screen division Rango de frecuencia por división de pantalla horizontal diff --git a/openhantek/translations/openhantek_fr.ts b/openhantek/translations/openhantek_fr.ts index 480d57cd..c1c35d2f 100644 --- a/openhantek/translations/openhantek_fr.ts +++ b/openhantek/translations/openhantek_fr.ts @@ -889,7 +889,7 @@ Impossible d'obtenir les données de niveau du canal depuis l'oscilloscope - + Couldn't get calibration data from oscilloscope's EEPROM. Use a config file for calibration! Impossible d'obtenir les données de niveau du canal depuis l'oscilloscope. Utilisez un fichier de configuration pour la calibration ! @@ -897,37 +897,37 @@ HorizontalDock - + Horizontal Horizontal - + Samplerate Taux d'éch. - + Effective samplerate, automatically selected from 'Timebase' setting Taux d'échantillonnage effectif, automatiquement sélectionné à partir du paramètre 'Timebase' - + /s /s - + Timebase Base temps - + Time per horizontal screen division Temps par division horizontale de l'écran - + Select the frequency of the calibration output, scroll for fast change Sélectionnez la fréquence de la sortie d'étalonnage, faites défiler pour un changement rapide @@ -936,17 +936,17 @@ Base fréq. - + Format Format - + Select signal over time or XY display Sélectionnez le signal dans le temps ou l'affichage XY - + Calibration out Etalonnage @@ -2336,22 +2336,22 @@ SpectrumDock - + Spectrum Spectre - + Magnitude per vertical screen division Magnitude par division verticale de l'écran - + Frequencybase Base fréq. - + Frequency range per horizontal screen division Gamme de fréquences par division horizontale de l'écran diff --git a/openhantek/translations/openhantek_it.ts b/openhantek/translations/openhantek_it.ts index b0721c26..9129c8e2 100644 --- a/openhantek/translations/openhantek_it.ts +++ b/openhantek/translations/openhantek_it.ts @@ -685,7 +685,7 @@ HantekDsoControl - + Couldn't get calibration data from oscilloscope's EEPROM. Use a config file for calibration! Impossibile ottenere i dati di calibrazione dall'EEPROM dell'oscilloscopio. Utilizzare un file di configurazione per la calibrazione! @@ -693,52 +693,52 @@ HorizontalDock - + Horizontal Horizontale - + Samplerate - + Effective samplerate, automatically selected from 'Timebase' setting Campionamento effettivo, selezionato automaticamente dall'impostazione 'Timebase' - + /s - + Timebase - + Time per horizontal screen division Tempo per divisione orizzontale dello schermo - + Format - + Select signal over time or XY display Selezionare il segnale nel tempo o la visualizzazione XY - + Calibration out - + Select the frequency of the calibration output, scroll for fast change Selezionare la frequenza della calibrazione, scorrere per il cambiamento veloce @@ -1823,22 +1823,22 @@ SpectrumDock - + Spectrum Spettro - + Magnitude per vertical screen division Magnitudine per divisione verticale dello schermo - + Frequencybase Base di frequenza - + Frequency range per horizontal screen division Frequenza per divisione orizzontale dello schermo diff --git a/openhantek/translations/openhantek_pl.ts b/openhantek/translations/openhantek_pl.ts index 46726f92..04d0b044 100644 --- a/openhantek/translations/openhantek_pl.ts +++ b/openhantek/translations/openhantek_pl.ts @@ -901,7 +901,7 @@ Nie można uzyskać danych o poziomie kanału z oscyloskopu - + Couldn't get calibration data from oscilloscope's EEPROM. Use a config file for calibration! Nie można pobrać danych kalibracyjnych z pamięci EEPROM oscyloskopu. Użyj pliku konfiguracyjnego do kalibracji! @@ -909,37 +909,37 @@ HorizontalDock - + Horizontal Poziom - + Samplerate Częstoliwość próbkowania - + Effective samplerate, automatically selected from 'Timebase' setting Efektywna częstotliwość próbkowania, automatycznie wybierana z ustawienia "Podstawa czasu" - + /s /s - + Timebase Podstawa czasu - + Time per horizontal screen division Czas na podział ekranu w poziomie - + Select the frequency of the calibration output, scroll for fast change Wybór częstotliwości kalibracji, przewijanie w celu szybkiej zmiany @@ -948,17 +948,17 @@ Częstotliwość bazowa - + Format Format - + Select signal over time or XY display Wybór wyświetlania sygnału w czasie lub XY - + Calibration out Sygnał kalibracyjny @@ -2450,22 +2450,22 @@ SpectrumDock - + Spectrum Spektrum - + Magnitude per vertical screen division Magnituda w pionowym podziale ekranu - + Frequencybase Częstotliwość bazowa - + Frequency range per horizontal screen division Zakres częstotliwości w poziomym podziale ekranu diff --git a/openhantek/translations/openhantek_pt.ts b/openhantek/translations/openhantek_pt.ts index 57ce31d3..86610998 100644 --- a/openhantek/translations/openhantek_pt.ts +++ b/openhantek/translations/openhantek_pt.ts @@ -884,7 +884,7 @@ Não foi possível obter dados do canal do osciloscópio - + Couldn't get calibration data from oscilloscope's EEPROM. Use a config file for calibration! Não foi possível obter dados de calibração a partir da EEPROM do osciloscópio. Use um arquivo de configuração para a calibração! @@ -892,37 +892,37 @@ HorizontalDock - + Horizontal Horizontal - + Samplerate - + Effective samplerate, automatically selected from 'Timebase' setting Amostragem efetiva, selecionada automaticamente da configuração 'Timebase' - + /s /s - + Timebase Tempo base - + Time per horizontal screen division Tempo por divisão de tela horizontal - + Select the frequency of the calibration output, scroll for fast change Selecione a freqüência da calibração, role para mudança rápida @@ -931,17 +931,17 @@ Frequência base - + Format Formato - + Select signal over time or XY display Selecionar o sinal ao longo do tempo ou visor XY - + Calibration out @@ -2289,22 +2289,22 @@ SpectrumDock - + Spectrum Espectro - + Magnitude per vertical screen division - + Frequencybase Frequência base - + Frequency range per horizontal screen division diff --git a/openhantek/translations/openhantek_ru.ts b/openhantek/translations/openhantek_ru.ts index 13f8a3ca..23461eda 100644 --- a/openhantek/translations/openhantek_ru.ts +++ b/openhantek/translations/openhantek_ru.ts @@ -839,7 +839,7 @@ HantekDsoControl - + Couldn't get calibration data from oscilloscope's EEPROM. Use a config file for calibration! Не удалось получить данные калибровки из EEPROM осциллографа. Используйте файл конфигурации для калибровки! @@ -847,37 +847,37 @@ HorizontalDock - + Horizontal Развёртка - + Samplerate Дискретизация - + Effective samplerate, automatically selected from 'Timebase' setting Эффективная частота дискретизации, с автоподбором из настроек 'Время/Деление' - + /s - + Timebase Время/Деление - + Time per horizontal screen division Время на деление экрана по горизонтали - + Select the frequency of the calibration output, scroll for fast change Выбор частоты сигнала на выходе калибровки, прокручивай для быстрой смены @@ -886,17 +886,17 @@ Частота/Деление - + Format Формат вывода - + Select signal over time or XY display Выбор отображения сигнала во времени или по XY - + Calibration out Выход калибровки @@ -2185,22 +2185,22 @@ SpectrumDock - + Spectrum Спектр - + Magnitude per vertical screen division Величина на вертикальное деление экрана - + Frequencybase Частота/Деление - + Frequency range per horizontal screen division Диапазон частот на горизонтальное деление экрана diff --git a/openhantek/translations/openhantek_sv.ts b/openhantek/translations/openhantek_sv.ts index e40b4041..f455b999 100644 --- a/openhantek/translations/openhantek_sv.ts +++ b/openhantek/translations/openhantek_sv.ts @@ -701,7 +701,7 @@ HantekDsoControl - + Couldn't get calibration data from oscilloscope's EEPROM. Use a config file for calibration! Kunde inte hämta kalibreringsdata från oscilloskopets EEPROM. Använd en konfigurationsfil för kalibrering! @@ -709,52 +709,52 @@ HorizontalDock - + Horizontal Horisontell - + Samplerate Sampelhastighet - + Effective samplerate, automatically selected from 'Timebase' setting Effektiv samplerate, automatiskt vald från inställningen "Timebase" - + /s /s - + Timebase Tidbas - + Time per horizontal screen division Tid per horisontell skärmdivision - + Format Format - + Select signal over time or XY display Välj signal över tid eller XY-display - + Calibration out Kalibrering ut - + Select the frequency of the calibration output, scroll for fast change Välj kalibreringsfrekvens, bläddra för snabb ändring @@ -1903,22 +1903,22 @@ SpectrumDock - + Spectrum Spektrum - + Magnitude per vertical screen division Storlek per vertikal skärmdivision - + Frequencybase Frekvensbas - + Frequency range per horizontal screen division Frekvensområde per horisontell skärmdivision diff --git a/openhantek/translations/openhantek_zh.ts b/openhantek/translations/openhantek_zh.ts index 6fecbc07..853a71a9 100644 --- a/openhantek/translations/openhantek_zh.ts +++ b/openhantek/translations/openhantek_zh.ts @@ -897,7 +897,7 @@ 获取示波器通道数据失败 - + Couldn't get calibration data from oscilloscope's EEPROM. Use a config file for calibration! 从示波器EEPOM获取校准数据失败,请使用配置文件进行校准! @@ -905,37 +905,37 @@ HorizontalDock - + Horizontal 水平 - + Samplerate 采样率 - + Effective samplerate, automatically selected from 'Timebase' setting - + /s /s - + Timebase 时基 - + Time per horizontal screen division - + Select the frequency of the calibration output, scroll for fast change @@ -944,17 +944,17 @@ 基频 - + Format 格式 - + Select signal over time or XY display - + Calibration out 校准信号 @@ -2358,22 +2358,22 @@ SpectrumDock - + Spectrum 频谱 - + Magnitude per vertical screen division - + Frequencybase 基频 - + Frequency range per horizontal screen division