Пример #1
0
    def enter_pairing_mode(self):
        """Enters pairing mode. Blocks the thread until pairing mode is set.

        Holds down the 'Home' and 'Back' buttons for a little over 5 seconds.
        """
        with SynchronizeRelays():
            self.hold_down(Buttons.HOME.value)
            self.hold_down(Buttons.BACK.value)

        time.sleep(PAIRING_MODE_WAIT_TIME)

        with SynchronizeRelays():
            self.release(Buttons.HOME.value)
            self.release(Buttons.BACK.value)
Пример #2
0
    def test_synchronize_relays(self):
        """Toggles relays using SynchronizeRelays().

        This makes each relay do it's action at the same time, without waiting
        after each relay to swap. Instead, all relays swap at the same time, and
        the wait is done after exiting the with statement.
        """
        for _ in range(0, 10):
            with SynchronizeRelays():
                self.relay_device.relays['BT_Power_Button'].toggle()
                self.relay_device.relays['BT_Pair'].toggle()
                self.relay_device.relays['BT_Reset'].toggle()
                self.relay_device.relays['BT_SomethingElse'].toggle()
 def clean_up(self):
     """Sets all relays to their default state (off)."""
     with SynchronizeRelays():
         for relay in self.relays.values():
             if relay.is_dirty():
                 relay.set_no()
 def setup(self):
     """Sets all relays to their default state (off)."""
     with SynchronizeRelays():
         for relay in self.relays.values():
             relay.set_no()
 def test_synchronize_relays(self):
     Relay.transition_wait_time = .1
     with SynchronizeRelays():
         self.assertEqual(Relay.transition_wait_time, 0)
     self.assertEqual(Relay.transition_wait_time, .1)