当前位置: 首页>>代码示例>>Python>>正文


Python Motion.command方法代码示例

本文整理汇总了Python中pytomation.devices.Motion.command方法的典型用法代码示例。如果您正苦于以下问题:Python Motion.command方法的具体用法?Python Motion.command怎么用?Python Motion.command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pytomation.devices.Motion的用法示例。


在下文中一共展示了Motion.command方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_motion_delay_from_interface

# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import command [as 别名]
 def test_motion_delay_from_interface(self):
     i = Mock()
     m = Motion(devices=i,
                delay={
                       Attribute.COMMAND: Command.STILL,
                       Attribute.SECS: 2,
                       })
     m.command(command=Command.MOTION, source=i)
     self.assertEqual(m.state, State.MOTION)
     m.command(command=Command.STILL, source=i)
     self.assertEqual(m.state, State.MOTION)
     time.sleep(3)
     self.assertEqual(m.state, State.STILL)
开发者ID:E3Dev,项目名称:pytomation,代码行数:15,代码来源:motion.py

示例2: test_light_scenario1

# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import command [as 别名]
 def test_light_scenario1(self):
     m = Motion()
     l = Light(
             address=(49, 6), 
             devices=m,
             mapped={
                     Attribute.COMMAND: Command.MOTION,
                     Attribute.SECS: 30*60
                     },
             ignore=({
                     Attribute.COMMAND: Command.STILL
                     },
                     {
                     Attribute.COMMAND: Command.DARK
                     },
                 ),
             name='Lamp',
             )
     self.assertEqual(l.state, State.UNKNOWN)
     m.command(command=State.ON, source=None)
     self.assertEqual(l.state, State.UNKNOWN)
开发者ID:chrisleck-old-personal,项目名称:pytomation,代码行数:23,代码来源:light.py

示例3: MotionTests

# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import command [as 别名]
class MotionTests(TestCase):
    
    def setUp(self):
        self.interface = Mock()
        self.interface.state = State.UNKNOWN
        self.device = Motion('D1', self.interface)

    def test_instantiation(self):
        self.assertIsNotNone(self.device,
                             'Motion Device could not be instantiated')

    def test_motion_motion(self):
        self.assertEqual(self.device.state, State.UNKNOWN)
        self.device.command(Command.MOTION, source=self.interface)
#        self.device._on_command('D1', State.ON)
        self.assertEqual(self.device.state, State.MOTION)
#        self.device._on_command('D1', State.OFF)
        self.device.command(Command.STILL, source=self.interface)
        self.assertEqual(self.device.state, State.STILL)

    def test_motion_ignore(self):
        self.device = Motion('D1', devices=(self.interface), ignore={
                                                                      'command': Command.STILL,
                                                                      },
                              )
        self.device.command(Command.MOTION, source=self.interface)
#        self.device._on_command('D1', State.ON, self.interface)
        self.assertEqual(self.device.state, State.MOTION)
        self.device.command(Command.MOTION, source=self.interface)
#        self.device._on_command('D1', State.OFF, self.interface)
        self.assertEqual(self.device.state, State.MOTION)
        
    def test_motion_on(self):
        m = Motion()
        m.command(command=Command.ON, source=None)
        self.assertEqual(m.state, State.MOTION)        
开发者ID:kengle3,项目名称:pytomation,代码行数:38,代码来源:motion.py

示例4: test_motion_retrigger

# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import command [as 别名]
 def test_motion_retrigger(self):
     i = Mock()
     m = Motion(devices=i,
                retrigger_delay={
                                 Attribute.SECS: 2,
                                 },
                )
     s = Light(devices=m)
     s.off()
     self.assertEqual(s.state, State.OFF)
     m.command(command=Command.ON, source=i)
     self.assertEqual(s.state, State.ON)
     s.off()
     self.assertEqual(s.state, State.OFF)
     m.command(command=Command.ON, source=i)
     self.assertEqual(s.state, State.OFF)
     time.sleep(3)
     m.command(command=Command.ON, source=i)
     self.assertEqual(s.state, State.ON)
开发者ID:E3Dev,项目名称:pytomation,代码行数:21,代码来源:motion.py

示例5: test_motion_on

# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import command [as 别名]
 def test_motion_on(self):
     m = Motion()
     m.command(command=Command.ON, source=None)
     self.assertEqual(m.state, State.MOTION)        
开发者ID:kengle3,项目名称:pytomation,代码行数:6,代码来源:motion.py

示例6: MotionTests

# 需要导入模块: from pytomation.devices import Motion [as 别名]
# 或者: from pytomation.devices.Motion import command [as 别名]
class MotionTests(TestCase):
    
    def setUp(self):
        self.interface = Mock()
        self.interface.state = State.UNKNOWN
        self.device = Motion('D1', self.interface)

    def test_instantiation(self):
        self.assertIsNotNone(self.device,
                             'Motion Device could not be instantiated')

    def test_motion_motion(self):
        self.assertEqual(self.device.state, State.UNKNOWN)
        self.device.command(Command.MOTION, source=self.interface)
#        self.device._on_command('D1', State.ON)
        self.assertEqual(self.device.state, State.MOTION)
#        self.device._on_command('D1', State.OFF)
        self.device.command(Command.STILL, source=self.interface)
        self.assertEqual(self.device.state, State.STILL)

    def test_motion_ignore(self):
        self.device = Motion('D1', devices=(self.interface), ignore={
                                                                      'command': Command.STILL,
                                                                      },
                              )
        self.device.command(Command.MOTION, source=self.interface)
#        self.device._on_command('D1', State.ON, self.interface)
        self.assertEqual(self.device.state, State.MOTION)
        self.device.command(Command.MOTION, source=self.interface)
#        self.device._on_command('D1', State.OFF, self.interface)
        self.assertEqual(self.device.state, State.MOTION)
        
    def test_motion_on(self):
        m = Motion()
        m.command(command=Command.ON, source=None)
        self.assertEqual(m.state, State.MOTION)        

    def test_motion_delay_from_interface(self):
        i = Mock()
        m = Motion(devices=i,
                   delay={
                          Attribute.COMMAND: Command.STILL,
                          Attribute.SECS: 2,
                          })
        m.command(command=Command.MOTION, source=i)
        self.assertEqual(m.state, State.MOTION)
        m.command(command=Command.STILL, source=i)
        self.assertEqual(m.state, State.MOTION)
        time.sleep(3)
        self.assertEqual(m.state, State.STILL)

    def test_motion_retrigger(self):
        i = Mock()
        m = Motion(devices=i,
                   retrigger_delay={
                                    Attribute.SECS: 2,
                                    },
                   )
        s = Light(devices=m)
        s.off()
        self.assertEqual(s.state, State.OFF)
        m.command(command=Command.ON, source=i)
        self.assertEqual(s.state, State.ON)
        s.off()
        self.assertEqual(s.state, State.OFF)
        m.command(command=Command.ON, source=i)
        self.assertEqual(s.state, State.OFF)
        time.sleep(3)
        m.command(command=Command.ON, source=i)
        self.assertEqual(s.state, State.ON)
开发者ID:E3Dev,项目名称:pytomation,代码行数:72,代码来源:motion.py


注:本文中的pytomation.devices.Motion.command方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。