11 #include <QDomDocument>
16 #define round(x) floor( (x) + 0.5 )
29 QVector< US_mwlRamp::RampRawData* >& rawConvertedData,
30 QList< TripleInfo >& all_chaninfo,
38 if ( rawConvertedData[ 0 ]->intarray.empty() )
46 QStringList rmvfilt(
"*.ramp" );
47 QStringList rmvfiles = d.entryList( rmvfilt, QDir::Files, QDir::Name );
48 for (
int ii = 0; ii < rmvfiles.size(); ii++ )
49 if ( ! d.remove( rmvfiles[ ii ] ) )
56 for (
int i = 0; i < all_chaninfo.size(); i++ )
58 if ( all_chaninfo[ i ].excluded )
continue;
60 QString triple = all_chaninfo[ i ].tripleDesc;
61 QStringList parts = triple.split(
" / ");
63 QString cell = parts[ 0 ];
64 QString channel = parts[ 1 ];
67 filename = runID +
"."
74 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}$" );
75 qDebug()<<
"_______________________________________________________________________";
76 qDebug()<<
"all_chaninfo[ i ].solution.saveStatus"<<all_chaninfo[ i ].solution.saveStatus;
78 qDebug()<<
"!rx.exactMatch( all_chaninfo[ i ].solution.solutionGUID "<<!rx.exactMatch( all_chaninfo[ i ].solution.solutionGUID) ;
81 ( ! rx.exactMatch( all_chaninfo[ i ].solution.solutionGUID ) ) )
84 all_chaninfo[ i ].solution.solutionDesc =
"New Solution";
88 all_chaninfo[ i ].solution.saveToDisk();
91 all_chaninfo[ i ].tripleFilename = filename;
107 if ( ! ff.open( QIODevice::WriteOnly ) )
return CANTOPEN;
108 QDataStream ds( &ff );
111 quint32 crc = 0xffffffffUL;
114 char magic[ 5 ] =
"UCDA";
115 write( ds, magic, 4, crc );
120 write( ds, fmt, 2, crc );
127 char c = data.
cell.toAscii();
129 write( ds, (
const char*) &ic, 1, crc );
132 c = data.
chan.toAscii();
133 write( ds, (
const char*)&c, 1, crc );
140 memset( desc,
'\0',
sizeof desc );
143 strncpy( desc, dd.data(),
sizeof desc );
144 write( ds, desc,
sizeof desc, crc );
168 qToLittleEndian( uf.u, ui.u );
169 write( ds, ui.c, 4, crc );
171 uf.f = (float) data.
radius;
172 qToLittleEndian( uf.u, ui.u );
173 write( ds, ui.c, 4, crc );
176 qToLittleEndian( uf.u, ui.u );
177 write( ds, ui.c, 4, crc );
179 uf.f = (float) data.
bottom;
180 qToLittleEndian( uf.u, ui.u );
181 write( ds, ui.c, 4, crc );
183 double n = data.
rpm.size();
185 qToLittleEndian( uf.u, ui.u );
186 write( ds, ui.c, 4, crc );
189 for (
int i=0; i<(int)n; i++)
191 uf.f = (float) data.
rpm.at(i);
192 qToLittleEndian( uf.u, ui.u );
193 write( ds, ui.c, 4, crc );
196 for (
int i=0; i<(int)n; i++)
198 uf.f = (float) data.
time.at(i);
199 qToLittleEndian( uf.u, ui.u );
200 write( ds, ui.c, 4, crc );
203 for (
int i=0; i<(int)n; i++)
205 uf.f = (float) data.
w2t.at(i);
206 qToLittleEndian( uf.u, ui.u );
207 write( ds, ui.c, 4, crc );
212 qToLittleEndian( uf.u, ui.u );
213 write( ds, ui.c, 4, crc );
217 for (
int i=0; i<(int)n_wl; i++)
219 wl_double = (double) data.
wl_array.at(i);
220 uf.f = (float) wl_double;
221 qToLittleEndian( uf.u, ui.u );
222 write( ds, ui.c, 4, crc );
226 for (
int lambda=0; lambda<n_wl; lambda++)
229 for (
int i=0; i<n; i++)
231 uf.f = (float) data.
intarray[lambda].at(i);
232 qToLittleEndian( uf.u, ui.u );
233 write( ds, ui.c, 4, crc );
279 QVector< US_mwlRamp::RampRawData >& rawConvertedData,
280 QList< TripleInfo >& all_chaninfo,
284 rawConvertedData.clear();
286 QStringList nameFilters = QStringList(
"*.ramp" );
290 QStringList files = d.entryList( nameFilters,
291 QDir::Files | QDir::Readable, QDir::Name );
293 if ( files.size() == 0 )
297 QStringList part = files[ 0 ].split(
"." );
301 all_chaninfo.clear();
302 for (
int i = 0; i < files.size(); i++ )
305 part = files[ i ].split(
"." );
322 foreach ( file, files )
324 QString filename = dir + file;
331 rawConvertedData << data;
342 if ( ! ff.open( QIODevice::ReadOnly ) )
return CANTOPEN;
343 QDataStream ds( &ff );
346 quint32 crc = 0xffffffffUL;
352 read( ds, magic, 4, crc );
354 if ( !strncmp( magic,
"UCDA", 4 ) != 0 ) qDebug() <<
"readmagic"<<magic;
357 unsigned char ver[ 2 ];
358 read( ds, (
char*) ver, 2, crc );
359 quint32 version = ( ( ver[ 0 ] & 0x0f ) << 8 ) | ( ver[ 1 ] & 0x0f );
361 if ( version !=
format_version ) qDebug() <<
"this ramp data version is bad!"<<version;
382 read( ds, cell.c, 1, crc );
383 data.
cell = (qFromLittleEndian( cell.i ))+
'0';
397 read( ds, chan.c, 1, crc );
398 data.
chan = qFromLittleEndian( chan.i );
406 read( ds, desc, 240, crc );
432 read( ds, u1.c, 4, crc );
433 u2.I = qFromLittleEndian( u1.I );
436 read( ds, u1.c, 4, crc );
437 u2.I = qFromLittleEndian( u1.I );
440 read( ds, u1.c, 4, crc );
441 u2.I = qFromLittleEndian( u1.I );
444 read( ds, u1.c, 4, crc );
445 u2.I = qFromLittleEndian( u1.I );
449 read( ds, u1.c, 4, crc );
450 u2.I = qFromLittleEndian( u1.I );
457 for (
int i=0; i<n; i++)
459 read( ds, u1.c, 4, crc );
460 u2.I = qFromLittleEndian( u1.I );
461 data.
rpm.append( u2.f);
466 for (
int i=0; i<n; i++)
468 read( ds, u1.c, 4, crc );
469 u2.I = qFromLittleEndian( u1.I );
470 data.
time.append( u2.f);
475 for (
int i=0; i<n; i++)
477 read( ds, u1.c, 4, crc );
478 u2.I = qFromLittleEndian( u1.I );
479 data.
w2t.append( u2.f);
480 qDebug()<<
"w2t"<<data.
w2t.at(i);
484 read( ds, u1.c, 4, crc );
485 u2.I = qFromLittleEndian( u1.I );
488 int n_wl = (int)dn_wl;
493 for (
int i=0; i<n_wl; i++)
495 read( ds, u1.c, 4, crc );
496 u2.I = qFromLittleEndian( u1.I );
498 data.
wl_array.append( (
int)wl_double);
501 qDebug()<<
"size_wl_arr"<<data.
wl_array.size();
504 for (
int lambda=0; lambda<n_wl; lambda++)
506 for (
int i=0; i<n; i++)
508 read( ds, u1.c, 4, crc );
509 u2.I = qFromLittleEndian( u1.I );
510 data.
intarray[lambda].append( u2.f);
736 tripleDesc = QString(
"" );
737 description = QString(
"" );
740 memset( tripleGUID, 0, 16 );
741 tripleFilename = QString(
"" );
749 qDebug() <<
"tripleID = " << tripleID <<
'\n'
750 <<
"tripleDesc = " << tripleDesc <<
'\n'
751 <<
"description = " << description <<
'\n'
752 <<
"centerpiece = " << centerpiece <<
'\n'
753 <<
"tripleGUID = " << QString( uuidc ) <<
'\n'
754 <<
"tripleFilename = " << tripleFilename <<
'\n'
755 <<
"solutionID = " << QString::number( solution.solutionID ) <<
'\n'
756 <<
"solutionGUID = " << solution.solutionGUID <<
'\n'
757 <<
"solutionDesc = " << solution.solutionDesc;
759 if ( excluded ) qDebug() <<
"excluded";
764 ds.writeRawData( c, len );
770 ds.readRawData( cc, len );