FACT++  1.0
int FitsLoader::DoDumpPlease ( const Event )
private

Perform the dumping, based on the current dump list.

Perform the actual dump, based on the current parameters.

Definition at line 527 of file fitsloader.cc.

References CalculateBufferSize(), MessageImp::Error(), fFile, fFileOut, fTable, StateMachineImp::GetCurrentState(), i, size, str, and writeValuesFromFits().

Referenced by FitsLoader().

528 {
529  fTable->makeThisCurrent();
530  vector<int> offsets = CalculateBufferSize();
531  int size = offsets[offsets.size()-1];
532  offsets.pop_back();
533  unsigned char* fitsBuffer = new unsigned char[size];
534 
535  ofstream targetFile(fFileOut);
536  int status = 0;
537 
538  for (int i=1;i<=fTable->rows(); i++)
539  {
540  fits_read_tblbytes(fFile->fitsPointer(), i, 1, size, fitsBuffer, &status);
541  if (status)
542  {
543  ostringstream str;
544  str << "An error occurred while reading fits row #" << i << " error code: " << status;
545  Error(str);
546  str.str("");
547  for (unsigned int j=0;j<offsets.size(); j++)
548  str << offsets[j] << " ";
549  Error(str);
550  }
551  writeValuesFromFits(offsets, targetFile, fitsBuffer);
552  }
553  delete[] fitsBuffer;
554  return GetCurrentState();
555 }
int GetCurrentState() const
return the current state of the machine
void writeValuesFromFits(vector< int > &offsets, ofstream &targetFile, unsigned char *fitsBuffer)
Write a single row of the selected data.
Definition: fitsloader.cc:164
int i
Definition: db_dim_client.c:21
char str[80]
Definition: test_client.c:7
string fFileOut
Name of the output file.
Definition: fitsloader.cc:80
CCfits::FITS * fFile
FITS pointer.
Definition: fitsloader.cc:74
int Error(const std::string &str)
Definition: MessageImp.h:49
int size
Definition: db_dim_server.c:17
CCfits::Table * fTable
Table pointer.
Definition: fitsloader.cc:76
vector< int > CalculateBufferSize()
Calculate the buffer size required to read a row of the fits table, as well as the offsets to each co...
Definition: fitsloader.cc:274

+ Here is the call graph for this function:

+ Here is the caller graph for this function: