Driver for Agilent/Keysight N8740A Power Supply
This commit is contained in:
55
site_ansto/instrument/config/environment/keysight_N8740A.sct
Normal file
55
site_ansto/instrument/config/environment/keysight_N8740A.sct
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
|
||||||
|
driver keysight_N8740A = {
|
||||||
|
vendor = keysight; device = N8740A;
|
||||||
|
protocol = std
|
||||||
|
class = environment
|
||||||
|
simulation_group = environment_simulation
|
||||||
|
group = {
|
||||||
|
type = int;
|
||||||
|
var state = {
|
||||||
|
readable = 2; read_command = 'OUTPUT:STATE?';
|
||||||
|
writeable = 1; write_command = 'OUTPUT:STATE ';
|
||||||
|
allowed = '0,1';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
group current = {
|
||||||
|
type = float;
|
||||||
|
var sensor = {
|
||||||
|
readable = 1; read_command = 'MEASURE:CURRENT?';
|
||||||
|
writeable = 1; read_command = 'MEASURE:CURRENT ';
|
||||||
|
}
|
||||||
|
var setpoint = {
|
||||||
|
readable = 1; read_command = 'SOURCE:CURRENT?';
|
||||||
|
writeable = 1; read_command = 'SOURCE:CURRENT ';
|
||||||
|
}
|
||||||
|
var limit = {
|
||||||
|
readable = 1; read_command = 'SOURCE:CURRENT:PROTECTION?';
|
||||||
|
writeable = 1; read_command = 'SOURCE:CURRENT:PROTECTION ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
group voltage = {
|
||||||
|
type = float;
|
||||||
|
var sensor = {
|
||||||
|
readable = 1; read_command = 'MEASURE:VOLTAGE?';
|
||||||
|
writeable = 1; read_command = 'MEASURE:VOLTAGE ';
|
||||||
|
}
|
||||||
|
var setpoint = {
|
||||||
|
readable = 1; read_command = 'SOURCE:VOLTAGE?';
|
||||||
|
writeable = 1; read_command = 'SOURCE:VOLTAGE ';
|
||||||
|
}
|
||||||
|
var limit = {
|
||||||
|
readable = 1; read_command = 'SOURCE:VOLTAGE:PROTECTION?';
|
||||||
|
writeable = 1; read_command = 'SOURCE:VOLTAGE:PROTECTION ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
group system = {
|
||||||
|
type = text;
|
||||||
|
data = false; control = false; mutable = false; nxsave = false;
|
||||||
|
var error = {
|
||||||
|
readable = 1; read_command = 'SYSTEM:ERROR?';
|
||||||
|
}
|
||||||
|
var version = {
|
||||||
|
readable = 1; read_command = 'SYSTEM:VERSION?';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
513
site_ansto/instrument/config/environment/sct_keysight_N8740A.tcl
Normal file
513
site_ansto/instrument/config/environment/sct_keysight_N8740A.tcl
Normal file
@ -0,0 +1,513 @@
|
|||||||
|
# Generated driver for keysight_N8740A
|
||||||
|
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
|
||||||
|
#
|
||||||
|
|
||||||
|
namespace eval ::scobj::keysight_N8740A {
|
||||||
|
set debug_threshold 5
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ::scobj::keysight_N8740A::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 now [clock seconds]
|
||||||
|
set ts [clock format ${now} -format "%Y%m%d"]
|
||||||
|
set log_file_name "../log/keysight_N8740A_[basename ${tc_root}]_${ts}.log"
|
||||||
|
set fd [open "${log_file_name}" "a"]
|
||||||
|
set ts [clock format ${now} -format "%T"]
|
||||||
|
puts ${fd} "${ts} ${debug_string}"
|
||||||
|
close ${fd}
|
||||||
|
}
|
||||||
|
} catch_message ]
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ::scobj::keysight_N8740A::sics_log {debug_level debug_string} {
|
||||||
|
set catch_status [ catch {
|
||||||
|
set debug_threshold ${::scobj::keysight_N8740A::debug_threshold}
|
||||||
|
if {${debug_level} >= ${debug_threshold}} {
|
||||||
|
sicslog "::scobj::keysight_N8740A::${debug_string}"
|
||||||
|
}
|
||||||
|
} catch_message ]
|
||||||
|
}
|
||||||
|
|
||||||
|
# check function for hset change
|
||||||
|
proc ::scobj::keysight_N8740A::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}
|
||||||
|
}
|
||||||
|
|
||||||
|
# function to request the read of a parameter on a device
|
||||||
|
proc ::scobj::keysight_N8740A::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 goes here
|
||||||
|
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}
|
||||||
|
}
|
||||||
|
|
||||||
|
# function to check the write parameter on a device
|
||||||
|
proc ::scobj::keysight_N8740A::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::keysight_N8740A::rdValue {tc_root} {
|
||||||
|
set catch_status [ catch {
|
||||||
|
debug_log ${tc_root} 1 "rdValue 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]"
|
||||||
|
}
|
||||||
|
# rdValue hook code goes here
|
||||||
|
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::keysight_N8740A::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 goes here
|
||||||
|
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::keysight_N8740A::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } {
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "::scobj::keysight_N8740A::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
||||||
|
set ns "[namespace current]"
|
||||||
|
set catch_status [ catch {
|
||||||
|
|
||||||
|
MakeSICSObj ${name} SCT_OBJECT
|
||||||
|
|
||||||
|
sicslist setatt ${name} driver keysight_N8740A
|
||||||
|
sicslist setatt ${name} klass ${device_class}
|
||||||
|
sicslist setatt ${name} long_name ${name}
|
||||||
|
|
||||||
|
set scobj_hpath /sics/${name}
|
||||||
|
|
||||||
|
hfactory ${scobj_hpath}/state plain user int
|
||||||
|
hsetprop ${scobj_hpath}/state read ${ns}::getValue ${scobj_hpath} rdValue {OUTPUT:STATE?}
|
||||||
|
hsetprop ${scobj_hpath}/state rdValue ${ns}::rdValue ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/state write ${ns}::setValue ${scobj_hpath} noResponse {OUTPUT:STATE }
|
||||||
|
hsetprop ${scobj_hpath}/state noResponse ${ns}::noResponse ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/state check ${ns}::checkrange ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/state control true
|
||||||
|
hsetprop ${scobj_hpath}/state data true
|
||||||
|
hsetprop ${scobj_hpath}/state mutable true
|
||||||
|
hsetprop ${scobj_hpath}/state nxsave true
|
||||||
|
hsetprop ${scobj_hpath}/state values 0,1
|
||||||
|
hsetprop ${scobj_hpath}/state oldval 0
|
||||||
|
hsetprop ${scobj_hpath}/state klass "parameter"
|
||||||
|
hsetprop ${scobj_hpath}/state sdsinfo "::nexus::scobj::sdsinfo"
|
||||||
|
hsetprop ${scobj_hpath}/state type "part"
|
||||||
|
hsetprop ${scobj_hpath}/state nxalias "${name}_state"
|
||||||
|
|
||||||
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||||
|
${sct_controller} poll ${scobj_hpath}/state 2
|
||||||
|
${sct_controller} write ${scobj_hpath}/state
|
||||||
|
hsetprop ${scobj_hpath}/state simulated false
|
||||||
|
} else {
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A"
|
||||||
|
hsetprop ${scobj_hpath}/state simulated true
|
||||||
|
}
|
||||||
|
|
||||||
|
hsetprop ${scobj_hpath} data "true"
|
||||||
|
hsetprop ${scobj_hpath} klass "@none"
|
||||||
|
hsetprop ${scobj_hpath} type "part"
|
||||||
|
|
||||||
|
hfactory ${scobj_hpath}/current plain spy none
|
||||||
|
|
||||||
|
hfactory ${scobj_hpath}/current/limit plain user float
|
||||||
|
hsetprop ${scobj_hpath}/current/limit read ${ns}::getValue ${scobj_hpath} rdValue {SOURCE:CURRENT:PROTECTION }
|
||||||
|
hsetprop ${scobj_hpath}/current/limit rdValue ${ns}::rdValue ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/current/limit write ${ns}::setValue ${scobj_hpath} noResponse {}
|
||||||
|
hsetprop ${scobj_hpath}/current/limit noResponse ${ns}::noResponse ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/current/limit check ${ns}::checkrange ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/current/limit control true
|
||||||
|
hsetprop ${scobj_hpath}/current/limit data true
|
||||||
|
hsetprop ${scobj_hpath}/current/limit mutable true
|
||||||
|
hsetprop ${scobj_hpath}/current/limit nxsave true
|
||||||
|
hsetprop ${scobj_hpath}/current/limit oldval 0.0
|
||||||
|
hsetprop ${scobj_hpath}/current/limit klass "parameter"
|
||||||
|
hsetprop ${scobj_hpath}/current/limit sdsinfo "::nexus::scobj::sdsinfo"
|
||||||
|
hsetprop ${scobj_hpath}/current/limit type "part"
|
||||||
|
hsetprop ${scobj_hpath}/current/limit nxalias "${name}_current_limit"
|
||||||
|
|
||||||
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||||
|
${sct_controller} poll ${scobj_hpath}/current/limit 1
|
||||||
|
${sct_controller} write ${scobj_hpath}/current/limit
|
||||||
|
hsetprop ${scobj_hpath}/current/limit simulated false
|
||||||
|
} else {
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A"
|
||||||
|
hsetprop ${scobj_hpath}/current/limit simulated true
|
||||||
|
}
|
||||||
|
|
||||||
|
hfactory ${scobj_hpath}/current/sensor plain user float
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor read ${ns}::getValue ${scobj_hpath} rdValue {MEASURE:CURRENT }
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor rdValue ${ns}::rdValue ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor write ${ns}::setValue ${scobj_hpath} noResponse {}
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor noResponse ${ns}::noResponse ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor check ${ns}::checkrange ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor control true
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor data true
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor mutable true
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor nxsave true
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor oldval 0.0
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor klass "parameter"
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor sdsinfo "::nexus::scobj::sdsinfo"
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor type "part"
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor nxalias "${name}_current_sensor"
|
||||||
|
|
||||||
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||||
|
${sct_controller} poll ${scobj_hpath}/current/sensor 1
|
||||||
|
${sct_controller} write ${scobj_hpath}/current/sensor
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor simulated false
|
||||||
|
} else {
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A"
|
||||||
|
hsetprop ${scobj_hpath}/current/sensor simulated true
|
||||||
|
}
|
||||||
|
|
||||||
|
hfactory ${scobj_hpath}/current/setpoint plain user float
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint read ${ns}::getValue ${scobj_hpath} rdValue {SOURCE:CURRENT }
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint rdValue ${ns}::rdValue ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint write ${ns}::setValue ${scobj_hpath} noResponse {}
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint noResponse ${ns}::noResponse ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint check ${ns}::checkrange ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint control true
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint data true
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint mutable true
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint nxsave true
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint oldval 0.0
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint klass "parameter"
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint sdsinfo "::nexus::scobj::sdsinfo"
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint type "part"
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint nxalias "${name}_current_setpoint"
|
||||||
|
|
||||||
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||||
|
${sct_controller} poll ${scobj_hpath}/current/setpoint 1
|
||||||
|
${sct_controller} write ${scobj_hpath}/current/setpoint
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint simulated false
|
||||||
|
} else {
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A"
|
||||||
|
hsetprop ${scobj_hpath}/current/setpoint simulated true
|
||||||
|
}
|
||||||
|
hsetprop ${scobj_hpath}/current data "true"
|
||||||
|
hsetprop ${scobj_hpath}/current klass "@none"
|
||||||
|
hsetprop ${scobj_hpath}/current type "part"
|
||||||
|
|
||||||
|
hfactory ${scobj_hpath}/system plain spy none
|
||||||
|
|
||||||
|
hfactory ${scobj_hpath}/system/error plain user text
|
||||||
|
hsetprop ${scobj_hpath}/system/error read ${ns}::getValue ${scobj_hpath} rdValue {SYSTEM:ERROR?}
|
||||||
|
hsetprop ${scobj_hpath}/system/error rdValue ${ns}::rdValue ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/system/error control false
|
||||||
|
hsetprop ${scobj_hpath}/system/error data false
|
||||||
|
hsetprop ${scobj_hpath}/system/error mutable false
|
||||||
|
hsetprop ${scobj_hpath}/system/error nxsave false
|
||||||
|
hsetprop ${scobj_hpath}/system/error oldval UNKNOWN
|
||||||
|
hsetprop ${scobj_hpath}/system/error sdsinfo "::nexus::scobj::sdsinfo"
|
||||||
|
hsetprop ${scobj_hpath}/system/error type "part"
|
||||||
|
hsetprop ${scobj_hpath}/system/error nxalias "${name}_system_error"
|
||||||
|
|
||||||
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||||
|
${sct_controller} poll ${scobj_hpath}/system/error 1
|
||||||
|
hsetprop ${scobj_hpath}/system/error simulated false
|
||||||
|
} else {
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A"
|
||||||
|
hsetprop ${scobj_hpath}/system/error simulated true
|
||||||
|
}
|
||||||
|
|
||||||
|
hfactory ${scobj_hpath}/system/version plain user text
|
||||||
|
hsetprop ${scobj_hpath}/system/version read ${ns}::getValue ${scobj_hpath} rdValue {SYSTEM:VERSION?}
|
||||||
|
hsetprop ${scobj_hpath}/system/version rdValue ${ns}::rdValue ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/system/version control false
|
||||||
|
hsetprop ${scobj_hpath}/system/version data false
|
||||||
|
hsetprop ${scobj_hpath}/system/version mutable false
|
||||||
|
hsetprop ${scobj_hpath}/system/version nxsave false
|
||||||
|
hsetprop ${scobj_hpath}/system/version oldval UNKNOWN
|
||||||
|
hsetprop ${scobj_hpath}/system/version sdsinfo "::nexus::scobj::sdsinfo"
|
||||||
|
hsetprop ${scobj_hpath}/system/version type "part"
|
||||||
|
hsetprop ${scobj_hpath}/system/version nxalias "${name}_system_version"
|
||||||
|
|
||||||
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||||
|
${sct_controller} poll ${scobj_hpath}/system/version 1
|
||||||
|
hsetprop ${scobj_hpath}/system/version simulated false
|
||||||
|
} else {
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A"
|
||||||
|
hsetprop ${scobj_hpath}/system/version simulated true
|
||||||
|
}
|
||||||
|
hsetprop ${scobj_hpath}/system data "false"
|
||||||
|
hsetprop ${scobj_hpath}/system klass "@none"
|
||||||
|
hsetprop ${scobj_hpath}/system type "part"
|
||||||
|
|
||||||
|
hfactory ${scobj_hpath}/voltage plain spy none
|
||||||
|
|
||||||
|
hfactory ${scobj_hpath}/voltage/limit plain user float
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit read ${ns}::getValue ${scobj_hpath} rdValue {SOURCE:VOLTAGE:PROTECTION }
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit rdValue ${ns}::rdValue ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit write ${ns}::setValue ${scobj_hpath} noResponse {}
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit noResponse ${ns}::noResponse ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit check ${ns}::checkrange ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit control true
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit data true
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit mutable true
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit nxsave true
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit oldval 0.0
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit klass "parameter"
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit sdsinfo "::nexus::scobj::sdsinfo"
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit type "part"
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit nxalias "${name}_voltage_limit"
|
||||||
|
|
||||||
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||||
|
${sct_controller} poll ${scobj_hpath}/voltage/limit 1
|
||||||
|
${sct_controller} write ${scobj_hpath}/voltage/limit
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit simulated false
|
||||||
|
} else {
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A"
|
||||||
|
hsetprop ${scobj_hpath}/voltage/limit simulated true
|
||||||
|
}
|
||||||
|
|
||||||
|
hfactory ${scobj_hpath}/voltage/sensor plain user float
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor read ${ns}::getValue ${scobj_hpath} rdValue {MEASURE:VOLTAGE }
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor rdValue ${ns}::rdValue ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor write ${ns}::setValue ${scobj_hpath} noResponse {}
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor noResponse ${ns}::noResponse ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor check ${ns}::checkrange ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor control true
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor data true
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor mutable true
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor nxsave true
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor oldval 0.0
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor klass "parameter"
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor sdsinfo "::nexus::scobj::sdsinfo"
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor type "part"
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor nxalias "${name}_voltage_sensor"
|
||||||
|
|
||||||
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||||
|
${sct_controller} poll ${scobj_hpath}/voltage/sensor 1
|
||||||
|
${sct_controller} write ${scobj_hpath}/voltage/sensor
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor simulated false
|
||||||
|
} else {
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A"
|
||||||
|
hsetprop ${scobj_hpath}/voltage/sensor simulated true
|
||||||
|
}
|
||||||
|
|
||||||
|
hfactory ${scobj_hpath}/voltage/setpoint plain user float
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint read ${ns}::getValue ${scobj_hpath} rdValue {SOURCE:VOLTAGE }
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint rdValue ${ns}::rdValue ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint write ${ns}::setValue ${scobj_hpath} noResponse {}
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint noResponse ${ns}::noResponse ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint check ${ns}::checkrange ${scobj_hpath}
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint control true
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint data true
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint mutable true
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint nxsave true
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint oldval 0.0
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint klass "parameter"
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint sdsinfo "::nexus::scobj::sdsinfo"
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint type "part"
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint nxalias "${name}_voltage_setpoint"
|
||||||
|
|
||||||
|
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||||
|
${sct_controller} poll ${scobj_hpath}/voltage/setpoint 1
|
||||||
|
${sct_controller} write ${scobj_hpath}/voltage/setpoint
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint simulated false
|
||||||
|
} else {
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A"
|
||||||
|
hsetprop ${scobj_hpath}/voltage/setpoint simulated true
|
||||||
|
}
|
||||||
|
hsetprop ${scobj_hpath}/voltage data "true"
|
||||||
|
hsetprop ${scobj_hpath}/voltage klass "@none"
|
||||||
|
hsetprop ${scobj_hpath}/voltage type "part"
|
||||||
|
hsetprop ${scobj_hpath} driver keysight_N8740A
|
||||||
|
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::keysight_N8740A::add_driver {name device_class simulation_flag ip_address tcp_port} {
|
||||||
|
set catch_status [ catch {
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "::scobj::keysight_N8740A::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::keysight_N8740A::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"
|
||||||
|
makesctcontroller sct_${name} aqadapter ${tcp_port}
|
||||||
|
} else {
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}"
|
||||||
|
makesctcontroller sct_${name} std ${ip_address}:${tcp_port}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for keysight_N8740A"
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
|
||||||
|
makesctcontroller sct_${name} aqadapter NULL
|
||||||
|
}
|
||||||
|
::scobj::keysight_N8740A::sics_log 1 "::scobj::keysight_N8740A::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
||||||
|
::scobj::keysight_N8740A::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
|
||||||
|
} catch_message ]
|
||||||
|
handle_exception ${catch_status} ${catch_message}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace eval ::scobj::keysight_N8740A {
|
||||||
|
namespace export debug_threshold
|
||||||
|
namespace export debug_log
|
||||||
|
namespace export sics_log
|
||||||
|
namespace export mkDriver
|
||||||
|
namespace export add_driver
|
||||||
|
}
|
||||||
|
|
||||||
|
proc add_keysight_N8740A {name ip_address tcp_port} {
|
||||||
|
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
|
||||||
|
::scobj::keysight_N8740A::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port}
|
||||||
|
}
|
||||||
|
|
||||||
|
clientput "file evaluation of sct_keysight_N8740A.tcl"
|
||||||
|
::scobj::keysight_N8740A::sics_log 9 "file evaluation of sct_keysight_N8740A.tcl"
|
||||||
|
|
||||||
|
proc ::scobj::keysight_N8740A::read_config {} {
|
||||||
|
set catch_status [ catch {
|
||||||
|
set ns "::scobj::keysight_N8740A"
|
||||||
|
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"] "keysight_N8740A"] } {
|
||||||
|
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::keysight_N8740A::read_config
|
||||||
|
} else {
|
||||||
|
::scobj::keysight_N8740A::sics_log 5 "No config dict"
|
||||||
|
}
|
Reference in New Issue
Block a user