Changeset 10955 for trunk/FACT++/src/Fits.cc
- Timestamp:
- 06/09/11 17:13:03 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Fits.cc
r10947 r10955 84 84 //! @param runNumber the runNumber for which this file is opened. 0 means nightly file. 85 85 // 86 voidFits::Open(const string& fileName, const string& tableName, FITS* file, int* fitsCounter, MessageImp* out, int runNumber)86 bool Fits::Open(const string& fileName, const string& tableName, FITS* file, int* fitsCounter, MessageImp* out, int runNumber) 87 87 { 88 88 // if (fMess) … … 104 104 fMess->Error(str); 105 105 fFile = NULL; 106 return ;106 return false; 107 107 } 108 108 fOwner = true; … … 166 166 { 167 167 fMess->Error("The table " + factTableName + " could not be created nor loaded. skipping it"); 168 return; 168 Close(); 169 return false; 169 170 } 170 171 fTable->makeThisCurrent(); … … 177 178 { 178 179 fMess->Error("The table " + factTableName + " could not be converted to a binary table. skipping"); 179 return; 180 Close(); 181 return false; 180 182 } 181 183 //read the table binary data. … … 192 194 { 193 195 fMess->Error("Column " + cMapIt->first + "Could not be read back from the disk"); 194 return; 196 Close(); 197 return false; 195 198 } 196 199 } … … 205 208 fMess->Error(str); 206 209 fTable = NULL; 210 Close(); 211 return false; 207 212 } 208 213 … … 210 215 fRefMjD = 0;//* static_cast<double*>(fStandardPointers[0]); 211 216 if (!updating) 212 WriteHeaderKeys(); 217 return WriteHeaderKeys(); 218 219 return true; 213 220 } 214 221 // -------------------------------------------------------------------------- … … 219 226 //!@param a comment explaining the meaning of the key 220 227 template <typename T> 221 voidFits::WriteSingleHeaderKey(string name, T value, string comment)228 bool Fits::WriteSingleHeaderKey(string name, T value, string comment) 222 229 { 223 230 try … … 230 237 str << "Could not add header keys in file " << fFileName << " reason: " << e.message(); 231 238 fMess->Error(str); 232 } 239 return false; 240 } 241 return true; 233 242 } 234 243 // -------------------------------------------------------------------------- … … 236 245 //! This writes the standard header 237 246 // 238 voidFits::WriteHeaderKeys()247 bool Fits::WriteHeaderKeys() 239 248 { 240 249 if (!fTable) 241 return ;250 return false; 242 251 string name; 243 252 string comment; … … 245 254 string stringValue; 246 255 247 WriteSingleHeaderKey("EXTREL", 1.0f, "Release Number");248 WriteSingleHeaderKey("TELESCOP", "FACT", "Telescope that acquired this data");249 WriteSingleHeaderKey("ORIGIN", "ISDC", "Institution that wrote the file");250 WriteSingleHeaderKey("CREATOR", "FACT++ DataLogger", "Program that wrote this file");256 if (!WriteSingleHeaderKey("EXTREL", 1.0f, "Release Number")) return false; 257 if (!WriteSingleHeaderKey("TELESCOP", "FACT", "Telescope that acquired this data")) return false; 258 if (!WriteSingleHeaderKey("ORIGIN", "ISDC", "Institution that wrote the file")) return false; 259 if (!WriteSingleHeaderKey("CREATOR", "FACT++ DataLogger", "Program that wrote this file")) return false; 251 260 stringValue = Time().GetAsStr(); 252 261 stringValue[10]= 'T'; 253 WriteSingleHeaderKey("DATE", stringValue, "File creation data"); 254 WriteSingleHeaderKey("TIMESYS", "TT", "Time frame system"); 255 WriteSingleHeaderKey("TIMEUNIT", "d", "Time unit"); 256 WriteSingleHeaderKey("TIMEREF", "UTC", "Time reference frame"); 257 WriteSingleHeaderKey("MJDREF", fRefMjD, "Modified Julian Date of origin"); 258 WriteSingleHeaderKey("TSTOP", fEndMjD, "Time of the last receied data"); 262 if (!WriteSingleHeaderKey("DATE", stringValue, "File creation data")) return false; 263 if (!WriteSingleHeaderKey("TIMESYS", "TT", "Time frame system")) return false; 264 if (!WriteSingleHeaderKey("TIMEUNIT", "d", "Time unit")) return false; 265 if (!WriteSingleHeaderKey("TIMEREF", "UTC", "Time reference frame")) return false; 266 if (!WriteSingleHeaderKey("MJDREF", fRefMjD, "Modified Julian Date of origin")) return false; 267 if (!WriteSingleHeaderKey("TSTOP", fEndMjD, "Time of the last receied data")) return false; 268 return true; 259 269 } 260 270 // -------------------------------------------------------------------------- … … 263 273 //! @param conv the converter corresponding to the service being logged 264 274 // 265 voidFits::Write(Converter* conv)275 bool Fits::Write(Converter* conv) 266 276 { 267 277 //first copy the standard variables to the copy buffer … … 284 294 str << fFileName << ": " << e.what(); 285 295 fMess->Error(str); 286 return ;296 return false; 287 297 } 288 298 … … 295 305 str << "Inserting row into " << fFileName << " failed (fits_insert_rows, rc=" << status << ")"; 296 306 fMess->Error(str); 297 // FIXME: What is a proper action here? 307 Close(); 308 return false; 298 309 } 299 310 … … 310 321 311 322 //data copied to buffer, can write to fits 312 fits_write_tblbytes(fFile->fitsPointer(), fNumRows, 1, fTotalNumBytes, fCopyBuffer, &status); 313 if (status) 323 if (fits_write_tblbytes(fFile->fitsPointer(), fNumRows, 1, fTotalNumBytes, fCopyBuffer, &status)) 314 324 { 315 325 char text[30];//max length of cfitsio error strings (from doc) … … 318 328 str << "Writing FITS row " << fNumRows << " in " << fFileName << ": " << text << " (file_write_tblbytes, rc=" << status << ")"; 319 329 fMess->Error(str); 320 // FIXME: What is a proper action here? 321 } 330 Close(); 331 return false; 332 } 333 return true; 322 334 } 323 335
Note:
See TracChangeset
for help on using the changeset viewer.