Changeset 10955 for trunk/FACT++/src/dataLogger.cc
- Timestamp:
- 06/09/11 17:13:03 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/dataLogger.cc
r10954 r10955 199 199 kSM_BadNightlyConfig = 0x101, ///< the folder specified for Nightly logging does not exist or has bad permissions 200 200 kSM_BadRunConfig = 0x102, ///< the folder specified for the run logging does not exist or has wrong permissions or no run number 201 kSM_WriteError = 0x103, ///< Denotes that an error occured while writing a file (text or fits). 201 202 } localstates_t; 202 203 … … 297 298 ///from NightlyOpen to waiting transition 298 299 int NightlyToWaitRunPlease(); 300 /// from writing to error 301 std::string SetCurrentState(int state, const char *txt="", const std::string &cmd=""); 299 302 #ifdef HAVE_FITS 300 303 ///Open fits files … … 560 563 if (out.is_open()) 561 564 out.close(); 565 SetCurrentState(kSM_WriteError); 562 566 } 563 567 } … … 928 932 AddStateName(kSM_BadNightlyConfig, "ErrNightlyFolder", "The folder for the nighly summary files is invalid."); 929 933 AddStateName(kSM_BadRunConfig, "ErrRunFolder", "The folder for the run files is invalid."); 934 AddStateName(kSM_WriteError, "ErrWrite", "An error occured while writing to a file."); 930 935 931 936 /*Add the possible transitions for this machine*/ … … 934 939 ("Start the nightly logging. Nightly file location must be specified already"); 935 940 936 AddEvent(kSM_Ready, fTransStop, kSM_NightlyOpen, kSM_WaitingRun, kSM_Logging )941 AddEvent(kSM_Ready, fTransStop, kSM_NightlyOpen, kSM_WaitingRun, kSM_Logging, kSM_WriteError) 937 942 (boost::bind(&DataLogger::GoToReadyPlease, this)) 938 943 ("Stop all data logging, close all files."); … … 946 951 ("Wait for a run to be started, open run-files as soon as a run number arrives."); 947 952 948 AddEvent(kSM_Ready, fTransReset, kSM_Error, kSM_BadNightlyConfig, kSM_BadRunConfig, kSM_ Error)953 AddEvent(kSM_Ready, fTransReset, kSM_Error, kSM_BadNightlyConfig, kSM_BadRunConfig, kSM_WriteError) 949 954 (boost::bind(&DataLogger::GoToReadyPlease, this)) 950 955 ("Transition to exit error states. Closes the nightly file if already opened."); … … 970 975 //Provide a print command 971 976 ostringstream str; 972 str << kSM_Ready << " " << kSM_NightlyOpen << " " << kSM_WaitingRun << " " << kSM_Logging << " " << kSM_BadNightlyConfig ;977 str << kSM_Ready << " " << kSM_NightlyOpen << " " << kSM_WaitingRun << " " << kSM_Logging << " " << kSM_BadNightlyConfig << " " << kSM_WriteError; 973 978 str << " " << kSM_BadRunConfig; 974 979 AddEvent(fPrintCommand, str.str().c_str(), "") … … 1309 1314 1310 1315 //create the converter for that service 1311 if ( sub.fConv&& isItaReport)1316 if ((!sub.fConv.get()) && isItaReport) 1312 1317 { 1313 1318 //trick the converter in case of 'C'. why do I do this ? well simple: the converter checks that the right number … … 1851 1856 fOpenedNightlyFits[fileNameOnly].push_back(serviceName); 1852 1857 1853 sub.nightlyFile.Open(partialName, serviceName, NULL, &fNumSubAndFitsData.numOpenFits, this, 0);//Out()); 1854 1858 if (!sub.nightlyFile.Open(partialName, serviceName, NULL, &fNumSubAndFitsData.numOpenFits, this, 0)) 1859 { 1860 SetCurrentState(kSM_WriteError); 1861 return; 1862 } 1855 1863 //notify the opening 1856 1864 string baseFileName = CompileFileName(fNightlyFilePath, "", ""); … … 1889 1897 } 1890 1898 1891 if (hasGrouping && cRunNumber->runFitsFile)1899 if (hasGrouping && (!cRunNumber->runFitsFile.get())) 1892 1900 try 1893 1901 { … … 1906 1914 NotifyOpenedFile(baseFileName, 7, fOpenedRunFiles);// + '_' + serviceName, 4); 1907 1915 if (hasGrouping) 1908 sub.runFile.Open(partialName, serviceName, (cRunNumber->runFitsFile).get(), &fNumSubAndFitsData.numOpenFits, this, sub.runNumber);//Out()); 1916 { 1917 if (!sub.runFile.Open(partialName, serviceName, (cRunNumber->runFitsFile).get(), &fNumSubAndFitsData.numOpenFits, this, sub.runNumber)) 1918 { 1919 SetCurrentState(kSM_WriteError); 1920 return; 1921 } 1922 } 1909 1923 else 1910 sub.runFile.Open(partialName, serviceName, NULL, &fNumSubAndFitsData.numOpenFits, this, sub.runNumber);//Out()); 1911 1924 { 1925 if (sub.runFile.Open(partialName, serviceName, NULL, &fNumSubAndFitsData.numOpenFits, this, sub.runNumber)) 1926 { 1927 SetCurrentState(kSM_WriteError); 1928 return; 1929 } 1930 } 1912 1931 if (fNumSubAndFitsIsOn) 1913 1932 fNumSubAndFits->updateService(); … … 2010 2029 if (sub.nightlyFile.IsOpen()) 2011 2030 { 2012 sub.nightlyFile.Write(sub.fConv.get()); 2013 if (fDebugIsOn) 2014 { 2015 Debug("Writing to nightly FITS " + sub.nightlyFile.fFileName); 2016 } 2017 } 2031 if (!sub.nightlyFile.Write(sub.fConv.get())) 2032 SetCurrentState(kSM_WriteError); 2033 } 2018 2034 if (sub.runFile.IsOpen()) 2019 2035 { 2020 sub.runFile.Write(sub.fConv.get()); 2021 if (fDebugIsOn) 2022 { 2023 Debug("Writing to Run FITS " + sub.runFile.fFileName); 2024 } 2036 if (!sub.runFile.Write(sub.fConv.get())) 2037 SetCurrentState(kSM_WriteError); 2025 2038 } 2026 2039 } 2027 2040 #endif //if has_fits 2041 2042 std::string DataLogger::SetCurrentState(int state, const char *txt, const std::string &cmd) 2043 { 2044 if (state == kSM_WriteError && GetCurrentState() == kSM_WriteError) 2045 return ""; 2046 return StateMachineImp::SetCurrentState(state, txt, cmd); 2047 } 2028 2048 // -------------------------------------------------------------------------- 2029 2049 //
Note:
See TracChangeset
for help on using the changeset viewer.