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

source /home/ventana/source/submenu/analog_input_list.tcl
source /home/ventana/source/submenu/analog_output_list.tcl

#------------------------------------------------------------------------------------#
# Initialize and set variable
#------------------------------------------------------------------------------------#

set cam2 .camera_popup2
set cam_timer2 0


#------------------------------------------------------------------------------------#
# This procedure create camera control display on the second screen
#------------------------------------------------------------------------------------#
	

proc camera_popup2 { } {

    global cam2
    global cam_timer2


    if [winfo exists $cam2] {
destroy $cam2
}
    global env
    set env(DISPLAY) :0.1
    toplevel $cam2 -width 32c -height 15c
    wm title $cam2 "Camera Control"

    label $cam2.labcamtitle \
        -foreground #0000b0 -height 0 -relief ridge -text {Cam Control} \
        -width 511
    button $cam2.butok -width 5 -height 3 \
        -command {set cam_timer2 0; send_down_camera2; destroy $cam2} -text OK 
    label $cam2.labshoulder \
        -text Shoulder
    label $cam2.labpan \
        -text Pan
    label $cam2.labtilt \
        -text Tilt


    #------------------------------------------------------------------------------------#
    # SHOULDER
    #------------------------------------------------------------------------------------#

    frame $cam2.shoulder_frame \
        -borderwidth 2 -height 95 -relief groove -width 680
    label $cam2.shoulder_frame.labsine \
        -text Sine
    label $cam2.shoulder_frame.labcosine \
        -text Cosine
    label $cam2.shoulder_frame.laboffset \
        -text Offset
    entry $cam2.shoulder_frame.entsine \
        -background white -textvariable cam_shoulder_sine -width 13  -state disabled
    entry $cam2.shoulder_frame.entcosine \
        -background white -textvariable cam_shoulder_cosine -width 13  -state disabled
    entry $cam2.shoulder_frame.entoffset \
        -background white -textvariable cam_shoulder_offset -width 13

    
    label $cam2.shoulder_frame.labcommand \
        -text Command
    label $cam2.shoulder_frame.labmaster \
        -text Master
    label $cam2.shoulder_frame.labfeedback \
        -text FeedBack
    entry $cam2.shoulder_frame.entcommand \
        -background white -textvariable cam_shoulder_command -width 13  -state disabled
    entry $cam2.shoulder_frame.entmaster \
        -background #d9d9d9 -textvariable cam_shoulder_master_value -width 13
    entry $cam2.shoulder_frame.entfeedback \
        -background #d9d9d9 -textvariable cam_shoulder_fb_value -width 13

    label $cam2.shoulder_frame.labservo \
        -text Servo
    entry $cam2.shoulder_frame.entservo \
        -background white -textvariable cam_shoulder_servo -width 14  -state disabled
    label $cam2.shoulder_frame.labtimeconst \
         -text "Time Const"
    label $cam2.shoulder_frame.labtimeconstunits \
         -text "X 20mSec"
    entry $cam2.shoulder_frame.enttimeconst \
         -background white -textvariable cam_time_constant -width 10

    label $cam2.shoulder_frame.plabel \
        -text P
    label $cam2.shoulder_frame.ilabel \
        -text I
    label $cam2.shoulder_frame.dlabel \
        -text D
    entry $cam2.shoulder_frame.entp \
        -background white -textvariable cam_p_shoulder -width 5
    entry $cam2.shoulder_frame.enti \
        -background white -textvariable cam_i_shoulder -width 5
    entry $cam2.shoulder_frame.entd \
        -background white -textvariable cam_d_shoulder -width 5
        

    button $cam2.shoulder_frame.butsine \
        -command { analog_input_list2 $cam2.shoulder_frame.entsine } \
        -height 21 -text v -width 27
    button $cam2.shoulder_frame.butcosine \
        -command { analog_input_list2 $cam2.shoulder_frame.entcosine } \
        -height 21 -text v -width 27
    button $cam2.shoulder_frame.butcommand \
        -command { surf_analog_input_list2 $cam2.shoulder_frame.entcommand } \
        -height 21 -text v -width 27
    button $cam2.shoulder_frame.butservo \
        -command { analog_output_list2 $cam2.shoulder_frame.entservo } \
        -height 21 -text v -width 27


    #------------------------------------------------------------------------------------#
    # PAN
    #------------------------------------------------------------------------------------#

    frame $cam2.pan_frame \
        -borderwidth 2 -height 95 -relief groove -width 680
    label $cam2.pan_frame.labsine \
        -text Sine
    label $cam2.pan_frame.labcosine \
        -text Cosine
    label $cam2.pan_frame.laboffset \
        -text Offset
    entry $cam2.pan_frame.entsine \
        -background white -textvariable cam_pan_sine -width 13  -state disabled
    entry $cam2.pan_frame.entcosine \
        -background white -textvariable cam_pan_cosine -width 13  -state disabled
    entry $cam2.pan_frame.entoffset \
        -background white -textvariable cam_pan_offset -width 13

    
    label $cam2.pan_frame.labcommand \
        -text Command
    label $cam2.pan_frame.labmaster \
        -text Master
    label $cam2.pan_frame.labfeedback \
        -text Feedback
    entry $cam2.pan_frame.entcommand \
        -background white -textvariable cam_pan_command -width 13  -state disabled
    entry $cam2.pan_frame.entmaster \
        -background #d9d9d9 -textvariable cam_pan_master_value -width 13
    entry $cam2.pan_frame.entfeedback \
        -background #d9d9d9 -textvariable cam_pan_fb_value -width 13

    label $cam2.pan_frame.labservo \
        -text Servo
    entry $cam2.pan_frame.entservo \
        -background white -textvariable cam_pan_servo -width 14   -state disabled

    label $cam2.pan_frame.plabel \
        -text P
    label $cam2.pan_frame.ilabel \
        -text I
    label $cam2.pan_frame.dlabel \
        -text D
    entry $cam2.pan_frame.entp \
        -background white -textvariable cam_p_pan -width 5
    entry $cam2.pan_frame.enti \
        -background white -textvariable cam_i_pan -width 5
    entry $cam2.pan_frame.entd \
        -background white -textvariable cam_d_pan -width 5


    button $cam2.pan_frame.butsine \
        -command { analog_input_list2 $cam2.pan_frame.entsine } \
        -height 21 -text v -width 27
    button $cam2.pan_frame.butcosine \
        -command { analog_input_list2 $cam2.pan_frame.entcosine } \
        -height 21 -text v -width 27
    button $cam2.pan_frame.butcommand \
        -command { surf_analog_input_list2 $cam2.pan_frame.entcommand } \
        -height 21 -text v -width 27
    button $cam2.pan_frame.butservo \
        -command { analog_output_list2 $cam2.pan_frame.entservo } \
        -height 21 -text v -width 27

    #------------------------------------------------------------------------------------#
    # TILT
    #------------------------------------------------------------------------------------#

    frame $cam2.tilt_frame \
        -borderwidth 2 -height 95 -relief groove -width 680
    label $cam2.tilt_frame.labsine \
        -text Sine
    label $cam2.tilt_frame.labcosine \
        -text Cosine
    label $cam2.tilt_frame.laboffset \
        -text Offset
    entry $cam2.tilt_frame.entsine \
        -background white -textvariable cam_tilt_sine -width 13   -state disabled
    entry $cam2.tilt_frame.entcosine \
        -background white -textvariable cam_tilt_cosine -width 13  -state disabled
    entry $cam2.tilt_frame.entoffset \
        -background white -textvariable cam_tilt_offset -width 13

    
    label $cam2.tilt_frame.labcommand \
        -text Command
    label $cam2.tilt_frame.labmaster \
         -text Master
    label $cam2.tilt_frame.labfeedback \
         -text Feedback
    entry $cam2.tilt_frame.entcommand \
        -background white -textvariable cam_tilt_command -width 13  -state disabled
    entry $cam2.tilt_frame.entmaster \
        -background #d9d9d9 -textvariable cam_tilt_master_value -width 13
    entry $cam2.tilt_frame.entfeedback \
        -background #d9d9d9 -textvariable cam_tilt_fb_value -width 13

    label $cam2.tilt_frame.labservo \
        -text Servo
    entry $cam2.tilt_frame.entservo \
        -background white -textvariable cam_tilt_servo -width 14 -state disabled
    label $cam2.tilt_frame.plabel \
        -text P
    label $cam2.tilt_frame.ilabel \
        -text I

    label $cam2.tilt_frame.dlabel \
        -text D
    entry $cam2.tilt_frame.entp \
        -background white -textvariable cam_p_tilt -width 5
    entry $cam2.tilt_frame.enti \
        -background white -textvariable cam_i_tilt -width 5
    entry $cam2.tilt_frame.entd \
        -background white -textvariable cam_d_tilt -width 5

    
    button $cam2.tilt_frame.butsine \
        -command { analog_input_list2 $cam2.tilt_frame.entsine } \
        -height 21 -text v -width 27
    button $cam2.tilt_frame.butcosine \
        -command { analog_input_list2 $cam2.tilt_frame.entcosine } \
        -height 21 -text v -width 27
    button $cam2.tilt_frame.butcommand \
        -command { surf_analog_input_list2 $cam2.tilt_frame.entcommand } \
        -height 21 -text v -width 27
    button $cam2.tilt_frame.butservo \
        -command { analog_output_list2 $cam2.tilt_frame.entservo } \
        -height 21 -text v -width 27

	#------------------------------------------------------------------------------------#
	# SETTING GEOMETRY
	#------------------------------------------------------------------------------------#



	place $cam2.labcamtitle -x 10 -y 10 -width 760 -height 20 
	place $cam2.shoulder_frame -x 80 -y 60 
	place $cam2.pan_frame -x 80 -y 160 
	place $cam2.tilt_frame -x 80 -y 260 
	place $cam2.labshoulder -x 5 -y 80 -anchor nw -bordermode ignore
	place $cam2.labpan -x 5 -y 180 -anchor nw -bordermode ignore
	place $cam2.labtilt -x 5 -y 280 -anchor nw -bordermode ignore


    #------------------------------------------------------------------------------------#
    # SHOULDER
    #------------------------------------------------------------------------------------#

    #------------------------------------------------------------------------------------#
    # Shoulder COLUMN 1
    #------------------------------------------------------------------------------------#
    
    place $cam2.shoulder_frame.labsine \
        -x 15 -y 10 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.labcosine \
        -x 5 -y 35 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.laboffset \
        -x 5 -y 60 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.entsine \
        -x 55 -y 10 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.entcosine \
        -x 55 -y 35 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.entoffset \
        -x 55 -y 60 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.butsine \
        -x 155 -y 10 -width 27 -height 21 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.butcosine \
        -x 155 -y 35 -width 27 -height 21 -anchor nw -bordermode ignore

    #------------------------------------------------------------------------------------#
    # Shoulder COLUMN 2
    #------------------------------------------------------------------------------------#
    
    place $cam2.shoulder_frame.labcommand \
        -x 190 -y 10 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.entcommand \
        -x 255 -y 10 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.labmaster \
        -x 200 -y 35 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.entmaster \
        -x 255 -y 35 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.labfeedback \
        -x 190 -y 60 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.entfeedback \
        -x 255 -y 60 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.butcommand \
        -x 355 -y 10 -width 27 -height 21 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.labtimeconst \
         -x 370 -y 60 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.labtimeconstunits \
         -x 520 -y 60 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.enttimeconst \
         -x 445 -y 60 -anchor nw -bordermode ignore


    #------------------------------------------------------------------------------------#
    # Shoulder COLUMN 3
    #------------------------------------------------------------------------------------#
    
    place $cam2.shoulder_frame.labservo \
        -x 400 -y 10 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.entservo \
        -x 445 -y 10 -anchor nw -bordermode ignore
    place $cam2.shoulder_frame.butservo \
        -x 545 -y 10 -width 27 -height 21 -anchor nw -bordermode ignore

    #------------------------------------------------------------------------------------#
    # Shoulder COLUMN 4
    #------------------------------------------------------------------------------------#
    
    place $cam2.shoulder_frame.plabel \
        -x 600 -y 10
    place $cam2.shoulder_frame.ilabel \
        -x 600 -y 35
    place $cam2.shoulder_frame.dlabel \
        -x 600 -y 60
    place $cam2.shoulder_frame.entp \
        -x 620 -y 10
    place $cam2.shoulder_frame.enti \
        -x 620 -y 35
    place $cam2.shoulder_frame.entd \
        -x 620 -y 60


    #------------------------------------------------------------------------------------#
    # PAN
    #------------------------------------------------------------------------------------#

    #------------------------------------------------------------------------------------#
    # Pan COLUMN 1
    #------------------------------------------------------------------------------------#
    
    place $cam2.pan_frame.labsine \
        -x 15 -y 10 -anchor nw -bordermode ignore
    place $cam2.pan_frame.labcosine \
        -x 5 -y 35 -anchor nw -bordermode ignore
    place $cam2.pan_frame.laboffset \
        -x 5 -y 60 -anchor nw -bordermode ignore
    place $cam2.pan_frame.entsine \
        -x 55 -y 10 -anchor nw -bordermode ignore
    place $cam2.pan_frame.entcosine \
        -x 55 -y 35 -anchor nw -bordermode ignore
    place $cam2.pan_frame.entoffset \
        -x 55 -y 60 -anchor nw -bordermode ignore
    place $cam2.pan_frame.butsine \
        -x 155 -y 10 -width 27 -height 21 -anchor nw -bordermode ignore
    place $cam2.pan_frame.butcosine \
        -x 155 -y 35 -width 27 -height 21 -anchor nw -bordermode ignore

    #------------------------------------------------------------------------------------#
    # Pan COLUMN 2
    #------------------------------------------------------------------------------------#

    place $cam2.pan_frame.labcommand \
        -x 190 -y 10 -anchor nw -bordermode ignore
    place $cam2.pan_frame.entcommand \
        -x 255 -y 10 -anchor nw -bordermode ignore
    place $cam2.pan_frame.labmaster \
        -x 200 -y 35 -anchor nw -bordermode ignore
    place $cam2.pan_frame.entmaster \
        -x 255 -y 35 -anchor nw -bordermode ignore
    place $cam2.pan_frame.labfeedback \
        -x 190 -y 60 -anchor nw -bordermode ignore
    place $cam2.pan_frame.entfeedback \
        -x 255 -y 60 -anchor nw -bordermode ignore
    place $cam2.pan_frame.butcommand \
        -x 355 -y 10 -width 27 -height 21 -anchor nw -bordermode ignore

    #------------------------------------------------------------------------------------#
    # Pan COLUMN 3
    #------------------------------------------------------------------------------------#

    place $cam2.pan_frame.labservo \
        -x 400 -y 10 -anchor nw -bordermode ignore
    place $cam2.pan_frame.entservo \
        -x 445 -y 10 -anchor nw -bordermode ignore
    place $cam2.pan_frame.butservo \
        -x 545 -y 10 -width 27 -height 21 -anchor nw -bordermode ignore

    #------------------------------------------------------------------------------------#
    # Pan COLUMN 4
    #------------------------------------------------------------------------------------#

    place $cam2.pan_frame.plabel \
        -x 600 -y 10
    place $cam2.pan_frame.ilabel \
        -x 600 -y 35
    place $cam2.pan_frame.dlabel \
        -x 600 -y 60
    place $cam2.pan_frame.entp \
        -x 620 -y 10
    place $cam2.pan_frame.enti \
        -x 620 -y 35
    place $cam2.pan_frame.entd \
        -x 620 -y 60


    #------------------------------------------------------------------------------------#
    # TILT
    #------------------------------------------------------------------------------------#

    #------------------------------------------------------------------------------------#
    # Tilt COLUMN 1
    #------------------------------------------------------------------------------------#

    place $cam2.tilt_frame.labsine \
        -x 15 -y 10 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.labcosine \
        -x 5 -y 35 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.laboffset \
        -x 5 -y 60 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.entsine \
        -x 55 -y 10 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.entcosine \
        -x 55 -y 35 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.entoffset \
        -x 55 -y 60 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.butsine \
        -x 155 -y 10 -width 27 -height 21 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.butcosine \
        -x 155 -y 35 -width 27 -height 21 -anchor nw -bordermode ignore

    #------------------------------------------------------------------------------------#
    # Tilt COLUMN 2
    #------------------------------------------------------------------------------------#

    place $cam2.tilt_frame.labcommand \
        -x 190 -y 10 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.entcommand \
        -x 255 -y 10 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.labmaster \
        -x 200 -y 35 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.entmaster \
        -x 255 -y 35 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.labfeedback \
        -x 190 -y 60 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.entfeedback \
        -x 255 -y 60 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.butcommand \
        -x 355 -y 10 -width 27 -height 21 -anchor nw -bordermode ignore


    #------------------------------------------------------------------------------------#
    # Tilt COLUMN 3
    #------------------------------------------------------------------------------------#

    place $cam2.tilt_frame.labservo \
        -x 400 -y 10 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.entservo \
        -x 445 -y 10 -anchor nw -bordermode ignore
    place $cam2.tilt_frame.butservo \
        -x 545 -y 10 -width 27 -height 21 -anchor nw -bordermode ignore

    #------------------------------------------------------------------------------------#
    # Tilt COLUMN 4
    #------------------------------------------------------------------------------------#

    place $cam2.tilt_frame.plabel \
        -x 600 -y 10
    place $cam2.tilt_frame.ilabel \
        -x 600 -y 35
    place $cam2.tilt_frame.dlabel \
        -x 600 -y 60
    place $cam2.tilt_frame.entp \
        -x 620 -y 10
    place $cam2.tilt_frame.enti \
        -x 620 -y 35
    place $cam2.tilt_frame.entd \
        -x 620 -y 60
    place $cam2.butok -x 350 -y 370


	#------------------------------------------------------------------------------------#
	# BINDING
	#------------------------------------------------------------------------------------#
	
	
	#------------------------------------------------------------------------------------#
	# Shoulder
	#------------------------------------------------------------------------------------#
		   
	bind $cam2.shoulder_frame.entp <Return> {send_down_camera2}
	bind $cam2.shoulder_frame.enti <Return> {send_down_camera2}
	bind $cam2.shoulder_frame.entd <Return> {send_down_camera2}
	bind $cam2.shoulder_frame.entoffset <Return> { send_down_camera2 }
	bind $cam2.shoulder_frame.enttimeconst <Return> { send_down_camera2 }
		
	#------------------------------------------------------------------------------------#
	# Pan
	#------------------------------------------------------------------------------------#
		
	bind $cam2.pan_frame.entp <Return> {send_down_camera2}
	bind $cam2.pan_frame.enti <Return> {send_down_camera2}
	bind $cam2.pan_frame.entd <Return> {send_down_camera2}
	bind $cam2.pan_frame.entoffset <Return> { send_down_camera2 }

	#------------------------------------------------------------------------------------#
	# Tilt
	#------------------------------------------------------------------------------------#
	
	bind $cam2.tilt_frame.entp <Return> {send_down_camera2}
	bind $cam2.tilt_frame.enti <Return> {send_down_camera2}
	bind $cam2.tilt_frame.entd <Return> {send_down_camera2}
	bind $cam2.tilt_frame.entoffset <Return> { send_down_camera2 }

	#------------------------------------------------------------------------------------#
	# Loop to update master and feedback value
	#------------------------------------------------------------------------------------#
	
	set cam_timer2 1
	loop_master_feedback_cam2




	

# end of proc "cam2_control_popup"
}



