Files
sics/site_ansto/instrument/util/extra_utility.tcl
Ferdi Franceschini e36e9f1146 conman.c
Reduce log noise by setting iout = eInternal for macros.

servlog.c
Fixed timestamp in logfiles to get hours.

hmm_configuration_common_1.tcl
Added ML's mods to wombat config: ie BAT and FAT TABLE attributes and elements for multi-period acquisition and histo-streaming.
Fixed "failed lsearch" bug. It's more robust to test for a non-successful lsearch instead of a failed lsearch.

nxscripts_common_1.tcl
SICS-297 Fixed Saving data series in a scratch file overwrites earlier entries.

instdict_specification.tcl
Added "scobj" kind and "sct_indexed_motor" sics object type for script context controllers and and objects.

hipadaba_configuration_common.tcl
Added sct_indexed_motor sics obj type to ::hdb::sobjadd and scobj kind to ::hdb::add_node

sct_positmotor_common.tcl
Update the index SICS variable when updating the current index value to make sure that the position is saved in the data file.
You must now provide the hdb node_name when creating the sct posit motor.
mk_sct_positmotor now sets the "param" and "long_name" attributes on the posit motor object

util/utility.tcl
Added ::utility::set_sct_indexed_motor_attributes to set SICS object attributes required for generating hdb info for an SCT_POSIT_MOTOR

nxscript.c
Merge the ansto mod to putslab (rev1.7) which adds support for saving unbuffered data from the histmem.

sicshipadaba.c
This incorporates the patch made to CommandSetCallback in rev1.10 so it can just be copied as is (ie no merge required).
WARNING: There are changes to ListHdbNode to handle record separators which may affect us.
Disabled sending hdb command start and stop messages because they break gumtree

sicshdbfactory.c
Disabled sending hdb command start and stop messages because they break gumtree

hipadaba_configuration_common.tcl R2.4DEV
The sct_posit_motor case of ::hdb::sobjadd is only needed to call add_node with kind=scobj.

nxscripts_common_1.tcl R2.4DEV
Added ::nexus::scobj::sdsinfo
_gen_nxdict now skips nodes with data_type == "none"

new util/script_context_util.tcl R2.4DEV
Adds ::scobj::hinitprops command to initialise the hdb properties for script context object nodes.

sct_positmotor_common.tcl R2.4DEV
Use ::scobj::hinitprops utility command to initialise hdb properties on script context object parameter nodes.

dynstring.c
DynStringReplace should memcopy '\0', otherwise it can get the wrong length for iTextLen.
Added DynStringReplaceWithLen to allow initialising a dynstring with char arrays which contain null chars and
other non-ascii chars.  Useful for read and write buffers in script context.

ascon.c
AsconRead return NULL for noResponse and AsconFailed otherwise the "result" node gets set with a spurious empty value.

scriptcontext.c
SctActionHandler only set  the "result" node if there really is a reply.

sicsobj.c
Update from M.K.

site_ansto.c
Added galil and ordela hvps protocol handlers for scriptcontext.

motor_dmc2280.c
Allow home parameter to be outside of limits (for KOWARI)

hardsup/makefile
Added ordela HVPS protocol handler

hardsup/sct_orhvpsprot.c
New ordela HVPS protocol handler.  Retries on NAKs and re-orders pot channels (ie toggles lower two bits).

hardsup/sct_velselprot.c
Start velocity selector protocol handler.

hardsup/sct_galilprot.c
Completed galil protocol handler.

hipadaba_configuration_common.tcl
Add new style SICS objects to hdb tree.

instdict_specification.tcl
Added scobj to kind list and sct_motor to sics object list. (and some housekeeping)

hmm_configuration_common_1.tcl
Added ratemaps to simulation.  Fixe BAT_TABLE and added PERIOD_INDICES as per Mark Lesha's mods for multi-period acquisition.
ratemaps now return float.

sct_postimotor_common.tcl
Now setting properties on the posit motor object so that it can be automatically added to the hdb tree.

hrpd/config/motors/motor_configuration.tcl
Fixed simulated msd motor so that it's handle properly in the hdb layer.

sans/config/hmm/detector_ordela.tcl
Updated the ordela calibration script to use the new sct_orhvpsprop.c script context controller.

quokka_configuration.tcl
Deleted lines which set the hdb properties for script context posit motors.  This is now handled automatically as for other SICS objects.

utility.tcl
setpos now replaces the motor setpos subcommand.
Added functions to set script context object attributes and sct_posit motor attributes.
Created hparPath and hsibPath convenience commands for new-style SICS objects.

script_context_util.tcl
NEW! Adds hinitprops function to initialise the hdb properties for a script context object

r2758 | ffr | 2008-12-12 17:53:53 +1100 (Fri, 12 Dec 2008) | 113 lines
2012-11-15 16:56:43 +11:00

219 lines
5.5 KiB
Tcl

