add He3 SICS controller

r3760 | jgn | 2012-10-08 13:29:25 +1100 (Mon, 08 Oct 2012) | 1 line
This commit is contained in:
Jing Chen
2012-10-08 13:29:25 +11:00
committed by Douglas Clowes
parent 5dcc460e78
commit a545823330
2 changed files with 275 additions and 46 deletions

View File

@@ -0,0 +1,187 @@
##
# @file He3 controller
#
# Author: Jing Chen (jgn@ansto.gov.au) June 2010
#
# The He3 controller can be installed with the following command,
# ::scobj::he3::mkHe3 {
# name "he3"
# IP localhost
# PORT 6290
# tuning 1
# interval 2
# }
#
# NOTE:
# If tuning=1 this will generate gom/set_gom, gchi/set_gchi and gphi/set_gphi
# nodes for the instrument scientists.
# The tuning parameter should be set to 0 for the users.
#
namespace eval ::scobj::he3 {
}
##
# @brief Request a state from the He3 controller by sending a get command
proc ::scobj::he3::rqStatFunc {} {
set comm "get\n"
sct send $comm
return rdState
}
##
# @brief Read and record the state report from the He3 server
proc ::scobj::he3::rdStatFunc {basePath} {
set replyStr [sct result]
hset $basePath/msg $replyStr
if {[string first "Error" $replyStr] != -1} {
broadcast "ERROR: Wrong Command to the He3 server, check again!"
} else {
set s1 [string trimright $replyStr "\n"]
set s2 [split $s1 ";:"]
array set stateArr $s2
hset $basePath/Amplitude $stateArr(amp)
hset $basePath/Frequence $stateArr(fre)
hset $basePath/NaN $stateArr(nan)
hset $basePath/T2 $stateArr(t2)
broadcast "Amp:$stateArr(amp); Fre:$stateArr(fre); NaN:$stateArr(nan); T2:$stateArr(t2)\n"
}
if {$replyStr != [sct oldval]} {
sct oldval $replyStr
sct update $replyStr
sct utime readtime
}
return idle
}
# send trigger signal and get repsponse from SICS
proc ::scobj::he3::sendTrigger {} {
set newPara [sct target]
if {[string equal [string toupper $newPara] "OK"]!=1} {
error "ERROR: please enter 'ok' to send a trigger signal to He3 device"
return idle
} else {
set cmd "trigger\r\n"
sct send $cmd
return checkReply
}
}
proc ::scobj::he3::checkReplyFunc {basePath} {
set replyStr [sct result]
hset $basePath/msg $replyStr
return idle
}
##
# @brief Make a He3 controller
#
# @param argList, {name "he3" IP localhost PORT 62900 tuning 1 interval 2}
#
# name: name of he3 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::he3::mkHe3 {argList} {
# Generate parameter array from the argument list
foreach {k v} $argList {
set KEY [string toupper $k]
set pa($KEY) $v
}
set hPath /sics/$pa(NAME)
MakeSICSObj $pa(NAME) SCT_OBJECT
sicslist setatt $pa(NAME) klass environment
sicslist setatt $pa(NAME) long_name $pa(NAME)
hsetprop $hPath oldval UNKNOWN
hfactory $hPath/msg plain internal text
hfactory $hPath/Amplitude plain internal float
hfactory $hPath/Frequence plain internal float
hfactory $hPath/NaN plain internal float
hfactory $hPath/T2 plain internal float
hset $hPath/Amplitude 0.0
hset $hPath/Frequence 0.0
hset $hPath/NaN 0.0
hset $hPath/T2 0.0
hsetprop $hPath klass environment
hsetprop $hPath privilege spy
hsetprop $hPath type part
hsetprop $hPath control true
hsetprop $hPath data true
foreach {hdbPath klass control data nxsave mutable priv alias} {
/sics/he3/Amplitude NXsensor true true true true user he3_Amplitude
/sics/he3/Frequence NXsensor true true true true user he3_Frequence
/sics/he3/NaN NXsample true true true true user he3_NaN
/sics/he3/T2 NXsample true true true true user he3_T2
} {
hsetprop $hdbPath nxalias $alias
hsetprop $hdbPath klass $klass
hsetprop $hdbPath privilege $priv
hsetprop $hdbPath control $control
hsetprop $hdbPath data $data
hsetprop $hdbPath nxsave $nxsave
hsetprop $hdbPath mutable $mutable
hsetprop $hdbPath sdsinfo ::nexus::scobj::sdsinfo
}
::scobj::hinitprops $pa(NAME)
makesctcontroller sct_he3 std $pa(IP):$pa(PORT)
hsetprop $hPath read ::scobj::he3::rqStatFunc
hsetprop $hPath rdState ::scobj::he3::rdStatFunc $hPath
# Initialise properties required for generating the API for GumTree and to save data
#::scobj::hinitprops $pa(NAME) Amplitude Frequence NaN T2
if {[SplitReply [environment_simulation]]=="false"} {
sct_he3 poll $hPath $pa(INTERVAL)
}
hsetprop $hPath tuning $pa(TUNING)
if {$pa(TUNING)} {
hfactory $hPath/send_trigger plain user text
::scobj::hinitprops $pa(NAME) send_trigger
hsetprop $hPath/send_trigger write ::scobj::he3::sendTrigger
hsetprop $hPath/send_trigger checkReply ::scobj::he3::checkReplyFunc /sics/$pa(NAME)
if {[SplitReply [environment_simulation]]=="false"} {
sct_he3 write $hPath/send_trigger $pa(INTERVAL)
}
}
}
proc He3Trigger {} {
set cmd "trigger\r\n"
sct_he3 send $cmd
}
publish He3Trigger user
::scobj::he3::mkHe3 {
name "he3"
IP 137.157.204.8
PORT 22
tuning 1
interval 1
}

