
/*
 * wishmain.c
 *
 * This is the main program for the "wish" interpreter. This code
 * is very short since most of the code is hidden inside the Tcl and Tk
 * libraries.
 */

#include <errno.h>
#include <sys/mman.h>		// for disabling paging
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>

#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <string>


#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <tcl.h>
#include <tk.h>
#include <GL/glut.h>
#include <GL/glu.h>
#include <GL/gl.h>

/* Header file for function callback wrmake cleanitten in c++*/
#include "commands.h"
#include "globalHeader.h"
#include "c++/alarm.h"
#include "c++/telemetry.h"

/* Files that needed togl and openGL */

#include "togl.h"


#define ESCAPE     27           /* ASCII code for ESC character.*/
#define PITCH	   1
#define ROLL 	   2


int rotation_mode;
float current_xrot;
float current_zrot;
float lateral;
float port;
float stbd;
float camv1;
float camh1;
float camv2;
float camh2;
float vertical;
float base_rad;
double matrix_rot [16];
double cam_matrix_rot[16];


void do_transformations();
void draw_sub();
void draw_camera1();
void draw_camera2();



//-----------------------------------------------------------
void initialize_graphics ( struct Togl *togl )
{
   /* initial values*/
   /*rotation_mode = NOTHING; */

   lateral = 0.0;
   port = 0.0;
   stbd = 0.0;
   camv1 = 0.0;
   camh1 = 0.0;
   camh2 = 0.0;
   camv2 = 0.0;
   vertical = 0.0;
   base_rad = 0.15;
   current_xrot = 0.0;
   current_zrot = 0.0;

  /* If you need to set the background colour to
     anything other than the default colour (which is black),
     then here is where you should make a call to glClearColor(). */

  glEnable (GL_DEPTH_TEST);     /* Needed to make z-buffering work. */


  glMatrixMode (GL_PROJECTION); /* Now modifying projection matrix.*/
  glLoadIdentity ();
  gluPerspective (45.0,       /* Viewport is 45 degrees (in y).*/
                         1.0,        /* Aspect ratio of window (i.e., a square window).*/
                          0.2,       /* Distance from eye point */
                               	/* of near clipping plane. */
                         102.2);    /* Distance from eye point */
                                	/* of far clipping plane.*/

  glMatrixMode (GL_MODELVIEW);  /* Now modifying model view matrix.*/
  glLoadIdentity ();
  gluLookAt (0.0, 0.0, 5.0, 		/* Camera at (0, 0, 5) and */
  	     0.0, 0.0, 0.0,     	/* looking at point (0, 0, 0) with */
                  0.0, 1.0, 0.0);    	/* (0, 1, 0) as the `up' direction   */
                                		/* on the screen.                       */
}

void draw_scene ( struct Togl *togl ) {   /* Function called every time scene is drawn. */

  glClear (GL_COLOR_BUFFER_BIT |  /* Clear the frame buffer as                               */
              GL_DEPTH_BUFFER_BIT);  /* well as the z (depth) buffer.                            */

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix ();        	 /* Save the current model view matrix.   */

  do_transformations ();   	/* Do all translation, scaling, rotation.  */
  draw_sub();    		/* Draw the vehicle                        */
  draw_camera1();             /* Draw the first camera on the left */
  draw_camera2();             /* Draw the second camera on the right */

  glPopMatrix ();     	/* Restore model view matrix to */
                      	 	/* that before glPushMatrix ().     */

  Togl_SwapBuffers(togl);  	/* Bring the back buffer to the front so we can see it. */
}

void reshape_viewport (struct Togl *togl) {
   int width, height ;
   width = Togl_Width(togl);
   height = Togl_Height(togl);
   glViewport(0, 0, (GLint)width, (GLint)height);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();

   gluPerspective (45.0,       // Viewport is 45 degrees (in y).
                         1.0,        // Aspect ratio of window (i.e., a square window).
                          0.2,       // Distance from eye point
                               	// of near clipping plane.
                         102.2);    // Distance from eye point
                                	// of far clipping plane.


   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();

   glTranslatef( 0.0, 0.5, 0.0 );
   /*
   glScalef(2.0, 2.0, 2.0);
   */
   gluLookAt (0.0, 0.0, 4.0, 		// Camera at (0, 0, 4) and
  	     0.0, 0.0, 0.0,     	// looking at point (0, 0, 0) with
                  0.0, 1.0, 0.0);    	// (0, 1, 0) as the `up' direction
                                		// on the screen.
   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

}




