當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。