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

class DistanceNotifier(AbstractMOOS):

    def default(self,  ci='unused'):
        precision = 0.2
        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)
        for key, value in self.data['distances'].items():
            #logger.info(key)
            if key == "scout1":
                self.m.Notify("RANGE_BUDDY", "binf="+str(value-precision)+",bsup="+str(value+precision), cur_time)
            if key == "scout2":
                self.m.Notify("RANGE_BUDDY", "binf="+str(value-precision)+",bsup="+str(value+precision), cur_time)
            if key == "boat":
                self.m.Notify("RANGE_B1", "binf="+str(value-precision)+",bsup="+str(value+precision), cur_time)