Modified the last two of the old drivers for the new sics_config.ini format.
This commit is contained in:
@ -664,7 +664,7 @@ debug_log "Registering node $nodeName for write callback"
|
||||
# @param name, the name of the multimeter (eg mm1)
|
||||
# @param IP, the IP address of the device, this can be a hostname, (eg ca1-kowari)
|
||||
# @param port, the IP protocol port number of the device
|
||||
proc add_k2700 {name IP port terminator {_tol 1.0} {CID 1} {CTYPE V} } {
|
||||
proc add_keithley_2700 {name IP port terminator {_tol 1.0} {CID 1} {CTYPE V} } {
|
||||
set fd [open "../log/k2700.log" a]
|
||||
if {[SplitReply [environment_simulation]]=="false"} {
|
||||
puts $fd "makesctcontroller sct_k2700 std ${IP}:$port"
|
||||
@ -680,26 +680,88 @@ set fd [open "../log/k2700.log" w]
|
||||
puts $fd "file evaluation of sct_keithley_2700.tcl"
|
||||
close $fd
|
||||
|
||||
if {[ catch {
|
||||
if { [ info exists ::config_dict ] } {
|
||||
dict for {secname secinfo} $::config_dict {
|
||||
if { [dict exists $secinfo "driver"] && ([dict get $secinfo "driver"] == "k2700") } {
|
||||
if { [ dict get $::secinfo enabled ] } {
|
||||
set name [dict get $::secinfo name]
|
||||
set IP [dict get $::secinfo ip]
|
||||
set PORT [dict get $::secinfo port]
|
||||
set term [dict get $::secinfo terminator]
|
||||
set tol [dict get $::secinfo tol]
|
||||
set cid [dict get $::secinfo id]
|
||||
set ctype [dict get $::secinfo type]
|
||||
namespace eval ::scobj::add_keithley_2700 {
|
||||
set debug_threshold 5
|
||||
}
|
||||
proc ::scobj::add_keithley_2700::sics_log {debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold ${::scobj::add_keithley_2700::debug_threshold}
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
sicslog "::scobj::add_keithley_2700::${debug_string}"
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
add_k2700 $name $IP $PORT $term $tol $cid $ctype
|
||||
clientput "file evaluation of sct_keithley_2700.tcl"
|
||||
::scobj::add_keithley_2700::sics_log 9 "file evaluation of sct_keithley_2700.tcl"
|
||||
|
||||
proc ::scobj::add_keithley_2700::read_config {} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::add_keithley_2700"
|
||||
dict for {k v} $::config_dict {
|
||||
if { [dict exists $v "implementation"] } {
|
||||
if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } {
|
||||
continue
|
||||
}
|
||||
set name [dict get $v name]
|
||||
set enabled [string tolower [dict get $v "enabled"]]
|
||||
set implementation [dict get $v "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"] "keithley_2700"] } {
|
||||
if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } {
|
||||
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
|
||||
set asyncqueue "null"
|
||||
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
|
||||
} elseif { [dict exists $v "asyncqueue"] } {
|
||||
set asyncqueue [dict get $v "asyncqueue"]
|
||||
} else {
|
||||
if { [dict exists $v "asyncprotocol"] } {
|
||||
set asyncprotocol [dict get $v "asyncprotocol"]
|
||||
} else {
|
||||
set asyncprotocol ${name}_protocol
|
||||
MakeAsyncProtocol ${asyncprotocol}
|
||||
if { [dict exists $v "terminator"] } {
|
||||
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
|
||||
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
|
||||
}
|
||||
}
|
||||
set asyncqueue ${name}_queue
|
||||
set IP [dict get $v ip]
|
||||
set PORT [dict get $v port]
|
||||
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
|
||||
if { [dict exists $v "timeout"] } {
|
||||
${asyncqueue} timeout "[dict get $v "timeout"]"
|
||||
}
|
||||
}
|
||||
set arg_list [list]
|
||||
foreach arg {term tol id datype} {
|
||||
if {[dict exists $v $arg]} {
|
||||
lappend arg_list "[dict get $v $arg]"
|
||||
} else {
|
||||
${ns}::sics_log 9 "Missing configuration value $arg"
|
||||
error "Missing configuration value $arg"
|
||||
}
|
||||
}
|
||||
add_keithley_2700 ${name} "aqadapter" ${asyncqueue} {*}$arg_list
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} message ]} {
|
||||
clientput "ERROR: $message"
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
if { [info exists ::config_dict] } {
|
||||
::scobj::add_keithley_2700::read_config
|
||||
} else {
|
||||
::scobj::add_keithley_2700::sics_log 5 "No config dict"
|
||||
}
|
||||
|
||||
|
||||
namespace import ::scobj::k2700::*
|
||||
|
@ -123,36 +123,216 @@ close $fd
|
||||
# NOTE: If the interval is negative then the multimeter will be polled on every cycle of
|
||||
# the SICS task loop.
|
||||
proc MakeProtek {name IP PORT {scale 1.0} {offset 0.0} {interval 0.5} {cbFunc "return idle"}} {
|
||||
set sctName "sct_$name"
|
||||
set sobjName "$name"
|
||||
set soState "so_state_$name"
|
||||
clientput "MakeSICSObj $sobjName SCT_OBJECT"
|
||||
MakeSICSObj $soState SCT_OBJECT
|
||||
MakeSICSObj $sobjName SCT_OBJECT user float
|
||||
sicslist setatt $sobjName long_name $sobjName
|
||||
set catch_status [ catch {
|
||||
set sctName "sct_$name"
|
||||
set sobjName "$name"
|
||||
set soState "so_state_$name"
|
||||
clientput "MakeSICSObj $sobjName SCT_OBJECT"
|
||||
MakeSICSObj $soState SCT_OBJECT
|
||||
MakeSICSObj $sobjName SCT_OBJECT user float
|
||||
sicslist setatt $sobjName long_name $sobjName
|
||||
|
||||
hfactory /sics/$soState/state plain user text
|
||||
hsetprop /sics/$soState/state read rqStateRep
|
||||
hsetprop /sics/$soState/state rdStateRep rdStateRep
|
||||
hsetprop /sics/$soState/state oldval "UNKNOWN"
|
||||
hsetprop /sics/$sobjName read rqVal "reportVal"
|
||||
hsetprop /sics/$sobjName reportVal ProtekMainDisplay /sics/$soState callBack
|
||||
hsetprop /sics/$sobjName callBack $cbFunc
|
||||
hfactory /sics/$sobjName/scale plain user float
|
||||
hset /sics/$sobjName/scale $scale
|
||||
hfactory /sics/$sobjName/offset plain user float
|
||||
hset /sics/$sobjName/offset $offset
|
||||
hsetprop /sics/$sobjName oldval "UNKNOWN"
|
||||
hfactory /sics/$soState/state plain user text
|
||||
hsetprop /sics/$soState/state read rqStateRep
|
||||
hsetprop /sics/$soState/state rdStateRep rdStateRep
|
||||
hsetprop /sics/$soState/state oldval "UNKNOWN"
|
||||
hsetprop /sics/$sobjName read rqVal "reportVal"
|
||||
hsetprop /sics/$sobjName reportVal ProtekMainDisplay /sics/$soState callBack
|
||||
hsetprop /sics/$sobjName callBack $cbFunc
|
||||
hfactory /sics/$sobjName/scale plain user float
|
||||
hset /sics/$sobjName/scale $scale
|
||||
hfactory /sics/$sobjName/offset plain user float
|
||||
hset /sics/$sobjName/offset $offset
|
||||
hsetprop /sics/$sobjName oldval "UNKNOWN"
|
||||
|
||||
sicslist setatt $sobjName klass sample
|
||||
::scobj::hinitprops $sobjName
|
||||
sicslist setatt $sobjName long_name $name
|
||||
if {[SplitReply [environment_simulation]] == false} {
|
||||
makesctcontroller $sctName protek608 $IP:$PORT
|
||||
sicslist setatt $sobjName klass sample
|
||||
::scobj::hinitprops $sobjName
|
||||
sicslist setatt $sobjName long_name $name
|
||||
if {[SplitReply [environment_simulation]] == false} {
|
||||
makesctcontroller $sctName protek608 $IP:$PORT
|
||||
hsetprop /sics/$soState/state IP $IP
|
||||
hsetprop /sics/$soState/state PORT $PORT
|
||||
$sctName poll /sics/$soState/state $interval
|
||||
$sctName poll /sics/$sobjName $interval
|
||||
$sctName poll /sics/$soState/state $interval
|
||||
$sctName poll /sics/$sobjName $interval
|
||||
}
|
||||
} catch_message ] {
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
return /sics/$sobjName
|
||||
}
|
||||
|
||||
|
||||
proc add_protekmm {name IP PORT CTYPE CID {scale 1.0} {offset 0.0} {interval 0.5} {cbFunc "return idle"}} {
|
||||
set catch_status [ catch {
|
||||
MakeProtek $name $IP $PORT $scale $offset $interval $cbFunc
|
||||
hsetprop /sics/$name permlink data_set ${CTYPE}${CID}S1
|
||||
} catch_message ] {
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
}
|
||||
|
||||
namespace eval ::scobj::add_protekmm {
|
||||
set debug_threshold 5
|
||||
}
|
||||
proc ::scobj::add_protekmm::sics_log {debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold ${::scobj::add_protekmm::debug_threshold}
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
sicslog "::scobj::add_protekmm::${debug_string}"
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
clientput "file evaluation of sct_protekmm.tcl"
|
||||
::scobj::add_protekmm::sics_log 9 "file evaluation of sct_protekmm.tcl"
|
||||
|
||||
proc ::scobj::add_protekmm::read_config {} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::add_protekmm"
|
||||
dict for {k v} $::config_dict {
|
||||
if { [dict exists $v "implementation"] } {
|
||||
if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } {
|
||||
continue
|
||||
}
|
||||
set name [dict get $v name]
|
||||
set enabled [string tolower [dict get $v "enabled"]]
|
||||
set implementation [dict get $v "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"] "protekmm"] } {
|
||||
if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } {
|
||||
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
|
||||
set asyncqueue "null"
|
||||
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
|
||||
} elseif { [dict exists $v "asyncqueue"] } {
|
||||
set asyncqueue [dict get $v "asyncqueue"]
|
||||
} else {
|
||||
if { [dict exists $v "asyncprotocol"] } {
|
||||
set asyncprotocol [dict get $v "asyncprotocol"]
|
||||
} else {
|
||||
set asyncprotocol ${name}_protocol
|
||||
MakeAsyncProtocol ${asyncprotocol}
|
||||
if { [dict exists $v "terminator"] } {
|
||||
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
|
||||
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
|
||||
}
|
||||
}
|
||||
set asyncqueue ${name}_queue
|
||||
set IP [dict get $v ip]
|
||||
set PORT [dict get $v port]
|
||||
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
|
||||
if { [dict exists $v "timeout"] } {
|
||||
${asyncqueue} timeout "[dict get $v "timeout"]"
|
||||
}
|
||||
}
|
||||
set arg_list [list]
|
||||
foreach arg {name ip port datype id scal offset interval cbfunc} {
|
||||
if {[dict exists $v $arg]} {
|
||||
lappend arg_list "[dict get $v $arg]"
|
||||
} else {
|
||||
${ns}::sics_log 9 "Missing configuration value $arg"
|
||||
error "Missing configuration value $arg"
|
||||
}
|
||||
}
|
||||
add_protekmm ${name} "aqadapter" ${asyncqueue} {*}$arg_list
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
if { [info exists ::config_dict] } {
|
||||
::scobj::add_protekmm::read_config
|
||||
} else {
|
||||
::scobj::add_protekmm::sics_log 5 "No config dict"
|
||||
}
|
||||
# Check config_dict for configuration
|
||||
namespace eval ::scobj::add_protekmm {
|
||||
set debug_threshold 5
|
||||
}
|
||||
proc ::scobj::add_protekmm::sics_log {debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold ${::scobj::add_protekmm::debug_threshold}
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
sicslog "::scobj::add_protekmm::${debug_string}"
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
clientput "file evaluation of sct_protekmm.tcl"
|
||||
::scobj::add_protekmm::sics_log 9 "file evaluation of sct_protekmm.tcl"
|
||||
|
||||
proc ::scobj::add_protekmm::read_config {} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::add_protekmm"
|
||||
dict for {k v} $::config_dict {
|
||||
if { [dict exists $v "implementation"] } {
|
||||
if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } {
|
||||
continue
|
||||
}
|
||||
set name [dict get $v name]
|
||||
set enabled [string tolower [dict get $v "enabled"]]
|
||||
set implementation [dict get $v "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"] "add_protekmm"] } {
|
||||
if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } {
|
||||
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
|
||||
set asyncqueue "null"
|
||||
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
|
||||
} elseif { [dict exists $v "asyncqueue"] } {
|
||||
set asyncqueue [dict get $v "asyncqueue"]
|
||||
} else {
|
||||
if { [dict exists $v "asyncprotocol"] } {
|
||||
set asyncprotocol [dict get $v "asyncprotocol"]
|
||||
} else {
|
||||
set asyncprotocol ${name}_protocol
|
||||
MakeAsyncProtocol ${asyncprotocol}
|
||||
if { [dict exists $v "terminator"] } {
|
||||
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
|
||||
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
|
||||
}
|
||||
}
|
||||
set asyncqueue ${name}_queue
|
||||
set IP [dict get $v ip]
|
||||
set PORT [dict get $v port]
|
||||
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
|
||||
if { [dict exists $v "timeout"] } {
|
||||
${asyncqueue} timeout "[dict get $v "timeout"]"
|
||||
}
|
||||
}
|
||||
set arg_list [list]
|
||||
foreach arg {name ip port datype id scale offset interval cbfunc} {
|
||||
if {[dict exists $v $arg]} {
|
||||
lappend arg_list "[dict get $v $arg]"
|
||||
} else {
|
||||
${ns}::sics_log 9 "Missing configuration value $arg"
|
||||
error "Missing configuration value $arg"
|
||||
}
|
||||
}
|
||||
add_protekmm ${name} "aqadapter" ${asyncqueue} {*}$arg_list
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
if { [info exists ::config_dict] } {
|
||||
::scobj::add_protekmm::read_config
|
||||
} else {
|
||||
::scobj::add_protekmm::sics_log 5 "No config dict"
|
||||
}
|
||||
|
Reference in New Issue
Block a user