Changed Calc errors to be reported only once (not on each update)

This commit is contained in:
Birunthan Mohanathas 2012-04-06 21:04:57 +03:00
parent 8c3fd63ffb
commit 8dd9b8e6f5

View File

@ -28,6 +28,7 @@ bool CMeasureCalc::c_RandSeeded = false;
**
*/
CMeasureCalc::CMeasureCalc(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_ValidFormula(false),
m_LowBound(),
m_HighBound(100),
m_UpdateRandom(false)
@ -57,10 +58,14 @@ bool CMeasureCalc::Update()
{
if (!CMeasure::PreUpdate()) return false;
if (m_ValidFormula)
{
const WCHAR* errMsg = MathParser::Parse(m_Formula.c_str(), this, &m_Value);
if (errMsg != NULL)
{
LogWithArgs(LOG_ERROR, L"Calc: %s in [%s]", errMsg, m_Name.c_str());
m_ValidFormula = false;
}
}
return PostUpdate();
@ -101,7 +106,11 @@ void CMeasureCalc::ReadConfig(CConfigParser& parser, const WCHAR* section)
if (errMsg != NULL)
{
LogWithArgs(LOG_ERROR, L"Calc: %s in [%s]", errMsg, m_Name.c_str());
m_Formula.clear();
m_ValidFormula = false;
}
else
{
m_ValidFormula = true;
}
}
}