45 return "SgDbhPhysicalRecord";
127 int hdd1, edd1, hd2, ed2;
136 QString().sprintf(
"DBH input error: format violation: HDD1!=2 (HDD1=%d)", hdd1));
137 record.
isOK_ =
false;
140 s >> (qint16 &)dd1 >> (qint32 &)edd1;
145 QString().sprintf(
"DBH input error: format violation: EDD1!=HDD1 (EDD1=%d, HDD1=%d)",
154 QString().sprintf(
"DBH input error: format violation: HD2!=DD1+DD1 (HD2=%d, DD1=%d)",
160 int parsedBytes = record.
readLR(s);
161 if (parsedBytes>record.
length_)
165 QString().sprintf(
"DBH input error: number of read bytes (%d) exceed record length (%d)",
167 record.
isOK_ =
false;
171 for (
int j=parsedBytes; j<record.
length_; j++)
179 QString().sprintf(
"DBH input error: format violation: ED2!=HD2 (ED2=%d, HD2=%d)",
181 record.
isOK_ =
false;
191 int hdd1, edd1, hd2, ed2;
196 hd2 = ed2 = record.
length();
197 dd1 = (short) record.
length()/2;
198 s << (
const qint32 &)hdd1 << (
const qint16 &)dd1 << (
const qint32 &)edd1 << (
const qint32 &)hd2;
199 int writtenBytes = record.
writeLR(s);
200 if (writtenBytes<record.
length())
201 for (
int j=writtenBytes; j<record.
length(); j++)
222 return "SgDbhDataRecordString";
237 int l = 2*descriptor->
dim1() + 1;
238 char *c =
new char[l];
240 + descriptor->
dim1()*dim2 + descriptor->
dim1()*descriptor->
dim2()*dim3);
241 for (
int i=0; i<l-1; i++)
244 QString Ret = (
const char*)c;
253 int dim2,
int dim3,
const QString& str)
255 int l = 2*descriptor->
dim1();
257 + descriptor->
dim1()*dim2 + descriptor->
dim1()*descriptor->
dim2()*dim3);
258 int i, n2copy = std::min(l,str.length());
259 for (i=0; i<n2copy; i++)
260 *(p+i) = str.at(i).toLatin1();
276 int i, n2copy = std::min(
length(),
text_.length());
277 for (i=0; i<n2copy; i++)
278 *(p+i) =
text_.at(i).toLatin1();
347 return base_&&-1<i&&i<num_ ? *(base_+i) : (C)0;
356 return (dim1<d->dim1() && dim2<d->dim2() && dim3<d->dim3() && dim1>=0 && dim2>=0 && dim3>=0) ?
378 memcpy((
void*)base_, (
void*)rec.
base_,
sizeof(C)*num_);
389 if (i<0 || i>=d->
dim1())
391 + QString().sprintf(
": access: the first index <%d> out of range [0:%d]", i, d->
dim1()));
392 if (j<0 || j>=d->
dim2())
394 + QString().sprintf(
": access: the second index <%d> out of range [0:%d]", j, d->
dim2()));
395 if (k<0 || k>=d->
dim3())
397 + QString().sprintf(
": access: the third index <%d> out of range [0:%d]", k, d->
dim3()));
409 base_ =
new C[(num_=length_/
sizeof(C))];
411 for(
int i=0; i<num_; i++,p++)
422 for(
int i=0; i<num_; i++,p++)
435 base_ =
new C[(num_=length_/
sizeof(C))];
436 memset((
void*)base_, 0, num_*
sizeof(C));
442 return "SgDbhDataRecord<C>";
463 return (
isOK_=
false);
483 int nYear, nMonth, nDay, nHour, nMin;
491 epoch_[4] = (short)round(dSec);
499 short p8, p9, p10, p11;
510 >> (qint16 &)p8 >> (qint16 &)p9 >> (qint16 &)p10 >> (qint16 &)p11;
528 << (qint16)0 << (qint16)0 << (qint16)0 << (qint16)0;
569 for (
int i=0; i<6; i++)
570 semiName_[i] = semiName.at(i).toLatin1();
578 short p5, p6, p7, p8;
594 >> (qint16 &)p5 >> (qint16 &)p6 >> (qint16 &)p7 >> (qint16 &)p8;
608 << (qint16)0 << (qint16)0 << (qint16)0 << (qint16)0;
628 s <<
"TC record: TOC Type: " <<
tocType_
648 >> (qint16 &)
pRest[8]
656 s >> (qint8 &)c[0] >> (qint8 &)c[1];
657 if (c[0]==(
unsigned char)7 && c[1]==(
unsigned char)208)
664 QString().sprintf(
": format violation: c[0]!=7 || c[1]!=208 (%d:%d)", c[0], c[1]));
679 << (
const qint16 &)
pRest[0] << (
const qint16 &)
pRest[1] << (
const qint16 &)
pRest[2]
680 << (
const qint16 &)
pRest[3] << (
const qint16 &)
pRest[4] << (
const qint16 &)
pRest[5]
681 << (
const qint16 &)
pRest[6] << (
const qint16 &)
pRest[7] << (
const qint16 &)
pRest[8];
686 s << (
const qint8 &)7 << (
const qint8 &)208;
715 s <<
"TE record: TE block number: " <<
teBlockNum_ <<
"; number of descriptors: "
718 <<
" (bytes)" << endl
720 <<
" R8:" <<
r8Num_ << endl;
791 << (
const qint16 &)
pRest_[0] << (
const qint16 &)
pRest_[1] << (
const qint16 &)
pRest_[2]
792 << (
const qint16 &)
pRest_[3] << (
const qint16 &)
pRest_[4] << (
const qint16 &)
pRest_[5]
793 << (
const qint16 &)
pRest_[6] << (
const qint16 &)
pRest_[7] << (
const qint16 &)
pRest_[8];
803 s <<
"DR record (length=" <<
length() <<
"): TC#: " <<
tcNo_ <<
"; NumOf TE Blocks: "
805 <<
", rest part: [" <<
pRest_[0] <<
":" <<
pRest_[1] <<
":"
826 short p5=0, p6=0, p7=0;
832 >> (qint16 &)p5 >> (qint16 &)p6 >> (qint16 &)p7
834 if (p5!=0 || p6!=0 || p7!=0)
836 QString().sprintf(
": surprise, non-null unused data (%d:%d:%d)", p5, p6, p7));
863 << (
const qint16 &)0 << (
const qint16 &)0 << (
const qint16 &)0
865 << (
const qint16 &)
pRest_[0] << (
const qint16 &)
pRest_[1];
881 s <<
"DE record (length=" <<
length() <<
")";
883 s <<
": TE#: " <<
teNo_
888 s <<
"; this is a Z3 record, number of phys.records above: " <<
numOfPhRecs_ << endl;
890 s <<
", rest part: [" <<
pRest_[0] <<
":" <<
pRest_[1] <<
"]" << endl;
924 s <<
"== Start Block dump: ==" << endl
929 <<
"Experiment description: " <<
expDescript().simplified() << endl
930 <<
"Session ID : " <<
sessionID() << endl
931 <<
"Version : " <<
version() << endl
932 <<
"Previous Database name: " <<
prevDb() << endl
934 <<
"== End of dump ==" << endl;
948 prevRec_.
setText(
"$" + str.left(9) + str.right(2) +
"DBH880930 GSFC GNU/Linux");
963 str.replace(8, 1, c);
967 str.replace(9, 1, c);
971 str.replace(8, 1, c);
975 str.replace(9, 1, c);
1006 int nYear, nMonth, nDay, nHour, nMin;
1010 currentEpochRecord[0] = (short)nYear;
1012 currentEpochRecord[2] = (short)nHour;
1013 currentEpochRecord[3] = (short)nMin;
1014 currentEpochRecord[4] = (short)round(dSec);
1057 int version,
const SgMJD& t)
1078 QString().sprintf(
"SgDbhStream: corrupted DBH file: wrong history string length for "
1116 const char *sTypes[] = {
"R8",
"I2",
"A2",
"D8",
"J4",
"UN"};
1118 s <<
"List of descriptors (=format) dump (Offsets are in sizeof(Par)):" << endl
1119 <<
"---- -------- --- --- --- --- ---- -- --------------------------------" << endl
1120 <<
" Num Abbrev. D1 D2 D3 Ver Offs Tp Description" << endl
1121 <<
"---- -------- --- --- --- --- ---- -- --------------------------------" << endl;
1125 str.sprintf(
"%3d. %8s [%3d,%3d,%3d] %3d %4d %2s %32s",
1126 i, qPrintable(descriptor->
getLCode()),
1127 descriptor->
dim1(), descriptor->
dim2(), descriptor->
dim3(),
1132 s <<
"------------------------------------------------------------------------" << endl;
1185 QHash<int, SgDbhPhysicalRecord*>::const_iterator j;
1225 ": SgDbhStream: operator=(): Wrong type of data record");
1265 s.readRawData(tmps, 8);
1267 descriptor->
lCode_ = (
const char*)tmps;
1269 >> (qint16 &)descriptor->
dim1_
1270 >> (qint16 &)descriptor->
dim2_
1271 >> (qint16 &)descriptor->
dim3_;
1285 s.readRawData(tmps, 32);
1299 for (
int dIdx=0; dIdx<num; dIdx++)
1302 for (
int i=0; i<8; i++)
1303 tmps[i] = descriptor->
lCode_.at(i).toLatin1();
1304 s.writeRawData(tmps, 8);
1306 << (
const qint16 &)descriptor->
dim1_
1307 << (
const qint16 &)descriptor->
dim2_
1308 << (
const qint16 &)descriptor->
dim3_;
1320 for (
int dIdx=0; dIdx<num; dIdx++)
1323 int n2write = std::min(descriptor->
description_.size(), 32), i;
1324 for (i=0; i<n2write; i++)
1328 s.writeRawData(tmps, 32);
1339 s <<
"Block length: " <<
calcDataSize() <<
" (bytes)" << endl;
1342 s <<
"== End of TE Block dump" << endl;
1355 if (descriptor->
type()==type)
1356 numOfData += descriptor->
dim1()*descriptor->
dim2()*descriptor->
dim3();
1375 if (descriptor->
getLCode()==
"I-FILLER")
1377 else if (descriptor->
getLCode()==
"A-FILLER")
1379 else if (descriptor->
getLCode()==
"D-FILLER")
1381 else if (descriptor->
getLCode()==
"J-FILLER")
1401 switch (descriptor->
type())
1404 sizeOfType =
sizeof(double);
1407 sizeOfType =
sizeof(short);
1410 sizeOfType = 2*
sizeof(char);
1413 sizeOfType =
sizeof(double);
1416 sizeOfType =
sizeof(int);
1423 dataSize += descriptor->
dim1()*descriptor->
dim2()*descriptor->
dim3()*sizeOfType;
1471 s <<
"== TC[" <<
tocType() <<
"] Block dump: ==" << endl;
1492 for (
int teCount=0; teCount<tcBlock.
listOfTeBlocks_.size(); teCount++)
1501 if (descriptor->
getLCode()!=
"R-FILLER" &&
1502 descriptor->
getLCode()!=
"I-FILLER" &&
1503 descriptor->
getLCode()!=
"A-FILLER" &&
1504 descriptor->
getLCode()!=
"D-FILLER" &&
1505 descriptor->
getLCode()!=
"J-FILLER")
1563 while (!listOfDataBlocks->isEmpty())
1564 delete listOfDataBlocks->takeFirst();
1566 delete listOfDataBlocks;
1578 ": listOfTcsData_.size()>tocNumber (need to replace QList with QHash)");
1583 for (
int teCount=0; teCount<tcBlock.
listOfTeBlocks()->size(); teCount++)
1587 listOfDataBlocks->append(dataBlock);
1609 ": properRecord(): called while the format is not ready");
1615 ": properRecord(): argument is NULL");
1621 QString().sprintf(
": properRecord(): the descriptor [%s] aka \"%s\", is from other TOC, %d;"
1622 " current TOC is %d", qPrintable(descriptor->
getLCode()),
1630 QString().sprintf(
": properRecord(): current TC block is NULL, TC# %d",
currentTcNumber()));
1646 short tcCount, teCount;
1654 for (teCount=0; teCount<tcBlock->
listOfTeBlocks()->size(); teCount++)
1665 if (descriptor->
getLCode()==
"R-FILLER")
1671 else if (descriptor->
getLCode()==
"I-FILLER")
1677 else if (descriptor->
getLCode()==
"A-FILLER")
1683 else if (descriptor->
getLCode()==
"D-FILLER")
1689 else if (descriptor->
getLCode()==
"J-FILLER")
1699 QString().sprintf(
": postRead(): descriptor [%s] already in the hash",
1700 qPrintable(descriptor->
getLCode())));
1703 descriptor->
setNTc(tcCount);
1704 descriptor->
setNTe(teCount);
1705 offset += descriptor->
dim1()*descriptor->
dim2()*descriptor->
dim3();
1711 ": postRead(): the order of records is not parsed correctly");
1715 ": postRead(): some data records are missed");
1719 ": postRead(): the order of records is parsed correctly");
1723 ": postRead(): too many records");
1758 ": getBlock: error reading DR record");
1767 ": getBlock: error reading DE record");
1770 if (DE.isCorrectPrefix() &&
isOK_)
1784 ": getBlock: error reading data record");
1793 *
dumpStream_ <<
"== TE[" << i <<
"] Data Block dump: ==" << endl;
1794 *
dumpStream_ <<
"The sizes of data records are:" << endl;
1806 << descriptor->
dim1() <<
"," << descriptor->
dim2() <<
","
1807 << descriptor->
dim3() <<
"] =" << endl <<
"(" << endl;
1808 for (
int li=0; li<descriptor->
dim3(); li++)
1811 for (
int lj=0; lj<descriptor->
dim2(); lj++)
1820 for (
int lk=0; lk<descriptor->
dim1(); lk++)
1822 switch(descriptor->
type())
1850 QString().sprintf(
": getBlock: can't find record for [%s] descriptor",
1851 qPrintable(descriptor->
getLCode())));
1877 if (!tcBlock->isLast() && (F.
isOK_ = F.
isOK_ && tcBlock->isOk()))
1881 }
while (tcBlock && !tcBlock->
isLast() && F.
isOK_);
QHash< int, SgDbhPhysicalRecord * > * recordByType()
QList< SgDbhPhysicalRecord * > * listOfRecords()
QList< SgDbhPhysicalRecord * > listOfRecords_
QHash< int, SgDbhPhysicalRecord * > recordByType_
QString className() const
SgDbhDataBlock & operator=(const SgDbhDataBlock &)
virtual SgDbhDataRecordString & operator=(const SgDbhDataRecordString &rec)
void setText(const QString &text)
const QString & getText() const
virtual int readLR(SgDbhStream &s)
static const QString className()
virtual QString getValue(SgDbhDatumDescriptor *, int dim2, int dim3)
virtual ~SgDbhDataRecordString()
void setValue(SgDbhDatumDescriptor *, int dim2, int dim3, const QString &)
virtual C & access(SgDbhDatumDescriptor *descriptor, int d1, int d2, int d3)
virtual C at(int i) const
virtual int readLR(SgDbhStream &s)
virtual C & operator[](int i)
virtual void reSize(int length)
virtual QString className() const
virtual SgDbhDataRecord< C > & operator=(const SgDbhDataRecord< C > &rec)
virtual C value(SgDbhDatumDescriptor *descriptor, int d1, int d2, int d3)
virtual int writeLR(SgDbhStream &s) const
short getModifiedAtVersion() const
const QString & getLCode() const
const QString & getDescription() const
void setOffset(int offset)
void setEvent(const QString &, const QString &, int, const SgMJD &)
SgDbhDataRecordString record3_
void setEpoch(const SgMJD &t)
SgDbhServiceRecordHS2 record2_
void dump(QTextStream &s) const
void setText(const QString &text)
void setVersion(int version)
SgDbhServiceRecordHS1 record1_
SgDbhListOfDescriptors & operator=(const SgDbhListOfDescriptors &)
QList< SgDbhDatumDescriptor * > listOfDescriptors_
QList< SgDbhDatumDescriptor * > * listOfDescriptors()
void dump(QTextStream &) const
void saveDataBlocksFromTcBlock(int TocNumber, SgDbhTcBlock &tcBlock)
QString className() const
QList< QList< SgDbhDataBlock * > * > listOfTcsData_
virtual int readLR(SgDbhStream &s)
static const QString className()
virtual int writeLR(SgDbhStream &s) const
virtual SgDbhPhysicalRecord & operator=(const SgDbhPhysicalRecord &)
virtual void reSize(int length)
virtual ~SgDbhPhysicalRecord()
void dump(QTextStream &s) const
virtual int writeLR(SgDbhStream &s) const
virtual int readLR(SgDbhStream &)
virtual QString className() const
virtual bool isAltered() const
virtual int readLR(SgDbhStream &s)
virtual int writeLR(SgDbhStream &s) const
void dump(QTextStream &s) const
void setLengthOfHistoryString(int length)
int getLengthOfHistoryString() const
SgMJD getHistoryEpoch() const
short lengthOfHistoryString_
int getVersionNumber() const
virtual bool isAltered() const
virtual int writeLR(SgDbhStream &s) const
void setHistoryEpoch(const SgMJD &)
virtual int readLR(SgDbhStream &s)
short installationNumber_
virtual int readLR(SgDbhStream &s)
virtual int writeLR(SgDbhStream &s) const
void setSemiName(const QString &)
virtual bool isAltered() const
virtual QString className() const
virtual int writeLR(SgDbhStream &s) const
virtual int readLR(SgDbhStream &)
void dump(QTextStream &s) const
short numTeBlocks() const
short numberOfDescriptors_
void dump(QTextStream &s) const
virtual int writeLR(SgDbhStream &s) const
virtual int readLR(SgDbhStream &)
virtual int writeLR(SgDbhStream &s) const
bool isCorrectPrefix() const
void setPrefix(const char prefix[2])
virtual bool isAltered() const
bool isPrefixParsed(SgDbhStream &)
void rotateVersion(int newVersion, const QString &newFileName)
SgDbhDataRecord< short > epochRec_
const QString & prevDescript() const
const QString & prevDb() const
void dump(QTextStream &) const
void alternateCode(const QString &)
SgDbhDataRecord< short > versionRec_
SgDbhDataRecordString prevDbRec_
SgDbhDataRecordString expDescriptRec_
SgDbhDataRecordString prevRec_
const QString & expDescript() const
const QString & sessionID() const
SgDbhDataRecordString dbNameRec_
SgDbhDataRecordString sessIDRec_
QList< SgDbhTeBlock * > * listOfTeBlocks()
QHash< QString, SgDbhDatumDescriptor * > * descriptorByLCode()
QList< SgDbhTeBlock * > listOfTeBlocks_
SgDbhServiceRecordTc recTc_
QHash< QString, SgDbhDatumDescriptor * > descriptorByLCode_
void dump(QTextStream &s) const
SgDbhTcBlock & operator=(const SgDbhTcBlock &)
int readRecordP3(SgDbhStream &)
SgDbhServiceRecordP3 recP3_
int writeRecordP3(SgDbhStream &) const
SgDbhServiceRecordP4 recP4_
int readRecordP4(SgDbhStream &)
void adjustServiceRecords()
void dump(QTextStream &) const
SgDbhTeBlock & operator=(const SgDbhTeBlock &)
int writeRecordP4(SgDbhStream &) const
int calculateNumOfData(SgDbhDatumDescriptor::Type type) const
SgDbhServiceRecordTe recTe_
virtual void write(LogLevel, quint32, const QString &, bool=false)
QString toString(Format format=F_Verbose) const
int calcDayOfYear() const
static SgMJD currentMJD()
static void MJD_reverse(int date, double time, int &nYear, int &nMonth, int &nDay, int &nHour, int &nMin, double &dSec)