Fixed: IfActions not fired when measure is disabled

This commit is contained in:
Birunthan Mohanathas 2012-05-30 09:46:11 +03:00
parent 8fb0be30d4
commit 9623766a61
32 changed files with 125 additions and 214 deletions

View File

@ -424,85 +424,74 @@ std::wstring CMeasure::ExtractWord(std::wstring& buffer)
return ret; return ret;
} }
/* bool CMeasure::Update()
** The base implementation of the update method. This includes the code
** that is common for all measures. This is called every time the measure
** is updated. The inherited classes must call the base implementation if
** they overwrite this method. If this method returns false, the update
** needs not to be done.
**
*/
bool CMeasure::PreUpdate()
{ {
if (IsDisabled()) bool update = !IsDisabled();
if (update)
{ {
m_Value = 0.0; // Disable measures return 0 as value // Only update the counter if the divider
return false; ++m_UpdateCounter;
if (m_UpdateCounter < m_UpdateDivider) return false;
m_UpdateCounter = 0;
// If we're logging the maximum value of the measure, check if
// the new value is greater than the old one, and update if necessary.
if (m_LogMaxValue)
{
if (m_MedianMaxValues.empty())
{
m_MedianMaxValues.resize(MEDIAN_SIZE, 0);
m_MedianMinValues.resize(MEDIAN_SIZE, 0);
}
m_MedianMaxValues[m_MedianPos] = m_Value;
m_MedianMinValues[m_MedianPos] = m_Value;
++m_MedianPos;
m_MedianPos %= MEDIAN_SIZE;
std::vector<double> medianArray;
medianArray = m_MedianMaxValues;
std::sort(medianArray.begin(), medianArray.end());
m_MaxValue = max(m_MaxValue, medianArray[MEDIAN_SIZE / 2]);
medianArray = m_MedianMinValues;
std::sort(medianArray.begin(), medianArray.end());
m_MinValue = min(m_MinValue, medianArray[MEDIAN_SIZE / 2]);
}
// Call derived method to update value
UpdateValue();
if (m_AverageSize > 0)
{
size_t averageValuesSize = m_AverageValues.size();
if (m_AverageSize != averageValuesSize)
{
m_AverageValues.resize(m_AverageSize, m_Value);
averageValuesSize = m_AverageValues.size();
if (m_AveragePos >= averageValuesSize) m_AveragePos = 0;
}
m_AverageValues[m_AveragePos] = m_Value;
++m_AveragePos;
m_AveragePos %= averageValuesSize;
// Calculate the average value
m_Value = 0;
for (size_t i = 0; i < averageValuesSize; ++i)
{
m_Value += m_AverageValues[i];
}
m_Value /= (double)averageValuesSize;
}
} }
else
// Only update the counter if the divider
++m_UpdateCounter;
if (m_UpdateCounter < m_UpdateDivider) return false;
m_UpdateCounter = 0;
// If we're logging the maximum value of the measure, check if
// the new value is greater than the old one, and update if necessary.
if (m_LogMaxValue)
{ {
if (m_MedianMaxValues.empty()) // Disabled measures have 0 as value
{ m_Value = 0.0;
m_MedianMaxValues.resize(MEDIAN_SIZE, 0);
m_MedianMinValues.resize(MEDIAN_SIZE, 0);
}
m_MedianMaxValues[m_MedianPos] = m_Value;
m_MedianMinValues[m_MedianPos] = m_Value;
++m_MedianPos;
m_MedianPos %= MEDIAN_SIZE;
std::vector<double> medianArray;
medianArray = m_MedianMaxValues;
std::sort(medianArray.begin(), medianArray.end());
m_MaxValue = max(m_MaxValue, medianArray[MEDIAN_SIZE / 2]);
medianArray = m_MedianMinValues;
std::sort(medianArray.begin(), medianArray.end());
m_MinValue = min(m_MinValue, medianArray[MEDIAN_SIZE / 2]);
}
return true;
}
/*
** Does post measuring things to the value. All measures must call this
** after they have set the m_Value.
**
*/
bool CMeasure::PostUpdate()
{
if (m_AverageSize > 0)
{
size_t averageValuesSize = m_AverageValues.size();
if (m_AverageSize != averageValuesSize)
{
m_AverageValues.resize(m_AverageSize, m_Value);
averageValuesSize = m_AverageValues.size();
if (m_AveragePos >= averageValuesSize) m_AveragePos = 0;
}
m_AverageValues[m_AveragePos] = m_Value;
++m_AveragePos;
m_AveragePos %= averageValuesSize;
// Calculate the average value
m_Value = 0;
for (size_t i = 0; i < averageValuesSize; ++i)
{
m_Value += m_AverageValues[i];
}
m_Value /= (double)averageValuesSize;
} }
if (m_MeterWindow) if (m_MeterWindow)
@ -513,7 +502,7 @@ bool CMeasure::PostUpdate()
{ {
if (!m_IfEqualCommitted) if (!m_IfEqualCommitted)
{ {
m_IfEqualCommitted = true; // To avoid crashing by !Update due to infinite loop m_IfEqualCommitted = true; // To avoid infinite loop from !Update
Rainmeter->ExecuteCommand(m_IfEqualAction.c_str(), m_MeterWindow); Rainmeter->ExecuteCommand(m_IfEqualAction.c_str(), m_MeterWindow);
} }
} }
@ -529,7 +518,7 @@ bool CMeasure::PostUpdate()
{ {
if (!m_IfAboveCommitted) if (!m_IfAboveCommitted)
{ {
m_IfAboveCommitted= true; // To avoid crashing by !Update due to infinite loop m_IfAboveCommitted= true; // To avoid infinite loop from !Update
Rainmeter->ExecuteCommand(m_IfAboveAction.c_str(), m_MeterWindow); Rainmeter->ExecuteCommand(m_IfAboveAction.c_str(), m_MeterWindow);
} }
} }
@ -545,7 +534,7 @@ bool CMeasure::PostUpdate()
{ {
if (!m_IfBelowCommitted) if (!m_IfBelowCommitted)
{ {
m_IfBelowCommitted = true; // To avoid crashing by !Update due to infinite loop m_IfBelowCommitted = true; // To avoid infinite loop from !Update
Rainmeter->ExecuteCommand(m_IfBelowAction.c_str(), m_MeterWindow); Rainmeter->ExecuteCommand(m_IfBelowAction.c_str(), m_MeterWindow);
} }
} }
@ -556,7 +545,7 @@ bool CMeasure::PostUpdate()
} }
} }
return true; return update;
} }
/* /*

View File

@ -52,7 +52,7 @@ public:
void ReadConfig(CConfigParser& parser) { ReadConfig(parser, GetName()); } void ReadConfig(CConfigParser& parser) { ReadConfig(parser, GetName()); }
virtual void Initialize(); virtual void Initialize();
virtual bool Update() = 0; bool Update();
const WCHAR* GetName() { return m_Name.c_str(); } const WCHAR* GetName() { return m_Name.c_str(); }
const std::wstring& GetOriginalName() { return m_Name; } const std::wstring& GetOriginalName() { return m_Name; }
@ -86,9 +86,7 @@ public:
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue() = 0;
virtual bool PreUpdate();
virtual bool PostUpdate();
bool ParseSubstitute(std::wstring buffer); bool ParseSubstitute(std::wstring buffer);
std::wstring ExtractWord(std::wstring& buffer); std::wstring ExtractWord(std::wstring& buffer);

View File

@ -117,10 +117,8 @@ void CMeasureCPU::ReadConfig(CConfigParser& parser, const WCHAR* section)
** Updates the current CPU utilization value. ** Updates the current CPU utilization value.
** **
*/ */
bool CMeasureCPU::Update() void CMeasureCPU::UpdateValue()
{ {
if (!CMeasure::PreUpdate()) return false;
if (m_Processor == 0) if (m_Processor == 0)
{ {
BOOL status; BOOL status;
@ -128,7 +126,7 @@ bool CMeasureCPU::Update()
// get new CPU's idle/kernel/user time // get new CPU's idle/kernel/user time
status = GetSystemTimes(&ftIdleTime, &ftKernelTime, &ftUserTime); status = GetSystemTimes(&ftIdleTime, &ftKernelTime, &ftUserTime);
if (status == 0) return false; if (status == 0) return;
CalcUsage(Ft2Double(ftIdleTime), CalcUsage(Ft2Double(ftIdleTime),
Ft2Double(ftKernelTime) + Ft2Double(ftUserTime)); Ft2Double(ftKernelTime) + Ft2Double(ftUserTime));
@ -146,9 +144,7 @@ bool CMeasureCPU::Update()
ULONG size = 0; ULONG size = 0;
status = c_NtQuerySystemInformation(SystemProcessorPerformanceInformation, buf, bufSize, &size); status = c_NtQuerySystemInformation(SystemProcessorPerformanceInformation, buf, bufSize, &size);
if (status == STATUS_SUCCESS || status != STATUS_INFO_LENGTH_MISMATCH) break; if (status == STATUS_INFO_LENGTH_MISMATCH)
else // status == STATUS_INFO_LENGTH_MISMATCH
{ {
if (size == 0) // Returned required buffer size is always 0 on Windows 2000/XP. if (size == 0) // Returned required buffer size is always 0 on Windows 2000/XP.
{ {
@ -176,37 +172,33 @@ bool CMeasureCPU::Update()
delete [] buf; delete [] buf;
buf = new BYTE[bufSize]; buf = new BYTE[bufSize];
} }
else
{
break;
}
++loop; ++loop;
} }
while (loop < 5); while (loop < 5);
if (status != STATUS_SUCCESS) // failed if (status == STATUS_SUCCESS)
{ {
delete [] buf; if (bufSize != c_BufferSize)
return false; {
// Store the new buffer size
c_BufferSize = bufSize;
}
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* systemPerfInfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*)buf;
int processor = m_Processor - 1;
CalcUsage(Li2Double(systemPerfInfo[processor].IdleTime),
Li2Double(systemPerfInfo[processor].KernelTime) + Li2Double(systemPerfInfo[processor].UserTime));
} }
if (bufSize != c_BufferSize)
{
// Store the new buffer size
c_BufferSize = bufSize;
}
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* systemPerfInfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*)buf;
int processor = m_Processor - 1;
CalcUsage(Li2Double(systemPerfInfo[processor].IdleTime),
Li2Double(systemPerfInfo[processor].KernelTime) + Li2Double(systemPerfInfo[processor].UserTime));
delete [] buf; delete [] buf;
} }
else
{
return false;
}
return PostUpdate();
} }
/* /*

View File

@ -31,10 +31,9 @@ public:
virtual UINT GetTypeID() { return TypeID<CMeasureCPU>(); } virtual UINT GetTypeID() { return TypeID<CMeasureCPU>(); }
virtual bool Update();
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private: private:
void CalcUsage(double idleTime, double systemTime); void CalcUsage(double idleTime, double systemTime);

View File

@ -54,10 +54,8 @@ CMeasureCalc::~CMeasureCalc()
** Updates the calculation ** Updates the calculation
** **
*/ */
bool CMeasureCalc::Update() void CMeasureCalc::UpdateValue()
{ {
if (!CMeasure::PreUpdate()) return false;
const WCHAR* errMsg = MathParser::Parse(m_Formula.c_str(), this, &m_Value); const WCHAR* errMsg = MathParser::Parse(m_Formula.c_str(), this, &m_Value);
if (errMsg != NULL) if (errMsg != NULL)
{ {
@ -71,8 +69,6 @@ bool CMeasureCalc::Update()
{ {
m_ParseError = false; m_ParseError = false;
} }
return PostUpdate();
} }
/* /*

View File

@ -29,12 +29,11 @@ public:
virtual UINT GetTypeID() { return TypeID<CMeasureCalc>(); } virtual UINT GetTypeID() { return TypeID<CMeasureCalc>(); }
virtual bool Update();
bool GetMeasureValue(const WCHAR* str, int len, double* value); bool GetMeasureValue(const WCHAR* str, int len, double* value);
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private: private:
void FormulaReplace(); void FormulaReplace();

View File

@ -59,10 +59,8 @@ CMeasureDiskSpace::~CMeasureDiskSpace()
** Updates the current disk free space value. ** Updates the current disk free space value.
** **
*/ */
bool CMeasureDiskSpace::Update() void CMeasureDiskSpace::UpdateValue()
{ {
if (!CMeasure::PreUpdate()) return false;
if (!m_Drive.empty()) if (!m_Drive.empty())
{ {
const WCHAR* drive = m_Drive.c_str(); const WCHAR* drive = m_Drive.c_str();
@ -161,8 +159,6 @@ bool CMeasureDiskSpace::Update()
} }
} }
} }
return PostUpdate();
} }
/* /*

View File

@ -29,11 +29,11 @@ public:
virtual UINT GetTypeID() { return TypeID<CMeasureDiskSpace>(); } virtual UINT GetTypeID() { return TypeID<CMeasureDiskSpace>(); }
virtual bool Update();
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private: private:
std::wstring m_Drive; std::wstring m_Drive;

View File

@ -41,10 +41,8 @@ CMeasureMemory::~CMeasureMemory()
** Updates the current total memory value. ** Updates the current total memory value.
** **
*/ */
bool CMeasureMemory::Update() void CMeasureMemory::UpdateValue()
{ {
if (!CMeasure::PreUpdate()) return false;
MEMORYSTATUSEX stat; MEMORYSTATUSEX stat;
stat.dwLength = sizeof(MEMORYSTATUSEX); stat.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&stat); // Doesn't measure values > 4GB. Should use GlobalMemoryStatusEx instead, but that requires Win2k. GlobalMemoryStatusEx(&stat); // Doesn't measure values > 4GB. Should use GlobalMemoryStatusEx instead, but that requires Win2k.
@ -56,8 +54,6 @@ bool CMeasureMemory::Update()
{ {
m_Value = (double)(__int64)(stat.ullTotalPageFile + stat.ullTotalPhys - stat.ullAvailPageFile - stat.ullAvailPhys); m_Value = (double)(__int64)(stat.ullTotalPageFile + stat.ullTotalPhys - stat.ullAvailPageFile - stat.ullAvailPhys);
} }
return PostUpdate();
} }
/* /*

View File

@ -29,10 +29,9 @@ public:
virtual UINT GetTypeID() { return TypeID<CMeasureMemory>(); } virtual UINT GetTypeID() { return TypeID<CMeasureMemory>(); }
virtual bool Update();
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private: private:
bool m_Total; bool m_Total;

View File

@ -55,10 +55,8 @@ CMeasureNet::~CMeasureNet()
** Checks if Action should be executed. ** Checks if Action should be executed.
** **
*/ */
bool CMeasureNet::Update() void CMeasureNet::UpdateValue()
{ {
if (!CMeasure::PreUpdate()) return false;
if (m_MeterWindow) if (m_MeterWindow)
{ {
if (!m_TrafficAction.empty()) if (!m_TrafficAction.empty())
@ -72,8 +70,6 @@ bool CMeasureNet::Update()
m_CurrentTraffic += m_Value; m_CurrentTraffic += m_Value;
} }
} }
return PostUpdate();
} }
/* /*

View File

@ -41,8 +41,6 @@ public:
virtual ~CMeasureNet(); virtual ~CMeasureNet();
virtual UINT GetTypeID() { return TypeID<CMeasureNet>(); } virtual UINT GetTypeID() { return TypeID<CMeasureNet>(); }
virtual bool Update();
static void UpdateIFTable(); static void UpdateIFTable();
@ -56,6 +54,8 @@ public:
protected: protected:
void ReadConfig(CConfigParser& parser, const WCHAR* section, CMeasureNet::NET net); void ReadConfig(CConfigParser& parser, const WCHAR* section, CMeasureNet::NET net);
void UpdateValue();
ULONG64 GetNetOctets(NET net); ULONG64 GetNetOctets(NET net);
ULONG64 GetNetStatsValue(NET net); ULONG64 GetNetStatsValue(NET net);

View File

@ -41,11 +41,9 @@ CMeasureNetIn::~CMeasureNetIn()
** Updates the current net in value. ** Updates the current net in value.
** **
*/ */
bool CMeasureNetIn::Update() void CMeasureNetIn::UpdateValue()
{ {
if (!CMeasureNet::PreUpdate()) return false; if (c_Table == NULL) return;
if (c_Table == NULL) return false;
if (m_Cumulative) if (m_Cumulative)
{ {
@ -78,8 +76,6 @@ bool CMeasureNetIn::Update()
m_Value = (double)(__int64)value; m_Value = (double)(__int64)value;
} }
return PostUpdate();
} }
/* /*

View File

@ -27,10 +27,9 @@ public:
CMeasureNetIn(CMeterWindow* meterWindow, const WCHAR* name); CMeasureNetIn(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureNetIn(); virtual ~CMeasureNetIn();
virtual bool Update();
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private: private:
bool m_FirstTime; bool m_FirstTime;

View File

@ -41,11 +41,9 @@ CMeasureNetOut::~CMeasureNetOut()
** Updates the current net out value. ** Updates the current net out value.
** **
*/ */
bool CMeasureNetOut::Update() void CMeasureNetOut::UpdateValue()
{ {
if (!CMeasureNet::PreUpdate()) return false; if (c_Table == NULL) return;
if (c_Table == NULL) return false;
if (m_Cumulative) if (m_Cumulative)
{ {
@ -78,8 +76,6 @@ bool CMeasureNetOut::Update()
m_Value = (double)(__int64)value; m_Value = (double)(__int64)value;
} }
return PostUpdate();
} }
/* /*

View File

@ -27,10 +27,9 @@ public:
CMeasureNetOut(CMeterWindow* meterWindow, const WCHAR* name); CMeasureNetOut(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureNetOut(); virtual ~CMeasureNetOut();
virtual bool Update();
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private: private:
bool m_FirstTime; bool m_FirstTime;

View File

@ -41,11 +41,9 @@ CMeasureNetTotal::~CMeasureNetTotal()
** Updates the current net total value. ** Updates the current net total value.
** **
*/ */
bool CMeasureNetTotal::Update() void CMeasureNetTotal::UpdateValue()
{ {
if (!CMeasureNet::PreUpdate()) return false; if (c_Table == NULL) return;
if (c_Table == NULL) return false;
if (m_Cumulative) if (m_Cumulative)
{ {
@ -78,8 +76,6 @@ bool CMeasureNetTotal::Update()
m_Value = (double)(__int64)value; m_Value = (double)(__int64)value;
} }
return PostUpdate();
} }
/* /*

View File

@ -27,10 +27,9 @@ public:
CMeasureNetTotal(CMeterWindow* meterWindow, const WCHAR* name); CMeasureNetTotal(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureNetTotal(); virtual ~CMeasureNetTotal();
virtual bool Update();
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private: private:
bool m_FirstTime; bool m_FirstTime;

View File

@ -41,10 +41,8 @@ CMeasurePhysicalMemory::~CMeasurePhysicalMemory()
** Updates the current physical memory value. ** Updates the current physical memory value.
** **
*/ */
bool CMeasurePhysicalMemory::Update() void CMeasurePhysicalMemory::UpdateValue()
{ {
if (!CMeasure::PreUpdate()) return false;
MEMORYSTATUSEX stat; MEMORYSTATUSEX stat;
stat.dwLength = sizeof(MEMORYSTATUSEX); stat.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&stat); GlobalMemoryStatusEx(&stat);
@ -56,8 +54,6 @@ bool CMeasurePhysicalMemory::Update()
{ {
m_Value = (double)(__int64)(stat.ullTotalPhys - stat.ullAvailPhys); m_Value = (double)(__int64)(stat.ullTotalPhys - stat.ullAvailPhys);
} }
return PostUpdate();
} }
/* /*

View File

@ -29,10 +29,9 @@ public:
virtual UINT GetTypeID() { return TypeID<CMeasurePhysicalMemory>(); } virtual UINT GetTypeID() { return TypeID<CMeasurePhysicalMemory>(); }
virtual bool Update();
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private: private:
bool m_Total; bool m_Total;

View File

@ -70,10 +70,8 @@ CMeasurePlugin::~CMeasurePlugin()
** Gets the current value from the plugin ** Gets the current value from the plugin
** **
*/ */
bool CMeasurePlugin::Update() void CMeasurePlugin::UpdateValue()
{ {
if (!CMeasure::PreUpdate()) return false;
if (m_UpdateFunc) if (m_UpdateFunc)
{ {
if (IsNewApi()) if (IsNewApi())
@ -95,8 +93,6 @@ bool CMeasurePlugin::Update()
// Reset to default // Reset to default
CSystem::ResetWorkingDirectory(); CSystem::ResetWorkingDirectory();
} }
return PostUpdate();
} }
/* /*

View File

@ -44,12 +44,12 @@ public:
virtual UINT GetTypeID() { return TypeID<CMeasurePlugin>(); } virtual UINT GetTypeID() { return TypeID<CMeasurePlugin>(); }
virtual bool Update();
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
virtual void Command(const std::wstring& command); virtual void Command(const std::wstring& command);
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private: private:
bool IsNewApi() { return m_ReloadFunc != NULL; } bool IsNewApi() { return m_ReloadFunc != NULL; }

View File

@ -45,10 +45,8 @@ CMeasureRegistry::~CMeasureRegistry()
** Gets the current value from the registry ** Gets the current value from the registry
** **
*/ */
bool CMeasureRegistry::Update() void CMeasureRegistry::UpdateValue()
{ {
if (!CMeasure::PreUpdate()) return false;
if (m_RegKey != NULL) if (m_RegKey != NULL)
{ {
DWORD size = 4096; DWORD size = 4096;
@ -99,8 +97,6 @@ bool CMeasureRegistry::Update()
{ {
RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey); RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey);
} }
return PostUpdate();
} }
/* /*

View File

@ -29,11 +29,11 @@ public:
virtual UINT GetTypeID() { return TypeID<CMeasureRegistry>(); } virtual UINT GetTypeID() { return TypeID<CMeasureRegistry>(); }
virtual bool Update();
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private: private:
std::wstring m_RegKeyName; std::wstring m_RegKeyName;

View File

@ -78,13 +78,8 @@ void CMeasureScript::Initialize()
** Updates the current disk free space value. ** Updates the current disk free space value.
** **
*/ */
bool CMeasureScript::Update() void CMeasureScript::UpdateValue()
{ {
if (!CMeasure::PreUpdate())
{
return false;
}
if (m_HasUpdateFunction) if (m_HasUpdateFunction)
{ {
m_ValueType = m_LuaScript->RunFunctionWithReturn(g_UpdateFunctionName, m_Value, m_StringValue); m_ValueType = m_LuaScript->RunFunctionWithReturn(g_UpdateFunctionName, m_Value, m_StringValue);
@ -95,8 +90,6 @@ bool CMeasureScript::Update()
m_ValueType = m_LuaScript->RunFunctionWithReturn(g_GetStringFunctionName, m_Value, m_StringValue); m_ValueType = m_LuaScript->RunFunctionWithReturn(g_GetStringFunctionName, m_Value, m_StringValue);
} }
} }
return PostUpdate();
} }
/* /*

View File

@ -30,7 +30,6 @@ public:
virtual UINT GetTypeID() { return TypeID<CMeasureScript>(); } virtual UINT GetTypeID() { return TypeID<CMeasureScript>(); }
virtual void Initialize(); virtual void Initialize();
virtual bool Update();
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
virtual void Command(const std::wstring& command); virtual void Command(const std::wstring& command);
@ -38,6 +37,7 @@ public:
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private: private:
LuaScript* m_LuaScript; LuaScript* m_LuaScript;

View File

@ -91,10 +91,8 @@ void CMeasureTime::TimeToString(WCHAR* buf, size_t bufLen, const WCHAR* format,
** Updates the current time ** Updates the current time
** **
*/ */
bool CMeasureTime::Update() void CMeasureTime::UpdateValue()
{ {
if (!CMeasure::PreUpdate()) return false;
FILETIME ftUTCTime; FILETIME ftUTCTime;
GetSystemTimeAsFileTime(&ftUTCTime); GetSystemTimeAsFileTime(&ftUTCTime);
@ -152,8 +150,6 @@ bool CMeasureTime::Update()
{ {
m_Value = (double)(m_Time.QuadPart / 10000000); m_Value = (double)(m_Time.QuadPart / 10000000);
} }
return PostUpdate();
} }

