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

class ModemNotifier(AbstractMOOS):
    def default(self,  ci='unused'):
        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)
        #logger.info(str(self.data))

        if(self.data['NAME']=="boat"):
            #logger.info("boat notifying %d BOAT_X" % self.data['BOAT_X'])
            self.m.Notify("BOAT_X", self.data['BOAT_X'], cur_time)
            self.m.Notify("BOAT_Y", self.data['BOAT_Y'], cur_time)
            self.m.Notify("BOAT_HEADING", self.data['BOAT_HEADING'], cur_time)
            self.m.Notify("BOAT_HEADING_DOT", self.data['BOAT_HEADING_DOT'], cur_time)
            self.m.Notify("BOAT_SPEED", self.data['BOAT_SPEED'], cur_time)
        elif(self.data['NAME']=="scout"):
            self.m.Notify("BOX_BUDDY", self.data['BOX_BUDDY'], cur_time)
            self.m.Notify("PRESSURE_Z_BUDDY", self.data['PRESSURE_Z'], cur_time)