# Path: braubuddy/thermometer/base.py
# class DeviceError(Exception):
#     """
#     Raised if there is a problem communicating with a thermometer device.
#     """
#     pass
# 
# Path: braubuddy/thermometer/base.py
# class ReadError(Exception):
#     """
#     Raised if there is a problem reading temperature.
#     """
#     pass
# 
# Path: braubuddy/thermometer/base.py
# class IThermometer(object):
#     """
#     Interface for creating a thermometer for use with :mod:`braudbuddy`.
#     """
#     __metaclass__ = abc.ABCMeta
# 
#     def __init__(self):
#         pass
# 
#     @abc.abstractmethod
#     def get_temperature(self, units='celsius'):
#         """
#         Get thermometer temperature in celsius or farenheit.
# 
#         :param units: Temperature units, 'celsius' (default) or 'farenheit.'
#         :type units: :class:`str`
#         :returns: Thermometer temperature reading
#         :rtype: :class:`float`
#         :raises: :class:`braubuddy.thermometer.ReadError` if temperature can
#             not be read.
#         """
#         pass


import ds18b20
from braubuddy.thermometer import DeviceError
from braubuddy.thermometer import ReadError
from braubuddy.thermometer import IThermometer

UNIT_MAP = {
    'celsius':      1,
    'fahrenheit':   2
}


class DS18B20Thermometer(IThermometer):
    """
    DS18B20 GPIO anagolgue thermometer manufactured by `Maxim
    Integrated Products <http://www.maximintegrated.com>`_.

    :raises: :class:`braubuddy.thermometer.DeviceError` if no DS18B20
        thermometer devices discovered.
    """

    def __init__(self):
        try:
            self._ds18b20_device = ds18b20.DS18B20()
        except Exception as err:
            msg = 'No DS18B20 devices discovered'

# Path: braubuddy/thermometer/base.py
# class DeviceError(Exception):
#     """
#     Raised if there is a problem communicating with a thermometer device.
#     """
#     pass
# 
# Path: braubuddy/thermometer/base.py
# class ReadError(Exception):
#     """
#     Raised if there is a problem reading temperature.
#     """
#     pass
# 
# Path: braubuddy/thermometer/base.py
# class IThermometer(object):
#     """
#     Interface for creating a thermometer for use with :mod:`braudbuddy`.
#     """
#     __metaclass__ = abc.ABCMeta
# 
#     def __init__(self):
#         pass
# 
#     @abc.abstractmethod
#     def get_temperature(self, units='celsius'):
#         """
#         Get thermometer temperature in celsius or farenheit.
# 
#         :param units: Temperature units, 'celsius' (default) or 'farenheit.'
#         :type units: :class:`str`
#         :returns: Thermometer temperature reading
#         :rtype: :class:`float`
#         :raises: :class:`braubuddy.thermometer.ReadError` if temperature can
#             not be read.
#         """
#         pass


# Path: braubuddy/thermometer/ds18b20_gpio.py
import ds18b20
from braubuddy.thermometer import DeviceError
from braubuddy.thermometer import ReadError
from braubuddy.thermometer import IThermometer


UNIT_MAP = {
    'celsius':      1,
    'fahrenheit':   2
}


class DS18B20Thermometer(IThermometer):
    """
    DS18B20 GPIO anagolgue thermometer manufactured by `Maxim
    Integrated Products <http://www.maximintegrated.com>`_.

    :raises: :class:`braubuddy.thermometer.DeviceError` if no DS18B20
        thermometer devices discovered.
    """

    def __init__(self):
        try:
            self._ds18b20_device = ds18b20.DS18B20()
        except Exception as err:
            msg = 'No DS18B20 devices discovered'

            raise DeviceError(msg)