2009-02-10 18:37:48 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2001 Kimmo Pekkola
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __MEASURE_H__
|
|
|
|
#define __MEASURE_H__
|
|
|
|
|
2011-02-07 08:02:12 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2009-02-10 18:37:48 +00:00
|
|
|
#include "Litestep.h"
|
2010-07-07 23:46:44 +00:00
|
|
|
#include "Group.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-01-19 15:31:45 +00:00
|
|
|
enum AUTOSCALE
|
|
|
|
{
|
|
|
|
AUTOSCALE_1024 = 1, // scales by 1024
|
|
|
|
AUTOSCALE_1000 = 2, // scales by 1000
|
|
|
|
|
|
|
|
AUTOSCALE_1024K = 101, // scales by 1024, and uses kilo as the lowest unit
|
|
|
|
AUTOSCALE_1000K = 102, // scales by 1000, and uses kilo as the lowest unit
|
|
|
|
|
|
|
|
AUTOSCALE_OFF = 0,
|
|
|
|
AUTOSCALE_ON = AUTOSCALE_1024
|
|
|
|
};
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
class CMeter;
|
2011-02-07 08:02:12 +00:00
|
|
|
class CMeterWindow;
|
|
|
|
class CConfigParser;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-07-07 23:46:44 +00:00
|
|
|
class CMeasure : public CGroup
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
public:
|
2011-02-15 16:26:54 +00:00
|
|
|
CMeasure(CMeterWindow* meterWindow, const WCHAR* name);
|
2009-02-10 18:37:48 +00:00
|
|
|
virtual ~CMeasure();
|
2011-02-15 16:26:54 +00:00
|
|
|
|
|
|
|
void ReadConfig(CConfigParser& parser) { ReadConfig(parser, GetName()); }
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
2010-06-01 14:55:52 +00:00
|
|
|
virtual void Initialize();
|
2009-02-10 18:37:48 +00:00
|
|
|
virtual bool Update() = 0;
|
|
|
|
|
|
|
|
virtual const WCHAR* GetStats();
|
|
|
|
|
2010-11-25 23:57:10 +00:00
|
|
|
const WCHAR* GetName() { return m_Name.c_str(); }
|
2011-11-18 22:40:58 +00:00
|
|
|
const std::wstring& GetOriginalName() { return m_Name; }
|
2011-11-09 08:52:32 +00:00
|
|
|
const char* GetAsciiName() { return m_AsciiName.c_str(); }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-11-25 23:57:10 +00:00
|
|
|
void Disable() { m_Disabled = true; }
|
|
|
|
void Enable() { m_Disabled = false; }
|
|
|
|
bool IsDisabled() { return m_Disabled; }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2009-08-26 17:37:15 +00:00
|
|
|
bool HasDynamicVariables() { return m_DynamicVariables; }
|
2011-07-27 10:42:35 +00:00
|
|
|
void SetDynamicVariables(bool b) { m_DynamicVariables = b; }
|
2009-08-26 17:37:15 +00:00
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
virtual void ExecuteBang(const WCHAR* args);
|
|
|
|
|
|
|
|
double GetValue();
|
|
|
|
double GetRelativeValue();
|
|
|
|
double GetValueRange();
|
2010-11-25 23:57:10 +00:00
|
|
|
double GetMinValue() { return m_MinValue; }
|
|
|
|
double GetMaxValue() { return m_MaxValue; }
|
|
|
|
|
2010-12-28 13:31:17 +00:00
|
|
|
void ResetUpdateCounter() { m_UpdateCounter = m_UpdateDivider; }
|
|
|
|
int GetUpdateCounter() { return m_UpdateCounter; }
|
|
|
|
int GetUpdateDivider() { return m_UpdateDivider; }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-01-19 15:31:45 +00:00
|
|
|
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
|
|
|
|
static void GetScaledValue(AUTOSCALE autoScale, int decimals, double theValue, WCHAR* buffer, size_t sizeInWords);
|
2011-07-02 10:16:38 +00:00
|
|
|
static void RemoveTrailingZero(WCHAR* str, int strLen);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-07-27 10:42:35 +00:00
|
|
|
CMeterWindow* GetMeterWindow() { return m_MeterWindow; }
|
|
|
|
|
2011-02-15 16:26:54 +00:00
|
|
|
static CMeasure* Create(const WCHAR* measure, CMeterWindow* meterWindow, const WCHAR* name);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool PreUpdate();
|
|
|
|
virtual bool PostUpdate();
|
|
|
|
|
|
|
|
bool ParseSubstitute(std::wstring buffer);
|
|
|
|
std::wstring ExtractWord(std::wstring& buffer);
|
|
|
|
const WCHAR* CheckSubstitute(const WCHAR* buffer);
|
2011-07-29 11:49:46 +00:00
|
|
|
bool MakePlainSubstitute(std::wstring& str, size_t index);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2009-08-26 17:37:15 +00:00
|
|
|
bool m_DynamicVariables; // If true, the measure contains dynamic variables
|
2009-02-10 18:37:48 +00:00
|
|
|
bool m_Invert; // If true, the value should be inverted
|
|
|
|
bool m_LogMaxValue; // If true, The maximum & minimum values are logged
|
|
|
|
double m_MinValue; // The minimum value (so far)
|
|
|
|
double m_MaxValue; // The maximum value (so far)
|
|
|
|
double m_Value; // The current value
|
2011-02-15 16:26:54 +00:00
|
|
|
const std::wstring m_Name; // Name of this Measure
|
2011-11-09 08:52:32 +00:00
|
|
|
const std::string m_AsciiName; // Name of this Measure in ANSI
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-07-29 11:49:46 +00:00
|
|
|
std::vector< std::pair<std::wstring, std::wstring> > m_Substitute; // Vec of substitute strings
|
|
|
|
bool m_RegExpSubstitute;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
std::vector<double> m_MedianMaxValues; // The values for the median filtering
|
|
|
|
std::vector<double> m_MedianMinValues; // The values for the median filtering
|
|
|
|
UINT m_MedianPos; // Position in the median array, where the new value is placed
|
|
|
|
|
|
|
|
std::vector<double> m_AverageValues;
|
|
|
|
UINT m_AveragePos;
|
|
|
|
UINT m_AverageSize;
|
|
|
|
|
|
|
|
double m_IfEqualValue; // The limit for the IfEqual action
|
|
|
|
double m_IfAboveValue; // The limit for the IfAbove action
|
|
|
|
double m_IfBelowValue; // The limit for the IfBelow action
|
|
|
|
std::wstring m_IfEqualAction; // The IfEqual action
|
|
|
|
std::wstring m_IfAboveAction; // The IfAbove action
|
|
|
|
std::wstring m_IfBelowAction; // The IfBelow action
|
|
|
|
bool m_IfEqualCommited; // True when the IfEqual action is executed.
|
|
|
|
bool m_IfAboveCommited; // True when the IfAbove action is executed.
|
|
|
|
bool m_IfBelowCommited; // True when the IfBelow action is executed.
|
|
|
|
bool m_Disabled; // Status of the measure
|
2010-12-28 13:31:17 +00:00
|
|
|
int m_UpdateDivider; // Divider for the update
|
|
|
|
int m_UpdateCounter; // Current update counter
|
2010-06-01 14:55:52 +00:00
|
|
|
bool m_Initialized;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
CMeterWindow* m_MeterWindow;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|