Make all sct drivers.
This commit is contained in:
@@ -180,7 +180,7 @@ proc ::scobj::mercury_scpi::rdText {tc_root} {
|
||||
sct oldval ${data}
|
||||
sct update ${data}
|
||||
sct utime readtime
|
||||
}
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
@@ -212,7 +212,7 @@ proc ::scobj::mercury_scpi::rdValue {tc_root} {
|
||||
sct oldval ${data}
|
||||
sct update ${data}
|
||||
sct utime readtime
|
||||
}
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
@@ -421,7 +421,6 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name id permlink tol valve
|
||||
${sct_controller} poll ${scobj_hpath}/Loop1/sensor 1
|
||||
${sct_controller} poll ${scobj_hpath}/Loop1/setpoint 5
|
||||
${sct_controller} write ${scobj_hpath}/Loop1/setpoint
|
||||
ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor ${sct_controller}
|
||||
} else {
|
||||
::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi"
|
||||
}
|
||||
@@ -498,7 +497,6 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name id permlink tol valve
|
||||
${sct_controller} poll ${scobj_hpath}/Loop2/sensor 1
|
||||
${sct_controller} poll ${scobj_hpath}/Loop2/setpoint 5
|
||||
${sct_controller} write ${scobj_hpath}/Loop2/setpoint
|
||||
ansto_makesctdrive ${name}_Loop2_setpoint ${scobj_hpath}/Loop2/setpoint ${scobj_hpath}/Loop2/sensor ${sct_controller}
|
||||
} else {
|
||||
::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi"
|
||||
}
|
||||
@@ -575,7 +573,6 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name id permlink tol valve
|
||||
${sct_controller} poll ${scobj_hpath}/Loop3/sensor 1
|
||||
${sct_controller} poll ${scobj_hpath}/Loop3/setpoint 5
|
||||
${sct_controller} write ${scobj_hpath}/Loop3/setpoint
|
||||
ansto_makesctdrive ${name}_Loop3_setpoint ${scobj_hpath}/Loop3/setpoint ${scobj_hpath}/Loop3/sensor ${sct_controller}
|
||||
} else {
|
||||
::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi"
|
||||
}
|
||||
@@ -652,7 +649,6 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name id permlink tol valve
|
||||
${sct_controller} poll ${scobj_hpath}/Loop4/sensor 1
|
||||
${sct_controller} poll ${scobj_hpath}/Loop4/setpoint 5
|
||||
${sct_controller} write ${scobj_hpath}/Loop4/setpoint
|
||||
ansto_makesctdrive ${name}_Loop4_setpoint ${scobj_hpath}/Loop4/setpoint ${scobj_hpath}/Loop4/sensor ${sct_controller}
|
||||
} else {
|
||||
::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi"
|
||||
}
|
||||
@@ -700,12 +696,18 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name id permlink tol valve
|
||||
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/Valve/sensor 5
|
||||
${sct_controller} write ${scobj_hpath}/Valve/setpoint
|
||||
ansto_makesctdrive ${name}_Valve_setpoint ${scobj_hpath}/Valve/setpoint ${scobj_hpath}/Valve/sensor ${sct_controller}
|
||||
} else {
|
||||
::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi"
|
||||
}
|
||||
hsetprop ${scobj_hpath} klass environment
|
||||
hsetprop ${scobj_hpath} debug_threshold 5
|
||||
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
|
||||
ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor ${sct_controller}
|
||||
ansto_makesctdrive ${name}_Loop2_setpoint ${scobj_hpath}/Loop2/setpoint ${scobj_hpath}/Loop2/sensor ${sct_controller}
|
||||
ansto_makesctdrive ${name}_Loop3_setpoint ${scobj_hpath}/Loop3/setpoint ${scobj_hpath}/Loop3/sensor ${sct_controller}
|
||||
ansto_makesctdrive ${name}_Loop4_setpoint ${scobj_hpath}/Loop4/setpoint ${scobj_hpath}/Loop4/sensor ${sct_controller}
|
||||
ansto_makesctdrive ${name}_Valve_setpoint ${scobj_hpath}/Valve/setpoint ${scobj_hpath}/Valve/sensor ${sct_controller}
|
||||
}
|
||||
# mkDriver hook code goes here
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
@@ -744,14 +746,17 @@ clientput "file evaluation of sct_mercury_scpi.tcl"
|
||||
proc ::scobj::mercury_scpi::read_config {} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::mercury_scpi"
|
||||
dict for {k v} $::config_dict {
|
||||
if { [dict exists $v "implementation"] } {
|
||||
if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } {
|
||||
dict for {k u} $::config_dict {
|
||||
if { [dict exists $u "implementation"] } {
|
||||
if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {
|
||||
continue
|
||||
}
|
||||
set name [dict get $v name]
|
||||
set enabled [string tolower [dict get $v "enabled"]]
|
||||
set implementation [dict get $v "implementation"]
|
||||
set enabled [string tolower [dict get $u "enabled"]]
|
||||
if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {
|
||||
continue
|
||||
}
|
||||
set name [dict get $u name]
|
||||
set implementation [dict get $u "implementation"]
|
||||
if { !([dict exists $::config_dict $implementation]) } {
|
||||
continue
|
||||
}
|
||||
@@ -760,40 +765,52 @@ proc ::scobj::mercury_scpi::read_config {} {
|
||||
continue
|
||||
}
|
||||
if { [string equal -nocase [dict get $v "driver"] "mercury_scpi"] } {
|
||||
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
|
||||
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"]
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
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"]"
|
||||
}
|
||||
} 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 arg_list [list]
|
||||
foreach arg {id permlink tol valve_tol} {
|
||||
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"
|
||||
}
|
||||
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]
|
||||
set missing_list [list]
|
||||
foreach arg {id permlink tol valve_tol} {
|
||||
if {[dict exists $u $arg]} {
|
||||
lappend arg_list "[dict get $u $arg]"
|
||||
} elseif {[dict exists $v $arg]} {
|
||||
lappend arg_list "[dict get $v $arg]"
|
||||
} else {
|
||||
${ns}::sics_log 9 "Missing configuration value $arg"
|
||||
lappend missing_list $arg
|
||||
}
|
||||
}
|
||||
if { [llength $missing_list] > 0 } {
|
||||
error "$name is missing configuration values $missing_list"
|
||||
}
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
add_mercury_scpi ${name} ${IP} ${PORT} {*}$arg_list
|
||||
} else {
|
||||
add_mercury_scpi ${name} "aqadapter" ${asyncqueue} {*}$arg_list
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user