#------------------------------------------------------------------------------------#
# Loop to update master and feedback value
#------------------------------------------------------------------------------------#

proc loop_master_feedback_cam2 { } {

	global cam2 cam_timer2
	global cam_shoulder_master_value cam_shoulder_fb_value
	global cam_pan_master_value cam_pan_fb_value
	global cam_tilt_master_value cam_tilt_fb_value
	
	if {![winfo exists $cam2] || $cam_timer2 == 0} {return}
	
	#puts "camera_popup.tcl: updating camera master and feedback "
	
	set mf [ret_camera_string]
	set mf_list [ split $mf | ]
	

	set cam_shoulder_master_value [expr ([lindex $mf_list 0] - 180) ]
	set cam_shoulder_fb_value [lindex $mf_list 1]
	set cam_pan_master_value [expr ([lindex $mf_list 2] - 180) ]
	set cam_pan_fb_value [lindex $mf_list 3]
	set cam_tilt_master_value [expr ([lindex $mf_list 4] - 180) ]
	set cam_tilt_fb_value [lindex $mf_list 5]
		
	
	after 500 [list loop_master_feedback_cam2]
}


#------------------------------------------------------------------------------------#
# This procedure will set the new variables and send them down to the sub
#------------------------------------------------------------------------------------#

proc send_down_camera2 { } {

	global cam2 cam_string old_cam_string cam_timer2
	global cam_shoulder_sine cam_shoulder_cosine cam_shoulder_offset cam_shoulder_command cam_shoulder_master_value cam_shoulder_fb_value cam_shoulder_servo cam_p_shoulder cam_i_shoulder cam_d_shoulder
	global cam_pan_sine cam_pan_cosine cam_pan_offset cam_pan_command cam_pan_master_value cam_pan_fb_value cam_pan_servo cam_p_pan cam_i_pan cam_d_pan
	global cam_tilt_sine cam_tilt_cosine cam_tilt_offset cam_tilt_command cam_tilt_master_value cam_tilt_fb_value cam_tilt_servo cam_p_tilt cam_i_tilt cam_d_tilt
	global cam_time_constant
	
	set a1 [lindex $cam_shoulder_sine 2]
	set a2 [lindex $cam_shoulder_cosine 2]
	set a3 [lindex $cam_shoulder_command 2]
	set a4 [lindex $cam_shoulder_servo 2]
	
	set b1 [lindex $cam_pan_sine 2]
	set b2 [lindex $cam_pan_cosine 2]
	set b3 [lindex $cam_pan_command 2]
	set b4 [lindex $cam_pan_servo 2]

	set c1 [lindex $cam_tilt_sine 2]
	set c2 [lindex $cam_tilt_cosine 2]
	set c3 [lindex $cam_tilt_command 2]
	set c4 [lindex $cam_tilt_servo 2]
	
	if { $a1 == "" || $a2 == "" || $a3 == "" || $a4 == ""  || $b1 == ""  || $b2 == "" || $b3 == "" \
  	|| $b4 == "" || $c1 == ""  || $c2 == "" ||  $c3 == "" ||  $c4 == "" } {
        		
        		set status [tk_dialog  .cam_warning2 { } {Some of the fields are empty.  Close the Camera Control window anyway ?} warning 0 {Yes } { No} ]
       		switch $status {   0 {set cam_timer2 0; destroy $cam2; return }
       				1 {return} }
        		
        		
        	}
        	
        	
   	
   	set cam_string "$a1|$a2|$cam_shoulder_offset|$a3|$cam_shoulder_master_value|$cam_shoulder_fb_value|$a4|$cam_p_shoulder|$cam_i_shoulder|$cam_d_shoulder|$b1|$b2|$cam_pan_offset|$b3|$cam_pan_master_value|$cam_pan_fb_value|$b4|$cam_p_pan|$cam_i_pan|$cam_d_pan|$c1|$c2|$cam_tilt_offset|$c3|$cam_tilt_master_value|$cam_tilt_fb_value|$c4|$cam_p_tilt|$cam_i_tilt|$cam_d_tilt"
	
	
	set old_cam_string  $cam_string

	#------------------------------------------------------------------------------------#
	# Set the new values in database and send it down to the sub	
	#------------------------------------------------------------------------------------#
	
	set_camera  $a1 $a2 $cam_shoulder_offset $a3 $cam_shoulder_master_value $cam_shoulder_fb_value $a4 $cam_p_shoulder $cam_i_shoulder $cam_d_shoulder $b1 $b2 $cam_pan_offset $b3 $cam_pan_master_value $cam_pan_fb_value $b4 $cam_p_pan $cam_i_pan $cam_d_pan $c1 $c2 $cam_tilt_offset $c3 $cam_tilt_master_value $cam_tilt_fb_value $c4 $cam_p_tilt $cam_i_tilt $cam_d_tilt
        send_cam_time_constant $cam_time_constant
                                       	
	#------------------------------------------------------------------------------------#
	# save all the information as a single string so it's easier when we want to 
	# write it to configuration file
	#------------------------------------------------------------------------------------#
	
	saving_cam_string $cam_string  	
	
	

}		

	
