Author: alexey Date: 2019-07-25 00:28:19 +0000 (Thu, 25 Jul 2019) New Revision: 2799 Modified: trunk/programs/us_com_project/us_com_project_gui.cpp trunk/programs/us_com_project/us_com_project_gui.h trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.cpp trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.h trunk/utils/us_xpn_data.cpp Log: Autoflow: * updates on properly stopping timers/threads when attempting to switch back centralizedto Managing Runs while LIVE UPDATE in full operation... * multiple other updates Modified: trunk/programs/us_com_project/us_com_project_gui.cpp =================================================================== --- trunk/programs/us_com_project/us_com_project_gui.cpp 2019-07-24 06:40:06 UTC (rev 2798) +++ trunk/programs/us_com_project/us_com_project_gui.cpp 2019-07-25 00:28:19 UTC (rev 2799) @@ -33,6 +33,7 @@ // dbg_level = US_Settings::us_debug(); curr_panx = 0; window_closed = false; + xpn_viewer_closed_soft = false; us_mode_bool = true; @@ -173,6 +174,7 @@ //connect( this, SIGNAL( clear_experiment( QString & ) ), epanExp, SLOT( clear_experiment( QString & ) ) ); connect( epanObserv, SIGNAL( close_everything() ), this, SLOT( close_all() )); + connect( this, SIGNAL( reset_live_update() ), epanObserv, SLOT( reset_live_update( ) ) ); //connect( epanPostProd, SIGNAL( switch_to_analysis( QString &, QString &) ), this, SLOT( switch_to_analysis( QString &, QString & ) ) ); //connect( this, SIGNAL( pass_to_analysis( QString &, QString & ) ), epanAnalysis, SLOT( do_analysis( QString &, QString & ) ) ); @@ -197,6 +199,8 @@ curr_panx = 0; window_closed = false; + xpn_viewer_closed_soft = false; + us_mode_bool = false; setWindowTitle( tr( "UltraScan Optima AUC Interface" ) ); @@ -337,6 +341,7 @@ connect( epanObserv, SIGNAL( switch_to_post_processing( QMap < QString, QString > & ) ), this, SLOT( switch_to_post_processing( QMap < QString, QString > & ) ) ); connect( this, SIGNAL( import_data_us_convert( QMap < QString, QString > & ) ), epanPostProd, SLOT( import_data_us_convert( QMap < QString, QString > & ) ) ); connect( epanObserv, SIGNAL( close_everything() ), this, SLOT( close_all() )); + connect( this, SIGNAL( reset_live_update() ), epanObserv, SLOT( reset_live_update( ) ) ); connect( epanPostProd, SIGNAL( switch_to_editing( QString &, QString &) ), this, SLOT( switch_to_editing( QString &, QString & ) ) ); connect( this, SIGNAL( reset_lims_import() ), epanPostProd, SLOT( reset_lims_import( ) ) ); @@ -381,18 +386,23 @@ 2. More complex: Back to Managing runs from active LIVE_UPDATE stage -- stop all timers and other processes... */ qDebug() << "Jumping from LIVE UPDATE."; + + //2. Stop all timers/threads, reset GUI - when stopping fully working LIVE UPDATE + if ( !xpn_viewer_closed_soft ) + emit reset_live_update(); } if ( curr_panx == 3 ) { qDebug() << "Jumping from LIMS IMPORT."; - //Send sigmal to reset LIMS IMPORT tab... Fully SET + //Send signal to reset LIMS IMPORT tab... Fully SET emit reset_lims_import(); } if ( curr_panx == 4 ) qDebug() << "Jumping from EDITING."; - + + xpn_viewer_closed_soft = false; epanInit ->initAutoflowPanel(); } @@ -627,6 +637,7 @@ // Slot to pass submitted to Optima run info to the Live Update tab void US_ComProjectMain::close_all( void ) { + xpn_viewer_closed_soft = true; tabWidget->setCurrentIndex( 0 ); //epanInit ->initAutoflowPanel(); //DO NOT Duplicate - was called in previous line while changing Tab!!! qDebug() << "XPN viewer /US_convert closed!"; @@ -671,6 +682,12 @@ tabWidget->setCurrentIndex( 3 ); // Maybe lock this panel from now on? i.e. tabWidget->tabBar()-setEnabled(false) ?? curr_panx = 3; + // Trigger resize to update size of the PostProcs + int curr_h = this->height() + 1; + int curr_w = this->width() + 1; + + this->resize( QSize(curr_w, curr_h) ); + for (int i = 1; i < tabWidget->count(); ++i ) { if ( i == 3 ) @@ -1021,7 +1038,7 @@ { QString list_instruments_in_use = occupied_instruments.join(", "); - QMessageBox * msg_instr_use = new QMessageBox; + QMessageBox * msg_instr_use = new QMessageBox(this); msg_instr_use->setIcon(QMessageBox::Information); msg_instr_use->setText(tr( "The following Optima instrument(s)<br>" "are currently in use: <br><br>" @@ -1656,6 +1673,9 @@ //ALEXEY: devise SLOT saying what to do upon completion of experiment and exporting AUC data to hard drive - Import Experimental Data !!! connect( sdiag, SIGNAL( experiment_complete_auto( QMap < QString, QString > & ) ), this, SLOT( to_post_processing ( QMap < QString, QString > & ) ) ); + + //ALEXEY: to reset timers/threads and GUI when returning back to InitDialog + connect( this, SIGNAL( reset_live_update_passed( ) ), sdiag, SLOT( reset_liveupdate_panel ( ) ) ); //ALEXEY: close program, emitted from sdiag connect( sdiag, SIGNAL( close_program() ), this, SLOT( to_close_program() ) ); @@ -1700,6 +1720,11 @@ QWidget::resizeEvent(event); } +void US_ObservGui::reset_live_update( void ) +{ + emit reset_live_update_passed(); +} + // Live Update's get and use submitted run's protocol details void US_ObservGui::process_protocol_details( QMap < QString, QString > & protocol_details ) { Modified: trunk/programs/us_com_project/us_com_project_gui.h =================================================================== --- trunk/programs/us_com_project/us_com_project_gui.h 2019-07-24 06:40:06 UTC (rev 2798) +++ trunk/programs/us_com_project/us_com_project_gui.h 2019-07-25 00:28:19 UTC (rev 2799) @@ -185,11 +185,13 @@ //void to_post_processing( QString & currDir, QString & protocolName, QString & invID_passed, QString & correctRadii ); void to_post_processing( QMap < QString, QString > & ); void to_close_program( void ); + void reset_live_update( void ); signals: void to_xpn_viewer( QMap < QString, QString > & protocol_details ); //void switch_to_post_processing( QString & currDir, QString & protocolName, QString & invID_passed, QString & correctRadii ); void switch_to_post_processing( QMap < QString, QString > & ); void close_everything( void ); + void reset_live_update_passed( void ); }; @@ -336,6 +338,8 @@ void close_initDialogue(); bool window_closed; + bool xpn_viewer_closed_soft; + int curr_panx; // Current panel index (0-7) //QStringList occupied_instruments; @@ -399,6 +403,7 @@ void us_comproject_closed( void ); void pass_used_instruments( QStringList & ); void reset_lims_import( void ); + void reset_live_update( void ); }; Modified: trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.cpp =================================================================== --- trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.cpp 2019-07-24 06:40:06 UTC (rev 2798) +++ trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.cpp 2019-07-25 00:28:19 UTC (rev 2799) @@ -656,6 +656,7 @@ grid_rpm = us_grid( data_plot_rpm ); + //ALEXEY: curves for sysdata must be re-defined in the reset_auto() !!! curv_rpm = us_curve( data_plot_rpm, "RPM" ); curv_temp = us_curve( data_plot_rpm, "Temperature" ); curv_temp->setYAxis ( QwtPlot::yRight ); @@ -665,6 +666,8 @@ curv_temp->setPen( pen_red); curv_rpm ->setPen( pen_green); + /*************************************************************************/ + connect( plot_rpm, SIGNAL( zoomedCorners( QRectF ) ), this, SLOT ( currentRectf ( QRectF ) ) ); @@ -1209,6 +1212,15 @@ data_plot_rpm->setAxisScale( QwtPlot::yRight , 0.0, 40 ); grid_rpm = us_grid( data_plot_rpm ); data_plot_rpm->replot(); + //Curves for RPM/Temp. + curv_rpm = us_curve( data_plot_rpm, "RPM" ); + curv_temp = us_curve( data_plot_rpm, "Temperature" ); + curv_temp->setYAxis ( QwtPlot::yRight ); + QPen pen_red ( Qt::red ); + QPen pen_green ( Qt::green ); + curv_temp->setPen( pen_red); + curv_rpm ->setPen( pen_green); + //RPM/Temp. rpm_box->setSpeed(0); temperature_box->setTemp(0); @@ -1884,7 +1896,7 @@ remaining_time_text = QString::number(dhms_remain[1]) + ":" + QString::number(dhms_remain[2]) + ":" + QString::number(dhms_remain[3]); le_remaining->setText( remaining_time_text ); qApp->processEvents(); - + //RPM/Temp. Plots: //counter_mins += 500; //temporary for testing only @@ -1901,7 +1913,7 @@ double* d_rpm = rpm_data.data(); double* d_temp = temp_data.data(); double* d_time = time_data.data(); - + //axis ranges, temporary double rpm_min = 0; double rpm_max = rpm + 5000; @@ -1913,7 +1925,7 @@ //if (temp_data.size() != 0 ) curv_temp->setSamples( d_time, d_temp, time_data.size() ); curv_rpm->setSamples( d_time, d_rpm, time_data.size() ); - + //data_plot_rpm->setAxisScale( QwtPlot::xBottom, 0.0, double(elapsed_time_1/60.0) ); // <-- HERE data_plot_rpm->setAxisScale( QwtPlot::xBottom, double(ElapsedTimeOffset/60.0), double(elapsed_time_1/60.0) ); // //data_plot_rpm->setAxisScale( QwtPlot::xBottom, 0.0, double(exp_time/60.0 + counter_mins ) ); // for testing only @@ -2121,15 +2133,84 @@ { timer_data_init->stop(); disconnect(timer_data_init, SIGNAL(timeout()), 0, 0); //Disconnect timer from anything + + reset_auto(); - reset_auto(); emit close_program(); } } } +// Reset LIVE UPDATE panel && stop timers && quit threads +void US_XpnDataViewer::reset_liveupdate_panel ( void ) +{ + //Quit sys_thread, emit finished() to stop timer_check_sysdata from withing thread + if ( !sys_thread->isFinished() ) + { + sys_thread->quit(); + qApp->processEvents(); + } + + //Disconnect timer_check_sysdata + if ( timer_check_sysdata->isActive() ) + { + timer_check_sysdata->stop(); + disconnect(timer_check_sysdata, SIGNAL(timeout()), 0, 0); + } + + //Stop other timers if active + if ( timer_all_data_avail->isActive() ) + { + timer_all_data_avail->stop(); + disconnect(timer_all_data_avail, SIGNAL(timeout()), 0, 0); + } + + if ( timer_data_reload->isActive() ) + { + timer_data_reload->stop(); + disconnect(timer_data_reload, SIGNAL(timeout()), 0, 0); + } + + if ( timer_data_init->isActive() ) + { + timer_data_init->stop(); + disconnect(timer_data_init, SIGNAL(timeout()), 0, 0); + } + + qApp->processEvents(); + + /***** DEBUG ***********************/ + if ( sys_thread->isFinished() ) + qDebug() << "QThread STOPPED upon clickig Manage Optima runs !!! "; + + if ( !timer_check_sysdata->isActive() ) + qDebug() << "QTimer timer_check_sysdata STOPPED by clickig Manage Optima runs !!! "; + + if ( !timer_data_init->isActive() ) + qDebug() << "QTimer timer_data_init STOPPED by clickig Manage Optima runs !!! "; + + if ( !timer_all_data_avail->isActive() ) + qDebug() << "QTimer timer_all_data_avail STOPPED by clickig Manage Optima runs !!! "; + + if ( !timer_data_reload->isActive() ) + qDebug() << "QTimer timer_data_reload STOPPED by clickig Manage Optima runs !!! "; + /*************************************/ + + reset_auto(); + + qDebug() << in_reload_auto << ", " << in_reload_all_data << ", " << in_reload_data_init << ", " << in_reload_check_sysdata; + + in_reload_auto = false; + in_reload_all_data = false; + in_reload_data_init = false; + in_reload_check_sysdata = false; + + qApp->processEvents(); +} + + //void US_XpnDataViewer::retrieve_xpn_raw_auto( QString & RunID ) -void US_XpnDataViewer::retrieve_xpn_raw_auto( ) +void US_XpnDataViewer::retrieve_xpn_raw_auto( void ) { if ( in_reload_all_data ) // If already doing a reload, return; // skip starting a new one Modified: trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.h =================================================================== --- trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.h 2019-07-24 06:40:06 UTC (rev 2798) +++ trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.h 2019-07-25 00:28:19 UTC (rev 2799) @@ -303,6 +303,8 @@ bool load_xpn_raw_auto ( void ); void check_for_data ( QMap < QString, QString > & ); void check_for_sysdata ( void ); + + void reset_liveupdate_panel ( void ); //void retrieve_xpn_raw_auto ( QString & ); void retrieve_xpn_raw_auto ( void ); Modified: trunk/utils/us_xpn_data.cpp =================================================================== --- trunk/utils/us_xpn_data.cpp 2019-07-24 06:40:06 UTC (rev 2798) +++ trunk/utils/us_xpn_data.cpp 2019-07-25 00:28:19 UTC (rev 2799) @@ -55,7 +55,7 @@ dbxpn.setUserName ( dbuser ); dbxpn.setPassword ( dbpasw ); - dbxpn.setConnectOptions("connect_timeout=3"); + dbxpn.setConnectOptions("connect_timeout=5"); if ( dbxpn.open() ) {