first = 1;
for (i = 0; i < s->values_max_length; i++) {
t = s->measures[i].time.tv_sec;
- v = s->measures[i].value.d_num;
+ v = s->measures[i].value;
if (v == UNKNOWN_DBL_VALUE || !t)
continue;
result = malloc(size * sizeof(struct measure));
for (i = 0; i < size; i++) {
- result[i].value.d_num = UNKNOWN_DBL_VALUE;
+ result[i].value = UNKNOWN_DBL_VALUE;
timerclear(&result[i].time);
}
#define UNKNOWN_DBL_VALUE DBL_MIN
struct measure {
- union value {
- double d_num;
- uint64_t ui64_num;
- } value;
+ double value;
struct timeval time;
};
&s->measures[1],
(s->values_max_length - 1) * sizeof(struct measure));
- s->measures[s->values_max_length - 1].value.d_num = v;
+ 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)
double psensor_get_current_value(struct psensor *sensor)
{
- return sensor->measures[sensor->values_max_length - 1].value.d_num;
+ return sensor->measures[sensor->values_max_length - 1].value;
}
struct measure *psensor_get_current_measure(struct psensor *sensor)
double t;
for (i = 0; i < sensor->values_max_length; i++) {
- t = sensor->measures[i].value.d_num;
+ t = sensor->measures[i].value;
if (t == UNKNOWN_DBL_VALUE)
continue;
int i;
double t;
for (i = 0; i < sensor->values_max_length; i++) {
- t = sensor->measures[i].value.d_num;
+ t = sensor->measures[i].value;
if (t == UNKNOWN_DBL_VALUE)
continue;
json_object_object_add(o,
ATT_MEASURE_VALUE,
- json_object_new_double(m->value.d_num));
+ json_object_new_double(m->value));
json_object_object_add(o, ATT_MEASURE_TIME,
json_object_new_int((m->time).tv_sec));
return o;
mo = json_object_new_object();
json_object_object_add(mo,
ATT_MEASURE_VALUE,
- json_object_new_double(m->value.d_num));
+ json_object_new_double(m->value));
json_object_object_add(mo, ATT_MEASURE_TIME,
json_object_new_int((m->time).tv_sec));
json_object_object_add(obj, ATT_SENSOR_LAST_MEASURE, mo);
void ui_notify(struct psensor *sensor, struct ui_psensor *ui)
{
struct timeval t;
- char *name;
+ char *body;
NotifyNotification *notif;
log_debug("last_notification %d", last_notification_tv.tv_sec);
notify_init("psensor");
if (notify_is_initted() == TRUE) {
- name = strdup(sensor->name);
+ body = strdup(sensor->name);
/*
* Since libnotify 0.7 notify_notification_new has
*/
#if NOTIFY_CHECK_VERSION(0, 7, 0)
notif = notify_notification_new
- (_("Temperature alert"), name, PSENSOR_ICON);
+ (_("Temperature alert"), body, PSENSOR_ICON);
#else
notif = notify_notification_new(_("Temperature alert"),
- name,
+ body,
PSENSOR_ICON,
GTK_WIDGET(ui->main_window));
#endif
- log_debug("notif_notification_new %s", sensor->name);
+ log_debug("notif_notification_new %s", body);
notify_notification_show(notif, NULL);
str = psensor_value_to_string(s->type,
s->measures[s->values_max_length -
- 1].value.d_num,
+ 1].value,
use_celcius);
gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_TEMP, str,