mirror of
https://github.com/JoelBender/bacpypes
synced 2025-09-28 22:15:23 +08:00
add some debugging
This commit is contained in:
parent
cb47cd6639
commit
c63f0d4996
|
@ -160,15 +160,20 @@ def FunctionTask(fn, *args, **kwargs):
|
||||||
# RecurringTask
|
# RecurringTask
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@bacpypes_debugging
|
||||||
class RecurringTask(_Task):
|
class RecurringTask(_Task):
|
||||||
|
|
||||||
_debug_contents = ('taskInterval',)
|
_debug_contents = ('taskInterval',)
|
||||||
|
|
||||||
def __init__(self, interval=None):
|
def __init__(self, interval=None):
|
||||||
|
if _debug: RecurringTask._debug("__init__ interval=%r", interval)
|
||||||
_Task.__init__(self)
|
_Task.__init__(self)
|
||||||
|
|
||||||
|
# save the interval, but do not automatically install
|
||||||
self.taskInterval = interval
|
self.taskInterval = interval
|
||||||
|
|
||||||
def install_task(self, interval=None):
|
def install_task(self, interval=None):
|
||||||
|
if _debug: RecurringTask._debug("install_task interval=%r", interval)
|
||||||
global _task_manager, _unscheduled_tasks
|
global _task_manager, _unscheduled_tasks
|
||||||
|
|
||||||
# set the interval if it hasn't already been set
|
# set the interval if it hasn't already been set
|
||||||
|
@ -181,6 +186,7 @@ class RecurringTask(_Task):
|
||||||
|
|
||||||
# if there is no task manager, postpone the install
|
# if there is no task manager, postpone the install
|
||||||
if not _task_manager:
|
if not _task_manager:
|
||||||
|
if _debug: RecurringTask._debug(" - no task manager")
|
||||||
_unscheduled_tasks.append(self)
|
_unscheduled_tasks.append(self)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -188,6 +194,7 @@ class RecurringTask(_Task):
|
||||||
now = _task_manager.get_time()
|
now = _task_manager.get_time()
|
||||||
interval = self.taskInterval / 1000.0
|
interval = self.taskInterval / 1000.0
|
||||||
self.taskTime = now + interval - (now % interval)
|
self.taskTime = now + interval - (now % interval)
|
||||||
|
if _debug: RecurringTask._debug(" - task time: %r", self.taskTime)
|
||||||
|
|
||||||
# install it
|
# install it
|
||||||
_task_manager.install_task(self)
|
_task_manager.install_task(self)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user