# Many of these functions are also useful in test and debug code
# running on an external Tcl interpreter.
set errorInfo ""
set errorCode NONE
set errorContext ""
set callStack ""
proc callinfo {args} {
if {$args == "errors"} {
set msg "ERROR CONTEXT\n$::errorContext\n\nCALLSTACK\n$::callStack"
} else {
set msg "CALLSTACK\n$::callStack"
}
return $msg
}
publish callinfo user
# @brief Reset error information variables when entering a catch command
proc entercatch {args} {
uplevel {
global errorCode errorContext callStack
if {[info level] > 0} {
set errorCode NONE
# set errorContext ""
# set callStack ""
}
}
}
# @brief Set the errorContext and build the callStack when leaving a catch command
#
# ::errorContext is set to ::errorInfo
# ::callStack is a stack of command calls showing the argument values
proc leavecatch {args} {
uplevel {
global callStack errorContext errorCode errorInfo
if {[info level] > 0} {
if {$errorCode=="NONE"} {
set callStack ""
set errorContext ""
} else {
append callStack "\t[info level 0]\n"
}
}
}
}
# @brief Set the ::errorCode to "ERROR" when ::errorInfo is modified.
#
# NOTE\n
# Tcl always sets errorCode=NONE when there is no additional information\n
# about an error, as well as when there is no error! However when a command\n
# returns with an error it always writes to errorInfo.
proc errorInfowrite {args} {
uplevel {
global errorContext errorCode errorInfo
if {[info level] > 0} {
if {$errorInfo != ""} {
append errorContext $errorInfo
set errorCode ERROR
}
}
}
}
proc callStack {enable} {
if {$enable} {
set trace_opt "add"
} else {
set trace_opt "remove"
}
trace $trace_opt variable errorInfo write errorInfowrite
trace $trace_opt execution catch enter entercatch
trace $trace_opt execution catch leave leavecatch
}
publish callStack mugger
callStack true
# LIST FUNCTIONS
proc head {args} {lindex [join $args] 0}
proc tail {args} {join [lrange [join $args] 1 end]}
# SET FUNCTIONS
# Set membership
proc setmem {el A} {
expr {[lsearch $A $el] >= 0}
}
# Set difference: A\B, members of A that are not in B
proc setdiff {A B} {
foreach el $A {
if {[lsearch -exact $B $el] == -1} {
lappend missing $el;
}
}
if {[info exists missing]} {
return $missing;
}
}
proc _intersection {lista listb} {
set result {}
foreach elem [join $listb] {
if { [lsearch -exact $lista $elem] >= 0} {
lappend result $elem
}
}
return $result
}
proc intersection {lista args} {
if {[llength $args] == 0} {return $lista}
if {[llength $args] == 1} {return [_intersection $lista $args]}
return [intersection [_intersection $lista [head $args]] [tail $args]];
}
# TYPE CHECKING
# This is an enhanced set membership function.
# It can check that an element is a member of a list or
# of a named type
proc isoneof {element setb} {
global simpleType;
set result 0;
foreach elb $setb {
switch $elb {
alpha {set result [string is alpha $element]}
text {set result [string is wordchar $element]}
print {set result [string is print $element]}
float {set result [string is double $element]}
int {set result [string is integer $element]}
default {set result [expr {$element == $elb}]}
}
if {$result == 1} {return 1}
}
return 0;
}
# Returns 'sicslist' output in lower case, this may be useful in macros.
# This function is used a lot in the hdbbuilder
proc tolower_sicslist {args} {
if [ catch {
set result [eval sicslist $args]
return [string tolower $result];
} message ] {
if {$::errorCode=="NONE"} {return $message}
return -code error $message
}
}
# \brief Enables or disables the debug_msg command
#
# \param mode on turns on debugging, off turns off debugging
#
# \see debug_msg
# TODO Set a callstack global variable
proc debug_mode {mode} {
switch $mode {
on {
proc debug_msg {args} {
switch [info level] {
0 {
# This happens when debug_msg is used with trace
clientput $args
}
1 {
# This probably only occurs if you debug_msg directly. Why would you do that?
set cmdinfo [info level 0]
set cmd [lindex $cmdinfo 0]
set nscmd [namespace origin $cmd]
clientput "DEBUG, ${nscmd}::$cmdinfo]$args"
}
2 {
set cmdinfo [info level -1]
set cmd [lindex $cmdinfo 0]
set nscmd [namespace origin $cmd]
clientput "DEBUG, ${nscmd}::$cmdinfo]$args"
}
3 - default {
set cmdinfo [info level -1]
set cmd [lindex $cmdinfo 0]
set nscmd [namespace origin $cmd]
set callerinfo [info level -2]
set caller [lindex $callerinfo 0]
set nscaller [namespace origin $caller]
clientput "DEBUG, ${nscaller}::$callerinfo\n\t${nscmd}::$cmdinfo]$args"
}
}
}
}
off {
proc debug_msg {args} {};
}
}
}
## \brief You can use debug_msg in place of 'puts' for debug info in Tcl macros.
#
# Add debug messages on the fly with
# strace add execution <proc> enter debug_msg
proc debug_msg {args} {};
publish debug_mode mugger
proc todo_msg {args} {
set cmdinfo [info level -1]
set cmd [lindex $cmdinfo 0]
clientput "TODO <$cmd> $args"
}
proc error_msg {args} {
set cmdinfo [info level -1]
set cmd [lindex $cmdinfo 0]
set arglist [lrange $cmdinfo 1 end]
error "ERROR: [namespace origin $cmd] $arglist: $args"
}