Changeset 11463


Ignore:
Timestamp:
07/19/11 14:13:46 (13 years ago)
Author:
lyard
Message:
added backlog of events and log without dim
File:
1 edited

Legend:

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

    r11441 r11463  
    5959#include "DimNetwork.h"
    6060
     61
    6162#ifdef HAVE_FITS
    6263#include "Fits.h"
     
    6465
    6566//Dim structures
    66 ///Distributes the writing statistics
    67 //struct DataLoggerStats {
    68 //    long sizeWritten;
    69 //    long freeSpace;
    70 //    long writingRate;
    71 //};
    7267///distributes the number of opened subscriptions and fits files
    7368struct NumSubAndFitsType {
     
    283278    void ServicesMonitoring();
    284279    inline void NotifyOpenedFile(const string &name, int type, DimDescribedService* service);
    285     ///variables for computing statistics
    286 //    DataLoggerStats fStatVar;
    287     ///stores the size of each file that is or was open
    288 //    map<string, long> fFileSizesMap;
    289     ///total size of the opened files BEFORE they were opened by the logger
    290 //    long fBaseSizeNightly;
    291 //    long fPreviousSize;
    292 //    long fBaseSizeRun;
    293280    ///Service for opened files
    294281    DimDescribedService* fOpenedNightlyFiles;
    295282    DimDescribedService* fOpenedRunFiles;
    296283    DimDescribedService* fNumSubAndFits;
    297 //    DimDescribedService* fStatsMonitoring;
    298284    NumSubAndFitsType fNumSubAndFitsData;
    299     ///Small function for calculating the total size written so far
    300 //    bool calculateTotalSizeWritten(DataLoggerStats& statVar, bool isPrinting);
    301285
    302286    /***************************************************
     
    358342    ///Open a text file and checks for ofstream status
    359343    bool OpenTextFilePlease(ofstream& stream, const string& name);
    360     ///Check if a dir is . and returns the actual string corresponding to .
    361 //    string CheckIfDirIsDot(const string& dir);
    362     ///Remembers the size of newly opened files. for statistic purposes
    363 //    bool RememberFileOrigSizePlease(string& fileName, bool nightly);
    364344    ///Checks if the input osftream is in error state, and if so close it.
    365345    bool CheckForOfstreamError(ofstream& out, bool isDailyStream);
     
    369349    ///Checks if a given path exist
    370350    bool DoesPathExist(string path);
    371     ///Check if the statistics service should be updated, and if so, do it
    372 //    void UpdateStatisticsService();
    373351    ///Check if old run numbers can be trimmed, and if so, do it
    374352    void TrimOldRunNumbers();
     
    384362    ///Remove all the services associated with a given server
    385363    void RemoveAllServices(const string&);
    386     ///Remove a server and all of its services
    387     //void RemoveServer(const std::string &s);
    388     ///Remove all the servers and all subscriptions
    389     //void RemoveAllServers();
     364    /***************************************************
     365     * Overwritten from MessageImp
     366    ***************************************************/
     367    vector<string> backLogBuffer;
     368    bool shouldBackLog;
     369public:
     370    int Write(const Time &time, const std::string &txt, int qos=kMessage);
     371
    390372}; //DataLogger
    391373
     374// --------------------------------------------------------------------------
     375//
     376//! Overwritten write function. This way we directly log the datalogger's messages, without going through dim's dns,
     377//! thus increasing robustness.
     378//! @param time: see MessageImp class param
     379//! @param txt: see MessageImp class param
     380//! @param qos: see MessageImp class param
     381//! @return see MessageImp class param
     382//
     383int DataLogger::Write(const Time&time, const std::string& txt, int qos)
     384{
     385    if (fNightlyLogFile.is_open())
     386    {
     387        MessageImp mimp(fNightlyLogFile);
     388        mimp.Write(time, txt, qos);
     389    }
     390    else if (shouldBackLog)
     391         {
     392             ostringstream str;
     393             MessageImp mimp(str);
     394             mimp.Write(time, txt, qos);
     395             backLogBuffer.push_back(str.str());
     396         }
     397    return StateMachineDim::Write(time, txt, qos);
     398}
    392399// --------------------------------------------------------------------------
    393400//
     
    489496    }
    490497
    491 //    list[service].dimInfo = shared_ptr<DimStampedInfo>(SubscribeToPlease(server, service));
    492498    list[service].dimInfo.reset(SubscribeToPlease(server, service));
    493499    list[service].server  = server;
     
    544550    }
    545551}
    546 /*
    547  // --------------------------------------------------------------------------
    548 //
    549 //! Remove a given server
    550 //! @param s the server to be removed
    551 //
    552 void DataLogger::RemoveServer(const std::string &s)
    553 {
    554     if (fServiceSubscriptions.erase(s) != 1)
    555     {
    556         Error("The server " + s + " to be removed was not in the servers list");
    557     }
    558     DimServiceInfoList::RemoveServer(s);
    559 }
    560 // --------------------------------------------------------------------------
    561 //
    562 //! Remove all the server and associated subscriptions
    563 //
    564 void DataLogger::RemoveAllServers()
    565 {
    566     fServiceSubscriptions.clear();
    567     DimServiceInfoList::RemoveAllServers();
    568     }*/
    569552
    570553// --------------------------------------------------------------------------
     
    588571    return false;
    589572}
    590 // --------------------------------------------------------------------------
    591 //
    592 //! Checks the size on disk of a given size, and remembers it in the relevant member variable
    593 //! @param fileName the file for which the size on disk should be retrieved
    594 //! @param nightly whether this is a run or nightly file, so that its size is added to the correct member variable
    595 //
    596 //bool DataLogger::RememberFileOrigSizePlease(string& fileName, bool nightly)
    597 //{
    598     //get the size of the file we're about to open
    599 //    if (fFileSizesMap.find(fileName) != fFileSizesMap.end())
    600 //        return false;
    601 
    602 //    if (nightly)
    603 //        fBaseSizeNightly += GetFileSize(fileName);
    604 //    else
    605 //        fBaseSizeRun += GetFileSize(fileName);
    606 //    fFileSizesMap[fileName] = 0;
    607 //    return true;//
    608 //}
    609573
    610574// --------------------------------------------------------------------------
     
    617581{
    618582    errno = 0;
     583    if (!stream.is_open())
    619584    stream.open(name.c_str(), ios_base::out | ios_base::app);
    620     if (!stream)
     585    if (!stream.is_open())
    621586    {
    622587        ostringstream str;
     
    817782// --------------------------------------------------------------------------
    818783//
    819 //! Calculate the total number of written bytes since the logger was started
    820 //! @param statVar the data structure that should be updated
    821 //! @param shouldWarn whether or not error messages should be outputted
    822 //! @param isPrinting whether this function was called from the PRINT command or not. If so, displays relevant information
    823 //
    824 /*
    825 bool DataLogger::calculateTotalSizeWritten(DataLoggerStats& statVar, bool isPrinting)
    826 {
    827 #ifdef HAVE_FITS
    828     if (isPrinting)
    829     {
    830         ostringstream str;
    831         str << "There are " << fNumSubAndFitsData.numOpenFits << " FITS files open:";
    832         Message(str);
    833     }
    834 
    835     ///TODO the grouping file is dealt with several times. This should not be a problem but well, better to fix it I guess.
    836     for (SubscriptionsListType::const_iterator x=fServiceSubscriptions.begin();
    837          x!=fServiceSubscriptions.end(); x++)
    838     {
    839         for (map<string, SubscriptionType>::const_iterator y=x->second.begin();
    840              y!=x->second.end(); y++)
    841         {
    842             if (y->second.runFile.IsOpen())
    843             {
    844                 fFileSizesMap[y->second.runFile.fFileName] = y->second.runFile.GetWrittenSize();
    845                 if (isPrinting)
    846                     Message("-> "+y->second.runFile.fFileName);
    847             }
    848             if (y->second.nightlyFile.IsOpen())
    849             {
    850                 fFileSizesMap[y->second.nightlyFile.fFileName] = y->second.nightlyFile.GetWrittenSize();
    851                 if (isPrinting)
    852                     Message("-> "+y->second.nightlyFile.fFileName);
    853             }
    854         }
    855     }
    856 #else
    857     if (isPrinting)
    858         Message("FITS output disabled at compilation");
    859 #endif
    860     //gather log and report files sizes on disk
    861     if (fNightlyLogFile.is_open())
    862         fFileSizesMap[fFullNightlyLogFileName] = GetFileSize(fFullNightlyLogFileName);
    863     if (fNightlyReportFile.is_open())
    864         fFileSizesMap[fFullNightlyReportFileName] = GetFileSize(fFullNightlyReportFileName);
    865     for (list<RunNumberType>::iterator it = fRunNumber.begin(); it != fRunNumber.end(); it++)
    866     {
    867         if (it->reportFile->is_open())
    868             fFileSizesMap[it->reportName] = GetFileSize(it->reportName);
    869 #ifdef RUN_LOGS
    870         if (it->logFile->is_open())
    871             fFileSizesMap[it->logName] = GetFileSize(it->logName);
    872 #endif
    873     }
    874 
    875     bool shouldWarn = false;
    876     struct statvfs vfs;
    877     if (!statvfs(fNightlyFilePath.c_str(), &vfs))
    878         statVar.freeSpace = vfs.f_bsize*vfs.f_bavail;
    879     else
    880     {
    881         ostringstream str;
    882         str << "Unable to retrieve stats for " << fNightlyFilePath << ". Reason: " << strerror(errno) << " [" << errno << "]";
    883         if (!shouldWarn)
    884             Error(str);
    885         statVar.freeSpace = -1;
    886     }
    887     //sum up all the file sizes. past and present
    888     statVar.sizeWritten = 0;
    889     for (map<string, long>::const_iterator it=fFileSizesMap.begin(); it != fFileSizesMap.end();  it++)
    890         statVar.sizeWritten += it->second;
    891     statVar.sizeWritten -= fBaseSizeNightly;
    892     statVar.sizeWritten -= fBaseSizeRun;
    893 
    894     return shouldWarn;
    895 }
    896 */
    897 // --------------------------------------------------------------------------
    898 //
    899784//! Default constructor. The name of the machine is given DATA_LOGGER
    900785//! and the state is set to kSM_Ready at the end of the function.
     
    905790                                       fFilesStats("DATA_LOGGER", *this)
    906791{
     792    shouldBackLog = true;
    907793    //initialize member data
    908794    fNightlyFilePath = ".";
     
    989875
    990876     //services parameters
    991      fDebugIsOn = false;
    992 //     fStatsPeriodDuration = 1.0f;
    993      fOpenedFilesIsOn = true;
     877     fDebugIsOn         = false;
     878     fOpenedFilesIsOn   = true;
    994879     fNumSubAndFitsIsOn = true;
    995880
     
    1022907     fDestructing = false;
    1023908
    1024      //start the monitoring service
    1025 //     fStatVar.sizeWritten = 0;
    1026 //     fStatVar.freeSpace = 0;
    1027 //     fStatVar.writingRate = 0;
    1028 //     fPreviousStatsUpdateTime = Time().Mjd();
    1029909     fPreviousOldRunNumberCheck = Time().Mjd();
    1030 //     fPreviousSize = 0;
    1031 
    1032 //     struct statvfs vfs;
    1033 //     if (!statvfs(fNightlyFilePath.c_str(), &vfs))
    1034 //         fStatVar.freeSpace = vfs.f_bsize*vfs.f_bavail;
    1035 //     else
    1036 //         fStatVar.freeSpace = -1;
    1037 
    1038 //     fStatsMonitoring = new DimDescribedService(GetName() + "/STATS", "X:3", fStatVar, "Add description here");
    1039 
    1040 //     fBaseSizeNightly = 0;
    1041 //     fBaseSizeRun = 0;
     910
    1042911     fDailyFileDayChangedAlready = true;
    1043912     fRunNumberTimeout = 60; //default run-timeout set to 1 minute
     
    1057926        Debug("DataLogger destruction starts");   
    1058927
    1059     //this boolean should not be required anymore, because it
     928    //this boolean should not be required anymore
    1060929    fDestructing = true;
    1061930
    1062931    //first, let's backup the datalogger/message service subscription
    1063     shared_ptr<DimStampedInfo> messageBackup;
    1064     const SubscriptionsListType::iterator x = fServiceSubscriptions.find("DATA_LOGGER");
    1065     if (x != fServiceSubscriptions.end())
    1066     {
    1067         const map<string, SubscriptionType>::iterator y = x->second.find("MESSAGE");
    1068         if (y != x->second.end())
    1069             messageBackup = y->second.dimInfo;
    1070     }
    1071 
    1072     dim_lock();
     932//    shared_ptr<DimStampedInfo> messageBackup;
     933//    const SubscriptionsListType::iterator x = fServiceSubscriptions.find("DATA_LOGGER");
     934//    if (x != fServiceSubscriptions.end())
     935//    {
     936//        const map<string, SubscriptionType>::iterator y = x->second.find("MESSAGE");
     937//        if (y != x->second.end())
     938//            messageBackup = y->second.dimInfo;
     939//    }
     940
     941//    dim_lock();
    1073942
    1074943     //now clear the services subscriptions
     
    1083952    GoToReadyPlease();
    1084953
    1085     dim_unlock();
     954//    dim_unlock();
    1086955
    1087956    Info("Will soon close the daily log file");
     
    1092961
    1093962    //release message service before closing nightly log file
    1094     if (messageBackup)
    1095         messageBackup.reset();
     963//    if (messageBackup)
     964 //       messageBackup.reset();
    1096965
    1097966    if (fNightlyLogFile.is_open())//this file is the only one that has not been closed by GoToReadyPlease
    1098967    {
    1099         dim_lock();
     968//        dim_lock();
    1100969        fNightlyLogFile.close();
    1101         dim_unlock();
     970//        dim_unlock();
    1102971    }
    1103972
     
    1105974        Debug("DataLogger desctruction ends");   
    1106975}
    1107 // --------------------------------------------------------------------------
    1108 //
    1109 //! checks if the statistic service should be updated, and if so, do it
    1110 //
    1111 /*void DataLogger::UpdateStatisticsService()
    1112 {
    1113     //update the fits files sizes
    1114     const Time cTime = Time();
    1115 
    1116     if ((fStatsPeriodDuration == 0) || ((cTime - fPreviousStatsUpdateTime).total_seconds() < fStatsPeriodDuration))
    1117         return;
    1118 
    1119     calculateTotalSizeWritten(fStatVar, false);
    1120     fStatVar.writingRate = (fStatVar.sizeWritten - fPreviousSize)/((cTime - fPreviousStatsUpdateTime).total_seconds());
    1121     fPreviousSize = fStatVar.sizeWritten;
    1122     fPreviousStatsUpdateTime = cTime;
    1123     //update the service. No need to check if data has been written, because some must have been, otherwise we would not have hit this piece of code
    1124     if (fStatVar.writingRate < 0)
    1125         fStatVar.writingRate = 0;
    1126     if (fStatVar.sizeWritten < 0)
    1127         fStatVar.sizeWritten = 0;
    1128     fStatsMonitoring->updateService();
    1129 
    1130     if(fDebugIsOn)
    1131     {
    1132         ostringstream str;
    1133         str << "Size written: " << fStatVar.sizeWritten/1000 << " kB; writing rate: ";
    1134         str << fStatVar.writingRate/1000 << " kB/s; free space: ";
    1135         str << fStatVar.freeSpace/(1000*1000) << " MB";
    1136         Debug(str);
    1137     }
    1138 }*/
     976
    1139977// --------------------------------------------------------------------------
    1140978//
     
    11641002    if (I==NULL)
    11651003        return;
    1166 
    1167     //it may happen that we try to write a dimInfo while closing files. Prevent that with a dim_lock()
    1168 //    dim_lock();
    11691004
    11701005    //check if the service pointer corresponds to something that we subscribed to
     
    11871022    {
    11881023        DimServiceInfoList::infoHandler();
    1189 //        dim_unlock();
    11901024        return;
    11911025    }
    11921026    if (I->getSize() <= 0 || I->getData()==NULL)
    11931027    {
    1194 //        dim_unlock();
    11951028        return;
    11961029    }
     
    12071040    if (I->getTimestamp() == 0)
    12081041    {
    1209 //        dim_unlock();
    12101042        return;
    12111043    }
     
    12171049
    12181050    ReportPlease(I, y->second);
    1219 
    1220 //    dim_unlock();
    1221     //update the fits files sizes
    1222  //   UpdateStatisticsService();
    12231051
    12241052    //remove old run numbers
     
    12811109#ifdef RUN_LOGS
    12821110    fFilesStats.FileOpened(run.logName);
    1283 //    RememberFileOrigSizePlease(run.logName, false);
    12841111#endif
    1285 //    RememberFileOrigSizePlease(run.reportName, false);
    12861112    fFilesStats.FileOpened(run.reportName);
    12871113    //TODO this notification scheme might be messed up now.... fix it !
     
    17461572int DataLogger::SetStatsPeriod(const Event& evt)
    17471573{
    1748 /*    const float backupDuration = fStatsPeriodDuration;
    1749 
    1750     fStatsPeriodDuration = evt.GetFloat();
    1751 
    1752     if (fStatsPeriodDuration < 0)
    1753     {
    1754         Error("Statistics period duration should be greater than zero. Discarding provided value.");
    1755         fStatsPeriodDuration = backupDuration;
    1756         return GetCurrentState();   
    1757     }
    1758     if (!finite(fStatsPeriodDuration))// != fStatsPeriodDuration)
    1759     {
    1760         Error("Provided duration does not appear to be a valid float. Discarding it.");
    1761         fStatsPeriodDuration = backupDuration;
    1762         return GetCurrentState();   
    1763     }
    1764     if (backupDuration == fStatsPeriodDuration)
    1765         Warn("Statistics period not modified. Supplied value already in use.");
    1766 
    1767     if (fStatsPeriodDuration == 0.0f)
    1768         Message("Statistics are now OFF");
    1769     else
    1770     {
    1771         ostringstream str;
    1772         str << "Statistics period is now " << fStatsPeriodDuration << " seconds";
    1773         Message(str);
    1774     }
    1775 */
    17761574    fFilesStats.SetUpdateInterval(evt.GetShort());
    17771575    return GetCurrentState();
     
    19871785        return kSM_BadNightlyConfig;
    19881786    }
    1989     //get the size of the newly opened file.
    1990 //    fBaseSizeNightly = GetFileSize(fFullNightlyLogFileName);
    1991 //    fBaseSizeNightly += GetFileSize(fFullNightlyReportFileName);
    1992 //    fFileSizesMap.clear();
    1993 //    fBaseSizeRun = 0;
    1994 //    fPreviousSize = 0;
    1995 //    fFilesStats.Reset();
     1787
    19961788    fFilesStats.FileOpened(fFullNightlyLogFileName);
    19971789    fFilesStats.FileOpened(fFullNightlyReportFileName);
     
    20531845        //get the size of the file we're about to open
    20541846        if (fFilesStats.FileOpened(partialName))
    2055 //        if (RememberFileOrigSizePlease(partialName, true))//and remember that the file was opened (i.e. not an update)
    20561847            fOpenedNightlyFits[fileNameOnly].push_back(serviceName);
    20571848
     
    20591850        {
    20601851            GoToRunWriteErrorState();
    2061             //SetCurrentState(kSM_WriteError);
    20621852            return;
    20631853        }
     
    20901880        //get the size of the file we're about to open
    20911881        if (fFilesStats.FileOpened(partialName))
    2092 //        if (RememberFileOrigSizePlease(partialName, false))//and remember that the file was opened (i.e. not an update)
    20931882            cRunNumber->openedFits[fileNameOnly].push_back(serviceName);
    20941883        else
     
    21091898                str << "Open FITS file " << partialName << ": " << e.message();
    21101899                Error(str);
    2111                 cRunNumber->runFitsFile = shared_ptr<CCfits::FITS>();//NULL;
     1900                cRunNumber->runFitsFile = shared_ptr<CCfits::FITS>();
    21121901                GoToRunWriteErrorState();
    2113                 //SetCurrentState(kSM_WriteError);
    21141902                return;
    21151903            }
    21161904
    21171905        const string baseFileName = CompileFileNameWithPath(fRunFilePath, sub.runNumber, "", "");
    2118         NotifyOpenedFile(baseFileName, 7, fOpenedRunFiles);// + '_' + serviceName, 4);
     1906        NotifyOpenedFile(baseFileName, 7, fOpenedRunFiles);
    21191907
    21201908        if (hasGrouping)
     
    21231911            {
    21241912                GoToRunWriteErrorState();
    2125                 //SetCurrentState(kSM_WriteError);
    21261913                return;
    21271914            }
     
    21321919            {
    21331920                GoToRunWriteErrorState();
    2134                 //SetCurrentState(kSM_WriteError);
    21351921                return;
    21361922            }
     
    22162002                GoToNightlyWriteErrorState();
    22172003                return;
    2218               //SetCurrentState(kSM_WriteError);
    22192004            }
    22202005         }
     
    22272012                GoToRunWriteErrorState();
    22282013                return;
    2229                 //SetCurrentState(kSM_WriteError);
    22302014            }
    22312015        }
     
    24812265       StopRunPlease();
    24822266   //it may be that dim tries to write a dimInfo while we're closing files. Prevent that
    2483 //   dim_lock();
    24842267   const string baseFileName = CompileFileNameWithPath(fNightlyFilePath, "", "");
    2485 //we should log everything that we can, even if in Ready state. thus removing this closing (done only in the destructor or at day-change)
    2486 //   if (fNightlyLogFile.is_open() && !fDestructing)//in case we're destructing the datalogger, wait before closing the log file.
    2487 //    {
    2488 //        fNightlyLogFile.close();
    2489 //        Info("Closed: "+baseFileName+".log");
    2490 //    }
     2268
    24912269    if (fNightlyReportFile.is_open())
    24922270    {
     
    25132291    CreateFitsGrouping(fOpenedNightlyFits, 0);
    25142292#endif
    2515 //    dim_unlock();
    25162293    return kSM_Ready;
    25172294}
     
    25672344
    25682345    //Adding entries that should ALWAYS be ignored
    2569     //fBlackList.insert("DATA_LOGGER/");
     2346    fBlackList.insert("DATA_LOGGER/MESSAGE");
    25702347    fBlackList.insert("/SERVICE_LIST");
    25712348    fBlackList.insert("DIS_DNS/");
     
    26042381         if (!OpenTextFilePlease(fNightlyLogFile, fFullNightlyLogFileName))
    26052382             SetCurrentState(kSM_BadNightlyConfig);
    2606     }
     2383         else
     2384         {
     2385             NotifyOpenedFile(fFullNightlyLogFileName, 1, fOpenedNightlyFiles);
     2386            for (vector<string>::iterator it=backLogBuffer.begin();it!=backLogBuffer.end();it++)
     2387                fNightlyLogFile << *it << endl;
     2388         }
     2389    }
     2390
     2391    shouldBackLog = false;
     2392    backLogBuffer.clear();
    26072393
    26082394    //configure the interval between statistics updates
     
    26192405}
    26202406
    2621 // --------------------------------------------------------------------------
    2622 /*
    2623  int RunDim(Configuration &conf)
    2624 {
    2625     WindowLog wout;
    2626 
    2627     ReadlineColor::PrintBootMsg(wout, conf.GetName(), false);
    2628 
    2629     //log.SetWindow(stdscr);
    2630     if (conf.Has("log"))
    2631         if (!wout.OpenLogFile(conf.Get<string>("log")))
    2632             wout << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl;
    2633 
    2634     // Start io_service.Run to use the StateMachineImp::Run() loop
    2635     // Start io_service.run to only use the commandHandler command detaching
    2636     DataLogger logger(wout);
    2637     if (!logger.EvalConfiguration(conf))
    2638         return -1;
    2639 
    2640     logger.Run(true);
    2641 
    2642     return 0;
    2643 }
    2644 */
    2645 // --------------------------------------------------------------------------
    26462407
    26472408#include "Main.h"
    2648 /*
    2649 void RunThread(DataLogger* logger)
    2650 {
    2651     // This is necessary so that the StateMachine Thread can signal the
    2652     // Readline thread to exit
    2653     logger->Run(true);
    2654     Readline::Stop();   
    2655 }
    2656 */
     2409
    26572410// --------------------------------------------------------------------------
    26582411template<class T>
     
    26602413{
    26612414    return Main<T, DataLogger>(conf, true);
    2662 /*
    2663     static T shell(conf.GetName().c_str(), conf.Get<int>("console")!=1);
    2664 
    2665     WindowLog &win  = shell.GetStreamIn();
    2666     WindowLog &wout = shell.GetStreamOut();
    2667 
    2668     if (conf.Has("log"))
    2669         if (!wout.OpenLogFile(conf.Get<string>("log")))
    2670             win << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl;
    2671 
    2672     DataLogger logger(wout);
    2673 
    2674     if (!logger.EvalConfiguration(conf))
    2675         return -1;
    2676    
    2677     shell.SetReceiver(logger);
    2678 
    2679     boost::thread t(boost::bind(RunThread, &logger));
    2680 
    2681     if (conf.Has("cmd"))
    2682     {
    2683         const vector<string> v = conf.Get<vector<string>>("cmd");
    2684         for (vector<string>::const_iterator it=v.begin(); it!=v.end(); it++)
    2685             shell.ProcessLine(*it);
    2686     }
    2687 
    2688     if (conf.Has("exec"))
    2689     {
    2690         const vector<string> v = conf.Get<vector<string>>("exec");
    2691         for (vector<string>::const_iterator it=v.begin(); it!=v.end(); it++)
    2692             shell.Execute(*it);
    2693     }
    2694 
    2695     if (conf.Get<bool>("quit"))
    2696         shell.Stop();
    2697 
    2698    
    2699     shell.Run(); // Run the shell
    2700    
    2701     logger.Stop();
    2702    
    2703     //Wait until the StateMachine has finished its thread
    2704     //before returning and destroyinng the dim objects which might
    2705     //still be in use.
    2706     t.join();
    2707 
    2708     return 0;
    2709 */
    27102415}
    27112416
Note: See TracChangeset for help on using the changeset viewer.