# 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 ] } # checklimits function for driveable interface proc ::scobj::keysight_N8740A::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::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} } # checkstatus function for driveable interface proc ::scobj::keysight_N8740A::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} } else { 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::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} } # halt function for driveable interface proc ::scobj::keysight_N8740A::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::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 request the read of a parameter on a device proc ::scobj::keysight_N8740A::read_setpoint {tc_root nextState cmd_str} { set catch_status [ catch { debug_log ${tc_root} 1 "read_setpoint tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" if { [hpropexists [sct] geterror] } { hdelprop [sct] geterror } set cmd "${cmd_str}" # read_setpoint hook code starts if { [hpropexists [sct] target] } { set target [sct target] if { [hval ${tc_root}/working_setpoint] != ${target} } { set elapsed_time [expr {[sct utime] - [sct ramp_start_time]}] debug_log ${tc_root} 1 "read_setpoint elapsed_time = ${elapsed_time}" if {[hpropexists [sct] ramp_rate_value] && [sct ramp_rate_value] > 0.0} { set ramped_value [expr {[sct ramp_rate_value] * ${elapsed_time}}] debug_log ${tc_root} 1 "read_setpoint ramped_value = ${ramped_value}" if { ${target} > [hval ${tc_root}/working_setpoint] } { set working_setpoint [expr {[sct ramp_start_value] + ${ramped_value}}] debug_log ${tc_root} 1 "read_setpoint working_setpoint+ = ${working_setpoint}" if { ${working_setpoint} > ${target} } { set working_setpoint ${target} } } else { set working_setpoint [expr {[sct ramp_start_value] - ${ramped_value}}] debug_log ${tc_root} 1 "read_setpoint working_setpoint- = ${working_setpoint}" if { ${working_setpoint} < ${target} } { set working_setpoint ${target} } } } else { set working_setpoint ${target} debug_log ${tc_root} 1 "read_setpoint working_setpoint = ${working_setpoint}" } if {![hpropexists [sct] ramp_rate_value] || [sct ramp_rate_value] != [hval ${tc_root}/ramp_rate]} { sct ramp_start_time [sct utime] sct ramp_start_value [hval ${tc_root}/working_setpoint] sct ramp_rate_value [hval ${tc_root}/ramp_rate] } set cmd "SOURCE:VOLTAGE ${working_setpoint}@@NOREPLY@@" sct result [hval ${tc_root}/working_setpoint] } } else { # cmd is fine } # read_setpoint hook code ends if { [hpropexists [sct] geterror] } { debug_log ${tc_root} 9 "[sct] error: [sct geterror]" error "[sct geterror]" } debug_log ${tc_root} 1 "read_setpoint 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 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 starts set cmd "${cmd_str}${par}@@NOREPLY@@" # 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} } # function to write a parameter value on a device proc ::scobj::keysight_N8740A::write_direct {tc_root nextState cmd_str} { set catch_status [ catch { debug_log ${tc_root} 1 "write_direct 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}" # write_direct hook code starts set cmd "@@NOSEND@@" sct result "" if { [sct target] != [sct oldval] } { debug_log ${tc_root} 1 "[sct] changed to new:[sct target], from old:[sct oldval]" sct oldval [sct target] sct update [sct target] sct utime readtime } # write_direct 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 "write_direct 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 write a parameter value on a device proc ::scobj::keysight_N8740A::write_setpoint {tc_root nextState cmd_str} { set catch_status [ catch { debug_log ${tc_root} 1 "write_setpoint 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}" # write_setpoint hook code starts set cmd "@@NOSEND@@" sct result "" sct ramp_start_time [sct utime] sct ramp_start_value [hval ${tc_root}/working_setpoint] sct ramp_rate_value [hval ${tc_root}/ramp_rate] if { [sct target] != [sct oldval] } { debug_log ${tc_root} 1 "[sct] changed to new:[sct target], from old:[sct oldval]" sct oldval [sct target] sct update [sct target] sct utime readtime } # write_setpoint 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 "write_setpoint 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}/amps plain user float hsetprop ${scobj_hpath}/amps read ${ns}::getValue ${scobj_hpath} rdValue {MEASURE:SCALAR:CURRENT:DC?} hsetprop ${scobj_hpath}/amps rdValue ${ns}::rdValue ${scobj_hpath} hsetprop ${scobj_hpath}/amps control true hsetprop ${scobj_hpath}/amps data true hsetprop ${scobj_hpath}/amps mutable true hsetprop ${scobj_hpath}/amps nxsave true hsetprop ${scobj_hpath}/amps units A hsetprop ${scobj_hpath}/amps oldval 0.0 hsetprop ${scobj_hpath}/amps klass "parameter" hsetprop ${scobj_hpath}/amps sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/amps type "part" hsetprop ${scobj_hpath}/amps nxalias "${name}_amps" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/amps 1 hsetprop ${scobj_hpath}/amps simulated false } else { ::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A" hsetprop ${scobj_hpath}/amps simulated true } hfactory ${scobj_hpath}/output_enable plain user int hsetprop ${scobj_hpath}/output_enable read ${ns}::getValue ${scobj_hpath} rdValue {OUTPUT:STATE?} hsetprop ${scobj_hpath}/output_enable rdValue ${ns}::rdValue ${scobj_hpath} hsetprop ${scobj_hpath}/output_enable write ${ns}::setValue ${scobj_hpath} noResponse {OUTPUT:STATE } hsetprop ${scobj_hpath}/output_enable noResponse ${ns}::noResponse ${scobj_hpath} hsetprop ${scobj_hpath}/output_enable check ${ns}::checkrange ${scobj_hpath} hsetprop ${scobj_hpath}/output_enable control true hsetprop ${scobj_hpath}/output_enable data true hsetprop ${scobj_hpath}/output_enable mutable true hsetprop ${scobj_hpath}/output_enable nxsave true hsetprop ${scobj_hpath}/output_enable values 0,1 hsetprop ${scobj_hpath}/output_enable oldval 0 hsetprop ${scobj_hpath}/output_enable klass "parameter" hsetprop ${scobj_hpath}/output_enable sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/output_enable type "part" hsetprop ${scobj_hpath}/output_enable nxalias "${name}_output_enable" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/output_enable 2 ${sct_controller} write ${scobj_hpath}/output_enable hsetprop ${scobj_hpath}/output_enable simulated false } else { ::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A" hsetprop ${scobj_hpath}/output_enable simulated true } hfactory ${scobj_hpath}/ramp_rate plain user float hsetprop ${scobj_hpath}/ramp_rate write ${ns}::write_direct ${scobj_hpath} noResponse {} hsetprop ${scobj_hpath}/ramp_rate noResponse ${ns}::noResponse ${scobj_hpath} hsetprop ${scobj_hpath}/ramp_rate check ${ns}::checkrange ${scobj_hpath} hsetprop ${scobj_hpath}/ramp_rate control true hsetprop ${scobj_hpath}/ramp_rate data true hsetprop ${scobj_hpath}/ramp_rate mutable true hsetprop ${scobj_hpath}/ramp_rate nxsave true hsetprop ${scobj_hpath}/ramp_rate lowerlimit 0 hsetprop ${scobj_hpath}/ramp_rate upperlimit 15 hsetprop ${scobj_hpath}/ramp_rate units V/S hsetprop ${scobj_hpath}/ramp_rate oldval 1.0 hset ${scobj_hpath}/ramp_rate 1.0 hsetprop ${scobj_hpath}/ramp_rate klass "parameter" hsetprop ${scobj_hpath}/ramp_rate sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/ramp_rate type "part" hsetprop ${scobj_hpath}/ramp_rate nxalias "${name}_ramp_rate" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} write ${scobj_hpath}/ramp_rate hsetprop ${scobj_hpath}/ramp_rate simulated false } else { ::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A" hsetprop ${scobj_hpath}/ramp_rate simulated true } hfactory ${scobj_hpath}/setpoint plain user float hsetprop ${scobj_hpath}/setpoint read ${ns}::read_setpoint ${scobj_hpath} rdValue {SOURCE:VOLTAGE?} hsetprop ${scobj_hpath}/setpoint rdValue ${ns}::rdValue ${scobj_hpath} hsetprop ${scobj_hpath}/setpoint write ${ns}::write_setpoint ${scobj_hpath} noResponse {SOURCE:VOLTAGE } 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 working_setpoint 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 150 hsetprop ${scobj_hpath}/setpoint tolerance 1 hsetprop ${scobj_hpath}/setpoint units V 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 settle_time "5" hsetprop ${scobj_hpath}/setpoint type "drivable" hsetprop ${scobj_hpath}/setpoint nxalias "${name}_setpoint" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/setpoint 1 ${sct_controller} write ${scobj_hpath}/setpoint hsetprop ${scobj_hpath}/setpoint simulated false } else { ::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A" hsetprop ${scobj_hpath}/setpoint simulated true } hfactory ${scobj_hpath}/volts plain user float hsetprop ${scobj_hpath}/volts read ${ns}::getValue ${scobj_hpath} rdValue {MEASURE:SCALAR:VOLTAGE:DC?} hsetprop ${scobj_hpath}/volts rdValue ${ns}::rdValue ${scobj_hpath} hsetprop ${scobj_hpath}/volts control true hsetprop ${scobj_hpath}/volts data true hsetprop ${scobj_hpath}/volts mutable true hsetprop ${scobj_hpath}/volts nxsave true hsetprop ${scobj_hpath}/volts units V hsetprop ${scobj_hpath}/volts oldval 0.0 hsetprop ${scobj_hpath}/volts klass "parameter" hsetprop ${scobj_hpath}/volts sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/volts type "part" hsetprop ${scobj_hpath}/volts nxalias "${name}_volts" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/volts 1 hsetprop ${scobj_hpath}/volts simulated false } else { ::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A" hsetprop ${scobj_hpath}/volts simulated true } hfactory ${scobj_hpath}/working_setpoint plain user float hsetprop ${scobj_hpath}/working_setpoint read ${ns}::getValue ${scobj_hpath} rdValue {SOURCE:VOLTAGE?} hsetprop ${scobj_hpath}/working_setpoint rdValue ${ns}::rdValue ${scobj_hpath} hsetprop ${scobj_hpath}/working_setpoint write ${ns}::write_direct ${scobj_hpath} noResponse {} hsetprop ${scobj_hpath}/working_setpoint noResponse ${ns}::noResponse ${scobj_hpath} hsetprop ${scobj_hpath}/working_setpoint check ${ns}::checkrange ${scobj_hpath} hsetprop ${scobj_hpath}/working_setpoint control true hsetprop ${scobj_hpath}/working_setpoint data true hsetprop ${scobj_hpath}/working_setpoint mutable true hsetprop ${scobj_hpath}/working_setpoint nxsave true hsetprop ${scobj_hpath}/working_setpoint units V hsetprop ${scobj_hpath}/working_setpoint oldval 0.0 hsetprop ${scobj_hpath}/working_setpoint klass "parameter" hsetprop ${scobj_hpath}/working_setpoint sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/working_setpoint type "part" hsetprop ${scobj_hpath}/working_setpoint nxalias "${name}_working_setpoint" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/working_setpoint 1 ${sct_controller} write ${scobj_hpath}/working_setpoint hsetprop ${scobj_hpath}/working_setpoint simulated false } else { ::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A" hsetprop ${scobj_hpath}/working_setpoint simulated true } hsetprop ${scobj_hpath} data "true" hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" ansto_makesctdrive ${name}_setpoint ${scobj_hpath}/setpoint ${scobj_hpath}/working_setpoint ${sct_controller} hfactory ${scobj_hpath}/current plain spy none hfactory ${scobj_hpath}/current/prot_enable plain user int hsetprop ${scobj_hpath}/current/prot_enable read ${ns}::getValue ${scobj_hpath} rdValue {SOURCE:CURRENT:PROTECTION:STATE?} hsetprop ${scobj_hpath}/current/prot_enable rdValue ${ns}::rdValue ${scobj_hpath} hsetprop ${scobj_hpath}/current/prot_enable write ${ns}::setValue ${scobj_hpath} noResponse {SOURCE:CURRENT:PROTECTION:STATE } hsetprop ${scobj_hpath}/current/prot_enable noResponse ${ns}::noResponse ${scobj_hpath} hsetprop ${scobj_hpath}/current/prot_enable check ${ns}::checkrange ${scobj_hpath} hsetprop ${scobj_hpath}/current/prot_enable control true hsetprop ${scobj_hpath}/current/prot_enable data true hsetprop ${scobj_hpath}/current/prot_enable mutable true hsetprop ${scobj_hpath}/current/prot_enable nxsave true hsetprop ${scobj_hpath}/current/prot_enable values 0,1 hsetprop ${scobj_hpath}/current/prot_enable oldval 0 hsetprop ${scobj_hpath}/current/prot_enable klass "parameter" hsetprop ${scobj_hpath}/current/prot_enable sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/current/prot_enable type "part" hsetprop ${scobj_hpath}/current/prot_enable nxalias "${name}_current_prot_enable" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/current/prot_enable 1 ${sct_controller} write ${scobj_hpath}/current/prot_enable hsetprop ${scobj_hpath}/current/prot_enable simulated false } else { ::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A" hsetprop ${scobj_hpath}/current/prot_enable simulated true } hfactory ${scobj_hpath}/current/prot_limit plain user float hsetprop ${scobj_hpath}/current/prot_limit read ${ns}::getValue ${scobj_hpath} rdValue {SOURCE:CURRENT?} hsetprop ${scobj_hpath}/current/prot_limit rdValue ${ns}::rdValue ${scobj_hpath} hsetprop ${scobj_hpath}/current/prot_limit write ${ns}::setValue ${scobj_hpath} noResponse {SOURCE:CURRENT } hsetprop ${scobj_hpath}/current/prot_limit noResponse ${ns}::noResponse ${scobj_hpath} hsetprop ${scobj_hpath}/current/prot_limit check ${ns}::checkrange ${scobj_hpath} hsetprop ${scobj_hpath}/current/prot_limit control true hsetprop ${scobj_hpath}/current/prot_limit data true hsetprop ${scobj_hpath}/current/prot_limit mutable true hsetprop ${scobj_hpath}/current/prot_limit nxsave true hsetprop ${scobj_hpath}/current/prot_limit lowerlimit 0 hsetprop ${scobj_hpath}/current/prot_limit upperlimit 22 hsetprop ${scobj_hpath}/current/prot_limit units A hsetprop ${scobj_hpath}/current/prot_limit oldval 0.0 hsetprop ${scobj_hpath}/current/prot_limit klass "parameter" hsetprop ${scobj_hpath}/current/prot_limit sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/current/prot_limit type "part" hsetprop ${scobj_hpath}/current/prot_limit nxalias "${name}_current_prot_limit" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/current/prot_limit 1 ${sct_controller} write ${scobj_hpath}/current/prot_limit hsetprop ${scobj_hpath}/current/prot_limit simulated false } else { ::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A" hsetprop ${scobj_hpath}/current/prot_limit 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/ident plain user text hsetprop ${scobj_hpath}/system/ident read ${ns}::getValue ${scobj_hpath} rdValue {*IDN?} hsetprop ${scobj_hpath}/system/ident rdValue ${ns}::rdValue ${scobj_hpath} hsetprop ${scobj_hpath}/system/ident control false hsetprop ${scobj_hpath}/system/ident data false hsetprop ${scobj_hpath}/system/ident mutable false hsetprop ${scobj_hpath}/system/ident nxsave false hsetprop ${scobj_hpath}/system/ident oldval UNKNOWN hsetprop ${scobj_hpath}/system/ident sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/system/ident type "part" hsetprop ${scobj_hpath}/system/ident nxalias "${name}_system_ident" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/system/ident 15 hsetprop ${scobj_hpath}/system/ident simulated false } else { ::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A" hsetprop ${scobj_hpath}/system/ident 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 15 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/hilimit plain user float hsetprop ${scobj_hpath}/voltage/hilimit read ${ns}::getValue ${scobj_hpath} rdValue {SOURCE:VOLTAGE:PROTECTION?} hsetprop ${scobj_hpath}/voltage/hilimit rdValue ${ns}::rdValue ${scobj_hpath} hsetprop ${scobj_hpath}/voltage/hilimit write ${ns}::setValue ${scobj_hpath} noResponse {SOURCE:VOLTAGE:PROTECTION } hsetprop ${scobj_hpath}/voltage/hilimit noResponse ${ns}::noResponse ${scobj_hpath} hsetprop ${scobj_hpath}/voltage/hilimit check ${ns}::checkrange ${scobj_hpath} hsetprop ${scobj_hpath}/voltage/hilimit control true hsetprop ${scobj_hpath}/voltage/hilimit data true hsetprop ${scobj_hpath}/voltage/hilimit mutable true hsetprop ${scobj_hpath}/voltage/hilimit nxsave true hsetprop ${scobj_hpath}/voltage/hilimit lowerlimit 0 hsetprop ${scobj_hpath}/voltage/hilimit upperlimit 165 hsetprop ${scobj_hpath}/voltage/hilimit units V hsetprop ${scobj_hpath}/voltage/hilimit oldval 0.0 hsetprop ${scobj_hpath}/voltage/hilimit klass "parameter" hsetprop ${scobj_hpath}/voltage/hilimit sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/voltage/hilimit type "part" hsetprop ${scobj_hpath}/voltage/hilimit nxalias "${name}_voltage_hilimit" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/voltage/hilimit 1 ${sct_controller} write ${scobj_hpath}/voltage/hilimit hsetprop ${scobj_hpath}/voltage/hilimit simulated false } else { ::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A" hsetprop ${scobj_hpath}/voltage/hilimit simulated true } hfactory ${scobj_hpath}/voltage/lolimit plain user float hsetprop ${scobj_hpath}/voltage/lolimit read ${ns}::getValue ${scobj_hpath} rdValue {SOURCE:VOLTAGE:LIMIT:LOW?} hsetprop ${scobj_hpath}/voltage/lolimit rdValue ${ns}::rdValue ${scobj_hpath} hsetprop ${scobj_hpath}/voltage/lolimit write ${ns}::setValue ${scobj_hpath} noResponse {SOURCE:VOLTAGE:LIMIT:LOW } hsetprop ${scobj_hpath}/voltage/lolimit noResponse ${ns}::noResponse ${scobj_hpath} hsetprop ${scobj_hpath}/voltage/lolimit check ${ns}::checkrange ${scobj_hpath} hsetprop ${scobj_hpath}/voltage/lolimit control true hsetprop ${scobj_hpath}/voltage/lolimit data true hsetprop ${scobj_hpath}/voltage/lolimit mutable true hsetprop ${scobj_hpath}/voltage/lolimit nxsave true hsetprop ${scobj_hpath}/voltage/lolimit units V hsetprop ${scobj_hpath}/voltage/lolimit oldval 0.0 hsetprop ${scobj_hpath}/voltage/lolimit klass "parameter" hsetprop ${scobj_hpath}/voltage/lolimit sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/voltage/lolimit type "part" hsetprop ${scobj_hpath}/voltage/lolimit nxalias "${name}_voltage_lolimit" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/voltage/lolimit 1 ${sct_controller} write ${scobj_hpath}/voltage/lolimit hsetprop ${scobj_hpath}/voltage/lolimit simulated false } else { ::scobj::keysight_N8740A::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for keysight_N8740A" hsetprop ${scobj_hpath}/voltage/lolimit 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} "instrument" ${simulation_flag} ${ip_address} ${tcp_port} } clientput "file evaluation of keysight_N8740A_sct.tcl" ::scobj::keysight_N8740A::sics_log 9 "file evaluation of keysight_N8740A_sct.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 "instrument" 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" }