Added data_age () to compute data's age

This commit is contained in:
Sasha MOREL 2017-11-19 16:50:20 +01:00
parent 43a526b001
commit 0bc6fe907a
1 changed files with 8 additions and 2 deletions

10
vcub.py
View File

@ -36,7 +36,7 @@ class Vcub ():
} }
''' '''
def __init__ (self, autoupdate_at_creation = True, autoupdate = False, autoupdate_delay = -1): def __init__ (self, autoupdate_at_creation = True, autoupdate = False, autoupdate_delay = -1):
self.lastupdate = 0 self.last_update = 0
self.data = None self.data = None
if autoupdate_at_creation: if autoupdate_at_creation:
self.update () self.update ()
@ -63,7 +63,13 @@ class Vcub ():
'location': (float (l [0]), float (l [1])) 'location': (float (l [0]), float (l [1]))
} }
self.data [int (j ['bm:IDENT'])] = e 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): def get_names (self):
''' '''