本文整理汇总了Python中device.Device.set_state方法的典型用法代码示例。如果您正苦于以下问题:Python Device.set_state方法的具体用法?Python Device.set_state怎么用?Python Device.set_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类device.Device
的用法示例。
在下文中一共展示了Device.set_state方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_state
# 需要导入模块: from device import Device [as 别名]
# 或者: from device.Device import set_state [as 别名]
def set_state(self, new_state):
if (self.state[0] == "Closed" or self.state[0] == "Waiting") and new_state[0] == "Open":
ns = (new_state[0], self.off_time)
self.last_open_time = None
Device.set_state(self, ns)
elif self.state[0] == "Open" and new_state[0] == "Closed":
ns = ("Waiting", self.off_time)
self.last_open_time = datetime.now()
Device.set_state(self, ns)
示例2: set_state
# 需要导入模块: from device import Device [as 别名]
# 或者: from device.Device import set_state [as 别名]
def set_state(self, new_state):
if (self.state[0] == 'Off' or self.state[0] == 'Waiting') \
and new_state[0] == 'On':
ns = (new_state[0], self.off_time)
self.last_motion_time = None
Device.set_state(self, ns)
elif self.state[0] == 'On' and new_state[0] == 'Off':
ns = ('Waiting', self.off_time)
self.last_motion_time = datetime.now()
Device.set_state(self, ns)