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
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-02-10 18:37:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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"
|
2012-08-09 13:50:58 +00:00
|
|
|
#include "Section.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
|
|
|
|
};
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
class MeasureValueSet
|
2013-01-29 07:02:16 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-05-31 14:18:52 +00:00
|
|
|
MeasureValueSet(double val, const WCHAR* str) : m_Value(val), m_StringValue(str) {}
|
2013-04-10 16:04:28 +00:00
|
|
|
void Set(double val, const WCHAR* str) { m_Value = val; m_StringValue = str; }
|
|
|
|
bool IsChanged(double val, const WCHAR* str) { if (m_Value != val || wcscmp(m_StringValue.c_str(), str) != 0) { Set(val, str); return true; } return false; }
|
2013-01-29 07:02:16 +00:00
|
|
|
private:
|
|
|
|
double m_Value;
|
|
|
|
std::wstring m_StringValue;
|
|
|
|
};
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
class Meter;
|
|
|
|
class MeterWindow;
|
|
|
|
class ConfigParser;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
class __declspec(novtable) Measure : public Section
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-05-31 14:18:52 +00:00
|
|
|
virtual ~Measure();
|
2011-02-15 16:26:54 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void ReadOptions(ConfigParser& parser) { ReadOptions(parser, GetName()); }
|
2011-02-15 16:26:54 +00:00
|
|
|
|
2010-06-01 14:55:52 +00:00
|
|
|
virtual void Initialize();
|
2012-05-30 06:46:11 +00:00
|
|
|
bool Update();
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-07-18 14:55:32 +00:00
|
|
|
void Disable();
|
|
|
|
void Enable();
|
2010-11-25 23:57:10 +00:00
|
|
|
bool IsDisabled() { return m_Disabled; }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-07-11 20:29:23 +00:00
|
|
|
void Pause() { m_Paused = true; }
|
|
|
|
void Unpause() { m_Paused = false; }
|
|
|
|
bool IsPaused() { return m_Paused; }
|
|
|
|
|
2012-02-01 15:55:29 +00:00
|
|
|
virtual void Command(const std::wstring& command);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
double GetValue();
|
|
|
|
double GetRelativeValue();
|
|
|
|
double GetValueRange();
|
2010-11-25 23:57:10 +00:00
|
|
|
double GetMinValue() { return m_MinValue; }
|
|
|
|
double GetMaxValue() { return m_MaxValue; }
|
|
|
|
|
2013-04-10 15:59:41 +00:00
|
|
|
virtual const WCHAR* GetStringValue();
|
|
|
|
const WCHAR* GetStringOrFormattedValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
|
|
|
|
const WCHAR* GetFormattedValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
|
|
|
|
|
2011-01-19 15:31:45 +00:00
|
|
|
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
|
|
|
|
2013-01-14 16:37:13 +00:00
|
|
|
const std::wstring& GetOnChangeAction() { return m_OnChangeAction; }
|
2013-01-29 07:02:16 +00:00
|
|
|
void DoChangeAction(bool execute = true);
|
2013-01-11 06:03:07 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
static Measure* Create(const WCHAR* measure, MeterWindow* meterWindow, const WCHAR* name);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
protected:
|
2013-05-31 14:18:52 +00:00
|
|
|
Measure(MeterWindow* meterWindow, const WCHAR* name);
|
2012-08-09 13:50:58 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
virtual void ReadOptions(ConfigParser& parser, const WCHAR* section);
|
2012-05-30 06:46:11 +00:00
|
|
|
virtual void UpdateValue() = 0;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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-12-09 03:28:19 +00:00
|
|
|
std::vector<std::wstring> m_Substitute; // Vec of substitute strings
|
2011-07-29 11:49:46 +00:00
|
|
|
bool m_RegExpSubstitute;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-10-03 09:36:11 +00:00
|
|
|
std::vector<double> m_MedianValues; // The values for the median filtering
|
2009-02-10 18:37:48 +00:00
|
|
|
UINT m_MedianPos; // Position in the median array, where the new value is placed
|
2012-01-23 15:43:31 +00:00
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
std::vector<double> m_AverageValues;
|
|
|
|
UINT m_AveragePos;
|
|
|
|
UINT m_AverageSize;
|
|
|
|
|
2012-09-06 07:39:01 +00:00
|
|
|
int64_t m_IfEqualValue; // The limit for the IfEqual action
|
2009-02-10 18:37:48 +00:00
|
|
|
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
|
2012-04-10 15:33:55 +00:00
|
|
|
bool m_IfEqualCommitted; // True when the IfEqual action is executed
|
|
|
|
bool m_IfAboveCommitted; // True when the IfAbove action is executed
|
|
|
|
bool m_IfBelowCommitted; // True when the IfBelow action is executed
|
2009-02-10 18:37:48 +00:00
|
|
|
bool m_Disabled; // Status of the measure
|
2013-07-11 20:29:23 +00:00
|
|
|
bool m_Paused;
|
2010-06-01 14:55:52 +00:00
|
|
|
bool m_Initialized;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-01-11 06:03:07 +00:00
|
|
|
std::wstring m_OnChangeAction;
|
2013-05-31 14:18:52 +00:00
|
|
|
MeasureValueSet* m_OldValue;
|
2013-01-29 07:02:16 +00:00
|
|
|
bool m_ValueAssigned;
|
2009-02-10 18:37:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|