diff --git a/tcl/astrium.tcl b/tcl/astrium.tcl index 29bd114e..783ad9e3 100644 --- a/tcl/astrium.tcl +++ b/tcl/astrium.tcl @@ -229,7 +229,7 @@ proc astchopcheckphase {chopper} { chocosct queue /sics/choco/asyst progress read set p2 [hval /sics/choco/${chopper}/dphas] if {abs($p2) < .03} { - wait 1 + wait 15 return idle } else { return busy @@ -306,6 +306,7 @@ proc astMakeChopperSpeed1 {var} { hsetprop $path checklimits astchopspeedlimit 0 hsetprop $path halt astchopstop hsetprop $path checkstatus astchopcheckspeed $ch + hsetprop $path priv manager makesctdriveobj $var $path DriveAdapter chocosct } #---------------------------------------------------------------------- @@ -321,6 +322,7 @@ proc astMakeChopperSpeed2 {var} { hsetprop $path checklimits astchopspeedlimit 0 hsetprop $path halt astchopstop hsetprop $path checkstatus astchopcheckspeed $ch + hsetprop $path priv manager makesctdriveobj $var $path DriveAdapter chocosct } #----------------------------------------------------------------------- @@ -351,6 +353,7 @@ proc astMakeChopperPhase1 {var} { hsetprop $path checklimits astchopphaselimit hsetprop $path halt astchopstop hsetprop $path checkstatus astchopcheckphase $ch + hsetprop $path priv manager makesctdriveobj $var $path DriveAdapter chocosct } #----------------------------------------------------------------------- @@ -366,6 +369,7 @@ proc astMakeChopperPhase2 {var} { hsetprop $path checklimits astchopphaselimit hsetprop $path halt astchopstop hsetprop $path checkstatus astchopcheckphase $ch + hsetprop $path priv manager makesctdriveobj $var $path DriveAdapter chocosct } #---------------------------------------------------------------------- @@ -380,7 +384,10 @@ proc astchopratiolimit {} { proc astMakeChopperRatio {var} { global choppers set ch [lindex $choppers 1] - set path /sics/choco/${ch}/ratio + set path /sics/choco/${ch}/Ratio + hdel $path + hfactory $path plain mugger float + chocosct connect $path hsetprop $path write astchopwrite "ratio 2 " hsetprop $path astchopwritereply astchopwritereply chocosct write $path @@ -452,10 +459,10 @@ if {$poldi == 1} { } set choppers [list chopper] - set chopperparlist [list amode aspee nspee nphas dphas averl ratio vibra t_cho \ + set chopperparlist [list amode aspee nspee nphas dphas averl ratio vibra vibax t_cho \ flowr vakum valve sumsi spver state] set chopperlonglist [list "Chopper Mode" "Actual Speed" "Set Speed" "Phase" "Phase Error" \ - "Loss Current" Ratio Vibration Temperature "Water Flow" Vakuum \ + "Loss Current" Ratio Vibration "Actual Vibration" Temperature "Water Flow" Vakuum \ Valve Sumsi] set chopperheader "POLDI Chopper Status" makesctcontroller chocosct std psts240:3005 "\r\n" 60 diff --git a/tcl/hdbutil.tcl b/tcl/hdbutil.tcl index 58aa23e9..8c02e7b6 100644 --- a/tcl/hdbutil.tcl +++ b/tcl/hdbutil.tcl @@ -568,6 +568,7 @@ proc makestdadmin {} { "exe batchpath" text hsetprop /instrument/experiment/batchpath priv user sicspoll add /instrument/experiment/batchpath hdb 60 + sicspoll add /instrument/experiment/datafilenumber hdb 60 } #---------------------------------------------------------- proc makecount {path} { diff --git a/tcl/nvs.tcl b/tcl/nvs.tcl new file mode 100644 index 00000000..6bbc3a3e --- /dev/null +++ b/tcl/nvs.tcl @@ -0,0 +1,157 @@ +#------------------------------------------------------------------------- +# This is a scriptcontext based driver for the NVS at SANS2. This NVS has +# the nasty feauture that its terminators are command dependent. +# +# Mark Koennecke, April 2009 +#----------------------------------------------------------------------- +makesctcontroller nvssct varterm psts229.psi.ch:3007 \n 30 +#makesctcontroller nvssct varterm localhost:8080 \n 30 +nvssct send "\\:REM\n" +nvssct debug -1 +MakeSecNVS nvs tilt nvssct +#---------------------------------------------------------------------------------- +# handle parameters first: Most are in the list. MODE is treated special, as an +# anchor for finding the status part of the reply and as the polled node used for +# updating the parameter list. Date, time and com mode are omitted. +#----------------------------------------------------------------------------------- +set nvsparlist [list R_SPEED A_SPEED P_LOSS R_CURRENT T_ROT T_INL T_OUT F_RATE A_VAC \ + V_OSC V_BCU Hz] + +foreach par $nvsparlist { + hfactory /sics/nvs/${par} plain internal float + nvssct connect /sics/nvs/${par} +} +#----------------------------------------------------------------- +proc nvsstatus {} { + sct send "\n:???\n" + return nvsstatusreply +} +#---------------------------------------------------------------- +# We purposely disregard the geterror mechanism here: it is better to +# have an old value rather then no value +#----------------------------------------------------------------- +proc nvsstatusreply {} { + global nvsparlist + set reply [sct result] + if {[string first ERR $reply] >= 0 \ + || [string first ASCERR $reply] >= 0} { + clientput "ERROR: $reply while reading NVS, parameter NOT updated" + return idle + } + set idx [string first MODE: $reply] + if {$idx < 0} { + clientput "Invalid status reponse $reply received from NVS" + return idle + } + set reply [string range $reply $idx end] + set parlist [split $reply /] + foreach pair $parlist { + set l [split $pair :] + set par [string trim [lindex $l 0]] + set value [string trim [lindex $l 1]] + if {[lsearch $nvsparlist $par] >= 0 || [string first MODE $par] >= 0} { + catch {hupdate /sics/nvs/${par} $value} msg + } + } + set speed [hval /sics/nvs/A_SPEED] + hupdate /sics/nvs $speed + return idle +} +#------------------------------------------------------------------------------- +set path /sics/nvs/MODE +hfactory $path plain internal text +hsetprop $path read nvsstatus +hsetprop $path nvsstatusreply nvsstatusreply +nvssct poll $path 60 +#================================================================================= +# This section cares for driving the NVS. Please note that there are two modes: +# at low speeds the NVS must be started before over 3000 RPM, a new value can be set. +# If ths NVS is already at speed, this step can be saved. +# Also we have to check for limits and forbidden speed regions +#-------------------------------------------------------------------------------- +set nvsrange [list -20 28800] +set nvsforbidden [list {3600 4500} {7800 10500} {21500 23500}] +#-------------------------------------------------------------------------------- +proc nvscheck {} { + global nvsrange nvsforbidden + set target [sct target] + set min [lindex $nvsrange 0] + set max [lindex $nvsrange 1] + if {$target < $min || $target > $max} { + error "$target is out of range" + } + foreach range $nvsforbidden { + set min [lindex $range 0] + set max [lindex $range 1] + if {$target > $min && $target < $max} { + error "$target is in forbidden region" + } + } + return OK +} +#-------------------------------------------------------------------------------- +# Halting for a NVS is interpreted as: leave at current speed +#-------------------------------------------------------------------------------- +proc nvshalt {} { + set current [hval /sics/nvs] + set send [format "\r:SDR %d\n" [expr int($current)]] + return nvsreply +} +#--------------------------------------------------------------------------------- +proc nvsreply {} { + set reply [sct result] + if {[string first ERR $reply] >= 0 \ + || [string first ASCERR $reply] >= 0} { + clientput "ERROR: $reply while driving NVS" + } + return idle +} +#-------------------------------------------------------------------------------- +# checking status +#-------------------------------------------------------------------------------- +proc nvscheckstatus {} { + set mode [sct runmode] + if {[string first start $mode] >= 0} { + return idle + } + set target [sct target] + set actual [hval /sics/nvs/A_SPEED] + if {abs($target - $actual) < 5} { + wait 20 + return idle + } + nvssct queue /sics/nvs/MODE progress read + return busy +} +#-------------------------------------------------------------------------------- +proc nvswrite {} { + set target [sct target] + set actual [hval /sics/nvs/A_SPEED] + if {$target < 50 } { + sct send "\r:HAL\n" + sct runmode halt + return nvsreply + } + if {$actual >= 3000} { + sct send [format "\r:SDR %d\n" [expr int($target)]] + sct runmode normal + } else { + sct send "\r:SST\n" + clientput "NVS started, check manually when done" + sct runmode start + } + return nvsreply +} +#--------------------------------------------------------------------------------- +hsetprop /sics/nvs checklimits nvscheck +hsetprop /sics/nvs checkstatus nvscheckstatus +hsetprop /sics/nvs halt nvshalt +hsetprop /sics/nvs nvsreply nvsreply +hsetprop /sics/nvs write nvswrite +hsetprop /sics/nvs runmode normal +nvssct write /sics/nvs + +nvssct queue /sics/nvs/MODE progress read +nvs tilt + + diff --git a/tcl/nvs20m.tcl b/tcl/nvs20m.tcl new file mode 100644 index 00000000..855987c8 --- /dev/null +++ b/tcl/nvs20m.tcl @@ -0,0 +1,163 @@ +#------------------------------------------------------------------------- +# This is a scriptcontext based driver for the NVS at SANS. +# +# script chains: +# +# - status reading: sitting at the Status node +# nvststatus - nvsstatusreply +# - driving: +# nvswrite - nvsreply +# +# Mark Koennecke, May 2009 +#----------------------------------------------------------------------- +makesctcontroller nvssct std psts223.psi.ch:3006 \n 30 +#makesctcontroller nvssct std localhost:8080 \n 30 +nvssct send "REM\n" +nvssct debug -1 +MakeSecNVS nvs tilt nvssct +#---------------------------------------------------------------------------------- +# handle parameters first: Most are in the list. MODE is treated special, as an +# anchor for finding the status part of the reply and as the polled node used for +# updating the parameter list. Date, time and com mode are omitted. +#----------------------------------------------------------------------------------- +set nvsparlist [list S_DREH I_DREH P_VERL STROM T_ROT T_VOR T_RUECK DURCHFL VAKUUM \ + BESCHL BCU Hz] + +foreach par $nvsparlist { + hfactory /sics/nvs/${par} plain internal float + nvssct connect /sics/nvs/${par} +} +#----------------------------------------------------------------- +proc nvsstatus {} { + sct send "???\n" + return nvsstatusreply +} +#---------------------------------------------------------------- +# We purposely disregard the geterror mechanism here: it is better to +# have an old value rather then no value +#----------------------------------------------------------------- +proc nvsstatusreply {} { + global nvsparlist + set reply [sct result] + if {[string first ERR $reply] >= 0 \ + || [string first ASCERR $reply] >= 0} { + clientput "ERROR: $reply while reading NVS, parameter NOT updated" + return idle + } + set idx [string first Status: $reply] + if {$idx < 0} { + clientput "Invalid status reponse $reply received from NVS" + return idle + } + set reply [string range $reply $idx end] + set parlist [split $reply /] + foreach pair $parlist { + set l [split $pair :] + set par [string trim [lindex $l 0]] + set value [string trim [lindex $l 1]] + if {[lsearch $nvsparlist $par] >= 0 || [string first Status $par] >= 0} { + catch {hupdate /sics/nvs/${par} $value} msg + } + } + set speed [hval /sics/nvs/I_DREH] + hupdate /sics/nvs $speed + return idle +} +#------------------------------------------------------------------------------- +set path /sics/nvs/Status +hfactory $path plain internal text +hsetprop $path read nvsstatus +hsetprop $path nvsstatusreply nvsstatusreply +nvssct poll $path 60 +#================================================================================= +# This section cares for driving the NVS. Please note that there are two modes: +# at low speeds the NVS must be started before over 3000 RPM, a new value can be set. +# If ths NVS is already at speed, this step can be saved. +# Also we have to check for limits and forbidden speed regions +#-------------------------------------------------------------------------------- +set nvsrange [list -20 28800] +set nvsforbidden [list {3600 4600} {7600 9600} {1 3599} ] +#-------------------------------------------------------------------------------- +proc nvscheck {} { + global nvsrange nvsforbidden + set target [sct target] + set min [lindex $nvsrange 0] + set max [lindex $nvsrange 1] + if {$target < $min || $target > $max} { + error "$target is out of range" + } + foreach range $nvsforbidden { + set min [lindex $range 0] + set max [lindex $range 1] + if {$target > $min && $target < $max} { + error "$target is in forbidden region" + } + } + return OK +} +#-------------------------------------------------------------------------------- +# Halting for a NVS is interpreted as: leave at current speed +#-------------------------------------------------------------------------------- +proc nvshalt {} { + set current [hval /sics/nvs] + set send [format "SDR %d\n" [expr int($current)]] + return nvsreply +} +#--------------------------------------------------------------------------------- +proc nvsreply {} { + set reply [sct result] + if {[string first ERR $reply] >= 0 \ + || [string first ASCERR $reply] >= 0} { + clientput "ERROR: $reply while driving NVS" + } + return idle +} +#-------------------------------------------------------------------------------- +# checking status +#-------------------------------------------------------------------------------- +proc nvscheckstatus {} { + set mode [sct runmode] + if {[string first start $mode] >= 0} { + return idle + } + set target [sct target] + set actual [hval /sics/nvs/I_DREH] + if {abs($target - $actual) < 5} { + wait 20 + return idle + } + nvssct queue /sics/nvs/Status progress read + return busy +} +#-------------------------------------------------------------------------------- +proc nvswrite {} { + set target [sct target] + set actual [hval /sics/nvs/I_DREH] + if {$target < 50 } { + sct send "HAL\n" + sct runmode halt + return nvsreply + } + if {$actual >= 3000} { + sct send [format "SDR %d\n" [expr int($target)]] + sct runmode normal + } else { + sct send "SST\n" + clientput "NVS started, check manually when done" + sct runmode start + } + return nvsreply +} +#--------------------------------------------------------------------------------- +hsetprop /sics/nvs checklimits nvscheck +hsetprop /sics/nvs checkstatus nvscheckstatus +hsetprop /sics/nvs halt nvshalt +hsetprop /sics/nvs nvsreply nvsreply +hsetprop /sics/nvs write nvswrite +hsetprop /sics/nvs runmode normal +nvssct write /sics/nvs + +nvssct queue /sics/nvs/Status progress read +nvs tilt + +