30 QStringList q(
"get_experiment_info_by_runID" );
44 QVector< SP_SPEEDPROFILE >& speedsteps )
46 qDebug() <<
"Exp:svToDB: update" << update <<
"ss-count" << speedsteps.count();
59 QByteArray RIxmlEscaped;
78 q <<
"update_experiment"
79 << QString::number( expID )
83 << QString::number(
labID )
103 q <<
"new_experiment"
107 << QString::number(
labID )
127 qDebug() <<
"Error saving experiment: " << saveStatus
133 QString idExp = QString::number( expID );
135 q <<
"get_experiment_info" << idExp;
143 q <<
"delete_speedsteps" << idExp;
145 if ( saveStatus != 0 )
147 qDebug() <<
"Delete_SpeedSteps" << saveStatus << db->
lastError();
149 qDebug() <<
"Exp:svToDB: delss status" << saveStatus << db->
lastError();
151 qDebug() <<
"Exp:svToDB: ss count" << speedsteps.count() <<
"expID" <<
expID;
152 for (
int jj = 0; jj < speedsteps.count(); jj++ )
154 qDebug() <<
"Exp:svToDB: jj" << jj <<
"expID" <<
expID;
157 qDebug() <<
"Exp:svToDB: ssstat=" << ssstat;
165 QVector< SP_SPEEDPROFILE >& speedsteps )
167 QStringList q(
"get_experiment_info_by_runID" );
193 xmlFile = db->
value( 16 ).toString().toAscii();
194 qDebug() <<
"Exp:rdDB: ExpInfRun: xmlFile size" << xmlFile.size();
205 q << QString(
"get_person_info" )
206 << QString::number(
invID );
216 q << QString(
"get_person_info" )
224 q << QString(
"get_instrument_info" )
232 q << QString(
"get_rotor_info" )
245 q << QString(
"get_rotor_calibration_profiles" )
254 q << QString(
"get_rotor_calibration_info" )
261 QStringList dateParts = db->
value( 7 ).toString().split(
" " );
262 rotorUpdated = QDate::fromString( dateParts[ 0 ],
"yyyy-MM-dd" );
270 qDebug() <<
"Exp:rdDB: xmlFile size" << xmlFile.size();
271 if ( xmlFile.size() > 0 )
274 QString RIPfname = readDir.absolutePath() +
"/" + runID +
"/"
275 + runID +
".RIProfile.xml";
276 qDebug() <<
"Exp:rdDB: RIPfname" << RIPfname;
278 QFile rfo( RIPfname );
279 qDebug() <<
"Exp:rdDB: rfo exists" << rfo.exists();
280 qDebug() <<
"Exp:rdDB: rfo size" << rfo.size();
282 if ( ! rfo.exists() || rfo.size() == 0 )
284 if ( rfo.open( QIODevice::WriteOnly ) )
286 qDebug() <<
"Exp:rdDB: rfo OPENED xmlFile size" << xmlFile.size();
287 rfo.write( xmlFile );
294 qDebug() <<
"Exp:rdDB: importRIxml status" << status;
308 qDebug() <<
"Exp:rdDB: speedsteps size expID" << speedsteps.size() <<
expID;
309 if(speedsteps.size()>0)
310 qDebug() <<
"Exp:rdDB: ss0 rspeed avgspeed" << speedsteps[0].rotorspeed
311 << speedsteps[0].avg_speed;
317 QList< US_Convert::TripleInfo >& triples,
321 QVector< SP_SPEEDPROFILE >& speedsteps )
323 QRegExp rx(
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" );
326 if ( this->
expGUID.isEmpty() || ! rx.exactMatch( this->
expGUID ) )
329 if ( dirname.right( 1 ) !=
"/" ) dirname +=
"/";
330 QString writeFile = runID +
"."
332 QFile file( dirname + writeFile );
333 if ( !file.open( QIODevice::WriteOnly | QIODevice::Text) )
337 qDebug() <<
" EsTD: writeFile" << writeFile;
338 QXmlStreamWriter xml;
339 xml.setDevice( &file );
340 xml.setAutoFormatting(
true );
342 xml.writeStartDocument();
343 xml.writeDTD(
"<!DOCTYPE US_Scandata>");
344 xml.writeStartElement(
"US_Scandata");
345 xml.writeAttribute(
"version",
"1.0");
348 xml.writeStartElement(
"experiment" );
349 xml.writeAttribute (
"id", QString::number( this->
expID ) );
350 xml.writeAttribute (
"guid", this->
expGUID );
351 xml.writeAttribute (
"type", this->
expType );
352 xml.writeAttribute (
"runID", this->runID );
354 xml.writeStartElement(
"investigator" );
355 xml.writeAttribute (
"id", QString::number( this->
invID ) );
356 xml.writeAttribute (
"guid", this->
invGUID );
357 xml.writeEndElement ();
359 xml.writeStartElement(
"name" );
360 xml.writeAttribute (
"value", this->
name );
361 xml.writeEndElement ();
363 xml.writeStartElement(
"project" );
367 xml.writeEndElement ();
369 xml.writeStartElement(
"lab" );
370 xml.writeAttribute (
"id", QString::number( this->
labID ) );
371 xml.writeEndElement ();
373 xml.writeStartElement(
"instrument" );
374 xml.writeAttribute (
"id", QString::number( this->
instrumentID ) );
376 xml.writeEndElement ();
378 xml.writeStartElement(
"operator" );
379 xml.writeAttribute (
"id", QString::number( this->
operatorID ) );
381 xml.writeEndElement ();
383 xml.writeStartElement(
"rotor" );
384 xml.writeAttribute (
"id", QString::number( this->
rotorID ) );
385 xml.writeAttribute (
"guid", this->
rotorGUID );
386 xml.writeAttribute (
"serial", this->
rotorSerial );
387 xml.writeAttribute (
"name", this->
rotorName );
388 xml.writeEndElement ();
390 xml.writeStartElement(
"calibration" );
391 xml.writeAttribute (
"id", QString::number( this->
calibrationID ) );
392 xml.writeAttribute (
"coeff1", QString::number( this->
rotorCoeff1 ) );
393 xml.writeAttribute (
"coeff2", QString::number( this->
rotorCoeff2 ) );
394 xml.writeAttribute(
"date", this->
rotorUpdated.toString(
"yyyy-MM-dd" ) );
395 xml.writeEndElement ();
397 QString psolGUID =
"";
398 QString psolDesc =
"";
399 qDebug() <<
" EsTD: triples loop" << triples.size();
402 for (
int trx = 0; trx < triples.size(); trx++ )
408 QStringList parts = triple.split(
" / ");
410 QString cell = parts[ 0 ];
411 QString channel = parts[ 1 ];
412 QString wl = parts[ 2 ];
416 xml.writeStartElement(
"dataset" );
417 xml.writeAttribute (
"id", QString::number( trp->
tripleID ) );
418 xml.writeAttribute (
"guid", uuidc );
419 xml.writeAttribute (
"cell", cell );
420 xml.writeAttribute (
"channel", channel );
422 if ( runType ==
"WA" )
423 xml.writeAttribute(
"radius", wl );
426 xml.writeAttribute(
"wavelength", wl );
428 xml.writeStartElement(
"centerpiece" );
429 xml.writeAttribute (
"id", QString::number( trp->
centerpiece ) );
430 xml.writeEndElement ();
436 if ( csolID == psolID || ( csolID < 0 && csolGUID == psolGUID ) )
446 xml.writeStartElement(
"solution" );
447 xml.writeAttribute (
"id", QString::number( csolID ) );
448 xml.writeAttribute (
"guid", csolGUID );
449 xml.writeAttribute (
"desc", csolDesc );
450 xml.writeEndElement ();
452 xml.writeEndElement ();
455 for (
int jj = 0; jj < speedsteps.count(); jj++ )
458 xml.writeStartElement(
"opticalSystem" );
460 xml.writeEndElement ();
462 xml.writeStartElement(
"date" );
463 xml.writeAttribute (
"value", this->
date );
464 xml.writeEndElement ();
466 xml.writeStartElement(
"runTemp" );
467 xml.writeAttribute (
"value", this->
runTemp );
468 xml.writeEndElement ();
470 xml.writeTextElement (
"label", this->
label );
471 xml.writeTextElement (
"comments", this->
comments );
474 xml.writeEndElement();
475 xml.writeEndDocument();
478 qDebug() <<
" EsTD: call proj saveToDisk";
485 QList< US_Convert::TripleInfo >& triples,
491 QString filename = runID +
"."
494 QFile f( dirname + filename );
496 QTextStream ds( &f );
498 QXmlStreamReader xml( &f );
500 while ( ! xml.atEnd() )
504 if ( xml.isStartElement() )
506 if ( xml.name() ==
"experiment" )
508 QXmlStreamAttributes a = xml.attributes();
509 this->
expID = a.value(
"id").toString().toInt();
510 this->
expGUID = a.value(
"guid" ).toString();
511 this->
expType = a.value(
"type" ).toString();
512 this->runID = a.value(
"runID" ).toString();
518 bool error = xml.hasError();
519 qDebug() <<
"readFromDisk() error" << error;
528 QXmlStreamReader& xml,
529 QList< US_Convert::TripleInfo >& triples,
533 while ( ! xml.atEnd() )
537 if ( xml.isEndElement() && xml.name() ==
"experiment" )
return;
539 if ( xml.isStartElement() )
541 if ( xml.name() ==
"investigator" )
543 QXmlStreamAttributes a = xml.attributes();
544 this->
invID = a.value(
"id" ).toString().toInt();
545 this->
invGUID = a.value(
"guid" ).toString();
548 else if ( xml.name() ==
"name" )
550 QXmlStreamAttributes a = xml.attributes();
551 this->
name = a.value(
"value" ).toString();
554 else if ( xml.name() ==
"project" )
556 QXmlStreamAttributes a = xml.attributes();
562 else if ( xml.name() ==
"lab" )
564 QXmlStreamAttributes a = xml.attributes();
565 this->
labID = a.value(
"id" ) .toString().toInt();
568 else if ( xml.name() ==
"instrument" )
570 QXmlStreamAttributes a = xml.attributes();
571 this->
instrumentID = a.value(
"id" ) .toString().toInt();
575 else if ( xml.name() ==
"operator" )
577 QXmlStreamAttributes a = xml.attributes();
578 this->
operatorID = a.value(
"id" ).toString().toInt();
582 else if ( xml.name() ==
"rotor" )
584 QXmlStreamAttributes a = xml.attributes();
585 this->
rotorID = a.value(
"id" ).toString().toInt();
586 this->
rotorGUID = a.value(
"guid" ).toString();
587 this->
rotorSerial = a.value(
"serial" ).toString();
588 this->
rotorName = a.value(
"name" ).toString();
589 this->
calibrationID = a.value(
"calibrationID" ).toString().toInt();
592 else if ( xml.name() ==
"calibration" )
594 QXmlStreamAttributes a = xml.attributes();
596 this->
rotorCoeff1 = a.value(
"coeff1" ).toString().toFloat();
597 this->
rotorCoeff2 = a.value(
"coeff2" ).toString().toFloat();
599 QDate::fromString( a.value(
"date" ).toString(),
"yyyy-MM-dd" );
602 else if ( xml.name() ==
"dataset" )
604 QXmlStreamAttributes a = xml.attributes();
605 QString cell = a.value(
"cell" ).toString();
606 QString channel = a.value(
"channel" ).toString();
609 if ( runType ==
"WA" )
610 wl = a.value(
"radius" ).toString();
613 wl = a.value(
"wavelength" ).toString();
616 QString triple = cell +
" / " + channel +
" / " + wl;
619 for (
int i = 0; i < triples.size(); i++ )
621 if ( triples[ i ].excluded )
continue;
623 if ( triple == triples[ i ].tripleDesc )
633 triples[ ndx ].tripleID = a.value(
"id" ).toString().toInt();
634 QString uuidc = a.value(
"guid" ).toString();
636 (
unsigned char*) triples[ ndx ].tripleGUID );
638 if ( runType ==
"WA" )
640 double r = wl.toDouble() * 1000.0;
641 QString radius = QString::number( qRound( r ) );
642 triples[ ndx ].tripleFilename = runID +
"."
651 triples[ ndx ].tripleFilename = runID +
"."
658 triples[ ndx ].excluded =
false;
664 else if ( xml.name() ==
"opticalSystem" )
666 QXmlStreamAttributes a = xml.attributes();
667 this->
opticalSystem = a.value(
"value" ).toString().toAscii();
670 else if ( xml.name() ==
"date" )
672 QXmlStreamAttributes a = xml.attributes();
673 this->
date = a.value(
"value" ).toString();
676 else if ( xml.name() ==
"runTemp" )
678 QXmlStreamAttributes a = xml.attributes();
679 this->
runTemp = a.value(
"value" ).toString();
682 else if ( xml.name() ==
"label" )
685 this->
label = xml.text().toString();
688 else if ( xml.name() ==
"comments" )
691 this->
comments = xml.text().toString();
694 else if ( xml.name() ==
"centrifugeProtocol" )
706 while ( ! xml.atEnd() )
710 if ( xml.isEndElement() && xml.name() ==
"dataset" )
return;
712 if ( xml.isStartElement() )
714 if ( xml.name() ==
"centerpiece" )
716 QXmlStreamAttributes a = xml.attributes();
717 triple.
centerpiece = a.value(
"id" ).toString().toInt();
720 else if ( xml.name() ==
"solution" )
722 QXmlStreamAttributes a = xml.attributes();
736 if ( dirname.right( 1 ) !=
"/" ) dirname +=
"/";
737 QString writeFile = runID +
"."
739 QFile file( dirname + writeFile );
740 if ( !file.open( QIODevice::WriteOnly | QIODevice::Text) )
747 QTextStream out( &file );
758 QString filename = runID +
"."
766 QFile f( dirname + filename );
769 QTextStream ds( &f );
770 QXmlStreamReader xml( &f );
772 while ( ! xml.atEnd() )
776 if ( xml.isStartElement() )
778 QXmlStreamAttributes a = xml.attributes();
779 QStringRef xname = xml.name();
783 double value = a.value(
"value" ).toString().toDouble();
787 else if ( xname ==
"WVL" )
789 int iwavl = a.value(
"value" ).toString().toInt();
793 else if ( xname ==
"WVPro" )
795 this->
RI_nscans = a.value(
"scans" ).toString().toInt();
796 this->
RI_nwvlns = a.value(
"wavelengths" ).toString().toInt();
801 bool error = xml.hasError();
803 qDebug() <<
"readRIDisk() error" << error;
814 str = QByteArray(
"" );
820 str = QByteArray(
"" );
827 QBuffer buffer( &str );
828 buffer.open( QIODevice::WriteOnly );
830 QXmlStreamWriter xml;
831 xml.setDevice( &buffer );
832 xml.setAutoFormatting(
true );
834 xml.writeStartDocument();
835 xml.writeDTD(
"<!DOCTYPE US_RIProfile>");
836 xml.writeStartElement(
"US_RIProfile");
837 xml.writeAttribute(
"version",
"1.0");
840 foreach (
double value, this->
RIProfile )
842 xml.writeStartElement(
"RI" );
843 xml.writeAttribute (
"value", QString::number( value ) );
844 xml.writeEndElement ();
847 if ( this->
RIwvlns.size() > 1 )
852 for (
int jj = 0; jj < nwvlns; jj++ )
854 int iwavl = this->
RIwvlns[ jj ];
855 xml.writeStartElement(
"WVL" );
856 xml.writeAttribute (
"value", QString::number( iwavl ) );
857 xml.writeEndElement ();
860 xml.writeStartElement(
"WVPro" );
861 xml.writeAttribute (
"scans", QString::number( nscans ) );
862 xml.writeAttribute (
"wavelengths", QString::number( nwvlns ) );
863 xml.writeEndElement ();
866 xml.writeEndElement();
867 xml.writeEndDocument();
874 QBuffer buffer( &str );
875 buffer.open( QIODevice::ReadOnly );
877 QXmlStreamReader xml( &buffer );
884 while ( ! xml.atEnd() )
888 if ( xml.isStartElement() )
890 QXmlStreamAttributes a = xml.attributes();
891 QStringRef xname = xml.name();
895 double value = a.value(
"value" ).toString().toDouble();
899 else if ( xname ==
"WVL" )
901 int iwavl = a.value(
"value" ).toString().toInt();
905 else if ( xname ==
"WVPro" )
907 this->
RI_nscans = a.value(
"scans" ).toString().toInt();
908 this->
RI_nwvlns = a.value(
"wavelengths" ).toString().toInt();
913 bool error = xml.hasError();
915 qDebug() <<
"importRIxml() error" << error;
931 runID = QString(
"" );
948 label = QString(
"" );
951 date = QString(
"" );
960 QString syncOK_text = (
syncOK ) ?
"true" :
"false";
962 qDebug() <<
"invID = " <<
invID <<
'\n'
963 <<
"invGUID = " <<
invGUID <<
'\n'
964 <<
"name = " <<
name <<
'\n'
965 <<
"expID = " <<
expID <<
'\n'
966 <<
"expGUID = " <<
expGUID <<
'\n'
970 <<
"runID = " <<
runID <<
'\n'
971 <<
"labID = " <<
labID <<
'\n'
976 <<
"rotorID = " <<
rotorID <<
'\n'
983 <<
"rotorUpdated = " <<
rotorUpdated.toString(
"yyyy-MM-dd" ) <<
'\n'
984 <<
"expType = " <<
expType <<
'\n'
986 <<
"runTemp = " <<
runTemp <<
'\n'
987 <<
"label = " <<
label <<
'\n'
988 <<
"comments = " <<
comments <<
'\n'
990 <<
"date = " <<
date <<
'\n'
991 <<
"syncOK = " << syncOK_text <<
'\n';
993 for (
int i = 0; i <
rpms.size(); i++ )
995 qDebug() <<
"i = " << i ;
996 qDebug() <<
"rpm = " <<
rpms[ i ];
999 qDebug() <<
"RI Profile data";
1000 for (
int i = 0; i <
RIProfile.size(); i++ )