From 0bc6fe907acaf7447faede6d0130dd18636c8f37 Mon Sep 17 00:00:00 2001 From: Sasha MOREL Date: Sun, 19 Nov 2017 16:50:20 +0100 Subject: [PATCH] Added data_age () to compute data's age --- vcub.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vcub.py b/vcub.py index 39b8155..dbc5c7c 100644 --- a/vcub.py +++ b/vcub.py @@ -36,7 +36,7 @@ class Vcub (): } ''' def __init__ (self, autoupdate_at_creation = True, autoupdate = False, autoupdate_delay = -1): - self.lastupdate = 0 + self.last_update = 0 self.data = None if autoupdate_at_creation: self.update () @@ -63,7 +63,13 @@ class Vcub (): 'location': (float (l [0]), float (l [1])) } self.data [int (j ['bm:IDENT'])] = e - self.lastupdate = time () + self.last_update = time () + + def data_age (self): + ''' + Computes the data's age + ''' + return (time () - self.last_update) def get_names (self): '''