sct_protek608.c

Implements a protocol handler for the protek  608 multimeters which just allows us to read the display.
It reports all elements of the display including the bar graph, it does not provide remote control of the multimeter.  The protocol handler broadcasts a warning to all clients if the auto-off function is enabled.

sct_rfamp.c
This is a protocol handler for the Mirrortron 35V 7A AC Generator (ANSFR-83B).

sinqhttpprot.c
Copied the PSI script context http protocol handler.

sct_orhvpsprot.c
Ordela high voltage power supply protocol handler now catches unknown commands.

sct_eurotherm_2000.tcl
Eurotherm controller for the kowari load frame by Douglas Clowes.

sct_lakeshore_3xx.tcl
Latest update from Arndt.  The two control loops are now independent, settletime and tolerance now work properly.

common_instrument_dictionary.tcl
Make instrument/status saveable.

sct_orhvps_common.tcl
Provides voltage ramping and implements the dhv1 command for the Ordela HVPS via the sct_orhpsprot.c protocol handler.

hmm_configuration_common_1.tcl
Adds new "histmem clockscale" subcommand to get and set the clock scale from the fat_clock_scale FAT parameter.
You can now upload the FAT FRAME_BUFFER and FRAME_DUTYCYCLE parameters to the histogram memory.
The veto commands are now "histmem veto on" and "histmem veto off".

hmm_object.tcl
The axis order for the histmem object has been restore to t,y,x

sct_positmotor_common.tcl
Code has been simplified.

nxscripts_common_1.tcl
Removed obsolete ::nexus::data function.  TOF axis now correctly report time_of_flight instead of "time".

plc_common_1.tcl
Make PLC info saveable.

scan_common_1.tcl
SICS-385 The scan command should check the final scan variable value against he soft upper and lower limits, not against the hard limits.
Make sure that the scan variable axis is saved.

platypus, kowari, quokka hmm_configuration.tcl
Use the HOR and VER entries in the new histmem_axes hash to select the horizontal and vertical axes for the histmem.

kowari motor_configuration.tcl secondary_slit_configuration.tcl
Flatten slits motor structure to match old layout in data files.

quokka commands.tcl
SICS-380 EApPosYmm -> EApPosY

quokka detector.tcl
Use new script context controller for Ordela HVPS

quokka hmm_configuration.tcl
Set detector height to 5.08*192 the same as the width

quokka motor_configuration.tcl
Code cleanup

quokka positmotor_configuration.tcl
Use new positmotor code.

quokka aperture_configuration.tcl
Added attenuation factor column to AttRotLookupTable

quokka parameters.tcl
SICS-380 Refactor nexus, remove redundant parameters.

site_ansto.c
Added the following protocols, Httpl, Protek608, aand RFAmp.

scriptcontext.c
SICS-386 SctActionHandler: set "send" string to NULL when a chain of scripts completes with state=idle.
It turns out that if none of the scripts in the "read chain" call [sct send] each time the chain is executed, then SICS will hammer the device with calls to AsconWrite(). This can be avoided if SctActionHandler sets the 'send' string to NULL before "goto finish" in the idle state. This will be safer and still let you have chains with multiple [sct send] and read scripts.

asyncprotocol.c
Fix platypus memory leak.

devser.c
SICS-387 Started adding code to pass signals on to script context drivers.

ascon.c
AsconTask(): Make sure we return to the AsconIdle state when sending a command which expect no response, also only reconnect if there is a Timeout when there has been an error.

r2888 | ffr | 2010-04-19 14:04:41 +1000 (Mon, 19 Apr 2010) | 90 lines
This commit is contained in:
Ferdi Franceschini
2010-04-19 14:04:41 +10:00
committed by Douglas Clowes
parent aa6bb7f1da
commit d9da95a5df
35 changed files with 3936 additions and 2477 deletions

View File

