102 lines
2.6 KiB
Tcl
102 lines
2.6 KiB
Tcl
# Author: jgn@ansto.gov.au
|
|
|
|
##
|
|
# @file Lyrebird Flight Tube Rotate controller
|
|
namespace eval ::scobj::galil {
|
|
variable sim_mode
|
|
}
|
|
|
|
|
|
##
|
|
# @brief Send a command which returns a TPF value from Motor
|
|
# @param nextState, State which handles the reply
|
|
# @return The next state
|
|
proc ::scobj::galil::getTPF {} {
|
|
sct send "TPF"
|
|
return ackCmd
|
|
}
|
|
|
|
##
|
|
# @brief Get a TPF value from Motor
|
|
# Convert TPF value to the Angle value which be displayed on Gumtree client.
|
|
proc ::scobj::galil::ackCmd {batpath} {
|
|
set tpfValue [sct result]
|
|
set tmp [expr {($tpfValue - 190161)*(-0.006696) + 25.77375473}]
|
|
broadcast "tpfValue = $tpfValue; tmp = $tmp"
|
|
hset $batpath/Angle $tmp
|
|
broadcast "Angle = [hget $batpath/Angle]"
|
|
return idle
|
|
}
|
|
|
|
##
|
|
# @brief Read Angle value from Gumtree client and then send the command to the Motor
|
|
# @return The next state
|
|
proc ::scobj::galil::getValue {nextState} {
|
|
set tmpAngle [sct target]
|
|
set comm "ANGLE=$tmpAngle"
|
|
sct send $comm
|
|
return $nextState
|
|
}
|
|
|
|
##
|
|
# @brief Get ACK from the Motor after sending an ANGLE command to the Motor
|
|
# @return IDLE
|
|
proc ::scobj::galil::rdStatusFunc {} {
|
|
set ack [sct result]
|
|
if {$ack == -1} {
|
|
broadcast "Done: angle command set correctly!"
|
|
} elseif {
|
|
broadcast "Error $ack: Angle is not set correctly, check the error code $ack!"
|
|
}
|
|
return idle
|
|
}
|
|
|
|
proc ::scobj::galil::mkGalil {argList} {
|
|
|
|
foreach {k v} $argList {
|
|
set KEY [string toupper $k]
|
|
set pa($KEY) $v
|
|
}
|
|
|
|
set NS ::scobj::$pa(NAME)
|
|
set internal $pa(INTERVAL)
|
|
set batObjName $pa(NAME)
|
|
|
|
set batpath /sics/$batObjName
|
|
|
|
set sim_mode [SplitReply [motor_simulation]]
|
|
#set sim_mode "false"
|
|
|
|
puts "sim_mode=$sim_mode"
|
|
|
|
MakeSICSObj $batObjName SCT_OBJECT
|
|
|
|
# Set hipadaba properties for GumTree interface
|
|
# and NeXus data file.
|
|
#sicslist setatt $pa(NAME) klass instrument
|
|
#sicslist setatt $pa(NAME) long_name $pa(NAME)
|
|
hsetprop $batpath klass NXaperture
|
|
|
|
hfactory /sics/$pa(NAME)/Angle plain user float
|
|
hfactory /sics/$pa(NAME)/setAngle plain user float
|
|
|
|
makesctcontroller sct_ft galil $pa(IP):$pa(PORT)
|
|
#makesctcontroller sct_ft std $pa(IP):$pa(PORT)
|
|
|
|
# Get the TPF value from the Motor, then convert to current ANGLE position
|
|
hsetprop $batpath read ${NS}::getTPF
|
|
hsetprop $batpath ackCmd ${NS}::ackCmd $batpath
|
|
|
|
# Read the ANGLE value from the Gumtree client, then send roate command to Motor and get ACK from Motor.
|
|
hsetprop $batpath write ${NS}::getValue rdStatus
|
|
hsetprop $batpath rdStatus ${NS}::rdStatusFunc
|
|
|
|
::scobj::hinitprops $batObjName setAngle Angle
|
|
|
|
puts "batpath : $batpath"
|
|
sct_ft poll $batpath $internal
|
|
sct_ft write $batpath
|
|
|
|
}
|
|
|