Changeset 10992 for trunk/FACT++/src
- Timestamp:
- 06/10/11 20:12:47 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/dataLogger.cc
r10991 r10992 370 370 DimStampedInfo* SubscribeToPlease(const string& server, const string& service); 371 371 ///Open a text file and checks for ofstream status 372 voidOpenTextFilePlease(ofstream& stream, const string& name);372 bool OpenTextFilePlease(ofstream& stream, const string& name); 373 373 ///Check if a dir is . and returns the actual string corresponding to . 374 374 // string CheckIfDirIsDot(const string& dir); … … 582 582 //! @name the file name 583 583 // 584 void DataLogger::OpenTextFilePlease(ofstream& stream, const string& name) 585 { 584 bool DataLogger::OpenTextFilePlease(ofstream& stream, const string& name) 585 { 586 Info("Opening: "+name); 587 586 588 errno = 0; 587 589 stream.open(name.c_str(), ios_base::out | ios_base::app); … … 589 591 { 590 592 ostringstream str; 591 str << " Open file " << name << ": " << strerror(errno) << " (errno=" << errno << ")";593 str << "Trying to open file " << name << ": " << strerror(errno) << " (errno=" << errno << ")"; 592 594 Error(str); 593 } 594 } 595 return false; 596 } 597 598 return true; 599 } 600 595 601 // -------------------------------------------------------------------------- 596 602 // … … 740 746 if (y->second.runFile.fRunNumber == fRunNumber.front().runNumber && y->second.runFile.IsOpen()) 741 747 { 742 if (fDebugIsOn)743 {744 ostringstream str;745 str << "Closing Fits run file " << y->second.runFile.fFileName;746 Debug(str);747 }748 748 y->second.runFile.Close(); 749 750 Info("Closed: "+y->second.runFile.fFileName); 749 751 } 750 752 //if a grouping file is on, decrease the number of opened fits manually … … 1178 1180 bool DataLogger::OpenStream(shared_ptr<ofstream> stream, const string &filename) 1179 1181 { 1182 Info("Opening: "+filename); 1183 1180 1184 if (stream->is_open()) 1181 1185 { … … 1323 1327 fNightlyReportFile.close(); 1324 1328 1329 Info("Closed: "+fFullNightlyLogFileName); 1330 Info("Closed: "+fFullNightlyReportFileName); 1331 1325 1332 fFullNightlyLogFileName = CompileFileName(fNightlyFilePath, "", "log"); 1326 1333 OpenTextFilePlease(fNightlyLogFile, fFullNightlyLogFileName); 1334 //FIXME: Handle return code properly! 1327 1335 1328 1336 fFullNightlyReportFileName = CompileFileName(fNightlyFilePath, "", "rep"); 1329 1337 OpenTextFilePlease(fNightlyReportFile, fFullNightlyReportFileName); 1338 //FIXME: Handle return code properly! 1330 1339 1331 1340 fDailyFileDayChangedAlready = true; … … 1735 1744 } 1736 1745 1737 Message("New "+type+" folder specified: "+givenPath);1746 Message("New "+type+" folder: "+givenPath); 1738 1747 1739 1748 target = givenPath; … … 1830 1839 } 1831 1840 fFullNightlyLogFileName = CompileFileName(fNightlyFilePath, "", "log"); 1832 OpenTextFilePlease(fNightlyLogFile, fFullNightlyLogFileName); 1841 if (!OpenTextFilePlease(fNightlyLogFile, fFullNightlyLogFileName)) 1842 return kSM_BadNightlyConfig; 1843 1833 1844 1834 1845 fFullNightlyReportFileName = CompileFileName(fNightlyFilePath, "", "rep"); 1835 OpenTextFilePlease(fNightlyReportFile, fFullNightlyReportFileName); 1836 1837 if (!fNightlyLogFile.is_open() || !fNightlyReportFile.is_open()) 1838 { 1839 ostringstream str; 1840 str << "Something went wrong while openning nightly files " << fFullNightlyLogFileName << " and " << fFullNightlyReportFileName; 1841 Error(str); 1846 if (!OpenTextFilePlease(fNightlyReportFile, fFullNightlyReportFileName)) 1842 1847 return kSM_BadNightlyConfig; 1843 } 1848 1844 1849 //get the size of the newly opened file. 1845 1850 fBaseSizeNightly = GetFileSize(fFullNightlyLogFileName); … … 1871 1876 if (sub.runFile.IsOpen() && sub.runFile.fRunNumber != sub.runNumber) 1872 1877 { 1873 if (fDebugIsOn)1874 Debug("Run number changed. Closing " + sub.runFile.fFileName);1875 1878 sub.runFile.Close(); 1879 Info("Closed: "+sub.runFile.fFileName+" (new run number)"); 1876 1880 } 1877 1881 … … 1910 1914 fOpenedNightlyFits[fileNameOnly].push_back(serviceName); 1911 1915 1916 ostringstream str; 1917 str << "Opening: " << partialName << " (Nfits=" << fNumSubAndFitsData.numOpenFits << ")"; 1918 Info(str); 1919 1912 1920 if (!sub.nightlyFile.Open(partialName, serviceName, NULL, &fNumSubAndFitsData.numOpenFits, this, 0)) 1913 1921 { … … 1920 1928 if (fNumSubAndFitsIsOn) 1921 1929 fNumSubAndFits->updateService(); 1922 if (fDebugIsOn)1923 {1924 ostringstream str;1925 str << "Opened Nightly FITS: " << partialName << " and table: " << serviceName << ".current number of opened FITS: " << fNumSubAndFitsData.numOpenFits;1926 Debug(str);1927 }1928 1930 } 1929 1931 //do the actual file open … … 1934 1936 if (hasGrouping) 1935 1937 { 1936 partialName = CompileFileName(fRunFilePath, sub.runNumber, " group", "fits");1938 partialName = CompileFileName(fRunFilePath, sub.runNumber, "", "fits"); 1937 1939 fileNameOnly = partialName.substr(partialName.find_last_of('/')+1, partialName.size()); 1938 1940 } … … 1960 1962 { 1961 1963 ostringstream str; 1962 str << " Could not open FITS Run file " << partialName << " reason: " << e.message();1964 str << "Open FITS file " << partialName << ": " << e.message(); 1963 1965 Error(str); 1964 1966 cRunNumber->runFitsFile = shared_ptr<CCfits::FITS>();//NULL; … … 1967 1969 const string baseFileName = CompileFileName(fRunFilePath, sub.runNumber, "", ""); 1968 1970 NotifyOpenedFile(baseFileName, 7, fOpenedRunFiles);// + '_' + serviceName, 4); 1971 1972 ostringstream str; 1973 str << "Opening: " << partialName << " (Nfits=" << fNumSubAndFitsData.numOpenFits << ")"; 1974 Info(str); 1975 1969 1976 if (hasGrouping) 1970 1977 { … … 1983 1990 } 1984 1991 } 1985 if (fNumSubAndFitsIsOn) 1986 fNumSubAndFits->updateService(); 1987 if (fDebugIsOn) 1988 { 1989 ostringstream str; 1990 str << "Opened Run FITS: " << partialName << " and table: " << serviceName << ".current number of opened FITS: " << fNumSubAndFitsData.numOpenFits; 1991 Debug(str); 1992 } 1992 if (fNumSubAndFitsIsOn) 1993 fNumSubAndFits->updateService(); 1993 1994 } 1994 1995 } … … 2165 2166 groupName = CompileFileName(fNightlyFilePath, "", "fits"); 2166 2167 2168 Info("Creating FITS group in: "+groupName); 2169 2167 2170 CCfits::Table* groupTable; 2168 2171 int maxCharLength = 50;//FILENAME_MAX; … … 2190 2193 { 2191 2194 ostringstream str; 2192 str << "C ould not open or create FITS table GROUPING in file " << groupName << " reason: " << e.message();2195 str << "Creating FITS table GROUPING in " << groupName << ": " << e.message(); 2193 2196 Error(str); 2194 2197 return; … … 2232 2235 if (status) 2233 2236 { 2237 char text[30];//max length of cfitsio error strings (from doc) 2238 fits_get_errstatus(status, text); 2234 2239 ostringstream str; 2235 str << " Could not write row #" << i << "In the fits grouping file " << groupName << ". Cfitsio error code: " << status;2240 str << "Writing FITS row " << i << " in " << groupName << ": " << text << " (file_write_tblbytes, rc=" << status << ")"; 2236 2241 Error(str); 2242 // FIXME: What to do in case of error? 2237 2243 } 2238 2244 }
Note:
See TracChangeset
for help on using the changeset viewer.