Oxford Intelligent Power Supply IPS120-10

r2964 | dcl | 2010-06-25 15:16:28 +1000 (Fri, 25 Jun 2010) | 2 lines
This commit is contained in:
Douglas Clowes
2010-06-25 15:16:28 +10:00
parent 0fbb07f31a
commit 4afb1a765c

View File

@@ -0,0 +1,685 @@
# Define procs in ::scobj::xxx namespace
# MakeSICSObj $obj SCT_<class>
# The MakeSICSObj cmd adds a /sics/$obj node. NOTE the /sics node is not browsable.
namespace eval ::scobj::ips120 {
# Environment controllers should have at least the following nodes
# /envcont/setpoint
# /envcont/sensor/value
proc debug_log {args} {
set fd [open "/tmp/ips120.log" a]
puts $fd "[clock format [clock seconds] -format "%T"] $args"
close $fd
}
# issue a command to read a register and expect a value response
proc getValue {tc_root nextState cmd} {
debug_log "getValue $cmd sct=[sct] root=$tc_root nextState=$nextState"
sct send "@2$cmd"
return $nextState
}
# issue a command with a value in the target property of the variable
proc setValue {tc_root nextState cmd} {
debug_log "setValue cmd=$cmd sct=[sct] $tc_root"
set par "[sct target]"
sct send "@2$cmd$par"
debug_log "setValue $cmd$par"
return $nextState
}
proc chkWrite {tc_root} {
set data [sct result]
debug_log "chkWrite resp=$data sct=[sct] tc_root=$tc_root"
if {[string equal -nocase -length 7 $data "ASCERR:"]} {
sct geterror "$data"
} elseif {[string equal -nocase -length 1 $data "?"]} {
sct geterror "Error: $data"
}
return idle
}
proc setPoint {tc_root nextState cmd} {
set catch_status [ catch {
debug_log "setPoint $tc_root $nextState $cmd sct=[sct]"
sct print "setPoint: sct=[sct] target=[sct target] writestatus=[sct writestatus]"
set err_msg ""
if { [hval $tc_root/Display/A] == 4 } {
set err_msg "Output is clamped (A=[hval $tc_root/Display/A])"
} elseif { [hval $tc_root/Display/C] != 3 } {
set err_msg "Control is not remote (C=[hval $tc_root/Display/C])"
} elseif { [hval $tc_root/Display/PstntField] == [sct target] } {
sct print "Persistent Field ([hval $tc_root/Display/PstntField]) already at target ([sct target])"
return idle
}
if { $err_msg != "" } {
sct print "error:$err_msg"
debug_log "error:$err_msg"
return -code error "$err_msg"
}
sct print "Driving Persistent Field ([hval $tc_root/Display/PstntField]) to target ([sct target])"
set par "[sct target]"
hset $tc_root/status "busy"
sct print "status: busy"
hset $tc_root/drive_state "START"
hsetprop $tc_root/setpoint driving 1
} catch_message ]
if {$catch_status != 0} {
return -code error $catch_message
}
sct print "setPoint: [hget $tc_root/drive_state]"
return $nextState
}
proc rdValue {tc_root} {
debug_log "rdValue tc_root=$tc_root sct=[sct]"
set data [sct result]
if {[ catch {
debug_log "rdValue $tc_root [sct] result=$data"
} catch_message ]} {
debug_log "rdValue $tc_root failure"
}
if {[string equal -nocase -length 7 $data "ASCERR:"]} {
sct geterror "$data"
set nextState idle
} elseif {[string equal -nocase -length 1 $data "?"]} {
sct geterror "Error: $data"
set nextState idle
} else {
if {[string index $data 0] == "R"} {
set data [string range $data 1 end]
set rslt [scan $data %f data]
debug_log "rdValue $tc_root IPS120 result=$data"
}
if {$data != [sct oldval]} {
sct oldval $data
sct update $data
sct utime readtime
debug_log "rdValue new data for $tc_root [sct] result=$data"
}
}
return idle
}
# This is the command phase of the state machine that drives the controller.
# For each state, it sends the appropriate command to get values from, or set
# values in the controller in a sequence intended to transition the controller
# between states.
proc getState {tc_root nextState cmd} {
debug_log "getState $tc_root $nextState $cmd sct=[sct]"
if {[ catch {
set my_state "[SplitReply [hgetprop $tc_root/ips120_state my_state]]"
if {$my_state == "STATE_V"} {
set my_cmd "V"
} elseif {$my_state == "STATE_X"} {
set my_cmd "X"
} elseif {$my_state == "STATE_C"} {
set my_cmd "C3"
} elseif {$my_state == "STATE_A0"} {
set my_cmd "A0"
} elseif {$my_state == "STATE_A1"} {
set my_cmd "A1"
} elseif {$my_state == "STATE_A2"} {
set my_cmd "A2"
} elseif {$my_state == "STATE_H0"} {
set my_cmd "H0"
} elseif {$my_state == "STATE_H1"} {
set my_cmd "H1"
} elseif {$my_state == "STATE_I"} {
if { [hval $tc_root/Display/H] == 1 } {
set my_cmd "I[hval $tc_root/Display/OutputCurrent]"
} elseif { ([hval $tc_root/Display/H] == 0 || [hval $tc_root/Display/H] == 2) } {
set my_cmd "I[hval $tc_root/Display/PstntCurrent]"
}
} elseif {$my_state == "STATE_J"} {
set my_cmd "J[SplitReply [hgetprop $tc_root/setpoint target]]"
} elseif {$my_state == "STATE_F"} {
set my_cmd "F7"
} else {
hsetprop $tc_root/ips120_state my_state "STATE_X"
set my_cmd "X"
}
sct send "@2$my_cmd"
debug_log "getState end $tc_root state=$my_state, cmd=$my_cmd"
} catch_message ]} {
debug_log "getState error: $catch_message"
}
debug_log "getState returns: $nextState"
return $nextState
}
# This is the response phase of the state machine that drives the controller.
# For each state, it reads the appropriate command response from the controller
# and, based on the response and internal variables performs a sequence
# intended to transition the controller between states.
##
# @brief Reads the current ips120 state and error messages.
proc rdState {tc_root} {
debug_log "rdState $tc_root sct=[sct] response=\"[sct result]\""
set nextState {}
if {[ catch {
set data "[sct result]"
if {[string equal -nocase -length 7 $data "ASCERR:"]} {
sct geterror "$data"
set nextState idle
} elseif {[string equal -nocase -length 1 $data "?"]} {
sct geterror "Error: $data"
set nextState idle
} else {
set my_state "[SplitReply [hgetprop $tc_root/ips120_state my_state]]"
debug_log "rdState $tc_root state=$my_state, response=\"[sct result]\""
if {$my_state == "STATE_V"} {
set my_version "[sct result]"
hsetprop $tc_root/ips120_state my_version "$my_version"
hsetprop $tc_root/ips120_state my_state "STATE_X"
debug_log "rdState $tc_root state=$my_state"
set nextState read
} elseif {$my_state == "STATE_X"} {
hsetprop $tc_root/ips120_state my_status "[sct result]"
set my_status "[SplitReply [hgetprop $tc_root/ips120_state my_status]]"
debug_log "rdState my_status=$my_status"
set rslt [scan $my_status "X%dA%dC%dH%dM%dP%d" the_x the_a the_c the_h the_m the_p]
if {$rslt == 6} {
if { [hval $tc_root/Display/X] != $the_x } { hset $tc_root/Display/X $the_x }
if { [hval $tc_root/Display/A] != $the_a } { hset $tc_root/Display/A $the_a }
if { [hval $tc_root/Display/C] != $the_c } { hset $tc_root/Display/C $the_c }
if { [hval $tc_root/Display/H] != $the_h } { hset $tc_root/Display/H $the_h }
if { [hval $tc_root/Display/M] != $the_m } { hset $tc_root/Display/M $the_m }
if { [hval $tc_root/Display/P] != $the_p } { hset $tc_root/Display/P $the_p }
debug_log "rdState $tc_root status($rslt)= X[format %02d $the_x] A$the_a C$the_c H$the_h M[format %02d $the_m] P[format %02d $the_p]"
# make decisions on next state
if { $the_c == 0 && $the_a == 4 && $the_m % 10 == 0 } {
# looks like power up TODO report an error?
debug_log "rdState: looks like power up c=$the_c a=$the_a m-$the_m"
}
if { [catch {
if { $the_h == 2 && "[hval $tc_root/Display/PstntCurrent]" != 0 && "[hval $tc_root/Display/OutputCurrent]" == 0 } {
if { [hval $tc_root/Display/Persistent] != 1 } { hset $tc_root/Display/Persistent 1 }
} else {
if { [hval $tc_root/Display/Persistent] != 0 } { hset $tc_root/Display/Persistent 0 }
}
} catch_message] } {
debug_log "rdState catch triggered on Persistent determination: $catch_message"
if { [hval $tc_root/Display/Persistent] != 0 } { hset $tc_root/Display/Persistent 0 }
}
if { [catch {
if { [hpropexists $tc_root/sensor/value geterror] } { hdelprop $tc_root/sensor/value geterror }
if { $the_h == 0 || $the_h == 2 } {
if { [hval $tc_root/sensor/value] != [hval $tc_root/Display/PstntField] } {
hset $tc_root/sensor/value [hval $tc_root/Display/PstntField]
}
} else {
if { [hval $tc_root/sensor/value] != [hval $tc_root/Display/OutputField] } {
hset $tc_root/sensor/value [hval $tc_root/Display/OutputField]
}
}
} catch_message] } {
debug_log "rdState catch triggered on Sensor determination: $catch_message"
if { [hpropexists $tc_root/sensor/value geterror] } { hdelprop $tc_root/sensor/value geterror }
if { [hval $tc_root/sensor/value] != 0 } { hset $tc_root/sensor/value 0 }
}
set my_driving [SplitReply [hgetprop $tc_root/setpoint driving]]
if { $the_c != 3 } {
hsetprop $tc_root/ips120_state my_state "STATE_C"
set nextState read
} elseif { $my_driving } {
if { [hval $tc_root/drive_state] == "IDLE" } {
} elseif { [hval $tc_root/drive_state] == "START" } {
if { [hval $tc_root/Display/H] == 1 && [hval $tc_root/Display/OutputCurrent] != [hval $tc_root/Display/TargetCurrent] } {
hsetprop $tc_root/ips120_state my_state "STATE_I"
set nextState read
} elseif { ([hval $tc_root/Display/H] == 0 || [hval $tc_root/Display/H] == 2) && [hval $tc_root/Display/PstntCurrent] != [hval $tc_root/Display/TargetCurrent] } {
hsetprop $tc_root/ips120_state my_state "STATE_I"
set nextState read
} elseif { $the_a != 1 } {
hsetprop $tc_root/ips120_state my_state "STATE_A1"
set nextState read
} elseif { $the_h != 1 } {
hsetprop $tc_root/ips120_state my_state "STATE_H1"
set nextState read
} else {
hsetprop $tc_root/ips120_state my_state "STATE_H1"
set nextState read
}
} elseif { [hval $tc_root/drive_state] == "RAMPING" } {
if { $the_m % 10 == 0 && [hval $tc_root/Display/OutputCurrent] == [hval $tc_root/Display/TargetCurrent] } {
hsetprop $tc_root/ips120_state my_state "STATE_H0"
set nextState read
}
} elseif { [hval $tc_root/drive_state] == "ZEROING" } {
if { $the_m % 10 == 0 && [hval $tc_root/Display/OutputCurrent] == 0 } {
hset $tc_root/drive_state "IDLE"
hset $tc_root/status "idle"
hsetprop $tc_root/setpoint driving 0
set nextState read
}
} elseif { [hval $tc_root/drive_state] == "HOLDING" } {
if { [clock seconds] >= [SplitReply [hgetprop $tc_root/setpoint hold_time]] } {
if { $the_h == 0 } {
hset $tc_root/drive_state "ZEROING"
hsetprop $tc_root/ips120_state my_state "STATE_A2"
} elseif { $the_h == 2 } {
hset $tc_root/drive_state "ZEROING"
hsetprop $tc_root/ips120_state my_state "STATE_A2"
} elseif { $the_h == 1 } {
hset $tc_root/drive_state "RAMPING"
hsetprop $tc_root/ips120_state my_state "STATE_J"
set nextState read
}
}
}
}
} else {
debug_log "rdState $tc_root error scan status = $rslt on $my_status"
hsetprop $tc_root/ips120_state my_state "STATE_V"
set nextState idle
}
} elseif {$my_state == "STATE_C"} {
hsetprop $tc_root/ips120_state my_state "STATE_F"
set nextState read
} elseif {$my_state == "STATE_A0"} {
hsetprop $tc_root/ips120_state my_state "STATE_X"
set nextState idle
} elseif {$my_state == "STATE_A1"} {
hsetprop $tc_root/ips120_state my_state "STATE_X"
set nextState idle
} elseif {$my_state == "STATE_A2"} {
hsetprop $tc_root/ips120_state my_state "STATE_X"
set nextState idle
} elseif {$my_state == "STATE_H0"} {
hsetprop $tc_root/ips120_state my_state "STATE_X"
hsetprop $tc_root/setpoint hold_time [expr [clock seconds] + 30]
hset $tc_root/drive_state "HOLDING"
set nextState idle
} elseif {$my_state == "STATE_H1"} {
hsetprop $tc_root/ips120_state my_state "STATE_X"
hsetprop $tc_root/setpoint hold_time [expr [clock seconds] + 30]
hset $tc_root/drive_state "HOLDING"
set nextState idle
} elseif {$my_state == "STATE_I"} {
hsetprop $tc_root/ips120_state my_state "STATE_X"
set nextState idle
} elseif {$my_state == "STATE_J"} {
hsetprop $tc_root/ips120_state my_state "STATE_X"
set nextState idle
} elseif {$my_state == "STATE_F"} {
hsetprop $tc_root/ips120_state my_state "STATE_X"
} else {
hsetprop $tc_root/ips120_state my_state "STATE_X"
}
#DFC
if {0} {
if { $nextState == "" } {
set my_status "[SplitReply [hgetprop $tc_root/ips120_state my_status]]"
debug_log "rdState my_status=$my_status"
set rslt [scan $my_status "X%dA%dC%dH%dM%dP%d" the_x the_a the_c the_h the_m the_p]
debug_log "rdState $tc_root status($rslt)= X[format %02d $the_x] A$the_a C$the_c H$the_h M[format %02d $the_m] P[format %02d $the_p]"
set my_driving [SplitReply [hgetprop $tc_root/setpoint driving]]
debug_log "rdState $tc_root: driving=$my_driving"
if {[ catch {
set val "[hval $tc_root/setpoint]"
} message ]} {
set val 0
debug_log "rdState $tc_root: setpoint=failure"
}
debug_log "rdState $tc_root: setpoint=$val"
if {[hpropexists $tc_root/setpoint target]} {
set tgt [SplitReply [hgetprop $tc_root/setpoint target]]
debug_log "rdState $tc_root: target=$tgt"
} else {
hsetprop $tc_root/setpoint target $val
set tgt [SplitReply [hgetprop $tc_root/setpoint target]]
debug_log "rdState $tc_root: initialised target to: target=$tgt"
}
if {$my_driving > 0} {
set field [hval $tc_root/sensor/value]
set tol [hval $tc_root/tolerance]
set lofield [expr {$tgt - $tol}]
set hifield [expr {$tgt + $tol}]
debug_log "rdState driving $tc_root until $field in ($lofield, $hifield)"
if {$field < $lofield} {
} elseif {$field > $hifield} {
} elseif { [expr $the_m % 10] == 0 } {
hset $tc_root/status "idle"
sct print "status: idle"
hset $tc_root/drive_state "IDLE"
hsetprop $tc_root/setpoint driving 0
debug_log "rdState driving $tc_root finished at $field in ($lofield, $hifield)"
}
}
set nextState idle
}
#DFC
} else {
set nextState idle
}
}
} catch_message ]} {
debug_log "rdState error: $catch_message"
}
debug_log "rdState returns: $nextState"
return $nextState
}
proc noResponse {} {
return idle
}
proc wrtValue {wcmd args} {
}
# check that a target is within allowable limits
proc check {tc_root} {
set setpoint [sct target]
set lolimit [hval $tc_root/lowerlimit]
set hilimit [hval $tc_root/upperlimit]
if {$setpoint < $lolimit || $setpoint > $hilimit} {
error "setpoint violates limits"
}
return OK
}
# Check that the sensor is reading within tolerance of the setpoint.
# Return 1 or 0 if it is or is not, respectively.
proc checktol {tc_root currtime timecheck} {
debug_log "checktol $tc_root $currtime $timecheck"
set field [hval $tc_root/sensor/value]
set lofield [expr {[$tc_root/setpoint] - [hval $tc_root/tolerance]}]
set hifield [expr {[$tc_root/setpoint] + [hval $tc_root/tolerance]}]
if { $field < $lofield || $field > $hifield} {
hset $tc_root/emon/isintol 0
return 0
} else {
set timeout [hval $tc_root/tolerance/settletime]
if { ($currtime - $timecheck) > $timeout } {
hset $tc_root/emon/isintol 1
}
return 1
}
}
##
# @brief Implement the checkstatus command for the drivable interface
#
# NOTE: The drive adapter initially sets the writestatus to "start" and will
# only call this when writestatus!="start"
proc drivestatus {tc_root} {
if {[sct driving]} {
return busy
} else {
sct print "drivestatus: idle"
return idle
}
}
proc halt {tc_root} {
debug_log "halt $tc_root"
hset $tc_root/setpoint [hval $tc_root/sensor/value]
hset $tc_root/drive_state "IDLE"
hset $tc_root/status "idle"
hsetprop $tc_root/setpoint driving 0
hsetprop $tc_root/ips120_state my_state "STATE_X"
return idle
}
##
# @brief createNode() creates a node for the given nodename with the properties and virtual
# function names provided
# @param scobj_hpath string variable holding the path to the object's base node in sics (/sample/tc1)
# @param sct_controller name of the scriptcontext object (typically sct_xxx_yyy)
# @param cmdGroup subdirectory (below /sample/tc*/) in which the node is to be created
# @param varName name of the actual node typically representing one device command
# @param readable set to 1 if the node represents a query command, 0 if it is not
# @param writable set to 1 if the node represents a request for a change in settings sent to the device
# @param drivable if set to 1 it prepares the node to provide a drivable interface
# @param dataType data type of the node, must be one of none, int, float, text
# @param permission defines what user group may read/write to this node (is one of spy, user, manager)
# @param rdCmd actual device query command to be sent to the device
# @param rdFunc nextState Function to be called after the getValue function, typically rdValue()
# @param wrCmd actual device write command to be sent to the device
# @param wrFunc Function to be called to send the wrCmd to the device, typically setValue()
# @param allowedValues allowed values for the node data - does not permit other
# @param klass Nexus class name (?)
# @return OK
proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable\
drivable dataType permission rdCmd rdFunc wrCmd\
wrFunc allowedValues klass} {
set catch_status [ catch {
# set ns ::scobj::ips120
set ns "[namespace current]"
set nodeName "$scobj_hpath/$cmdGroup/$varName"
if {1 > [string length $cmdGroup]} {
set nodeName "$scobj_hpath/$varName"
}
debug_log "Creating node $nodeName"
hfactory $nodeName plain $permission $dataType
if {$readable > 0} {
hsetprop $nodeName read ${ns}::getValue $scobj_hpath $rdFunc $rdCmd
hsetprop $nodeName $rdFunc ${ns}::$rdFunc $scobj_hpath
set poll_period 30
if { $readable >= 0 && $readable <= 9 } {
set poll_period [lindex [list 0 1 2 3 4 5 10 15 20 30] $readable]
}
debug_log "Registering node $nodeName for poll at $poll_period seconds"
$sct_controller poll $nodeName $poll_period
}
if {$writable == 1} {
set parts [split "$wrFunc" "."]
if { [llength $parts] == 2 } {
set func_name [lindex $parts 0]
set next_state [lindex $parts 1]
hsetprop $nodeName write ${ns}::$func_name $scobj_hpath $next_state $wrCmd
hsetprop $nodeName $next_state ${ns}::$next_state $scobj_hpath
} else {
hsetprop $nodeName write ${ns}::$wrFunc $scobj_hpath noResponse $wrCmd
hsetprop $nodeName noResponse ${ns}::noResponse
}
hsetprop $nodeName writestatus UNKNOWN
debug_log "Registering node $nodeName for write callback"
$sct_controller write $nodeName
}
switch -exact $dataType {
"none" { }
"int" { hsetprop $nodeName oldval -1 }
"float" { hsetprop $nodeName oldval -1.0 }
default { hsetprop $nodeName oldval UNKNOWN }
}
if {1 < [string length $allowedValues]} {
hsetprop $nodeName values $allowedValues
}
# Drive adapter interface
if {$drivable == 1} {
hsetprop $nodeName check ${ns}::check $scobj_hpath
hsetprop $nodeName driving 0
hsetprop $nodeName checklimits ${ns}::check $scobj_hpath
hsetprop $nodeName checkstatus ${ns}::drivestatus $scobj_hpath
hsetprop $nodeName halt ${ns}::halt $scobj_hpath
}
} message ]
if {$catch_status != 0} {
return -code error "in createNode $message"
}
return OK
}
proc mk_sct_oxford_ips120 {sct_controller klass tempobj tol} {
set catch_status [ catch {
# set ns ::scobj::ips120
set ns "[namespace current]"
MakeSICSObj $tempobj SCT_OBJECT
sicslist setatt $tempobj klass $klass
sicslist setatt $tempobj long_name $tempobj
set scobj_hpath /sics/$tempobj
set deviceCommand {\
{} setpoint 0 1 1 float user {} {rdValue} {J} {setPoint} {}\
sensor value 0 0 0 float internal {} {rdValue} {} {} {}\
Display OutputCurrent 1 0 0 float internal {R0} {rdValue} {} {} {}\
Display TargetCurrent 1 0 0 float internal {R5} {rdValue} {} {} {}\
Display SweepCurrent 5 0 0 float internal {R6} {rdValue} {} {} {}\
Display OutputField 1 0 0 float internal {R7} {rdValue} {} {} {}\
Display TargetField 1 0 0 float internal {R8} {rdValue} {} {} {}\
Display SweepField 5 0 0 float internal {R9} {rdValue} {} {} {}\
Display LimitVolts 5 0 0 float internal {R15} {rdValue} {} {} {}\
Display PstntCurrent 1 0 0 float internal {R16} {rdValue} {} {} {}\
Display TripCurrent 3 0 0 float internal {R17} {rdValue} {} {} {}\
Display PstntField 1 0 0 float internal {R18} {rdValue} {} {} {}\
Display TripField 3 0 0 float internal {R19} {rdValue} {} {} {}\
Display HeaterCurrent 2 0 0 float internal {R20} {rdValue} {} {} {}\
Display SafeCurrentNeg 5 0 0 float internal {R21} {rdValue} {} {} {}\
Display SafeCurrentPos 5 0 0 float internal {R22} {rdValue} {} {} {}\
Display LeadResistance 5 0 0 float internal {R23} {rdValue} {} {} {}\
Display CoilInductance 5 0 0 float internal {R24} {rdValue} {} {} {}\
Display Persistent 0 0 0 int internal {} {} {} {} {}\
Display A 0 0 0 text internal {} {} {} {} {}\
Display C 0 0 0 text internal {} {} {} {} {}\
Display H 0 0 0 text internal {} {} {} {} {}\
Display M 0 0 0 text internal {} {} {} {} {}\
Display P 0 0 0 text internal {} {} {} {} {}\
Display X 0 0 0 text internal {} {} {} {} {}\
Control A 0 1 0 int user {} {} {A} {setValue.chkWrite} {0,1,2,4}\
Control C 0 1 0 int user {} {} {C} {setValue.chkWrite} {0,1,2,3}\
Control H 0 1 0 int user {} {} {H} {setValue.chkWrite} {0,1}\
Control I 0 1 0 float user {} {} {I} {setValue.chkWrite} {}\
Control J 0 1 0 float user {} {} {J} {setValue.chkWrite} {}\
Control M 0 1 0 int user {} {} {M} {setValue.chkWrite} {0,1,4,5,8,9}\
Control P 0 1 0 int user {} {} {P} {setValue.chkWrite} {0,1,2,4}\
Control Q 0 1 0 int user {} {} {Q} {setValue} {0,2,4,6}\
Control S 0 1 0 float user {} {} {S} {setValue.chkWrite} {}\
Control T 0 1 0 float user {} {} {T} {setValue.chkWrite} {}\
}
hfactory $scobj_hpath/sensor plain spy none
hfactory $scobj_hpath/Display plain spy none
hfactory $scobj_hpath/Control plain spy none
foreach {cmdGroup varName readable writable drivable dataType permission rdCmd rdFunc wrCmd wrFunc allowedValues} $deviceCommand {
createNode $scobj_hpath $sct_controller $cmdGroup $varName $readable $writable $drivable $dataType $permission $rdCmd $rdFunc $wrCmd $wrFunc $allowedValues $klass
}
hsetprop $scobj_hpath/sensor/value lowerlimit -12
hsetprop $scobj_hpath/sensor/value upperlimit 12
hsetprop $scobj_hpath/sensor/value units "T"
hfactory $scobj_hpath/apply_tolerance plain user int
hsetprop $scobj_hpath/apply_tolerance values 0,1
hset $scobj_hpath/apply_tolerance 1
hfactory $scobj_hpath/tolerance plain user float
hsetprop $scobj_hpath/tolerance units "T"
hfactory $scobj_hpath/tolerance/settletime plain user float
hset $scobj_hpath/tolerance/settletime 5.0
hsetprop $scobj_hpath/tolerance/settletime units "s"
hset $scobj_hpath/tolerance $tol
hfactory $scobj_hpath/status plain spy text
hset $scobj_hpath/status "idle"
hsetprop $scobj_hpath/status values busy,idle
hfactory $scobj_hpath/ips120_state plain spy text
hsetprop $scobj_hpath/ips120_state read ${ns}::getState $scobj_hpath rdState "X"
hsetprop $scobj_hpath/ips120_state rdState ${ns}::rdState $scobj_hpath
hsetprop $scobj_hpath/ips120_state oldval "UNKNOWN"
hsetprop $scobj_hpath/ips120_state my_state "STATE_V"
hsetprop $scobj_hpath/ips120_state my_status "UNKNOWN"
hsetprop $scobj_hpath/ips120_state my_version "UNKNOWN"
hfactory $scobj_hpath/drive_state plain mugger text
hset $scobj_hpath/drive_state "UNKNOWN"
hfactory $scobj_hpath/remote_ctrl plain spy text
hset $scobj_hpath/remote_ctrl "UNKNOWN"
hfactory $scobj_hpath/ips120_lasterror plain user text
hset $scobj_hpath/ips120_lasterror ""
hfactory $scobj_hpath/lowerlimit plain mugger float
hsetprop $scobj_hpath/lowerlimit units "T"
hset $scobj_hpath/lowerlimit -11
hfactory $scobj_hpath/upperlimit plain mugger float
hsetprop $scobj_hpath/upperlimit units "T"
hset $scobj_hpath/upperlimit 11
hfactory $scobj_hpath/emon plain spy none
hfactory $scobj_hpath/emon/monmode plain user text
hsetprop $scobj_hpath/emon/monmode values idle,drive,monitor,error
hset $scobj_hpath/emon/monmode "idle"
hfactory $scobj_hpath/emon/isintol plain user int
hset $scobj_hpath/emon/isintol 1
hfactory $scobj_hpath/emon/errhandler plain user text
hset $scobj_hpath/emon/errhandler "pause"
if {[SplitReply [environment_simulation]]=="false"} {
# $sct_controller poll $scobj_hpath/setpoint
# $sct_controller write $scobj_hpath/setpoint
# $sct_controller poll $scobj_hpath/sensor/value
$sct_controller poll $scobj_hpath/ips120_state 1 halt read
}
::scobj::hinitprops $tempobj
hsetprop $scobj_hpath klass NXenvironment
# ::scobj::set_required_props $scobj_hpath
hsetprop $scobj_hpath type part
foreach snsr {sensor} {
foreach {rootpath hpath klass priv} "\
$scobj_hpath $snsr NXsensor spy\
$scobj_hpath $snsr/value sensor user\
" {
hsetprop $rootpath/$hpath klass $klass
hsetprop $rootpath/$hpath privilege $priv
hsetprop $rootpath/$hpath control true
hsetprop $rootpath/$hpath data true
hsetprop $rootpath/$hpath nxsave true
}
hsetprop $scobj_hpath/$snsr type part
hsetprop $scobj_hpath/$snsr/value nxalias tc1_${snsr}_value
hsetprop $scobj_hpath/$snsr/value mutable true
hsetprop $scobj_hpath/$snsr/value sdsinfo ::nexus::scobj::sdsinfo
}
hsetprop $scobj_hpath privilege spy
::scobj::hinitprops $tempobj setpoint
if {[SplitReply [environment_simulation]]=="false"} {
ansto_makesctdrive ${tempobj}_driveable $scobj_hpath/setpoint $scobj_hpath/sensor/value $sct_controller
}
} catch_message ]
if {$catch_status != 0} {
return -code error $catch_message
}
}
namespace export mk_sct_oxford_ips120
}
##
# @brief Create a Oxford ips120 power supply controller
#
# @param name, the name of the power supply controller (eg tc1)
# @param IP, the IP address of the device, this can be a hostname, (eg ca1-kowari)
# @param port, the IP protocol port number of the device
# @param _tol (optional), this is the initial tolerance setting
proc add_ips120 {name IP port {_tol 5.0}} {
set fd [open "/tmp/ips120.log" a]
if {[SplitReply [environment_simulation]]=="false"} {
puts $fd "makesctcontroller sct_ips120 oxford ${IP}:$port"
makesctcontroller sct_ips120 oxford ${IP}:$port
}
puts $fd "mk_sct_oxford_ips120 sct_ips120 environment $name $_tol"
mk_sct_oxford_ips120 sct_ips120 environment $name $_tol
puts $fd "makesctemon $name /sics/$name/emon/monmode /sics/$name/emon/isintol /sics/$name/emon/errhandler"
makesctemon $name /sics/$name/emon/monmode /sics/$name/emon/isintol /sics/$name/emon/errhandler
close $fd
}
puts stdout "file evaluation of sct_oxford_ips.tcl"
set fd [open "/tmp/ips120.log" w]
puts $fd "file evaluation of sct_oxford_ips.tcl"
close $fd
namespace import ::scobj::ips120::*
#add_ips120 ips120 137.157.201.213 502 5
add_ips120 ips120 localhost 30509 0.001