View File

@@ -74,6 +74,12 @@ proc ::scobj::magnetic::rdTempSetPointStateFunc {basePath} {
hset $basePath/TempSetPoint $replyStr
}
if {$replyStr != [sct oldval]} {
sct oldval $replyStr
sct update $replyStr
sct utime readtime
}
return idle
}
@@ -100,6 +106,12 @@ proc ::scobj::magnetic::rdFieldStateFunc {basePath} {
hset $basePath/magneticField $replyStr
}
if {$replyStr != [sct oldval]} {
sct oldval $replyStr
sct update $replyStr
sct utime readtime
}
return idle
}
@@ -131,6 +143,12 @@ proc ::scobj::magnetic::rdTempStateFunc {basePath} {
hset $basePath/Temp_s3 $paraArr(T3)
}
if {$replyStr != [sct oldval]} {
sct oldval $replyStr
sct update $replyStr
sct utime readtime
}
return idle
}
@@ -153,50 +171,74 @@ proc ::scobj::magnetic::mkMagnetic {argList} {
}
MakeSICSObj $pa(NAME) SCT_OBJECT
#sicslist setatt $pa(NAME) klass environment
sicslist setatt $pa(NAME) klass environment
sicslist setatt $pa(NAME) long_name $pa(NAME)
hfactory /sics/$pa(NAME)/field plain user float
hfactory /sics/$pa(NAME)/magneticField plain user float
set hPath /sics/$pa(NAME)
hfactory /sics/$pa(NAME)/start_magnetic plain user float
hfactory /sics/$pa(NAME)/end_magnetic plain user float
hfactory $hPath/field plain user float
hfactory $hPath/magneticField plain user float
hfactory /sics/$pa(NAME)/Temp plain user float
hfactory /sics/$pa(NAME)/Temp_s1 plain user float
hfactory /sics/$pa(NAME)/Temp_s2 plain user float
hfactory /sics/$pa(NAME)/Temp_s3 plain user float
#hfactory /sics/$pa(NAME)/Set_Sensor_Temp user float
#hfactory /sics/$pa(NAME)/Set_Sensor_Channel user int
hfactory $hPath/start_magnetic plain user float
hfactory $hPath/end_magnetic plain user float
hfactory /sics/$pa(NAME)/start_temperature_s1 plain user float
hfactory /sics/$pa(NAME)/end_temperature_s1 plain user float
hfactory /sics/$pa(NAME)/start_temperature_s2 plain user float
hfactory /sics/$pa(NAME)/end_temperature_s2 plain user float
hfactory /sics/$pa(NAME)/start_temperature_s3 plain user float
hfactory /sics/$pa(NAME)/end_temperature_s3 plain user float
hfactory $hPath/Temp plain user float
hfactory $hPath/Temp_s1 plain user float
hfactory $hPath/Temp_s2 plain user float
hfactory $hPath/Temp_s3 plain user float
#hfactory $hPath/Set_Sensor_Temp user float
#hfactory $hPath/Set_Sensor_Channel user int
hfactory $hPath/start_temperature_s1 plain user float
hfactory $hPath/end_temperature_s1 plain user float
hfactory $hPath/start_temperature_s2 plain user float
hfactory $hPath/end_temperature_s2 plain user float
hfactory $hPath/start_temperature_s3 plain user float
hfactory $hPath/end_temperature_s3 plain user float
# Setting Magnetic field
hfactory /sics/$pa(NAME)/setPoint plain user float
hfactory /sics/$pa(NAME)/setRate plain user float
hfactory $hPath/setPoint plain user float
hfactory $hPath/setRate plain user float
# Setting Temperature & initiate
hfactory /sics/$pa(NAME)/TempSetTarget plain user float
hfactory /sics/$pa(NAME)/TempSetPoint plain user float
hfactory $hPath/TempSetTarget plain user float
hfactory $hPath/TempSetPoint plain user float
hset /sics/$pa(NAME)/magneticField 0
hset /sics/$pa(NAME)/setPoint 0
hset $hPath/magneticField 0
hset $hPath/setPoint 0
hset /sics/$pa(NAME)/TempSetTarget 0
hset /sics/$pa(NAME)/TempSetPoint 0
hset $hPath/TempSetTarget 0
hset $hPath/TempSetPoint 0
hsetprop $hPath oldval UNKNOWN
hsetprop $hPath/Temp oldval UNKNOWN
hsetprop $hPath/field oldval UNKNOWN
# add HDB file
hsetprop $hPath klass environment
hsetprop $hPath privilege spy
hsetprop $hPath type part
hsetprop $hPath control true
hsetprop $hPath data true
foreach {hdbPath klass control data nxsave mutable priv alias} {
/sics/magnetic/Temp_s1 NXsensor true true true true user magnetic_T1
/sics/magnetic/Temp_s2 NXsensor true true true true user magnetic_T2
/sics/magnetic/Temp_s3 NXsensor true true true true user magnetic_T3
/sics/magnetic/magneticField NXsensor true true true true user magnetic_Field
} {
hsetprop $hdbPath nxalias $alias
hsetprop $hdbPath klass $klass
hsetprop $hdbPath privilege $priv
hsetprop $hdbPath control $control
hsetprop $hdbPath data $data
hsetprop $hdbPath nxsave $nxsave
hsetprop $hdbPath mutable $mutable
hsetprop $hdbPath sdsinfo ::nexus::scobj::sdsinfo
}
# Initialise properties required for generating the API for GumTree and to save data
::scobj::hinitprops $pa(NAME) start_magnetic end_magnetic magneticField
::scobj::hinitprops $pa(NAME) start_temperature_s1 end_temperature_s1 Temp_s1
::scobj::hinitprops $pa(NAME) start_temperature_s2 end_temperature_s2 Temp_s2
::scobj::hinitprops $pa(NAME) start_temperature_s3 end_temperature_s3 Temp_s3
sicslist setatt $pa(NAME) klass environment
::scobj::hinitprops $pa(NAME)
# proc ::histogram_memory::pre_count "{fPath $pa(NAME)}" {
# hset /sics/$fPath/start_magnetic [hval /sics/$fPath/magneticField]
@@ -216,33 +258,33 @@ proc ::scobj::magnetic::mkMagnetic {argList} {
makesctcontroller sct_magnetic std $pa(IP):$pa(PORT)
hsetprop /sics/$pa(NAME) read ::scobj::magnetic::rqTempSetPointFunc
hsetprop /sics/$pa(NAME) rdTempSetPointState ::scobj::magnetic::rdTempSetPointStateFunc /sics/$pa(NAME)
hsetprop $hPath read ::scobj::magnetic::rqTempSetPointFunc
hsetprop $hPath rdTempSetPointState ::scobj::magnetic::rdTempSetPointStateFunc $hPath
hsetprop /sics/$pa(NAME)/field read ::scobj::magnetic::rqFieldFunc
hsetprop /sics/$pa(NAME)/field rdFieldState ::scobj::magnetic::rdFieldStateFunc /sics/$pa(NAME)
hsetprop $hPath/field read ::scobj::magnetic::rqFieldFunc
hsetprop $hPath/field rdFieldState ::scobj::magnetic::rdFieldStateFunc $hPath
hsetprop /sics/$pa(NAME)/Temp read ::scobj::magnetic::rqTempFunc
hsetprop /sics/$pa(NAME)/Temp rdTempState ::scobj::magnetic::rdTempStateFunc /sics/$pa(NAME)
hsetprop $hPath/Temp read ::scobj::magnetic::rqTempFunc
hsetprop $hPath/Temp rdTempState ::scobj::magnetic::rdTempStateFunc $hPath
if {[SplitReply [environment_simulation]]=="false"} {
sct_magnetic poll /sics/$pa(NAME) 1
sct_magnetic poll $hPath 1
#need to set interval to 1 if need to monitor magnetic value in Labview
#sct_magnetic poll /sics/$pa(NAME)/field 1
sct_magnetic poll /sics/$pa(NAME)/field $pa(INTERVAL)
sct_magnetic poll /sics/$pa(NAME)/Temp $pa(INTERVAL)
#sct_magnetic poll $hPath/field 1
sct_magnetic poll $hPath/field $pa(INTERVAL)
sct_magnetic poll $hPath/Temp $pa(INTERVAL)
}
hsetprop /sics/$pa(NAME) tuning $pa(TUNING)
hsetprop $hPath tuning $pa(TUNING)
if {$pa(TUNING)} {
hfactory /sics/$pa(NAME)/set_magneticField plain user float
hfactory $hPath/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)
hsetprop $hPath/set_magneticField write ::scobj::magnetic::setting
hsetprop $hPath/set_magneticField checkReply ::scobj::magnetic::checkReplyFunc $hPath
if {[SplitReply [environment_simulation]]=="false"} {
sct_magnetic write /sics/$pa(NAME)/set_magneticField
sct_magnetic write $hPath/set_magneticField
}
}