Regen SC driver for west 4100/6100

This commit is contained in:
Douglas Clowes
2014-10-27 14:41:46 +11:00
parent 09cedac66d
commit 3bcd3fa0fb

View File

@ -27,6 +27,33 @@ proc ::scobj::west_6100::sics_log {debug_level debug_string} {
} catch_message ]
}
# checklimits function for driveable interface
proc ::scobj::west_6100::checklimits {tc_root} {
set catch_status [ catch {
debug_log ${tc_root} 1 "checklimits tc_root=${tc_root} sct=[sct] target=[sct target]"
set setpoint [sct target]
if { [hpropexists [sct] lowerlimit] } {
set lolimit [sct lowerlimit]
} else {
# lowerlimit not set, use target
set lolimit [sct target]
}
if { [hpropexists [sct] upperlimit] } {
set hilimit [sct upperlimit]
} else {
# upperlimit not set, use target
set hilimit [sct target]
}
# checklimits hook code goes here
if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {
sct driving 0
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
}
return OK
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# check function for hset change
proc ::scobj::west_6100::checkrange {tc_root} {
set catch_status [ catch {
@ -53,6 +80,40 @@ proc ::scobj::west_6100::checkrange {tc_root} {
handle_exception ${catch_status} ${catch_message}
}
# checkstatus function for driveable interface
proc ::scobj::west_6100::checkstatus {tc_root} {
set catch_status [ catch {
# checkstatus hook code goes here
if {[sct driving]} {
set sp "[sct target]"
set pv "[hval ${tc_root}/[sct driveable]]"
if { abs(${pv} - ${sp}) <= [sct tolerance] } {
if { [hpropexists [sct] settle_time] } {
if { [hpropexists [sct] settle_time_start] } {
if { [sct utime] - [sct settle_time_start] >= [sct settle_time]} {
sct driving 0
return "idle"
}
return "busy"
} else {
sct utime settle_time_start
return "busy"
}
}
sct driving 0
return "idle"
}
if { [hpropexists [sct] settle_time_start] } {
hdelprop [sct] settle_time_start
}
return "busy"
} else {
return "idle"
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to request the read of a parameter on a device
proc ::scobj::west_6100::getDecimal {tc_root nextState cmd_str} {
set catch_status [ catch {
@ -101,6 +162,18 @@ proc ::scobj::west_6100::getInteger {tc_root nextState cmd_str} {
handle_exception ${catch_status} ${catch_message}
}
# halt function for driveable interface
proc ::scobj::west_6100::halt {tc_root} {
set catch_status [ catch {
debug_log ${tc_root} 1 "halt tc_root=${tc_root} sct=[sct] driving=[sct driving]"
### TODO hset [sct] [hval [sct]]
# halt hook code goes here
sct driving 0
return "idle"
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to check the write parameter on a device
proc ::scobj::west_6100::noResponse {tc_root} {
set catch_status [ catch {
@ -262,8 +335,8 @@ proc ::scobj::west_6100::wrInteger {tc_root nextState cmd_str} {
handle_exception ${catch_status} ${catch_message}
}
proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port dev_id } {
::scobj::west_6100::sics_log 9 "::scobj::west_6100::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}"
proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id } {
::scobj::west_6100::sics_log 9 "::scobj::west_6100::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}"
set ns "[namespace current]"
set catch_status [ catch {
@ -358,6 +431,8 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/sensor data true
hsetprop ${scobj_hpath}/sensor mutable true
hsetprop ${scobj_hpath}/sensor nxsave true
hsetprop ${scobj_hpath}/sensor permlink data_set "T[format "%02d" ${id}]S01"
hsetprop ${scobj_hpath}/sensor @description "T[format "%02d" ${id}]S01"
hsetprop ${scobj_hpath}/sensor oldval 0.0
hsetprop ${scobj_hpath}/sensor klass "parameter"
hsetprop ${scobj_hpath}/sensor sdsinfo "::nexus::scobj::sdsinfo"
@ -370,14 +445,25 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/setpoint write ${ns}::wrDecimal ${scobj_hpath} noResponse {2}
hsetprop ${scobj_hpath}/setpoint noResponse ${ns}::noResponse ${scobj_hpath}
hsetprop ${scobj_hpath}/setpoint check ${ns}::checkrange ${scobj_hpath}
hsetprop ${scobj_hpath}/setpoint driving 0
hsetprop ${scobj_hpath}/setpoint checklimits ${ns}::checklimits ${scobj_hpath}
hsetprop ${scobj_hpath}/setpoint checkstatus ${ns}::checkstatus ${scobj_hpath}
hsetprop ${scobj_hpath}/setpoint halt ${ns}::halt ${scobj_hpath}
hsetprop ${scobj_hpath}/setpoint driveable sensor
hsetprop ${scobj_hpath}/setpoint control true
hsetprop ${scobj_hpath}/setpoint data true
hsetprop ${scobj_hpath}/setpoint mutable true
hsetprop ${scobj_hpath}/setpoint nxsave true
hsetprop ${scobj_hpath}/setpoint lowerlimit 0
hsetprop ${scobj_hpath}/setpoint upperlimit 1600
hsetprop ${scobj_hpath}/setpoint tolerance 1
hsetprop ${scobj_hpath}/setpoint permlink data_set "T[format "%02d" ${id}]SP01"
hsetprop ${scobj_hpath}/setpoint @description "T[format "%02d" ${id}]SP01"
hsetprop ${scobj_hpath}/setpoint oldval 0.0
hsetprop ${scobj_hpath}/setpoint klass "parameter"
hsetprop ${scobj_hpath}/setpoint sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/setpoint type "part"
hsetprop ${scobj_hpath}/setpoint settle_time "30"
hsetprop ${scobj_hpath}/setpoint type "drivable"
hsetprop ${scobj_hpath}/setpoint nxalias "${name}_setpoint"
hfactory ${scobj_hpath}/w_sp plain user float
@ -471,14 +557,17 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath} klass ${device_class}
hsetprop ${scobj_hpath} data true
hsetprop ${scobj_hpath} debug_threshold 5
if {[string equal -nocase "${simulation_flag}" "false"]} {
ansto_makesctdrive ${name}_setpoint ${scobj_hpath}/setpoint ${scobj_hpath}/sensor ${sct_controller}
}
# mkDriver hook code goes here
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
proc ::scobj::west_6100::add_driver {name device_class simulation_flag ip_address tcp_port dev_id} {
proc ::scobj::west_6100::add_driver {name device_class simulation_flag ip_address tcp_port id} {
set catch_status [ catch {
::scobj::west_6100::sics_log 9 "::scobj::west_6100::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}"
::scobj::west_6100::sics_log 9 "::scobj::west_6100::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}"
if {[string equal -nocase "${simulation_flag}" "false"]} {
if {[string equal -nocase "aqadapter" "${ip_address}"]} {
::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"
@ -490,8 +579,8 @@ proc ::scobj::west_6100::add_driver {name device_class simulation_flag ip_addres
} else {
::scobj::west_6100::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for west_6100"
}
::scobj::west_6100::sics_log 1 "::scobj::west_6100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}"
::scobj::west_6100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}
::scobj::west_6100::sics_log 1 "::scobj::west_6100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}"
::scobj::west_6100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
@ -504,9 +593,9 @@ namespace eval ::scobj::west_6100 {
namespace export add_driver
}
proc add_west_6100 {name ip_address tcp_port dev_id} {
proc add_west_6100 {name ip_address tcp_port id} {
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
::scobj::west_6100::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${dev_id}"
::scobj::west_6100::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}"
}
clientput "file evaluation of sct_west_6100.tcl"
@ -572,7 +661,7 @@ proc ::scobj::west_6100::read_config {} {
}
set arg_list [list]
set missing_list [list]
foreach arg {dev_id} {
foreach arg {id} {
if {[dict exists $u $arg]} {
lappend arg_list "[dict get $u $arg]"
} elseif {[dict exists $v $arg]} {