set dive_num [get_dive_num]

###########################
# Include source files    #
###########################

source /home/ventana/source/submenu/auto_cruise.tcl
source /home/ventana/source/submenu/auto_pilot_popup.tcl
source /home/ventana/source/submenu/arm_control_popup.tcl
source /home/ventana/source/submenu/camera_popup.tcl
source /home/ventana/source/submenu/teleos_setup.tcl
source /home/ventana/source/submenu/log_field.tcl


set software_statistics [split [get_software_statistics] |]
	        	
set serial_device_transmit [lindex $software_statistics 0]
set telemetry_receive_thread_timer [lindex $software_statistics 1]
set head_hist_and_telem_timer_thread_timer [lindex $software_statistics 2]
set depth_hist_thread_timer [lindex $software_statistics 3]
set io_poll_analogs_thread_timer [lindex $software_statistics 4]
set io_poll_digitals_thread_timer [lindex $software_statistics 5]
set disk_logging_thread_timer [lindex $software_statistics 6]
set serial_port_receive_thread_timer [lindex $software_statistics 7]


############################################
# Create the menu for the "Setting" button #
############################################

proc create_setting_submenu { } {

set v_setting .ventana.bar.maintenance.menu.setting
menu $v_setting

######################################
# Create window to enter Dive Number 	#
######################################

$v_setting add command -label "Dive Number" \
	-command dive_popup

######################################
# Create window to enter RPM Interval 	#
######################################

$v_setting add command -label "RPM Interval" \
	-command rpm_popup


# Create window to enter Latitude Value 	#
######################################

$v_setting add command -label "Latitude" \
	-command latitude_popup

	
###########################################
# Create the "Teleos" setup window        #
###########################################

$v_setting add command -label "Teleos Setup" \
	-command teleos_setup



###########################################
# Create the "Disk Logging" setup window  #
###########################################

$v_setting add command -label "Disk Logging" \
	-command logging

	
###########################################
# Create the "Auto Cruise" Window		         #
###########################################


$v_setting add command -label "Auto Cruise" \
	-command auto_cruise



###########################################
# Create the "Auto Pilot" submenu        	 #
###########################################


$v_setting add command -label "Auto Pilot" \
	-command auto_pilot_popup


###########################################
# Create the "Arm" submenu                #
###########################################

$v_setting add command -label "Arm Control" \
	-command arm_control_popup


	
###########################################
# Create the "Camera" submenu                #
###########################################

$v_setting add command -label "Camera Control" \
	-command camera_popup

	
###########################################
# Create the "Software" submenu                #
###########################################

$v_setting add command -label "Software Stats" \
	-command software_popup

###########################################
# Create the "Software" submenu                #
###########################################

$v_setting add command -label "Pilot Interface" \
	-command pilot_interface
	
	
# end of proc "create_setting_submenu"
}

proc software_popup { } {
	
	global env
	set env(DISPLAY) :0

	# Dave - April. 16, 2003
	if [winfo exists .software] {destroy .software}	
	toplevel .software
	wm title .software "Software Statistics"

	set software_statistics [split [get_software_statistics] |]
	        	
	set serial_device_transmit [lindex $software_statistics 0]
	set telemetry_receive_thread_timer [lindex $software_statistics 1]
	set head_hist_and_telem_timer_thread_timer [lindex $software_statistics 2]
	set depth_hist_thread_timer [lindex $software_statistics 3]
	set io_poll_analogs_thread_timer [lindex $software_statistics 4]
	set io_poll_digitals_thread_timer [lindex $software_statistics 5]
	set disk_logging_thread_timer [lindex $software_statistics 6]
	set serial_port_receive_thread_timer [lindex $software_statistics 7]
	
	label .software.label1 -text "Serial Devices Transmit Thread"
	entry .software.ent1 -bg white -width 10 -textvariable serial_device_transmit -state disabled
	label .software.label2 -text "Telemetry Receive Thread"
	entry .software.ent2 -bg white -width 10 -textvariable telemetry_receive_thread_timer -state disabled
	label .software.label3 -text "Heading History & Telemetry Timeout Thread"
	entry .software.ent3 -bg white -width 10 -textvariable head_hist_and_telem_timer_thread_timer -state disabled
	label .software.label4 -text "Depth History Thread"
	entry .software.ent4 -bg white -width 10 -textvariable depth_hist_thread_timer -state disabled
	label .software.label5 -text "Analog IO Polling Thread"
	entry .software.ent5 -bg white -width 10 -textvariable io_poll_analogs_thread_timer -state disabled
	label .software.label6 -text "Digital IO Polling Thread"
	entry .software.ent6 -bg white -width 10 -textvariable io_poll_digitals_thread_timer -state disabled
	label .software.label7 -text "Disk Logging Thread"
	entry .software.ent7 -bg white -width 10 -textvariable disk_logging_thread_timer -state disabled
	label .software.label8 -text "Serial Devices Receive Thread"
	entry .software.ent8 -bg white -width 10 -textvariable serial_port_receive_thread_timer -state disabled
	
	button .software.close -text "Close" \
		-command {destroy .software} -width 5 -height 2
	
	pack .software.label1 .software.ent1  -side top
	pack .software.label2 .software.ent2  -side top
	pack .software.label3 .software.ent3  -side top
	pack .software.label4 .software.ent4  -side top
	pack .software.label5 .software.ent5  -side top
	pack .software.label6 .software.ent6  -side top
	pack .software.label7 .software.ent7  -side top
	pack .software.label8 .software.ent8  -side top
	
	pack .software.close -side left  -pady 2m -padx 2m

        software_popup_update

}

