[us-commits] r2765 - in trunk: gui programs/us_com_project programs/us_convert programs/us_experiment programs/us_xpn_viewer sql

svn at svn.aucsolutions.com svn at svn.aucsolutions.com
Thu May 16 23:09:43 MDT 2019


Author: alexey
Date: 2019-05-17 05:09:32 +0000 (Fri, 17 May 2019)
New Revision: 2765

Modified:
   trunk/gui/us_select_item.cpp
   trunk/programs/us_com_project/us_com_project_gui.cpp
   trunk/programs/us_com_project/us_com_project_gui.h
   trunk/programs/us_convert/us_convert_gui.cpp
   trunk/programs/us_convert/us_convert_gui.h
   trunk/programs/us_experiment/us_experiment_gui_optima.cpp
   trunk/programs/us_experiment/us_experiment_gui_optima.h
   trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.cpp
   trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.h
   trunk/sql/us3.sql
   trunk/sql/us3_autoflow_procs.sql
Log:
Automatic flow: first shot at the automation of the stransition from LIBE UPDATE to EDTING
  * no user input required
  * case of NO chromatic abberation for instrument considered:
    -- commercial soft - abort at EDITING stage
    -- Data Aqcution/academoc - choice
    -- no manual stop of the run from Optima panel covered yet... (still requires user input)







Modified: trunk/gui/us_select_item.cpp
===================================================================
--- trunk/gui/us_select_item.cpp	2019-05-15 20:19:58 UTC (rev 2764)
+++ trunk/gui/us_select_item.cpp	2019-05-17 05:09:32 UTC (rev 2765)
@@ -113,7 +113,7 @@
        
        le_info->setText(tr( "<ul><li>Information on one or more experimental methods submitted to Bechman Optima(s) is available. "
 			    "You can reattach to the job by selecting the run from the list below. "
-			    "Alternatively, you can define new experiment method. </ul></li>" ));
+			    "Alternatively, you can define and submit a new experiment method to the availabale Optima instrument(s). </ul></li>" ));
        
        main->addWidget( le_info );
      }

Modified: trunk/programs/us_com_project/us_com_project_gui.cpp
===================================================================
--- trunk/programs/us_com_project/us_com_project_gui.cpp	2019-05-15 20:19:58 UTC (rev 2764)
+++ trunk/programs/us_com_project/us_com_project_gui.cpp	2019-05-17 05:09:32 UTC (rev 2765)
@@ -27,7 +27,7 @@
 #endif
 
 
