import logging; logger = logging.getLogger("morse." + __name__)
import pymoos.MOOSCommClient
from morse.middleware.moos import AbstractMOOS
from morse.core import blenderapi
import random

class DvlNotifier(AbstractMOOS):
    def default(self,  ci='unused'):
        eps = 1.0

        cur_time=pymoos.MOOSCommClient.MOOSTime()
        # post the simulation time so that it can be synced to MOOSTime
        self.m.Notify('actual_time', blenderapi.persistantstorage().current_time, cur_time)
        velocity = self.data['velocity']

        #logger.info('%s' % velocity[0])
        #logger.info('%s' % velocity[1])
        #logger.info('%s' % velocity[2])

        self.m.Notify("DVL_VX", "binf="+str(velocity[0]-eps)+",bsup="+str(velocity[0]+eps), cur_time)
        self.m.Notify("DVL_VY", "binf="+str(velocity[1]-eps)+",bsup="+str(velocity[1]+eps), cur_time)
        self.m.Notify("DVL_VZ", "binf="+str(velocity[2]-eps)+",bsup="+str(velocity[2]+eps), cur_time)