proc software_popup_update { } {

	global serial_device_transmit telemetry_receive_thread_timer
	global head_hist_and_telem_timer_thread_timer
	global depth_hist_thread_timer io_poll_analogs_thread_timer
	global io_poll_digitals_thread_timer disk_logging_thread_timer
	global serial_port_receive_thread_timer
	
	if { ![winfo exists .software]} {return}
	
	set software_statistics [split [get_software_statistics] |]
	        	
        set serial_device_transmit [lindex $software_statistics 0]
        set telemetry_receive_thread_timer [lindex $software_statistics 1]
        set head_hist_and_telem_timer_thread_timer [lindex $software_statistics 2]
        set depth_hist_thread_timer [lindex $software_statistics 3]
        set io_poll_analogs_thread_timer [lindex $software_statistics 4]
        set io_poll_digitals_thread_timer [lindex $software_statistics 5]
    	set disk_logging_thread_timer [lindex $software_statistics 6]
        set serial_port_receive_thread_timer [lindex $software_statistics 7]

        after 1000 [list software_popup_update]

}
proc dive_popup { } {
	
	global env
	set env(DISPLAY) :0
	

	# Kenny - Nov. 18, 2002
	global dive_num	
	set dive_num [get_dive_num]
	
	if [winfo exists .dive] {destroy .dive}	
	toplevel .dive
	wm title .dive "Dive Number"
	
	label .dive.label -text "Dive Number"
	entry .dive.ent -bg white -width 10 -textvariable dive_num
	
	button .dive.ok -text "Ok" \
		-command {set_dive_num $dive_num } -width 5 -height 2
	button .dive.close -text "Close" \
		-command {destroy .dive} -width 5 -height 2
	
	pack .dive.label .dive.ent  -side top -pady 2m -padx 2m
	pack .dive.ok .dive.close -side left  -pady 2m -padx 2m
	
	bind .dive.ent <Return> { set_dive_num $dive_num }
	


}

proc rpm_popup { } {
	
	global env
	set env(DISPLAY) :0

	# Kenny - Nov. 18, 2002
	global rpm_interval	
	set rpm_interval [get_rpm_interval]
	
	
	if [winfo exists .rpm] {destroy .rpm}	
	toplevel .rpm
	wm title .rpm "RPM Interval"
	
	label .rpm.label -text "RPM Interval (Sec)"
	entry .rpm.ent -bg white -width 10 -textvariable rpm_interval
	
	button .rpm.ok -text "Ok" \
		-command {set_rpm_interval $rpm_interval } -width 5 -height 2
	button .rpm.close -text "Close" \
		-command {destroy .rpm} -width 5 -height 2
	
	pack .rpm.label .rpm.ent  -side top -pady 2m -padx 2m
	pack .rpm.ok .rpm.close -side left  -pady 2m -padx 2m
	
	bind .rpm.ent <Return> { set_rpm_interval $rpm_interval }
	


}



proc latitude_popup { } {
	
	global env
	set env(DISPLAY) :0

	# Kenny - Nov. 18, 2002
	global latitude_val	
	set latitude_val [get_latitude_val]
	
	
	if [winfo exists .latitude] {destroy .latitude}	
	toplevel .latitude
	wm title .latitude "Latitude Value"
	
	label .latitude.label -text "Latitude"
	entry .latitude.ent -bg white -width 10 -textvariable latitude_val
	
	button .latitude.ok -text "Ok" \
		-command {set_latitude_val $latitude_val } -width 5 -height 2
	button .latitude.close -text "Close" \
		-command {destroy .latitude} -width 5 -height 2
	
	pack .latitude.label .latitude.ent  -side top -pady 2m -padx 2m
	pack .latitude.ok .latitude.close -side left  -pady 2m -padx 2m
	
	bind .latitude.ent <Return> { set_latitude_val $latitude_val }
	

}