-//// Constructor:  build the main layout with tab widget panels
+//// Constructor:  ACADEMIC: 'Data Acquision' / us_comproject_academic programs
 US_ComProjectMain::US_ComProjectMain(QString us_mode) : US_Widgets()
 {
   //   dbg_level    = US_Settings::us_debug();
@@ -143,9 +143,10 @@
 
    connect( epanExp, SIGNAL( switch_to_live_update( QMap < QString, QString > &) ), this, SLOT( switch_to_live_update( QMap < QString, QString > & )  ) );
    connect( this   , SIGNAL( pass_to_live_update( QMap < QString, QString > &) ),   epanObserv, SLOT( process_protocol_details( QMap < QString, QString > & )  ) );
-
-   connect( epanObserv, SIGNAL( switch_to_post_processing( QString &, QString &, QString &) ), this, SLOT( switch_to_post_processing( QString &, QString &, QString &) ) );
-   connect( this, SIGNAL( import_data_us_convert( QString &, QString &, QString & ) ),  epanPostProd, SLOT( import_data_us_convert( QString &, QString &, QString & )  ) );
+   connect( epanExp, SIGNAL( to_autoflow_records( ) ), this, SLOT( to_autoflow_records( ) ) );
+   
+   connect( epanObserv, SIGNAL( switch_to_post_processing( QString &, QString &, QString &, SQtring &) ), this, SLOT( switch_to_post_processing( QString &, QString &, QString &, QString &) ) );
+   connect( this, SIGNAL( import_data_us_convert( QString &, QString &, QString &, QString & ) ),  epanPostProd, SLOT( import_data_us_convert( QString &, QString &, QString &, QString & )  ) );
    connect( epanObserv, SIGNAL( switch_to_experiment( QString &) ), this, SLOT( switch_to_experiment(  QString & )  ) );
    connect( this, SIGNAL( clear_experiment( QString & ) ),  epanExp, SLOT( clear_experiment( QString & )  ) );
    connect( epanObserv, SIGNAL( close_everything() ), this, SLOT( close_all() ));
@@ -165,7 +166,7 @@
 
 
 
-//// Constructor:  build the main layout with tab widget panels
+//// Constructor:  COMMERCIAL: us_comproject
 US_ComProjectMain::US_ComProjectMain() : US_Widgets()
 {
   //   dbg_level    = US_Settings::us_debug();
@@ -275,9 +276,10 @@
 
    connect( epanExp, SIGNAL( switch_to_live_update( QMap < QString, QString > &) ), this, SLOT( switch_to_live_update( QMap < QString, QString > & )  ) );
    connect( this   , SIGNAL( pass_to_live_update( QMap < QString, QString > &) ),   epanObserv, SLOT( process_protocol_details( QMap < QString, QString > & )  ) );
-
-   connect( epanObserv, SIGNAL( switch_to_post_processing( QString &, QString &, QString & ) ), this, SLOT( switch_to_post_processing( QString &, QString &, QString & )));
-   connect( this, SIGNAL( import_data_us_convert( QString &, QString &, QString & ) ),  epanPostProd, SLOT( import_data_us_convert( QString &, QString &, QString & )  ) );
+   connect( epanExp, SIGNAL( to_autoflow_records( ) ), this, SLOT( to_autoflow_records( ) ) );
+   
+   connect( epanObserv, SIGNAL( switch_to_post_processing( QString &, QString &, QString &, QString & ) ), this, SLOT( switch_to_post_processing( QString &, QString &, QString &, QString & )));
+   connect( this, SIGNAL( import_data_us_convert( QString &, QString &, QString &, QString & ) ),  epanPostProd, SLOT( import_data_us_convert( QString &, QString &, QString &, QString & )  ) );
    connect( epanObserv, SIGNAL( switch_to_experiment( QString &) ), this, SLOT( switch_to_experiment(  QString & )  ) );
    connect( this, SIGNAL( clear_experiment( QString & ) ),  epanExp, SLOT( clear_experiment( QString & )  ) );
    connect( epanObserv, SIGNAL( close_everything() ), this, SLOT( close_all() ));
@@ -300,6 +302,12 @@
     event->accept();
 }
 
+void US_ComProjectMain::to_autoflow_records( void )
+{
+  check_current_stage();
+}
+
+
 // Function that checks for current program stage based on US-lims DB entry
 void US_ComProjectMain::check_current_stage( void )
 {
@@ -386,10 +394,20 @@
   if ( autoflow_records < 1 )
     return;
 
+  //ALEXEY:
+  /*
+      -- Read (and count) Optima Instruments;
+      -- If the number of 'autoflow' records with the status LIVE_UPDATE && RUNNING is the same as # instruments, disable 'Def. New Exp.' buttion
+      -- Identify free Optima(s) & pass the list to the us_experiment (Lab/Rotors tab -> instruments)
+      -- 
+   */
 
+
   // Dialog of existing autoflow records
   US_Passwd  pw;
   US_DB2* dbP  = new US_DB2( pw.getPasswd() );
+
+  //read_optima_machines
   list_all_autoflow_records( autoflowdata, dbP );
   
   QString pdtitle( tr( "Select Optima Run to Follow" ) );
@@ -433,7 +451,7 @@
   QString currDir      = protocol_details[ "dataPath" ];
   QString invID_passed = protocol_details[ "invID_passed" ];
   QString ProtName     = protocol_details[ "protocolName" ];
-  
+  QString correctRadii = protocol_details[ "correctRadii" ];
  
   //ALEXEY: if stage=="EDITING" && curDir.isEmpty() (NULL)
   /*
@@ -452,7 +470,7 @@
   if ( stage == "EDITING" )
     {
       //do something
-      switch_to_post_processing( currDir, ProtName, invID_passed );
+      switch_to_post_processing( currDir, ProtName, invID_passed, correctRadii );
 
       //ALEXEY: should pass investigator as well: should be saved in 'autoflow'
       /*
@@ -474,6 +492,66 @@
   
 }
 
+// Slot to read all Optima machines <------------------------------- // New
+void US_ComProjectMain::read_optima_machines( US_DB2* db )
+{
+  QStringList q( "" );
+  q.clear();
+  q  << QString( "get_instrument_names" )
+     << QString::number( 1 );
+  db->query( q );
+  
+  if ( db->lastErrno() == US_DB2::OK )      // If not, no instruments defined
+    {
+      QList< int > instrumentIDs;
+      
+      // Grab all the IDs so we can reuse the db connection
+      while ( db->next() )
+	{
+	  int ID = db->value( 0 ).toString().toInt();
+	  instrumentIDs << ID;
+	  
+	  qDebug() << "InstID: " << ID;
+	}
+      
+      // Instrument information
+      foreach ( int ID, instrumentIDs )
+	{
+	  QMap<QString,QString> instrument;
+	  
+	  q.clear();
+	  q  << QString( "get_instrument_info_new" )
+	     << QString::number( ID );
+	  db->query( q );
+	  db->next();
+
+	  instrument[ "ID" ]              =   QString::number( ID );
+	  instrument[ "name" ]            =   db->value( 0 ).toString();
+	  instrument[ "serial" ]          =   db->value( 1 ).toString();
+	  instrument[ "optimaHost" ]      =   db->value( 5 ).toString();	   
+	  instrument[ "optimaPort" ]      =   db->value( 6 ).toString(); 
+	  instrument[ "optimaDBname" ]    =   db->value( 7 ).toString();	   
+	  instrument[ "optimaDBusername" ] =  db->value( 8 ).toString();	   
+	  instrument[ "optimaDBpassw" ]    =  db->value( 9 ).toString();	   
+	  instrument[ "selected" ]        =   db->value( 10 ).toString();
+	    
+	  instrument[ "opsys1" ]  = db->value( 11 ).toString();
+	  instrument[ "opsys2" ]  = db->value( 12 ).toString();
+	  instrument[ "opsys3" ]  = db->value( 13 ).toString();
+
+	  instrument[ "radcalwvl" ]  =  db->value( 14 ).toString();
+	  instrument[ "chromoab" ]   =  db->value( 15 ).toString();
+
+	  
+	  if ( instrument[ "name" ].contains("Optima") || instrument[ "optimaHost" ].contains("AUC_DATA_DB") )
+	    this->instruments << instrument;
+	}
+    }
+  qDebug() << "Reading Instrument: FINISH";
+}
+
+
+
 // Query autoflow for # records
 int US_ComProjectMain::list_all_autoflow_records( QList< QStringList >& autoflowdata, US_DB2* dbP )
 {
@@ -504,7 +582,8 @@
       if ( time_started.toString().isEmpty() )
 	autoflowentry << QString( tr( "NOT STARTED" ) );
       else
-	autoflowentry << time_started.toString();
+	autoflowentry << QString( tr( "STARTED" ) );
+	//autoflowentry << time_started.toString();
       
       autoflowdata  << autoflowentry;
       nrecs++;
@@ -578,7 +657,8 @@
            protocol_details[ "dataPath" ]       = db->value( 8 ).toString();   
 	   protocol_details[ "OptimaName" ]     = db->value( 9 ).toString();
 	   protocol_details[ "runStarted" ]     = db->value( 10 ).toString();
-	   protocol_details[ "invID_passed" ]   = db->value( 11 ).toString(); 
+	   protocol_details[ "invID_passed" ]   = db->value( 11 ).toString();
+	   protocol_details[ "correctRadii" ]   = db->value( 12 ).toString();
 	 }
      }
 
@@ -636,13 +716,13 @@
 }
 
 // Slot to switch from the Live Update to Editing tab
-void US_ComProjectMain::switch_to_post_processing( QString  & currDir, QString & protocolName,  QString & invID_passed )
+void US_ComProjectMain::switch_to_post_processing( QString  & currDir, QString & protocolName,  QString & invID_passed, QString & correctRadii )
 {
    tabWidget->setCurrentIndex( 2 );   // Maybe lock this panel from now on? i.e. tabWidget->tabBar()-setEnabled(false) ??
 
    // ALEXEY: Make a record to 'autoflow' table: stage# = 2; 
 
-   emit import_data_us_convert( currDir, protocolName, invID_passed );
+   emit import_data_us_convert( currDir, protocolName, invID_passed, correctRadii );
 }
      
 // Slot to switch back from the Live Update to Experiment tab
@@ -756,6 +836,8 @@
 
    connect( this, SIGNAL( reset_experiment( QString & ) ), sdiag, SLOT( us_exp_clear( QString & ) ) );
    
+   connect( sdiag, SIGNAL( exp_cleared( ) ), this, SLOT( exp_cleared( ) ) );
+   
    sdiag->pb_close->setEnabled(false);  // Disable Close button
    offset = 0;
    sdiag->move(offset, 2*offset);
@@ -824,7 +906,13 @@
   emit reset_experiment( protocolName );
 }
 
+//Upon clearing Experiment .. 
+void US_ExperGui::exp_cleared( void )
+{
+  emit to_autoflow_records();
+}
 
+
 // On click to open US_Experiment  <-- NOT USED, us_experimnet is loaded immediately
 void US_ExperGui::manageExperiment()
 {
@@ -922,7 +1010,7 @@
    connect( this, SIGNAL( to_xpn_viewer( QMap < QString, QString > &) ), sdiag, SLOT( check_for_data ( QMap < QString, QString > & )  ) );
 
    //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( QString &, QString &, QString & ) ), this, SLOT( to_post_processing ( QString &, QString &, QString &) ) );
+   connect( sdiag, SIGNAL( experiment_complete_auto( QString &, QString &, QString &, QString & ) ), this, SLOT( to_post_processing ( QString &, QString &, QString &, QString & ) ) );
 
    //ALEXEY: return to 1st panel when exp. aborted & no data saved..
    connect( sdiag, SIGNAL( return_to_experiment( QString & ) ), this, SLOT( to_experiment ( QString &) ) );
@@ -984,9 +1072,9 @@
   emit to_xpn_viewer( protocol_details );
 }
 
-void US_ObservGui::to_post_processing( QString & currDir, QString & protocolName, QString & invID_passed )
+void US_ObservGui::to_post_processing( QString & currDir, QString & protocolName, QString & invID_passed,  QString & correctRadii )
 {
-  emit switch_to_post_processing( currDir, protocolName, invID_passed );
+  emit switch_to_post_processing( currDir, protocolName, invID_passed, correctRadii );
 }
 
 void US_ObservGui::to_experiment( QString & protocolName )
@@ -1043,7 +1131,7 @@
    sdiag = new US_ConvertGui("AUTO");
    sdiag->setParent(this, Qt::Widget);
 
-   connect( this, SIGNAL( to_post_prod( QString &, QString &, QString & ) ), sdiag, SLOT( import_data_auto ( QString &, QString &, QString & )  ) );
+   connect( this, SIGNAL( to_post_prod( QString &, QString &, QString &, QString & ) ), sdiag, SLOT( import_data_auto ( QString &, QString &, QString &, QString & )  ) );
    //ALEXEY: switch to Analysis
    connect( sdiag, SIGNAL( saving_complete_auto( QString &, QString & ) ), this, SLOT( to_analysis ( QString &, QString &) ) );
    //ALEXEY: for academic ver. switch back to experiment
@@ -1054,13 +1142,16 @@
    sdiag->setFrameShape( QFrame::Box);
    sdiag->setLineWidth(2);
 
+   if ( mainw->us_mode_bool )
+     sdiag->us_mode_passed();
+
    sdiag->show();
 
 }
 
-void US_PostProdGui::import_data_us_convert( QString & currDir, QString & protocolName, QString & invID_passed )
+void US_PostProdGui::import_data_us_convert( QString & currDir, QString & protocolName, QString & invID_passed, QString & correctRadii )
 {
-  emit to_post_prod( currDir, protocolName, invID_passed );
+  emit to_post_prod( currDir, protocolName, invID_passed, correctRadii );
 }
 
 void US_PostProdGui::to_analysis( QString & currDir, QString & protocolName )

Modified: trunk/programs/us_com_project/us_com_project_gui.h
===================================================================
--- trunk/programs/us_com_project/us_com_project_gui.h	2019-05-15 20:19:58 UTC (rev 2764)
+++ trunk/programs/us_com_project/us_com_project_gui.h	2019-05-17 05:09:32 UTC (rev 2765)
@@ -89,11 +89,13 @@
       void us_exp_is_closed_set_button( void );
       void to_live_update( QMap < QString, QString > & protocol_details );
       void clear_experiment( QString & protocolName);
-     
+      void exp_cleared( void );
+      
    signals:
       void switch_to_live_update( QMap < QString, QString > & protocol_details );
       void set_auto_mode( void );
       void reset_experiment( QString & protocolName);
+      void to_autoflow_records( void );
 };
 
 
@@ -116,12 +118,12 @@
       
  private slots:
       void process_protocol_details( QMap < QString, QString > & protocol_details );
-      void to_post_processing( QString & currDir, QString & protocolName, QString & invID_passed );
+      void to_post_processing( QString & currDir, QString & protocolName, QString & invID_passed, QString & correctRadii );
       void to_experiment( QString & protocolName );
       void to_close_program( void );
  signals:
       void to_xpn_viewer( QMap < QString, QString > & protocol_details );
-      void switch_to_post_processing( QString & currDir, QString & protocolName, QString & invID_passed  );
+      void switch_to_post_processing( QString & currDir, QString & protocolName, QString & invID_passed, QString & correctRadii  );
       void switch_to_experiment( QString & protocolName );
       void close_everything( void );
 };
@@ -146,12 +148,12 @@
     void resizeEvent(QResizeEvent *event) override;
       
   private slots:
-    void import_data_us_convert( QString & currDir, QString & protocolName, QString & invID_passed  );
+    void import_data_us_convert( QString & currDir, QString & protocolName, QString & invID_passed, QString & correctRadii  );
     void to_analysis( QString & currDir, QString & protocolName );
     void to_experiment( QString & protocolName );
     
   signals:
-    void to_post_prod( QString & currDir, QString & protocolName, QString & invID_passed  );
+    void to_post_prod( QString & currDir, QString & protocolName, QString & invID_passed, QString & correctRadii  );
     void switch_to_analysis( QString & currDir, QString & protocolName );
     void switch_to_exp( QString & protocolName );
 };
@@ -246,8 +248,11 @@
   int  get_autoflow_records( void );
   QMap < QString, QString > read_autoflow_record( int );
   static int list_all_autoflow_records( QList< QStringList >&, US_DB2* );
+
+  void read_optima_machines( US_DB2* = 0 ); 
+  QMap<QString, QString> currentInstrument;     
+  QList< QMap<QString, QString> > instruments;  
   
-  
 private slots:
   //void reset     ( void );
   //void newPanel  ( int  );     // Move to a new panel
@@ -259,16 +264,18 @@
   //void unable_tabs_buttons( void);  // Slot to unable Tabs and Buttons when user level is low
   //void enable_tabs_buttons( void);  // Slot to enable Tabs and Buttons after protocol is loaded
   void switch_to_live_update( QMap < QString, QString > & protocol_details );
-  void switch_to_post_processing( QString & currDir, QString & protocolName, QString & invID_passed  );
+  void switch_to_post_processing( QString & currDir, QString & protocolName, QString & invID_passed, QString & correctRadii );
   void switch_to_analysis( QString & currDir, QString & protocolName );
   void switch_to_experiment( QString & protocolName );
   //void check_current_stage( void );
   void close_all( void );
   void closeEvent      ( QCloseEvent* );
+
+  void to_autoflow_records( void );
   
 signals:
   void pass_to_live_update( QMap < QString, QString > & protocol_details ); 
-  void import_data_us_convert( QString & currDir, QString & protocolName, QString & invID_passed );
+  void import_data_us_convert( QString & currDir, QString & protocolName, QString & invID_passed, QString & correctRadii );
   void pass_to_analysis( QString & currDir, QString & protocolName );
   void clear_experiment( QString & protocolName);
   void us_comproject_closed( void );

Modified: trunk/programs/us_convert/us_convert_gui.cpp
===================================================================
--- trunk/programs/us_convert/us_convert_gui.cpp	2019-05-15 20:19:58 UTC (rev 2764)
+++ trunk/programs/us_convert/us_convert_gui.cpp	2019-05-17 05:09:32 UTC (rev 2765)
@@ -47,6 +47,8 @@
 {
    ExpData.invID = US_Settings::us_inv_ID();
 
+   usmode = false;
+
    // Ensure data directories are there
    QDir dir;
    dir.mkpath( US_Settings::workBaseDir() );
@@ -545,6 +547,8 @@
 {
    ExpData.invID = US_Settings::us_inv_ID();
 
+   usmode = false;
+
    // Ensure data directories are there
    QDir dir;
    dir.mkpath( US_Settings::workBaseDir() );
@@ -1112,8 +1116,15 @@
    reimport();
 }
 
-void US_ConvertGui::import_data_auto( QString &currDir, QString &protocolName, QString &invID_passed )
+void US_ConvertGui::us_mode_passed( void )
 {
+  qDebug() << "US_Convert:   US_MODE SIGNAL: ";
+  usmode = true;
+}
+
+
+void US_ConvertGui::import_data_auto( QString &currDir, QString &protocolName, QString &invID_passed, QString &correctRadii )
+{
   // ALEXEY TO BE ADDED...
   /* 
      assign investigator HERE passed in (QString &currDir, QString &protocolName, QString &invID_passed) as 3rd parameter; saved in 'autoflow' table
@@ -1127,8 +1138,60 @@
   qDebug() << "US_CONVERT: ExpData.invID, invID_passed: " << ExpData.invID << ", " << invID_passed;
   
   int impType = getImports_auto( currDir );
-  ProtocolName_auto = protocolName;   
+  ProtocolName_auto = protocolName;
 
+  //ALEXEY: if there is no radii_correction data found, return for commercial, and present dialogue for academic:
+  if ( correctRadii == "NO" )
+    {
+      if ( !usmode ) // us_comprojetc
+	{
+	  //return because in commercial ver. ther must be radii corrections for instrument!!!
+	  QMessageBox::information( this,
+				    tr( "No Chromatic Aberration Correction Found: " ),
+				    tr( "NO wavelength correction data for currently used \n"
+					"Optima machine found in DB! \n"
+					"Data will NOT be imported; Program will be reset.") );
+	   
+	   //ALEXY: need to delete autoflow record here
+	   delete_autoflow_record();
+	   emit saving_complete_back_to_exp( ProtocolName_auto );
+	   return;
+	  
+	}
+      else          // us_comproject_academoc / Data Acquisition  
+	{
+	  //dialog
+	  
+	  QMessageBox msgBox;
+	  msgBox.setText(tr("No Chromatic Aberration Correction Found!"));
+	  msgBox.setInformativeText( tr("NO wavelength correction data for currently used \n"
+					"Optima machine found in DB! \n"
+					"Data were NOT modified ! \n\n"
+					"You may proceed with importing data by clicking <b>Continue</b> \n" 
+					"OR disregard data and reset the program by clicking <b>Ignore Data</b> ") );
+	  
+	  msgBox.setWindowTitle(tr("Data Not Modified"));
+	  QPushButton *Continue  = msgBox.addButton(tr("Continue"), QMessageBox::YesRole);
+	  QPushButton *Ignore    = msgBox.addButton(tr("Ignore Data"), QMessageBox::RejectRole);
+	  
+	  msgBox.setIcon(QMessageBox::Question);
+	  msgBox.exec();
+
+	  if (msgBox.clickedButton() == Continue)
+	    {
+	      msgBox.accept();
+	    }
+	  else if ( msgBox.clickedButton() == Ignore )
+	    {
+	      delete_autoflow_record();
+	      emit saving_complete_back_to_exp( ProtocolName_auto );
+	      return;
+	    }
+	}
+    }
+
+  
+
    if ( impType == 1 )
    {
      qDebug() << "IMPORT MWL auto...";
@@ -1536,55 +1599,84 @@
    le_runID ->setText( runID );
    scanTolerance = 5.0;
 
-   // //ALEXEY: Remove Duplicates in Channel's description
-   // for (int i = 0; i < allData.size(); i++)
-   //   {
-   //     qDebug() << "Description BEFORE: " << i << ", " << allData[ i ].description;
+   // //ALEXEY: Remove Duplicates in Channel's description: Simpler solution
+   //  for (int i = 0; i < allData.size(); i++)
+   //    {
+   // 	qDebug() << "Description BEFORE: " << i << ", " << allData[ i ].description;
+	
+   // 	QString desc   = allData[ i ].description;
+   // 	desc.replace(",", "");
+   // 	desc.replace(";", "");
 
-   //     QString desc   = allData[ i ].description;
-   //     desc.replace(",", "");
-   //     QString desc_a = desc.split(QRegExp(";"))[0];
-   //     QString desc_b = desc.split(QRegExp(";"))[1];
+   // 	QStringList desc_list = desc.split(QRegExp("\\s+"));
+   // 	desc_list.removeDuplicates();
+	
+   // 	QString final_desc("");
+   // 	for ( int i=0; i<desc_list.size(); i++ )
+   // 	  {
+   // 	    if ( desc_list[i].isEmpty() )
+   // 	      continue;
+   // 	    final_desc +=  desc_list[i];
 
-   //     //list of channel A desc
-   //     QStringList desc_list_a = desc_a.split(QRegExp("\\s+"));
-   //     desc_list_a.removeDuplicates();
+   // 	    if ( i != desc_list.size() - 1)
+   // 	      final_desc += QString(" ");
+   // 	  }
 
-   //     //list of channel B desc
-   //     QStringList desc_list_b = desc_b.split(QRegExp("\\s+"));
-   //     desc_list_b.removeDuplicates();
+   // 	allData[ i ].description = final_desc;
+   // 	qDebug() << "Description AFTER:  " << i << ", " << allData[ i ].description;
+   //    }
+     
 
-   //     QString final_desc("");
-       
-   //     for ( int i=0; i<desc_list_a.size(); i++ )
-   // 	 {
-   // 	   if ( desc_list_a[i].isEmpty() )
-   // 	     continue;
-   // 	   final_desc +=  desc_list_a[i];
+    
+     // //ALEXEY: Remove Duplicates in Channel's description
+     // for (int i = 0; i < allData.size(); i++)
+     //   {
+     //     qDebug() << "Description BEFORE: " << i << ", " << allData[ i ].description;
 
-   // 	   if ( i != desc_list_a.size() - 1)
-   // 	     final_desc += QString(" ");
-   // 	   else
-   // 	     final_desc += QString("; ");
+     //     QString desc   = allData[ i ].description;
+     //     desc.replace(",", "");
+     //     QString desc_a = desc.split(QRegExp(";"))[0];
+     //     QString desc_b = desc.split(QRegExp(";"))[1];
 
-   // 	 }
-   //     for ( int i=0; i<desc_list_b.size(); i++ )
-   // 	 {
-   // 	   if ( desc_list_b[i].isEmpty() )
-   // 	     continue;
-   // 	   final_desc +=  desc_list_b[i];
+     //     //list of channel A desc
+     //     QStringList desc_list_a = desc_a.split(QRegExp("\\s+"));
+     //     desc_list_a.removeDuplicates();
 
-   // 	   if ( i != desc_list_b.size() - 1)
-   // 	     final_desc += QString(" ");
-   // 	   // else
-   // 	   //   final_desc += QString("; ");
-	   
-   // 	 }
+     //     //list of channel B desc
+     //     QStringList desc_list_b = desc_b.split(QRegExp("\\s+"));
+     //     desc_list_b.removeDuplicates();
+
+     //     QString final_desc("");
+    
+     //     for ( int i=0; i<desc_list_a.size(); i++ )
+     // 	 {
+     // 	   if ( desc_list_a[i].isEmpty() )
+     // 	     continue;
+     // 	   final_desc +=  desc_list_a[i];
+
+     // 	   if ( i != desc_list_a.size() - 1)
+     // 	     final_desc += QString(" ");
+     // 	   else
+     // 	     final_desc += QString("; ");
+
+     // 	 }
+     //     for ( int i=0; i<desc_list_b.size(); i++ )
+     // 	 {
+     // 	   if ( desc_list_b[i].isEmpty() )
+     // 	     continue;
+     // 	   final_desc +=  desc_list_b[i];
+
+     // 	   if ( i != desc_list_b.size() - 1)
+     // 	     final_desc += QString(" ");
+     // 	   // else
+     // 	   //   final_desc += QString("; ");
+    	   
+     // 	 }
+    
+     //     allData[ i ].description = final_desc;
+     //     qDebug() << "Description AFTER:  " << i << ", " << allData[ i ].description;
+     //   }
        
-   //     allData[ i ].description = final_desc;
-   //     qDebug() << "Description AFTER:  " << i << ", " << allData[ i ].description;
-   //   }
-       
    if ( ! init_output_data() )
       return;
 
@@ -4715,28 +4807,31 @@
    } // End of 'else' loop for multispeed case
 
 // x  x  x  x  x
-   if ( !us_convert_auto_mode )
+   if ( us_convert_auto_mode )   // if us_comproject OR us_comproject_academic
      {
-       QMessageBox::information( this,
-				 tr( "Save is Complete" ),
-				 tr( "The save of all data and reports is complete." ) );
-
-       //ALEXY: need to delete autoflow record here
-       delete_autoflow_record();
-       emit saving_complete_back_to_exp( ProtocolName_auto );
-       return;
+       if ( usmode )             // us_comproject_academic
+	 {
+	   QMessageBox::information( this,
+				     tr( "Save is Complete" ),
+				     tr( "The save of all data and reports is complete." ) );
+	   
+	   //ALEXY: need to delete autoflow record here
+	   delete_autoflow_record();
+	   emit saving_complete_back_to_exp( ProtocolName_auto );
+	   return;
+	 }
+       else                       // us_comproject
+	 {
+	   // ALEXEY: // If "AUTO" - emit signal to pass to stage 4. Analysis
+	   QMessageBox::information( this,
+				     tr( "Save is Complete" ),
+				     tr( "The save of all data and reports is complete.\n\n"
+					 "The program will switch to Analysis stage." ) );
+	   
+	   // Either emit ONLY if not US_MODE, or do NOT connect with slot on us_comproject...
+	   emit saving_complete_auto( currentDir, ProtocolName_auto  );   
+	 }
      }
-   else
-     {
-       // ALEXEY: // If "AUTO" - emit signal to pass to stage 4. Analysis
-       QMessageBox::information( this,
-				 tr( "Save is Complete" ),
-				 tr( "The save of all data and reports is complete.\n\n"
-				     "The program will switch to Analysis stage." ) );
-
-       // Either emit ONLY if not US_MODE, or do NOT connect with slot on us_comproject...
-       emit saving_complete_auto( currentDir, ProtocolName_auto  );   
-     }
 }
 
 //Delete autoflow record upon Run abortion

Modified: trunk/programs/us_convert/us_convert_gui.h
===================================================================
--- trunk/programs/us_convert/us_convert_gui.h	2019-05-15 20:19:58 UTC (rev 2764)
+++ trunk/programs/us_convert/us_convert_gui.h	2019-05-17 05:09:32 UTC (rev 2765)
@@ -46,6 +46,9 @@
       US_SimulationParameters simparams;      //!< Simulation parameters
       QList< double >         subsets;        //!< A list of subset boundaries
 
+      void us_mode_passed  ( void );
+      bool usmode;
+
   signals:
       void saving_complete_auto( QString &, QString & );
       void saving_complete_back_to_exp( QString & );
@@ -299,7 +302,7 @@
       */
       void assign_investigator( int );
 
-      void import_data_auto  (QString &, QString &, QString &);
+      void import_data_auto  (QString &, QString &, QString &, QString &);
       
       void import            ( void );
       void reimport          ( void );

Modified: trunk/programs/us_experiment/us_experiment_gui_optima.cpp
===================================================================
--- trunk/programs/us_experiment/us_experiment_gui_optima.cpp	2019-05-15 20:19:58 UTC (rev 2764)
+++ trunk/programs/us_experiment/us_experiment_gui_optima.cpp	2019-05-17 05:09:32 UTC (rev 2765)
@@ -221,7 +221,8 @@
 
   // ALEXEY: do proper reset of everything
   reset();
-  //emit to_live_update( protocol_details );
+  
+  emit exp_cleared();
 }
 
 // When run submitted to Optima
@@ -5304,6 +5305,7 @@
          protocol_details[ "CellChNumber" ]   = QString::number(rpSolut->nschan); // this can be read from protocol in US-lims DB
 	 protocol_details[ "duration" ]       = QString::number(Total_duration);
 	 protocol_details[ "invID_passed" ]   = QString::number(US_Settings::us_inv_ID());
+	 protocol_details[ "correctRadii" ]   = QString("YES");
 	 
          int nwavl_tot = 0;
          for ( int kk = 0; kk < rpRange->nranges; kk++ )

Modified: trunk/programs/us_experiment/us_experiment_gui_optima.h
===================================================================
--- trunk/programs/us_experiment/us_experiment_gui_optima.h	2019-05-15 20:19:58 UTC (rev 2764)
+++ trunk/programs/us_experiment/us_experiment_gui_optima.h	2019-05-17 05:09:32 UTC (rev 2765)
@@ -958,6 +958,7 @@
     signals:
       void us_exp_is_closed( void );
       void to_live_update( QMap < QString, QString > &protocol_details );
+      void exp_cleared ( void );
       
       
 };

