• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 __future__ import absolute_import
18from __future__ import division
19from __future__ import print_function
20
21from acts.controllers.relay_lib.errors import RelayConfigError
22from acts.controllers.relay_lib.helpers import validate_key
23from acts.controllers.relay_lib.relay import Relay
24
25
26class RelayBoard(object):
27    """Handles interfacing with the Relays and RelayDevices.
28
29    This is the base class for all RelayBoards.
30    """
31
32    def __init__(self, config):
33        """Creates a RelayBoard instance. Handles naming and relay creation.
34
35        Args:
36            config: A configuration dictionary, usually pulled from an element
37            under in "boards" list in the relay rig config file.
38        """
39        self.name = validate_key('name', config, str, 'config')
40        if '/' in self.name:
41            raise RelayConfigError('RelayBoard name cannot contain a "/".')
42        self.relays = dict()
43        for pos in self.get_relay_position_list():
44            self.relays[pos] = Relay(self, pos)
45
46    def set(self, relay_position, state):
47        """Sets the relay to the given state.
48
49        Args:
50            relay_position: the relay having its state modified.
51            state: the state to set the relay to. Currently only states NO and
52                   NC are supported.
53        """
54        raise NotImplementedError()
55
56    def get_relay_position_list(self):
57        """Returns a list of all possible relay positions."""
58        raise NotImplementedError()
59
60    def get_relay_status(self, relay):
61        """Returns the state of the given relay."""
62        raise NotImplementedError()
63