r3322 | jgn | 2012-01-03 11:52:32 +1100 (Tue, 03 Jan 2012) | 1 line
This commit is contained in:
committed by
Douglas Clowes
parent
48992ffe70
commit
5fab34ac0d
@@ -1,142 +0,0 @@
|
||||
##
|
||||
# @file Magnetic Controller
|
||||
#
|
||||
# This is a driver for SICS to make following communication with the Labview Oxford device
|
||||
#
|
||||
# 1. read and set the Magnetic Field parameter : magneticField
|
||||
# 2. read the Magnetic Temperature paramter : magneticTemp
|
||||
#
|
||||
# Author: Jing Chen (jgn@ansto.gov.au) July 2011
|
||||
#
|
||||
# The Magnetic Controller can be installed with the following command,
|
||||
# ::scobj::magnetic::mkMagnetic {
|
||||
# name "magnetic"
|
||||
# IP localhost
|
||||
# PORT 62944
|
||||
# tuning 1
|
||||
# interval 1
|
||||
#
|
||||
|
||||
##
|
||||
# @brief Set a Magnetific Field value and send to the Oxford Device.
|
||||
#
|
||||
# @param basePath, The object path, this is where we keep our state variables.
|
||||
|
||||
namespace eval ::scobj::magnetic {
|
||||
}
|
||||
|
||||
proc ::scobj::magnetic::setting {} {
|
||||
set newField [sct target]
|
||||
set comm "setF $newField\r\n"
|
||||
|
||||
sct send $comm
|
||||
return checkReply
|
||||
}
|
||||
|
||||
proc ::scobj::magnetic::checkReplyFunc {basePath} {
|
||||
# set replyStr [sct result]
|
||||
#analysis the reply from the Oxford Device
|
||||
# if {[string first "Error" $replyStr] != -1} {
|
||||
# broadcast "ERROR: Oxford Device cannot set the new target value, check again!!"
|
||||
# }
|
||||
return idle
|
||||
}
|
||||
|
||||
##
|
||||
|
||||
# @brief Request a state report from the Oxford Device by sending a Magnetic Field request command
|
||||
proc ::scobj::magnetic::rqFieldFunc {} {
|
||||
set comm "getF\r\n"
|
||||
sct send $comm
|
||||
return rdFieldState
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Read and record the Magnetific Field value from the Oxford Device
|
||||
proc ::scobj::magnetic::rdFieldStateFunc {basePath} {
|
||||
set replyStr [sct result]
|
||||
broadcast "getF reply:$replyStr"
|
||||
if {[string first "Error" $replyStr] != -1} {
|
||||
broadcast "ERROR: cannot get the Magnetific Field value from the Oxford Device, check again!"
|
||||
} else {
|
||||
hset $basePath/magneticField $replyStr
|
||||
}
|
||||
|
||||
return idle
|
||||
}
|
||||
|
||||
|
||||
# @brief Request a state report from the Oxford Device by sending a Magnetic Temperature request command
|
||||
proc ::scobj::magnetic::rqTempFunc {} {
|
||||
set comm "getT\r\n"
|
||||
sct send $comm
|
||||
return rdTempState
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Read and record the Magnetific Temperature value from the Oxford Device
|
||||
proc ::scobj::magnetic::rdTempStateFunc {basePath} {
|
||||
set replyStr [sct result]
|
||||
broadcast "getT reply:$replyStr\n"
|
||||
if {[string first "Error" $replyStr] != -1} {
|
||||
broadcast "ERROR: cannot get the Magnetific Temperature value from the Oxford Device, check again!"
|
||||
} else {
|
||||
hset $basePath/magneticTemp $replyStr
|
||||
}
|
||||
|
||||
return idle
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
# @brief Make a Magnetic Controller
|
||||
#
|
||||
# @param argList, {name "magnetic" IP localhost PORT 65123 tuning 1 interval 1}
|
||||
#
|
||||
# name: name of magnetic controller object
|
||||
# IP: IP address of RF generator moxa box
|
||||
# PORT: Port number assigned to the generator on the moxa-box
|
||||
# tuning: boolean, set tuning=1 to allow instrument scientists to set the axe positions
|
||||
# interval: polling and ramping interval in seconds.
|
||||
|
||||
proc ::scobj::magnetic::mkMagnetic {argList} {
|
||||
# Generate parameter array from the argument list
|
||||
foreach {k v} $argList {
|
||||
set KEY [string toupper $k]
|
||||
set pa($KEY) $v
|
||||
}
|
||||
|
||||
MakeSICSObj $pa(NAME) SCT_OBJECT
|
||||
sicslist setatt $pa(NAME) klass instrument
|
||||
sicslist setatt $pa(NAME) long_name $pa(NAME)
|
||||
|
||||
hfactory /sics/$pa(NAME)/magneticField plain user float
|
||||
hfactory /sics/$pa(NAME)/magneticTemp plain user float
|
||||
|
||||
#makesctcontroller sct_magnetic rfamp $pa(IP):$pa(PORT)
|
||||
makesctcontroller sct_magnetic std $pa(IP):$pa(PORT)
|
||||
|
||||
hsetprop /sics/$pa(NAME)/magneticField read ::scobj::magnetic::rqFieldFunc
|
||||
hsetprop /sics/$pa(NAME)/magneticField rdFieldState ::scobj::magnetic::rdFieldStateFunc /sics/$pa(NAME)
|
||||
|
||||
hsetprop /sics/$pa(NAME)/magneticTemp read ::scobj::magnetic::rqTempFunc
|
||||
hsetprop /sics/$pa(NAME)/magneticTemp rdTempState ::scobj::magnetic::rdTempStateFunc /sics/$pa(NAME)
|
||||
|
||||
hsetprop /sics/$pa(NAME) tuning $pa(TUNING)
|
||||
|
||||
# Initialise properties required for generating the API for GumTree and to save data
|
||||
#::scobj::hinitprops $pa(NAME) magneticField magneticTemp
|
||||
|
||||
sct_magnetic poll /sics/$pa(NAME)/magneticField $pa(INTERVAL)
|
||||
sct_magnetic poll /sics/$pa(NAME)/magneticTemp $pa(INTERVAL)
|
||||
|
||||
if {$pa(TUNING)} {
|
||||
hfactory /sics/$pa(NAME)/set_magneticField plain user float
|
||||
|
||||
hsetprop /sics/$pa(NAME)/set_magneticField write ::scobj::magnetic::setting
|
||||
hsetprop /sics/$pa(NAME)/set_magneticField checkReply ::scobj::magnetic::checkReplyFunc /sics/$pa(NAME)
|
||||
|
||||
sct_magnetic write /sics/$pa(NAME)/set_magneticField $pa(INTERVAL)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
fileeval $cfPath(beamline)/sct_magnetic.tcl
|
||||
|
||||
::scobj::magnetic::mkMagnetic {
|
||||
name "magnetic"
|
||||
IP 137.157.204.8
|
||||
PORT 22
|
||||
tuning 1
|
||||
interval 3
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user