SysInfo: Added "Idle_Time" type. Use "SysInfoData to scale the output.

This commit is contained in:
Brian Ferguson 2014-02-23 10:55:44 -07:00
parent 7a1c0f6e78
commit de91403db9

View File

@ -44,6 +44,7 @@ enum MeasureType
MEASURE_RAS_STATUS, MEASURE_RAS_STATUS,
MEASURE_OS_VERSION, MEASURE_OS_VERSION,
MEASURE_OS_BITS, MEASURE_OS_BITS,
MEASURE_IDLE_TIME,
MEASURE_ADAPTER_DESCRIPTION, MEASURE_ADAPTER_DESCRIPTION,
MEASURE_NET_MASK, MEASURE_NET_MASK,
MEASURE_IP_ADDRESS, MEASURE_IP_ADDRESS,
@ -132,6 +133,11 @@ PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{ {
measure->type = MEASURE_OS_BITS; measure->type = MEASURE_OS_BITS;
} }
else if (_wcsicmp(L"IDLE_TIME", type) == 0)
{
defaultData = 1;
measure->type = MEASURE_IDLE_TIME;
}
else if (_wcsicmp(L"ADAPTER_DESCRIPTION", type) == 0) else if (_wcsicmp(L"ADAPTER_DESCRIPTION", type) == 0)
{ {
defaultData = 0; defaultData = 0;
@ -388,6 +394,14 @@ PLUGIN_EXPORT double Update(void* data)
si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) ? 64.0 : 32.0; si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) ? 64.0 : 32.0;
} }
case MEASURE_IDLE_TIME:
{
LASTINPUTINFO idle = { sizeof(LASTINPUTINFO) };
GetLastInputInfo(&idle);
int scale = (measure->data < 1) ? 1 : measure->data;
return (double)((GetTickCount() - idle.dwTime) / scale);
}
case MEASURE_INTERNET_CONNECTIVITY: case MEASURE_INTERNET_CONNECTIVITY:
{ {
const auto connectivity = GetNetworkConnectivity(); const auto connectivity = GetNetworkConnectivity();