X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fpsensor.c;h=236842aab9ff50611d47a128269b85194ebd45eb;hb=9ec6664daa4be58caa3a7d0fedf27d58207c7434;hp=d151ac1dfd86d5c88d92944e30957c723aa3495d;hpb=d6141b1d4fea0db9b115b06c668be6195ac4e5c6;p=psensor.git diff --git a/src/lib/psensor.c b/src/lib/psensor.c index d151ac1..236842a 100644 --- a/src/lib/psensor.c +++ b/src/lib/psensor.c @@ -42,8 +42,16 @@ struct psensor *psensor_create(char *id, psensor->id = id; psensor->name = name; psensor->chip = chip; - psensor->min = UNKNOWN_DBL_VALUE; - psensor->max = UNKNOWN_DBL_VALUE; + psensor->sess_lowest = UNKNOWN_DBL_VALUE; + psensor->sess_highest = UNKNOWN_DBL_VALUE; + + if (type & SENSOR_TYPE_PERCENT) { + psensor->min = 0; + psensor->max = 100; + } else { + psensor->min = UNKNOWN_DBL_VALUE; + psensor->max = UNKNOWN_DBL_VALUE; + } psensor->type = type; @@ -57,10 +65,6 @@ struct psensor *psensor_create(char *id, psensor->cb_alarm_raised_data = NULL; psensor->alarm_raised = 0; - psensor->url = NULL; - - psensor->color = NULL; - psensor->provider_data = NULL; psensor->provider_data_free_fct = &free; @@ -103,13 +107,8 @@ void psensor_free(struct psensor *s) if (s->chip) free(s->chip); - if (s->color) - free(s->color); - measures_free(s->measures); - free(s->url); - if (s->provider_data && s->provider_data_free_fct) s->provider_data_free_fct(s->provider_data); @@ -256,11 +255,11 @@ void psensor_set_current_measure(struct psensor *s, double v, struct timeval tv) s->measures[s->values_max_length - 1].value = v; s->measures[s->values_max_length - 1].time = tv; - if (s->min == UNKNOWN_DBL_VALUE || v < s->min) - s->min = v; + if (s->sess_lowest == UNKNOWN_DBL_VALUE || v < s->sess_lowest) + s->sess_lowest = v; - if (s->max == UNKNOWN_DBL_VALUE || v > s->max) - s->max = v; + if (s->sess_highest == UNKNOWN_DBL_VALUE || v > s->sess_highest) + s->sess_highest = v; if (v > s->alarm_high_threshold || v < s->alarm_low_threshold) { if (!s->alarm_raised && s->cb_alarm_raised) {