sct_bruker_BEC1.tcl
Arndt's latest updates, this is sct_bruker_BEC1_20100625.tcl r3135 | ffr | 2011-05-19 08:38:09 +1000 (Thu, 19 May 2011) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
8514dace59
commit
12b524cfbb
@@ -216,6 +216,9 @@ proc bruker_BEC1_init {sct_controller tc_root} {
|
|||||||
proc getValue {tc_root nextState cmd expectedLen} {
|
proc getValue {tc_root nextState cmd expectedLen} {
|
||||||
set catch_status [ catch {
|
set catch_status [ catch {
|
||||||
set ::scobj::bruker_BEC1::bruker_BEC1_lastQueryCmd "$cmd"
|
set ::scobj::bruker_BEC1::bruker_BEC1_lastQueryCmd "$cmd"
|
||||||
|
if [hpropexists [sct] geterror] {
|
||||||
|
hdelprop [sct] geterror
|
||||||
|
}
|
||||||
after $::scobj::bruker_BEC1::bruker_BEC1_MIN_TIME_BETWEEN_COMMANDS
|
after $::scobj::bruker_BEC1::bruker_BEC1_MIN_TIME_BETWEEN_COMMANDS
|
||||||
sct send $cmd
|
sct send $cmd
|
||||||
# puts "sct send !$cmd!"
|
# puts "sct send !$cmd!"
|
||||||
@@ -299,7 +302,7 @@ proc getValue {tc_root nextState cmd expectedLen} {
|
|||||||
# Beware that Bruker uses reverse notation.
|
# Beware that Bruker uses reverse notation.
|
||||||
set data [ExtractValue $orgdata $::scobj::bruker_BEC1::bruker_BEC1_lastQueryCmd]
|
set data [ExtractValue $orgdata $::scobj::bruker_BEC1::bruker_BEC1_lastQueryCmd]
|
||||||
#puts "rdValue: Interpreting status byte information: $::scobj::bruker_BEC1::bruker_BEC1_lastQueryCmd"
|
#puts "rdValue: Interpreting status byte information: $::scobj::bruker_BEC1::bruker_BEC1_lastQueryCmd"
|
||||||
#pwrCtrl EthernetAddrHex 1 0 1 0 text spy {ETH/} {rdValue} {} {setValue} {}\
|
#pwrCtrl EthernetAddrHex 1 0 1 0 text spy {ETH/} {rdValue} {} {setValue} {}
|
||||||
hset $::scobj::bruker_BEC1::bruker_BEC1_path2nodes/pwrctrl/EthernetAddrDec "UNKNOWN"
|
hset $::scobj::bruker_BEC1::bruker_BEC1_path2nodes/pwrctrl/EthernetAddrDec "UNKNOWN"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -446,14 +449,19 @@ proc setDesiredField {tc_root nextState cmd} {
|
|||||||
set ns ::scobj::lh45
|
set ns ::scobj::lh45
|
||||||
set par [sct target]
|
set par [sct target]
|
||||||
|
|
||||||
|
#hset $tc_root/status "busy"
|
||||||
|
set wrStatus [sct writestatus]
|
||||||
|
if {$wrStatus == "start"} {
|
||||||
|
# Called by drive adapter
|
||||||
|
# puts "setDesiredField(): driving set to 1"
|
||||||
|
set nodename $tc_root/sensor/setpoint
|
||||||
|
hsetprop $nodename driving 1
|
||||||
|
}
|
||||||
|
#puts "setDesiredField(wrStatus=$wrStatus): sct send $cmd$par"
|
||||||
after $::scobj::bruker_BEC1::bruker_BEC1_MIN_TIME_BETWEEN_COMMANDS
|
after $::scobj::bruker_BEC1::bruker_BEC1_MIN_TIME_BETWEEN_COMMANDS
|
||||||
sct send "$cmd$par"
|
sct send "$cmd$par"
|
||||||
return $nextState
|
return $nextState
|
||||||
} message ]
|
} message ]
|
||||||
if {$catch_status == 1} {
|
|
||||||
# TCL_ERROR
|
|
||||||
sct driving 0
|
|
||||||
}
|
|
||||||
handle_exception $catch_status $message "in setDesiredField(). Last write command: $::scobj::bruker_BEC1::bruker_BEC1_lastWriteCmd"
|
handle_exception $catch_status $message "in setDesiredField(). Last write command: $::scobj::bruker_BEC1::bruker_BEC1_lastWriteCmd"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,14 +478,19 @@ proc setDesiredCurrent {tc_root nextState cmd} {
|
|||||||
set ns ::scobj::lh45
|
set ns ::scobj::lh45
|
||||||
set par [sct target]
|
set par [sct target]
|
||||||
|
|
||||||
|
#hset $tc_root/status "busy"
|
||||||
|
set wrStatus [sct writestatus]
|
||||||
|
if {$wrStatus == "start"} {
|
||||||
|
# Called by drive adapter
|
||||||
|
# puts "setDesiredCurrent(): driving set to 1"
|
||||||
|
set nodename $tc_root/sensor/nominal_outp_current
|
||||||
|
hsetprop $nodename driving 1
|
||||||
|
}
|
||||||
|
#puts "setDesiredCurrent(wrStatus=$wrStatus): sct send $cmd$par"
|
||||||
after $::scobj::bruker_BEC1::bruker_BEC1_MIN_TIME_BETWEEN_COMMANDS
|
after $::scobj::bruker_BEC1::bruker_BEC1_MIN_TIME_BETWEEN_COMMANDS
|
||||||
sct send "$cmd$par"
|
sct send "$cmd$par"
|
||||||
return $nextState
|
return $nextState
|
||||||
} message ]
|
} message ]
|
||||||
if {$catch_status == 1} {
|
|
||||||
# TCL_ERROR
|
|
||||||
sct driving 0
|
|
||||||
}
|
|
||||||
handle_exception $catch_status $message "in setDesiredCurrent(). Last write command: $::scobj::bruker_BEC1::bruker_BEC1_lastWriteCmd"
|
handle_exception $catch_status $message "in setDesiredCurrent(). Last write command: $::scobj::bruker_BEC1::bruker_BEC1_lastWriteCmd"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,7 +575,7 @@ proc ExtractValue {response lastQueryCmd} {
|
|||||||
# update the node last_error_msg
|
# update the node last_error_msg
|
||||||
hset $::scobj::bruker_BEC1::bruker_BEC1_path2nodes/emon/last_error_msg $::scobj::bruker_BEC1::bruker_BEC1_errMsg
|
hset $::scobj::bruker_BEC1::bruker_BEC1_path2nodes/emon/last_error_msg $::scobj::bruker_BEC1::bruker_BEC1_errMsg
|
||||||
hset $::scobj::bruker_BEC1::bruker_BEC1_path2nodes/emon/last_error_msg2 $::scobj::bruker_BEC1::bruker_BEC1_errMsg2
|
hset $::scobj::bruker_BEC1::bruker_BEC1_path2nodes/emon/last_error_msg2 $::scobj::bruker_BEC1::bruker_BEC1_errMsg2
|
||||||
#if { 0 != [string compare -length 4 $lastQueryCmd "POL/"] \
|
#if { 0 != [string compare -length 4 $lastQueryCmd "POL/"]
|
||||||
# || $::scobj::bruker_BEC1::bruker_BEC1_polarityUnitAbsent == false} {
|
# || $::scobj::bruker_BEC1::bruker_BEC1_polarityUnitAbsent == false} {
|
||||||
#}
|
#}
|
||||||
}
|
}
|
||||||
@@ -707,9 +720,9 @@ proc analyseStatusByte {statusByteString} {
|
|||||||
if { 0 != [string compare -length 2 $tmp_LSB_ErrByte "00"]} {
|
if { 0 != [string compare -length 2 $tmp_LSB_ErrByte "00"]} {
|
||||||
# Error byte, LSB
|
# Error byte, LSB
|
||||||
# Value, hex, Explanation
|
# Value, hex, Explanation
|
||||||
set errList {\
|
set errList {
|
||||||
08 {External Security}\
|
08 {External Security}
|
||||||
04 {Temperature transformer, rectifier or PWM}\
|
04 {Temperature transformer, rectifier or PWM}
|
||||||
02 {Line Phase missing}
|
02 {Line Phase missing}
|
||||||
01 {Cooling water failure}
|
01 {Cooling water failure}
|
||||||
}
|
}
|
||||||
@@ -718,8 +731,8 @@ proc analyseStatusByte {statusByteString} {
|
|||||||
|
|
||||||
if { 0 != [string compare -length 2 $tmp_MSB_ErrByte "00"]} {
|
if { 0 != [string compare -length 2 $tmp_MSB_ErrByte "00"]} {
|
||||||
# status byte hex Value, Explanation
|
# status byte hex Value, Explanation
|
||||||
set errList {\
|
set errList {
|
||||||
08 {Inrush procedure error}\
|
08 {Inrush procedure error}
|
||||||
01 {Current limit exceeded}
|
01 {Current limit exceeded}
|
||||||
}
|
}
|
||||||
set MSB_ErrByteTxt [decodeErrByte $tmp_MSB_ErrByte $errList]
|
set MSB_ErrByteTxt [decodeErrByte $tmp_MSB_ErrByte $errList]
|
||||||
@@ -727,13 +740,13 @@ proc analyseStatusByte {statusByteString} {
|
|||||||
|
|
||||||
if { 0 != [string compare -length 2 $tmp_PwrSupplyStatusByte "00"]} {
|
if { 0 != [string compare -length 2 $tmp_PwrSupplyStatusByte "00"]} {
|
||||||
# status byte hex Value, Explanation
|
# status byte hex Value, Explanation
|
||||||
set errList {\
|
set errList {
|
||||||
80 {Remote enabled}\
|
80 {Remote enabled}
|
||||||
40 {DC power on}\
|
40 {DC power on}
|
||||||
20 {Normal polarity}\
|
20 {Normal polarity}
|
||||||
10 {Reverse polarity}\
|
10 {Reverse polarity}
|
||||||
04 {External reference enabled}\
|
04 {External reference enabled}
|
||||||
02 {Field regulation enabled}\
|
02 {Field regulation enabled}
|
||||||
01 {Internal reference set}
|
01 {Internal reference set}
|
||||||
}
|
}
|
||||||
set PwrSupplyStatusByteTxt [decodeErrByte $tmp_PwrSupplyStatusByte $errList]
|
set PwrSupplyStatusByteTxt [decodeErrByte $tmp_PwrSupplyStatusByte $errList]
|
||||||
@@ -741,28 +754,28 @@ proc analyseStatusByte {statusByteString} {
|
|||||||
|
|
||||||
if { 0 != [string compare -length 2 $tmp_StateMachineStatusByte "00"]} {
|
if { 0 != [string compare -length 2 $tmp_StateMachineStatusByte "00"]} {
|
||||||
# status byte hex Value; State
|
# status byte hex Value; State
|
||||||
set errList {\
|
set errList {
|
||||||
1C {Return to neutral state}\
|
1C {Return to neutral state}
|
||||||
1B {Control DC interlock}\
|
1B {Control DC interlock}
|
||||||
1A {Wait time}\
|
1A {Wait time}
|
||||||
19 {Set time 1 second}\
|
19 {Set time 1 second}
|
||||||
18 {Set Inrush OFF}\
|
18 {Set Inrush OFF}
|
||||||
17 {Wait time}\
|
17 {Wait time}
|
||||||
16 {Set time 1 second}\
|
16 {Set time 1 second}
|
||||||
15 {Set DC ON}\
|
15 {Set DC ON}
|
||||||
14 {Wait time}\
|
14 {Wait time}
|
||||||
13 {Set time 1 second}\
|
13 {Set time 1 second}
|
||||||
12 {Set Inrush ON}\
|
12 {Set Inrush ON}
|
||||||
11 {Test ADC:0}\
|
11 {Test ADC:0}
|
||||||
10 {Set DAC to 0}\
|
10 {Set DAC to 0}
|
||||||
0F {Set reference to intern}\
|
0F {Set reference to intern}
|
||||||
0C {Return to neutral state}\
|
0C {Return to neutral state}
|
||||||
0B {Wait time}\
|
0B {Wait time}
|
||||||
0A {Set 2 seconds}\
|
0A {Set 2 seconds}
|
||||||
09 {Set reference to intern}\
|
09 {Set reference to intern}
|
||||||
08 {Set DC off}\
|
08 {Set DC off}
|
||||||
07 {Test ADC:0}\
|
07 {Test ADC:0}
|
||||||
06 {Test DAC:0}\
|
06 {Test DAC:0}
|
||||||
05 {Ramp DAC to 0}
|
05 {Ramp DAC to 0}
|
||||||
}
|
}
|
||||||
#00 {Neutral state}
|
#00 {Neutral state}
|
||||||
@@ -946,7 +959,7 @@ proc helpNotes4user {scobj_hpath cmdGroup varName} {
|
|||||||
set h3 {«POL:1» Set negative polarity}
|
set h3 {«POL:1» Set negative polarity}
|
||||||
set helptext $h1$CRLF$h2$CRLF$h3
|
set helptext $h1$CRLF$h2$CRLF$h3
|
||||||
}
|
}
|
||||||
"actual_dac_field*" {
|
"desired_field*" {
|
||||||
set h1 {FLD «nn.nn» Query/Set magnetic field strength }
|
set h1 {FLD «nn.nn» Query/Set magnetic field strength }
|
||||||
set h2 {«nn.nn» magnetic field strength in Teslas (setpoint)}
|
set h2 {«nn.nn» magnetic field strength in Teslas (setpoint)}
|
||||||
set helptext $h1$CRLF$h2
|
set helptext $h1$CRLF$h2
|
||||||
@@ -1074,9 +1087,7 @@ proc helpNotes4user {scobj_hpath cmdGroup varName} {
|
|||||||
# @param allowedValues allowed values for the node data - does not permit other
|
# @param allowedValues allowed values for the node data - does not permit other
|
||||||
# @param klasse Nexus class name (?)
|
# @param klasse Nexus class name (?)
|
||||||
# @return OK
|
# @return OK
|
||||||
proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable\
|
proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable pollEnabled drivable replyLen dataType permission rdCmd rdFunc wrCmd wrFunc allowedValues klasse} {
|
||||||
pollEnabled drivable replyLen dataType permission rdCmd rdFunc wrCmd\
|
|
||||||
wrFunc allowedValues klasse} {
|
|
||||||
#puts "createing node for: $scobj_hpath $cmdGroup $varName $readable $writable $pollEnabled $drivable $dataType $permission $rdCmd $rdFunc $wrCmd $wrFunc"
|
#puts "createing node for: $scobj_hpath $cmdGroup $varName $readable $writable $pollEnabled $drivable $dataType $permission $rdCmd $rdFunc $wrCmd $wrFunc"
|
||||||
set catch_status [ catch {
|
set catch_status [ catch {
|
||||||
set ns ::scobj::bruker_BEC1
|
set ns ::scobj::bruker_BEC1
|
||||||
@@ -1171,25 +1182,25 @@ proc mk_sct_bruker_BEC1 {sct_controller klasse tempobj tol} {
|
|||||||
# wrCmd actual device write command to be sent to the device
|
# wrCmd actual device write command to be sent to the device
|
||||||
# wrFunc Function to be called to send the wrCmd to the device, typically setValue()
|
# wrFunc Function to be called to send the wrCmd to the device, typically setValue()
|
||||||
# allowedValues allowed values for the node data - does not permit other
|
# allowedValues allowed values for the node data - does not permit other
|
||||||
set deviceCommandToplevel {\
|
set deviceCommandToplevel {
|
||||||
sensor measured_field 1 0 1 0 13 float spy {CHF/} {rdValue} {} {setValue} {}\
|
sensor desired_field 1 1 1 0 16 float user {FLD/} {rdValue} {FLD=} {setValue} {}
|
||||||
sensor actual_dac_field 1 1 1 0 16 float user {FLD/} {rdValue} {FLD=} {setValue} {}\
|
sensor measured_field 1 0 1 0 13 float spy {CHF/} {rdValue} {} {setValue} {}
|
||||||
sensor desired_current 1 1 1 1 15 float user {CUR/} {rdValue} {CUR=} {setDesiredCurrent} {}\
|
sensor desired_current 1 1 1 1 15 float user {CUR/} {rdValue} {CUR=} {setDesiredCurrent} {}
|
||||||
sensor nominal_outp_current 1 0 1 0 13 float spy {CHN/} {rdValue} {} {setDesiredCurrent} {}\
|
sensor nominal_outp_current 1 0 1 0 13 float spy {CHN/} {rdValue} {} {setDesiredCurrent} {}
|
||||||
}
|
}
|
||||||
set deviceCommand {\
|
set deviceCommand {
|
||||||
pwrctrl dc_power 1 1 1 0 7 int user {DCP/} {inTolerance} {DCP=} {setValue} {0,1}\
|
pwrctrl dc_power 1 1 1 0 7 int user {DCP/} {inTolerance} {DCP=} {setValue} {0,1}
|
||||||
pwrctrl pwr_ctrl_from 1 1 1 0 7 int user {EXT/} {rdValue} {EXT=} {setValue} {0,1,2}\
|
pwrctrl pwr_ctrl_from 1 1 1 0 7 int user {EXT/} {rdValue} {EXT=} {setValue} {0,1,2}
|
||||||
pwrctrl local_remote_state 1 1 1 0 7 int user {REM/} {rdValue} {REM=} {setValue} {0,1}\
|
pwrctrl local_remote_state 1 1 1 0 7 int user {REM/} {rdValue} {REM=} {setValue} {0,1}
|
||||||
pwrctrl output_voltage 1 0 1 0 12 float spy {CHV/} {rdValue} {} {setValue} {}\
|
pwrctrl output_voltage 1 0 1 0 12 float spy {CHV/} {rdValue} {} {setValue} {}
|
||||||
pwrctrl reset_error_msg 0 1 0 0 7 int user {} {rdValue} {RST=} {setValue} {0}\
|
pwrctrl reset_error_msg 0 1 0 0 7 int user {} {rdValue} {RST=} {setValue} {0}
|
||||||
pwrctrl statusByte 1 1 1 0 13 text user {STA/} {rdValue} {STA=} {setValue} {0}\
|
pwrctrl statusByte 1 1 1 0 13 text user {STA/} {rdValue} {STA=} {setValue} {0}
|
||||||
}
|
}
|
||||||
# it seems these functions are not supported by our device
|
# it seems these functions are not supported by our device
|
||||||
#pwrCtrl EthernetAddrHex 1 0 1 0 text spy {ETH/} {rdValue} {} {setValue} {}\
|
#pwrCtrl EthernetAddrHex 1 0 1 0 text spy {ETH/} {rdValue} {} {setValue} {}
|
||||||
#pwrCtrl LoadResistance 1 0 1 0 float spy {RES/} {rdValue} {} {setValue} {}\
|
#pwrCtrl LoadResistance 1 0 1 0 float spy {RES/} {rdValue} {} {setValue} {}
|
||||||
#pwrCtrl QueryPolarity 1 0 1 0 int spy {POL/} {rdValue} {} {setValue} {}\
|
#pwrCtrl QueryPolarity 1 0 1 0 int spy {POL/} {rdValue} {} {setValue} {}
|
||||||
#pwrCtrl SetPolarity 0 1 0 0 int user {} {rdValue} {POL=} {setValue} {0,1}\
|
#pwrCtrl SetPolarity 0 1 0 0 int user {} {rdValue} {POL=} {setValue} {0,1}
|
||||||
|
|
||||||
hfactory $scobj_hpath/sensor plain spy none
|
hfactory $scobj_hpath/sensor plain spy none
|
||||||
foreach {cmdGroup varName readable writable pollEnabled drivable replyLen dataType permission rdCmd rdFunc wrCmd wrFunc allowedValues} $deviceCommandToplevel {
|
foreach {cmdGroup varName readable writable pollEnabled drivable replyLen dataType permission rdCmd rdFunc wrCmd wrFunc allowedValues} $deviceCommandToplevel {
|
||||||
@@ -1277,13 +1288,13 @@ proc mk_sct_bruker_BEC1 {sct_controller klasse tempobj tol} {
|
|||||||
set nxProperties "
|
set nxProperties "
|
||||||
$scobj_hpath sensor NXsensor spy
|
$scobj_hpath sensor NXsensor spy
|
||||||
$scobj_hpath sensor/measured_field sensor user
|
$scobj_hpath sensor/measured_field sensor user
|
||||||
$scobj_hpath sensor/actual_dac_field sensor user
|
$scobj_hpath sensor/desired_field sensor user
|
||||||
$scobj_hpath sensor/desired_current sensor user
|
$scobj_hpath sensor/desired_current sensor user
|
||||||
$scobj_hpath sensor/nominal_outp_current sensor user
|
$scobj_hpath sensor/nominal_outp_current sensor user
|
||||||
"
|
"
|
||||||
set aliasProperties "
|
set aliasProperties "
|
||||||
$scobj_hpath measured_field sensor _sensor_MeasuredField
|
$scobj_hpath measured_field sensor _sensor_MeasuredField
|
||||||
$scobj_hpath actual_dac_field sensor _sensor_ActualDAC_Field
|
$scobj_hpath desired_field sensor _sensor_ActualDAC_Field
|
||||||
$scobj_hpath desired_current sensor _sensor_DesiredCurrent
|
$scobj_hpath desired_current sensor _sensor_DesiredCurrent
|
||||||
$scobj_hpath nominal_outp_current sensor _sensor_NominalOutpCurrent
|
$scobj_hpath nominal_outp_current sensor _sensor_NominalOutpCurrent
|
||||||
"
|
"
|
||||||
@@ -1307,14 +1318,16 @@ proc mk_sct_bruker_BEC1 {sct_controller klasse tempobj tol} {
|
|||||||
# for generating the GumTree interface and saving data for script context objects (hdf file)
|
# for generating the GumTree interface and saving data for script context objects (hdf file)
|
||||||
# @param scobj, name of script context object (path to a node)
|
# @param scobj, name of script context object (path to a node)
|
||||||
# @param par, optional parameter (name of the node variable)
|
# @param par, optional parameter (name of the node variable)
|
||||||
::scobj::hinitprops $tempobj/sensor nominal_outp_current
|
|
||||||
|
# Changed ffr 20100625: do not call hinitprops to avoid a conflict with a change in SICServer vers. 2_5
|
||||||
|
#::scobj::hinitprops $tempobj/sensor nominal_outp_current
|
||||||
hsetprop $scobj_hpath/pwrctrl/statusByte control false
|
hsetprop $scobj_hpath/pwrctrl/statusByte control false
|
||||||
|
|
||||||
ansto_makesctdrive ${tempobj}_driveable $scobj_hpath/sensor/desired_current $scobj_hpath/sensor/nominal_outp_current $sct_controller
|
ansto_makesctdrive ${tempobj}_driveable $scobj_hpath/sensor/desired_current $scobj_hpath/sensor/nominal_outp_current $sct_controller
|
||||||
|
|
||||||
# initialise the device
|
# initialise the device
|
||||||
bruker_BEC1_init $sct_controller $scobj_hpath
|
bruker_BEC1_init $sct_controller $scobj_hpath
|
||||||
puts "Bruker BEC1 power supply for 1-Tesla magnet ready at /sample/$tempobj (Driver 2010-04-07)"
|
puts "Bruker BEC1 power supply for 1-Tesla magnet ready at /sample/$tempobj (Driver 2010-06-25)"
|
||||||
} message ]
|
} message ]
|
||||||
handle_exception $catch_status $message "In subroutine mk_sct_bruker_BEC1()."
|
handle_exception $catch_status $message "In subroutine mk_sct_bruker_BEC1()."
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user