39 #include <visp3/core/vpStatisticalTestShewhart.h>
44 #include <visp3/core/vpException.h>
45 #include <visp3/core/vpMath.h>
50 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_17)
59 name =
"3-sigma alarm";
62 name =
"2-sigma alarm";
65 name =
"1-sigma alarm";
68 name =
"Same-side alarm";
74 name =
"Unknown WECO alarm";
105 unsigned int nbAboveMean = 0;
106 unsigned int nbAbove2SigmaLimit = 0;
107 unsigned int nbAbove1SigmaLimit = 0;
110 nbAbove2SigmaLimit = 0;
111 nbAbove1SigmaLimit = 0;
120 ++nbAbove2SigmaLimit;
124 ++nbAbove2SigmaLimit;
126 if (nbAbove2SigmaLimit >= 2) {
134 ++nbAbove1SigmaLimit;
138 ++nbAbove1SigmaLimit;
140 if (nbAbove1SigmaLimit >= 4) {
151 else if (nbAbove2SigmaLimit >= 2) {
155 else if (nbAbove1SigmaLimit >= 4) {
177 unsigned int nbAboveMean = 0;
178 unsigned int nbAbove2SigmaLimit = 0;
179 unsigned int nbAbove1SigmaLimit = 0;
182 nbAbove2SigmaLimit = 0;
183 nbAbove1SigmaLimit = 0;
192 ++nbAbove2SigmaLimit;
196 ++nbAbove2SigmaLimit;
198 if (nbAbove2SigmaLimit >= 2) {
206 ++nbAbove1SigmaLimit;
210 ++nbAbove1SigmaLimit;
212 if (nbAbove1SigmaLimit >= 4) {
223 else if (nbAbove2SigmaLimit >= 2) {
227 else if (nbAbove1SigmaLimit >= 4) {
238 if (areStatsAvailable) {
241 return areStatsAvailable;
255 , m_nbDataInBuffer(0)
256 , m_activateWECOrules(activateWECOrules)
259 , m_oneSigmaNegLim(0.f)
260 , m_oneSigmaPosLim(0.f)
261 , m_twoSigmaNegLim(0.f)
262 , m_twoSigmaPosLim(0.f)
264 init(activateWECOrules, activatedRules, nbSamplesForStats);
269 , m_nbDataInBuffer(0)
270 , m_activateWECOrules(activateWECOrules)
273 , m_oneSigmaNegLim(0.f)
274 , m_oneSigmaPosLim(0.f)
275 , m_twoSigmaNegLim(0.f)
276 , m_twoSigmaPosLim(0.f)
278 init(activateWECOrules, activatedRules, mean, stdev);
283 std::vector<float> signals;
297 if (activatedRules.size() !=
COUNT_WECO - 1) {
298 std::stringstream errMsg;
299 errMsg <<
"Error: the expected number of rules is " <<
COUNT_WECO -1 <<
", the number given to the method is " << activatedRules.size() << std::endl;
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
static float modulo(const float &value, const float &modulo)
Gives the rest of value divided by modulo when the quotient can only be an integer.
vpMeanDriftType
Enum that indicates if a drift of the mean occurred.
void init()
(Re)Initialize the algorithm.
virtual bool updateStatistics(const float &signal)
Update m_s and if enough values are available, compute the mean, the standard deviation and the limit...
bool m_areStatisticsComputed
vpStatisticalTestShewhart(const bool &activateWECOrules=true, const std::vector< bool > &activatedRules=CONST_ALL_WECO_ACTIVATED, const unsigned int &nbSamplesForStats=30)
Construct a new vpStatisticalTestShewhart object.
virtual bool updateStatistics(const float &signal) VP_OVERRIDE
Update m_s and if enough values are available, compute the mean, the standard deviation and the limit...
static const unsigned int NB_DATA_SIGNAL
virtual vpMeanDriftType detectUpwardMeanDrift() VP_OVERRIDE
Detects if an upward mean drift occurred on the mean.
virtual vpMeanDriftType detectDownwardMeanDrift() VP_OVERRIDE
Detects if a downward mean drift occurred.
static const std::vector< bool > CONST_ALL_WECO_ACTIVATED
virtual void updateTestSignals(const float &signal) VP_OVERRIDE
Update the test signals.
std::vector< float > getSignals() const
Get the NB_DATA_SIGNAL last signal values, sorted from the latest [0] to the newest [NB_DATA_SIGNAL -...
std::vector< bool > m_activatedWECOrules
unsigned int m_nbDataInBuffer
unsigned int m_idCurrentData
float m_signal[NB_DATA_SIGNAL]
virtual void computeLimits() VP_OVERRIDE
Compute the upper and lower limits of the test signal.
static std::string vpWecoRulesAlarmToString(const vpWecoRulesAlarm &alarm)
Class that permits a simple test comparing the current value to the standard deviation of the signal.