/****************************************************************************/
/* Copyright (c) 2015 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : EZ17.h                                                        */
/* Author   : Henthorn                                                      */
/* Project  : i2MAP                                                         */
/* Version  : 1.0                                                           */
/* Created  : 06/01/2015                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#ifndef   _EZ17_
#define   _EZ17_

#include "Syslog.h"

/*
CLASS
EZ17

DESCRIPTION
EZ17 interface

AUTHOR
Henthorn
*/

class EZ17 {

public:

   enum EZ17_Pos {
      Home = 0,
      F56
   };

   EZ17(int fd);  // File descriptor to UDP socket connected to EZ17
   ~EZ17();

   void reset();      // Reset (use after a power cycle)
   int home();        
   int position() { return _position; }
   int goto_pos(EZ17_Pos pos);
   int goto_steps(int steps);
   void send_msg(const char *msg = NULL);
   int read_msg();
   void halt() { send_msg("/1T\r"); }
   int read_position(char ntries = 5);
   int last_known_position();
   void save_position();
   int set_position(int steps);
   int wait_for_move(unsigned int timeout_secs);
   const char* build_motion_cmd(const char* ez_cmd);

   char _outbuf[100];  // Send buffer
   char _inbuf[100];   // Receive buffer

protected:
   int _fd;
   int _position;      // Last known position (or steps)
   Boolean _home;      // Set to True if device has been homed since last reset

};

#endif
