1#!/usr/bin/env python3 2# 3# Copyright 2016 - The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17from acts.controllers.relay_lib.relay import RelayState 18from acts.controllers.relay_lib.usb_relay_board_base import UsbRelayBoardBase 19from pylibftdi import BitBangDevice 20 21 22class RdlRelayBoard(UsbRelayBoardBase): 23 def set(self, relay_position, value): 24 """Returns the current status of the passed in relay. 25 26 Args: 27 relay_position: Relay position. 28 value: Turn_on or Turn_off the relay for the given relay_position. 29 """ 30 with BitBangDevice(self.device) as bb: 31 if value == RelayState.NO: 32 bb.port |= self.address[relay_position] 33 else: 34 bb.port &= ~(self.address[relay_position]) 35 self.status_dict[relay_position] = value 36