UltraScan III
us_buffer.cpp
Go to the documentation of this file.
1 #include "us_buffer.h"
3 #include "us_settings.h"
4 #include "us_constants.h"
5 #include "us_db2.h"
6 #include "us_datafiles.h"
7 #include "us_util.h"
8 
9 void US_BufferComponent::getAllFromDB( const QString& masterPW,
10  QMap< QString, US_BufferComponent >& componentList )
11 {
12  US_DB2 db( masterPW );
13 
14  if ( db.lastErrno() != US_DB2::OK )
15  {
16  qDebug() << "Database Error"
17  << "US_BufferComponent ::connectDB: Could not open DB\n"
18  << db.lastError();
19  return;
20  }
21 
22  QStringList q( "get_buffer_component_desc" );
23  db.query( q );
24  QStringList cids;
25 
26  while ( db.next() )
27  {
28  cids << db.value( 0 ).toString();
29  }
30 
31  for ( int ii = 0; ii < cids.size(); ii++ )
32  {
34  c.componentID = cids.at( ii );
35  c.getInfoFromDB( &db );
36  componentList[ c.componentID ] = c;
37  }
38 }
39 
41 {
42  QStringList q( "get_buffer_component_info" );
43  q << componentID;
44 
45  db->query( q );
46  db->next();
47 
48  unit = db->value( 0 ).toString();
49  name = db->value( 1 ).toString();
50  QString viscosity = db->value( 2 ).toString();
51  QString density = db->value( 3 ).toString();
52  range = db->value( 4 ).toString();
53  grad_form = US_Util::bool_flag( db->value( 5 ).toString() );
54 
55  QStringList sl = viscosity.split( " " );
56 
57  for ( int i = 0; i < 6 ; i++ )
58  visc_coeff[ i ] = sl[ i ].toDouble();
59 
60  sl = density.split( " " );
61 
62  for ( int i = 0; i < 6 ; i++ )
63  dens_coeff[ i ] = sl[ i ].toDouble();
64 
65  sl = sl.mid( 6 ); // Remove coefficients
66  range = range.isEmpty() ? sl.join( " " ) : range;
67 }
68 
70  QMap< QString, US_BufferComponent >& componentList )
71 {
72  componentList.clear();
73 
74  QString fname = US_Settings::appBaseDir() + "/etc/bufferComponents.xml";
75  QFile file( fname );
76 
77  if ( ! file.open( QIODevice::ReadOnly | QIODevice::Text) )
78  {
79  // Fail quietly
80  qDebug() << "Cannot open file " << fname;
81  return;
82  }
83 
84  QXmlStreamReader xml( &file );
85 
86  while ( ! xml.atEnd() )
87  {
88  xml.readNext();
89 
90  if ( xml.isStartElement() )
91  {
92  if ( xml.name() == "component" )
93  component( xml, componentList );
94  }
95  }
96 
97  file.close();
98 }
99 
101  QXmlStreamReader& xml,
102  QMap< QString, US_BufferComponent >& componentList )
103 {
105 
106  QXmlStreamAttributes a = xml.attributes();
107  bc.componentID = a.value( "id" ).toString();
108  bc.name = a.value( "name" ).toString();
109  bc.unit = a.value( "unit" ).toString();
110  bc.range = a.value( "range" ).toString();
112  a.value( "gradient_forming" ).toString() );
113 
114  while ( ! xml.atEnd() )
115  {
116 
117  if ( xml.isEndElement() && xml.name() == "component" )
118  {
119  componentList[ bc.componentID ] = bc;
120  return;
121  }
122 
123  if ( xml.isStartElement() && xml.name() == "densityCoefficients" )
124  {
125  QXmlStreamAttributes a = xml.attributes();
126  bc.dens_coeff[ 0 ] = a.value( "c0" ).toString().toDouble();
127  bc.dens_coeff[ 1 ] = a.value( "c1" ).toString().toDouble();
128  bc.dens_coeff[ 2 ] = a.value( "c2" ).toString().toDouble();
129  bc.dens_coeff[ 3 ] = a.value( "c3" ).toString().toDouble();
130  bc.dens_coeff[ 4 ] = a.value( "c4" ).toString().toDouble();
131  bc.dens_coeff[ 5 ] = a.value( "c5" ).toString().toDouble();
132  }
133 
134  if ( xml.isStartElement() && xml.name() == "viscosityCoefficients" )
135  {
136  QXmlStreamAttributes a = xml.attributes();
137  bc.visc_coeff[ 0 ] = a.value( "c0" ).toString().toDouble();
138  bc.visc_coeff[ 1 ] = a.value( "c1" ).toString().toDouble();
139  bc.visc_coeff[ 2 ] = a.value( "c2" ).toString().toDouble();
140  bc.visc_coeff[ 3 ] = a.value( "c3" ).toString().toDouble();
141  bc.visc_coeff[ 4 ] = a.value( "c4" ).toString().toDouble();
142  bc.visc_coeff[ 5 ] = a.value( "c5" ).toString().toDouble();
143  }
144 
145  xml.readNext();
146  }
147 }
148 
150  const QMap< QString, US_BufferComponent >& componentList )
151 {
152  QFile file( US_Settings::appBaseDir() + "/etc/bufferComponents.xml" );
153 
154  if ( ! file.open( QIODevice::WriteOnly | QIODevice::Text) )
155  {
156  qDebug() << "Cannot open file " << US_Settings::appBaseDir() + "/etc/bufferComponents.xml";
157  return;
158  }
159 
160  QXmlStreamWriter xml( &file );
161  xml.setAutoFormatting( true );
162 
163  xml.writeStartDocument();
164  xml.writeDTD ( "<!DOCTYPE US_BufferComponents>" );
165  xml.writeStartElement( "BufferComponents" );
166  xml.writeAttribute ( "version", "1.0" );
167 
168  QStringList keys = componentList.keys();
169 
170  for ( int i = 0; i < keys.size(); i++ )
171  {
172  QString key = keys[ i ];
173  xml.writeStartElement( "component" );
174  xml.writeAttribute( "id" , componentList[ key ].componentID );
175  xml.writeAttribute( "name" , componentList[ key ].name );
176  xml.writeAttribute( "unit" , componentList[ key ].unit );
177  xml.writeAttribute( "range", componentList[ key ].range );
178  xml.writeAttribute( "gradient_forming",
179  US_Util::bool_string( componentList[ key ].grad_form ) );
180 
181  QString factor;
182  QString value;
183 
184  xml.writeStartElement( "densityCoefficients" );
185  for ( int j = 0; j < 6; j++ )
186  {
187  factor.sprintf( "c%i", j );
188  value = QString::number( componentList[ key ].dens_coeff[ j ], 'f', 5 );
189  xml.writeAttribute( factor, value );
190  }
191 
192  xml.writeEndElement(); // densityCoefficients
193 
194  xml.writeStartElement( "viscosityCoefficients" );
195  for ( int j = 0; j < 6; j++ )
196  {
197  factor.sprintf( "c%i", j );
198  value = QString::number( componentList[ key ].visc_coeff[ j ], 'f', 5 );
199  xml.writeAttribute( factor, value );
200  }
201 
202  xml.writeEndElement(); // viscosityCoefficients
203  xml.writeEndElement(); // component
204  }
205 
206  xml.writeEndElement(); // US_BufferComponents
207  xml.writeEndDocument();
208 
209  file.close();
210 }
211 
212 //------------- US_Buffer
214 {
215  compressibility = 0.0;
216  pH = WATER_PH;
217  density = DENS_20W;
219  manual = false;
220  person .clear();
221  bufferID .clear();
222  GUID .clear();
223  description .clear();
224  extinction .clear();
225  refraction .clear();
226  fluorescence .clear();
227  component .clear();
228  componentIDs .clear();
229  concentration.clear();
230 }
231 
232 void US_Buffer::getSpectrum( US_DB2* db, const QString& type )
233 {
234  QStringList q;
235  q << "get_spectrum" << bufferID << "Buffer" << type;
236 
237  db->query( q );
238 
239  while ( db->next() )
240  {
241  double lambda = db->value( 0 ).toDouble();
242  double value = db->value( 1 ).toDouble();
243 
244  if ( type == "Extinction" )
245  extinction[ lambda ] = value;
246  else if ( type == "Refraction" )
247  refraction[ lambda ] = value;
248  else
249  fluorescence[ lambda ] = value;
250  }
251 }
252 
253 void US_Buffer::putSpectrum( US_DB2* db, const QString& type ) const
254 {
255  QStringList q;
256  q << "new_spectrum" << bufferID << "Buffer" << type << "" << "";
257 
258  if ( type == "Extinction" )
259  {
260  QList< double > keys = extinction.keys();
261 
262  for ( int i = 0; i < keys.size(); i++ )
263  {
264  double wavelength = keys[ i ];
265  q[ 4 ] = QString::number( wavelength, 'f', 1 );
266  q[ 5 ] = QString::number( extinction[ wavelength ], 'e', 4 );
267  db->statusQuery( q );
268  }
269  }
270 
271  else if ( type == "Refraction" )
272  {
273  QList< double > keys = refraction.keys();
274 
275  for ( int i = 0; i < keys.size(); i++ )
276  {
277  double wavelength = keys[ i ];
278  q[ 4 ] = QString::number( wavelength, 'f', 1 );
279  q[ 5 ] = QString::number( refraction[ wavelength ], 'e', 4 );
280  db->statusQuery( q );
281  }
282  }
283 
284  else
285  {
286  QList< double > keys = fluorescence.keys();
287 
288  for ( int i = 0; i < keys.size(); i++ )
289  {
290  double wavelength = keys[ i ];
291  q[ 4 ] = QString::number( wavelength, 'f', 1 );
292  q[ 5 ] = QString::number( fluorescence[ wavelength ], 'e', 4 );
293  db->statusQuery( q );
294  }
295  }
296 }
297 
298 bool US_Buffer::writeToDisk( const QString& filename ) const
299 {
300  QFile file( filename );
301  if ( ! file.open( QIODevice::WriteOnly | QIODevice::Text) )
302  {
303  qDebug() << "Cannot open file for writing: " << filename;
304  return false;
305  }
306 
307  QXmlStreamWriter xml( &file );
308  xml.setAutoFormatting( true );
309 
310  xml.writeStartDocument();
311  xml.writeDTD ( "<!DOCTYPE US_Buffer>" );
312  xml.writeStartElement( "BufferData" );
313  xml.writeAttribute ( "version", "1.0" );
314 
315  xml.writeStartElement( "buffer" );
316  xml.writeAttribute( "id" , "0" ); // buffers written to disk get bufferID "0"
317  xml.writeAttribute( "guid" , GUID );
318  xml.writeAttribute( "description", description );
319  xml.writeAttribute( "ph" , QString::number( pH , 'f', 5 ) );
320  xml.writeAttribute( "density" , QString::number( density , 'f', 6 ) );
321  xml.writeAttribute( "viscosity" , QString::number( viscosity, 'f', 5 ) );
322  xml.writeAttribute( "compressibility",
323  QString::number( compressibility, 'e', 4 ) );
324  xml.writeAttribute( "manual" , US_Util::bool_string( manual ) );
325 
326  for ( int i = 0; i < component.size(); i++ )
327  {
328  xml.writeStartElement( "component" );
329  xml.writeAttribute( "id" , componentIDs[ i ] );
330  xml.writeAttribute( "concentration",
331  QString::number( concentration[ i ], 'f', 5 ) );
332  xml.writeEndElement(); // component
333  }
334 
335  xml.writeStartElement( "spectrum" );
336 
337  QList< double > keys = extinction.keys();
338 
339  for ( int i = 0; i < extinction.size(); i++ )
340  {
341  xml.writeStartElement( "extinction" );
342  double wavelength = keys[ i ];
343  double value = extinction[ wavelength ];
344  xml.writeAttribute( "wavelength", QString::number( wavelength, 'f', 1 ) );
345  xml.writeAttribute( "value" , QString::number( value, 'e', 4 ) );
346  xml.writeEndElement(); // extinction
347  }
348 
349  for ( int i = 0; i < refraction.size(); i++ )
350  {
351  xml.writeStartElement( "refraction" );
352  double wavelength = keys[ i ];
353  double value = refraction[ wavelength ];
354  xml.writeAttribute( "wavelength", QString::number( wavelength, 'f', 1 ) );
355  xml.writeAttribute( "value" , QString::number( value, 'e', 4 ) );
356  xml.writeEndElement(); // refraction
357  }
358 
359  for ( int i = 0; i < fluorescence.size(); i++ )
360  {
361  xml.writeStartElement( "fluorescence" );
362  double wavelength = keys[ i ];
363  double value = fluorescence[ wavelength ];
364  xml.writeAttribute( "wavelength", QString::number( wavelength, 'f', 1 ) );
365  xml.writeAttribute( "value" , QString::number( value, 'e', 4 ) );
366  xml.writeEndElement(); // fluorescence
367  }
368 
369  xml.writeEndElement(); // spectrum
370  xml.writeEndElement(); // buffer
371  xml.writeEndElement(); // US_Buffer
372  xml.writeEndDocument();
373 
374  return true;
375 }
376 
377 bool US_Buffer::readFromDB( US_DB2* db, const QString& bufID )
378 {
379  QStringList q( "get_buffer_info" );
380  q << bufID; // bufferID from list widget entry
381 
382  db->query( q );
383  if ( db->lastErrno() != 0 ) return false;
384 
385  db->next();
386 
387  bufferID = bufID;
388  GUID = db->value( 0 ).toString();
389  description = db->value( 1 ).toString();
390  compressibility = db->value( 2 ).toString().toDouble();
391  pH = db->value( 3 ).toString().toDouble();
392  viscosity = db->value( 4 ).toString().toDouble();
393  density = db->value( 5 ).toString().toDouble();
394  int manx = description.indexOf( " [M]" );
395  if ( manx > 0 )
396  {
397  manual = true;
398  description = description.left( manx ).simplified();
399  }
400  else
401  manual = US_Util::bool_flag( db->value( 6 ).toString() );
402 
403  component .clear();
404  componentIDs .clear();
405  concentration.clear();
406  q .clear();
407 
408  q << "get_buffer_components" << bufferID;
409 
410  db->query( q );
411  int status = db->lastErrno();
412  if ( status != US_DB2::OK && status != US_DB2::NOROWS )
413  {
414  qDebug() << "get_buffer_components error=" << status;
415  return false;
416  }
417 
418  while ( db->next() )
419  {
420  componentIDs << db->value( 0 ).toString();
421  concentration << db->value( 4 ).toString().toDouble();
422  }
423 
424  for ( int i = 0; i < componentIDs.size(); i++ )
425  {
427  bc.componentID = componentIDs[ i ];
428  bc.getInfoFromDB( db );
429  component << bc;
430  }
431 
432  // Get spectrum data
433  getSpectrum( db, "Refraction" );
434  getSpectrum( db, "Extinction" );
435  getSpectrum( db, "Fluorescence" );
436  return true;
437 }
438 
439 int US_Buffer::saveToDB( US_DB2* db, const QString private_buffer ) const
440 {
441  int idBuffer = 0;
442  QStringList q;
443  q << "get_bufferID"
444  << GUID;
445  db->query( q );
446 
447  int ncomp = component.size();
448  int status = db->lastErrno();
449  QString descrip = description;
450  int manx = descrip.indexOf( " [M]" );
451 
452  if ( manx > 0 )
453  descrip = descrip.left( manx ).simplified();
454 //qDebug() << "get_bufferID-stat" << status;
455 
456  if ( status != US_DB2::OK && status != US_DB2::NOROWS )
457  {
458  qDebug() << "get_bufferID error=" << status;
459  return -9;
460  }
461 
462  else if ( status == US_DB2::NOROWS )
463  { // There is no buffer with the given GUID, so create a new one
464  q.clear();
465  q << "new_buffer"
466  << GUID
467  << descrip
468  << QString::number( compressibility, 'e', 4 )
469  << QString::number( pH , 'f', 4 )
470  << QString::number( density , 'f', 6 )
471  << QString::number( viscosity , 'f', 5 )
473  << private_buffer // Private
474  << QString::number( US_Settings::us_inv_ID() );
475 
476  db->statusQuery( q );
477 //qDebug() << "new_buffer-stat" << db->lastErrno();
478 
479  if ( db->lastErrno() != US_DB2::OK )
480  {
481  qDebug() << "new_buffer error=" << db->lastErrno();
482  return -1;
483  }
484 
485  idBuffer = db->lastInsertID();
486 //qDebug() << "new_buffer-idBuffer" << idBuffer;
487  }
488 
489  else
490  { // The buffer exists, so update it
491  db->next(); // Get the ID of the existing buffer record
492  QString bufID = db->value( 0 ).toString();
493  idBuffer = bufID.toInt();
494 //qDebug() << "old_buffer-idBuffer" << idBuffer;
495  q.clear();
496  q << "update_buffer"
497  << bufID
498  << descrip
499  << QString::number( compressibility, 'e', 4 )
500  << QString::number( pH , 'f', 4 )
501  << QString::number( density , 'f', 6 )
502  << QString::number( viscosity , 'f', 5 )
504  << private_buffer; // Private
505 
506  db->statusQuery( q );
507 
508 //qDebug() << "update_stat" << db->lastErrno();
509  if ( db->lastErrno() != US_DB2::OK )
510  {
511  qDebug() << "update_buffer error=" << db->lastErrno();
512  return -2;
513  }
514 
515  // Delete any components, so any given are a new list
516  q.clear();
517  q << "delete_buffer_components" << bufID;
518  db->statusQuery( q );
519  status = db->lastErrno();
520 //qDebug() << "delete_buffer_components status=" << status << US_DB2::NOROWS;
521  if ( status != US_DB2::OK && status != US_DB2::NOROWS )
522  {
523  qDebug() << "delete_buffer_components error=" << db->lastErrno();
524  return -3;
525  }
526  }
527 
528  for ( int i = 0; i < ncomp; i++ )
529  {
530  q.clear();
531  q << "add_buffer_component"
532  << QString::number( idBuffer )
533  << component[ i ].componentID
534  << QString::number( concentration[ i ], 'f', 5 );
535  db->statusQuery( q );
536 //qDebug() << "add_buffer_components-status=" << db->lastErrno();
537 
538  if ( db->lastErrno() != US_DB2::OK )
539  {
540  qDebug() << "add_buffer_component i,error=" << i << db->lastErrno();
541  return -4;
542  }
543  }
544 
545  putSpectrum( db, "Extinction" );
546  putSpectrum( db, "Refraction" );
547  putSpectrum( db, "Fluorescence" );
548 
549  // Also write to to disk
550  bool newFile;
551  QString path = US_Settings::dataDir() + "/buffers";
552  QString filename = get_filename( path, GUID, newFile );
553  writeToDisk( filename );
554 
555  return idBuffer;
556 }
557 
558 
559 bool US_Buffer::readFromDisk( const QString& filename )
560 {
561  QFile file( filename );
562 
563  if ( ! file.open( QIODevice::ReadOnly | QIODevice::Text) )
564  {
565  qDebug() << "Cannot open file for reading: " << filename;
566  return false;
567  }
568 
569  QXmlStreamReader xml( &file );
570 
571  while ( ! xml.atEnd() )
572  {
573  xml.readNext();
574 
575  if ( xml.isStartElement() )
576  {
577  if ( xml.name() == "buffer" )
578  readBuffer( xml );
579  }
580  }
581 
582  file.close();
583  return true;
584 }
585 
587  const QString& path, const QString& guid, bool& newFile )
588 {
589  return
590  US_DataFiles::get_filename( path, guid, "B", "buffer", "guid", newFile );
591 }
592 
593 void US_Buffer::readBuffer( QXmlStreamReader& xml )
594 {
595  QXmlStreamAttributes a = xml.attributes();
596 
597  bufferID = a.value( "id" ).toString();
598  GUID = a.value( "guid" ).toString();
599  description = a.value( "description" ).toString();
600  compressibility = a.value( "compressibility" ).toString().toDouble();
601  pH = a.value( "ph" ).toString().toDouble();
602  density = a.value( "density" ).toString().toDouble();
603  viscosity = a.value( "viscosity" ).toString().toDouble();
604  manual = US_Util::bool_flag( a.value( "manual" ).toString() );
605 
606  concentration.clear();
607  componentIDs .clear();
608 
609  while ( ! xml.atEnd() )
610  {
611  if ( xml.isEndElement() && xml.name() == "buffer" ) break;
612 
613  if ( xml.isStartElement() && xml.name() == "component" )
614  {
615  QXmlStreamAttributes a = xml.attributes();
616  concentration << a.value( "concentration" ).toString().toDouble();
617  componentIDs << a.value( "id" ).toString();
618  }
619 
620  if ( xml.isStartElement() && xml.name() == "spectrum" )
621  readSpectrum( xml );
622 
623  xml.readNext();
624  }
625 }
626 
627 void US_Buffer::readSpectrum( QXmlStreamReader& xml )
628 {
629  while ( ! xml.atEnd() )
630  {
631  if ( xml.isEndElement() && xml.name() == "spectrum" ) break;
632 
633  if ( xml.isStartElement() && xml.name() == "extinction" )
634  {
635  QXmlStreamAttributes a = xml.attributes();
636  extinction[ a.value( "wavelength" ).toString().toDouble() ] =
637  a.value( "value" ).toString().toDouble();
638  }
639 
640  if ( xml.isStartElement() && xml.name() == "refraction" )
641  {
642  QXmlStreamAttributes a = xml.attributes();
643  refraction[ a.value( "wavelength" ).toString().toDouble() ] =
644  a.value( "value" ).toString().toDouble();
645  }
646 
647  if ( xml.isStartElement() && xml.name() == "fluorescence" )
648  {
649  QXmlStreamAttributes a = xml.attributes();
650  fluorescence[ a.value( "wavelength" ).toString().toDouble() ] =
651  a.value( "value" ).toString().toDouble();
652  }
653 
654  xml.readNext();
655  }
656 }
657 
658 void US_Buffer::compositeCoeffs( double* d_coeff, double* v_coeff )
659 {
660  int ncomp = component.size(); // Number of buffer components
661 
662  if ( ncomp == 0 )
663  return; // If 0, nothing to do
664 
665  // Pre-remove water value from components beyond first
666  d_coeff[ 0 ] = (double)( 1 - ncomp ) * DENS_20W;
667  v_coeff[ 0 ] = (double)( 1 - ncomp ) * VISC_20W;
668 
669  for ( int ii = 1; ii < 6; ii++ )
670  { // Initialize other coefficients to zero
671  d_coeff[ ii ] = 0.0;
672  v_coeff[ ii ] = 0.0;
673  }
674 
675  double sumc1 = 0.0;
676  double sumcr = 0.0;
677  double sumc2 = 0.0;
678  double sumc3 = 0.0;
679  double sumc4 = 0.0;
680 
681  for ( int ii = 0; ii < ncomp; ii++ )
682  { // Sum concentration and coefficient values
683  double c1 = concentration[ ii ]; // c ^ 1
684  double cr = sqrt( c1 ); // c ^ 0.5
685  double c2 = c1 * c1; // c ^ 2
686  double c3 = c2 * c1; // c ^ 3
687  double c4 = c3 * c1; // c ^ 4
688  sumc1 += c1; // Sum concentration terms
689  sumcr += cr;
690  sumc2 += c2;
691  sumc3 += c3;
692  sumc4 += c4;
693 
694  // Accumulate weighted coefficient terms
695  d_coeff[ 0 ] += component[ ii ].dens_coeff[ 0 ];
696  d_coeff[ 1 ] += component[ ii ].dens_coeff[ 1 ] * cr;
697  d_coeff[ 2 ] += component[ ii ].dens_coeff[ 2 ] * c1;
698  d_coeff[ 3 ] += component[ ii ].dens_coeff[ 3 ] * c2;
699  d_coeff[ 4 ] += component[ ii ].dens_coeff[ 4 ] * c3;
700  d_coeff[ 5 ] += component[ ii ].dens_coeff[ 5 ] * c4;
701 
702  v_coeff[ 0 ] += component[ ii ].visc_coeff[ 0 ];
703  v_coeff[ 1 ] += component[ ii ].visc_coeff[ 1 ] * cr;
704  v_coeff[ 2 ] += component[ ii ].visc_coeff[ 2 ] * c1;
705  v_coeff[ 3 ] += component[ ii ].visc_coeff[ 3 ] * c2;
706  v_coeff[ 4 ] += component[ ii ].visc_coeff[ 4 ] * c3;
707  v_coeff[ 5 ] += component[ ii ].visc_coeff[ 5 ] * c4;
708  }
709 
710  // Normalize coefficients and multiply by standard powers
711  v_coeff[ 1 ] *= ( 1.0e-3 / sumcr );
712  v_coeff[ 2 ] *= ( 1.0e-2 / sumc1 );
713  v_coeff[ 3 ] *= ( 1.0e-3 / sumc2 );
714  v_coeff[ 4 ] *= ( 1.0e-4 / sumc3 );
715  v_coeff[ 5 ] *= ( 1.0e-6 / sumc4 );
716 
717  d_coeff[ 1 ] *= ( 1.0e-3 / sumcr );
718  d_coeff[ 2 ] *= ( 1.0e-2 / sumc1 );
719  d_coeff[ 3 ] *= ( 1.0e-3 / sumc2 );
720  d_coeff[ 4 ] *= ( 1.0e-4 / sumc3 );
721  d_coeff[ 5 ] *= ( 1.0e-6 / sumc4 );
722 }
723 
724 void US_Buffer::dumpBuffer( void ) const
725 {
726  qDebug() << "person " << person;
727  qDebug() << "bufferID " << bufferID;
728  qDebug() << "GUID " << GUID;
729  qDebug() << "description " << description;
730  qDebug() << "compressibility" << compressibility;
731  qDebug() << "pH " << pH;
732  qDebug() << "density " << density;
733  qDebug() << "viscosity " << viscosity;
734  qDebug() << "extinction " << extinction;
735  qDebug() << "refraction " << refraction;
736  qDebug() << "fluorescence " << fluorescence;
737  qDebug() << "manual " << manual;
738  qDebug() << "Components " << component.size();
739  for ( int i = 0; i < component.size(); i++ )
740  {
741  qDebug() << component[ i ].name << concentration[ i ] << componentIDs[ i ];
742  }
743 };