From 13cc11e200f8f3115336ef327f7bfc51ad414f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 28 Dec 2018 14:04:35 +0100 Subject: [PATCH] tag: refresh_in() *must* use the realtime unit --- particles/progress_bar.c | 6 +----- tag.c | 8 ++++++-- tag.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/particles/progress_bar.c b/particles/progress_bar.c index 34ea9b3..a6e8b59 100644 --- a/particles/progress_bar.c +++ b/particles/progress_bar.c @@ -129,10 +129,6 @@ instantiate(const struct particle *particle, const struct tag_set *tags) if (rt == TAG_REALTIME_NONE) return exposable; - else if (rt != TAG_REALTIME_SECONDS) { - LOG_WARN("unimplemented tag realtime unit: %d", rt); - return exposable; - } #if 0 long units_per_segment = (max - min) / p->width; @@ -155,7 +151,7 @@ instantiate(const struct particle *particle, const struct tag_set *tags) #endif - if (!tag->refresh_in(tag, units_til_next_segment * 1000)) + if (!tag->refresh_in(tag, units_til_next_segment)) LOG_WARN("failed to schedule update of tag"); return exposable; diff --git a/tag.c b/tag.c index 4d6a6cb..9d6e040 100644 --- a/tag.c +++ b/tag.c @@ -42,7 +42,7 @@ no_realtime(const struct tag *tag) } static bool -unimpl_refresh_in(const struct tag *tag, long milli_seconds) +unimpl_refresh_in(const struct tag *tag, long units) { return false; } @@ -117,7 +117,7 @@ int_as_float(const struct tag *tag) } static bool -int_refresh_in(const struct tag *tag, long milli_seconds) +int_refresh_in(const struct tag *tag, long units) { const struct private *priv = tag->private; if (priv->value_as_int.realtime_unit == TAG_REALTIME_NONE) @@ -126,6 +126,10 @@ int_refresh_in(const struct tag *tag, long milli_seconds) if (tag->owner == NULL || tag->owner->refresh_in == NULL) return false; + long milli_seconds = units; + if (priv->value_as_int.realtime_unit == TAG_REALTIME_SECS) + milli_seconds *= 1000; + return tag->owner->refresh_in(tag->owner, milli_seconds); } diff --git a/tag.h b/tag.h index d94363f..887cb67 100644 --- a/tag.h +++ b/tag.h @@ -6,7 +6,7 @@ enum tag_realtime_unit { TAG_REALTIME_NONE, - TAG_REALTIME_SECONDS + TAG_REALTIME_SECS, }; struct module; @@ -26,7 +26,7 @@ struct tag { long (*max)(const struct tag *tag); enum tag_realtime_unit (*realtime)(const struct tag *tag); - bool (*refresh_in)(const struct tag *tag, long milli_seconds); + bool (*refresh_in)(const struct tag *tag, long units); }; struct tag_set {