import logging; logger = logging.getLogger("morse." + __name__)

import morse.core.sensor

from morse.core.services import service, async_service
from morse.core import status
from morse.helpers.components import add_data, add_property

class BoatGps(morse.core.sensor.Sensor):
    _name = "BoatGps"
    _short_desc = "gps"

    # define here the data fields exported by your sensor
    # format is: field name, default initial value, type, description
    add_data('boatx', 0.0, 'float', 'x coordinate of boat in world coordinates in meters')
    add_data('boaty', 0.0, 'float', 'y coordinate of boat in world coordinates in meters')

    def __init__(self, obj, parent=None):
        logger.info("%s initialization" % obj.name)
        morse.core.sensor.Sensor.__init__(self, obj, parent)

        logger.info('Component initialized')

    def default_action(self):

        self.local_data['boatx'] = self.position_3d.x # distance along X in world coordinates
        self.local_data['boaty'] = self.position_3d.y # distance along Y in world coordinates

