# Path: wfcommon/units.py
# def identity(value):
# def FToC(value): 
# def CToF(value): 
# def InHgToHPa(value):
# def HPaToInHg(value):
# def HPaToMmHg(value):
# def MmHgToHPa(value):
# def InToMm(value): 
# def MmToIn(value): 
# def MpsToKt(value):
# def KtToMps(value):
# def MpsToKmh(value):
# def KmhToMps(value):
# def MphToMps(value): 
# def MpsToMph(value): 
# def MpsToBft(value):
# def BftToMps(value):
# def convert(measure, value, to_units, from_units=None):
#     def __init__(self, units):
#     def convert(self, measure, value):        
#     def convert_back(self, measure, value):        
#     def temp(self, value):
#     def press(self, value):
#     def wind(self, value):
#     def rain(self, value):
# def unit_roll(measure, unit):
# class Converter(object):


import time
import logging
        import weather.stations.davis
from wfcommon import units
        Serial port tty to use. Defaults to /dev/ttyS0.

    period [numeric] (optional):
        Polling interval in seconds. Defaults to 60.
    '''

    ARCHIVE_INTERVAL=10

    port='/dev/ttyS0'
    period=60

    logger = logging.getLogger('station.vantagepro')

    name = 'Davis VantagePro'

    def run(self, generate_event, send_event, context={}):

        station = weather.stations.davis.VantagePro(self.port, self.ARCHIVE_INTERVAL)

        while True:

            try:
                station.parse()

                e = generate_event('press')
                e.value = units.InHgToHPa(station.fields['Pressure'])
                send_event(e)
                
                e = generate_event('temp')
                e.sensor = 0

# Path: wfcommon/units.py
# def identity(value):
# def FToC(value): 
# def CToF(value): 
# def InHgToHPa(value):
# def HPaToInHg(value):
# def HPaToMmHg(value):
# def MmHgToHPa(value):
# def InToMm(value): 
# def MmToIn(value): 
# def MpsToKt(value):
# def KtToMps(value):
# def MpsToKmh(value):
# def KmhToMps(value):
# def MphToMps(value): 
# def MpsToMph(value): 
# def MpsToBft(value):
# def BftToMps(value):
# def convert(measure, value, to_units, from_units=None):
#     def __init__(self, units):
#     def convert(self, measure, value):        
#     def convert_back(self, measure, value):        
#     def temp(self, value):
#     def press(self, value):
#     def wind(self, value):
#     def rain(self, value):
# def unit_roll(measure, unit):
# class Converter(object):


# Path: wfdriver/station/vantagepro.py
import time
import logging
        import weather.stations.davis
from wfcommon import units

        Serial port tty to use. Defaults to /dev/ttyS0.

    period [numeric] (optional):
        Polling interval in seconds. Defaults to 60.
    '''

    ARCHIVE_INTERVAL=10

    port='/dev/ttyS0'
    period=60

    logger = logging.getLogger('station.vantagepro')

    name = 'Davis VantagePro'

    def run(self, generate_event, send_event, context={}):

        station = weather.stations.davis.VantagePro(self.port, self.ARCHIVE_INTERVAL)

        while True:

            try:
                station.parse()

                e = generate_event('press')
                e.value = units.InHgToHPa(station.fields['Pressure'])
                send_event(e)
                
                e = generate_event('temp')
                e.sensor = 0

                e.value = units.FToC(station.fields['TempIn'])