/**************************************************************************
 * telemetry_string.h
 * comments added later
 *************************************************************************/


#ifndef TELEMETRY_STRING_H
#define TELEMETRY_STRING_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 <string>
#include <pthread.h>
#include <math.h>
#include <ctype.h>
#include "errors.h"

extern int teleos_enable;
extern int dive_num;
extern int rpm_interval;   // Dave 10/10/02
extern string log_filename;
extern int log_interval;
extern int log_time;
extern int disk_logging_status;     	
extern int printer_logging_status;

void *disk_logging(void *arg);

extern char* get_curr_time();


/* structure with info be be received and processed
 * from the ARL Vision Control System    (13 member)
 */
struct VisionControlStringIn_ {
	float turns_ext_in;
	float foreaft_ext_in;
	float lateral_ext_in;
	float vertical_ext_in;
	float spare_0_ext_in;
	float spare_1_ext_in;
	float spare_2_ext_in;
	float spare_3_ext_in;
	float spare_4_ext_in;
	float spare_5_ext_in;
	float spare_6_ext_in;
	float spare_7_ext_in;
	int input_ctr_disable;
} ;



/* structure with info be be received and processed
 * from the Tms Control System 
 */
struct TmsControlStringIn_ {
  	int cable_out;
  	int cable_speed;
   	int tension;
   	int pressure;
   	char tms_string[255];

};


// This is the structure for logging to disk information
struct Disk_Logging
{
	Disk_Logging *next;	// pointer to the next node
  	string name;
  	int type;
  	int channel;
  	
};



class Telemetry_String {
public:
   Telemetry_String()		throw();
   ~Telemetry_String()		throw();
   
   // functions used for vision and logging
   void		updateOutFields(int protocolChoice);
   char* 	vision_concat();
   char* 	logging_concat();
   char* 	depth_concat();
   char* 	rovhead_concat();
   char* 	shiphead_concat();
   int 		parse_and_set_string( char some_string[] );
   void 	lineout(int fd, char* line);

   VisionControlStringIn_ VisionControlStringIn;
   TmsControlStringIn_ TmsControlStringIn;


   // functions used for logging disk to data 
   Disk_Logging disk_log;
   int disk_log_time;   	// in minute
   Disk_Logging *first_log;
   Disk_Logging *log_ptr;
   int add_log_item (string name, int type, int channel, string filename, int time, int interval);
   //int delete_log_item (string name, int type, int channel);
   int delete_log_item (int index);
   int delete_all_log_item();
   void display_log_db();
   int check_log_db(string name);
   int log_count;
   char* get_log_info(int index);
   char* printing_log_data();

};


extern Telemetry_String telstring;

#endif
