39 uint64_t *timestamp_io)
41 uint64_t timestamp = *timestamp_io;
42 uint64_t timestamp_incr = 5;
43 const uint64_t error_count = 0;
44 const int priority = 50;
45 const float swing = 1E-2
f;
46 double sum_dev_squares = 0.0f;
49 for (uint32_t i = 0; i < count; i++) {
50 float iter_swing = (0 == (i % 2)) ? swing : -swing;
51 float iter_val = mean + iter_swing;
52 float iter_dev = iter_val - mean;
53 sum_dev_squares += (iter_dev * iter_dev);
54 timestamp += timestamp_incr;
55 validator->
put(timestamp, iter_val, error_count, priority);
58 double rms =
sqrt(sum_dev_squares / (
double)count);
60 *rms_err = (float)rms;
61 *timestamp_io = timestamp;
67 printf(
"state: 0x%x no_data: %d stale: %d timeout:%d\n",
78 const float incr_value,
80 uint64_t *timestamp_io)
82 uint64_t timestamp = *timestamp_io;
83 const uint64_t timestamp_incr = 5;
84 const uint32_t timeout_usec = 2000;
86 float val = *value_io;
87 const uint64_t error_count = 0;
88 const int priority = 50;
96 timestamp += timestamp_incr;
97 validator->
put(timestamp, val, error_count, priority);
100 *timestamp_io = timestamp;
static constexpr uint32_t ERROR_FLAG_TIMEOUT
void dump_validator_state(DataValidator *validator)
Print out the state of a DataValidator.
void insert_values_around_mean(DataValidator *validator, const float mean, uint32_t count, float *rms_err, uint64_t *timestamp_io)
Insert a series of samples around a mean value.
const int equal_value_count
static constexpr uint32_t ERROR_FLAG_STALE_DATA
void print()
Print the validator value.
void set_timeout(uint32_t timeout_interval_us)
Set the timeout value.
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
uint32_t state() const
Get the error state of this validator.
static constexpr uint32_t ERROR_FLAG_NO_DATA
void set_equal_value_threshold(uint32_t threshold)
Set the equal count threshold.
void put(uint64_t timestamp, float val, uint64_t error_count, int priority)
Put an item into the validator.
void fill_validator_with_samples(DataValidator *validator, const float incr_value, float *value_io, uint64_t *timestamp_io)
Insert a time series of samples into the validator.
Dual< Scalar, N > sqrt(const Dual< Scalar, N > &a)