Changeset 12167
- Timestamp:
- 10/11/11 13:47:04 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/datalogger.cc
r12120 r12167 10 10 The possible states and transitions of the machine are: 11 11 \dot 12 digraph datalogger { 13 node [shape=record, fontname=Helvetica, fontsize=10]; 14 e [label="Error" color="red"]; 15 r [label="Ready"] 16 d [label="NightlyOpen"] 17 w [label="WaitingRun"] 18 l [label="Logging"] 19 b [label="BadNightlyconfig" color="red"] 20 c [label="BadRunConfig" color="red"] 12 // FIXME FIXME: Error states missing... 13 digraph datalogger 14 { 15 node [shape=record, fontname=Helvetica, fontsize=10]; 21 16 22 e -> r 23 r -> e 24 r -> d 25 r -> b 26 d -> w 27 d -> r 28 w -> r 29 l -> r 30 l -> w 31 b -> d 32 w -> c 33 w -> l 34 b -> r 35 c -> r 36 c -> l 17 srt [label="Start" style="rounded"] 18 rdy [label="Ready"] 19 nop [label="NightlyOpen"] 20 wait [label="WaitingRun"] 21 log [label="Logging"] 22 23 //e [label="Error" color="red"]; 24 //c [label="BadFolder" color="red"] 25 26 27 cmd_start [label="START" shape="none" height="0"] 28 cmd_stop [label="STOP" shape="none" height="0"] 29 cmd_stopr [label="STOP_RUN_LOGGING" shape="none" height="0"] 30 cmd_startr [label="START_RUN_LOGGING" shape="none" height="0"] 31 32 { rank=same; cmd_startr cmd_stopr } 33 { rank=same; cmd_start cmd_stop } 34 35 36 srt -> rdy 37 38 rdy -> cmd_start [ arrowhead="open" dir="both" arrowtail="tee" weight=10 ] 39 cmd_start -> nop 40 41 nop -> cmd_stop [ arrowhead="none" dir="both" arrowtail="inv" ] 42 wait -> cmd_stop [ arrowhead="none" dir="both" arrowtail="inv" ] 43 log -> cmd_stop [ arrowhead="none" dir="both" arrowtail="inv" ] 44 cmd_stop -> rdy 45 46 wait -> cmd_stopr [ arrowhead="none" dir="both" arrowtail="inv" ] 47 log -> cmd_stopr [ arrowhead="none" dir="both" arrowtail="inv" ] 48 cmd_stopr -> nop 49 50 nop -> cmd_startr [ arrowhead="none" dir="both" arrowtail="inv" weight=10 ] 51 rdy -> cmd_startr [ arrowhead="none" dir="both" arrowtail="inv" ] 52 cmd_startr -> wait [ weight=10 ] 53 54 55 wait -> log 56 log -> wait 37 57 } 38 58 \enddot … … 181 201 enum 182 202 { 183 kSM_NightlyOpen = 20, ///< Nightly file openned and writing 184 kSM_WaitingRun = 30, ///< waiting for the run number to open the run file 185 kSM_Logging = 40, ///< both files openned and writing 186 kSM_BadNightlyConfig = 0x101, ///< the folder specified for Nightly logging does not exist or has bad permissions 187 kSM_BadRunConfig = 0x102, ///< the folder specified for the run logging does not exist or has wrong permissions or no run number 188 kSM_RunWriteError = 0x103, ///< Denotes that an error occured while writing a run file (text or fits). 189 kSM_DailyWriteError = 0x103,///< Denots that an error occured while writing a daily file (text or fits). 203 kSM_NightlyOpen = 20, ///< Nightly file openned and writing 204 kSM_WaitingRun = 30, ///< waiting for the run number to open the run file 205 kSM_Logging = 40, ///< both files openned and writing 206 kSM_BadFolder = 0x101, ///< the folder specified for Nightly logging does not exist or has bad permissions 207 kSM_RunWriteError = 0x103, ///< Denotes that an error occured while writing a run file (text or fits). 208 kSM_DailyWriteError = 0x103, ///< Denots that an error occured while writing a daily file (text or fits). 190 209 } localstates_t; 191 210 … … 203 222 /// ofstream for the Nightly report file 204 223 ofstream fNightlyReportFile; 205 /// base path of the Nightlyfile 206 string fNightlyFilePath; 207 ///base path of the run file 208 string fRunFilePath; 224 /// base path of files 225 string fFilePath; 209 226 ///run numbers 210 227 list<RunNumberType> fRunNumber; … … 246 263 void ReportPlease(DimInfo* I, SubscriptionType& sub); 247 264 248 int ConfigureFileName(string &target, const string &type, const EventImp &evt);249 265 ///Configuration of the nightly file path 250 int ConfigureNightlyFileName(const Event& evt); 251 ///Configuration fo the file name 252 int ConfigureRunFileName(const Event& evt); 253 ///DEPREC - configuration of the run number 254 int ConfigureRunNumber(const Event& evt); 266 int ConfigureFilePath(const Event& evt); 255 267 ///print the current state of the dataLogger 256 268 int PrintStatePlease(const Event& evt); … … 260 272 int StartPlease(); 261 273 ///from waiting to logging transition 262 int StartRunPlease();263 // /from logging to waiting transition264 int StopRun Please();274 //int StartRunPlease(); 275 // from logging to waiting transition 276 int StopRunLogging(); 265 277 ///stop and reset transition 266 278 int GoToReadyPlease(); … … 336 348 void AppendYearMonthDaytoPath(string& path); 337 349 ///Form the files path 338 string CompileFileNameWithPath(const string &path, const string &service, const string & extension, const Time &time=Time());350 string CompileFileNameWithPath(const string &path, const string &service, const string & extension, uint32_t run=0/*, const Time &time=Time()*/); 339 351 ///Form the file names only 340 string CompileFileName(const string& service, const string& extension, const Time& time=Time()); 341 ///Form the files path 342 string CompileFileNameWithPath(const string &path, const int32_t run, const string &service, const string & extension, const Time &time=Time()); 343 ///Form the file names only 344 string CompileFileName(const int32_t run, const string& service, const string& extension);//, const Time& time=Time()); 352 string CompileFileName(const string& service, const string& extension, uint32_t run=0, const Time& time=Time()) const; 345 353 ///Check whether service is in black and/or white list 346 354 bool ShouldSubscribe(const string& server, const string& service); … … 633 641 // 634 642 //string DataLogger::CompileFileName(const string &path, const string &service, const string & extension, const Time &time) 635 string DataLogger::CompileFileName(const string& service, const string& extension, const Time& time)643 string DataLogger::CompileFileName(const string& service, const string& extension, uint32_t run, const Time& time) const 636 644 { 637 645 ostringstream str; 638 //calculate time suitable for naming path. 639 const Time ftime(time-boost::posix_time:: time_duration(12,0,0));640 641 //output base of file name 642 str << Time::fmt("%Y_%m_%d") << ftime;643 644 //output service name 646 647 const Time ftime(time-boost::posix_time::hours(12)); 648 str << ftime.NightAsInt(); 649 650 if (run>0) 651 str << '_' << setfill('0') << setw(3) << run; 652 645 653 if (!service.empty()) 646 str << "_" << service; 647 648 //output appropriate extension 654 str << '.' << service; 655 649 656 if (!extension.empty()) 650 657 str << "." << extension; … … 653 660 } 654 661 655 string DataLogger::CompileFileNameWithPath(const string& path, const string& service, const string& extension, const Time& time)662 string DataLogger::CompileFileNameWithPath(const string& path, const string& service, const string& extension, uint32_t run/*, const Time& time*/) 656 663 { 657 664 ostringstream str; 665 666 const Time time; 667 658 668 //calculate time suitable for naming files. 659 const Time ftime (time-boost::posix_time::time_duration(12,0,0));669 const Time ftime = time-boost::posix_time::hours(12); 660 670 661 671 //output it 662 str << path << Time::fmt("/%Y/%m/%d") << ftime;672 str << path << ftime.GetAsStr("/%Y/%m/%d"); 663 673 664 674 //check if target directory exist … … 666 676 CreateDirectory(str.str()); 667 677 668 str << '/' << CompileFileName(service, extension, time);678 str << '/' << CompileFileName(service, extension, run, time); 669 679 670 680 return str.str(); … … 672 682 673 683 } 674 // -------------------------------------------------------------------------- 675 // 676 //! Compiles a file name 677 //! @param run the run number 678 //! @param service the service name, if any 679 //! @param extension the extension to add, if any 680 // 681 string DataLogger::CompileFileName(const int32_t run, const string& service, const string& extension) 682 { 683 ostringstream str; 684 //output base of file name 685 str << setfill('0') << setw(8) << run; 686 687 //output service name 688 if (!service.empty()) 689 str << "_" << service; 690 691 //output appropriate extension 692 if (!extension.empty()) 693 str << "." << extension; 694 return str.str(); 695 } 696 // -------------------------------------------------------------------------- 697 // 698 //! Compiles a file name withh path 699 //! @param path the base path where to put the file 700 //! @param time the time at which the file is created 701 //! @param run the run number 702 //! @param service the service name, if any 703 //! @param extension the extension to add, if any 704 // 705 string DataLogger::CompileFileNameWithPath(const string& path, const int32_t run, const string& service, const string& extension, const Time& time) 706 { 707 ostringstream str; 708 //calculate suitable time for naming files and output it 709 str << path << Time::fmt("/%Y/%m/%d") << (time-boost::posix_time::time_duration(12,0,0)); 710 711 //check if target directory exist 712 if (!DoesPathExist(str.str())) 713 CreateDirectory(str.str()); 714 715 str << '/' << CompileFileName(run, service, extension);//, time); 716 717 return str.str(); 718 719 } 684 720 685 // -------------------------------------------------------------------------- 721 686 // … … 772 737 shouldBackLog = true; 773 738 //initialize member data 774 fNightlyFilePath = "."; 775 fRunFilePath = "."; 739 fFilePath = "."; 776 740 777 741 //Give a name to this machine's specific states … … 779 743 AddStateName(kSM_WaitingRun, "WaitForRun", "The summary files for the night are open and we wait for a run to be started."); 780 744 AddStateName(kSM_Logging, "Logging", "The summary files for the night and the files for a single run are open."); 781 AddStateName(kSM_BadNightlyConfig, "ErrNightlyFolder", "The folder for the nighly summary files is invalid."); 782 AddStateName(kSM_BadRunConfig, "ErrRunFolder", "The folder for the run files is invalid."); 745 AddStateName(kSM_BadFolder, "ErrInvalidFolder", "The folder for the files is not invalid."); 783 746 AddStateName(kSM_DailyWriteError, "ErrDailyWrite", "An error occured while writing to a daily (and run) file."); 784 747 AddStateName(kSM_RunWriteError, "ErrRunWrite", "An error occured while writing to a run file."); 785 748 786 749 // Add the possible transitions for this machine 787 AddEvent(kSM_NightlyOpen, "START", kSM_Ready, kSM_Bad NightlyConfig)750 AddEvent(kSM_NightlyOpen, "START", kSM_Ready, kSM_BadFolder) 788 751 (bind(&DataLogger::StartPlease, this)) 789 752 ("Start the nightly logging. Nightly file location must be specified already"); … … 792 755 (bind(&DataLogger::GoToReadyPlease, this)) 793 756 ("Stop all data logging, close all files."); 794 757 /* 795 758 AddEvent(kSM_Logging, "START_RUN", kSM_WaitingRun, kSM_BadRunConfig) 796 759 (bind(&DataLogger::StartRunPlease, this)) … … 798 761 799 762 AddEvent(kSM_WaitingRun, "STOP_RUN", kSM_Logging) 800 (bind(&DataLogger::StopRun Please, this))763 (bind(&DataLogger::StopRunLogging, this)) 801 764 ("Wait for a run to be started, open run-files as soon as a run number arrives."); 802 803 AddEvent(kSM_Ready, "RESET", kSM_Error, kSM_Bad NightlyConfig, kSM_BadRunConfig, kSM_DailyWriteError, kSM_RunWriteError)765 */ 766 AddEvent(kSM_Ready, "RESET", kSM_Error, kSM_BadFolder, kSM_DailyWriteError, kSM_RunWriteError) 804 767 (bind(&DataLogger::GoToReadyPlease, this)) 805 768 ("Transition to exit error states. Closes the any open file."); 806 769 807 AddEvent(kSM_WaitingRun, " WAIT_FOR_RUN_NUMBER", kSM_Logging,kSM_NightlyOpen, kSM_Ready)770 AddEvent(kSM_WaitingRun, "START_RUN_LOGGING", /*kSM_Logging,*/ kSM_NightlyOpen, kSM_Ready) 808 771 (bind(&DataLogger::NightlyToWaitRunPlease, this)) 809 772 ("Go to waiting for run number state. In this state with any received run-number a new file is opened."); 810 773 811 AddEvent(kSM_NightlyOpen, "BACK_TO_NIGHTLY_OPEN", kSM_WaitingRun) 812 (bind(&DataLogger::BackToNightlyOpenPlease, this)) 813 ("Go from the wait for run to nightly open state."); 814 774 AddEvent(kSM_NightlyOpen, "STOP_RUN_LOGGING", kSM_WaitingRun, kSM_Logging) 775 (bind(&DataLogger::BackToNightlyOpenPlease, this)) 776 ("Go from the wait for run to nightly open state."); 777 778 /* 815 779 // Add the possible configurations for this machine 816 AddEvent("SET_ NIGHTLY_FOLDER", "C", kSM_Ready, kSM_BadNightlyConfig)780 AddEvent("SET_FOLDER", "C", kSM_Ready, kSM_BadNightlyConfig) 817 781 (bind(&DataLogger::ConfigureNightlyFileName, this, placeholders::_1)) 818 782 ("Configure the base folder for the nightly files." … … 823 787 ("Configure the base folder for the run files." 824 788 "|Path[string]:Absolute or relative path name where the run files should be stored."); 825 826 AddEvent("SET_RUN_NUMBER", "X", kSM_Ready, kSM_NightlyOpen, kSM_WaitingRun, kSM_BadRunConfig, kSM_Logging) 827 (bind(&DataLogger::ConfigureRunNumber, this, placeholders::_1)) 828 ("Configure the run number. Cannot be done in logging state"); 829 789 */ 830 790 // Provide a print command 831 AddEvent("PRINT ")791 AddEvent("PRINT_INFO") 832 792 (bind(&DataLogger::PrintStatePlease, this, placeholders::_1)) 833 793 ("Print information about the internal status of the data logger."); … … 1053 1013 #ifdef RUN_LOGS 1054 1014 // open log file 1055 run.logName = CompileFileName(f RunFilePath, run.runNumber, "", "log");1015 run.logName = CompileFileName(fFilePath, "", "log", run.runNumber); 1056 1016 if (!OpenStream(run.logFile, run.logName)) 1057 1017 return -1; … … 1059 1019 1060 1020 // open report file 1061 run.reportName = CompileFileNameWithPath(f RunFilePath, run.runNumber, "", "rep");1021 run.reportName = CompileFileNameWithPath(fFilePath, "", "rep", run.runNumber); 1062 1022 if (!OpenStream(run.reportFile, run.reportName)) 1063 1023 return -1; … … 1069 1029 fFilesStats.FileOpened(run.reportName); 1070 1030 //TODO this notification scheme might be messed up now.... fix it ! 1071 const string baseFileName = CompileFileNameWithPath(f RunFilePath, run.runNumber, "", "");1031 const string baseFileName = CompileFileNameWithPath(fFilePath, "", "", run.runNumber); 1072 1032 NotifyOpenedFile(baseFileName, 3, fOpenedRunFiles); 1073 1033 run.openedFits.clear(); … … 1093 1053 { 1094 1054 Error("Newly provided run number has already been used (or is still in use). Going to error state"); 1095 SetCurrentState(kSM_Bad RunConfig);1055 SetCurrentState(kSM_BadFolder); 1096 1056 return; 1097 1057 } … … 1133 1093 #endif 1134 1094 } 1135 StopRun Please();1136 SetCurrentState(kSM_Bad RunConfig);1095 StopRunLogging(); 1096 SetCurrentState(kSM_BadFolder); 1137 1097 } 1138 1098 … … 1181 1141 } 1182 1142 1183 //Check whether we should close and reopen daily text files or not 1184 //This should work in any case base of the following: 1185 // - fDailyFileDayChangedAlready is initialized to true. So if the dataLogger is started around noon, no file will be closed 1186 // - fDailyFileDayChangedAlready is set to false if (time != 12), so the file will be closed and reopened only if the logger runs since before noon (which is the required behavior) 1187 //This only applies to text files. Fits are closed and reopened based on the last and current service received time. 1188 //this was not applicable to text files, because as they gather several services, we have no guarantee that the received time will be greater than the previous one, 1189 //which could lead to several close/reopen instead of only one. 1143 // 1144 // Check whether we should close and reopen daily text files or not 1145 // 1146 // This should work in any case base of the following: 1147 // - fDailyFileDayChangedAlready is initialized to true. So if the 1148 // dataLogger is started around noon, no file will be closed 1149 // - fDailyFileDayChangedAlready is set to false if (time != 12), so 1150 // the file will be closed and reopened only if the logger runs since 1151 // before noon (which is the required behavior) 1152 // 1153 // This only applies to text files. Fits are closed and reopened based on 1154 // the last and current service received time. 1155 // This was not applicable to text files, because as they gather several 1156 // services, we have no guarantee that the received time will be greater 1157 // than the previous one, which could lead to several close/reopen instead 1158 // of only one. 1159 // 1190 1160 if (Time().h() == 12 && !fDailyFileDayChangedAlready) 1191 1161 { … … 1200 1170 Info("Closed: "+fFullNightlyReportFileName); 1201 1171 1202 fFullNightlyLogFileName = CompileFileNameWithPath(f NightlyFilePath, "", "log");1172 fFullNightlyLogFileName = CompileFileNameWithPath(fFilePath, "", "log"); 1203 1173 if (!OpenTextFilePlease(fNightlyLogFile, fFullNightlyLogFileName)) 1204 1174 { 1205 1175 GoToReadyPlease(); 1206 SetCurrentState(kSM_Bad NightlyConfig);1176 SetCurrentState(kSM_BadFolder); 1207 1177 return; 1208 1178 } 1209 1179 fNightlyLogFile << endl; 1210 1180 1211 fFullNightlyReportFileName = CompileFileNameWithPath(f NightlyFilePath, "", "rep");1181 fFullNightlyReportFileName = CompileFileNameWithPath(fFilePath, "", "rep"); 1212 1182 if (!OpenTextFilePlease(fNightlyReportFile, fFullNightlyReportFileName)) 1213 1183 { 1214 1184 GoToReadyPlease(); 1215 SetCurrentState(kSM_Bad NightlyConfig);1185 SetCurrentState(kSM_BadFolder); 1216 1186 return; 1217 1187 } … … 1407 1377 1408 1378 //print the path configuration 1409 Message("Nightly path: " + boost::filesystem::system_complete(boost::filesystem::path(fNightlyFilePath)).directory_string()); 1410 Message("Run path: " + boost::filesystem::system_complete(boost::filesystem::path(fRunFilePath)).directory_string()); 1379 Message("File path: " + boost::filesystem::system_complete(boost::filesystem::path(fFilePath)).directory_string()); 1411 1380 1412 1381 //print active run numbers … … 1619 1588 // -------------------------------------------------------------------------- 1620 1589 // 1621 //! Configure a given file name1622 //! @param target1623 //! where to put the result1624 //! @param type1625 //! what to append to the created path. currently only run or nightly1626 //! @param evt1627 //! the event transporting the path1628 //! @returns1629 //! currently only the current state.1630 //1631 int DataLogger::ConfigureFileName(string &target, const string &type, const EventImp &evt)1632 {1633 if (!evt.GetText())1634 {1635 Error("Empty "+type+" folder given. Please specify a valid path.");1636 return GetCurrentState();1637 }1638 1639 const string givenPath = evt.GetText();1640 if (!DoesPathExist(givenPath))1641 {1642 Error("Provided "+type+" path '"+givenPath+"' is not a valid folder. Ignored");1643 return GetCurrentState();1644 }1645 1646 Message("New "+type+" folder: "+givenPath);1647 1648 target = givenPath;1649 1650 fFilesStats.SetCurrentFolder(givenPath);1651 1652 return GetCurrentState();1653 }1654 1655 // --------------------------------------------------------------------------1656 //1657 1590 //! Sets the path to use for the Nightly log file. 1658 1591 //! @param evt … … 1660 1593 //! @returns 1661 1594 //! currently only the current state. 1662 // 1663 int DataLogger::ConfigureNightlyFileName(const Event& evt) 1664 { 1665 return ConfigureFileName(fNightlyFilePath, "nightly", evt); 1666 } 1667 1668 // -------------------------------------------------------------------------- 1669 // 1670 //! Sets the path to use for the run log file. 1671 //! @param evt 1672 //! the event transporting the path 1673 //! @returns 1674 //! currently only the current state 1675 int DataLogger::ConfigureRunFileName(const Event& evt) 1676 { 1677 return ConfigureFileName(fRunFilePath, "run", evt); 1678 } 1679 1680 // -------------------------------------------------------------------------- 1681 // 1682 //! Sets the run number. 1683 //! @param evt 1684 //! the event transporting the run number 1685 //! @returns 1686 //! currently only the current state 1687 int DataLogger::ConfigureRunNumber(const Event& evt) 1688 { 1689 AddNewRunNumber(evt.GetXtra(), evt.GetTime()); 1595 /* 1596 int DataLogger::ConfigureFilePath(const Event& evt) 1597 { 1598 if (!evt.GetText()) 1599 { 1600 Error("Empty folder given. Please specify a valid path."); 1601 return GetCurrentState(); 1602 } 1603 1604 const string givenPath = evt.GetText(); 1605 if (!DoesPathExist(givenPath)) 1606 { 1607 Error("Provided path '"+givenPath+"' is not a valid folder... ignored."); 1608 return GetCurrentState(); 1609 } 1610 1611 Message("New folder: "+givenPath); 1612 1613 fFilePath = givenPath; 1614 1615 fFilesStats.SetCurrentFolder(givenPath); 1616 1690 1617 return GetCurrentState(); 1691 1618 } 1619 */ 1620 1692 1621 // -------------------------------------------------------------------------- 1693 1622 // … … 1733 1662 //! and tries to open it. 1734 1663 //! @returns 1735 //! kSM_NightlyOpen if success, kSM_Bad NightlyConfigif failure1664 //! kSM_NightlyOpen if success, kSM_BadFolder if failure 1736 1665 int DataLogger::StartPlease() 1737 1666 { … … 1740 1669 Debug("Starting..."); 1741 1670 } 1742 fFullNightlyLogFileName = CompileFileNameWithPath(f NightlyFilePath, "", "log");1671 fFullNightlyLogFileName = CompileFileNameWithPath(fFilePath, "", "log"); 1743 1672 bool nightlyLogOpen = fNightlyLogFile.is_open(); 1744 1673 if (!OpenTextFilePlease(fNightlyLogFile, fFullNightlyLogFileName)) 1745 return kSM_Bad NightlyConfig;1674 return kSM_BadFolder; 1746 1675 if (!nightlyLogOpen) 1747 1676 fNightlyLogFile << endl; 1748 1677 1749 fFullNightlyReportFileName = CompileFileNameWithPath(f NightlyFilePath, "", "rep");1678 fFullNightlyReportFileName = CompileFileNameWithPath(fFilePath, "", "rep"); 1750 1679 if (!OpenTextFilePlease(fNightlyReportFile, fFullNightlyReportFileName)) 1751 1680 { 1752 1681 fNightlyLogFile.close(); 1753 1682 Info("Closed: "+fFullNightlyReportFileName); 1754 return kSM_Bad NightlyConfig;1683 return kSM_BadFolder; 1755 1684 } 1756 1685 … … 1758 1687 fFilesStats.FileOpened(fFullNightlyReportFileName); 1759 1688 //notify that a new file has been opened. 1760 const string baseFileName = CompileFileNameWithPath(f NightlyFilePath, "", "");1689 const string baseFileName = CompileFileNameWithPath(fFilePath, "", ""); 1761 1690 NotifyOpenedFile(baseFileName, 3, fOpenedNightlyFiles); 1762 1691 … … 1807 1736 if (!sub.nightlyFile.IsOpen()) 1808 1737 { 1809 const string partialName = CompileFileNameWithPath(f NightlyFilePath, serviceName, "fits");1738 const string partialName = CompileFileNameWithPath(fFilePath, serviceName, "fits"); 1810 1739 1811 1740 const string fileNameOnly = partialName.substr(partialName.find_last_of('/')+1, partialName.size()); … … 1827 1756 1828 1757 //notify the opening 1829 const string baseFileName = CompileFileNameWithPath(f NightlyFilePath, "", "");1758 const string baseFileName = CompileFileNameWithPath(fFilePath, "", ""); 1830 1759 NotifyOpenedFile(baseFileName, 7, fOpenedNightlyFiles); 1831 1760 if (fNumSubAndFitsIsOn) … … 1835 1764 if (!sub.runFile.IsOpen() && (GetCurrentState() == kSM_WaitingRun || GetCurrentState() == kSM_Logging) && sub.runNumber > 0) 1836 1765 {//buffer for the run file have already been allocated when doing the Nightly file 1837 string fileNameOnly; 1838 string partialName; 1839 if (hasGrouping) 1840 { 1841 partialName = CompileFileNameWithPath(fRunFilePath, sub.runNumber, "", "fits"); 1842 } 1843 else 1844 { 1845 partialName = CompileFileNameWithPath(fRunFilePath, sub.runNumber, serviceName, "fits"); 1846 } 1847 1848 fileNameOnly = partialName.substr(partialName.find_last_of('/')+1, partialName.size()); 1766 1767 const string partialName = 1768 CompileFileNameWithPath(fFilePath, hasGrouping ? "" : serviceName, "fits", sub.runNumber); 1769 1770 const string fileNameOnly = 1771 partialName.substr(partialName.find_last_of('/')+1, partialName.size()); 1849 1772 1850 1773 //get the size of the file we're about to open … … 1873 1796 } 1874 1797 1875 const string baseFileName = CompileFileNameWithPath(f RunFilePath, sub.runNumber, "", "");1798 const string baseFileName = CompileFileNameWithPath(fFilePath, "", "", sub.runNumber); 1876 1799 NotifyOpenedFile(baseFileName, 7, fOpenedRunFiles); 1877 1800 … … 1982 1905 } 1983 1906 1907 /* 1984 1908 // -------------------------------------------------------------------------- 1985 1909 // … … 2005 1929 return kSM_Logging; 2006 1930 } 2007 1931 */ 2008 1932 #ifdef HAVE_FITS 2009 1933 // -------------------------------------------------------------------------- … … 2053 1977 return; 2054 1978 } 2055 string groupName; 2056 if (runNumber != 0) 2057 groupName = CompileFileNameWithPath(fRunFilePath, runNumber, "", "fits"); 2058 else 2059 groupName = CompileFileNameWithPath(fNightlyFilePath, "", "fits"); 1979 const string groupName = CompileFileNameWithPath(fFilePath, "", "fits", runNumber); 2060 1980 2061 1981 Info("Creating FITS group in: "+groupName); … … 2150 2070 //! @returns 2151 2071 //! kSM_WaitingRun if success, kSM_FatalError otherwise 2152 int DataLogger::StopRun Please()2072 int DataLogger::StopRunLogging() 2153 2073 { 2154 2074 … … 2209 2129 } 2210 2130 if (GetCurrentState() == kSM_Logging || GetCurrentState() == kSM_WaitingRun) 2211 StopRunPlease(); 2131 StopRunLogging(); 2132 2212 2133 //it may be that dim tries to write a dimInfo while we're closing files. Prevent that 2213 const string baseFileName = CompileFileNameWithPath(f NightlyFilePath, "", "");2134 const string baseFileName = CompileFileNameWithPath(fFilePath, "", ""); 2214 2135 2215 2136 if (fNightlyReportFile.is_open()) … … 2245 2166 //! If current state is kSM_Ready, then tries to go to nightlyOpen state first. 2246 2167 //! @returns 2247 //! kSM_WaitingRun or kSM_ badNightlyConfig2168 //! kSM_WaitingRun or kSM_BadFolder 2248 2169 int DataLogger::NightlyToWaitRunPlease() 2249 2170 { 2250 2171 int cState = GetCurrentState(); 2251 2172 2252 if (cState == kSM_Logging)2253 cState = kSM_NightlyOpen;2173 // if (cState == kSM_Logging) 2174 // cState = kSM_NightlyOpen; 2254 2175 2255 2176 if (cState == kSM_Ready) … … 2273 2194 int DataLogger::BackToNightlyOpenPlease() 2274 2195 { 2196 if (GetCurrentState()==kSM_Logging) 2197 StopRunLogging(); 2198 2275 2199 if (fDebugIsOn) 2276 2200 { … … 2326 2250 return 2; 2327 2251 2328 fRunFilePath = folder; 2329 fNightlyFilePath = folder; 2330 fFullNightlyLogFileName = CompileFileNameWithPath(fNightlyFilePath, "", "log"); 2252 fFilePath = folder; 2253 fFullNightlyLogFileName = CompileFileNameWithPath(fFilePath, "", "log"); 2331 2254 if (!OpenTextFilePlease(fNightlyLogFile, fFullNightlyLogFileName)) 2332 2255 return 3;
Note:
See TracChangeset
for help on using the changeset viewer.