/**************************************************************************
 * telemetry.h
 * comments added later
 *************************************************************************/


#ifndef TELEMETRY_H
#define TELEMETRY_H


#include <sys/types.h>
#include <sys/stat.h>
#include <sys/signal.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <sched.h>
#include "telemetry_string.h"


extern int status;
extern pthread_t thread;
extern pthread_t thread_2;
extern pthread_attr_t etached_attr;

// for testing the parse error only
extern int parse_error;

/***********************************************************************/

//extern string command;
extern float sub_analog_in[64];		/* sub analog coming in */


extern int tty_send_request (char* cmd );
extern int tty_lineout(char* cmd);

extern void *send (void *arg);
extern void *tty_send_init (void *arg);
extern void *tty_recv_routine (void *arg);

extern void start_routine();
extern int spawn_receive_status;
extern int ground_channel;
extern float ground_value;
	
extern int armByte;
extern int camByte;

/***********************************************************************/



class Telemetry {
public:
	Telemetry()		throw();
	~Telemetry()		throw();
	
 	void auto_depth_calc();
 	void auto_altitude_calc();
 	void auto_head_calc();
        void head_calc();
	bool parse_and_set_values ();
	int bad_packet_counter;	
	
	
private:          	
	// value obtained from vehicle
	float depth, depth_jog;
	float head;
	
	// values obtained from surface
	float auto_depth, auto_depth_gain, auto_depth_offset;
	float auto_head, auto_head_gain, auto_head_offset;
		
	// values calculated
	float auto_depth_error, auto_head_error;
	float vert_command, lat_command;
	float foreaft_command, turns_command;
	float stbd_thruster, port_thruster;
	
	
};



extern Telemetry telemetryObj;

#endif
