APPENDIX H: TCL PROGRAMMING G UIDE 153TCL Server designed to interact with a TCL useramppermission offamplock 1ampclear 1set val1 0.0set val2 0.0set val3 0.0while { 1 } {set s [amplisten]if {[string length $s] > 0}{if {$s == “DATA”}{puts [format “Mach Value = %f; Voltage Value = %f;Current Value = %f.” $val1 $val2 $val3]ampresponse} elseif {$s == “READ1”}{set readTarget [ampexec “READ MACH” 5 “##$$” 1]scan readTarget “MACH Val %f” val1puts “READ1 COMPLETED”ampresponse} elseif {$s == “READ2”}{set readTarget [ampexec “READ VOLTAGE” 5“##$$” 1]scan readTarget “VOLT Val %f” val2puts “READ2 COMPLETED”ampresponse} elseif {$s == “READ3”}{set readTarget [ampexec “READ CURRENT” 5“##$$” 1]scan readTarget “AMP Val %f” val3puts “READ3 COMPLETED”ampresponse} elseif {$s == “CONSOLE”}{ampunlock 1puts “Lock Released. Waiting for DONECONSOLE input”ampresponsewhile { [amplisten] != “DONECONSOLE” }{ampdelay 10}amplock 1puts “Lock Acquired”ampresponse} elseif {$s == “QUIT”}{amppermission onampunlock 1puts “Exiting script”ampresponsebreak} else {Allow observersand operators toissue commands tothis TCL ServiceLock the consolefor this TCL serviceto use.Clear old data in the TCL internal buffer so that thereis no confusion when data is gathered upon userrequest.Initializing variablesRead in usercommand.If the reader requeststhe TCL service to re-acquire one of the threevalues, the TCL servicewill issue the commandto the target and read inthe value. It will alsorespond back to therequester with amessage,“COMPLETE”If user input is “DATA” , format the data associatedwith variables val1, val2, val3 in a string and respondback the user.If the user input is“CONSOLE”relinquish the writeconsole access lockand respond withcontent “Console Lockreleased and waitingfor inputDONECONSOLE”.If user input is QUIT lockup permission on TCLscript, unlock writeaccess and exit script.