609 lines
25 KiB
Tcl
609 lines
25 KiB
Tcl
# Generated driver for huber_pilot
|
|
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
|
|
#
|
|
|
|
namespace eval ::scobj::huber_pilot {
|
|
set debug_threshold 5
|
|
if { ![info exists ::scobj::permlink_device_counter]} {
|
|
set ::scobj::permlink_device_counter 0
|
|
}
|
|
}
|
|
|
|
proc ::scobj::huber_pilot::debug_log {tc_root debug_level debug_string} {
|
|
set catch_status [ catch {
|
|
set debug_threshold [hgetpropval ${tc_root} debug_threshold]
|
|
if {${debug_level} >= ${debug_threshold}} {
|
|
set fd [open "../log/huber_pilot_[basename ${tc_root}].log" "a"]
|
|
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
|
|
puts ${fd} "${line}"
|
|
close ${fd}
|
|
}
|
|
} catch_message ]
|
|
}
|
|
|
|
proc ::scobj::huber_pilot::sics_log {debug_level debug_string} {
|
|
set catch_status [ catch {
|
|
set debug_threshold ${::scobj::huber_pilot::debug_threshold}
|
|
if {${debug_level} >= ${debug_threshold}} {
|
|
sicslog "::scobj::huber_pilot::${debug_string}"
|
|
}
|
|
} catch_message ]
|
|
}
|
|
|
|
# checklimits function for driveable interface
|
|
proc ::scobj::huber_pilot::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::huber_pilot::checkrange {tc_root} {
|
|
set catch_status [ catch {
|
|
debug_log ${tc_root} 1 "checkrange 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]
|
|
}
|
|
# checkrange hook code goes here
|
|
if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {
|
|
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
|
|
}
|
|
return OK
|
|
} catch_message ]
|
|
handle_exception ${catch_status} ${catch_message}
|
|
}
|
|
|
|
# checkstatus function for driveable interface
|
|
proc ::scobj::huber_pilot::checkstatus {tc_root} {
|
|
set catch_status [ catch {
|
|
# checkstatus hook code goes here
|
|
if {[sct driving]} {
|
|
set sp "[sct target]"
|
|
if {[hpropexists [sct] simulated] && [sct simulated] == "true"} {
|
|
set pv "${sp}"
|
|
hupdateif ${tc_root}/[sct driveable] ${sp}
|
|
}
|
|
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::huber_pilot::getValue {tc_root nextState cmd_str} {
|
|
set catch_status [ catch {
|
|
debug_log ${tc_root} 1 "getValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
|
if { [hpropexists [sct] geterror] } {
|
|
hdelprop [sct] geterror
|
|
}
|
|
set cmd "${cmd_str}"
|
|
# getValue hook code starts
|
|
set cmd "M${cmd_str}****"
|
|
# getValue hook code ends
|
|
if { [hpropexists [sct] geterror] } {
|
|
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
|
error "[sct geterror]"
|
|
}
|
|
debug_log ${tc_root} 1 "getValue sct send ${cmd}"
|
|
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
|
|
sct send "${cmd}"
|
|
}
|
|
return ${nextState}
|
|
} catch_message ]
|
|
handle_exception ${catch_status} ${catch_message}
|
|
}
|
|
|
|
# halt function for driveable interface
|
|
proc ::scobj::huber_pilot::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::huber_pilot::noResponse {tc_root} {
|
|
set catch_status [ catch {
|
|
debug_log ${tc_root} 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]"
|
|
# noResponse hook code goes here
|
|
return "idle"
|
|
} catch_message ]
|
|
handle_exception ${catch_status} ${catch_message}
|
|
}
|
|
|
|
# function to parse the read of a parameter on a device
|
|
proc ::scobj::huber_pilot::rdStatus {tc_root} {
|
|
set catch_status [ catch {
|
|
debug_log ${tc_root} 1 "rdStatus tc_root=${tc_root} sct=[sct] result=[sct result]"
|
|
if { [hpropexists [sct] geterror] } {
|
|
hdelprop [sct] geterror
|
|
}
|
|
set data [sct result]
|
|
set nextState "idle"
|
|
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
|
|
# the protocol driver has reported an error
|
|
sct geterror "${data}"
|
|
error "[sct geterror]"
|
|
}
|
|
# rdStatus hook code starts
|
|
if {[string length ${data}] < 7} {
|
|
sct geterror "rdValue short response ${data}"
|
|
} elseif { ![string equal -nocase [string range ${data} 0 0] "S"] } {
|
|
sct geterror "rdValue syntax error ${data}"
|
|
} else {
|
|
set resp [scan [string range ${data} 3 end] "%x" val]
|
|
if { ${resp} < 1 } {
|
|
sct geterror "rdValue scan error ${data}"
|
|
} else {
|
|
set data ${val}
|
|
}
|
|
}
|
|
# rdStatus hook code ends
|
|
if { [hpropexists [sct] geterror] } {
|
|
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
|
error "[sct geterror]"
|
|
}
|
|
if { ${data} != [sct oldval] } {
|
|
debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]"
|
|
sct oldval ${data}
|
|
sct update ${data}
|
|
sct utime readtime
|
|
}
|
|
return ${nextState}
|
|
} catch_message ]
|
|
handle_exception ${catch_status} ${catch_message}
|
|
}
|
|
|
|
# function to parse the read of a parameter on a device
|
|
proc ::scobj::huber_pilot::rdTemp {tc_root} {
|
|
set catch_status [ catch {
|
|
debug_log ${tc_root} 1 "rdTemp tc_root=${tc_root} sct=[sct] result=[sct result]"
|
|
if { [hpropexists [sct] geterror] } {
|
|
hdelprop [sct] geterror
|
|
}
|
|
set data [sct result]
|
|
set nextState "idle"
|
|
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
|
|
# the protocol driver has reported an error
|
|
sct geterror "${data}"
|
|
error "[sct geterror]"
|
|
}
|
|
# rdTemp hook code starts
|
|
if {[string length ${data}] < 7} {
|
|
sct geterror "rdValue short response ${data}"
|
|
} elseif { ![string equal -nocase [string range ${data} 0 0] "S"] } {
|
|
sct geterror "rdValue syntax error ${data}"
|
|
} else {
|
|
set resp [scan [string range ${data} 3 end] "%x" val]
|
|
if { ${resp} < 1 } {
|
|
sct geterror "rdValue scan error ${data}"
|
|
} else {
|
|
if { ${val} >= 0x8000 } {
|
|
set val [expr ${val} - 0x10000]
|
|
}
|
|
set data [expr 0.01 * ${val}]
|
|
if { ${data} <= -151.00 } {
|
|
sct geterror "rdValue value error ${data}"
|
|
}
|
|
}
|
|
}
|
|
# rdTemp hook code ends
|
|
if { [hpropexists [sct] geterror] } {
|
|
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
|
error "[sct geterror]"
|
|
}
|
|
if { ${data} != [sct oldval] } {
|
|
debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]"
|
|
sct oldval ${data}
|
|
sct update ${data}
|
|
sct utime readtime
|
|
}
|
|
return ${nextState}
|
|
} catch_message ]
|
|
handle_exception ${catch_status} ${catch_message}
|
|
}
|
|
|
|
# function to write a parameter value on a device
|
|
proc ::scobj::huber_pilot::setValue {tc_root nextState cmd_str} {
|
|
set catch_status [ catch {
|
|
debug_log ${tc_root} 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
|
if { [hpropexists [sct] geterror] } {
|
|
hdelprop [sct] geterror
|
|
}
|
|
set par [sct target]
|
|
set cmd "${cmd_str}${par}"
|
|
# setValue hook code starts
|
|
set param [expr { round(100.0 * [sct target]) }]
|
|
set param [string range [format "%04X" ${param}] end-3 end]
|
|
set cmd "M${cmd_str}${param}"
|
|
# setValue hook code ends
|
|
if { [hpropexists [sct] geterror] } {
|
|
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
|
error "[sct geterror]"
|
|
}
|
|
if { [hpropexists [sct] driving] } {
|
|
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
|
|
sct driving 1
|
|
}
|
|
}
|
|
debug_log ${tc_root} 1 "setValue sct send ${cmd}"
|
|
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
|
|
sct send "${cmd}"
|
|
}
|
|
return ${nextState}
|
|
} catch_message ]
|
|
handle_exception ${catch_status} ${catch_message}
|
|
}
|
|
|
|
proc ::scobj::huber_pilot::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } {
|
|
::scobj::huber_pilot::sics_log 9 "::scobj::huber_pilot::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
|
set ns "[namespace current]"
|
|
set catch_status [ catch {
|
|
|
|
set permlink_device_number [format "%02d" [incr ::scobj::permlink_device_counter]]
|
|
|
|
MakeSICSObj ${name} SCT_OBJECT
|
|
|
|
sicslist setatt ${name} klass ${device_class}
|
|
sicslist setatt ${name} long_name ${name}
|
|
|
|
set scobj_hpath /sics/${name}
|
|
|
|
hfactory ${scobj_hpath}/Loop1 plain spy none
|
|
|
|
hfactory ${scobj_hpath}/Loop1/sensor_int plain user float
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int read ${ns}::getValue ${scobj_hpath} rdTemp {01}
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int rdTemp ${ns}::rdTemp ${scobj_hpath}
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int control true
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int data true
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int mutable true
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int nxsave true
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int permlink data_set "T${permlink_device_number}S01"
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int @description "T${permlink_device_number}S01"
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int oldval 0.0
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int klass "parameter"
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int sdsinfo "::nexus::scobj::sdsinfo"
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int type "part"
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int nxalias "${name}_Loop1_sensor_int"
|
|
|
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
|
${sct_controller} poll ${scobj_hpath}/Loop1/sensor_int 1
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int simulated false
|
|
} else {
|
|
::scobj::huber_pilot::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for huber_pilot"
|
|
hsetprop ${scobj_hpath}/Loop1/sensor_int simulated true
|
|
}
|
|
|
|
hfactory ${scobj_hpath}/Loop1/setpoint plain user float
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint read ${ns}::getValue ${scobj_hpath} rdTemp {00}
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint rdTemp ${ns}::rdTemp ${scobj_hpath}
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint write ${ns}::setValue ${scobj_hpath} noResponse {00}
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint noResponse ${ns}::noResponse ${scobj_hpath}
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint check ${ns}::checkrange ${scobj_hpath}
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint driving 0
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint checklimits ${ns}::checklimits ${scobj_hpath}
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint checkstatus ${ns}::checkstatus ${scobj_hpath}
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint halt ${ns}::halt ${scobj_hpath}
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint driveable Loop1/sensor_int
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint control true
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint data true
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint mutable true
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint nxsave true
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint lowerlimit 5.0
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint upperlimit 30.0
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint tolerance 0.5
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint permlink data_set "T${permlink_device_number}SP01"
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint @description "T${permlink_device_number}SP01"
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint oldval 0.0
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint klass "parameter"
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint sdsinfo "::nexus::scobj::sdsinfo"
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint settle_time "10"
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint type "drivable"
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint nxalias "${name}_Loop1_setpoint"
|
|
|
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
|
${sct_controller} poll ${scobj_hpath}/Loop1/setpoint 1
|
|
${sct_controller} write ${scobj_hpath}/Loop1/setpoint
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint simulated false
|
|
} else {
|
|
::scobj::huber_pilot::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for huber_pilot"
|
|
hsetprop ${scobj_hpath}/Loop1/setpoint simulated true
|
|
}
|
|
|
|
hfactory ${scobj_hpath}/Loop1/vMaxSP plain user float
|
|
hsetprop ${scobj_hpath}/Loop1/vMaxSP read ${ns}::getValue ${scobj_hpath} rdTemp {31}
|
|
hsetprop ${scobj_hpath}/Loop1/vMaxSP rdTemp ${ns}::rdTemp ${scobj_hpath}
|
|
hsetprop ${scobj_hpath}/Loop1/vMaxSP control true
|
|
hsetprop ${scobj_hpath}/Loop1/vMaxSP data true
|
|
hsetprop ${scobj_hpath}/Loop1/vMaxSP mutable true
|
|
hsetprop ${scobj_hpath}/Loop1/vMaxSP nxsave true
|
|
hsetprop ${scobj_hpath}/Loop1/vMaxSP oldval 0.0
|
|
hsetprop ${scobj_hpath}/Loop1/vMaxSP klass "parameter"
|
|
hsetprop ${scobj_hpath}/Loop1/vMaxSP sdsinfo "::nexus::scobj::sdsinfo"
|
|
hsetprop ${scobj_hpath}/Loop1/vMaxSP type "part"
|
|
hsetprop ${scobj_hpath}/Loop1/vMaxSP nxalias "${name}_Loop1_vMaxSP"
|
|
|
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
|
${sct_controller} poll ${scobj_hpath}/Loop1/vMaxSP 1
|
|
hsetprop ${scobj_hpath}/Loop1/vMaxSP simulated false
|
|
} else {
|
|
::scobj::huber_pilot::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for huber_pilot"
|
|
hsetprop ${scobj_hpath}/Loop1/vMaxSP simulated true
|
|
}
|
|
|
|
hfactory ${scobj_hpath}/Loop1/vMinSP plain user float
|
|
hsetprop ${scobj_hpath}/Loop1/vMinSP read ${ns}::getValue ${scobj_hpath} rdTemp {30}
|
|
hsetprop ${scobj_hpath}/Loop1/vMinSP rdTemp ${ns}::rdTemp ${scobj_hpath}
|
|
hsetprop ${scobj_hpath}/Loop1/vMinSP control true
|
|
hsetprop ${scobj_hpath}/Loop1/vMinSP data true
|
|
hsetprop ${scobj_hpath}/Loop1/vMinSP mutable true
|
|
hsetprop ${scobj_hpath}/Loop1/vMinSP nxsave true
|
|
hsetprop ${scobj_hpath}/Loop1/vMinSP oldval 0.0
|
|
hsetprop ${scobj_hpath}/Loop1/vMinSP klass "parameter"
|
|
hsetprop ${scobj_hpath}/Loop1/vMinSP sdsinfo "::nexus::scobj::sdsinfo"
|
|
hsetprop ${scobj_hpath}/Loop1/vMinSP type "part"
|
|
hsetprop ${scobj_hpath}/Loop1/vMinSP nxalias "${name}_Loop1_vMinSP"
|
|
|
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
|
${sct_controller} poll ${scobj_hpath}/Loop1/vMinSP 1
|
|
hsetprop ${scobj_hpath}/Loop1/vMinSP simulated false
|
|
} else {
|
|
::scobj::huber_pilot::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for huber_pilot"
|
|
hsetprop ${scobj_hpath}/Loop1/vMinSP simulated true
|
|
}
|
|
|
|
hfactory ${scobj_hpath}/Loop1/vTE plain user float
|
|
hsetprop ${scobj_hpath}/Loop1/vTE read ${ns}::getValue ${scobj_hpath} rdTemp {07}
|
|
hsetprop ${scobj_hpath}/Loop1/vTE rdTemp ${ns}::rdTemp ${scobj_hpath}
|
|
hsetprop ${scobj_hpath}/Loop1/vTE control true
|
|
hsetprop ${scobj_hpath}/Loop1/vTE data true
|
|
hsetprop ${scobj_hpath}/Loop1/vTE mutable true
|
|
hsetprop ${scobj_hpath}/Loop1/vTE nxsave true
|
|
hsetprop ${scobj_hpath}/Loop1/vTE permlink data_set "T${permlink_device_number}S07"
|
|
hsetprop ${scobj_hpath}/Loop1/vTE @description "T${permlink_device_number}S07"
|
|
hsetprop ${scobj_hpath}/Loop1/vTE oldval 0.0
|
|
hsetprop ${scobj_hpath}/Loop1/vTE klass "parameter"
|
|
hsetprop ${scobj_hpath}/Loop1/vTE sdsinfo "::nexus::scobj::sdsinfo"
|
|
hsetprop ${scobj_hpath}/Loop1/vTE type "part"
|
|
hsetprop ${scobj_hpath}/Loop1/vTE nxalias "${name}_Loop1_vTE"
|
|
|
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
|
${sct_controller} poll ${scobj_hpath}/Loop1/vTE 1
|
|
hsetprop ${scobj_hpath}/Loop1/vTE simulated false
|
|
} else {
|
|
::scobj::huber_pilot::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for huber_pilot"
|
|
hsetprop ${scobj_hpath}/Loop1/vTE simulated true
|
|
}
|
|
|
|
hfactory ${scobj_hpath}/Loop1/vTmpActive plain user int
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpActive read ${ns}::getValue ${scobj_hpath} rdStatus {14}
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpActive rdStatus ${ns}::rdStatus ${scobj_hpath}
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpActive control true
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpActive data true
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpActive mutable true
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpActive nxsave true
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpActive oldval 0
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpActive klass "parameter"
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpActive sdsinfo "::nexus::scobj::sdsinfo"
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpActive type "part"
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpActive nxalias "${name}_Loop1_vTmpActive"
|
|
|
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
|
${sct_controller} poll ${scobj_hpath}/Loop1/vTmpActive 1
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpActive simulated false
|
|
} else {
|
|
::scobj::huber_pilot::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for huber_pilot"
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpActive simulated true
|
|
}
|
|
|
|
hfactory ${scobj_hpath}/Loop1/vTmpMode plain user int
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpMode read ${ns}::getValue ${scobj_hpath} rdStatus {13}
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpMode rdStatus ${ns}::rdStatus ${scobj_hpath}
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpMode control true
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpMode data true
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpMode mutable true
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpMode nxsave true
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpMode oldval 0
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpMode klass "parameter"
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpMode sdsinfo "::nexus::scobj::sdsinfo"
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpMode type "part"
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpMode nxalias "${name}_Loop1_vTmpMode"
|
|
|
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
|
${sct_controller} poll ${scobj_hpath}/Loop1/vTmpMode 1
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpMode simulated false
|
|
} else {
|
|
::scobj::huber_pilot::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for huber_pilot"
|
|
hsetprop ${scobj_hpath}/Loop1/vTmpMode simulated true
|
|
}
|
|
hsetprop ${scobj_hpath}/Loop1 data "true"
|
|
hsetprop ${scobj_hpath}/Loop1 klass "@none"
|
|
hsetprop ${scobj_hpath}/Loop1 type "part"
|
|
ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor_int ${sct_controller}
|
|
hsetprop ${scobj_hpath} klass ${device_class}
|
|
hsetprop ${scobj_hpath} data true
|
|
hsetprop ${scobj_hpath} debug_threshold 5
|
|
# mkDriver hook code goes here
|
|
} catch_message ]
|
|
handle_exception ${catch_status} ${catch_message}
|
|
}
|
|
|
|
proc ::scobj::huber_pilot::add_driver {name device_class simulation_flag ip_address tcp_port} {
|
|
set catch_status [ catch {
|
|
::scobj::huber_pilot::sics_log 9 "::scobj::huber_pilot::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
|
if {[string equal -nocase "aqadapter" "${ip_address}"]} {
|
|
::scobj::huber_pilot::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"
|
|
makesctcontroller sct_${name} aqadapter ${tcp_port}
|
|
} else {
|
|
::scobj::huber_pilot::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}"
|
|
makesctcontroller sct_${name} std ${ip_address}:${tcp_port}
|
|
}
|
|
} else {
|
|
::scobj::huber_pilot::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for huber_pilot"
|
|
::scobj::huber_pilot::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
|
|
makesctcontroller sct_${name} aqadapter NULL
|
|
}
|
|
::scobj::huber_pilot::sics_log 1 "::scobj::huber_pilot::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
|
::scobj::huber_pilot::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
|
|
} catch_message ]
|
|
handle_exception ${catch_status} ${catch_message}
|
|
}
|
|
|
|
namespace eval ::scobj::huber_pilot {
|
|
namespace export debug_threshold
|
|
namespace export debug_log
|
|
namespace export sics_log
|
|
namespace export mkDriver
|
|
namespace export add_driver
|
|
}
|
|
|
|
proc add_huber_pilot {name ip_address tcp_port} {
|
|
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
|
|
::scobj::huber_pilot::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port}
|
|
}
|
|
|
|
clientput "file evaluation of sct_huber_pilot.tcl"
|
|
::scobj::huber_pilot::sics_log 9 "file evaluation of sct_huber_pilot.tcl"
|
|
|
|
proc ::scobj::huber_pilot::read_config {} {
|
|
set catch_status [ catch {
|
|
set ns "::scobj::huber_pilot"
|
|
dict for {k u} $::config_dict {
|
|
if { [dict exists $u "implementation"] } {
|
|
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
|
|
set device_class "environment"
|
|
if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {
|
|
continue
|
|
}
|
|
set enabled [string tolower [dict get $u "enabled"]]
|
|
if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {
|
|
continue
|
|
}
|
|
if { [dict exists $u "simulation_group"] } {
|
|
set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]]
|
|
}
|
|
if { [dict exists $u "device_class"] } {
|
|
set device_class "[dict get $u "device_class"]"
|
|
}
|
|
set name [dict get $u name]
|
|
set implementation [dict get $u "implementation"]
|
|
if { !([dict exists $::config_dict $implementation]) } {
|
|
continue
|
|
}
|
|
set v [dict get $::config_dict $implementation]
|
|
if { !([dict exists $v "driver"]) } {
|
|
continue
|
|
}
|
|
if { [string equal -nocase [dict get $v "driver"] "huber_pilot"] } {
|
|
if { ![string equal -nocase "${simulation_flag}" "false"] } {
|
|
set asyncqueue "null"
|
|
${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"
|
|
${ns}::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
|
|
makesctcontroller sct_${name} aqadapter NULL
|
|
} elseif { [dict exists $v "asyncqueue"] } {
|
|
set asyncqueue [dict get $v "asyncqueue"]
|
|
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
|
set ip_address [dict get $v ip]
|
|
set tcp_port [dict get $v port]
|
|
makesctcontroller sct_${name} std ${ip_address}:${tcp_port}
|
|
} else {
|
|
makesctcontroller sct_${name} aqadapter ${asyncqueue}
|
|
}
|
|
} else {
|
|
if { [dict exists $v "asyncprotocol"] } {
|
|
set asyncprotocol [dict get $v "asyncprotocol"]
|
|
} else {
|
|
set asyncprotocol ${name}_protocol
|
|
MakeAsyncProtocol ${asyncprotocol}
|
|
if { [dict exists $v "sendterminator"] } {
|
|
${asyncprotocol} sendterminator "[dict get $v "sendterminator"]"
|
|
} elseif { [dict exists $v "terminator"] } {
|
|
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
|
|
}
|
|
if { [dict exists $v "replyterminator"] } {
|
|
${asyncprotocol} replyterminator "[dict get $v "replyterminator"]"
|
|
} elseif { [dict exists $v "terminator"] } {
|
|
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
|
|
}
|
|
}
|
|
set asyncqueue ${name}_queue
|
|
set ip_address [dict get $v ip]
|
|
set tcp_port [dict get $v port]
|
|
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port}
|
|
if { [dict exists $v "timeout"] } {
|
|
${asyncqueue} timeout "[dict get $v "timeout"]"
|
|
}
|
|
makesctcontroller sct_${name} aqadapter ${asyncqueue}
|
|
}
|
|
${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
|
|
}
|
|
}
|
|
}
|
|
} catch_message ]
|
|
handle_exception ${catch_status} ${catch_message}
|
|
}
|
|
|
|
if { [info exists ::config_dict] } {
|
|
::scobj::huber_pilot::read_config
|
|
} else {
|
|
::scobj::huber_pilot::sics_log 5 "No config dict"
|
|
}
|