# Path: braubuddy/envcontroller/base.py
# class IEnvController(object):
#     """
#     Interface for creating an environmental controller for use with
#     :mod:`braubuddy`.
#     """
#     __metaclass__ = abc.ABCMeta
# 
#     def __init__(self):
#         pass
# 
#     @abc.abstractmethod
#     def set_heater_level(percent):
#         """
#         Set environmental controller's heater power level as a percentage of
#         full power.
# 
#         :param percent: Heater power level.
#         :type _percent: :class:`int` in range(0-100)
#         :raises: PercentageError if percent is invalid
#         """
# 
#     @abc.abstractmethod
#     def set_cooler_level(percent):
#         """
#         Set environmental controller's cooler power level as a percentage of
#         full power.
# 
#         :param percent: Cooler power level.
#         :type _percent: :class:`int` in range(0-100)
#         :raises: PercentageError if percent is invalid
#         """
# 
#     @abc.abstractmethod
#     def get_power_levels(self):
#         """
#         Get heater and cooler power levels.
# 
#         :returns: Heater and cooler power levels
#         :rtype: :class:`tuple` of (:class:`int` <heater_power_level>,
#             :class:`int` <cooler_power_level>)
#         """
# 
# Path: braubuddy/envcontroller/base.py
# class DeviceError(Exception):
#     """
#     Raised if there is a problem communicating with an environmental control
#     device.
#     """
#     pass
# 
# Path: braubuddy/envcontroller/base.py
# class PercentageError(Exception):
#     """
#     Raised when a percentage is passed not in the range 0-100
#     """


import tosr0x
from braubuddy.envcontroller import IEnvController
from braubuddy.envcontroller import DeviceError
from braubuddy.envcontroller import PercentageError
        """
        Internal method.

        Get attached Tosr0x devices

        :returns: list of attached Tosr0x devices
        :rtype: :class:`list` of :class:`tosr0x.relayModule`
        """

        tosr0x_devices = tosr0x.handler()
        return tosr0x_devices

    def _set_relay_from_percent(self, relay_number, percent):
        """
        Internal method.

        Set given relay number state based on percent value. Percentage is
        converted to either on (0%) or off (1-100%).

        :param relay_number: The number of the relay to set.
        :type relay_number: :class:`float`
        :param percent: Power percentage. Converted to either on (0%) or off
            (0-100%).
        :type percent: Float
        :raises: :class:`envcontroller.PercentageError` if percent is not in
            the range 0-100.
        """

        if percent not in range(0, 101):
            msg = '{0} is not in range 0-100'.format(percent)

# Path: braubuddy/envcontroller/base.py
# class IEnvController(object):
#     """
#     Interface for creating an environmental controller for use with
#     :mod:`braubuddy`.
#     """
#     __metaclass__ = abc.ABCMeta
# 
#     def __init__(self):
#         pass
# 
#     @abc.abstractmethod
#     def set_heater_level(percent):
#         """
#         Set environmental controller's heater power level as a percentage of
#         full power.
# 
#         :param percent: Heater power level.
#         :type _percent: :class:`int` in range(0-100)
#         :raises: PercentageError if percent is invalid
#         """
# 
#     @abc.abstractmethod
#     def set_cooler_level(percent):
#         """
#         Set environmental controller's cooler power level as a percentage of
#         full power.
# 
#         :param percent: Cooler power level.
#         :type _percent: :class:`int` in range(0-100)
#         :raises: PercentageError if percent is invalid
#         """
# 
#     @abc.abstractmethod
#     def get_power_levels(self):
#         """
#         Get heater and cooler power levels.
# 
#         :returns: Heater and cooler power levels
#         :rtype: :class:`tuple` of (:class:`int` <heater_power_level>,
#             :class:`int` <cooler_power_level>)
#         """
# 
# Path: braubuddy/envcontroller/base.py
# class DeviceError(Exception):
#     """
#     Raised if there is a problem communicating with an environmental control
#     device.
#     """
#     pass
# 
# Path: braubuddy/envcontroller/base.py
# class PercentageError(Exception):
#     """
#     Raised when a percentage is passed not in the range 0-100
#     """


# Path: braubuddy/envcontroller/tosr0x_usb.py
import tosr0x
from braubuddy.envcontroller import IEnvController
from braubuddy.envcontroller import DeviceError
from braubuddy.envcontroller import PercentageError

        """
        Internal method.

        Get attached Tosr0x devices

        :returns: list of attached Tosr0x devices
        :rtype: :class:`list` of :class:`tosr0x.relayModule`
        """

        tosr0x_devices = tosr0x.handler()
        return tosr0x_devices

    def _set_relay_from_percent(self, relay_number, percent):
        """
        Internal method.

        Set given relay number state based on percent value. Percentage is
        converted to either on (0%) or off (1-100%).

        :param relay_number: The number of the relay to set.
        :type relay_number: :class:`float`
        :param percent: Power percentage. Converted to either on (0%) or off
            (0-100%).
        :type percent: Float
        :raises: :class:`envcontroller.PercentageError` if percent is not in
            the range 0-100.
        """

        if percent not in range(0, 101):
            msg = '{0} is not in range 0-100'.format(percent)

            raise PercentageError(msg)