Changeset 10534 for trunk/FACT++


Ignore:
Timestamp:
05/03/11 18:19:26 (13 years ago)
Author:
tbretz
Message:
Added some code to get rid of the getcwd warning - we have to go through all warnings and errors again anyway; use the build in boolean for the commands
File:
1 edited

Legend:

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

    r10529 r10534  
    321321        int SetOpenedFilesOnOff(const Event& evt);
    322322        int SetNumSubsAndFitsOnOff(const Event& evt);
    323         bool getBooleanFromString(const std::string&);
    324323        ///boolean to prevent DIM update while desctructing the dataLogger
    325324        bool fDestructing;     
     
    559558                fNumSubAndFitsIsOn = true;
    560559                //provide services control commands
    561                 AddConfiguration(fDebugOnOff, "C", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready)
     560                AddConfiguration(fDebugOnOff, "B:1", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready)
    562561                                (boost::bind(&DataLogger::SetDebugOnOff, this, _1));
    563562                AddConfiguration(fStatsPeriod, "F", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready)
    564563                                (boost::bind(&DataLogger::SetStatsPeriod, this, _1));
    565                 AddConfiguration(fStartStopOpenedFiles, "C", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready)
     564                AddConfiguration(fStartStopOpenedFiles, "B:1", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready)
    566565                                (boost::bind(&DataLogger::SetOpenedFilesOnOff ,this, _1));
    567                 AddConfiguration(fStartStopNumSubsAndFits, "C", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready)
     566                AddConfiguration(fStartStopNumSubsAndFits, "B:1", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready)
    568567                                (boost::bind(&DataLogger::SetNumSubsAndFitsOnOff, this, _1));
    569568                fDestructing = false;
     
    11011100        if (fNightlyFileName == ".")
    11021101        {
    1103                 char currentPath[FILENAME_MAX];
    1104                 getcwd(currentPath, sizeof(currentPath));
    1105                 actualTargetDir = currentPath;
    1106         }
     1102            char currentPath[FILENAME_MAX];
     1103            if (getcwd(currentPath, sizeof(currentPath)))
     1104                actualTargetDir = currentPath;
     1105        }
    11071106        else
    11081107                actualTargetDir = fNightlyFileName;
     
    11101109        if (fRunFileName == ".")
    11111110        {
    1112                 char currentPath[FILENAME_MAX];
    1113                 getcwd(currentPath, sizeof(currentPath));
    1114                 actualTargetDir = currentPath;
     1111            char currentPath[FILENAME_MAX];
     1112            if (getcwd(currentPath, sizeof(currentPath)))
     1113                actualTargetDir = currentPath;
    11151114        }
    11161115        else
     
    12381237        return GetCurrentState();
    12391238}
    1240 // --------------------------------------------------------------------------
    1241 //
    1242 //! figure out whether the string means on or off
    1243 //! @param evt
    1244 //!             the current event. contains the instruction string: On, Off, on, off, ON, OFF, 0 or 1
    1245 //! @returns
    1246 //!             the equivalent boolean
    1247 //!
    1248 bool DataLogger::getBooleanFromString(const std::string& str)
    1249 {
    1250         if (str == "On" || str == "ON" || str == "on" || str == "1")
    1251                 return true;
    1252         if (str == "Off" || str == "OFF" || str == "off" || str == "0")
    1253                 return false;
    1254         Error("Argument could not be converted to boolean. please use On/on/ON/1 or Off/off/OFF/0. defaulting to false.");
    1255         return false;
    1256 }
     1239
    12571240// --------------------------------------------------------------------------
    12581241//
     
    12661249{
    12671250        bool backupDebug = fDebugIsOn;
    1268         fDebugIsOn = getBooleanFromString(evt.GetText());
     1251        fDebugIsOn = evt.GetBool();
    12691252        if (fDebugIsOn == backupDebug)
    12701253                Warn("Warning: debug mode was already in the requested state");
     
    12721255        {
    12731256                stringstream str;
    1274                 str << "Debug mode is now " << evt.GetText();
     1257                str << "Debug mode is now " << fDebugIsOn;
    12751258                Message(str.str());
    12761259        }
     
    13271310{
    13281311        bool backupOpened = fOpenedFilesIsOn;
    1329         fOpenedFilesIsOn = getBooleanFromString(evt.GetText());
     1312        fOpenedFilesIsOn = evt.GetBool();
    13301313        if (fOpenedFilesIsOn == backupOpened)
    13311314                Warn("Warning: opened files service mode was already in the requested state");
     
    13331316        {
    13341317                stringstream str;
    1335                 str << "Opened files service mode is now " << evt.GetText();
     1318                str << "Opened files service mode is now " << fOpenedFilesIsOn;
    13361319                Message(str.str());
    13371320        }
     
    13501333{
    13511334        bool backupSubs = fNumSubAndFitsIsOn;
    1352         fNumSubAndFitsIsOn = getBooleanFromString(evt.GetText());
     1335        fNumSubAndFitsIsOn = evt.GetBool();
    13531336        if (fNumSubAndFitsIsOn == backupSubs)
    13541337                Warn("Warning: Number of subscriptions service mode was already in the requested state");
     
    13561339        {
    13571340                stringstream str;
    1358                 str << "Number of subscriptions service mode is now " << evt.GetText();
     1341                str << "Number of subscriptions service mode is now " << fNumSubAndFitsIsOn;
    13591342                Message(str.str());
    13601343        }
     
    14971480        {
    14981481                char currentPath[FILENAME_MAX];
    1499                 getcwd(currentPath, sizeof(currentPath));
    1500                 if (errno != 0)
    1501                 {
    1502                         std::stringstream str;
    1503                         str << "Unable retrieve current path" << ". Reason: " << strerror(errno) << " [" << errno << "]";
    1504                         Error(str);     
    1505                 }
    1506                 actualTargetDir = currentPath;
     1482                if (!getcwd(currentPath, sizeof(currentPath)))
     1483                {
     1484                    if (errno != 0)
     1485                    {
     1486                        std::stringstream str;
     1487                        str << "Unable retrieve current path" << ". Reason: " << strerror(errno) << " [" << errno << "]";
     1488                        Error(str);
     1489                    }
     1490                }
     1491                actualTargetDir = currentPath;
    15071492        }
    15081493        else
     
    15551540                {
    15561541                        char currentPath[FILENAME_MAX];
    1557                         getcwd(currentPath, sizeof(currentPath));
    1558                         actualTargetDir = currentPath;
     1542                        if (getcwd(currentPath, sizeof(currentPath)))
     1543                            actualTargetDir = currentPath;
    15591544                }
    15601545                else
     
    16111596                        {
    16121597                                char currentPath[FILENAME_MAX];
    1613                                 getcwd(currentPath, sizeof(currentPath));
    1614                                 actualTargetDir = currentPath;
     1598                                if (getcwd(currentPath, sizeof(currentPath)))
     1599                                    actualTargetDir = currentPath;
    16151600                        }
    16161601                        else
     
    18111796        {
    18121797                char currentPath[FILENAME_MAX];
    1813                 getcwd(currentPath, sizeof(currentPath));
    1814                 if (errno != 0)
    1815                 {
    1816                         std::stringstream str;
    1817                         str << "Unable to retrieve the current path" << ". Reason: " << strerror(errno) << " [" << errno << "]";
    1818                         Error(str);     
    1819                 }               
     1798                if (!getcwd(currentPath, sizeof(currentPath)))
     1799                {
     1800                    if (errno != 0)
     1801                    {
     1802                        std::stringstream str;
     1803                        str << "Unable to retrieve the current path" << ". Reason: " << strerror(errno) << " [" << errno << "]";
     1804                        Error(str);
     1805                    }
     1806                }
    18201807                actualTargetDir = currentPath;
    18211808        }
Note: See TracChangeset for help on using the changeset viewer.