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;
psensor->cb_alarm_raised_data = NULL;
psensor->alarm_raised = 0;
- psensor->color = NULL;
-
psensor->provider_data = NULL;
psensor->provider_data_free_fct = &free;
if (s->chip)
free(s->chip);
- if (s->color)
- free(s->color);
-
measures_free(s->measures);
if (s->provider_data && s->provider_data_free_fct)
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) {
}
/*
- Returns the minimal value of a given 'type' (SENSOR_TYPE_TEMP or
- SENSOR_TYPE_FAN)
+ * Returns the minimal value of a given 'type' (SENSOR_TYPE_TEMP or
+ * SENSOR_TYPE_FAN)
*/
static double get_min_value(struct psensor **sensors, int type)
{
}
/*
- Returns the maximal value of a given 'type' (SENSOR_TYPE_TEMP or
- SENSOR_TYPE_FAN)
+ * Returns the maximal value of a given 'type' (SENSOR_TYPE_TEMP or
+ * SENSOR_TYPE_FAN)
*/
double get_max_value(struct psensor **sensors, int type)
{
void psensor_log_measures(struct psensor **sensors)
{
- if (log_level == LOG_DEBUG)
+ if (log_level == LOG_DEBUG) {
+ if (!sensors)
+ return;
+
while (*sensors) {
log_debug("Measure: %s %.2f",
(*sensors)->name,
sensors++;
}
+ }
}
struct psensor **psensor_list_copy(struct psensor **sensors)