//*** zooCam.h contains function prototypes for the ZooGlider
//*** Apr2015 
//*** May2016 adding the zonar.c information as well
//*******************************************************************

//=== prototypes ==============================================================
short    zCam_on        ( void           ) ;
short    zCam_config_mux(  short turn_on ) ;
short    zCam_off       ( void        ) ;
short    get_z_prompt   ( TUPort *tup ) ;
short    send_zCam      ( TUPort *tup, char str[], char sget[], short echo ) ;
long     get_z_date     ( TUPort *tup ) ;
long     set_z_date     ( TUPort *tup ) ;
short    zCam_shutdown  ( TUPort *tup ) ;
short    zcam_start_unix( TUPort *tup ) ;
short    zcam_start     ( TUPort *tup ) ;
short    zcam_stop      ( TUPort *tup ) ;
int      zcam_snoop     ( void        ) ;
short    start_zoog_dive( short state ) ;
short    stop_zoog_dive ( void        ) ;
short    zooCam_state   ( void        ) ;

void     test_zCam      ( void        ) ;
void     menu_zCam      ( void        ) ;
//=============================================================================

//=== zonar.c prototypes ======================================================
short    zonarOn          ( void           ) ;
short    zonarConfigMux   ( short t        ) ;
short    zonarOff         ( void           ) ;
short    zonarAck         ( TUPort *tup    ) ;
short    zonarGetCfg      ( TUPort *tup    ) ;
short    zonarGetStatus   ( TUPort *tup    ) ;
void     zonarInitParams  ( void           ) ;
short    zonarInitDive    ( TUPort *tup    ) ;
short    zonarEndDive     ( TUPort *tup    ) ;
short    zonarBurst       ( TUPort *tup    ) ;
short    zonarDoBurst     ( TUPort *tup    ) ;
short    zonarQuery       ( TUPort *tup    ) ;
short    zonarLast        ( TUPort *tup, short beam ) ;
short    zonarState       ( void      ) ;

void     zooAlloc       ( struct adp_param *adp  ) ;
void     zonarStore     ( char *s, short k       ) ;
void     zonarPack      ( void        ) ;
void     zonarPost      ( void        ) ;
void     zoo_sbd_param  ( void        ) ;
void     zooFlashDump   ( short pid   ) ;
void     testZonar      ( void        ) ;
void     menuZonar      ( void        ) ;
void     createFakeZonar( void        ) ;

//=============================================================================

//=== state-machine definitions =============================================== 
//=== the state is defined by:
//=== all.zcam->zcamState for the zooCam.
//=== all.zcam->zonarState for the zonar.

#define ZCAM_OFF                0   // the zooCam is in idle-off mode
#define ZCAM_START_RQST         1   // we WANT to start it up (still off).
#define ZCAM_BOOTING            2   // it is in the process of booting up
#define ZCAM_BOOTED             3   // we have gotten a unix shell prompt.
#define ZCAM_RUNNING            4   // zooCam is now running
#define ZCAM_STOP_RQST          5   // we WANT to stop the ZooCam.
#define ZCAM_START_AGAIN        6   // first start failed, try again
#define ZONAR_START_AT_Z        7   // request to start at desired depth
#define ZONAR_WAITING_START     8   // now waiting for that depth

//=== define various start/stop errors of ZooCam ==============================
//=== the error status is stored in all.zcam->zcam_stat

#define ZOOG_FAIL_UNIX      0x0001  // Failed the UNIX start-up 
#define ZOOG_FAIL_START     0x0002  // Failed the program start-up
//#define ZOOG_8        0x0004  // not defined yet
//#define ZOOG_8        0x0008  // not defined yet
//-------------
#define ZOOG_SHDN_UNIX      0x0010  // failed shutting down unix
#define ZOOG_FAIL_STOP      0x0020  // failed stopping the program
//#define ZOOG_8      0x0040  // extra pumps needed to get to surface
//#define ZOOG_8      0x0080  // required too long to leave the surface
//------------- rest are not defined yet -------------

//=============================================================================

//=== zonar.c definitions =====================================================

//== define the command char set: must agree w/goZonar() zonar.c switch{}
#define ZONAR_NAK     '?'  // char from ZONAR when there is an error
#define ZONAR_ACK     '>'  // char used to get an ACK reply
#define ZONAR_CFG     'C'  // char used to get the configuration
#define ZONAR_STATUS  'S'  // char used to get the status
#define ZONAR_INIT    'I'  // char used to get initialize the dive
#define ZONAR_BURST   'B'  // char used to take a burst
#define ZONAR_LAST    'G'  // char used to get the last burst for a specific beam.
#define ZONAR_END     'E'  // char used to end the dive
#define ZONAR_LOWPWR  'L'  // char used to leave the zonar in low power
#define ZONAR_SHORE   '^'  // char used before relaying a shore command to zonar

#define ZONAR_QUERY   '#'  // char from ZONAR when it is waiting for a response
#define ZONAR_Q_DIVE  'd'  // char before QUERY, saying zonar wants the dive#
#define ZONAR_Q_TIME  't'  // char before QUERY, saying zonar wants the time
#define ZONAR_Q_PRESS 'p'  // char before QUERY, saying zonar wants the pressure

