Changeset 12167 for trunk/FACT++/src


Ignore:
Timestamp:
10/11/11 13:47:04 (13 years ago)
Author:
tbretz
Message:
Updated graph; unified paths; updated compilation of file-names; removed obsolete commands
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/datalogger.cc

    r12120 r12167  
    1010  The possible states and transitions of the machine are:
    1111  \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];
    2116 
    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
    3757  }
    3858  \enddot
     
    181201    enum
    182202    {
    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).
    190209    } localstates_t;
    191210   
     
    203222    /// ofstream for the Nightly report file
    204223    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;
    209226    ///run numbers
    210227    list<RunNumberType> fRunNumber;
     
    246263    void ReportPlease(DimInfo* I, SubscriptionType& sub); 
    247264
    248     int ConfigureFileName(string &target, const string &type, const EventImp &evt);
    249265    ///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);
    255267    ///print the current state of the dataLogger
    256268    int PrintStatePlease(const Event& evt);
     
    260272    int StartPlease();
    261273    ///from waiting to logging transition
    262     int StartRunPlease();
    263     /// from logging to waiting transition
    264     int StopRunPlease();
     274    //int StartRunPlease();
     275    // from logging to waiting transition
     276    int StopRunLogging();
    265277    ///stop and reset transition
    266278    int GoToReadyPlease();
     
    336348    void AppendYearMonthDaytoPath(string& path);
    337349    ///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()*/);
    339351    ///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;
    345353    ///Check whether service is in black and/or white list
    346354    bool ShouldSubscribe(const string& server, const string& service);
     
    633641//
    634642//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)
     643string DataLogger::CompileFileName(const string& service, const string& extension, uint32_t run, const Time& time) const
    636644{
    637645    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
    645653    if (!service.empty())
    646         str  << "_" << service;
    647 
    648     //output appropriate extension
     654        str << '.' << service;
     655
    649656    if (!extension.empty())
    650657        str << "." << extension;
     
    653660}
    654661
    655 string DataLogger::CompileFileNameWithPath(const string& path, const string& service, const string& extension, const Time& time)
     662string DataLogger::CompileFileNameWithPath(const string& path, const string& service, const string& extension, uint32_t run/*, const Time& time*/)
    656663{
    657664    ostringstream str;
     665
     666    const Time time;
     667
    658668    //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);
    660670
    661671    //output it
    662     str << path << Time::fmt("/%Y/%m/%d") << ftime;
     672    str << path << ftime.GetAsStr("/%Y/%m/%d");
    663673
    664674    //check if target directory exist
     
    666676        CreateDirectory(str.str());
    667677
    668     str << '/' << CompileFileName(service, extension, time);
     678    str << '/' << CompileFileName(service, extension, run, time);
    669679
    670680    return str.str();
     
    672682
    673683}
    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
    720685// --------------------------------------------------------------------------
    721686//
     
    772737    shouldBackLog = true;
    773738    //initialize member data
    774     fNightlyFilePath = ".";
    775     fRunFilePath = ".";
     739    fFilePath = ".";
    776740
    777741    //Give a name to this machine's specific states
     
    779743    AddStateName(kSM_WaitingRun,       "WaitForRun",       "The summary files for the night are open and we wait for a run to be started.");
    780744    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.");
    783746    AddStateName(kSM_DailyWriteError,  "ErrDailyWrite",    "An error occured while writing to a daily (and run) file.");
    784747    AddStateName(kSM_RunWriteError,    "ErrRunWrite",      "An error occured while writing to a run file.");
    785748
    786749    // Add the possible transitions for this machine
    787     AddEvent(kSM_NightlyOpen, "START", kSM_Ready, kSM_BadNightlyConfig)
     750    AddEvent(kSM_NightlyOpen, "START", kSM_Ready, kSM_BadFolder)
    788751        (bind(&DataLogger::StartPlease, this))
    789752        ("Start the nightly logging. Nightly file location must be specified already");
     
    792755        (bind(&DataLogger::GoToReadyPlease, this))
    793756        ("Stop all data logging, close all files.");
    794 
     757/*
    795758    AddEvent(kSM_Logging, "START_RUN", kSM_WaitingRun, kSM_BadRunConfig)
    796759        (bind(&DataLogger::StartRunPlease, this))
     
    798761
    799762    AddEvent(kSM_WaitingRun, "STOP_RUN", kSM_Logging)
    800         (bind(&DataLogger::StopRunPlease, this))
     763        (bind(&DataLogger::StopRunLogging, this))
    801764        ("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_BadNightlyConfig, kSM_BadRunConfig, kSM_DailyWriteError, kSM_RunWriteError)
     765*/
     766    AddEvent(kSM_Ready, "RESET", kSM_Error, kSM_BadFolder, kSM_DailyWriteError, kSM_RunWriteError)
    804767        (bind(&DataLogger::GoToReadyPlease, this))
    805768        ("Transition to exit error states. Closes the any open file.");
    806769
    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)
    808771        (bind(&DataLogger::NightlyToWaitRunPlease, this))
    809772        ("Go to waiting for run number state. In this state with any received run-number a new file is opened.");
    810773
    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    /*
    815779    // 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)
    817781        (bind(&DataLogger::ConfigureNightlyFileName, this, placeholders::_1))
    818782        ("Configure the base folder for the nightly files."
     
    823787        ("Configure the base folder for the run files."
    824788         "|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     */
    830790     // Provide a print command
    831      AddEvent("PRINT")
     791     AddEvent("PRINT_INFO")
    832792            (bind(&DataLogger::PrintStatePlease, this, placeholders::_1))
    833793            ("Print information about the internal status of the data logger.");
     
    10531013#ifdef RUN_LOGS
    10541014    // open log file
    1055     run.logName = CompileFileName(fRunFilePath, run.runNumber, "", "log");
     1015    run.logName = CompileFileName(fFilePath, "", "log", run.runNumber);
    10561016    if (!OpenStream(run.logFile, run.logName))
    10571017        return -1;
     
    10591019
    10601020    // open report file
    1061     run.reportName = CompileFileNameWithPath(fRunFilePath, run.runNumber, "", "rep");
     1021    run.reportName = CompileFileNameWithPath(fFilePath, "", "rep", run.runNumber);
    10621022    if (!OpenStream(run.reportFile, run.reportName))
    10631023        return -1;
     
    10691029    fFilesStats.FileOpened(run.reportName);
    10701030    //TODO this notification scheme might be messed up now.... fix it !
    1071     const string baseFileName = CompileFileNameWithPath(fRunFilePath, run.runNumber, "", "");
     1031    const string baseFileName = CompileFileNameWithPath(fFilePath, "", "", run.runNumber);
    10721032    NotifyOpenedFile(baseFileName, 3, fOpenedRunFiles);
    10731033    run.openedFits.clear();
     
    10931053        {
    10941054            Error("Newly provided run number has already been used (or is still in use). Going to error state");
    1095             SetCurrentState(kSM_BadRunConfig);
     1055            SetCurrentState(kSM_BadFolder);
    10961056            return;
    10971057        }
     
    11331093#endif
    11341094        }
    1135         StopRunPlease();
    1136         SetCurrentState(kSM_BadRunConfig);
     1095        StopRunLogging();
     1096        SetCurrentState(kSM_BadFolder);
    11371097    }
    11381098
     
    11811141    }
    11821142
    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    //
    11901160    if (Time().h() == 12 && !fDailyFileDayChangedAlready)
    11911161    {
     
    12001170        Info("Closed: "+fFullNightlyReportFileName);
    12011171
    1202         fFullNightlyLogFileName = CompileFileNameWithPath(fNightlyFilePath, "", "log");
     1172        fFullNightlyLogFileName = CompileFileNameWithPath(fFilePath, "", "log");
    12031173        if (!OpenTextFilePlease(fNightlyLogFile, fFullNightlyLogFileName))
    12041174        {
    12051175            GoToReadyPlease();
    1206             SetCurrentState(kSM_BadNightlyConfig);
     1176            SetCurrentState(kSM_BadFolder);
    12071177            return;
    12081178        }
    12091179        fNightlyLogFile << endl;
    12101180
    1211         fFullNightlyReportFileName = CompileFileNameWithPath(fNightlyFilePath, "", "rep");
     1181        fFullNightlyReportFileName = CompileFileNameWithPath(fFilePath, "", "rep");
    12121182        if (!OpenTextFilePlease(fNightlyReportFile, fFullNightlyReportFileName))
    12131183        {
    12141184            GoToReadyPlease();
    1215             SetCurrentState(kSM_BadNightlyConfig);
     1185            SetCurrentState(kSM_BadFolder);
    12161186            return;
    12171187        }
     
    14071377
    14081378    //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());
    14111380
    14121381    //print active run numbers
     
    16191588// --------------------------------------------------------------------------
    16201589//
    1621 //!    Configure a given file name
    1622 //! @param target
    1623 //!        where to put the result
    1624 //! @param type
    1625 //!         what to append to the created path. currently only run or nightly
    1626 //! @param evt
    1627 //!         the event transporting the path
    1628 //! @returns
    1629 //!        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 //
    16571590//!    Sets the path to use for the Nightly log file.
    16581591//! @param evt
     
    16601593//! @returns
    16611594//!        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/*
     1596int 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
    16901617    return GetCurrentState();
    16911618}
     1619*/
     1620
    16921621// --------------------------------------------------------------------------
    16931622//
     
    17331662//! and tries to open it.
    17341663//! @returns
    1735 //!        kSM_NightlyOpen if success, kSM_BadNightlyConfig if failure
     1664//!        kSM_NightlyOpen if success, kSM_BadFolder if failure
    17361665int DataLogger::StartPlease()
    17371666{
     
    17401669        Debug("Starting...");   
    17411670    }
    1742     fFullNightlyLogFileName = CompileFileNameWithPath(fNightlyFilePath, "", "log");
     1671    fFullNightlyLogFileName = CompileFileNameWithPath(fFilePath, "", "log");
    17431672    bool nightlyLogOpen = fNightlyLogFile.is_open();
    17441673    if (!OpenTextFilePlease(fNightlyLogFile, fFullNightlyLogFileName))
    1745         return kSM_BadNightlyConfig;
     1674        return kSM_BadFolder;
    17461675    if (!nightlyLogOpen)
    17471676        fNightlyLogFile << endl;
    17481677
    1749     fFullNightlyReportFileName = CompileFileNameWithPath(fNightlyFilePath, "", "rep");
     1678    fFullNightlyReportFileName = CompileFileNameWithPath(fFilePath, "", "rep");
    17501679    if (!OpenTextFilePlease(fNightlyReportFile, fFullNightlyReportFileName))
    17511680    {
    17521681        fNightlyLogFile.close();
    17531682        Info("Closed: "+fFullNightlyReportFileName);
    1754         return kSM_BadNightlyConfig;
     1683        return kSM_BadFolder;
    17551684    }
    17561685
     
    17581687    fFilesStats.FileOpened(fFullNightlyReportFileName);
    17591688    //notify that a new file has been opened.
    1760     const string baseFileName = CompileFileNameWithPath(fNightlyFilePath, "", "");
     1689    const string baseFileName = CompileFileNameWithPath(fFilePath, "", "");
    17611690    NotifyOpenedFile(baseFileName, 3, fOpenedNightlyFiles);
    17621691
     
    18071736    if (!sub.nightlyFile.IsOpen())
    18081737    {
    1809         const string partialName = CompileFileNameWithPath(fNightlyFilePath, serviceName, "fits");
     1738        const string partialName = CompileFileNameWithPath(fFilePath, serviceName, "fits");
    18101739
    18111740        const string fileNameOnly = partialName.substr(partialName.find_last_of('/')+1, partialName.size());
     
    18271756
    18281757        //notify the opening
    1829         const string baseFileName = CompileFileNameWithPath(fNightlyFilePath, "", "");
     1758        const string baseFileName = CompileFileNameWithPath(fFilePath, "", "");
    18301759        NotifyOpenedFile(baseFileName, 7, fOpenedNightlyFiles);
    18311760        if (fNumSubAndFitsIsOn)
     
    18351764    if (!sub.runFile.IsOpen() && (GetCurrentState() == kSM_WaitingRun || GetCurrentState() == kSM_Logging) && sub.runNumber > 0)
    18361765    {//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());
    18491772
    18501773        //get the size of the file we're about to open
     
    18731796            }
    18741797
    1875         const string baseFileName = CompileFileNameWithPath(fRunFilePath, sub.runNumber, "", "");
     1798        const string baseFileName = CompileFileNameWithPath(fFilePath, "", "", sub.runNumber);
    18761799        NotifyOpenedFile(baseFileName, 7, fOpenedRunFiles);
    18771800
     
    19821905}
    19831906
     1907/*
    19841908// --------------------------------------------------------------------------
    19851909//
     
    20051929    return kSM_Logging;
    20061930}
    2007 
     1931*/
    20081932#ifdef HAVE_FITS
    20091933// --------------------------------------------------------------------------
     
    20531977        return;
    20541978    }
    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);
    20601980
    20611981    Info("Creating FITS group in: "+groupName);
     
    21502070//! @returns
    21512071//!        kSM_WaitingRun if success, kSM_FatalError otherwise
    2152 int DataLogger::StopRunPlease()
     2072int DataLogger::StopRunLogging()
    21532073{
    21542074
     
    22092129   }
    22102130   if (GetCurrentState() == kSM_Logging || GetCurrentState() == kSM_WaitingRun)
    2211        StopRunPlease();
     2131       StopRunLogging();
     2132
    22122133   //it may be that dim tries to write a dimInfo while we're closing files. Prevent that
    2213    const string baseFileName = CompileFileNameWithPath(fNightlyFilePath, "", "");
     2134   const string baseFileName = CompileFileNameWithPath(fFilePath, "", "");
    22142135
    22152136    if (fNightlyReportFile.is_open())
     
    22452166//! If current state is kSM_Ready, then tries to go to nightlyOpen state first.
    22462167//!    @returns
    2247 //!        kSM_WaitingRun or kSM_badNightlyConfig
     2168//!        kSM_WaitingRun or kSM_BadFolder
    22482169int DataLogger::NightlyToWaitRunPlease()
    22492170{
    22502171    int cState = GetCurrentState();
    22512172
    2252     if (cState == kSM_Logging)
    2253         cState = kSM_NightlyOpen;
     2173//    if (cState == kSM_Logging)
     2174//        cState = kSM_NightlyOpen;
    22542175
    22552176    if (cState == kSM_Ready)
     
    22732194int DataLogger::BackToNightlyOpenPlease()
    22742195{
     2196    if (GetCurrentState()==kSM_Logging)
     2197        StopRunLogging();
     2198
    22752199    if (fDebugIsOn)
    22762200    {
     
    23262250             return 2;
    23272251
    2328          fRunFilePath     = folder;
    2329          fNightlyFilePath = folder;
    2330          fFullNightlyLogFileName = CompileFileNameWithPath(fNightlyFilePath, "", "log");
     2252         fFilePath = folder;
     2253         fFullNightlyLogFileName = CompileFileNameWithPath(fFilePath, "", "log");
    23312254         if (!OpenTextFilePlease(fNightlyLogFile, fFullNightlyLogFileName))
    23322255             return 3;
Note: See TracChangeset for help on using the changeset viewer.