/****************************************************************************/
/* Copyright (c) 2007 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : DynoLayeredControlServer.h                                    */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 02/23/2007                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#ifndef _DYNOLAYEREDCONTROLSERVER_H
#define _DYNOLAYEREDCONTROLSERVER_H

#include "LayeredControlServer.h"
#include "DynoCommand.h"
#include "Syslog.h"

#define DEFAULT_RESPONSE_TIME 500

class DynoLayeredControlServer : public LayeredControlServer {

public:

  DynoLayeredControlServer( int, char ** );
  ~DynoLayeredControlServer();

  virtual LayeredControlIF::Status appendBehaviors(
                                LayeredControlIF::BehaviorFilename file);
  virtual LayeredControlIF::Status insertBehaviors(
                                LayeredControlIF::BehaviorFilename file,
                                long behavior_id);
  virtual LayeredControlIF::Status deleteBehavior(long behavior_id);
  
  virtual double elapsedMissionTime()
  {
    Syslog::write("DynoLayeredControlServer elapsedMissionTime");
    return LayeredControlServer::elapsedMissionTime();
  }
  
  virtual void abortMission() { LayeredControlServer::abortMission(); }
  virtual Boolean abortingMission()
  {
    return LayeredControlServer::abortingMission();
  }

  virtual void state(double *elapsedTime,
             LayeredControlIF::MissionState *st, 
	     LayeredControlIF::Name behaviorName,
             short *behaviorIndex, long *behaviorId)
  {
    LayeredControlServer::state(elapsedTime, st, behaviorName,
                                behaviorIndex, behaviorId);
  }

  virtual int spawnAuxTasks();

  virtual void setNewBehaviorTimeoutLimit(long limit_in_seconds);
    

protected:

  LayeredControlIF::Status getDriverResponse(unsigned int milliWait=DEFAULT_RESPONSE_TIME);

  DynoCommand *_output;  // Commands to DynoLayeredControl  
  DynoCommand *_input;   // Responses from DynoLayeredControl
};


#endif