Modified: trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.cpp
===================================================================
--- trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.cpp	2019-05-15 20:19:58 UTC (rev 2764)
+++ trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.cpp	2019-05-17 05:09:32 UTC (rev 2765)
@@ -220,6 +220,8 @@
    QGridLayout* settings    = new QGridLayout;
    QGridLayout* live_params = new QGridLayout;
    QGridLayout* time_params = new QGridLayout;
+
+   auto_mode_bool = true;
    
    navgrec      = 10;
    dbg_level    = US_Settings::us_debug();
@@ -741,6 +743,8 @@
    setPalette( US_GuiSettings::frameColor() );
 
    QGridLayout* settings = new QGridLayout;
+   
+   auto_mode_bool = false;
 
    navgrec      = 10;
    dbg_level    = US_Settings::us_debug();
@@ -1659,21 +1663,31 @@
        << RunID_to_retrieve
        << currentDir;
 
-   //db->query( qry );
+   db->query( qry );
 
-   // OR
+   //ALEXEY: if there is NO chromatic Abber. data, set corrRadii in autoflow record to 'NO'
+   if ( correctRadii == "NO" )
+     {
+       qry.clear();
+       qry << "update_autoflow_at_live_update_radiicorr"
+	   << RunID_to_retrieve;
 
-   qDebug() << "Trying to Update Autoflow table AT LIVE_UPDATE!!";
-   int status = db->statusQuery( qry );
+       db->query( qry );
+     }
    