/*********************************************************************************
 *
 * Tcl_AppInit --
 *
 *	This procedure performs application-specific initialization.
 *	Most applications, especially those that incorporate additional
 *	packages, will have their own version of this procedure.
 *
 *
 ***********************************************************************************/

int Tcl_AppInit(Tcl_Interp *interp)
{
  	/*
   	* Initialize both the Tcl and Tk libraries
   	*/
   	

    	if (Tcl_Init(interp) == TCL_ERROR) {
		return TCL_ERROR;
   	 }
   	
   	
   	 if (Tk_Init(interp) == TCL_ERROR) {
		return TCL_ERROR;
  	}
  	

   	 if (Togl_Init(interp) == TCL_ERROR) {
    		return TCL_ERROR;
    	}


    	Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL);

    	/*-------------------------------------------
    	* Specify the C callback functions for widget creation, display,
    	* and reshape.
    	*-------------------------------------------*/

    	
    	
   	Togl_CreateFunc( initialize_graphics );
   	Togl_DisplayFunc( draw_scene );
   	Togl_ReshapeFunc( reshape_viewport );

   	
   	
     	/*----------------------------------------------------------------------------
     	* Tcl_CreateCommand (interp, "Tcl command", C++ function, (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
     	*----------------------------------------------------------------------------*/


     	/* to animate vehicle */
     	/* Each of this funtions will return the number of degree or points the vehicle
       	 should lateral / rotate
     	*/
     	
     	
     	
     	Togl_CreateCommand( "lateral_veh", Lateral_Cmd );
     	Togl_CreateCommand( "port_veh", Port_Cmd );
     	Togl_CreateCommand( "stbd_veh", Stbd_Cmd );        	
     	Togl_CreateCommand( "camv1_veh", Camv1_Cmd );
     	Togl_CreateCommand( "camh1_veh", Camh1_Cmd );
     	Togl_CreateCommand( "camv2_veh", Camv2_Cmd );
     	Togl_CreateCommand( "camh2_veh", Camh2_Cmd );
     	Togl_CreateCommand( "pitch_veh", Pitch_Cmd );
     	Togl_CreateCommand( "roll_veh", Roll_Cmd );
     	Togl_CreateCommand( "vertical_veh", Vertical_Cmd );	


