/*
********************************************************
Copyright 2000 MBARI.
MBARI Proprietary Information. All rights reserved.
NOTE: This file is automatically generated.
DO NOT MODIFY.
********************************************************
*/

#ifndef __DynamicControlIF_H
#define __DynamicControlIF_H

#include "TaskInterface.h"


#define DynamicControlIFServerName "DynamicControlIFServer"

/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : DynamicControlIF.idl                                          */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 02/07/2000                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
/*
CLASS 
DynamicControlIF

DESCRIPTION
TaskInterface to DynamicControl

AUTHOR
Tom O'Reilly
*/
class DynamicControlIF : public TaskInterface {

  friend class DynamicControlIF_SK;

  public:

  // Forward declarations of public structures
  struct Command;
  struct LogData;
  
  ////////////////////////////////////////////////////////////
  // Events generated by DynamicControl 
  enum Event {
    Ready,
    Update
  };

  enum VerticalMode {
    VmInitial = -1,
    Elevator,
    Pitch,
    Depth
  };

  enum HorizontalMode {
    HmInitial = -1,
    Rudder,
    Heading,
    Waypoint
  };

  enum SpeedMode {
    SmInitial = -1,
    Current,
    Speed
  };

  
  
  /////////////////////////////////////////////////////////
  // Describes command output of LayeredControl
  struct Command {
    DynamicControlIF::VerticalMode verticalMode;
    double vertical;
    DynamicControlIF::SpeedMode speedMode;
    double speed;
    DynamicControlIF::HorizontalMode horizontalMode;
    double horizontal;
    // Waypoint coords; valid only when horizontalMode == Waypoint
    double north;
    double east;
  };
  ////////////////////////////////////////////////////////////
  // TEST - Data to be logged
  struct LogData {
    double propOmegaCmd;
    double rudderCmd;
    double elevatorCmd;
  };
  DynamicControlIF(const char *name, int timeout = 10);

  DynamicControlIF(const char *name, const char *serverName, int timeout = 10);

  ~DynamicControlIF();

  ///////////////////////////////////////////////////////////////////
  // Get data to be logged
  void getLogData(DynamicControlIF::LogData *data);

  ///////////////////////////////////////////////////////////////////
  // Command depth, heading, speed
  void setCommand(DynamicControlIF::Command *command);

  ///////////////////////////////////////////////////////////////////
  // Set maximum heading rate
  // [input] rate: Maximum heading rate (meters/sec)
  void setMaxHeadingRate(double rate);

  ///////////////////////////////////////////////////////////////////
  // Get maximum heading rate (meters/sec)
  double maxHeadingRate();

  ///////////////////////////////////////////////////////////////////
  // Set maximum depth rate
  // [input] rate: Maximum depth rate (meters/sec)
  void setMaxDepthRate(double rate);

  ///////////////////////////////////////////////////////////////////
  // Get maximum depth rate (meters/sec)
  double maxDepthRate();

  ///////////////////////////////////////////////////////////////////
  // Set tau
  void setTau(float tau);

  ///////////////////////////////////////////////////////////////////
  // Get tau
  float tau();

  ///////////////////////////////////////////////////////////////////
  // Set pitch servo gains
  void setPitchServoGains(double proportional, double integral, double derivative);

  ///////////////////////////////////////////////////////////////////
  // Get pitch servo gains
  void pitchServoGains(double *proportional, double *integral, double *derivative);

  ///////////////////////////////////////////////////////////////////
  // Set heading servo gains
  void setHeadingServoGains(double proportional, double integral, double derivative);

  ///////////////////////////////////////////////////////////////////
  // Get heading servo gains
  void headingServoGains(double *proportional, double *integral, double *derivative);

  
  protected:

  // Message codes for each method
  enum DynamicControlIFMsgCode {
    GetLogDataMsgCode,
    SetCommandMsgCode,
    SetMaxHeadingRateMsgCode,
    MaxHeadingRateMsgCode,
    SetMaxDepthRateMsgCode,
    MaxDepthRateMsgCode,
    SetTauMsgCode,
    TauMsgCode,
    SetPitchServoGainsMsgCode,
    PitchServoGainsMsgCode,
    SetHeadingServoGainsMsgCode,
    HeadingServoGainsMsgCode
  };

  // Define message structure for each method
  struct GetLogDataMsg : Request, Reply {
    DynamicControlIF::LogData data;
  
  } _getLogDataMsg;

  struct SetCommandMsg : Request, Reply {
    DynamicControlIF::Command command;
  
  } _setCommandMsg;

  struct SetMaxHeadingRateMsg : Request, Reply {
    double rate;
  
  } _setMaxHeadingRateMsg;

  struct MaxHeadingRateMsg : Request, Reply {
    double returnVal;
  
  } _maxHeadingRateMsg;

  struct SetMaxDepthRateMsg : Request, Reply {
    double rate;
  
  } _setMaxDepthRateMsg;

  struct MaxDepthRateMsg : Request, Reply {
    double returnVal;
  
  } _maxDepthRateMsg;

  struct SetTauMsg : Request, Reply {
    float tau;
  
  } _setTauMsg;

  struct TauMsg : Request, Reply {
    float returnVal;
  
  } _tauMsg;

  struct SetPitchServoGainsMsg : Request, Reply {
    double proportional;
    double integral;
    double derivative;
  
  } _setPitchServoGainsMsg;

  struct PitchServoGainsMsg : Request, Reply {
    double proportional;
    double integral;
    double derivative;
  
  } _pitchServoGainsMsg;

  struct SetHeadingServoGainsMsg : Request, Reply {
    double proportional;
    double integral;
    double derivative;
  
  } _setHeadingServoGainsMsg;

  struct HeadingServoGainsMsg : Request, Reply {
    double proportional;
    double integral;
    double derivative;
  
  } _headingServoGainsMsg;

};

#endif