-   if ( status == US_DB2::NO_AUTOFLOW_RECORD )
-     {
-       QMessageBox::warning( this,
-			     tr( "Autoflow Record Not Updated" ),
-			     tr( "No autoflow record\n"
-				 "associated with RunID %1 exists!" ).arg( RunID_to_retrieve ) );
-       return;
-     }
+   // // OR
+
+   // qDebug() << "Trying to Update Autoflow table AT LIVE_UPDATE!!";
+   // int status = db->statusQuery( qry );
+   
+   // if ( status == US_DB2::NO_AUTOFLOW_RECORD )
+   //   {
+   //     QMessageBox::warning( this,
+   // 			     tr( "Autoflow Record Not Updated" ),
+   // 			     tr( "No autoflow record\n"
+   // 				 "associated with RunID %1 exists!" ).arg( RunID_to_retrieve ) );
+   //     return;
+   //   }
 }
    
 
@@ -1819,17 +1833,16 @@
 	{
 	  if ( !timer_data_reload->isActive() )
 	    {
-
 	      qDebug() << "TRY PROCEED INTO ==5 from check_for_sys_data()....";
 	      // ALEXEY Export AUC data: devise export_auc_auto() function which would return directory name with saved data - to pass to emit signal below... 
 	      export_auc_auto();
 	      
-	      QString mtitle_complete  = tr( "Complete!" );
-	      QString message_done     = tr( "Experiment was completed. Optima data saved..." );
-	      QMessageBox::information( this, mtitle_complete, message_done );
+	      // QString mtitle_complete  = tr( "Complete!" );
+	      // QString message_done     = tr( "Experiment was completed. Optima data saved..." );
+	      // QMessageBox::information( this, mtitle_complete, message_done );
 	      
 	      updateautoflow_record_atLiveUpdate();
-	      emit experiment_complete_auto( currentDir, ProtocolName, invID_passed  );  // Updtade later: what should be passed with signal ??
+	      emit experiment_complete_auto( currentDir, ProtocolName, invID_passed, correctRadii  );  // Updtade later: what should be passed with signal ??
 	
 	      return;
 	    }
@@ -1855,7 +1868,7 @@
 	      
 	      QMessageBox msgBox;
 	      msgBox.setText(tr("Experiment was aborted!"));
-	      msgBox.setInformativeText("The data retrieved so far can be saved or disregarded. If saved, the program will proceed to the next stage (Editing). Otherwise, it will return to the initial stage (Experiment).");
+	      msgBox.setInformativeText("The data retrieved so far can be saved or disregarded. If saved, the program will proceed to the next stage (Editing). Otherwise, it will return to the initial stage (Experiment), all data will be lost.");
 	      msgBox.setWindowTitle(tr("Experiment Abortion"));
 	      QPushButton *Save      = msgBox.addButton(tr("Save Data"), QMessageBox::YesRole);
 	      QPushButton *Ignore    = msgBox.addButton(tr("Ignore Data"), QMessageBox::RejectRole);
@@ -1872,7 +1885,7 @@
 		  QMessageBox::information( this, mtitle_complete, message_done );
 		  
 		  updateautoflow_record_atLiveUpdate();
-		  emit experiment_complete_auto( currentDir, ProtocolName, invID_passed  );  // Updtade later: what should be passed with signal ??
+		  emit experiment_complete_auto( currentDir, ProtocolName, invID_passed, correctRadii  );  // Updtade later: what should be passed with signal ??
 		  return;
 		}
 	      