View File

@ -29,11 +29,11 @@ public:
virtual UINT GetTypeID() { return TypeID<CMeasureTime>(); } virtual UINT GetTypeID() { return TypeID<CMeasureTime>(); }
virtual bool Update();
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private: private:
void TimeToString(WCHAR* buf, size_t bufLen, const WCHAR* format, const struct tm* time); void TimeToString(WCHAR* buf, size_t bufLen, const WCHAR* format, const struct tm* time);

View File

@ -62,14 +62,10 @@ void CMeasureUptime::ReadConfig(CConfigParser& parser, const WCHAR* section)
** Updates the current uptime ** Updates the current uptime
** **
*/ */
bool CMeasureUptime::Update() void CMeasureUptime::UpdateValue()
{ {
if (!CMeasure::PreUpdate()) return false;
ULONGLONG ticks = CSystem::GetTickCount64(); ULONGLONG ticks = CSystem::GetTickCount64();
m_Value = (double)(__int64)(ticks / 1000); m_Value = (double)(__int64)(ticks / 1000);
return PostUpdate();
} }
/* /*

View File

@ -29,11 +29,11 @@ public:
virtual UINT GetTypeID() { return TypeID<CMeasureUptime>(); } virtual UINT GetTypeID() { return TypeID<CMeasureUptime>(); }
virtual bool Update();
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private: private:
bool m_AddDaysToHours; bool m_AddDaysToHours;

View File

@ -41,13 +41,11 @@ CMeasureVirtualMemory::~CMeasureVirtualMemory()
** Updates the current virtual memory value. ** Updates the current virtual memory value.
** **
*/ */
bool CMeasureVirtualMemory::Update() void CMeasureVirtualMemory::UpdateValue()
{ {
if (!CMeasure::PreUpdate()) return false;
MEMORYSTATUSEX stat; MEMORYSTATUSEX stat;
stat.dwLength = sizeof(MEMORYSTATUSEX); stat.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&stat); // Doesn't measure values > 4GB. Should use GlobalMemoryStatusEx instead, but that requires Win2k. GlobalMemoryStatusEx(&stat);
if (m_Total) if (m_Total)
{ {
m_Value = (double)(__int64)stat.ullTotalPageFile; m_Value = (double)(__int64)stat.ullTotalPageFile;
@ -56,9 +54,6 @@ bool CMeasureVirtualMemory::Update()
{ {
m_Value = (double)(__int64)(stat.ullTotalPageFile - stat.ullAvailPageFile); m_Value = (double)(__int64)(stat.ullTotalPageFile - stat.ullAvailPageFile);
} }
return PostUpdate();
} }
/* /*

View File

@ -29,10 +29,9 @@ public:
virtual UINT GetTypeID() { return TypeID<CMeasureVirtualMemory>(); } virtual UINT GetTypeID() { return TypeID<CMeasureVirtualMemory>(); }
virtual bool Update();
protected: protected:
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();
private: private:
bool m_Total; bool m_Total;