version 20091209_2. Not tested. Merges the changes from 20091201 and 20091209_1(ffr).
r2839 | axm | 2009-12-09 18:41:43 +1100 (Wed, 09 Dec 2009) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
8b6c89ebc1
commit
ab7774aa4c
@@ -53,9 +53,8 @@ proc handle_exception {status message} {
|
||||
#
|
||||
# @author: Arndt Meier, ANSTO, 2009-08-31
|
||||
# @brief: driver for Bruker 1-Tesla magnet power supply (in TCL)
|
||||
# @version: 20091002 for sics2_4
|
||||
# @version: 20091009 for sics2_4
|
||||
#
|
||||
# known bugs: betaa stage - version 1.1.0
|
||||
# ----------------------------------------------------------------------------*/
|
||||
|
||||
# Notes
|
||||
@@ -91,6 +90,11 @@ proc handle_exception {status message} {
|
||||
# did not have the expected effect so far.
|
||||
# - Fixed the StateMachineStatusByteTxt bug - now decodes the
|
||||
# status byte correctly into its corresponding error text.
|
||||
# - Removed terminator variable - obsolete as this is done when the scriptcontext
|
||||
# object is created.
|
||||
# - proc drivestatus now sets a retval variable that is returned. Default
|
||||
# action for drivable when paused is lazy instead of pause to avoid
|
||||
# stopping the histogram server.
|
||||
|
||||
# Default parameters for the device
|
||||
namespace eval ::scobj::bruker_BEC1 {
|
||||
@@ -109,7 +113,7 @@ namespace eval ::scobj::bruker_BEC1 {
|
||||
# provide a global variable holding the path to the nodes
|
||||
set bruker_BEC1_path2nodes "/sample/ma1"
|
||||
# terminator string for serial communication
|
||||
set bruker_BEC1_term ""
|
||||
#set bruker_BEC1_term "" !obsolete. Done in the call to the scriptcontext constructor
|
||||
# variables that are identical to node names but are needed internally as well
|
||||
# temperature tolerance in Ampere
|
||||
set bruker_BEC1_tolerance 0.1
|
||||
@@ -207,8 +211,8 @@ proc getValue {tc_root nextState cmd expectedLen} {
|
||||
set tNow [clock clicks -milliseconds]
|
||||
}
|
||||
#set diff2 [expr $tNow - $::scobj::bruker_BEC1::bruker_BEC1_timeLastCommand]
|
||||
sct send $cmd$::scobj::bruker_BEC1::bruker_BEC1_term
|
||||
# puts "sct send !$cmd$::scobj::bruker_BEC1::bruker_BEC1_term!"
|
||||
sct send $cmd
|
||||
# puts "sct send !$cmd!"
|
||||
set ::scobj::bruker_BEC1::bruker_BEC1_timeLastCommand $tNow
|
||||
#puts "diff1:$diff1, diff2:$diff2 $cmd"
|
||||
} message ] {
|
||||
@@ -301,7 +305,7 @@ puts "Rejected !$data! as reply to $::scobj::bruker_BEC1::bruker_BEC1_lastQueryC
|
||||
}
|
||||
return idle
|
||||
} message ]
|
||||
handle_exception $catch_status $message
|
||||
handle_exception $catch_status "in rdValue: $message. Last query command: $::scobj::bruker_BEC1::bruker_BEC1_lastQueryCmd"
|
||||
}
|
||||
|
||||
|
||||
@@ -337,7 +341,7 @@ proc inTolerance {expectedLength} {
|
||||
# Discard - this it is not the reply to our query because this is what happened:
|
||||
#ERROR: in rdValue: in analyseStatusByte(): in decodeErrByte(): syntax error in expression "0xHF": extra tokens at end of expression. errByte: HF, errList: 08 {Inrush procedure error} 01 {Current limit exceeded}
|
||||
# . statusByteString: STA/0CHF/-0.0002T. Last query command: STA/
|
||||
puts "Rejected !$data! as reply to $::scobj::bruker_BEC1::bruker_BEC1_lastQueryCmd"
|
||||
#puts "Rejected !$data! as reply to $::scobj::bruker_BEC1::bruker_BEC1_lastQueryCmd"
|
||||
return idle
|
||||
}
|
||||
set data [ExtractValue $data $::scobj::bruker_BEC1::bruker_BEC1_lastQueryCmd]
|
||||
@@ -384,7 +388,7 @@ puts "Rejected !$data! as reply to $::scobj::bruker_BEC1::bruker_BEC1_lastQueryC
|
||||
# puts "inTolerance 4 $::scobj::bruker_BEC1::bruker_BEC1_sct_obj_name data:$data"
|
||||
return idle
|
||||
} message ]
|
||||
handle_exception $catch_status $message
|
||||
handle_exception $catch_status "in inTolerance: $message. Last query command: $::scobj::bruker_BEC1::bruker_BEC1_lastQueryCmd"
|
||||
# puts "Leaving inTolerance idx:$CtrlLoopIdx"
|
||||
}
|
||||
|
||||
@@ -407,7 +411,7 @@ proc setValue {tc_root nextState cmd } {
|
||||
while {[expr $tNow - $::scobj::bruker_BEC1::bruker_BEC1_timeLastCommand] < $::scobj::bruker_BEC1::bruker_BEC1_MIN_TIME_BETWEEN_COMMANDS} {
|
||||
set tNow [clock clicks -milliseconds]
|
||||
}
|
||||
sct send "$cmd$par$::scobj::bruker_BEC1::bruker_BEC1_term"
|
||||
sct send "$cmd$par"
|
||||
set ::scobj::bruker_BEC1::bruker_BEC1_timeLastCommand $tNow
|
||||
if { 0 == [string compare -length 4 $cmd "RST=0"] } {
|
||||
# Reset error messages - also update the node displaying the last error
|
||||
@@ -452,13 +456,13 @@ proc setDesiredField {tc_root nextState cmd} {
|
||||
set nodename $tc_root/sensor/setpoint
|
||||
hsetprop $nodename driving 1
|
||||
}
|
||||
#puts "setDesiredField(wrStatus=$wrStatus): sct send $cmd$par$::scobj::bruker_BEC1::bruker_BEC1_term"
|
||||
#puts "setDesiredField(wrStatus=$wrStatus): sct send $cmd$par"
|
||||
set tNow [clock clicks -milliseconds]
|
||||
#set diff1 [expr $tNow - $::scobj::bruker_BEC1::bruker_BEC1_timeLastCommand]
|
||||
while {[expr $tNow - $::scobj::bruker_BEC1::bruker_BEC1_timeLastCommand] < $::scobj::bruker_BEC1::bruker_BEC1_MIN_TIME_BETWEEN_COMMANDS} {
|
||||
set tNow [clock clicks -milliseconds]
|
||||
}
|
||||
sct send "$cmd$par$::scobj::bruker_BEC1::bruker_BEC1_term"
|
||||
sct send "$cmd$par"
|
||||
} message ] {
|
||||
return -code error "in setDesiredField: $message. Last write command: $::scobj::bruker_BEC1::bruker_BEC1_lastWriteCmd"
|
||||
}
|
||||
@@ -486,13 +490,13 @@ proc setDesiredCurrent {tc_root nextState cmd} {
|
||||
set nodename $tc_root/sensor/NominalOutpCurrent
|
||||
hsetprop $nodename driving 1
|
||||
}
|
||||
#puts "setDesiredCurrent(wrStatus=$wrStatus): sct send $cmd$par$::scobj::bruker_BEC1::bruker_BEC1_term"
|
||||
#puts "setDesiredCurrent(wrStatus=$wrStatus): sct send $cmd$par"
|
||||
set tNow [clock clicks -milliseconds]
|
||||
#set diff1 [expr $tNow - $::scobj::bruker_BEC1::bruker_BEC1_timeLastCommand]
|
||||
while {[expr $tNow - $::scobj::bruker_BEC1::bruker_BEC1_timeLastCommand] < $::scobj::bruker_BEC1::bruker_BEC1_MIN_TIME_BETWEEN_COMMANDS} {
|
||||
set tNow [clock clicks -milliseconds]
|
||||
}
|
||||
sct send "$cmd$par$::scobj::bruker_BEC1::bruker_BEC1_term"
|
||||
sct send "$cmd$par"
|
||||
set ::scobj::bruker_BEC1::bruker_BEC1_timeLastCommand $tNow
|
||||
} message ] {
|
||||
return -code error "in setDesiredCurrent: $message. Last write command: $::scobj::bruker_BEC1::bruker_BEC1_lastWriteCmd"
|
||||
@@ -509,12 +513,17 @@ proc setDesiredCurrent {tc_root nextState cmd} {
|
||||
# NOTE: The drive adapter initially sets the writestatus to "start" and will
|
||||
# only call this when writestatus!="start"
|
||||
proc drivestatus {tc_root} {
|
||||
# broadcast "DEBUG: in drivestatus. Last write command: $::scobj::bruker_BEC1::bruker_BEC1_lastWriteCmd"
|
||||
if [sct driving] {
|
||||
return busy
|
||||
} else {
|
||||
return idle
|
||||
# broadcast "DEBUG: in drivestatus. Last write command: $::scobj::bruker_BEC1::bruker_BEC1_lastWriteCmd"
|
||||
if [ catch {
|
||||
if [sct driving] {
|
||||
set retval busy
|
||||
} else {
|
||||
set retval idle
|
||||
}
|
||||
} message ] {
|
||||
return -code error "in drivestatus: $message. Last write command: $::scobj::bruker_BEC1::bruker_BEC1_lastWriteCmd"
|
||||
}
|
||||
return $retval
|
||||
}
|
||||
|
||||
##
|
||||
@@ -1157,11 +1166,9 @@ proc mk_sct_bruker_BEC1 {sct_controller klass tempobj tol} {
|
||||
set ::scobj::bruker_BEC1::bruker_BEC1_sct_obj_name $tempobj
|
||||
|
||||
# terminator string for serial communication
|
||||
set CR "\r"
|
||||
set LF "\n"
|
||||
#set ::scobj::bruker_BEC1::bruker_BEC1_term $CR
|
||||
set ::scobj::bruker_BEC1::bruker_BEC1_term ""
|
||||
|
||||
#set CR "\r"
|
||||
#set LF "\n"
|
||||
|
||||
set ::scobj::bruker_BEC1::bruker_BEC1_tolerance $tol
|
||||
set ::scobj::bruker_BEC1::bruker_BEC1_driveTolerance [expr $tol * $::scobj::bruker_BEC1::bruker_BEC1_tolerance]
|
||||
|
||||
@@ -1262,7 +1269,7 @@ proc mk_sct_bruker_BEC1 {sct_controller klass tempobj tol} {
|
||||
helpNotes4user $scobj_hpath "emon" "monMode"
|
||||
|
||||
hfactory $scobj_hpath/emon/errhandler plain spy text
|
||||
hset $scobj_hpath/emon/errhandler "pause"
|
||||
hset $scobj_hpath/emon/errhandler "lazy"
|
||||
helpNotes4user $scobj_hpath "emon" "errhandler"
|
||||
|
||||
hfactory $scobj_hpath/pwrCtrl/LSB_Err plain spy text
|
||||
@@ -1334,7 +1341,7 @@ proc mk_sct_bruker_BEC1 {sct_controller klass tempobj tol} {
|
||||
|
||||
# initialise the device
|
||||
bruker_BEC1_init $sct_controller $scobj_hpath
|
||||
puts "Bruker BEC1 power supply for 1-Tesla magnet ready at /sample/$tempobj (Driver 20091002_beta)"
|
||||
puts "Bruker BEC1 power supply for 1-Tesla magnet ready at /sample/$tempobj (Driver 20091009_beta)"
|
||||
} message ] {
|
||||
return -code error "in mk_sct_bruker_BEC1 $message"
|
||||
}
|
||||
@@ -1353,8 +1360,15 @@ proc mk_sct_bruker_BEC1 {sct_controller klass tempobj tol} {
|
||||
# @param tol magnetic field strength tolerance in Tesla (default 0.1T)
|
||||
# @return nothing (well, the sct object)
|
||||
proc add_bruker_BEC1 {name IP port {_tol 0.1} } {
|
||||
# Don't create a magnet controller for the script validator, this may cause the
|
||||
# the BEC1 to lock up.
|
||||
# NOTE: This is placed outside the catch block because "return" raises an exception
|
||||
if [SplitReply [environment_simulation]] {
|
||||
return
|
||||
}
|
||||
if [ catch {
|
||||
puts "\nadd_bruker_BEC1: makesctcontroller $name std ${IP}:$port for Bruker BEC1 1-Tesla magnet power supply"
|
||||
# Command terminator for Bruker unit is only carriage return without linefeed '\r'
|
||||
makesctcontroller sct_bruker_BEC1_$name std ${IP}:$port "\r"
|
||||
mk_sct_bruker_BEC1 sct_bruker_BEC1_$name environment $name $_tol
|
||||
makesctemon $name /sics/$name/emon/monMode /sics/$name/emon/isInTolerance /sics/$name/emon/errhandler
|
||||
|
||||
Reference in New Issue
Block a user