@@ -1933,8 +1946,8 @@
   TripleNumber = protocol_details[ "TripleNumber" ];
   OptimaName   = protocol_details[ "OptimaName" ];               //New
   TotalDuration = protocol_details[ "duration" ];
-
   invID_passed = protocol_details[ "invID_passed" ];
+  correctRadii = protocol_details[ "correctRadii" ];
 
   selectOptimaByName_auto( OptimaName );                         //New  
   
@@ -2269,7 +2282,7 @@
 	   
 	   QMessageBox msgBox;
 	   msgBox.setText(tr("Experiment was aborted!"));
-	   msgBox.setInformativeText("The data retrieved so far can be saved or disregarded. If saved, the program will proceed to the next stage (Editing). Otherwise, it will return to the initial stage (Experiment).");
+	   msgBox.setInformativeText("The data retrieved so far can be saved or disregarded. If saved, the program will proceed to the next stage (Editing). Otherwise, it will return to the initial stage (Experiment), all data will be lost.");
 	   msgBox.setWindowTitle(tr("Experiment Abortion"));
 	   QPushButton *Save      = msgBox.addButton(tr("Save Data"), QMessageBox::YesRole);
 	   QPushButton *Ignore    = msgBox.addButton(tr("Ignore Data"), QMessageBox::RejectRole);
