mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	Fixed: IfActions not fired when measure is disabled
This commit is contained in:
		| @@ -424,85 +424,74 @@ std::wstring CMeasure::ExtractWord(std::wstring& buffer) | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| /* | ||||
| ** 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() | ||||
| bool CMeasure::Update() | ||||
| { | ||||
| 	if (IsDisabled()) | ||||
| 	bool update = !IsDisabled(); | ||||
|  | ||||
| 	if (update) | ||||
| 	{ | ||||
| 		m_Value = 0.0;	// Disable measures return 0 as value | ||||
| 		return false; | ||||
| 		// 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()) | ||||
| 			{ | ||||
| 				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; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// 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) | ||||
| 	else | ||||
| 	{ | ||||
| 		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]); | ||||
| 	} | ||||
|  | ||||
| 	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; | ||||
| 		// Disabled measures have 0 as value | ||||
| 		m_Value = 0.0; | ||||
| 	} | ||||
|  | ||||
| 	if (m_MeterWindow) | ||||
| @@ -513,7 +502,7 @@ bool CMeasure::PostUpdate() | ||||
| 			{ | ||||
| 				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); | ||||
| 				} | ||||
| 			} | ||||
| @@ -529,7 +518,7 @@ bool CMeasure::PostUpdate() | ||||
| 			{ | ||||
| 				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); | ||||
| 				} | ||||
| 			} | ||||
| @@ -545,7 +534,7 @@ bool CMeasure::PostUpdate() | ||||
| 			{ | ||||
| 				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); | ||||
| 				} | ||||
| 			} | ||||
| @@ -556,7 +545,7 @@ bool CMeasure::PostUpdate() | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return true; | ||||
| 	return update; | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -52,7 +52,7 @@ public: | ||||
| 	void ReadConfig(CConfigParser& parser) { ReadConfig(parser, GetName()); } | ||||
|  | ||||
| 	virtual void Initialize(); | ||||
| 	virtual bool Update() = 0; | ||||
| 	bool Update(); | ||||
|  | ||||
| 	const WCHAR* GetName() { return m_Name.c_str(); } | ||||
| 	const std::wstring& GetOriginalName() { return m_Name; } | ||||
| @@ -86,9 +86,7 @@ public: | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
|  | ||||
| 	virtual bool PreUpdate(); | ||||
| 	virtual bool PostUpdate(); | ||||
| 	virtual void UpdateValue() = 0; | ||||
|  | ||||
| 	bool ParseSubstitute(std::wstring buffer); | ||||
| 	std::wstring ExtractWord(std::wstring& buffer); | ||||
|   | ||||
| @@ -117,10 +117,8 @@ void CMeasureCPU::ReadConfig(CConfigParser& parser, const WCHAR* section) | ||||
| ** Updates the current CPU utilization value. | ||||
| ** | ||||
| */ | ||||
| bool CMeasureCPU::Update() | ||||
| void CMeasureCPU::UpdateValue() | ||||
| { | ||||
| 	if (!CMeasure::PreUpdate()) return false; | ||||
|  | ||||
| 	if (m_Processor == 0) | ||||
| 	{ | ||||
| 		BOOL status; | ||||
| @@ -128,7 +126,7 @@ bool CMeasureCPU::Update() | ||||
|  | ||||
| 		// get new CPU's idle/kernel/user time | ||||
| 		status = GetSystemTimes(&ftIdleTime, &ftKernelTime, &ftUserTime); | ||||
| 		if (status == 0) return false; | ||||
| 		if (status == 0) return; | ||||
|  | ||||
| 		CalcUsage(Ft2Double(ftIdleTime), | ||||
| 			Ft2Double(ftKernelTime) + Ft2Double(ftUserTime)); | ||||
| @@ -146,9 +144,7 @@ bool CMeasureCPU::Update() | ||||
| 			ULONG size = 0; | ||||
|  | ||||
| 			status = c_NtQuerySystemInformation(SystemProcessorPerformanceInformation, buf, bufSize, &size); | ||||
| 			if (status == STATUS_SUCCESS || status != STATUS_INFO_LENGTH_MISMATCH) break; | ||||
|  | ||||
| 			else  // status == STATUS_INFO_LENGTH_MISMATCH | ||||
| 			if (status == STATUS_INFO_LENGTH_MISMATCH) | ||||
| 			{ | ||||
| 				if (size == 0)  // Returned required buffer size is always 0 on Windows 2000/XP. | ||||
| 				{ | ||||
| @@ -176,37 +172,33 @@ bool CMeasureCPU::Update() | ||||
| 				delete [] buf; | ||||
| 				buf = new BYTE[bufSize]; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				break; | ||||
| 			} | ||||
|  | ||||
| 			++loop; | ||||
| 		} | ||||
| 		while (loop < 5); | ||||
|  | ||||
| 		if (status != STATUS_SUCCESS)  // failed | ||||
| 		if (status == STATUS_SUCCESS) | ||||
| 		{ | ||||
| 			delete [] buf; | ||||
| 			return false; | ||||
| 			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)); | ||||
| 		} | ||||
|  | ||||
| 		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; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -31,10 +31,9 @@ public: | ||||
|  | ||||
| 	virtual UINT GetTypeID() { return TypeID<CMeasureCPU>(); } | ||||
|  | ||||
| 	virtual bool Update(); | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
| 	virtual void UpdateValue(); | ||||
|  | ||||
| private: | ||||
| 	void CalcUsage(double idleTime, double systemTime); | ||||
|   | ||||
| @@ -54,10 +54,8 @@ CMeasureCalc::~CMeasureCalc() | ||||
| ** 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); | ||||
| 	if (errMsg != NULL) | ||||
| 	{ | ||||
| @@ -71,8 +69,6 @@ bool CMeasureCalc::Update() | ||||
| 	{ | ||||
| 		m_ParseError = false; | ||||
| 	} | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -29,12 +29,11 @@ public: | ||||
|  | ||||
| 	virtual UINT GetTypeID() { return TypeID<CMeasureCalc>(); } | ||||
|  | ||||
| 	virtual bool Update(); | ||||
|  | ||||
| 	bool GetMeasureValue(const WCHAR* str, int len, double* value); | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
| 	virtual void UpdateValue(); | ||||
|  | ||||
| private: | ||||
| 	void FormulaReplace(); | ||||
|   | ||||
| @@ -59,10 +59,8 @@ CMeasureDiskSpace::~CMeasureDiskSpace() | ||||
| ** Updates the current disk free space value. | ||||
| ** | ||||
| */ | ||||
| bool CMeasureDiskSpace::Update() | ||||
| void CMeasureDiskSpace::UpdateValue() | ||||
| { | ||||
| 	if (!CMeasure::PreUpdate()) return false; | ||||
|  | ||||
| 	if (!m_Drive.empty()) | ||||
| 	{ | ||||
| 		const WCHAR* drive = m_Drive.c_str(); | ||||
| @@ -161,8 +159,6 @@ bool CMeasureDiskSpace::Update() | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -29,11 +29,11 @@ public: | ||||
|  | ||||
| 	virtual UINT GetTypeID() { return TypeID<CMeasureDiskSpace>(); } | ||||
|  | ||||
| 	virtual bool Update(); | ||||
| 	virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
| 	virtual void UpdateValue(); | ||||
|  | ||||
| private: | ||||
| 	std::wstring m_Drive; | ||||
|   | ||||
| @@ -41,10 +41,8 @@ CMeasureMemory::~CMeasureMemory() | ||||
| ** Updates the current total memory value. | ||||
| ** | ||||
| */ | ||||
| bool CMeasureMemory::Update() | ||||
| void CMeasureMemory::UpdateValue() | ||||
| { | ||||
| 	if (!CMeasure::PreUpdate()) return false; | ||||
|  | ||||
| 	MEMORYSTATUSEX stat; | ||||
| 	stat.dwLength = sizeof(MEMORYSTATUSEX); | ||||
| 	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); | ||||
| 	} | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -29,10 +29,9 @@ public: | ||||
|  | ||||
| 	virtual UINT GetTypeID() { return TypeID<CMeasureMemory>(); } | ||||
|  | ||||
| 	virtual bool Update(); | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
| 	virtual void UpdateValue(); | ||||
|  | ||||
| private: | ||||
| 	bool m_Total; | ||||
|   | ||||
| @@ -55,10 +55,8 @@ CMeasureNet::~CMeasureNet() | ||||
| ** Checks if Action should be executed. | ||||
| ** | ||||
| */ | ||||
| bool CMeasureNet::Update() | ||||
| void CMeasureNet::UpdateValue() | ||||
| { | ||||
| 	if (!CMeasure::PreUpdate()) return false; | ||||
|  | ||||
| 	if (m_MeterWindow) | ||||
| 	{ | ||||
| 		if (!m_TrafficAction.empty()) | ||||
| @@ -72,8 +70,6 @@ bool CMeasureNet::Update() | ||||
| 			m_CurrentTraffic += m_Value; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -41,8 +41,6 @@ public: | ||||
| 	virtual ~CMeasureNet(); | ||||
|  | ||||
| 	virtual UINT GetTypeID() { return TypeID<CMeasureNet>(); } | ||||
| 	 | ||||
| 	virtual bool Update(); | ||||
|  | ||||
| 	static void UpdateIFTable(); | ||||
|  | ||||
| @@ -56,6 +54,8 @@ public: | ||||
|  | ||||
| protected: | ||||
| 	void ReadConfig(CConfigParser& parser, const WCHAR* section, CMeasureNet::NET net); | ||||
| 	void UpdateValue(); | ||||
|  | ||||
| 	ULONG64 GetNetOctets(NET net); | ||||
| 	ULONG64 GetNetStatsValue(NET net); | ||||
|  | ||||
|   | ||||
| @@ -41,11 +41,9 @@ CMeasureNetIn::~CMeasureNetIn() | ||||
| ** Updates the current net in value. | ||||
| ** | ||||
| */ | ||||
| bool CMeasureNetIn::Update() | ||||
| void CMeasureNetIn::UpdateValue() | ||||
| { | ||||
| 	if (!CMeasureNet::PreUpdate()) return false; | ||||
|  | ||||
| 	if (c_Table == NULL) return false; | ||||
| 	if (c_Table == NULL) return; | ||||
|  | ||||
| 	if (m_Cumulative) | ||||
| 	{ | ||||
| @@ -78,8 +76,6 @@ bool CMeasureNetIn::Update() | ||||
|  | ||||
| 		m_Value = (double)(__int64)value; | ||||
| 	} | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -27,10 +27,9 @@ public: | ||||
| 	CMeasureNetIn(CMeterWindow* meterWindow, const WCHAR* name); | ||||
| 	virtual ~CMeasureNetIn(); | ||||
|  | ||||
| 	virtual bool Update(); | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
| 	virtual void UpdateValue(); | ||||
|  | ||||
| private: | ||||
| 	bool m_FirstTime; | ||||
|   | ||||
| @@ -41,11 +41,9 @@ CMeasureNetOut::~CMeasureNetOut() | ||||
| ** Updates the current net out value. | ||||
| ** | ||||
| */ | ||||
| bool CMeasureNetOut::Update() | ||||
| void CMeasureNetOut::UpdateValue() | ||||
| { | ||||
| 	if (!CMeasureNet::PreUpdate()) return false; | ||||
|  | ||||
| 	if (c_Table == NULL) return false; | ||||
| 	if (c_Table == NULL) return; | ||||
|  | ||||
| 	if (m_Cumulative) | ||||
| 	{ | ||||
| @@ -78,8 +76,6 @@ bool CMeasureNetOut::Update() | ||||
|  | ||||
| 		m_Value = (double)(__int64)value; | ||||
| 	} | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -27,10 +27,9 @@ public: | ||||
| 	CMeasureNetOut(CMeterWindow* meterWindow, const WCHAR* name); | ||||
| 	virtual ~CMeasureNetOut(); | ||||
|  | ||||
| 	virtual bool Update(); | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
| 	virtual void UpdateValue(); | ||||
|  | ||||
| private: | ||||
| 	bool m_FirstTime; | ||||
|   | ||||
| @@ -41,11 +41,9 @@ CMeasureNetTotal::~CMeasureNetTotal() | ||||
| ** Updates the current net total value. | ||||
| ** | ||||
| */ | ||||
| bool CMeasureNetTotal::Update() | ||||
| void CMeasureNetTotal::UpdateValue() | ||||
| { | ||||
| 	if (!CMeasureNet::PreUpdate()) return false; | ||||
|  | ||||
| 	if (c_Table == NULL) return false; | ||||
| 	if (c_Table == NULL) return; | ||||
|  | ||||
| 	if (m_Cumulative) | ||||
| 	{ | ||||
| @@ -78,8 +76,6 @@ bool CMeasureNetTotal::Update() | ||||
|  | ||||
| 		m_Value = (double)(__int64)value; | ||||
| 	} | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -27,10 +27,9 @@ public: | ||||
| 	CMeasureNetTotal(CMeterWindow* meterWindow, const WCHAR* name); | ||||
| 	virtual ~CMeasureNetTotal(); | ||||
|  | ||||
| 	virtual bool Update(); | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
| 	virtual void UpdateValue(); | ||||
|  | ||||
| private: | ||||
| 	bool m_FirstTime; | ||||
|   | ||||
| @@ -41,10 +41,8 @@ CMeasurePhysicalMemory::~CMeasurePhysicalMemory() | ||||
| ** Updates the current physical memory value. | ||||
| ** | ||||
| */ | ||||
| bool CMeasurePhysicalMemory::Update() | ||||
| void CMeasurePhysicalMemory::UpdateValue() | ||||
| { | ||||
| 	if (!CMeasure::PreUpdate()) return false; | ||||
|  | ||||
| 	MEMORYSTATUSEX stat; | ||||
| 	stat.dwLength = sizeof(MEMORYSTATUSEX); | ||||
| 	GlobalMemoryStatusEx(&stat); | ||||
| @@ -56,8 +54,6 @@ bool CMeasurePhysicalMemory::Update() | ||||
| 	{ | ||||
| 		m_Value = (double)(__int64)(stat.ullTotalPhys - stat.ullAvailPhys); | ||||
| 	} | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -29,10 +29,9 @@ public: | ||||
|  | ||||
| 	virtual UINT GetTypeID() { return TypeID<CMeasurePhysicalMemory>(); } | ||||
|  | ||||
| 	virtual bool Update(); | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
| 	virtual void UpdateValue(); | ||||
|  | ||||
| private: | ||||
| 	bool m_Total; | ||||
|   | ||||
| @@ -70,10 +70,8 @@ CMeasurePlugin::~CMeasurePlugin() | ||||
| ** Gets the current value from the plugin | ||||
| ** | ||||
| */ | ||||
| bool CMeasurePlugin::Update() | ||||
| void CMeasurePlugin::UpdateValue() | ||||
| { | ||||
| 	if (!CMeasure::PreUpdate()) return false; | ||||
|  | ||||
| 	if (m_UpdateFunc) | ||||
| 	{ | ||||
| 		if (IsNewApi()) | ||||
| @@ -95,8 +93,6 @@ bool CMeasurePlugin::Update() | ||||
| 		// Reset to default | ||||
| 		CSystem::ResetWorkingDirectory(); | ||||
| 	} | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -44,12 +44,12 @@ public: | ||||
|  | ||||
| 	virtual UINT GetTypeID() { return TypeID<CMeasurePlugin>(); } | ||||
|  | ||||
| 	virtual bool Update(); | ||||
| 	virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); | ||||
| 	virtual void Command(const std::wstring& command); | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
| 	virtual void UpdateValue(); | ||||
|  | ||||
| private: | ||||
| 	bool IsNewApi() { return m_ReloadFunc != NULL; } | ||||
|   | ||||
| @@ -45,10 +45,8 @@ CMeasureRegistry::~CMeasureRegistry() | ||||
| ** Gets the current value from the registry | ||||
| ** | ||||
| */ | ||||
| bool CMeasureRegistry::Update() | ||||
| void CMeasureRegistry::UpdateValue() | ||||
| { | ||||
| 	if (!CMeasure::PreUpdate()) return false; | ||||
|  | ||||
| 	if (m_RegKey != NULL) | ||||
| 	{ | ||||
| 		DWORD size = 4096; | ||||
| @@ -99,8 +97,6 @@ bool CMeasureRegistry::Update() | ||||
| 	{ | ||||
| 		RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey); | ||||
| 	} | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -29,11 +29,11 @@ public: | ||||
|  | ||||
| 	virtual UINT GetTypeID() { return TypeID<CMeasureRegistry>(); } | ||||
|  | ||||
| 	virtual bool Update(); | ||||
| 	virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
| 	virtual void UpdateValue(); | ||||
|  | ||||
| private: | ||||
| 	std::wstring m_RegKeyName; | ||||
|   | ||||
| @@ -78,13 +78,8 @@ void CMeasureScript::Initialize() | ||||
| ** Updates the current disk free space value. | ||||
| ** | ||||
| */ | ||||
| bool CMeasureScript::Update() | ||||
| void CMeasureScript::UpdateValue() | ||||
| { | ||||
| 	if (!CMeasure::PreUpdate()) | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	if (m_HasUpdateFunction) | ||||
| 	{ | ||||
| 		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); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -30,7 +30,6 @@ public: | ||||
| 	virtual UINT GetTypeID() { return TypeID<CMeasureScript>(); } | ||||
|  | ||||
| 	virtual void Initialize(); | ||||
| 	virtual bool Update(); | ||||
| 	virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); | ||||
| 	virtual void Command(const std::wstring& command); | ||||
|  | ||||
| @@ -38,6 +37,7 @@ public: | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
| 	virtual void UpdateValue(); | ||||
|  | ||||
| private: | ||||
| 	LuaScript* m_LuaScript; | ||||
|   | ||||
| @@ -91,10 +91,8 @@ void CMeasureTime::TimeToString(WCHAR* buf, size_t bufLen, const WCHAR* format, | ||||
| ** Updates the current time | ||||
| ** | ||||
| */ | ||||
| bool CMeasureTime::Update() | ||||
| void CMeasureTime::UpdateValue() | ||||
| { | ||||
| 	if (!CMeasure::PreUpdate()) return false; | ||||
|  | ||||
| 	FILETIME ftUTCTime; | ||||
| 	GetSystemTimeAsFileTime(&ftUTCTime); | ||||
|  | ||||
| @@ -152,8 +150,6 @@ bool CMeasureTime::Update() | ||||
| 	{ | ||||
| 		m_Value = (double)(m_Time.QuadPart / 10000000); | ||||
| 	} | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -29,11 +29,11 @@ public: | ||||
|  | ||||
| 	virtual UINT GetTypeID() { return TypeID<CMeasureTime>(); } | ||||
|  | ||||
| 	virtual bool Update(); | ||||
| 	virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
| 	virtual void UpdateValue(); | ||||
|  | ||||
| private: | ||||
| 	void TimeToString(WCHAR* buf, size_t bufLen, const WCHAR* format, const struct tm* time); | ||||
|   | ||||
| @@ -62,14 +62,10 @@ void CMeasureUptime::ReadConfig(CConfigParser& parser, const WCHAR* section) | ||||
| ** Updates the current uptime | ||||
| ** | ||||
| */ | ||||
| bool CMeasureUptime::Update() | ||||
| void CMeasureUptime::UpdateValue() | ||||
| { | ||||
| 	if (!CMeasure::PreUpdate()) return false; | ||||
|  | ||||
| 	ULONGLONG ticks = CSystem::GetTickCount64(); | ||||
| 	m_Value = (double)(__int64)(ticks / 1000); | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -29,11 +29,11 @@ public: | ||||
|  | ||||
| 	virtual UINT GetTypeID() { return TypeID<CMeasureUptime>(); } | ||||
|  | ||||
| 	virtual bool Update(); | ||||
| 	virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
| 	virtual void UpdateValue(); | ||||
|  | ||||
| private: | ||||
| 	bool m_AddDaysToHours; | ||||
|   | ||||
| @@ -41,13 +41,11 @@ CMeasureVirtualMemory::~CMeasureVirtualMemory() | ||||
| ** Updates the current virtual memory value. | ||||
| ** | ||||
| */ | ||||
| bool CMeasureVirtualMemory::Update() | ||||
| void CMeasureVirtualMemory::UpdateValue() | ||||
| { | ||||
| 	if (!CMeasure::PreUpdate()) return false; | ||||
|  | ||||
| 	MEMORYSTATUSEX stat; | ||||
| 	stat.dwLength = sizeof(MEMORYSTATUSEX); | ||||
| 	GlobalMemoryStatusEx(&stat);		// Doesn't measure values > 4GB. Should use GlobalMemoryStatusEx instead, but that requires Win2k. | ||||
| 	GlobalMemoryStatusEx(&stat); | ||||
| 	if (m_Total) | ||||
| 	{ | ||||
| 		m_Value = (double)(__int64)stat.ullTotalPageFile; | ||||
| @@ -56,9 +54,6 @@ bool CMeasureVirtualMemory::Update() | ||||
| 	{ | ||||
| 		m_Value = (double)(__int64)(stat.ullTotalPageFile - stat.ullAvailPageFile); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	return PostUpdate(); | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
| @@ -29,10 +29,9 @@ public: | ||||
|  | ||||
| 	virtual UINT GetTypeID() { return TypeID<CMeasureVirtualMemory>(); } | ||||
|  | ||||
| 	virtual bool Update(); | ||||
|  | ||||
| protected: | ||||
| 	virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); | ||||
| 	virtual void UpdateValue(); | ||||
|  | ||||
| private: | ||||
| 	bool m_Total; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Birunthan Mohanathas
					Birunthan Mohanathas