mirror of
https://github.com/synthetos/g2.git
synced 2026-02-06 02:51:54 +08:00
Fix status reports continuously reporting large int or float values
Switched to double for storing the old value
This commit is contained in:
@@ -385,7 +385,6 @@ stat_t sr_run_text_status_report()
|
||||
static stat_t _populate_unfiltered_status_report()
|
||||
{
|
||||
const char sr_str[] = "sr";
|
||||
// char tmp[TOKEN_LEN+1];
|
||||
nvObj_t *nv = nv_reset_nv_list(); // sets *nv to the start of the body
|
||||
|
||||
nv->valuetype = TYPE_PARENT; // setup the parent object (no length checking required)
|
||||
@@ -432,13 +431,12 @@ static uint8_t _populate_filtered_status_report()
|
||||
{
|
||||
const char sr_str[] = "sr";
|
||||
bool has_data = false;
|
||||
// char tmp[TOKEN_LEN+1];
|
||||
float current_value;
|
||||
double current_value;
|
||||
nvObj_t *nv = nv_reset_nv_list(); // sets nv to the start of the body
|
||||
|
||||
// Set thresholds to detect value changes based on precision for the value.
|
||||
// Allow for floating point roundoffs, i.e. precision = 2 is 0.01 becomes --> 0.009
|
||||
float precision[8] = { 0.9, 0.09, 0.009, 0.0009, 0.00009, 0.000009, 0.0000009, 0.00000009 };
|
||||
double precision[8] = { 0.9, 0.09, 0.009, 0.0009, 0.00009, 0.000009, 0.0000009, 0.00000009 };
|
||||
|
||||
nv->valuetype = TYPE_PARENT; // setup the parent object (no need to length check the copy)
|
||||
strcpy(nv->token, sr_str);
|
||||
|
||||
@@ -64,7 +64,7 @@ struct status_report_item { // structure to hold the cached status report items,
|
||||
index_t index;
|
||||
// uint8_t flags; // operations flags - see defines below
|
||||
int8_t precision; // decimal precision for display (JSON)
|
||||
float value;
|
||||
double value;
|
||||
fptrCmd get; // GET binding aka uint8_t (*get)(nvObj_t *nv)
|
||||
};
|
||||
|
||||
@@ -79,7 +79,6 @@ typedef struct srSingleton {
|
||||
index_t stat_index; // table index value for stat - determined during initialization
|
||||
uint8_t throttle_counter; // slow down SRs when in a constrained time (not phat_city)
|
||||
status_report_item status_report_list[NV_STATUS_REPORT_LEN]; // status report elements to report
|
||||
// float status_report_value[NV_STATUS_REPORT_LEN]; // previous values for filtered reporting
|
||||
} srSingleton_t;
|
||||
|
||||
typedef struct qrSingleton { // data for queue reports
|
||||
|
||||
Reference in New Issue
Block a user