@@ -2286,7 +2299,7 @@
 	       QMessageBox::information( this, mtitle_complete, message_done );
 	       
 	       updateautoflow_record_atLiveUpdate();
-	       emit experiment_complete_auto( currentDir, ProtocolName, invID_passed  );  // Updtade later: what should be passed with signal ??
+	       emit experiment_complete_auto( currentDir, ProtocolName, invID_passed, correctRadii  );  // Updtade later: what should be passed with signal ??
 	       return;
 	     }
 	   
@@ -3635,13 +3648,13 @@
 	      // ALEXEY Export AUC data: devise export_auc_auto() function which would return directory name with saved data - to pass to emit signal below... 
 	      export_auc_auto();
 	  
-	      QString mtitle_complete  = tr( "Complete!" );
-	      QString message_done     = tr( "Experiment was completed. Optima data saved..." );
-	      QMessageBox::information( this, mtitle_complete, message_done );
+	      // QString mtitle_complete  = tr( "Complete!" );
+	      // QString message_done     = tr( "Experiment was completed. Optima data saved..." );
+	      // QMessageBox::information( this, mtitle_complete, message_done );
 
 	      updateautoflow_record_atLiveUpdate();
 	      
-	      emit experiment_complete_auto( currentDir, ProtocolName, invID_passed  );  // Updtade later: what should be passed with signal ??
+	      emit experiment_complete_auto( currentDir, ProtocolName, invID_passed, correctRadii  );  // Updtade later: what should be passed with signal ??
 	      //QString temp_protname("DemchukA_exosomes40K_111418");
 	      //emit experiment_complete_auto( currentDir, temp_protname  );  
 	  