/******************************************************************************
 * Ventena Specific wish commands                                             *
 * The new functionalities for wish are created in the following section      *
 * These commands interface the c++ codes in the directory c++                *
 * Please take a look at the file commands.h and commands.c for more details  *
 ******************************************************************************/	

   	Tcl_CreateCommand(interp, "send_io_elem_info", send_io_elem_info_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

    	Tcl_CreateCommand(interp, "ret_io_elem_value", ret_io_elem_value_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

    	Tcl_CreateCommand(interp, "ret_all_info", ret_all_info_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

    	Tcl_CreateCommand(interp, "database_dump", database_dump_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

     	Tcl_CreateCommand(interp, "saving", saving_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

     	Tcl_CreateCommand(interp, "opening", opening_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

     	// sending the output list to database
     	Tcl_CreateCommand(interp, "send_out_list_info", send_out_list_info_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

     	// get all the outputs to be displayed inside listbox
     	Tcl_CreateCommand(interp, "display_output", display_output_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

     	// checking the IO element output database, Button database and Slidebar database to see if the button has been mapped there
     	Tcl_CreateCommand(interp, "check_out_db", check_out_db_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

     	// --------------------- Button -----------------------
     	
     	Tcl_CreateCommand(interp, "add_to_button_db", add_to_button_db_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
		
     	Tcl_CreateCommand(interp, "remove_button_from_db", remove_button_from_db_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);


    	// -------------------- Slidebar -----------------------------

     	Tcl_CreateCommand(interp, "add_to_slidebar_db", add_to_slidebar_db_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
		
     	Tcl_CreateCommand(interp, "remove_slidebar_from_db", remove_slidebar_from_db_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
		

     	//---------------------------------------------------------
     	
     	Tcl_CreateCommand(interp, "show_connection_existence", show_connection_existence_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
     		
	Tcl_CreateCommand(interp, "send_alternate_but_down", send_alternate_but_down_cmd,
			(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
			
			
	Tcl_CreateCommand(interp, "send_momentary_but_down", send_momentary_but_down_cmd,
			(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
			
	Tcl_CreateCommand(interp, "send_slide_down", send_slide_down_cmd,
			(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
			
	Tcl_CreateCommand(interp, "set_slide_value", set_slide_value_cmd,
			(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
			
	Tcl_CreateCommand(interp, "get_slide_value", get_slide_value_cmd,
			(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
						
	Tcl_CreateCommand(interp, "get_button_state", get_button_state_cmd,
			(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
			
			
	Tcl_CreateCommand(interp, "set_button_state", set_button_state_cmd,
			(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
			
	Tcl_CreateCommand(interp, "get_button_count", get_button_count_cmd,
			(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
			
	Tcl_CreateCommand(interp, "get_slidebar_count", get_slidebar_count_cmd,
			(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
			
	Tcl_CreateCommand(interp, "get_button_string", get_button_string_cmd,
			(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "get_button_name", get_button_name_cmd,
			(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
	Tcl_CreateCommand(interp, "get_button_color_type", get_button_color_type_cmd,
			(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
			
	Tcl_CreateCommand(interp, "get_slidebar_string", get_slidebar_string_cmd,
			(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
	Tcl_CreateCommand(interp, "get_slidebar_name", get_slidebar_name_cmd,
			(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
						
		     		
	/************************** Graphic Purposes ******************************/

     	Tcl_CreateCommand(interp, "get_depth_hist", get_depth_hist_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
        Tcl_CreateCommand(interp, "get_depth", get_depth_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "get_head_hist", get_head_hist_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	
	Tcl_CreateCommand(interp, "spawn_receive_thread", spawn_receive_thread_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
  	Tcl_CreateCommand(interp, "spawn_depth_thread", spawn_depth_thread_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_head", get_head_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

     	Tcl_CreateCommand(interp, "get_pitch", get_pitch_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

     	Tcl_CreateCommand(interp, "get_roll", get_roll_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

   	Tcl_CreateCommand(interp, "clean_up_screen", clean_up_screen_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

        Tcl_CreateCommand(interp, "get_button_connection", get_button_connection_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

        Tcl_CreateCommand(interp, "get_slide_connection", get_slide_connection_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "add_alarm_to_db", add_alarm_to_db_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "reset_alarm", reset_alarm_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "check_alarm", check_alarm_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	//Tcl_CreateCommand(interp, "generate_alarm", generate_alarm_cmd,
	//	     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "check_ana_status", check_ana_status_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "check_dig_status", check_dig_status_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
		
	Tcl_CreateCommand(interp, "check_other_status", check_other_status_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "get_ana_alarm_name", get_ana_alarm_name_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "get_dig_alarm_name", get_dig_alarm_name_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "get_other_alarm_name", get_other_alarm_name_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
	Tcl_CreateCommand(interp, "get_alarm_descr", get_alarm_descr_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
	Tcl_CreateCommand(interp, "get_alarm_name", get_alarm_name_cmd,
	             (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
        Tcl_CreateCommand(interp, "set_ana_alarm", set_ana_alarm_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
        Tcl_CreateCommand(interp, "set_other_alarm", set_other_alarm_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
			
	Tcl_CreateCommand(interp, "clear_alarm_list", clear_alarm_list_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
	Tcl_CreateCommand(interp, "send_clear_list_to_bottom", send_clear_list_to_bottom_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
     	Tcl_CreateCommand(interp, "stop_poll", stop_poll_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

     	Tcl_CreateCommand(interp, "test_poll", test_poll_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "set_light_db", set_light_db_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "send_switches_down", send_switches_down_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

      	Tcl_CreateCommand(interp, "set_graphic_info", set_graphic_info_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
   
	Tcl_CreateCommand(interp, "detritus_select", Detritus_select_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

        Tcl_CreateCommand(interp, "get_light_string", get_light_string_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "get_compass_string", get_compass_string_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "get_vehicle_string", get_vehicle_string_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "get_graph_info", get_graph_info_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "retSubAnaSize", retSubAnaSize_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
	Tcl_CreateCommand(interp, "retAnaOutSize", retAnaOutSize_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);


	Tcl_CreateCommand(interp, "setting_bar_detail", setting_bar_detail_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "getting_bar_detail", getting_bar_detail_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "get_bar_voltage", get_bar_voltage_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
		
	Tcl_CreateCommand(interp, "get_element_name", get_element_name_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "get_bname", get_bname_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_bcount", get_bcount_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_sname", get_sname_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_scount", get_scount_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "set_autopilot", set_autopilot_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
	Tcl_CreateCommand(interp, "set_arm", set_arm_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "set_camera", set_camera_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_compass_info", get_compass_info_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_vehicle_info", get_vehicle_info_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_depth_graph_info", get_depth_graph_info_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "ret_arm_string", ret_arm_string_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "ret_camera_string", ret_camera_string_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "auto_calibrate_max", auto_calibrate_max_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "auto_calibrate_min", auto_calibrate_min_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	//Tcl_CreateCommand(interp, "ret_auto_pilot_string", ret_arm_string_cmd,
	//	     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);	

	Tcl_CreateCommand(interp, "get_xy_pos", get_xy_pos_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
	Tcl_CreateCommand(interp, "saving_auto_pilot_string", saving_auto_pilot_string_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "saving_arm_string", saving_arm_string_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
	Tcl_CreateCommand(interp, "saving_cam_string", saving_cam_string_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
	Tcl_CreateCommand(interp, "loading_auto_pilot_string", loading_auto_pilot_string_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_CreateCommand(interp, "loading_arm_string", loading_arm_string_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
	Tcl_CreateCommand(interp, "loading_cam_string", loading_cam_string_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	
     	Tcl_CreateCommand(interp, "tool_select", Tool_select_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
        Tcl_CreateCommand(interp, "get_vehicle_act", get_vehicle_act_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
        Tcl_CreateCommand(interp, "get_auto_setpt", get_auto_setpt_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);		
        Tcl_CreateCommand(interp, "get_auto_head_status", get_auto_head_status_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
        Tcl_CreateCommand(interp, "get_auto_depth_status", get_auto_depth_status_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
        Tcl_CreateCommand(interp, "get_auto_altitude_status", get_auto_altitude_status_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
       	Tcl_CreateCommand(interp, "get_auto_depth_setpt", get_auto_depth_setpt_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "set_light_conn_db", set_light_conn_db_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_light_conn_db", get_light_conn_db_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "sending_camera_enable", sending_camera_enable_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "switch_arm_enable", switch_arm_enable_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_sit_camera_angle", get_sit_camera_angle_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_sony_camera_angle", get_sony_camera_angle_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_sony_camera_display", get_sony_camera_display_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "enabling_channel", enabling_channel_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_telemetry_status", get_telemetry_status_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
//	Tcl_CreateCommand(interp, "generate", generate_cmd,
//		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "bad_packet_counter", bad_packet_counter_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "switch_teleos_enable", switch_teleos_enable_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "set_tms_display",  set_tms_display_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_tms_display",  get_tms_display_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "check_bypass_status",  check_bypass_status_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_altitude",  get_altitude_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_8_ground_value",  get_8_ground_value_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "select_ground_mode",  select_ground_mode_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_16_ground_value",  get_16_ground_value_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "set_dive_num",  set_dive_num_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_dive_num",  get_dive_num_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "set_rpm_interval",  set_rpm_interval_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_rpm_interval",  get_rpm_interval_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_rpm_speed",  get_rpm_speed_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
     	Tcl_CreateCommand(interp, "get_vehicle_speed",  get_vehicle_speed_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_aux_heading",  get_aux_heading_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_ov_count",  get_ov_count_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_overlay_info",  get_overlay_info_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_overlay_channel",  get_overlay_channel_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_analog_value",  get_analog_value_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_top_analog_value",  get_top_analog_value_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_raw_analog_value",  get_raw_analog_value_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_digital_status",  get_digital_status_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_button_pos",  get_button_pos_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_slidebar_pos",  get_slidebar_pos_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "set_teleos_setup",  set_teleos_setup_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_teleos_info",  get_teleos_info_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_digital_value",  get_digital_value_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "send_default_down",  send_default_down_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "manipulate_auto_cruise_setpt", manipulate_auto_cruise_setpt_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "manipulate_auto_cruise_lat_setpt", manipulate_auto_cruise_lat_setpt_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "set_latitude_val",  set_latitude_val_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_latitude_val",  get_latitude_val_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_tms_info",  get_tms_info_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_raw_depth",  get_raw_depth_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "add_log_item",  add_log_item_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "delete_log_item",  delete_log_item_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "display_log_db",  display_log_db_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "check_log_db",  check_log_db_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_log_count",  get_log_count_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_log_info",  get_log_info_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_disk_status",  get_disk_status_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "disk_logging", disk_logging_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "subout_make", subout_make_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "download_init", download_init_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "set_disk_enable", set_disk_enable_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);							
	Tcl_CreateCommand(interp, "update_log_variables", update_log_variables_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_sub_output", get_sub_output_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "delete_single_input", delete_single_input_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);		
 	Tcl_CreateCommand(interp, "get_io_connection", get_io_connection_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);		
  	Tcl_CreateCommand(interp, "set_auto_cruise", set_auto_cruise_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);			
	Tcl_CreateCommand(interp, "serial_sensor_thread", serial_sensor_thread_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);			
	Tcl_CreateCommand(interp, "get_ship_head", get_ship_head_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);			
	Tcl_CreateCommand(interp, "dvl_altitude", dvl_altitude_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);			
	Tcl_CreateCommand(interp, "set_compass_deviation",  set_compass_deviation_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_compass_deviation",  get_compass_deviation_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_teleos_tx_string",  get_teleos_tx_string_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_teleos_rx_string",  get_teleos_rx_string_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_teleos_status",  get_teleos_status_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_ship_gyro_status",  get_ship_gyro_status_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_tms_status",  get_tms_status_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_current_time",  get_current_time_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_arm_display",  get_arm_display_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_cam_display",  get_cam_display_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_auto_cruise",  get_auto_cruise_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "send_arm_time_constant",  send_arm_time_constant_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "send_cam_time_constant",  send_cam_time_constant_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_arm_time_constant",  get_arm_time_constant_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_cam_time_constant",  get_cam_time_constant_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_dvl_heading",  get_dvl_heading_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
      	Tcl_CreateCommand(interp, "make_O_item", make_O_item_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "delete_O_item", delete_O_item_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_page", get_page_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);			
 	Tcl_CreateCommand(interp, "save_page", save_page_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);			
 	Tcl_CreateCommand(interp, "get_software_statistics", get_software_statistics_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);			
 	Tcl_CreateCommand(interp, "get_dvl_data", get_dvl_data_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);	
 	Tcl_CreateCommand(interp, "get_overlay_string", get_overlay_string_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);	
 	Tcl_CreateCommand(interp, "get_overlay_string_plus", get_overlay_string_plus_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);	
	Tcl_CreateCommand(interp, "get_overlay_strings_from_file", get_overlay_strings_from_file_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "put_overlay_strings_to_file", put_overlay_strings_to_file_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "put_teleos_ethernet_to_telemetry", put_teleos_ethernet_to_telemetry_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
	Tcl_CreateCommand(interp, "get_teleos_tx_ethernet", get_teleos_tx_ethernet_cmd,
		     (ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);

//****************************************************************************/
//MBARI Station keeping commands

    Tcl_CreateCommand(interp, "connect_auto_rov",
                      (Tcl_CmdProc*)connect_auto_rov_cmd, NULL, NULL);

    Tcl_CreateCommand(interp, "disconnect_auto_rov",
                      (Tcl_CmdProc*)disconnect_auto_rov_cmd, NULL, NULL);

    Tcl_CreateCommand(interp, "set_auto_rov_tmout", 
                      (Tcl_CmdProc*)set_auto_rov_tmout_cmd, NULL, NULL);
        
    Tcl_CreateCommand(interp, "get_auto_rov_serv", 
                      (Tcl_CmdProc*)get_auto_rov_serv_cmd, NULL, NULL);

    Tcl_CreateCommand(interp, "get_auto_rov_port", 
                      (Tcl_CmdProc*)get_auto_rov_port_cmd, NULL, NULL);

    Tcl_CreateCommand(interp, "get_auto_rov_connect", 
                      (Tcl_CmdProc*)get_auto_rov_connect_cmd, NULL, NULL);

    Tcl_CreateCommand(interp, "send_auto_rov_cmd", 
                      (Tcl_CmdProc*)send_auto_rov_cmd_cmd, NULL, NULL);

//********************** End Station Keeping Commands ************************/

/************************ End Ventena specific wish commands *****************/

	
	
	
    	Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);


    	return TCL_OK;

}




/********************************************************************************
 *
 * main --
 *	This is the main program for the application.
 *
 *********************************************************************************/


int main(int argc, char **argv)
{

    Tk_Main(argc, argv, Tcl_AppInit);

    return 0;		/* Needed only to prevent compiler warning. */
}

