Changeset 10534 for trunk/FACT++
- Timestamp:
- 05/03/11 18:19:26 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/dataLogger.cc
r10529 r10534 321 321 int SetOpenedFilesOnOff(const Event& evt); 322 322 int SetNumSubsAndFitsOnOff(const Event& evt); 323 bool getBooleanFromString(const std::string&);324 323 ///boolean to prevent DIM update while desctructing the dataLogger 325 324 bool fDestructing; … … 559 558 fNumSubAndFitsIsOn = true; 560 559 //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) 562 561 (boost::bind(&DataLogger::SetDebugOnOff, this, _1)); 563 562 AddConfiguration(fStatsPeriod, "F", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready) 564 563 (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) 566 565 (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) 568 567 (boost::bind(&DataLogger::SetNumSubsAndFitsOnOff, this, _1)); 569 568 fDestructing = false; … … 1101 1100 if (fNightlyFileName == ".") 1102 1101 { 1103 1104 getcwd(currentPath, sizeof(currentPath)); 1105 1106 1102 char currentPath[FILENAME_MAX]; 1103 if (getcwd(currentPath, sizeof(currentPath))) 1104 actualTargetDir = currentPath; 1105 } 1107 1106 else 1108 1107 actualTargetDir = fNightlyFileName; … … 1110 1109 if (fRunFileName == ".") 1111 1110 { 1112 1113 getcwd(currentPath, sizeof(currentPath)); 1114 1111 char currentPath[FILENAME_MAX]; 1112 if (getcwd(currentPath, sizeof(currentPath))) 1113 actualTargetDir = currentPath; 1115 1114 } 1116 1115 else … … 1238 1237 return GetCurrentState(); 1239 1238 } 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 1257 1240 // -------------------------------------------------------------------------- 1258 1241 // … … 1266 1249 { 1267 1250 bool backupDebug = fDebugIsOn; 1268 fDebugIsOn = getBooleanFromString(evt.GetText());1251 fDebugIsOn = evt.GetBool(); 1269 1252 if (fDebugIsOn == backupDebug) 1270 1253 Warn("Warning: debug mode was already in the requested state"); … … 1272 1255 { 1273 1256 stringstream str; 1274 str << "Debug mode is now " << evt.GetText();1257 str << "Debug mode is now " << fDebugIsOn; 1275 1258 Message(str.str()); 1276 1259 } … … 1327 1310 { 1328 1311 bool backupOpened = fOpenedFilesIsOn; 1329 fOpenedFilesIsOn = getBooleanFromString(evt.GetText());1312 fOpenedFilesIsOn = evt.GetBool(); 1330 1313 if (fOpenedFilesIsOn == backupOpened) 1331 1314 Warn("Warning: opened files service mode was already in the requested state"); … … 1333 1316 { 1334 1317 stringstream str; 1335 str << "Opened files service mode is now " << evt.GetText();1318 str << "Opened files service mode is now " << fOpenedFilesIsOn; 1336 1319 Message(str.str()); 1337 1320 } … … 1350 1333 { 1351 1334 bool backupSubs = fNumSubAndFitsIsOn; 1352 fNumSubAndFitsIsOn = getBooleanFromString(evt.GetText());1335 fNumSubAndFitsIsOn = evt.GetBool(); 1353 1336 if (fNumSubAndFitsIsOn == backupSubs) 1354 1337 Warn("Warning: Number of subscriptions service mode was already in the requested state"); … … 1356 1339 { 1357 1340 stringstream str; 1358 str << "Number of subscriptions service mode is now " << evt.GetText();1341 str << "Number of subscriptions service mode is now " << fNumSubAndFitsIsOn; 1359 1342 Message(str.str()); 1360 1343 } … … 1497 1480 { 1498 1481 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; 1507 1492 } 1508 1493 else … … 1555 1540 { 1556 1541 char currentPath[FILENAME_MAX]; 1557 getcwd(currentPath, sizeof(currentPath));1558 1542 if (getcwd(currentPath, sizeof(currentPath))) 1543 actualTargetDir = currentPath; 1559 1544 } 1560 1545 else … … 1611 1596 { 1612 1597 char currentPath[FILENAME_MAX]; 1613 getcwd(currentPath, sizeof(currentPath)); 1614 1598 if (getcwd(currentPath, sizeof(currentPath))) 1599 actualTargetDir = currentPath; 1615 1600 } 1616 1601 else … … 1811 1796 { 1812 1797 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 } 1820 1807 actualTargetDir = currentPath; 1821 1808 }
Note:
See TracChangeset
for help on using the changeset viewer.