diff --git a/site_ansto/instrument/lyrebird/config/motors/sct_flightTube.tcl b/site_ansto/instrument/lyrebird/config/motors/sct_flightTube.tcl new file mode 100644 index 00000000..3b5f413c --- /dev/null +++ b/site_ansto/instrument/lyrebird/config/motors/sct_flightTube.tcl @@ -0,0 +1,102 @@ +# Author: + + +## +# @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 + +} + diff --git a/site_ansto/instrument/lyrebird/config/motors/spin_galil.tcl b/site_ansto/instrument/lyrebird/config/motors/spin_galil.tcl new file mode 100644 index 00000000..29ef096c --- /dev/null +++ b/site_ansto/instrument/lyrebird/config/motors/spin_galil.tcl @@ -0,0 +1,11 @@ +fileeval $cfPath(motors)/sct_flightTube.tcl + +::scobj::galil::mkGalil { + name "galil" + #IP 137.157.204.25 + IP localhost + PORT 1034 + tuning 1 + interval 1 +} + diff --git a/site_ansto/instrument/lyrebird/lyrebird_configuration.tcl b/site_ansto/instrument/lyrebird/lyrebird_configuration.tcl index 8563fb5f..ad832e4b 100644 --- a/site_ansto/instrument/lyrebird/lyrebird_configuration.tcl +++ b/site_ansto/instrument/lyrebird/lyrebird_configuration.tcl @@ -18,7 +18,7 @@ fileeval $cfPath(source)/source.tcl source $cfPath(hipadaba)/hipadaba_configuration.tcl fileeval $cfPath(motors)/motor_configuration.tcl -fileeval $cfPath(motors)/sct_flightTube.tcl +fileeval $cfPath(motors)/spin_galil.tcl fileeval $cfPath(motors)/positmotor_configuration.tcl #fileeval $cfPath(velsel)/velsel.tcl