/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : OdysseyThruster.h                                             */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 02/07/2000                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#ifndef _ODYSSEYTHRUSTER_H
#define _ODYSSEYTHRUSTER_H

#include "TailConeIF.h"
#include "EventLogIF.h"
#include "SerialDevice.h"
#include "SailDevice.h"

/*
CLASS 
OdysseyThruster

DESCRIPTION
Odyssey thruster device driver

AUTHOR
Tom O'Reilly
*/
class OdysseyThruster {

public:

  ///////////////////////////////////////////////////////////////////
  // Constructor
  // [input] serialDevice: SAIL network's SerialDevice object
  OdysseyThruster(SerialDevice *serialDevice);
  OdysseyThruster(SerialDevice *serialDevice, int timeout);
  ~OdysseyThruster();

  ///////////////////////////////////////////////////////////////////
  // Initialize serial port, reset thruster device
  DeviceIF::Status initialize(Boolean busMonitor);

  ///////////////////////////////////////////////////////////////////
  // Spin thruster with specified current
  DeviceIF::Status control(double current);

  ///////////////////////////////////////////////////////////////////
  // Return prop speed in rpm
  double propSpeed();

  ///////////////////////////////////////////////////////////////////
  // Enable thruster
  void enable();

  ///////////////////////////////////////////////////////////////////
  // Disable thruster; command() and initialize() will return error
  void disable();

  ///////////////////////////////////////////////////////////////////
  // Return True if enabled, else False
  Boolean enabled();

  ///////////////////////////////////////////////////////////////////
  // Returns motor current
  double current();
  
private:

  SailDevice *_sailDevice;

  char _command[32];
  char _reply[80];

  int _raw16usPeriod;
  double _propSpeed;
  double _current;
  int _rawBatt;

  Boolean _enabled;
  Boolean _initialized;

  int _thrusterTimeout;

  char _eventMsg[256];
};

#endif