@@ -3663,7 +3676,7 @@
 	      
 	      QMessageBox msgBox;
 	      msgBox.setText(tr("Experiment was aborted!"));
-	      msgBox.setInformativeText("The data retrieved so far can be saved or disregarded. If saved, the program will proceed to the next stage (Editing). Otherwise, it will return to the initial stage (Experiment).");
+	      msgBox.setInformativeText("The data retrieved so far can be saved or disregarded. If saved, the program will proceed to the next stage (Editing). Otherwise, it will return to the initial stage (Experiment), all data will be lost.");
 	      msgBox.setWindowTitle(tr("Experiment Abortion"));
 	      QPushButton *Save      = msgBox.addButton(tr("Save Data"), QMessageBox::YesRole);
 	      QPushButton *Ignore    = msgBox.addButton(tr("Ignore Data"), QMessageBox::RejectRole);
@@ -3680,7 +3693,7 @@
 		  QMessageBox::information( this, mtitle_complete, message_done );
 
 		  updateautoflow_record_atLiveUpdate();
-		  emit experiment_complete_auto( currentDir, ProtocolName, invID_passed  );  // Updtade later: what should be passed with signal ??
+		  emit experiment_complete_auto( currentDir, ProtocolName, invID_passed, correctRadii );  // Updtade later: what should be passed with signal ??
 		  return;
 		}
 	      
