void CWakeOnAccess::SaveToXML() { CXBMCTinyXML xmlDoc; TiXmlElement xmlRootElement("onaccesswakeup"); TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement); if (!pRoot) return; XMLUtils::SetInt(pRoot, "netinittimeout", m_netinit_sec); XMLUtils::SetInt(pRoot, "netsettletime", m_netsettle_ms); for (EntriesVector::const_iterator i = m_entries.begin(); i != m_entries.end(); ++i) { TiXmlElement xmlSetting("wakeup"); TiXmlNode* pWakeUpNode = pRoot->InsertEndChild(xmlSetting); if (pWakeUpNode) { XMLUtils::SetString(pWakeUpNode, "host", i->host); XMLUtils::SetString(pWakeUpNode, "mac", i->mac); XMLUtils::SetInt(pWakeUpNode, "pingport", i->ping_port); XMLUtils::SetInt(pWakeUpNode, "pingmode", i->ping_mode); XMLUtils::SetInt(pWakeUpNode, "timeout", GetTotalSeconds(i->timeout)); XMLUtils::SetInt(pWakeUpNode, "waitonline", i->wait_online1_sec); XMLUtils::SetInt(pWakeUpNode, "waitonline2", i->wait_online2_sec); XMLUtils::SetInt(pWakeUpNode, "waitservices", i->wait_services_sec); } } xmlDoc.SaveFile(GetSettingFile()); }
void CAlarmHandler::LogFault(DataDictionary alarmdata) { std::string filename; std::vector<DataDictionary> tempdata; tempdata.push_back(alarmdata); // Use blank types... Duration already formatted to hr:min:sec // Write to common fault history file for display { boost::mutex::scoped_lock lock(_alarm_mutex); filename=_archivepath+"AlarmHistory.csv"; _csvarchiver.append(filename.c_str(),_faultitems, DataDictionary(), tempdata); } // Use blank types... TBF,TTR formatted to hr:min:sec change back to seconds filename=_archivepath+this->_sMachine+"AlarmHistory.csv"; tempdata.back()["TBF"] = ToString<double>(GetTotalSeconds(alarmdata["TBF"])); tempdata.back()["TTR"] = ToString<double>(GetTotalSeconds(alarmdata["TTR"])); // We are skipping the first fault, if the timing is just started from when we started. Skews #s. if(!_bRejectFirstMtbf) _csvarchiver.append(filename.c_str(),_faultitems, DataDictionary(), tempdata); _bRejectFirstMtbf=false; }
FString FTimespan::ToString( const TCHAR* Format ) const { FString Result; while (*Format != TCHAR('\0')) { if ((*Format == TCHAR('%')) && (*++Format != TCHAR('\0'))) { switch (*Format) { case TCHAR('n'): if (Ticks < 0) Result += TCHAR('-'); break; case TCHAR('N'): Result += (Ticks < 0) ? TCHAR('-') : TCHAR('+'); break; case TCHAR('d'): Result += FString::Printf(TEXT("%i"), FMath::Abs(GetDays())); break; case TCHAR('h'): Result += FString::Printf(TEXT("%02i"), FMath::Abs(GetHours())); break; case TCHAR('m'): Result += FString::Printf(TEXT("%02i"), FMath::Abs(GetMinutes())); break; case TCHAR('s'): Result += FString::Printf(TEXT("%02i"), FMath::Abs(GetSeconds())); break; case TCHAR('f'): Result += FString::Printf(TEXT("%03i"), FMath::Abs(GetMilliseconds())); break; case TCHAR('D'): Result += FString::Printf(TEXT("%f"), FMath::Abs(GetTotalDays())); break; case TCHAR('H'): Result += FString::Printf(TEXT("%f"), FMath::Abs(GetTotalHours())); break; case TCHAR('M'): Result += FString::Printf(TEXT("%f"), FMath::Abs(GetTotalMinutes())); break; case TCHAR('S'): Result += FString::Printf(TEXT("%f"), FMath::Abs(GetTotalSeconds())); break; case TCHAR('F'): Result += FString::Printf(TEXT("%f"), FMath::Abs(GetTotalMilliseconds())); break; default: Result += *Format; } } else { Result += *Format; } ++Format; } return Result; }
void CWakeOnAccess::LoadFromXML() { bool enabled = CSettings::GetInstance().GetBool(CSettings::SETTING_POWERMANAGEMENT_WAKEONACCESS); CXBMCTinyXML xmlDoc; if (!xmlDoc.LoadFile(GetSettingFile())) { if (enabled) CLog::Log(LOGNOTICE, "%s - unable to load:%s", __FUNCTION__, GetSettingFile().c_str()); return; } TiXmlElement* pRootElement = xmlDoc.RootElement(); if (strcmpi(pRootElement->Value(), "onaccesswakeup")) { CLog::Log(LOGERROR, "%s - XML file %s doesnt contain <onaccesswakeup>", __FUNCTION__, GetSettingFile().c_str()); return; } m_entries.clear(); CLog::Log(LOGNOTICE,"WakeOnAccess - Load settings :"); SetEnabled(enabled); int tmp; if (XMLUtils::GetInt(pRootElement, "netinittimeout", tmp, 0, 5 * 60)) m_netinit_sec = tmp; CLog::Log(LOGNOTICE," -Network init timeout : [%d] sec", m_netinit_sec); if (XMLUtils::GetInt(pRootElement, "netsettletime", tmp, 0, 5 * 1000)) m_netsettle_ms = tmp; CLog::Log(LOGNOTICE," -Network settle time : [%d] ms", m_netsettle_ms); const TiXmlNode* pWakeUp = pRootElement->FirstChildElement("wakeup"); while (pWakeUp) { WakeUpEntry entry; std::string strtmp; if (XMLUtils::GetString(pWakeUp, "host", strtmp)) entry.host = strtmp; if (XMLUtils::GetString(pWakeUp, "mac", strtmp)) entry.mac = strtmp; if (entry.host.empty()) CLog::Log(LOGERROR, "%s - Missing <host> tag or it's empty", __FUNCTION__); else if (entry.mac.empty()) CLog::Log(LOGERROR, "%s - Missing <mac> tag or it's empty", __FUNCTION__); else { if (XMLUtils::GetInt(pWakeUp, "pingport", tmp, 0, USHRT_MAX)) entry.ping_port = (unsigned short) tmp; if (XMLUtils::GetInt(pWakeUp, "pingmode", tmp, 0, USHRT_MAX)) entry.ping_mode = (unsigned short) tmp; if (XMLUtils::GetInt(pWakeUp, "timeout", tmp, 10, 12 * 60 * 60)) entry.timeout.SetDateTimeSpan (0, 0, 0, tmp); if (XMLUtils::GetInt(pWakeUp, "waitonline", tmp, 0, 10 * 60)) // max 10 minutes entry.wait_online1_sec = tmp; if (XMLUtils::GetInt(pWakeUp, "waitonline2", tmp, 0, 10 * 60)) // max 10 minutes entry.wait_online2_sec = tmp; if (XMLUtils::GetInt(pWakeUp, "waitservices", tmp, 0, 5 * 60)) // max 5 minutes entry.wait_services_sec = tmp; CLog::Log(LOGNOTICE," Registering wakeup entry:"); CLog::Log(LOGNOTICE," HostName : %s", entry.host.c_str()); CLog::Log(LOGNOTICE," MacAddress : %s", entry.mac.c_str()); CLog::Log(LOGNOTICE," PingPort : %d", entry.ping_port); CLog::Log(LOGNOTICE," PingMode : %d", entry.ping_mode); CLog::Log(LOGNOTICE," Timeout : %d (sec)", GetTotalSeconds(entry.timeout)); CLog::Log(LOGNOTICE," WaitForOnline : %d (sec)", entry.wait_online1_sec); CLog::Log(LOGNOTICE," WaitForOnlineEx : %d (sec)", entry.wait_online2_sec); CLog::Log(LOGNOTICE," WaitForServices : %d (sec)", entry.wait_services_sec); m_entries.push_back(entry); } pWakeUp = pWakeUp->NextSiblingElement("wakeup"); // get next one } }
LONG CMSTimeSpan::GetSeconds() const throw() { return( LONG( GetTotalSeconds()-(GetTotalMinutes()*60) ) ); }
// Gets number of seconds that have passed since last minute. DWORD CMMTimer::GetCurrentSeconds() const { return GetTotalSeconds() - GetTotalMinutes() * SECONDS_PER_MINUTE; }
// Gets number of milliseconds that have passed since the last second. DWORD CMMTimer::GetCurrentMilliseconds() const { return m_Milliseconds - GetTotalSeconds() * MILLISECONDS_PER_SECOND; }
// Gets total number of minutes that have passed since this timer began. DWORD CMMTimer::GetTotalMinutes() const { return GetTotalSeconds() / SECONDS_PER_MINUTE; }
long sltimespan::GetSeconds() const throw() { return( long( GetTotalSeconds()-(GetTotalMinutes()*60) ) ); }