📄 callat.py
字号:
# This script is in the public domain and has no copyright## CallAt/CallIn are simple utility classes that call a specified# function at a given point in the future.#import simcoreimport net.tinyos.sim.eventclass CallAt: def __init__(self, when, callback, args = None): interruptID = simcore.interp.getInterruptID() def mycallback(interruptEvent): if (interruptEvent.get_id() != interruptID): return simcore.interp.removeEventHandler(self.eventID); if args != None: callback(args); else: callback(); evclass = net.tinyos.sim.event.InterruptEvent self.eventID = simcore.interp.addEventHandler(mycallback, evclass); simcore.interp.interruptInFuture(when, interruptID) def cancel(self): simcore.interp.removeEventHandler(self.eventID)class CallIn(CallAt): def __init__(self, delay, callback, args = None): when = simcore.sim.getTossimTime() + delay; CallAt.__init__(self, when, callback, args);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -