watch_dog_timer.py
Go to the documentation of this file.
00001 import time
00002 __author__ = 'caja'
00003 
00004 
00005 class WatchDogTimer(object):
00006     @staticmethod
00007     def now():
00008         return int(round(time.time() * 1000))
00009 
00010     def __init__(self, timeout):
00011         self._wd_time = WatchDogTimer.now()
00012         self._timeout = timeout
00013         self._is_timeout = False
00014 
00015     def check_if_timeout(self, now):
00016         if not self._is_timeout:
00017             self._is_timeout = (now - self._wd_time) > self._timeout
00018         return self._is_timeout
00019 
00020     def set_watch_dog(self, now):
00021         self._wd_time = now
00022 
00023     def is_timeout(self):
00024         return self._is_timeout


ric_board
Author(s): RoboTiCan
autogenerated on Fri Oct 27 2017 03:02:31