Changeset 11015 for trunk/FACT++/src
- Timestamp:
- 06/13/11 18:05:57 (13 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Fits.cc
r10955 r11015 35 35 //! @param numDataBytes the number of bytes taken by the variable 36 36 // 37 void Fits::AddStandardColumn( Description& desc, stringdataFormat, void* dataPointer, long unsigned int numDataBytes)37 void Fits::AddStandardColumn(const Description& desc, const string &dataFormat, void* dataPointer, long unsigned int numDataBytes) 38 38 { 39 39 //check if entry already exist 40 for (vector<Description>:: iterator it=fStandardColDesc.begin(); it != fStandardColDesc.end(); it++)40 for (vector<Description>::const_iterator it=fStandardColDesc.begin(); it != fStandardColDesc.end(); it++) 41 41 if (it->name == desc.name) 42 42 return; … … 54 54 //! @param numDataBytes the number of bytes taken by the DIM data. 55 55 // 56 void Fits::InitDataColumns( vector<Description>desc, vector<string>& dataFormat, void* dataPointer, int numDataBytes)56 void Fits::InitDataColumns(const vector<Description> &desc, vector<string>& dataFormat, void* dataPointer, int numDataBytes) 57 57 {//we will copy this information here. It duplicates the data, which is not great, but it is the easiest way of doing it right now 58 58 if (desc.size() == dataFormat.size()) … … 101 101 { 102 102 ostringstream str; 103 str << " Could not open FITS file " << fileName << " reason: " << e.message();103 str << "Opening FITS file " << fileName << ": " << e.message(); 104 104 fMess->Error(str); 105 105 fFile = NULL; … … 129 129 } 130 130 //for (int i=static_cast<int>(fDataColDesc.size())-1;i>=0;i--) 131 for ( int i=0; i< static_cast<int>(fDataColDesc.size()); i++)131 for (unsigned int i=0; i<fDataColDesc.size(); i++) 132 132 { 133 133 if (fDataColDesc[i].name != "") … … 147 147 try 148 148 { 149 string factTableName = tableName;150 149 //first, let's check if the table already exist in the file 151 150 vector<string> tryToLoadName; 152 tryToLoadName.push_back(factTableName); 153 fFile->read(tryToLoadName); 151 tryToLoadName.push_back(tableName); 152 fFile->read(tryToLoadName); 153 154 154 const multimap< string, CCfits::ExtHDU * >& extMap = fFile->extension(); 155 if (extMap.find( factTableName) == extMap.end())155 if (extMap.find(tableName) == extMap.end()) 156 156 { 157 157 for (multimap<string, CCfits::ExtHDU*>::const_iterator it=extMap.begin(); it!= extMap.end(); it++) 158 158 fMess->Debug(it->first); 159 fTable = fFile->addTable( factTableName, 0, allNames, allDataTypes, allUnits);159 fTable = fFile->addTable(tableName, 0, allNames, allDataTypes, allUnits); 160 160 } 161 161 else 162 162 { 163 fTable = dynamic_cast<CCfits::Table*>(extMap.find( factTableName)->second);163 fTable = dynamic_cast<CCfits::Table*>(extMap.find(tableName)->second); 164 164 } 165 165 if (!fTable) 166 166 { 167 fMess->Error("T he table " + factTableName + " could not be created nor loaded. skipping it");167 fMess->Error("Table " + tableName + " could not be created nor loaded from "+fileName); 168 168 Close(); 169 169 return false; … … 177 177 if (!bTable) 178 178 { 179 fMess->Error("T he table " + factTableName + " could not be converted to a binary table. skipping");179 fMess->Error("Table " + tableName + " in "+fileName+" could not be converted to a binary table."); 180 180 Close(); 181 181 return false; … … 186 186 187 187 //double check that the data was indeed read from the disk. Go through the fTable instead as colName is empty (yes, it is !) 188 map<string, Column*> cMap = fTable->column(); 189 map<string, Column*>::iterator cMapIt; 190 191 for (cMapIt = cMap.begin(); cMapIt != cMap.end(); cMapIt++) 188 const map<string, Column*> cMap = fTable->column(); 189 190 for (map<string, Column*>::const_iterator cMapIt = cMap.begin(); cMapIt != cMap.end(); cMapIt++) 192 191 { 193 192 if (!cMapIt->second->isRead()) 194 193 { 195 fMess->Error(" Column " + cMapIt->first + "Could not be read back from the disk");194 fMess->Error("Reading column " + cMapIt->first + " back from "+fileName+" failed."); 196 195 Close(); 197 196 return false; … … 205 204 { 206 205 ostringstream str; 207 str << "Could not open or create FITS table " << tableName << " in file " << fileName << " reason: " << e.message();206 str << "Opening or creating table " << tableName << " in " << fileName << ": " << e.message(); 208 207 fMess->Error(str); 209 208 fTable = NULL; … … 226 225 //!@param a comment explaining the meaning of the key 227 226 template <typename T> 228 bool Fits::WriteSingleHeaderKey( string name, T value, stringcomment)227 bool Fits::WriteSingleHeaderKey(const string &name, const T &value, const string &comment) 229 228 { 230 229 try … … 249 248 if (!fTable) 250 249 return false; 251 string name; 252 string comment; 253 254 string stringValue; 250 251 string stringValue = Time().GetAsStr(); 252 stringValue[10]= 'T'; 255 253 256 254 if (!WriteSingleHeaderKey("EXTREL", 1.0f, "Release Number")) return false; … … 258 256 if (!WriteSingleHeaderKey("ORIGIN", "ISDC", "Institution that wrote the file")) return false; 259 257 if (!WriteSingleHeaderKey("CREATOR", "FACT++ DataLogger", "Program that wrote this file")) return false; 260 stringValue = Time().GetAsStr();261 stringValue[10]= 'T';262 258 if (!WriteSingleHeaderKey("DATE", stringValue, "File creation data")) return false; 263 259 if (!WriteSingleHeaderKey("TIMESYS", "TT", "Time frame system")) return false; … … 373 369 if (stat(fFileName.c_str(), &st)) 374 370 return 0; 375 else 376 377 } 371 372 return st.st_size; 373 } -
trunk/FACT++/src/Fits.h
r10955 r11015 88 88 89 89 ///Adds a column that exists in all FITS files 90 void AddStandardColumn( Description& desc, stringdataFormat, void* dataPointer, long unsigned int numDataBytes);90 void AddStandardColumn(const Description& desc, const string &dataFormat, void* dataPointer, long unsigned int numDataBytes); 91 91 92 92 ///Adds columns specific to the service being logged. 93 void InitDataColumns( vector<Description>desc, vector<string>& dataFormat, void* dataPointer, int numDataBytes);93 void InitDataColumns(const vector<Description> &desc, vector<string>& dataFormat, void* dataPointer, int numDataBytes); 94 94 95 95 ///Opens a FITS file … … 106 106 private: 107 107 template <typename T> 108 bool WriteSingleHeaderKey( string name, T value, stringcomment);108 bool WriteSingleHeaderKey(const string &name, const T &value, const string &comment); 109 109 110 110 };//Fits
Note:
See TracChangeset
for help on using the changeset viewer.