29 QStringList q(
"get_experiment_info_by_runID" );
67 q <<
"update_experiment"
68 << QString::number(
expID )
72 << QString::number(
labID )
95 << QString::number(
labID )
114 qDebug() <<
"Error saving experiment: " << saveStatus
121 q <<
"get_experiment_info"
122 << QString::number(
expID );
135 QStringList q(
"get_experiment_info_by_runID" );
161 xmlFile = db->
value( 16 ).toString().toAscii();
172 q << QString(
"get_person_info" )
173 << QString::number(
invID );
183 q << QString(
"get_person_info" )
191 q << QString(
"get_instrument_info" )
199 q << QString(
"get_rotor_info" )
212 q << QString(
"get_rotor_calibration_profiles" )
221 q << QString(
"get_rotor_calibration_info" )
228 QStringList dateParts = db->
value( 7 ).toString().split(
" " );
229 rotorUpdated = QDate::fromString( dateParts[ 0 ],
"yyyy-MM-dd" );
237 QVector< US_mwlRamp::RampRawData* >& data,
238 QList< US_Ramp::TripleInfo >& triples,
243 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}$" );
246 if ( this->
expGUID.isEmpty() || ! rx.exactMatch( this->
expGUID ) )
249 if ( dirname.right( 1 ) !=
"/" ) dirname +=
"/";
250 QString writeFile = runID +
"." +
"xml";
251 QFile file( dirname + writeFile );
252 if ( !file.open( QIODevice::WriteOnly | QIODevice::Text) )
255 qDebug() <<
" EsTD: writeFile" << writeFile;
256 QXmlStreamWriter xml;
257 xml.setDevice( &file );
258 xml.setAutoFormatting(
true );
260 xml.writeStartDocument();
261 xml.writeDTD(
"<!DOCTYPE US_Rampdata>");
262 xml.writeStartElement(
"US_Rampdata");
263 xml.writeAttribute(
"version",
"1.0");
266 xml.writeStartElement(
"experiment" );
267 xml.writeAttribute (
"id", QString::number( this->
expID ) );
268 xml.writeAttribute (
"guid", this->
expGUID );
270 xml.writeAttribute (
"runID", this->runID );
272 xml.writeStartElement(
"investigator" );
273 xml.writeAttribute (
"id", QString::number( this->
invID ) );
274 xml.writeAttribute (
"guid", this->
invGUID );
275 xml.writeEndElement ();
277 xml.writeStartElement(
"name" );
278 xml.writeAttribute (
"value", this->
name );
279 xml.writeEndElement ();
281 xml.writeStartElement(
"project" );
285 xml.writeEndElement ();
287 xml.writeStartElement(
"lab" );
288 xml.writeAttribute (
"id", QString::number( this->
labID ) );
289 xml.writeEndElement ();
291 xml.writeStartElement(
"instrument" );
292 xml.writeAttribute (
"id", QString::number( this->
instrumentID ) );
294 xml.writeEndElement ();
296 xml.writeStartElement(
"operator" );
297 xml.writeAttribute (
"id", QString::number( this->
operatorID ) );
299 xml.writeEndElement ();
301 xml.writeStartElement(
"rotor" );
302 xml.writeAttribute (
"id", QString::number( this->
rotorID ) );
303 xml.writeAttribute (
"guid", this->
rotorGUID );
304 xml.writeAttribute (
"serial", this->
rotorSerial );
305 xml.writeAttribute (
"name", this->
rotorName );
306 xml.writeEndElement ();
308 xml.writeStartElement(
"calibration" );
309 xml.writeAttribute (
"id", QString::number( this->
calibrationID ) );
310 xml.writeAttribute (
"coeff1", QString::number( this->
rotorCoeff1 ) );
311 xml.writeAttribute (
"coeff2", QString::number( this->
rotorCoeff2 ) );
312 xml.writeAttribute(
"date", this->
rotorUpdated.toString(
"yyyy-MM-dd" ) );
313 xml.writeEndElement ();
315 QString psolGUID =
"";
316 QString psolDesc =
"";
317 qDebug() <<
" EsTD: triples loop" << triples.size();
320 for (
int trx = 0; trx < triples.size(); trx++ )
334 xml.writeStartElement(
"dataset" );
335 xml.writeAttribute (
"id", QString::number( trp->
tripleID ) );
336 xml.writeAttribute (
"cell", data[trx]->cell );
337 xml.writeAttribute (
"channel", data[trx]->chan );
338 xml.writeStartElement(
"centerpiece" );
339 xml.writeAttribute (
"id", QString::number( trp->
centerpiece ) );
340 xml.writeEndElement ();
346 if ( csolID == psolID || ( csolID < 0 && csolGUID == psolGUID ) )
356 xml.writeStartElement(
"solution" );
357 xml.writeAttribute (
"id", QString::number( csolID ) );
358 xml.writeAttribute (
"guid", csolGUID );
359 xml.writeAttribute (
"desc", csolDesc );
360 xml.writeEndElement ();
365 for (
int lambda = 0; lambda < data[trx]->wl_array.size(); lambda++)
367 xml.writeStartElement(
"subset" );
368 QString wl = QString::number(data[trx]->wl_array.at(lambda));
369 xml.writeAttribute(
"wavelength", wl );
370 xml.writeAttribute(
"guid", uuidc );
371 xml.writeEndElement ();
373 xml.writeEndElement ();
380 xml.writeStartElement(
"date" );
381 xml.writeAttribute (
"value", this->
date );
382 xml.writeEndElement ();
384 xml.writeStartElement(
"runTemp" );
385 xml.writeAttribute (
"value", this->
runTemp );
386 xml.writeEndElement ();
388 xml.writeTextElement (
"label", this->
label );
389 xml.writeTextElement (
"comments", this->
comments );
392 xml.writeEndElement();
393 xml.writeEndDocument();
396 qDebug() <<
" EsTD: call proj saveToDisk";
403 QList< US_Ramp::TripleInfo >& triples,
409 QString filename = runID +
"." +
"xml";
411 QFile f( dirname + filename );
413 QTextStream ds( &f );
415 QXmlStreamReader xml( &f );
417 while ( ! xml.atEnd() )
421 if ( xml.isStartElement() )
423 if ( xml.name() ==
"experiment" )
425 QXmlStreamAttributes a = xml.attributes();
426 this->
expID = a.value(
"id").toString().toInt();
427 this->
expGUID = a.value(
"guid" ).toString();
428 this->
expType = a.value(
"type" ).toString();
429 this->runID = a.value(
"runID" ).toString();
436 bool error = xml.hasError();
437 qDebug() <<
"readFromDisk() error" << error;
446 QXmlStreamReader& xml,
447 QList< US_Ramp::TripleInfo >& triples,
451 while ( ! xml.atEnd() )
455 if ( xml.isEndElement() && xml.name() ==
"experiment" )
return;
457 if ( xml.isStartElement() )
459 if ( xml.name() ==
"investigator" )
461 QXmlStreamAttributes a = xml.attributes();
462 this->
invID = a.value(
"id" ).toString().toInt();
463 this->
invGUID = a.value(
"guid" ).toString();
466 else if ( xml.name() ==
"name" )
468 QXmlStreamAttributes a = xml.attributes();
469 this->
name = a.value(
"value" ).toString();
472 else if ( xml.name() ==
"project" )
474 QXmlStreamAttributes a = xml.attributes();
480 else if ( xml.name() ==
"lab" )
482 QXmlStreamAttributes a = xml.attributes();
483 this->
labID = a.value(
"id" ) .toString().toInt();
486 else if ( xml.name() ==
"instrument" )
488 QXmlStreamAttributes a = xml.attributes();
489 this->
instrumentID = a.value(
"id" ) .toString().toInt();
493 else if ( xml.name() ==
"operator" )
495 QXmlStreamAttributes a = xml.attributes();
496 this->
operatorID = a.value(
"id" ).toString().toInt();
500 else if ( xml.name() ==
"rotor" )
502 QXmlStreamAttributes a = xml.attributes();
503 this->
rotorID = a.value(
"id" ).toString().toInt();
504 this->
rotorGUID = a.value(
"guid" ).toString();
505 this->
rotorSerial = a.value(
"serial" ).toString();
506 this->
rotorName = a.value(
"name" ).toString();
507 this->
calibrationID = a.value(
"calibrationID" ).toString().toInt();
510 else if ( xml.name() ==
"calibration" )
512 QXmlStreamAttributes a = xml.attributes();
514 this->
rotorCoeff1 = a.value(
"coeff1" ).toString().toFloat();
515 this->
rotorCoeff2 = a.value(
"coeff2" ).toString().toFloat();
517 QDate::fromString( a.value(
"date" ).toString(),
"yyyy-MM-dd" );
521 else if ( xml.name() ==
"dataset" )
523 QXmlStreamAttributes a = xml.attributes();
524 QString qid = a.value(
"id" ).toString();
525 QString cell = a.value(
"cell" ).toString();
526 QString channel = a.value(
"channel" ).toString();
536 QString triple = cell +
" / " + channel;
539 for (
int i = 0; i < triples.size(); i++ )
541 if ( triples[ i ].excluded )
continue;
543 if ( triple == triples[ i ].tripleDesc )
553 triples[ ndx ].tripleID = a.value(
"id" ).toString().toInt();
554 QString uuidc = a.value(
"guid" ).toString();
556 (
unsigned char*) triples[ ndx ].tripleGUID );
557 triples[ ndx ].tripleFilename = runID +
"."
561 triples[ ndx ].excluded =
false;
574 else if ( xml.name() ==
"date" )
576 QXmlStreamAttributes a = xml.attributes();
577 this->
date = a.value(
"value" ).toString();
580 else if ( xml.name() ==
"runTemp" )
582 QXmlStreamAttributes a = xml.attributes();
583 this->
runTemp = a.value(
"value" ).toString();
586 else if ( xml.name() ==
"label" )
589 this->
label = xml.text().toString();
592 else if ( xml.name() ==
"comments" )
595 this->
comments = xml.text().toString();
598 else if ( xml.name() ==
"centrifugeProtocol" )
611 while ( ! xml.atEnd() )
615 if ( xml.isEndElement() && xml.name() ==
"dataset" )
return;
617 if ( xml.isStartElement() )
619 if ( xml.name() ==
"centerpiece" )
621 QXmlStreamAttributes a = xml.attributes();
622 triple.
centerpiece = a.value(
"id" ).toString().toInt();
626 else if ( xml.name() ==
"solution" )
628 QXmlStreamAttributes a = xml.attributes();
634 else if ( xml.name() ==
"subset" )
636 QXmlStreamAttributes a = xml.attributes();
637 int tempwl = a.value(
"wavelength" ).toString().toInt();
638 QString tripleGUID = a.value(
"guid" ).toString();
656 runID = QString(
"" );
672 label = QString(
"" );
675 date = QString(
"" );
682 QString syncOK_text = (
syncOK ) ?
"true" :
"false";
684 qDebug() <<
"invID = " <<
invID <<
'\n'
685 <<
"invGUID = " <<
invGUID <<
'\n'
686 <<
"name = " <<
name <<
'\n'
687 <<
"expID = " <<
expID <<
'\n'
688 <<
"expGUID = " <<
expGUID <<
'\n'
692 <<
"runID = " <<
runID <<
'\n'
693 <<
"labID = " <<
labID <<
'\n'
698 <<
"rotorID = " <<
rotorID <<
'\n'
705 <<
"rotorUpdated = " <<
rotorUpdated.toString(
"yyyy-MM-dd" ) <<
'\n'
707 <<
"runTemp = " <<
runTemp <<
'\n'
708 <<
"label = " <<
label <<
'\n'
709 <<
"comments = " <<
comments <<
'\n'
711 <<
"date = " <<
date <<
'\n'
712 <<
"syncOK = " << syncOK_text <<
'\n';