@@ -3868,12 +3881,15 @@
    // a correction was found
    if (correction.size() > 0)
    {
-     QMessageBox::warning( this,
-            tr( "Chromatic Aberration Correction:" ),
-	    tr( "Wavelength correction data for currently used Optima machine\n"
-		"are found in DB and will be used to correct your data for\n"
-		"chromatic aberration between 190 nm and 800 nm.\n\n"
-		"Exported data will be modified!\n") );
+     if ( !auto_mode_bool  )
+       {
+	 QMessageBox::warning( this,
+			       tr( "Chromatic Aberration Correction:" ),
+			       tr( "Wavelength correction data for currently used Optima machine\n"
+				   "are found in DB and will be used to correct your data for\n"
+				   "chromatic aberration between 190 nm and 800 nm.\n\n"
+				   "Exported data will be modified!\n") );
+       }
      
       // For each triple, get the wavelength; then compute and apply a correction
       for ( int jd = 0; jd < ntripl; jd++ )
@@ -3893,13 +3909,21 @@
                }
             }
          }
-if (jd<3 || (jd+4)>ntripl )
-DbgLv(1) << "c_r:  ri0 ro0" << r_radii[0] << allData[jd].xvalues[0]
- << "rin ron" << r_radii[npoint-1] << allData[jd].xvalues[npoint-1];
+	 if (jd<3 || (jd+4)>ntripl )
+	   DbgLv(1) << "c_r:  ri0 ro0" << r_radii[0] << allData[jd].xvalues[0]
+		    << "rin ron" << r_radii[npoint-1] << allData[jd].xvalues[npoint-1];
       }
    }
+   else // No chromatic abberation in instrument's table
+     {
+       if ( auto_mode_bool  )
+	 {
+	   correctRadii = QString("NO");
+	 }
+     }
 }
 
+
 /*
 // Apply a chromatic aberration correction to auc data radius values       <--- OLD function
 void US_XpnDataViewer::correct_radii()

Modified: trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.h
===================================================================
--- trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.h	2019-05-15 20:19:58 UTC (rev 2764)
+++ trunk/programs/us_xpn_viewer/us_xpn_viewer_gui.h	2019-05-17 05:09:32 UTC (rev 2765)
@@ -96,6 +96,8 @@
      US_XpnDataViewer(QString auto_mode);
 
   private:
+     bool auto_mode_bool;
+     
      QVector< US_DataIO::RawData >   allData;    //!< All AUC raw data
 
      QVector< double > r_radii;     //!< Loaded radii
@@ -280,6 +282,8 @@
      QString        OptimaName;          //New
      QString        TotalDuration;       //New
      QString        invID_passed;
+     QString        correctRadii;
+     
      int            ElapsedTimeOffset;
 
      void           timeToList( int&, QList< int >& );
@@ -347,7 +351,7 @@
      void test_optima_connection( void );              //New
      
    signals:
-     void experiment_complete_auto( QString &, QString &, QString & );
+     void experiment_complete_auto( QString &, QString &, QString &, QString & );
      void return_to_experiment( QString & );
      void close_program( void );
 };

Modified: trunk/sql/us3.sql
===================================================================
--- trunk/sql/us3.sql	2019-05-15 20:19:58 UTC (rev 2764)
+++ trunk/sql/us3.sql	2019-05-17 05:09:32 UTC (rev 2765)
@@ -101,6 +101,7 @@
   runStarted TIMESTAMP NULL,
   invID  INT NULL,
   created TIMESTAMP NULL,
+  corrRadii enum('YES', 'NO') NOT NULL,
   PRIMARY KEY (ID) )
 ENGINE = InnoDB;
 

Modified: trunk/sql/us3_autoflow_procs.sql
===================================================================
--- trunk/sql/us3_autoflow_procs.sql	2019-05-15 20:19:58 UTC (rev 2764)
+++ trunk/sql/us3_autoflow_procs.sql	2019-05-17 05:09:32 UTC (rev 2765)
@@ -151,7 +151,7 @@
       SELECT @OK AS status;
 
       SELECT   protName, cellChNum, tripleNum, duration, runName, expID, 
-      	       runID, status, dataPath, optimaName, runStarted, invID, created
+      	       runID, status, dataPath, optimaName, runStarted, invID, created, corrRadii 
       FROM     autoflow
       WHERE    ID = p_autoflowID;
 
@@ -283,6 +283,46 @@
 END$$
 
 
+
+-- Update autoflow record with corrRadii value at LIVE_UPDATE
+DROP PROCEDURE IF EXISTS update_autoflow_at_live_update_radiicorr$$
+CREATE PROCEDURE update_autoflow_at_live_update_radiicorr ( p_personGUID    CHAR(36),
+                                             	p_password      VARCHAR(80),
+                                       	     	p_runID    	 INT )
+					 
+  MODIFIES SQL DATA  
+
+BEGIN
+  DECLARE count_records INT;
+
+  CALL config();
+  SET @US3_LAST_ERRNO = @OK;
+  SET @US3_LAST_ERROR = '';
+
+  SELECT     COUNT(*)
+  INTO       count_records
+  FROM       autoflow
+  WHERE      runID = p_runID;
+
+  IF ( verify_user( p_personGUID, p_password ) = @OK ) THEN
+    IF ( count_records = 0 ) THEN
+      SET @US3_LAST_ERRNO = @NO_AUTOFLOW_RECORD;
+      SET @US3_LAST_ERROR = 'MySQL: no rows returned';
+
+    ELSE
+      UPDATE   autoflow
+      SET      corrRadii = 'NO'
+      WHERE    runID = p_runID;
+
+    END IF;
+
+  END IF;
+
+  SELECT @US3_LAST_ERRNO AS status;
+
+END$$
+
+
 ----  get initial elapsed time upon reattachment ----------------------------- 
 DROP FUNCTION IF EXISTS read_autoflow_times$$
 CREATE FUNCTION read_autoflow_times ( p_personGUID CHAR(36),



More information about the us-commits mailing list