Quote:
Originally Posted by jwakeman
Code:
bool PIDController::OnTarget()
{
bool temp;
CRITICAL_REGION(m_semaphore)
{
temp = fabs(m_error) < (m_tolerance / 100 *
(m_maximumInput - m_minimumInput));
}
END_REGION;
return temp;
}
|
On a side note:
It looks like m_tolerance, m_maximumInput, and m_minimumInput are all constants.
Take them, and the calculation, out of the critical region
Code:
bool PIDController::OnTarget()
{
double temp;
CRITICAL_REGION(m_semaphore)
{
temp=m_error;
}
END_REGION;
return (fabs(temp) < (m_tolerance / 100 * (m_maximumInput - m_minimumInput)));
}