@@ -269,13 +269,27 @@ if {0} {
# value on all the servers.
proc clock_scale {args} {
switch $args {
"" { return 1 }
"" { return [expr [SplitReply [hmm configure fat_clock_scale]]/1000.0] }
"units" { return "microseconds"}
default {
todo_msg "Set clock_scale as an integer number of nanoseconds"
return -code error "[info level 0]: Invalid argument $args"
}
}
}
proc get_clock_scale {} {
return [SplitReply [hmm configure fat_clock_scale]]
}
proc set_clock_scale {val} {
set catch_status [ catch {
if {[string is integer $val] == 0} {
error "ERROR: clock scale should be an integer. NOTE: The clock base is in nanoseconds"
}
hmm configure fat_clock_scale $val
::histogram_memory::stop
hmm init
} message ]
handle_exception $catch_status $message
}
## @brief Use boundaries or centres to calculate axis values
#
# @param axis_name x_bin, y_bin, x_pixel_offset, y_pixel_offset, two_theta
@@ -850,7 +864,7 @@ proc CAT_TABLE {args} {
#
proc FAT_TABLE {args} {
if [ catch {
set attributes { FRAME_FREQUENCY SIZE_PERIOD NOS_PERIODS COUNT_METHOD COUNT_SIZE READ_DATA_TYPE VIEW_MAG_X VIEW_MAG_Y HISTO_STREAMING P7888_PLL_FREQ_CARD_X P7888_PLL_FREQ_CARD_Y P7888_CARD_MODE_X P7888_CARD_MODE_Y RAW_HISTO_XMIN RAW_HISTO_XMAX RAW_HISTO_YMIN RAW_HISTO_YMAX TEST_HISTO_1D_SIZES TEST_HISTO_2D_SIZES P7888_PLL_SYNC_METHOD }
set attributes { FRAME_FREQUENCY FRAME_BUFFER FRAME_DUTYCYCLE SIZE_PERIOD NOS_PERIODS COUNT_METHOD COUNT_SIZE READ_DATA_TYPE VIEW_MAG_X VIEW_MAG_Y HISTO_STREAMING P7888_PLL_FREQ_CARD_X P7888_PLL_FREQ_CARD_Y P7888_CARD_MODE_X P7888_CARD_MODE_Y RAW_HISTO_XMIN RAW_HISTO_XMAX RAW_HISTO_YMIN RAW_HISTO_YMAX TEST_HISTO_1D_SIZES TEST_HISTO_2D_SIZES P7888_PLL_SYNC_METHOD }
set elements {{ }}
@@ -1262,6 +1276,7 @@ proc ::histogram_memory::upload_config {filler_defaults} {
# Restore the init level to 0
# subesquent inits will only upload specified FAT settings to histogram server.
hmm configure init 0
hmm init
# Now issue stop to the server.
# This not only makes sure it's stopped, but lets us see certain configuration variables
@@ -1394,7 +1409,6 @@ proc ::histogram_memory::set_frame_freq {freq {frame_source EXTERNAL}} {
::set newfreq $freq
}
::histogram_memory::stop
set clock_scale_ns 1000.0
hmm configure fat_frame_frequency $newfreq
hmm init
} message ] {
@@ -1504,6 +1518,7 @@ proc ::histogram_memory::ic_initialize {} {
::histogram_memory::initialise_dictionary
::histogram_memory::frame_source_always_internal $default_frame_source_always_internal([instname])
::histogram_memory::set_frame_freq 50
::histogram_memory::set_clock_scale 1000
::histogram_memory::set_frame_source $default_frame_source_when_there_is_no_frame_signal([instname])
::histogram_memory::count_method unlimited
::histogram_memory::count_size 0
@@ -1591,14 +1606,14 @@ proc ::histogram_memory::post_count {} {}
proc ::histogram_memory::veto {action} {
switch $action {
"enable" {
"on" {
if {[status] == "status = Counting"} {
hmm veto
} else {
error "ERROR: veto only allowed while counting"
}
}
"disable" {
"off" {
if {[status] == "status = Paused"} {
hmm noveto
} else {
@@ -1606,7 +1621,7 @@ proc ::histogram_memory::post_count {} {}
}
}
default {
error "ERROR: $action must be 'enable' or 'disable'"
error "ERROR: $action must be 'on' or 'off'"
}
}
}
@@ -1800,6 +1815,13 @@ namespace eval ::histogram_memory {
eval "::histogram_memory::count_size $args"
}
}
"clockscale" {
if {$args == ""} {
set reply [::histogram_memory::get_clock_scale ]
} else {
eval "::histogram_memory::set_clock_scale $args"
}
}
"freq" {
if {$args == ""} {
set reply [::histogram_memory::get_frame_freq ]

View File

@@ -213,38 +213,38 @@ proc ::histogram_memory::set_axes {typelist} {
switch [string toupper $type] {
"HISTOGRAM_XYT" - "HISTOPERIOD_XYT" {
lappend rank 3
set dim0 [SplitReply [$HMOBJ configure $INST_NXC]]
set dim0 [SplitReply [$HMOBJ configure oat_ntc_eff]]
set dim1 [SplitReply [$HMOBJ configure $INST_NYC]]
set dim2 [SplitReply [$HMOBJ configure oat_ntc_eff]]
set dim2 [SplitReply [$HMOBJ configure $INST_NXC]]
lappend dimstr "$dim0,$dim1,$dim2"
lappend hmmslabstart [list 0 0 0]
lappend hmmslabend [list $dim0 $dim1 $dim2]
lappend hmmperiodsize [expr $dim0 * $dim1 * $dim2]
lappend axeslist [::histogram_memory::gen_axes {SVAR HOR VER TOF}]
lappend axeslist [::histogram_memory::gen_axes {SVAR TOF VER HOR}]
lappend siglist $signal
lappend hmmdatname $HMOBJ
}
"HISTOGRAM_XY" - "HISTOPERIOD_XY" {
lappend rank 2
set dim0 [SplitReply [$HMOBJ configure $INST_NXC]]
set dim1 [SplitReply [$HMOBJ configure $INST_NYC]]
set dim0 [SplitReply [$HMOBJ configure $INST_NYC]]
set dim1 [SplitReply [$HMOBJ configure $INST_NXC]]
lappend dimstr "$dim0,$dim1"
lappend hmmslabstart [list 0 0]
lappend hmmslabend [list $dim0 $dim1]
lappend hmmperiodsize [expr $dim0 * $dim1]
lappend axeslist [::histogram_memory::gen_axes {SVAR HOR VER}]
lappend axeslist [::histogram_memory::gen_axes {SVAR VER HOR}]
lappend siglist $signal
lappend hmmdatname "${HMOBJ}_xy"
}
"HISTOGRAM_XT" - "HISTOPERIOD_XT" {
lappend rank 2
set dim0 [SplitReply [$HMOBJ configure $INST_NXC]]
set dim1 [SplitReply [$HMOBJ configure oat_ntc_eff]]
set dim0 [SplitReply [$HMOBJ configure oat_ntc_eff]]
set dim1 [SplitReply [$HMOBJ configure $INST_NXC]]
lappend dimstr "$dim0,$dim1"
lappend hmmslabstart [list 0 0]
lappend hmmslabend [list $dim0 $dim1]
lappend hmmperiodsize [expr $dim0 * $dim1]
lappend axeslist [::histogram_memory::gen_axes {SVAR HOR TOF}]
lappend axeslist [::histogram_memory::gen_axes {SVAR TOF HOR}]
lappend siglist $signal
lappend hmmdatname "${HMOBJ}_xt"
}
@@ -295,37 +295,37 @@ proc ::histogram_memory::set_axes {typelist} {
}
"TOTAL_HISTOGRAM_XY" {
lappend rank 2
set dim0 [SplitReply [$HMOBJ configure $INST_NXC]]
set dim1 [SplitReply [$HMOBJ configure $INST_NYC]]
set dim0 [SplitReply [$HMOBJ configure $INST_NYC]]
set dim1 [SplitReply [$HMOBJ configure $INST_NXC]]
lappend dimstr "$dim0,$dim1"
lappend hmmslabstart [list 0 0]
lappend hmmslabend [list $dim0 $dim1]
lappend hmmperiodsize [expr $dim0 * $dim1]
lappend axeslist [::histogram_memory::gen_axes {SVAR HOR VER}]
lappend axeslist [::histogram_memory::gen_axes {SVAR VER HOR}]
lappend siglist $signal
lappend hmmdatname "${HMOBJ}_total_xy"
}
"TOTAL_HISTOGRAM_XY_CORRECTED" {
lappend rank 2
set dim0 [SplitReply [$HMOBJ configure $INST_NXC]]
set dim1 [SplitReply [$HMOBJ configure $INST_NYC]]
set dim0 [SplitReply [$HMOBJ configure $INST_NYC]]
set dim1 [SplitReply [$HMOBJ configure $INST_NXC]]
lappend dimstr "$dim0,$dim1"
lappend hmmslabstart [list 0 0]
lappend hmmslabend [list $dim0 $dim1]
lappend hmmperiodsize [expr $dim0 * $dim1]
lappend axeslist [::histogram_memory::gen_axes {SVAR HOR VER}]
lappend axeslist [::histogram_memory::gen_axes {SVAR VER HOR}]
lappend siglist $signal
lappend hmmdatname "${HMOBJ}_total_xy_corrected"
}
"TOTAL_HISTOGRAM_XT" {
lappend rank 2
set dim0 [SplitReply [$HMOBJ configure $INST_NXC]]
set dim1 [SplitReply [$HMOBJ configure oat_ntc_eff]]
set dim0 [SplitReply [$HMOBJ configure oat_ntc_eff]]
set dim1 [SplitReply [$HMOBJ configure $INST_NXC]]
lappend dimstr "$dim0,$dim1"
lappend hmmslabstart [list 0 0]
lappend hmmslabend [list $dim0 $dim1]
lappend hmmperiodsize [expr $dim0 * $dim1]
lappend axeslist [::histogram_memory::gen_axes {SVAR HOR TOF}]
lappend axeslist [::histogram_memory::gen_axes {SVAR TOF HOR}]
lappend siglist $signal
lappend hmmdatname "${HMOBJ}_total_xt"
}

View File

@@ -0,0 +1,373 @@
##
# @file Implements control for the Ordela high voltage power supply using the odrhvps protocol handler.
#
# This controller implements voltage ramping and always reads the current value before
# attempting to set the new voltage.
MakeSicsObj so_dhv1 SCT_OBJECT
namespace eval ::scobj::dethvps { }
##
# @brief Requests a value using the given command.
#
# @param nextSubState, Specifies the state which will handle the reply.
# @param cmd, The query command.
proc ::scobj::dethvps::rqValue {nextSubState cmd} {
set catch_status [ catch {
sct send $cmd
return $nextSubState
} msg ]
handle_exception $catch_status $msg
}
##
# @brief Processes replies from the voltage controller and controls the
# transition between the ramping superstates.
#
# @param vPath, Hdb node path for the voltage.
proc ::scobj::dethvps::rdValue {vPath} {
variable RAMPIDLE
variable RAMPSTOP
variable RAMPSTART
variable RAMPBUSY
variable MAXPOTVAL
variable RAMPINTEREST
set catch_status [ catch {
set data [sct result]
set currSuperState [sct ramping]
switch -glob -- $data {
"ASCERR:*" {
sct geterror $data
if {$currSuperState == $RAMPBUSY || $currSuperState == $RAMPSTART} {
broadcast "ERROR: $data, dhv1 stopped ramping detector voltage"
statemon stop dhv1
} else {
# broadcast "ERROR: $data"
}
if {$currSuperState != $RAMPIDLE} {
sct ramping $RAMPIDLE
}
return idle
}
default {
if {$data != [sct oldval]} {
sct geterror ""
sct oldval $data
sct update $data
set voltage [expr [sct max] * $data / double($MAXPOTVAL) ]
hset $vPath $voltage
if {$RAMPINTEREST} {
broadcast "dhv1 = $voltage"
}
sct utime readtime
}
}
}
switch $currSuperState [ subst {
$RAMPSTART {
sct ramping $RAMPBUSY
statemon start dhv1
return ramp
}
$RAMPBUSY {
return ramp
}
$RAMPSTOP {
sct ramping $RAMPIDLE
statemon stop dhv1
return idle
}
$RAMPIDLE {
return idle
}
default {
broadcast "ERROR: dhv1([info level 0]) sct ramping = [sct ramping], STOPPING"
sct ramping $RAMPIDLE
statemon stop dhv1
return idle
}
} ]
} msg ]
handle_exception $catch_status $msg
}
##
# @brief Checks the target voltage and sets the ramping superstate and ramp direction.
proc ::scobj::dethvps::setValue {nextSubState} {
variable RAMPIDLE
variable RAMPSTOP
variable RAMPSTART
variable RAMPBUSY
set catch_status [ catch {
set par [sct target]
set maxV [sct max]
if {$par < 0 || $par > $maxV} {
broadcast "ERROR: dhv1 target must be between 0 and $maxV"
sct seterror "ERROR: dhv1 target must be between 0 and $maxV"
return idle
}
set currSuperState [sct ramping]
set oldval [sct oldval]
if {$par == $oldval} {
if {$currSuperState == $RAMPBUSY || $currSuperState == $RAMPSTART} {
sct ramping $RAMPSTOP
}
return idle
}
if {$par < $oldval} {
sct rampstep -1
} else {
sct rampstep 1
}
if {$currSuperState != $RAMPBUSY && $currSuperState != $RAMPSTART} {
sct ramping $RAMPSTART
}
return $nextSubState
} msg ]
handle_exception $catch_status $msg
}
##
# @brief Checks that a command has been acknowledged
proc ::scobj::dethvps::getACK {} {
variable RAMPIDLE
variable RAMPSTOP
variable RAMPSTART
variable RAMPBUSY
set catch_status [ catch {
set currSuperState [sct ramping]
set data [sct result]
switch -glob $data {
"ASCERR:*" {
sct seterror $data
if {$currSuperState == $RAMPBUSY || $currSuperState == $RAMPSTART} {
broadcast "ERROR: $data, dhv1 stopped ramping detector voltage"
statemon stop dhv1
} else {
# broadcast "ERROR: $data"
}
if {$currSuperState != $RAMPSTOP} {
sct ramping $RAMPSTOP
}
return idle
}
ACK {
return idle
}
default {
return idle
}
}
} msg ]
handle_exception $catch_status $msg
}
##
# @brief Increments or decrements voltage until target has been reached
#
# @param cmd, The set voltage command
proc ::scobj::dethvps::ramping {cmd} {
variable RAMPIDLE
variable RAMPSTOP
variable RAMPSTART
variable RAMPBUSY
variable MINRAMPINTERVAL
set catch_status [ catch {
set rampstep [sct rampstep]
set target [sct target]
set oldval [sct oldval]
switch -- $rampstep {
1 {
if {$oldval >= $target} {
sct ramping $RAMPSTOP
return idle
}
}
-1 {
if {$oldval <= $target} {
sct ramping $RAMPSTOP
return idle
}
}
default {
sct ramping $RAMPSTOP
broadcast "ERROR: dhv1, Invalid ramp step: $rampstep STOPPING"
sct seterror "ERROR: dhv1, Invalid ramp step: $rampstep"
return idle
}
}
set target [expr [sct oldval] + [sct rampstep]]
sct send "$cmd $target"
return getACK
} msg ]
handle_exception $catch_status $msg
}
##
# @brief Command interface for voltage controller
proc ::scobj::dethvps::drvCmd {} {
variable RAMPIDLE
variable RAMPSTOP
variable RAMPSTART
variable RAMPBUSY
variable potValPath
set catch_status [ catch {
set cmd [sct target]
switch -- $cmd {
"halt" - "stop" {
hsetprop $potValPath ramping $RAMPSTOP
}
"up" {
hset $potValPath [sct upper]
}
"down" {
hset $potValPath [sct lower]
}
"off" {
hset $potValPath 0
}
default {
clientput "ERROR: Unknown command $cmd"
sct seterror "ERROR: Unknown command $cmd"
return idle
}
}
return idle
} msg ]
handle_exception $catch_status $msg
}
##
# @brief Implements the old command line interface for the dhv1 voltage controller.
proc ::scobj::dethvps::dhv1 {{CMD getVoltage} {val ""} } {
variable RAMPINTEREST
variable potValPath
variable voltagePath
variable cmdPath
set catch_status [ catch {
set qsObjPath ""
switch -- $CMD {
"list" {
clientput "dhv1.interval = [hgetpropval $potValPath interval]"
clientput "dhv1.upper = [hgetpropval $cmdPath upper]"
clientput "dhv1.lower = [hgetpropval $cmdPath lower]"
clientput "dhv1.max = [hgetpropval $potValPath max]"
return
}
"interval" {
return "dhv1.interval = [hgetpropval $potValPath interval]"
}
"max" {
set qsObjPath $potValPath
}
"upper" {
if {$val > 63.0} {
error "dhv1 upper must be no greater than 63"
}
set qsObjPath $cmdPath
}
"lower" {
if {$val > 63.0} {
error "dhv1 lower must be no greater than 63"
}
set qsObjPath $cmdPath
}
"getVoltage" {
return "[info level 0 ] = [hval $voltagePath]"
}
"interest" {
set RAMPINTEREST 1
statemon interest
}
"uninterest" {
set RAMPINTEREST 0
statemon uninterest
}
"reset" - "lock" - "unlock" - "debug" {
return
}
default {
hset $cmdPath $CMD
}
}
if {$qsObjPath != ""} {
if {$val != ""} {
if {[SplitReply [config myrights]] == 0} {
hsetprop $qsObjPath $CMD $val
} else {
error "ERROR: $CMD can only be initialised from a configuration file"
}
} else {
return "dhv1.$CMD = [hgetpropval $qsObjPath $CMD]"
}
}
} msg ]
handle_exception $catch_status $msg
}
namespace eval ::scobj::dethvps {
variable RAMPIDLE 0
variable RAMPSTOP 1
variable RAMPSTART 2
variable RAMPBUSY 3
variable MINRAMPINTERVAL 10
variable RAMPINTEREST 0
variable MAXPOTVAL 63.0
variable INITMAXVOLTAGE 2600.0
variable INITUPPERPOTVAL 57
variable INITLOWERPOTVAL 19
variable potValPath /sics/so_dhv1/potval
variable voltagePath /sics/so_dhv1/voltage
variable cmdPath /sics/so_dhv1/cmd
namespace export dhv1
hfactory $potValPath plain user int
hsetprop $potValPath read ::scobj::dethvps::rqValue rdValue "H"
hsetprop $potValPath rdValue ::scobj::dethvps::rdValue $voltagePath
hsetprop $potValPath write ::scobj::dethvps::setValue idle
hsetprop $potValPath getACK ::scobj::dethvps::getACK
hsetprop $potValPath ramp ::scobj::dethvps::ramping "h"
hsetprop $potValPath ramping $RAMPIDLE
hsetprop $potValPath rampstep 0
hsetprop $potValPath oldval -1
hsetprop $potValPath max $INITMAXVOLTAGE
hsetprop $potValPath interval -1
hfactory $voltagePath plain internal float
hset $voltagePath -1
hfactory $cmdPath plain user text
hsetprop $cmdPath write ::scobj::dethvps::drvCmd
hsetprop $cmdPath upper $INITUPPERPOTVAL
hsetprop $cmdPath lower $INITLOWERPOTVAL
}
proc ::scobj::dethvps::init {host ip rampinterval} {
variable potValPath
variable voltagePath
variable cmdPath
variable MINRAMPINTERVAL
if {[SplitReply [detector_simulation]] == "false"} {
makesctcontroller sct_dhv ordhvps $host:$ip
set MINRAMPINTERVAL $rampinterval
hsetprop $potValPath interval $rampinterval
sct_dhv poll $potValPath $rampinterval
sct_dhv write $potValPath
sct_dhv write $cmdPath
}
}
namespace import ::scobj::dethvps::dhv1
publish dhv1 user