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

#ifndef __SimulatorIF_H
#define __SimulatorIF_H

#include "TaskInterface.h"

#include "BluefinBatteryIF.h"

#define SimulatorIFServerName "SimulatorIFServer"

class SimulatorIF : public TaskInterface {

  friend class SimulatorIF_SK;

  public:

  
  ////////////////////////////////////////////////////////////
  // Clients can subscribe to these events...
  enum Event {
    NewOutput
  };

  
  typedef double Vector[3];
  
  SimulatorIF(const char *name, int timeout = 10);

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

  ~SimulatorIF();

  ////////////////////////////////////////////////////////////
  // Set current velocity
  long setCurrent(double north, double east);

  ////////////////////////////////////////////////////////////
  // Set propeller speed (rads/sec), elevator (rads), and rudder (rads)
  long command(double propOmega, double elevator, double rudder);

  ////////////////////////////////////////////////////////////
  // Get position vector and Euler angles
  long state(SimulatorIF::Vector position, SimulatorIF::Vector positionRate, SimulatorIF::Vector euler, SimulatorIF::Vector eulerRate);

  ////////////////////////////////////////////////////////////
  // Get rotational velocity components
  long rotationalVelocity(SimulatorIF::Vector velocity, SimulatorIF::Vector backDiff);

  ////////////////////////////////////////////////////////////
  // Get translational velocity components
  long translationalVelocity(SimulatorIF::Vector velocity, SimulatorIF::Vector backDiff);

  ////////////////////////////////////////////////////////////
  // Get translational velocity components
  long translationalBottomVelocity(SimulatorIF::Vector vel_Bo_N_B);

  ////////////////////////////////////////////////////////////
  // Get control surface angles
  long controlSurfaces(double *rudder, double *elevator);

  ////////////////////////////////////////////////////////////
  // Get body force vector
  long force(SimulatorIF::Vector vector);

  ////////////////////////////////////////////////////////////
  // Get body torque vector
  long torque(SimulatorIF::Vector vector);

  ////////////////////////////////////////////////////////////
  // Get prop angular speed
  long propOmega(double *rpm);

  ////////////////////////////////////////////////////////////
  // Get thruster current
  long motorCurrent(double *motor);

  ////////////////////////////////////////////////////////////
  // Get water speed
  long waterSpeed(double *waterSpeed);

  ////////////////////////////////////////////////////////////
  // Get simulation time (seconds)
  double simTime();

  ////////////////////////////////////////////////////////////
  // Get water depth.  dx and dy are offsets, in meters, from the 
  // x,y (UTM) vehicle position.
  double waterDepth(double dx, double dy);

  ////////////////////////////////////////////////////////////
  // Get integer number of elapsed sample periods
  long nTs();

  ////////////////////////////////////////////////////////////
  // Get ranges for each Dvl beam:
  double beamRange(SimulatorIF::Vector offset_B, SimulatorIF::Vector los_B, double minRange, double maxRange, double rangeTol, long *simCntr, double *grazing, Boolean *surfaceDetect);

  ////////////////////////////////////////////////////////////
  // Get the range vector from the Usbl
  double usbl(SimulatorIF::Vector offset_B, SimulatorIF::Vector transponder, double minRange, double maxRange, SimulatorIF::Vector usblRange);

  ///////////////////////////////////////////////////////////////////
  // Return data for given battery 
  void getSimBatteryData(BluefinBatteryIF::BfBattData *data);

  ///////////////////////////////////////////////////////////////////
  // Return data for given battery 
  void getSimDeltaTData(Boolean *vertMt, Boolean *fwdEnabled);

  
  protected:

  // Message codes for each method
  enum SimulatorIFMsgCode {
    SetCurrentMsgCode,
    CommandMsgCode,
    StateMsgCode,
    RotationalVelocityMsgCode,
    TranslationalVelocityMsgCode,
    TranslationalBottomVelocityMsgCode,
    ControlSurfacesMsgCode,
    ForceMsgCode,
    TorqueMsgCode,
    PropOmegaMsgCode,
    MotorCurrentMsgCode,
    WaterSpeedMsgCode,
    SimTimeMsgCode,
    WaterDepthMsgCode,
    NTsMsgCode,
    BeamRangeMsgCode,
    UsblMsgCode,
    GetSimBatteryDataMsgCode,
    GetSimDeltaTDataMsgCode
  };

  // Define message structure for each method
  struct SetCurrentMsg : Request, Reply {
    long returnVal;
    double north;
    double east;
  
  } _setCurrentMsg;

  struct CommandMsg : Request, Reply {
    long returnVal;
    double propOmega;
    double elevator;
    double rudder;
  
  } _commandMsg;

  struct StateMsg : Request, Reply {
    long returnVal;
    SimulatorIF::Vector position;
    SimulatorIF::Vector positionRate;
    SimulatorIF::Vector euler;
    SimulatorIF::Vector eulerRate;
  
  } _stateMsg;

  struct RotationalVelocityMsg : Request, Reply {
    long returnVal;
    SimulatorIF::Vector velocity;
    SimulatorIF::Vector backDiff;
  
  } _rotationalVelocityMsg;

  struct TranslationalVelocityMsg : Request, Reply {
    long returnVal;
    SimulatorIF::Vector velocity;
    SimulatorIF::Vector backDiff;
  
  } _translationalVelocityMsg;

  struct TranslationalBottomVelocityMsg : Request, Reply {
    long returnVal;
    SimulatorIF::Vector vel_Bo_N_B;
  
  } _translationalBottomVelocityMsg;

  struct ControlSurfacesMsg : Request, Reply {
    long returnVal;
    double rudder;
    double elevator;
  
  } _controlSurfacesMsg;

  struct ForceMsg : Request, Reply {
    long returnVal;
    SimulatorIF::Vector vector;
  
  } _forceMsg;

  struct TorqueMsg : Request, Reply {
    long returnVal;
    SimulatorIF::Vector vector;
  
  } _torqueMsg;

  struct PropOmegaMsg : Request, Reply {
    long returnVal;
    double rpm;
  
  } _propOmegaMsg;

  struct MotorCurrentMsg : Request, Reply {
    long returnVal;
    double motor;
  
  } _motorCurrentMsg;

  struct WaterSpeedMsg : Request, Reply {
    long returnVal;
    double waterSpeed;
  
  } _waterSpeedMsg;

  struct SimTimeMsg : Request, Reply {
    double returnVal;
  
  } _simTimeMsg;

  struct WaterDepthMsg : Request, Reply {
    double returnVal;
    double dx;
    double dy;
  
  } _waterDepthMsg;

  struct NTsMsg : Request, Reply {
    long returnVal;
  
  } _nTsMsg;

  struct BeamRangeMsg : Request, Reply {
    double returnVal;
    SimulatorIF::Vector offset_B;
    SimulatorIF::Vector los_B;
    double minRange;
    double maxRange;
    double rangeTol;
    long simCntr;
    double grazing;
    Boolean surfaceDetect;
  
  } _beamRangeMsg;

  struct UsblMsg : Request, Reply {
    double returnVal;
    SimulatorIF::Vector offset_B;
    SimulatorIF::Vector transponder;
    double minRange;
    double maxRange;
    SimulatorIF::Vector usblRange;
  
  } _usblMsg;

  struct GetSimBatteryDataMsg : Request, Reply {
    BluefinBatteryIF::BfBattData data;
  
  } _getSimBatteryDataMsg;

  struct GetSimDeltaTDataMsg : Request, Reply {
    Boolean vertMt;
    Boolean fwdEnabled;
  
  } _getSimDeltaTDataMsg;

};

#endif

